ok

Mini Shell

Direktori : /home2/selectio/public_html/ramali.in/dashboard/public/
Upload File :
Current File : //home2/selectio/public_html/ramali.in/dashboard/public/edit-shipping-form.php

<?php
include_once('includes/functions.php');
$function = new functions;
include_once('includes/custom-functions.php');
$fn = new custom_functions;
?>
<?php
$ID = (isset($_GET['id'])) ? $db->escapeString($fn->xss_clean($_GET['id'])) : "";


if (isset($_POST['btnEdit'])) {
    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']['update'] == 1) {
        
        $state = $db->escapeString($fn->xss_clean($_POST['state']));
        $district = $db->escapeString($fn->xss_clean($_POST['district']));
        $amount = $db->escapeString($fn->xss_clean($_POST['amount']));
        $status = $db->escapeString($fn->xss_clean($_POST['status']));
        $id = $db->escapeString($fn->xss_clean($_GET['id']));
       
      error_log($status);
        // create array variable to handle error
        $error = array();
        if (empty($state)) {
            $error['state'] = " <span class='label label-danger'>Required!</span>";
        }
        if (empty($amount)) {
            $error['amount'] = " <span class='label label-danger'>Required!</span>";
        }
        if (empty($status)) {
            $error['status'] = " <span class='label label-danger'>Required!</span>";
        }


        if (!empty($amount)){
            
            error_log("UPDATE shipping SET 
                district='".$district."', 
                state_id='".$state."', 
                weight_amount = '".$amount."', 
                status = '".$status."' 
                WHERE id ='".$ID."'");

                $sql_query = "UPDATE shipping SET
                district='".$district."', 
                state_id='".$state."', 
                weight_amount = '".$amount."', 
                status = '".$status."' 
                WHERE id ='".$ID."'";
                
                $db->sql($sql_query);
                $update_result = $db->getResult();
                
                if (!empty($update_result)) {
                    $update_result = 0;
                } else {
                    $update_result = 1;
                }
            

            if ($update_result == 1) {
                $error['update_subcategory'] = " <section class='content-header'><span class='label label-success'>Shipping updated Successfully</span></section>";
            } else {
                $error['update_subcategory'] = " <span class='label label-danger'>Failed update Shipping</span>";
            }
        }
    } else {
        $error['check_permission'] = " <section class='content-header'><span class='label label-danger'>You have no permission to update subcategory</span></section>";
    }
}

$data = array();

error_log("SELECT * FROM shipping WHERE id =" . $ID);

$sql_query = "SELECT * FROM shipping WHERE id =" . $ID;
$db->sql($sql_query);
$res_query = $db->getResult();
if (isset($_POST['btnCancel'])) { ?>
    <script>
        window.location.href = "shipping-details.php";
    </script>
<?php } ?>
<section class="content-header">
    <h1>
        Edit Shipping <small><a href='shipping-details.php'> <i class='fa fa-angle-double-left'></i>&nbsp;&nbsp;&nbsp;Back to Shipping</a></small></h1>
    <small><?php echo isset($error['update_subcategory']) ? $error['update_subcategory'] : ''; ?></small>
    <ol class="breadcrumb">
        <li><a href="home.php"><i class="fa fa-home"></i> Home</a></li>
    </ol>
</section>

<section class="content">
    <!-- Main row -->
    <div class="row">
        <div class="col-md-6">
            <?php if ($permissions['subcategories']['update'] == 0) { ?>
                <div class="alert alert-danger topmargin-sm">You have no permission to update subcategory.</div>
            <?php } ?>
            <!-- general form elements -->
            <div class="box box-primary">
                <div class="box-header with-border">
                    <h3 class="box-title">Edit Shipping</h3>
                </div><!-- /.box-header -->
                <!-- form start -->
                <form method="post" enctype="multipart/form-data" id="edit_subcategory_form">
                    <div class="box-body">
                        
                        <div class="form-group">
                            <label for="style">Status</label>
                            <select id="state_id" onchange="selectS_State()" name="state" class="form-control">
                                
                                <?php  $selected = "";
                                
                                    $state_query = "SELECT * FROM tb_state WHERE status=1";
                                    $db->sql($state_query);
                                    $res_state = $db->getResult();
                                foreach($res_state as $state_data){
                                    ?>
                                    <option value="<?= $state_data['id'] ?>" <?php if($state_data['id']==$res_query[0]['state_id']){  echo "selected"; } ?> > <?=$state_data['state']?> </option>
                                    <?php
                                        
                                }
                                    ?>
                            </select>
                            <br>
                        </div>
                        
                        
                        <div class="form-group">
                            <label for="exampleInputEmail1">District Name</label>
                            <div class="msg"><?php echo isset($error['name']) ? $error['name'] : ''; ?></div>
                            <input type="text" class="form-control" name="district" value="<?php echo $res_query[0]['district']; ?>">
                        </div>
                        <div class="form-group">
                            <label for="exampleInputEmail1">Per Weight Amount</label>
                            <div class="msg"><?php echo isset($error['subtitle']) ? $error['amount'] : ''; ?></div>
                            <input type="number" class="form-control" name="amount" value="<?php echo $res_query[0]['weight_amount']; ?>">
                        </div>
                        
                        <div class="form-group">
                            <label for="style">Status</label>
                            <select name="status" class="form-control">
                                
                                <?php  $selected = "";
                                    if($res_query[0]['status']==0){ 
                                        $selected =  "selected"; } 
                                    ?>
                                
                                <option value="1" <?= $selected  ?> > Active</option>
                                <option value="0" <?= $selected  ?> > Inactive </option>
                            </select>
                            <br>
                        </div>
                       
                    </div><!-- /.box-body -->

                    <div class="box-footer">
                        <button type="submit" class="btn btn-primary" name="btnEdit">Update</button>
                        <button type="submit" class="btn btn-danger" name="btnCancel">Cancel</button>
                    </div>
                </form>
            </div><!-- /.box -->
            <?php echo isset($error['check_permission']) ? $error['check_permission'] : ''; ?>
        </div>
    </div>
</section>

<div class="separator"> </div>

<script src="dist/js/jquery.validate.min.js"></script>
<script>
    $('#edit_subcategory_form').validate({
        rules: {
            category: "required",
            name: "required",
            subtitle: "required",
        }
    });
    var data = $('.msg').html();
    if (data != '') {
        $('.msg').show().delay(3000).fadeOut();
    }
    
   
</script>

<script>

    $(document).ready(function(){
        selectS_State();
    });

     function selectS_State(){
        alert(id);
        var id = $("#state_id").val();
        alert(id);
        
    //      $.ajax({
    //     url: 'ui-api/size-api.php',
    //     type: 'post',
    //     data:{pro_id:pro_id,type:'add_size'},
    //     dataType: 'json',
    //     success: function (response) {
    //         console.log(response);
    //         $("#Catelogue_pieces").html(response['catalogue_prices']);
    //       $('.size-price').html(response['price']);
    //       $('#input_vlaue').html(response['product_variant09']);
    //       $('#product_images').html(response['product_images']);
    //       $('.total-price').html(response['discount_price']);
            
    //     }
    // });
        
    }
    
</script>


<?php $db->disconnect(); ?>

Zerion Mini Shell 1.0