<?php
include('header.php');
if ($_SESSION['usertype'] != "ADMIN2") {
    ?>
        <script>
            window.location.href = 'index.php';
        </script>
        <?php

        
        die;
    }
    

if (isset($_GET['userid']) && $_GET['userid'] != NUL) {
    $id = base64_decode($_GET['userid']);
    $res = mysqli_query($conn, "SELECT * FROM `usertable` WHERE userid='$id'");
    $data = mysqli_fetch_assoc($res);
}


if (isset($_POST['ahkweb'])  && $_POST['ahkweb'] == "ahkwebsolutions") {
    $name = mysqli_real_escape_string($conn,$_POST['name']);
    $email = mysqli_real_escape_string($conn,$_POST['email']);
    $status = mysqli_real_escape_string($conn,$_POST['status']);
    $userid = mysqli_real_escape_string($conn,$_POST['userid']);
    $city = mysqli_real_escape_string($conn,$_POST['city']);
    $state = mysqli_real_escape_string($conn,$_POST['state']);
    $phone = mysqli_real_escape_string($conn, $_POST['phone']);
    $mobile = mysqli_real_escape_string($conn, $_POST['mobile']);
    $dob = mysqli_real_escape_string($conn, $_POST['dob']);
    $names = mysqli_real_escape_string($conn, $_POST['names']);
    $address = mysqli_real_escape_string($conn, $_POST['address']);
    $child = mysqli_real_escape_string($conn, $_POST['child']);
    $voter = mysqli_real_escape_string($conn, $_POST['voter']);
    $birth = mysqli_real_escape_string($conn, $_POST['birth']);
    $duplicate = mysqli_real_escape_string($conn, $_POST['duplicate']);
    $panapply1 = mysqli_real_escape_string($conn, $_POST['panapply1']);
    $pan = mysqli_real_escape_string($conn, $_POST['pan']);
    $biometric = mysqli_real_escape_string($conn, $_POST['biometric']);
    $aayusman = mysqli_real_escape_string($conn, $_POST['aayusman']);
    $newpan = mysqli_real_escape_string($conn, $_POST['newpan']);
    $cpan = mysqli_real_escape_string($conn, $_POST['cpan']);
    $walletamount = mysqli_real_escape_string($conn,$_POST['walletamount']);

    $usertype = mysqli_real_escape_string($conn,$_POST['usertype']);

    $username = $_SESSION['phone'];
    $ires = mysqli_query($conn,"UPDATE `usertable` SET `name`='$name', `emailid`='$email', phone='$phone', `walletamount`='$walletamount',`state`='$state',`city`='$city',`userid`='$userid',`status`='$status', `mobile`='$mobile', `dob`='$dob',  `names`='$names', `address`='$address', `child`='$child',`voter`='$voter',`birth`='$birth', `duplicate`='$duplicate',   `pan`='$pan',   `panapply1`='$panapply1',  `biometric`='$biometric', `aayusman`='$aayusman',`newpan`='$newpan',`cpan`='$cpan',  `usertype`='$usertype' WHERE userid='$id' ");    

    if($ires){
        ?>
        <script>
            $(function(){
                Swal.fire(
                    'Success',
                    'User Updated Successfully',
                    'success'
                )
            });
            window.setTimeout(function() {
  window.location.href = "userlist2.php";
  }, 1500);
        </script>
        <?php
    }else{
        ?>
        <script>
            $(function(){
                Swal.fire(
                    'Opps',
                    'Internal Server Error Please try Agin Later',
                    'error'
                )
            });
        </script>
        <?php
    }
}
?>

