<!-- Page Heading -->


          <!-- <h1 class="h3 mb-2 text-gray-800">Tables</h1>


          <p class="mb-4">DataTables is a third party plugin that is used to generate the demo table below. For more information about DataTables, please visit the <a target="_blank" href="https://datatables.net">official DataTables documentation</a>.</p> -->





          <!-- DataTales Example -->





  





          <div class="card shadow mb-4">


            <div class="card-header py-3">


              <h6 class="m-0 font-weight-bold text-primary">Data Prioritas Kegiatan</h6>


            </div>


            <div class="card-body">


              <!-- <a href='javascript:void(0)' onclick="getpopup('popup/tambah_prioritas_kegiatan','popupedit');" class="btn btn-primary btn-icon-split btn-sm mb-4">


                    <span class="icon text-white-50">


                      <i class="fas fa-plus"></i>


                    </span>


                    <span class="text">Tambah Data Prioritas Kegiatan</span>


              </a> -->


              <div class="table-responsive">


                <table class="table table-bordered" id="tabel_data_prioritas_kegiatan" width="100%" cellspacing="0">


                  <thead>


                    <tr>


                      <th>No</th>


                      <th>Nama</th>


                      <th>Keterangan</th>


                      <!-- <th>Aksi</th> -->


                    </tr>


                  </thead>


                  <!-- <tfoot>


                    <tr>


                      <th>Name</th>


                      <th>Position</th>


                      <th>Office</th>


                      <th>Age</th>


                      <th>Start date</th>


                      <th>Salary</th>


                    </tr>


                  </tfoot> -->


                  <tbody>


                  </tbody>


                </table>


              </div>


            </div>


          </div>


<script type="text/javascript">


$(document).ready(function(){


    


    var base_url = "<?=base_url()?>";


    


    var data_prioritas_kegiatan = function(){


        $('#tabel_produk').hide();


        $.ajax({ 


            url: base_url + 'prioritas_kegiatan/data_prioritas_kegiatan',


            type: "post",


            // data:{<?php echo $this->security->get_csrf_token_name(); ?>:'<?php echo $this->security->get_csrf_hash(); ?>'},


            // data:{},


            dataType: "json",


            async : 'false',


            success: function(result){


              // alert(JSON.stringify(result))


              var data = [];


                for ( var i=0 ; i<result.length ; i++ ) {


                  // alert(result[i].kode_pka)


                    var no = i+1;


                    // var satuan;


                    // if(result[i].satuan == 1){


                    //     satuan = 'Pcs';


                    // }else{


                    //     satuan = 'Kg';


                    // }


                    // var link_edit = "<a href='javascript:void(0)' onclick=\"getpopup('aksesoris/edit','"++"','popupedit','"+result[i].id_kma+"');\"><span class='btn btn-info fa fa-edit' title='Edit Aksesoris'></span></a>";


                    var link_edit = `<a href="javascript:void(0)" title="Edit" onclick="getpopup('Popup/edit_prioritas_kegiatan','popupedit','`+result[i].id_prioritas_kegiatan+`');" class="btn btn-info btn-icon-split btn-sm">


                                        <span class="icon text-white-50">


                                          <i class="fas fa-edit"></i>


                                        </span>


                                      </a>`;


                    var link_hapus = `<a href="javascript:void(0)" title="Hapus" onclick="hapus_prioritas_kegiatan('`+result[i].id_prioritas_kegiatan+`');" class="btn btn-danger btn-icon-split btn-sm">


                                        <span class="icon text-white-50">


                                          <i class="fas fa-trash-alt"></i>


                                        </span>


                                      </a>`;


                    // var link_acc = `<a href="#" class="btn btn-success btn-icon-split btn-sm">


                    //                     <span class="icon text-white-50">


                    //                       <i class="fas fa-file-signature"></i>


                    //                     </span>


                    //                     <span class="text">ACC</span>


                    //                   </a>`;


                    // var link_hapus = `<a href="#" class="btn btn-danger btn-icon-split btn-sm">


                    //                     <span class="icon text-white-50">


                    //                       <i class="fas fa-trash-alt"></i>


                    //                     </span>


                    //                     <span class="text">Hapus</span>


                    //                   </a>`;


                    // var gambar = '<div style="width:100%;text-align:center"><img src="uploads/aksesoris/rz_'+result[i].gambar+'" style="width:100px;height:100px"></div>';


                    // data.push([no,result[i].nama,'<span class="label label-purple">'+result[i].stok_awal+' '+satuan+'</span>','<span class="label label-purple">'+result[i].stok_akhir+' '+satuan+'</span>',result[i].hargas,gambar,result[i].tgl,'<div style="width:100%;text-align:center">'+link_edit+'</div>']);


                    data.push([no,result[i].nama,result[i].keterangan/*,link_edit+" "+link_hapus*/]);


                }


                $('#tabel_data_prioritas_kegiatan').DataTable({


                    //"bJQueryUI"     : true,


                    data                : data,


                    deferRender         : true,


                    processing          : true,


                    ordering            : true,


                    retrieve            : false,


                    paging              : true,


                    deferLoading        : 57,


                    bDestroy            : true,


                    autoWidth           : false,


                    bFilter             : true,


                    iDisplayLength      : 10,


                    responsive: true,


                    language: {


                      searchPlaceholder: 'Cari',


                      sSearch: '',


                      lengthMenu: '_MENU_',


                    },


                });


               


            },


            beforeSend: function () {





            },


            complete: function () {


                // $('#tabel_produk').show();


            }


        });


    }


    data_prioritas_kegiatan();


    hapus_prioritas_kegiatan = function(id_prioritas_kegiatan){


      bootbox.confirm("Apakah Anda Yakin Akan Menghapus Data?", function(result){ 


        if (result==true) {


          $.ajax({


                url             : base_url + 'prioritas_kegiatan/hapus_prioritas_kegiatan', 


                type            : "POST",


                dataType        : 'json',


                data            : {id_prioritas_kegiatan:id_prioritas_kegiatan},


                success         : function(response){


                  if(response == true){


                        Command: toastr["success"]("Data Prioritas Kegiatan Berhasil Dihapus", "Berhasil");


                        getcontens('page/data_prioritas_kegiatan');


                    }else{


                        Command: toastr["error"]("Simpan error, data tidak berhasil disimpan", "Error");


                    }


                },


                error: function(jqXHR, textStatus, errorThrown) {


                  $('#loading').modal('hide');


                  Command: toastr["error"](errorThrown, "Error");


                },


                beforeSend: function () {


                  $('#loading').modal('show');


                },


                complete: function () {


                    $('#loading').modal('hide');


                }


          })


        }


      });


    }


  });


</script>


