azmicolejr

Card - View

Jan 7th, 2022
919
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 4.12 KB | None | 0 0
  1. -- VIEW --
  2.  
  3. <?php $this->load->view('back/head'); ?>
  4. <?php $this->load->view('back/header'); ?>
  5. <?php $this->load->view('back/leftbar'); ?>
  6.  
  7. <div class="content-wrapper">
  8.   <section class="content-header">
  9.     <h1><?php echo $title ?></h1>
  10.     <ol class="breadcrumb">
  11.       <li><a href="<?php echo base_url('dashboard') ?>"><i class="fa fa-dashboard"></i> Home</a></li>
  12.       <li>Kartu Garansi</li>
  13.       <li class="active"><a href="<?php echo current_url() ?>"><?php echo $title ?></a></li>
  14.     </ol>
  15.   </section>
  16.  
  17.   <section class="content">
  18.     <div class="box box-primary">
  19.       <div class="box-body table-responsive padding">
  20.         <p><button class="btn btn-grey" onclick="reload_table()"><i class="glyphicon glyphicon-refresh"></i> Refresh </button></p>
  21.  
  22.         <?php echo validation_errors() ?>
  23.         <?php if ($this->session->flashdata('message')) {
  24.           echo $this->session->flashdata('message');
  25.         } ?>
  26.  
  27.         <p>
  28.           <select class="form-control" id="urutkan" style="margin-top:5px">
  29.             <option value="1" <?php echo $this->uri->segment(3) == 1 ? ' selected' : ''; ?>>Nota SPK</option>
  30.             <option value="2" <?php echo $this->uri->segment(3) == 2 ? ' selected' : ''; ?>>Nota Pelunasan</option>
  31.           </select>
  32.         </p>
  33.  
  34.         <table id="datatable" class="table table-striped table-bordered" cellspacing="0" width="100%">
  35.           <thead>
  36.             <tr>
  37.               <th style="text-align: center">Last Update</th>
  38.               <th style="text-align: center">No. Nota Pelunasan</th>
  39.               <th style="text-align: center">Nota SPK</th>
  40.               <th style="text-align: center">Nama Customer</th>
  41.               <th style="text-align: center">No. HP</th>
  42.               <th style="text-align: center">Plat Nomor</th>
  43.               <th style="text-align: center">Jenis Mobil</th>
  44.               <th style="text-align: center">Nama Produk</th>
  45.               <th style="text-align: center">Berlaku s/d</th>
  46.               <th style="text-align: center">Catatan Maintenance</th>
  47.               <th style="text-align: center">Aksi</th>
  48.             </tr>
  49.           </thead>
  50.           <tbody></tbody>
  51.         </table>
  52.       </div>
  53.     </div>
  54.   </section>
  55. </div>
  56.  
  57. <!-- DATA TABLES SCRIPT -->
  58. <script src="<?php echo base_url('assets/plugins/datatables/jquery.dataTables.min.js') ?>" type="text/javascript"></script>
  59. <script src="<?php echo base_url('assets/plugins/datatables/dataTables.bootstrap.min.js') ?>" type="text/javascript"></script>
  60. <script type="text/javascript">
  61.   $(document).ready(function() {
  62.     $('#urutkan').on('change', function() {
  63.       var url = "<?php echo base_url('warranty_card/index/') ?>";
  64.       var status = $(this).val();
  65.       window.location = url + status;
  66.     });
  67.  
  68.     table = $('#datatable').DataTable({
  69.       processing: true, //Feature control the processing indicator.
  70.       serverSide: true, //Feature control DataTables' server-side processing mode.
  71.       bPaginate: true,
  72.       bLengthChange: true,
  73.       bFilter: true,
  74.       bSort: true,
  75.       bInfo: true,
  76.       order: [
  77.         [0, 'desc']
  78.       ],
  79.       lengthMenu: [
  80.         [10, 25, 50, 100, 500, 1000, -1],
  81.         [10, 25, 50, 100, 500, 1000, "Semua"]
  82.       ],
  83.       ajax: {
  84.         "url": "<?php echo site_url('warranty_card/ajax_list_by_pelunasan') ?>",
  85.         "type": "POST"
  86.       },
  87.     });
  88.   });
  89.  
  90.   function reload_table() {
  91.     table.ajax.reload(null, false); //reload datatable ajax
  92.   }
  93.  
  94.   function delete_data(id_warranty_card) {
  95.     if (confirm('Apakah Anda yakin?')) {
  96.       // ajax delete data to database
  97.       $.ajax({
  98.         url: "<?php echo site_url('warranty_card/ajax_delete') ?>/" + id_warranty_card,
  99.         type: "POST",
  100.         dataType: "JSON",
  101.         success: function(data) {
  102.           //if success reload ajax table
  103.           alert('Hapus data berhasil');
  104.  
  105.           $('#modal_form').modal('hide');
  106.           reload_table();
  107.         },
  108.         error: function(jqXHR, textStatus, errorThrown) {
  109.           alert('Gagal menghapus data');
  110.         }
  111.       });
  112.     }
  113.   }
  114. </script>
  115.  
  116. <?php $this->load->view('back/footer'); ?>
Advertisement
Add Comment
Please, Sign In to add comment