<!-- Content Wrapper. Contains page content -->


    <!-- Content Header (Page header) -->
    <div class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <!--------<h1 class="m-0">Edit User</h1>--------->
                </div><!-- /.col -->
                <div class="col-sm-6 text-right">
                    <!---------<a href="users.php" class="btn btn-primary btn-sm">User List</a>---------->
                </div><!-- /.col -->
            </div><!-- /.row -->
        </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->

    <!-- Main content -->
    <section class="content">
        <div class="container-fluid">
            <div class="row">
                <!-- left column -->
                <div class="col-md-12">

                    <!-- general form elements -->
                    <div class="card card-default">


                        <!-- form start -->
                        <form method="post" action="" autocomplete="off" enctype="multipart/form-data">
                            <input type="hidden" name="_token" value="1TDde6CMH369W5RCLWCgTOjV8fR50kKPMlAfDgjN"> <input type="hidden" name="_method" value="PUT">
                            <input type="hidden" name="ahkweb" value="ahkwebsolutions">
                            <div class="card-body row">
                                
                            <div class="form-group col-md-2">
                                    <label for="walletamount">Wallet Balance</label>
                                    <input type="text" class="form-control" id="walletamount" name="walletamount" placeholder="walletamount" value="<?php echo $data['walletamount'] ?> " readonly>
                                </div>

                               
                                <div class="form-group col-md-2">
                                    <label for="status">Status<span class="text-danger">*</span></label>
                                    <select class="form-control" name="status" id="">
                                        <option  value="">Select status</option>
                                        <option <?php if($data['status'] == 'unverified'){ echo 'selected';} ?> value="unverified">Block</option>
                                        <option <?php if($data['status'] == 'verified'){ echo 'selected';} ?> value="verified">Active</option>
                                        </select>
                                </div>
                                
                                <div class="form-group col-md-2" style="display: none;">
                                    <label for="status">Child Enrolment Permition<span class="text-danger">*</span></label>
                                    <select class="form-control" name="panfind_fee" id="">
                                        <option  value="">Select status</option>
                                        <option <?php if($data['status'] == 'verified'){ echo 'selected';} ?> value="verified">ACTIVE</option>
                                        
                                    </select>
                                </div>
                                
                                <div class="form-group col-md-2">
                                    <label for="death_address">User Type<span class="text-danger">*</span></label>
                                    <select class="form-control" name="usertype" id="">
                                        <option  value="">Select Usertype</option>
                                        <option <?php if($data['usertype'] == 'OPERATOR'){ echo 'selected';} ?> value="OPERATOR">Operator</option>
                                        <option <?php if($data['usertype'] == 'DISTRIBUTOR'){ echo 'selected';} ?> value="DISTRIBUTOR">Distributor</option>
                                        <option <?php if($data['usertype'] == 'SUPERDISTRIBUTOR'){ echo 'selected';} ?> value="SUPERDISTRIBUTOR">Super Distributor</option>
                                       
                                    </select>
                                </div>
                                <div class="form-group col-md-2">
                                    <label for="name">Full Name <span class="text-danger">*</span></label>
                                    <input type="text" class="form-control" id="name" name="name" placeholder="FULL NAME" value="<?php echo $data['name'] ?>" required="">
                                </div>
                               
                                <div class="form-group col-md-2">
                                    <label for="email">Email<span class="text-danger">*</span></label>
                                    <input type="text" class="form-control" id="email" name="email" placeholder="email" value="<?php echo $data['emailid'] ?>"required="">
                                </div>

                                <div class="form-group col-md-2">
                                    <label for="phone">Mobile No.<span class="text-danger">*</span></label>
                                    <input type="text" class="form-control" id="phone" name="phone" placeholder="phone" value="<?php echo $data['phone'] ?>"required="">
                                </div>
                                
                                <div class="form-group col-md-2" style="display:;">
                                    <label for="child">Child Enrolment<span class="text-danger">*</span></label>
                                    <input type="text" class="form-control" id="child" name="child" placeholder="child" value="<?php echo $data['child'] ?>" readonly required="">
                                </div>
                                
                                
                                <div class="form-group col-md-2" style="display: none;">
                                    <label for="address">Mobile No Update Charge<span class="text-danger">*</span></label>
                                    <input type="text" class="form-control" id="address" name="address" placeholder="address" value="<?php echo $data['address'] ?>" readonly required="">
                                </div>
                                
                                
                                <div class="form-group col-md-2">
                                    <label for="address">UCL Charges <span class="text-danger">*</span></label>
                                    <input type="text" class="form-control" id="address" name="address" placeholder="address" value="<?php echo $data['address'] ?>" readonly required="">
                                </div>
                                
                                <div class="form-group col-md-2">
                                    <label for="gender">Gender Update<span class="text-danger">*</span></label>
                                    <input type="text" class="form-control" id="gender" name="gender" placeholder="" value="<?php echo $data['gender'] ?>" readonly required="">
                                </div>
                                
                                
                                <div class="form-group col-md-2">
                                    <label for="dob">DOB Charge<span class="text-danger">*</span></label>
                                    <input type="text" class="form-control" id="dob" name="dob" placeholder="dob" value="<?php echo $data['dob'] ?>" readonly required="">
                                </div>
                                
                                
                                <div class="form-group col-md-2">
                                    <label for="names">Name Update Charge<span class="text-danger">*</span></label>
                                    <input type="text" class="form-control" id="names" name="names" placeholder="names" value="<?php echo $data['names'] ?>" readonly required="">
                                </div>
                                <div class="form-group col-md-2" style="display: none;">
                                    <label for="duplicate">Dublicate PDF Charge<span class="text-danger">*</span></label>
                                    <input type="text" class="form-control" id="duplicate" name="duplicate" placeholder="duplicate" value="<?php echo $data['duplicate'] ?>"required="">
                                </div>
                                
                                
                                   <div class="form-group col-md-2" style="display: none;">
                                     <label for="voter">Votter PDF Charge<span class="text-danger">*</span></label>
                                    <input type="text" class="form-control" id="voter" name="voter" placeholder="voter" value="<?php echo $data['voter'] ?>"required="">
                                </div>
                                
                                
                                   <div class="form-group col-md-2" style="display: ;">
                                     <label for="biometric">Passport<span class="text-danger">*</span></label>
                                    <input type="text" class="form-control" id="passport" name="passport" placeholder="passport" value="<?php echo $data['passport'] ?>" readonly required="">
                                </div>
                                
                                <div class="form-group col-md-2" style="display: ;">
                                     <label for="biometric">Pension<span class="text-danger">*</span></label>
                                    <input type="text" class="form-control" id="pension" name="pension" placeholder="pension" value="<?php echo $data['pension'] ?>" readonly required="">
                                </div>
                                
                                <div class="form-group col-md-2" style="display: none;">
                                     <label for="birth">Birth Certificate Charge<span class="text-danger">*</span></label>
                                    <input type="text" class="form-control" id="birth" name="birth" placeholder="birth" value="<?php echo $data['birth'] ?>"required="">
                                </div>
                                
                                
                                <div class="form-group col-md-2" style="display:;">
                                     <label for="aayusman">Address Without Doc<span class="text-danger">*</span></label>
                                    <input type="text" class="form-control" id="aayusman" name="aayusman" placeholder="aayusman" value="<?php echo $data['aayusman'] ?>" readonly required="">
                                </div>
                                <div class="form-group col-md-2" style="display:;">
                                     <label for="newpan">New Pan<span class="text-danger">*</span></label>
                                    <input type="text" class="form-control" id="newpan" name="newpan" placeholder="" value="<?php echo $data['newpan'] ?>" readonly required="">
                                </div>
                                <div class="form-group col-md-2" style="display:;">
                                     <label for="cpan">C Pan<span class="text-danger">*</span></label>
                                    <input type="text" class="form-control" id="cpan" name="cpan" placeholder="" value="<?php echo $data['cpan'] ?>" readonly required="">
                                </div>
                                
                                   <div class="form-group col-md-2" style="display:;">
                                     <label for="pan">Birth Charge<span class="text-danger">*</span></label>
                                    <input type="text" class="form-control" id="pan" name="pan" placeholder="pan" value="<?php echo $data['pan'] ?>" readonly required="">
                                </div>
                                
                                <div class="form-group col-md-2" style="display: none;">
                                     <label for="pan">New Pan Card Charge<span class="text-danger">*</span></label>
                                    <input type="text" class="form-control" id="pan" name="pan" placeholder="pan" value="<?php echo $data['pan'] ?>"required="">
                                </div>
                                
                                
                                <div class="form-group col-md-2" style="display: none;">
                                     <label for="panapply1">Pan Correction Charge<span class="text-danger">*</span></label>
                                    <input type="text" class="form-control" id="panapply1" name="panapply1" placeholder="panapply1" value="<?php echo $data['panapply1'] ?>"required="">
                                </div>
                                
                                
                                


 

                                <div class="form-group col-md-2">
                                    <label for="userid">Username<span class="text-danger">*</span></label>
                                    <input type="text" class="form-control" id="userid" name="userid" placeholder="userid" value="<?php echo $data['userid'] ?>" readonly >
                                
                                </div>
                                
                             <!----------       <div class="form-group col-md-6">
                                    <label for="password">Password<span class="text-danger">*</span></label>
                                    <input type="text" class="form-control" id="password" name="password" placeholder="password" value="<?php echo $data['password'] ?>" readonly >
                                
                                </div>

          <div class="form-group col-md-6">
                                    <label for="state">State<span class="text-danger">*</span></label>
                                    <input type="text" class="form-control" id="state" name="state" placeholder="state" value="<?php echo $data['state'] ?>"required="" readonly >
                                </div>

                                <div class="form-group col-md-6">
                                    <label for="city">City<span class="text-danger">*</span></label>
                                    <input type="text" class="form-control" id="city" name="city" placeholder="city" value="<?php echo $data['city'] ?>"required="" readonly>
                                </div>----------->

                              

                            </div>
                            <!-- /.card-body -->

                            <div class="card-footer text-right pt-3 pb-3 mt-2">
                                <button type="submit" class="btn btn-primary btn-lg">Update</button>
                            </div>
                        </form>
                    </div>
                    <!-- /.card -->
                </div>
            </div>
        </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->


