drzeo

View_produk

Dec 1st, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.47 KB | None | 0 0
  1. <!-- DataTables -->
  2.   <link rel="stylesheet" href="<?= base_url("assets/"); ?>datatables/css/dataTables.bootstrap.css">
  3.   <!-- Content Wrapper. Contains page content -->
  4.   <div class="content-wrapper">
  5.     <!-- Content Header (Page header) -->
  6.     <section class="content-header">
  7.       <h1>
  8.          Produk
  9.       </h1>
  10.       <ol class="breadcrumb">
  11.         <li><a href=""><i class="fa fa-dashboard"></i>  Produk</a></li>
  12.         <li class="active">Daftar  Produk</li>
  13.       </ol>
  14.     </section>
  15.  
  16.     <!-- Main content -->
  17.     <section class="content">
  18.  
  19.       <!-- Default box -->
  20.       <div class="box">
  21.         <div class="box-header with-border">
  22.           <h3 class="box-title">Daftar Produk</h3>
  23.  
  24.           <div class="box-tools pull-right">
  25.             <button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip"
  26.                     title="Collapse">
  27.               <i class="fa fa-minus"></i></button>
  28.             <button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove">
  29.               <i class="fa fa-times"></i></button>
  30.           </div>
  31.         </div>
  32.         <div class="box-body">
  33.           <div>
  34.               <button class="btn btn-primary" onclick="tambah()"><span class="fa fa-edit"></span> Tambah</button>
  35.               <button class="btn btn-default" onclick="reload_table()"><i class="glyphicon glyphicon-refresh"></i> Reload</button>
  36.           </div><br>
  37.           <div class="box-body table-responsive no-padding">
  38.               <table id="mytable" class="table table-striped table-bordered table-hover" width="100%">
  39.                   <thead>
  40.                       <tr><th width="1%">No</th>
  41.                           <th>Nama Produk</th>
  42.                           <th>Kategori Produk</th>
  43.                           <th>Harga Pelanggan</th>
  44.                           <th>Harga Umum</th>
  45.                           <th>Stok</th>
  46.                           <th width="20%">Action</th>
  47.                       </tr>
  48.                   </thead>
  49.                   <tbody>
  50.                   </tbody>
  51.               </table>
  52.           </div>
  53.         </div>
  54.         <!-- /.box-body -->
  55.         <div class="box-footer">
  56.           Footer
  57.         </div>
  58.         <!-- /.box-footer-->
  59.       </div>
  60.       <!-- /.box -->
  61.  
  62.     </section>
  63.     <!-- /.content -->
  64.   </div>
  65.   <!-- /.content-wrapper -->
  66. <!-- jQuery 3 -->
  67. <script src="<?= base_url("assets/"); ?>bower_components/jquery/dist/jquery.min.js"></script>
  68. <!-- DataTables -->
  69. <script src="<?= base_url("assets/"); ?>datatables/js/jquery.dataTables.min.js"></script>
  70. <script src="<?= base_url("assets/"); ?>datatables/js/dataTables.bootstrap.js"></script>
  71. <!-- page script -->
  72. <script type="text/javascript">
  73.            
  74.     $.fn.dataTableExt.oApi.fnPagingInfo = function(oSettings)
  75.     {
  76.         return {
  77.             "iStart": oSettings._iDisplayStart,
  78.             "iEnd": oSettings.fnDisplayEnd(),
  79.             "iLength": oSettings._iDisplayLength,
  80.             "iTotal": oSettings.fnRecordsTotal(),
  81.             "iFilteredTotal": oSettings.fnRecordsDisplay(),
  82.             "iPage": Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength),
  83.             "iTotalPages": Math.ceil(oSettings.fnRecordsDisplay() / oSettings._iDisplayLength)
  84.         };
  85.     };
  86.  
  87.     var table = $('#mytable').DataTable({
  88.         oLanguage: {
  89.             sProcessing: "loading..."
  90.         },
  91.         processing: true,
  92.         serverSide: true,
  93.         ajax: {"url": "<?= base_url() ?>admin/produk/json", "type": "POST"},
  94.         columns: [
  95.             {
  96.                 "data": "id",
  97.                 "orderable": false
  98.             },
  99.             {"data": "nama"},
  100.             {"data": "nama_kategori_produk"},
  101.             {"data": "pelanggan"},
  102.             {"data": "umum"},
  103.             {"data": "qty"},
  104.             {"data": "view","orderable": false}
  105.         ],
  106.         order: [[1, 'asc']],
  107.         rowCallback: function(row, data, iDisplayIndex) {
  108.             var info = this.fnPagingInfo();
  109.             var page = info.iPage;
  110.             var length = info.iLength;
  111.             var index = page * length + (iDisplayIndex + 1);
  112.             $('td:eq(0)', row).html(index);
  113.         }
  114.     });
  115.  
  116.     //fun reload
  117.     function reload_table()
  118.     {
  119.         table.ajax.reload(null,false); //reload datatable ajax
  120.     }
  121.  
  122.     // Aktif Navigasi
  123.   $(document).ready(function() {
  124.         $('#produk').addClass('active treeview');
  125.     });
  126. </script>
Advertisement
Add Comment
Please, Sign In to add comment