ok
Direktori : /proc/thread-self/root/home2/selectio/public_html/ramali.in/dashboard/public/ |
Current File : //proc/thread-self/root/home2/selectio/public_html/ramali.in/dashboard/public/add-shipping-form.php |
<?php include_once('includes/functions.php'); $function = new functions; include_once('includes/custom-functions.php'); $fn = new custom_functions; ?> <?php if (isset($_POST['btnAdd'])) { if (ALLOW_MODIFICATION == 0 && !defined(ALLOW_MODIFICATION)) { echo '<label class="alert alert-danger">This operation is not allowed in demo panel!.</label>'; return false; } if ($permissions['subcategories']['create'] == 1) { $target_path = './upload/images/'; if (!is_dir($target_path)) { mkdir($target_path, 0777, true); } $subcategory_name = $db->escapeString($fn->xss_clean($_POST['subcategory_name'])); $slug = $db->escapeString($function->slugify($fn->xss_clean($_POST['subcategory_name']))); $sql = "SELECT slug FROM subcategory"; $db->sql($sql); $res = $db->getResult(); $i = 1; foreach ($res as $row) { if ($slug == $row['slug']) { $slug = $slug . '-' . $i; $i++; } } $state = $db->escapeString($fn->xss_clean($_POST['state_id'])); $district = $db->escapeString($fn->xss_clean($_POST['district'])); count($district); error_log("Total_Count".count($district)); // create array variable to handle error $error = array(); if (empty($state)) { $error['state'] = " <span class='label label-danger'>Required!</span>"; } if (!empty($state)) { // insert new data to menu table $sql_query = "INSERT INTO shipping (state, amount) VALUES('$state', '$amount')"; // Execute query $db->sql($sql_query); // store result $result = $db->getResult(); if (!empty($result)) { $result = 0; } else { $result = 1; } if ($result == 1) { $error['success'] = " <section class='content-header'><span class='label label-success'>Shipping Details Added Successfully</span></section>"; } else { $error['success'] = " <span class='label label-danger'>Failed add Shipping</span>"; } } } else { $error['check_permission'] = " <section class='content-header'><span class='label label-danger'>You have no permission to create subcategory</span></section>"; } } if (isset($_POST['btnCancel'])) { header("location: shipping-details.php"); } ?> <section class="content-header"> <h1>Add Shipping Details<small><a href='subcategories.php'> <i class='fa fa-angle-double-left'></i> Back to Shipping details</a></small></h1> <?php echo isset($error['success']) ? $error['success'] : ''; ?> <ol class="breadcrumb"> <li><a href="home.php"><i class="fa fa-home"></i> Home</a></li> </ol> <hr /> </section> <section class="content"> <div class="row"> <div class="col-md-6"> <?php if ($permissions['subcategories']['create'] == 0) { ?> <div class="alert alert-danger">You have no permission to State.</div> <?php } ?> <!-- general form elements --> <div class="box box-primary"> <div class="box-header with-border"> <h3 class="box-title">Add State</h3> </div><!-- /.box-header --> <!-- form start --> <form method="post" id="add_state" > <div class="box-body"> <div class="form-group"> <label for="exampleInputEmail1">State</label> <input type="text" class="form-control" name="state" required> </div> </div> <div class="box-footer"> <button type="submit" class="btn btn-primary" name="btnAdd">Add State</button> <input type="reset" class="btn-warning btn" value="Clear" /> </div> </form> </div><!-- /.box --> <?php echo isset($error['check_permission']) ? $error['check_permission'] : ''; ?> </div> <div class="col-md-6"> <?php if ($permissions['subcategories']['create'] == 0) { ?> <div class="alert alert-danger">You have no permission to create Shipping Details.</div> <?php } ?> <!-- general form elements --> <div class="box box-primary"> <div class="box-header with-border"> <h3 class="box-title">Add Shipping details</h3> </div><!-- /.box-header --> <!-- form start --> <form method="post" id="amount_add" enctype="multipart/form-data" > <div class="box-body"> <div class="form-group"> <label for="exampleInputEmail1">Select State</label> <select class="form-control" id="State_option" name="state_id" required=""> </select> </div> <div class="co-md-12"> <div class="row"> <div class="col-md-5"> <div class="form-group"> <label for="exampleInputEmail1">District</label><?php echo isset($error['state']) ? $error['state'] : ''; ?> <input type="text" class="form-control" name="district[]" required> </div> </div> <div class="col-md-5"> <div class="form-group"> <label for="exampleInputEmail1">Weight Amount</label> <input type="number" class="form-control" name="weight_amount[]" required> </div> </div> <div class="col-md-2"> <img src="images/plus.png" onclick="add_district()" alt="No image" style="margin-top: 40%;" /> </div> </div> <div id="add_row"> </div> </div> </div><!-- /.box-body --> <div class="box-footer"> <button type="submit" class="btn btn-primary" >Add Amount</button> <input type="reset" class="btn-warning btn" value="Clear" /> </div> </form> </div><!-- /.box --> <?php echo isset($error['check_permission']) ? $error['check_permission'] : ''; ?> </div> </div> </section> <div class="separator"> </div> <?php $db->disconnect(); ?> <script> $(document).ready(function(){ dropdown(); }); function dropdown(){ console.log('IS Wrking this functions'); $.ajax({ url: 'api/add_shipping.php', type: 'post', dataType: 'json', data:{type:'select_state'}, success: function (response) { if(response['status']==200){ $("#State_option").html(response['option']); }else{ $("#State_option").html(response['option']); } } }); } function reset_row(){ $("#add_row").empty(); } $(document).on('click', '.remove_class', function() { $(this).closest('.row').remove(); }); function add_district(){ html=' <div class="row"><div class="col-md-5"><div class="form-group"><label for="exampleInputEmail1">District</label><input type="text" class="form-control" name="district[]" required></div></div><div class="col-md-5"><div class="form-group"><label for="exampleInputEmail1">Weight Amount</label><input type="number" class="form-control" name="weight_amount[]" required></div></div><div class="col-md-2"><img src="images/remove.png" class="remove_class" alt="No image" style="margin-top: 40%;" /></div></div>'; $("#add_row").append(html); } $('#add_state').on('submit', function(e){ console.log("Click And Form Working"); e.preventDefault(); $('#loading-div').show(); $('#content-div').hide(); $('#final_submit').prop('disabled', true); var formData = new FormData(this); formData.append('type', 'add_state'); $.ajax({ url: 'api/add_shipping.php', type: 'post', dataType: 'json', data: formData, cache: false, contentType: false, processData: false, enctype: 'multipart/form-data', success: function (response) { if(response['status']==200){ alert(response['message']); $("#add_state").trigger("reset"); $("#done1").trigger("reset"); $('#loading-div').hide(); $('#content-div').show(); dropdown(); }else{ alert(response['message']); $('#loading-div').hide(); $('#content-div').show(); dropdown(); } } }); }); $('#amount_add').on('submit', function(e){ console.log("Click And Form Working"); e.preventDefault(); $('#loading-div').show(); $('#content-div').hide(); $('#final_submit').prop('disabled', true); var formData = new FormData(this); formData.append('type', 'amount_add'); $.ajax({ url: 'api/add_shipping.php', type: 'post', dataType: 'json', data: formData, cache: false, contentType: false, processData: false, enctype: 'multipart/form-data', success: function (response) { if(response['status']==200){ alert(response['message']); $("#amount_add").trigger("reset"); $('#loading-div').hide(); $('#content-div').show(); dropdown(); reset_row(); }else{ alert(response['message']); $('#loading-div').hide(); $('#content-div').show(); dropdown(); } } }); }); </script> </script>