Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- Main row -->
- <div class="row">
- <div class="col-md-12">
- <!-- TABLE: KELOLA PRODUK -->
- <div class="box box-danger">
- <div class="box-header with-border">
- <h3 class="box-title">Kelola Toko</h3>
- <a href="/store/store/create_store" class="btn btn-sm btn-primary pull-right" id="btn-add-store">Tambah Toko</a>
- </div><!-- /.box-header -->
- <div class="box-body">
- <div class="table-responsive">
- <table id="table-store" class="table no-margin">
- <thead class="thead-inverse">
- <tr>
- <th style="text-align:center">No</th>
- <th style="text-align:center">Nama Toko</th>
- <th style="text-align:center">Alamat Toko</th>
- <th style="text-align:center">Aksi</th>
- </tr>
- </thead>
- <tbody class="text-center">
- </tbody>
- </table>
- </div><!-- /.table-responsive -->
- <div class="table-responsive">
- <table id="table-store-lol" class="table no-margin">
- <thead class="thead-inverse">
- <tr>
- <th style="text-align:center">No</th>
- <th style="text-align:center">Nama Toko</th>
- <th style="text-align:center">Alamat Toko</th>
- <th style="text-align:center">Aksi</th>
- </tr>
- </thead>
- <tbody class="text-center">
- </tbody>
- </table>
- </div><!-- /.table-responsive -->
- </div><!-- /.box-body -->
- <div class="box-footer clearfix">
- </div><!-- /.box-footer -->
- </div><!-- /.box -->
- </div><!-- /.col -->
- </div><!-- /.row -->
- <script type="text/javascript">
- function listStores(){
- $.ajax({
- type: "GET",
- url: "<?php echo base_url()?>api/store/liststorebyuser/<?php echo $data ?>",
- success: function(resp) {
- if(resp.success == true){
- var tbody = '';
- var no = 0;
- $.each(resp.data, function(k,v){
- no++;
- tbody += "<tr>";
- tbody += "<td>"+no+".</td>";
- tbody += "<td>"+v.name+"</td>";
- tbody += "<td>"+v.address+"</td>";
- 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>";
- tbody += "</tr>";
- });
- $('#table-store tbody').html(tbody);
- $('#table-store').dataTable({
- });
- }
- },
- dataType: 'json'
- });
- return false;
- }
- function deleteStores(id){
- $.ajax({
- type: "GET",
- url: "<?php echo base_url()?>api/store/delete/"+id+"",
- success: function(resp) {
- if(resp.success == true){
- alert("Data berhasil di hapus");
- //$('#table-store').dataTable().fnClearTable();
- $('#table-store').dataTable().fnDestroy();
- $('#table-store-lol').dataTable().fnDestroy();
- //$.fn.dataTableExt.sErrMode = 'throw'
- listStores();
- }
- },
- dataType: 'json'
- });
- return false;
- }
- function editStores(id){
- window.location.href = "<?php echo base_url()?>store/store/update_store/"+id+"";
- return false;
- }
- $(document).ready( function () {
- var table;
- listStores();
- $('#btn-ubah').click(function(){
- });
- $('#table-store-lol').dataTable({
- "processing": true,
- "serverSide": true,
- "ajax": "<?php echo base_url()?>api/store/liststosrebyuser/<?php echo $data ?>"
- });
- console.log("woloo");
- });
- </script>
Add Comment
Please, Sign In to add comment