</div>
<!-- /.content-wrapper -->

<!-- <footer class="main-footer">
    <strong>Copyright &copy; 2014-2021 <a href="https://adminlte.io">AdminLTE.io</a>.</strong>
    All rights reserved.
    <div class="float-right d-none d-sm-inline-block">
      <b>Version</b> 3.1.0
    </div>
  </footer> -->

<!-- Control Sidebar -->
<!-- <aside class="control-sidebar control-sidebar-dark"> -->
<!-- Control sidebar content goes here -->
<!-- </aside> -->
<!-- /.control-sidebar -->
</div>
<!-- ./wrapper -->

<!-- jQuery -->
<script src="plugins/jquery/jquery.min.js"></script>
<!-- jQuery UI 1.11.4 -->
<script src="plugins/jquery-ui/jquery-ui.min.js"></script>
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<script>
    $.widget.bridge('uibutton', $.ui.button)
</script>
<!-- Bootstrap 4 -->
<script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>

<!-- Select2 -->
<script src="plugins/select2/js/select2.full.min.js"></script>

<!-- SweetAlert -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/8.11.8/sweetalert2.all.min.js"></script>

<!-- DataTables  & Plugins -->
<script src="plugins/datatables/jquery.dataTables.min.js"></script>
<script src="plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
<script src="plugins/datatables-buttons/js/dataTables.buttons.min.js"></script>
<script src="plugins/datatables-buttons/js/buttons.bootstrap4.min.js"></script>

