Guest User

Untitled

a guest
Nov 29th, 2016
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!-- Main row -->
  2. <div class="row">
  3.  <div class="col-md-12">
  4.   <!-- TABLE: KELOLA PRODUK -->
  5.   <div class="box box-danger">
  6.       <div class="box-header with-border">
  7.         <h3 class="box-title">Kelola Toko</h3>
  8.         <a href="/store/store/create_store" class="btn btn-sm btn-primary pull-right" id="btn-add-store">Tambah Toko</a>        
  9.       </div><!-- /.box-header -->
  10.       <div class="box-body">
  11.       <div class="table-responsive">
  12.         <table id="table-store" class="table no-margin">
  13.           <thead class="thead-inverse">
  14.             <tr>
  15.               <th style="text-align:center">No</th>
  16.               <th style="text-align:center">Nama Toko</th>
  17.               <th style="text-align:center">Alamat Toko</th>
  18.               <th style="text-align:center">Aksi</th>
  19.             </tr>
  20.           </thead>
  21.           <tbody class="text-center">
  22.            
  23.           </tbody>
  24.         </table>
  25.       </div><!-- /.table-responsive -->
  26.  
  27.       <div class="table-responsive">
  28.         <table id="table-store-lol" class="table no-margin">
  29.           <thead class="thead-inverse">
  30.             <tr>
  31.               <th style="text-align:center">No</th>
  32.               <th style="text-align:center">Nama Toko</th>
  33.               <th style="text-align:center">Alamat Toko</th>
  34.               <th style="text-align:center">Aksi</th>
  35.             </tr>
  36.           </thead>
  37.           <tbody class="text-center">
  38.            
  39.           </tbody>
  40.         </table>
  41.       </div><!-- /.table-responsive -->
  42.  
  43.     </div><!-- /.box-body -->
  44.     <div class="box-footer clearfix">
  45.     </div><!-- /.box-footer -->
  46.   </div><!-- /.box -->
  47.  </div><!-- /.col -->
  48. </div><!-- /.row -->
  49.  
  50.  
  51. <script type="text/javascript">
  52.   function listStores(){
  53.       $.ajax({
  54.           type: "GET",
  55.           url: "<?php echo base_url()?>api/store/liststorebyuser/<?php echo $data ?>",
  56.           success: function(resp) {
  57.             if(resp.success == true){
  58.  
  59.               var tbody = '';
  60.               var no = 0;
  61.  
  62.               $.each(resp.data, function(k,v){
  63.                 no++;
  64.                 tbody += "<tr>";
  65.                 tbody += "<td>"+no+".</td>";
  66.                 tbody += "<td>"+v.name+"</td>";
  67.                 tbody += "<td>"+v.address+"</td>";
  68.                 tbody += "<td><button type='button' onclick='editStores(\""+v.id+"\")' value='Ubah' class='btn btn-sm btn-success btn-update'>Ubah</button> <button type='button' onclick='deleteStores(\""+v.id+"\")' value='Hapus' class='btn btn-sm btn-danger btn-delete'>Hapus</button> </td>";
  69.                 tbody += "</tr>";
  70.               });
  71.  
  72.               $('#table-store tbody').html(tbody);
  73.               $('#table-store').dataTable({
  74.                   });
  75.  
  76.              
  77.             }
  78.           },
  79.           dataType: 'json'
  80.       });
  81.  
  82.       return false;
  83.   }
  84.  
  85.   function deleteStores(id){
  86.       $.ajax({
  87.           type: "GET",
  88.           url: "<?php echo base_url()?>api/store/delete/"+id+"",
  89.           success: function(resp) {
  90.             if(resp.success == true){
  91.               alert("Data berhasil di hapus");
  92.               //$('#table-store').dataTable().fnClearTable();
  93.               $('#table-store').dataTable().fnDestroy();
  94.               $('#table-store-lol').dataTable().fnDestroy();
  95.               //$.fn.dataTableExt.sErrMode = 'throw'
  96.               listStores();
  97.             }
  98.           },
  99.           dataType: 'json'
  100.       });
  101.  
  102.       return false;
  103.   }
  104.  
  105.   function editStores(id){
  106.       window.location.href = "<?php echo base_url()?>store/store/update_store/"+id+"";
  107.       return false;
  108.   }
  109.  
  110.  
  111.   $(document).ready( function () {
  112.       var table;
  113.       listStores();
  114.       $('#btn-ubah').click(function(){
  115.       });
  116.       $('#table-store-lol').dataTable({
  117.         "processing": true,
  118.         "serverSide": true,
  119.         "ajax": "<?php echo base_url()?>api/store/liststosrebyuser/<?php echo $data ?>"
  120.       });
  121.       console.log("woloo");
  122.  
  123.      
  124.   });
  125. </script>
Add Comment
Please, Sign In to add comment