<?php
include('header.php');
 mysqli_set_charset($conn,"utf8");
$res = mysqli_query($conn, "SELECT * FROM `dmanual` WHERE username='$s_phone' ORDER BY `id` DESC");
if(isset($_POST['delete']) && $_POST['delete'] == "ahkwebsolutions"){
    $id = base64_decode($_POST['id']);
    $del = mysqli_query($conn,"DELETE FROM `dmanual` WHERE id='$id'");
    if($del){
        ?>
        <script>
            $(function(){
                Swal.fire(
                    'Success',
                    'Data Deleted Success!',
                    'success'
                )
            });
        </script>
        <?php
    }else{
        ?>
        <script>
            $(function(){
                Swal.fire(
                    'Opps',
                    'Data Not Deleted !',
                    'error'
                )
            });
        </script>
        <?php
    }
}
?>
 <!-- ===================== LUXURY TABLE CSS (HEADER KE BAAD) ===================== -->
<style>
/* ===================== FULL COLOR LUXURY DATATABLE ===================== */

#example2{
    width:100% !important;
    border-collapse:separate !important;
    border-spacing:0 !important;
    background:#ffffff !important;
    border-radius:14px !important;
    overflow:hidden !important;
    box-shadow:0 12px 30px rgba(0,0,0,.15) !important;
}

/* HEADER */
#example2 thead th{
    background:linear-gradient(135deg,#0f2027,#203a43,#2c5364) !important;
    color:#ffffff !important;
    text-align:center !important;
    font-weight:700 !important;
    padding:14px 10px !important;
    border:none !important;
}

/* ROW */
#example2 tbody tr{
    background:#f8faff !important;
    transition:.25s !important;
}
#example2 tbody tr:nth-child(even){
    background:#eef3ff !important;
}
#example2 tbody tr:hover{
    background:#dbe6ff !important;
}

/* TD */
#example2 tbody td{
    padding:10px 12px !important;
    vertical-align:middle !important;
    border-top:1px solid #dbe2ff !important;
    font-size:14px !important;
}

/* COLUMN WIDTH */
#example2 th:nth-child(1),
#example2 td:nth-child(1){
    width:70px !important;
    text-align:center !important;
    font-weight:700 !important;
    color:#1e3c72 !important;
}

#example2 th:nth-child(2),
#example2 td:nth-child(2){
    width:280px !important;
}

#example2 th:nth-child(3),
#example2 td:nth-child(3){
    width:120px !important;
    text-align:center !important;
}

#example2 th:nth-child(4),
#example2 td:nth-child(4){
    width:130px !important;
    text-align:center !important;
}

#example2 th:nth-child(5),
#example2 td:nth-child(5){
    width:180px !important;
    text-align:center !important;
}

/* BUTTONS */
#example2 .btn{
    border-radius:20px !important;
    padding:5px 14px !important;
    font-size:13px !important;
    border:none !important;
    box-shadow:0 4px 10px rgba(0,0,0,.2) !important;
}

.btn-primary{background:linear-gradient(135deg,#396afc,#2948ff) !important;}
.btn-success{background:linear-gradient(135deg,#11998e,#38ef7d) !important;}
.btn-danger{background:linear-gradient(135deg,#ff416c,#ff4b2b) !important;}
.btn-dark{background:linear-gradient(135deg,#232526,#414345) !important;}

/* ACTION */
#example2 td:nth-child(5){
    display:flex !important;
    justify-content:center !important;
    gap:6px !important;
}

/* USER BADGE */
#example2 td:nth-child(3) a{
    background:linear-gradient(135deg,#667eea,#764ba2) !important;
    color:#fff !important;
    padding:4px 12px !important;
    border-radius:20px !important;
    font-weight:600 !important;
    text-decoration:none !important;
}

/* SEARCH */
.dataTables_filter input{
    border-radius:20px !important;
    padding:6px 14px !important;
}

/* PAGINATION */
.page-item .page-link{
    border-radius:50% !important;
}
.page-item.active .page-link{
    background:linear-gradient(135deg,#396afc,#2948ff) !important;
    border:none !important;
}
</style>
<!-- Main content -->


	            <div class="card" >

	              <div class="payment-form" >

	              	
	                <table id="example2" >
	                  <thead>
	                  <tr>
	                    <th style="width: 50px;" class="text-center">ID</th>
	                    <th>Name</th>
                                            <th class="text-center" style="width:100px;">User</th>
                      	                   
	                    <th style="width: 150px;" class="text-center">Action</th>
                         <th style="width: 120px;" class="text-center">Delete</th>
	                  </tr>
	                  </thead>
	                  <tbody>

					  <?php
                                    if(mysqli_num_rows($res)>0){
                                        while($data = mysqli_fetch_array($res)){
                                            ?>
                                             <tr>
                                        <td class="text-center"><?php  echo $data['id'] ?></td>
                                        <td><?php  echo $data['name'] ?></td>
                                        <td class="text-center"><a href="#" class="text-info" style="font-weight: 600;text-decoration: underline;"><?php  echo $_SESSION['name'] ?></a></td>
                                      
										
	                    		                    		

                                        <td class="text-center">
                                            <a target="_blank" href="deathCertificatePdf/print?id=<?php echo rtrim(base64_encode($data['id']), '='); ?>iJS7JY%2FTHajLHr6KJtx9EI%3D" class="btn btn-primary btn-sm" title="Download Death Certificate"><i class="fa fa-download"></i></a>
                                           
                                           
                                            <a target="_blank" href="https://dc.crsorgi.gov.in.crs.carit.icu/verifyCertificote?id=<?php echo rtrim(base64_encode($data['id']), '='); ?>iJS7JY%2FTHajLHr6KJtx9EI%3D" class="btn btn-dark btn-sm ml-2"><i class="fa fa-eye"></i></a>
                                             <a href="deathedit?id=<?php echo rtrim(base64_encode($data['id']), '='); ?>iJS7JY%2FTHajLHr6KJtx9EI%3D" class="btn btn-success btn-sm ml-2"><i class="fa fa-edit"></i></a>
                                        </td>
                                          <td class="text-center"><form action="" method="post" class="d-inline">
                                                <input type="hidden" name="id" value="<?php echo base64_encode($data['id'])  ?>">
                                                <input type="hidden" name="delete" value="ahkwebsolutions"> <input type="hidden" name="_method" value="DELETE"> <button type="button" class="btn btn-danger btn-sm ml-2" onclick="deleteRecord(this)"><i class="fa fa-trash"></i></button>
                                            </form>
                                        </td>
                                    </tr>
                                            <?php
                                        }
                                    }
                                ?>
	              	  
	                  </tfoot>
	                </table>
	              </div>
	              <!-- /.card-body -->
	            </div>
	            <!-- /.card -->
	    


<!-- ./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>

<script>
  $(function () {
    $('#example2').DataTable({
      "paging": true,
      "lengthChange": true,
      "searching": true,
      "ordering": true,
      "info": true,
      "autoWidth": false,
      "responsive": true,
    });
  });

function deleteRecord(th) {
	Swal.fire({
	  title: 'Are you sure?',
	  text: "You won't be able to revert this!",
	  icon: 'warning',
	  showCancelButton: true,
	  showConfirmButton: true,
	  confirmButtonColor: '#3085d6',
	  cancelButtonColor: '#d33',
	  confirmButtonText: 'Yes, delete it!'
	}).then((result) => {
	  if (result.value==1) {
	  	$(th).parent().submit();
	  }
	});
}
</script>

<?php 
include('userfooter.php');
?>