<script src="plugins/datatables-buttons/js/buttons.html5.min.js"></script>
<script src="plugins/datatables-buttons/js/buttons.print.min.js"></script>
<script src="plugins/datatables-buttons/js/buttons.colVis.min.js"></script>

<!-- ChartJS -->
<script src="plugins/chart.js/Chart.min.js"></script>
<!-- Sparkline -->
<script src="plugins/sparklines/sparkline.js"></script>
<!-- JQVMap -->
<script src="plugins/jqvmap/jquery.vmap.min.js"></script>
<script src="plugins/jqvmap/maps/jquery.vmap.usa.js"></script>
<!-- jQuery Knob Chart -->
<script src="plugins/jquery-knob/jquery.knob.min.js"></script>
<!-- daterangepicker -->
<script src="plugins/moment/moment.min.js"></script>
<script src="plugins/daterangepicker/daterangepicker.js"></script>
<!-- Tempusdominus Bootstrap 4 -->
<script src="plugins/tempusdominus-bootstrap-4/js/tempusdominus-bootstrap-4.min.js"></script>
<!-- Summernote -->
<script src="plugins/summernote/summernote-bs4.min.js"></script>
<!-- overlayScrollbars -->
<script src="plugins/overlayScrollbars/js/jquery.overlayScrollbars.min.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/adminlte.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>
<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<script src="dist/js/pages/dashboard.js"></script>

<script src="https://code.jquery.com/ui/1.13.0/jquery-ui.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.3/jquery.validate.min.js" integrity="sha512-37T7leoNS06R80c8Ulq7cdCDU5MNQBwlYoy1TX/WUsLFC2eYNqtKlV0QjH7r8JpG/S0GUMZwebnVFLPd6SU5yg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-toast-plugin/1.3.2/jquery.toast.min.js" integrity="sha512-zlWWyZq71UMApAjih4WkaRpikgY9Bz1oXIW5G0fED4vk14JjGlQ1UmkGM392jEULP8jbNMiwLWdM8Z87Hu88Fw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

<script>
    function alertMessage(type, message) {
        if (type == 'error') {
            type = 'danger';
        }

        return "<div class='alert alert-" + type + " alert-dismissible'> <a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a> " + message + " </div>";
    }
</script>



</body>

</html>