Advertisement
Novinaldi

semuadatatransaksi.php

Jan 28th, 2021
670
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.01 KB | None | 0 0
  1. <link rel="stylesheet" href="<?= base_url(); ?>assets/plugins/datatables/jquery.dataTables.min.css">
  2. <link rel="stylesheet" href="<?= base_url(); ?>assets/plugins/datatables/responsive/responsive.dataTables.min.css">
  3. <link rel="stylesheet" href="<?= base_url(); ?>assets/plugins/datatables/responsive/rowReorder.dataTables.min.css">
  4. <script src="<?= base_url(); ?>assets/plugins/datatables/jquery.dataTables.min.js"></script>
  5. <script src="<?= base_url(); ?>assets/plugins/datatables/responsive/dataTables.rowReorder.min.js"></script>
  6. <script src="<?= base_url(); ?>assets/plugins/datatables/responsive/dataTables.responsive.min.js"></script>
  7. <div class="col-lg-12">
  8.     <div class="card border-light mb-1 animated fadeInLeft">
  9.         <div class="card-header">
  10.             <?php
  11.             $idgrup = $this->session->userdata('idgrup');
  12.             if ($idgrup == 1) {
  13.             ?>
  14.  
  15.             <button type="button" class="btn btn-sm btn-pinterest"
  16.                 onclick="window.location='<?= site_url('admin/penjualan/index') ?>'">
  17.                 <i class="fa fa-fast-backward" aria-hidden="true"></i> Kembali
  18.             </button>
  19.             <?php
  20.             } else {
  21.             ?>
  22.             <button type="button" class="btn btn-sm btn-pinterest"
  23.                 onclick="window.location='<?= site_url('k/home/index') ?>'">
  24.                 <i class="fa fa-fast-backward" aria-hidden="true"></i> Kembali
  25.             </button>
  26.             <?php
  27.             }
  28.             ?>
  29.  
  30.         </div>
  31.         <div class="card-body">
  32.             <div class="col-lg-12">
  33.                 <div class="form-group row">
  34.                     <label for="staticEmail" class="col-sm-1 col-form-label">Filter</label>
  35.                     <div class="col-sm-3">
  36.                         <input type="date" name="tglawal" id="tglawal" class="form-control form-control-sm"
  37.                             value="<?= date('Y-m-d'); ?>">
  38.                     </div>
  39.                     <div class="col-sm-3">
  40.                         <input type="date" name="tglakhir" id="tglakhir" class="form-control form-control-sm"
  41.                             value="<?= date('Y-m-d'); ?>">
  42.                     </div>
  43.                     <?php
  44.                     if ($this->session->userdata('idgrup') == 1) :
  45.                     ?>
  46.                     <div class="col-sm-3">
  47.                         <select name="users" id="users" class="form-control-sm form-control">
  48.                             <option value="" selected>-Semua-</option>
  49.                             <?php foreach ($datauser->result_array() as $d) : ?>
  50.                             <option value="<?= $d['userid']; ?>"><?= $d['usernama']; ?></option>
  51.                             <?php endforeach; ?>
  52.                         </select>
  53.                     </div>
  54.                     <?php
  55.                     endif;
  56.                     ?>
  57.                     <div class="col-sm-1">
  58.                         <button type="button" class="btn btn-success btn-sm btnfilter">
  59.                             Tampilkan
  60.                         </button>
  61.                     </div>
  62.                 </div>
  63.             </div>
  64.             <div class="col-lg-12">
  65.                 <table style="font-size: 10pt;" class="table table-sm table-striped table-bordered display nowrap"
  66.                     id="datatransaksi" width="100%">
  67.                     <thead>
  68.                         <tr>
  69.                             <th>#</th>
  70.                             <th>Faktur</th>
  71.                             <th>Tanggal</th>
  72.                             <th>Pelanggan</th>
  73.                             <th>Stt.Bayar</th>
  74.                             <th>User Input</th>
  75.                             <th>Jml.Item</th>
  76.                             <th>Total Bersih (Rp)</th>
  77.                             <th>#</th>
  78.                         </tr>
  79.                     </thead>
  80.                     <tbody>
  81.  
  82.                     </tbody>
  83.                 </table>
  84.             </div>
  85.  
  86.         </div>
  87.     </div>
  88. </div>
  89. <div class="viewmodalitem" style="display: none;"></div>
  90. <script>
  91. function cetakfaktur(faktur) {
  92.     var top = window.screen.height - 400;
  93.     top = top > 0 ? top / 2 : 0;
  94.  
  95.     var left = window.screen.width - 200;
  96.     left = left > 0 ? left / 2 : 0;
  97.  
  98.     // var url = '.././pemasok/index';
  99.     var uploadWin = window.open('<?= site_url('admin/penjualan/cetakfaktur/') ?>' + faktur,
  100.         "Struk Kasir",
  101.         "width=200,height=400" + ",top=" + top +
  102.         ",left=" + left);
  103.     uploadWin.moveTo(left, top);
  104.     uploadWin.focus();
  105. }
  106.  
  107. function tampildatapenjualan() {
  108.     let tglawal = $('#tglawal').val();
  109.     let tglakhir = $('#tglakhir').val();
  110.     let users = $('#users').val();
  111.     table = $('#datatransaksi').DataTable({
  112.         responsive: true,
  113.         "destroy": true,
  114.         "processing": true,
  115.         "serverSide": true,
  116.         "order": [],
  117.  
  118.         "ajax": {
  119.             "url": "<?= site_url('admin/penjualan/ambilsemuadata') ?>",
  120.             "type": "POST",
  121.             "data": {
  122.                 tglawal: tglawal,
  123.                 tglakhir: tglakhir,
  124.                 users: users,
  125.             }
  126.         },
  127.  
  128.  
  129.         "columnDefs": [{
  130.                 "targets": [0],
  131.                 "orderable": false,
  132.                 "width": 3
  133.             },
  134.             {
  135.                 "targets": [6],
  136.                 "className": "text-center",
  137.             }, {
  138.                 "targets": [7],
  139.                 "className": "text-right",
  140.             }, {
  141.                 "targets": [8],
  142.                 "width": 5
  143.             }
  144.         ]
  145.     });
  146. }
  147. $(document).ready(function() {
  148.     tampildatapenjualan();
  149.  
  150.     $('.btnfilter').click(function(e) {
  151.         e.preventDefault();
  152.         tampildatapenjualan();
  153.     });
  154. });
  155.  
  156. // Hapus transaksi holding
  157. function hapus(faktur) {
  158.     Swal.fire({
  159.         title: `Hapus Transaksi`,
  160.         html: `Yakin transaksi <strong>${faktur}</strong> dihapus ?`,
  161.         icon: 'warning',
  162.         showCancelButton: true,
  163.         confirmButtonColor: '#3085d6',
  164.         cancelButtonColor: '#d33',
  165.         confirmButtonText: 'Ya,Hapus',
  166.         cancelButtonText: 'Tidak'
  167.     }).then((result) => {
  168.         if (result.value) {
  169.             $.ajax({
  170.                 type: "post",
  171.                 url: "<?= site_url('admin/penjualan/hapustransaksiditahan') ?>",
  172.                 data: {
  173.                     faktur: faktur
  174.                 },
  175.                 dataType: "json",
  176.                 success: function(response) {
  177.                     if (response.sukses) {
  178.                         Swal.fire({
  179.                             position: 'top-center',
  180.                             icon: 'success',
  181.                             title: response.sukses,
  182.                             showConfirmButton: true,
  183.                         }).then((result) => {
  184.                             if (result.value) {
  185.                                 window.location.reload();
  186.                             }
  187.                         })
  188.                     }
  189.                 },
  190.                 error: function(xhr, ajaxOptions, thrownError) {
  191.                     alert(xhr.status + "\n" + xhr.responseText + "\n" +
  192.                         thrownError);
  193.                 }
  194.             });
  195.         }
  196.     })
  197. }
  198.  
  199. // edit transaksi
  200. function edit(faktur) {
  201.     window.location.href = ("<?= site_url('admin/penjualan/edit/') ?>") + faktur;
  202. }
  203.  
  204. function itempenjualan(faktur) {
  205.     $.ajax({
  206.         type: "post",
  207.         url: "<?= site_url('admin/penjualan/detail_itempenjualan') ?>",
  208.         data: {
  209.             faktur: faktur
  210.         },
  211.         dataType: "json",
  212.         cache: false,
  213.         success: function(response) {
  214.             if (response.data) {
  215.                 $('.viewmodalitem').html(response.data).show();
  216.                 $('#modaldataitem').modal('show');
  217.             }
  218.         },
  219.         error: function(xhr, ajaxOptions, thrownError) {
  220.             alert(xhr.status + "\n" + xhr.responseText + "\n" +
  221.                 thrownError);
  222.         }
  223.     });
  224. }
  225. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement