Advertisement
kura2yamato

Solvr dtable

Oct 3rd, 2022
1,000
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.35 KB | Fixit | 0 0
  1.  
  2. Err… harus lebih rapi
  3.  
  4. .....
  5.  
  6. <!--DataTable......-->
  7.  
  8. Hide quoted text
  9. <div class="table-responsive">
  10.  
  11.    <form action="" method="POST" id="formcheck">
  12.  
  13.    <table class="table table-bordered table-striped table-hover" id="table-datatable">
  14.  
  15.     <thead>
  16.  
  17.             <tr>
  18.  
  19.             <th></th>
  20.  
  21.             <th width="5%">NO</th>
  22.  
  23.             <th width="10%">TANGGAL</th>
  24.  
  25.             <th>DIVISI</th>
  26.  
  27.             <th>NAMA KASIR</th>
  28.  
  29.             <th>NAMA PENJUAL</th>
  30.  
  31.             <th>NOMOR PENJUAL</th>
  32.  
  33.             <th>PEMBELIAN</th>
  34.  
  35.             <th width="12%">NOMINAL</th>
  36.  
  37.             <th>STATUS</th>
  38.  
  39.             <th width="9%">OPSI</th>
  40.  
  41.         </tr>
  42.  
  43.       </thead>
  44.  
  45.         <tfoot style="display: table-header-group">
  46.  
  47.         <tr>
  48.  
  49.             <td></td>
  50.  
  51.             <td></td>
  52.  
  53.             <th>TANGGAL</th>
  54.  
  55.             <th>DIVISI</th>
  56.  
  57.             <th>NAMA KASIR</th>
  58.  
  59.             <th>NAMA PENJUAL</th>
  60.  
  61.             <th>NOMOR PENJUAL</th>
  62.  
  63.             <th>PEMBELIAN</th>
  64.  
  65.             <th>NOMINAL</th>
  66.  
  67.             <th>STATUS</th>
  68.  
  69.             <td></td>
  70.  
  71.       </tr>
  72.  
  73.     </tfoot>
  74.  
  75.       <tbody>
  76.  
  77.         <?php
  78.  
  79.         $no=1;
  80.  
  81.         $data = mysqli_query($koneksi,"SELECT * FROM sa_beli2nd,divisi where divisi_id=kode_divisi order by tanggal_beli desc, kode_divisi asc, id_beli desc");
  82.  
  83.         while($d = mysqli_fetch_array($data)){
  84.  
  85.         ?>
  86.  
  87.             <tr>
  88.  
  89.           <td class="text-center"><input type="checkbox" class="check" name="check" id="check"
  90.  
  91.               onclick="konfirmasi(this)" value="<?php echo $d['id_beli']; ?>"></td>
  92.  
  93.           <td class="text-center"><?php echo $no++; ?></td>
  94.  
  95.           <td class="text-center"><?php echo date('d-m-Y', strtotime($d['tanggal_beli'])); ?></td>
  96.  
  97.           <td><?php echo $d['divisi']; ?></td>
  98.  
  99.           <td><?php echo $d['kasir']; ?></td>
  100.  
  101.           <td><?php echo $d['penjual']; ?></td>
  102.  
  103.           <td><?php echo $d['no_penjual']; ?></td>
  104.  
  105.           <td><?php echo $d['jenis_beli']; ?></td>
  106.  
  107.           <td class="text-right text-primary"><?php echo "Rp. ".number_format($d['nominal'])." ,-";?></td>
  108.  
  109.           <td><?php echo $d['status']; ?></td>
  110.  
  111.           <td class="text-center">  
  112.  
  113.           <?php if($id_user == '3'){ ?>
  114.  
  115.             <button type="button" class="btn btn-warning btn-sm" data-toggle="modal" data-target="#edit_sa_<?php echo $d['id_beli'] ?>">
  116.  
  117.               <i class="fa fa-cog" style="display:grid; justify-content:center;"></i>
  118.  
  119.             </button>
  120.  
  121.  
  122.             <button type="button" class="btn btn-danger btn-sm" data-toggle="modal" data-target="#hapus_sa_<?php echo $d['id_beli'] ?>">
  123.  
  124.               <i class="fa fa-trash" style="display:grid; justify-content:center;"></i>
  125.  
  126.             </button>
  127.  
  128.           <?php } ?>
  129.  
  130.  
  131.             <button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#lihat_sa_<?php echo $d['id_beli'] ?>">
  132.  
  133.               <i class="fa fa-eye" style="display:grid; justify-content:center;"></i>
  134.  
  135.             </button>
  136.  
  137.         </td>
  138.  
  139.             </tr>
  140.  
  141.  
  142.  
  143.  
  144. //Jquery Ajax Menandai data......
  145.  
  146. <script>
  147.  
  148.   function konfirmasi(obj){
  149.  
  150.     var idKonfirmasi = $(obj).val();
  151.  
  152.       //$(obj).data("check")
  153.  
  154.     //document.getElementById("check").checked
  155.  
  156.     if(true){
  157.  
  158.       var checked = confirm("Ingin menandai data ini?")
  159.  
  160.       if (checked === true) {
  161.  
  162.               alert("update/edit "+idKonfirmasi);
  163.  
  164.           $.ajax({
  165.  
  166.             url: "sa_beli2nd_update.php",
  167.  
  168.             method: "POST",
  169.  
  170.             data: {type: "editData", id: idKonfirmasi},
  171.  
  172.             success: function(){
  173.  
  174.               window.location.replace="sa_beli2nd.php";                      
  175.  
  176.             }
  177.  
  178.                   //tidak ada kondisi kalau gagal!!!
  179.  
  180.           });
  181.  
  182.         }else{
  183.  
  184.             let check = document.getElementById("check");
  185.  
  186.             check.checked = false;
  187.  
  188.         }
  189.  
  190.     }
  191.  
  192.   }
  193.  
  194. </script>
  195.  
  196.  
  197.  
  198. <?php
  199.  
  200. //File Proccess (sa_beli2nd_update.php)
  201.  
  202. if($_POST["type"] == "editData" ){
  203.  
  204.       $id = $_POST["id"];
  205.  
  206.       $query =  mysqli_query($koneksi, "UPDATE sa_beli2nd set status= 'Tuntas' WHERE id = '$id' ");
  207.  
  208.       if($query){
  209.  
  210.             //header("location:sa_beli2nd.php");
  211.  
  212.             return 1;//mengembalikan nilai bukan header location
  213.  
  214.       }
  215.  
  216.       return 0;
  217.  
  218. }
  219.  
  220.  
  221.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement