<!-- 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">Sesi Evaluasi PKA</h6>





            </div>





            <div class="card-body">





              <input type="hidden" id="kode_sesi_pka" name="kode_sesi_pka">





              <div class="row">





                <div class="form-group  col-md-12">





                    <label for="exampleFormControlTextarea1">Periode Tahun</label>





                    <select class="form-control" id="periode_thn" name="periode_thn" required disabled>





                    </select>





                </div>





                <div class="form-group col-md-12">





                  <label for="exampleInputEmail1">Periode</label>





                  <div class="row">





                    <div class="form-group col-md-6">





                          <input type="text" class="form-control datepicker" id="dari" name="dari" aria-describedby="emailHelp" placeholder="" required disabled>





                          <small id="emailHelp" class="form-text text-muted">Periode Dari Tanggal.</small>





                    </div>





                    <div class="form-group col-md-6">





                          <input type="text" class="form-control datepicker" id="sampai" name="sampai" aria-describedby="emailHelp" placeholder="" required disabled>





                          <small id="emailHelp" class="form-text text-muted">Periode Sampai Tanggal.</small>





                    </div>





                  </div> 





                </div>





                <div class="form-group  col-md-12">





                          <label for="exampleFormControlTextarea1">Keterangan</label>





                          <textarea class="form-control" id="keterangan" name="keterangan" rows="3" required disabled></textarea>





                        </div>





                





              </div>





              <div class="modal-footer">





                  <a href='javascript:void(0)' style="display: none;" onclick="" class="btn btn-secondary btn-icon-split mb-3" id="btn-batal">





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





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





                    </span>





                  </a>





                  <a href='javascript:void(0)' style="display: none;" onclick="" class="btn btn-primary btn-icon-split mb-3" id="btn-update">





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





                      <i class="fas fa-calendar-check"></i>





                    </span>





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





                  </a>





                  





                  <a href='javascript:void(0)' onclick="" class="btn btn-info btn-icon-split mb-3" id="btn-edit">





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





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





                    </span>





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





                  </a>





                  <a href='javascript:void(0)' id="btn-publish" class="btn btn-success btn-icon-split mb-3" id="btn-tambah-page">





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





                      <i class="fas fa-paper-plane"></i>





                    </span>





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





                  </a>





                  





              </div>





              <!-- <a href='javascript:void(0)' onclick="getpopup('popup/tambah_sesi_pka','popupedit');" class="btn btn-primary btn-icon-split mb-3" id="btn-tambah-page">





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





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





                </span>





                <span class="text"> Tambah Sesi </span>





              </a>





              <div class="table-responsive">





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





                  <thead>





                    <tr>





                      <th>No</th>





                      <th>Kode</th>





                      <th>Periode</th>





                      <th>Keterangan</th>





                      <th>Dibuat Pada</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 datepicker = function(){





      $('.datepicker').datepicker({





          format: 'dd MM yyyy',





          todayHighlight:true,





          toggleActive:true,





          daysOfWeekDisabled:'0',





          autoclose:true,





          language:'id'





      });





    }





    datepicker();





    th = function($param){


      var thn_ini = "<?=date('Y')?>";


      var $id = $('#periode_thn');


      $id.empty();   


      for (var i = parseInt(thn_ini); i <= parseInt(thn_ini)+5; i++) {


        var p= i+1


        var periode = i+"/"+p;


        if ($param == periode) {


          selected = "selected";


        }else{


          selected ="";


        }


         $id.append('<option value="'+periode+'" '+selected+'>' + periode + '</option>');


       } 


    }


    // th()


    // th("2022/2023")





    





    var data_sesi_pka = function(){





          $.ajax({ 





            url: base_url + 'pka/data_sesi_ev_pka',





            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){


              if (result =="kosong") {


                Command: toastr["info"]("Data Masih Kosong!, <br> Silahkan Edit data", "Info");


              }else{


                $("#dari").val(result.dari_tgl);


                $("#sampai").val(result.sampai_tgl);


                $("#keterangan").val(result.keterangan);


                $("#kode_sesi_pka").val(result.kode_sesi_ev_pka);


                if (result.publish == "0") {


                  $("#btn-publish").show();


                }else{


                  $("#btn-publish").hide();


                }


                th(result.periode_thn);


              }


            },


            error: function(jqXHR, textStatus, errorThrown) {


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


            },


            beforeSend: function () {


            },


            complete: function () {


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


            }


          });





    }





    data_sesi_pka();





    $("#btn-edit").click(function(){





      $("#dari").attr("disabled",false);





      $("#sampai").attr("disabled",false);





      $("#keterangan").attr("disabled",false);





      $("#periode_thn").attr("disabled",false);





      $("#btn-edit").hide();





      $("#btn-update").show();





      $("#btn-batal").show();





      $("#btn-publish").hide();





      th($("#periode_thn").val());


    });





    $("#btn-batal").click(function(){





      data_sesi_pka();





      $("#dari").attr("disabled",true);





      $("#sampai").attr("disabled",true);





      $("#keterangan").attr("disabled",true);





      $("#periode_thn").attr("disabled",true);





      $("#btn-edit").show();





      $("#btn-update").hide();





      $("#btn-batal").hide();











    });





    $("#btn-update").click(function(){





      bootbox.confirm("Apakah Anda Yakin akan mengupdate?", function(result){ 





        if (result==true) {





            var periode_thn = $("#periode_thn").val();





          var dari = $("#dari").val();





          var sampai = $("#sampai").val();





          var keterangan = $("#keterangan").val();





          var kode_sesi_pka = $("#kode_sesi_pka").val();





          $.ajax({ 





              url: base_url + 'pka/update_sesi_ev_pka',





              type: "post",





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





              data:{periode_thn:periode_thn,dari:dari,sampai:sampai,keterangan:keterangan,kode_sesi:kode_sesi_pka},





              dataType: "json",





              async : 'false',





              success: function(result){





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





                if (result) {





                  





                  Command: toastr["success"]("Sesi Berhasil Dibuat", "Berhasil");





                  data_sesi_pka();





                  $("#dari").attr("disabled",true);





                  $("#sampai").attr("disabled",true);





                  $("#keterangan").attr("disabled",true);





                  $("#periode_thn").attr("disabled",true);





                  $("#btn-edit").show();





                  $("#btn-update").hide();





                  $("#btn-batal").hide();





                  





                }else{





                  Command: toastr["error"]("Maaf Anda Gagal Mengupdate", "Error");





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





                }





                





              },





              error: function(jqXHR, textStatus, errorThrown) {





                    // swal.close();





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





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





              },





              beforeSend: function () {





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





              },





              complete: function () {





                  





              }





            });





        }





      });





    // swal({





    //     title: "Kirim?",





    //     text: "Apakah anda yakin akan Meng-Update data...?",





    //     icon: "warning",





    //     buttons: true,





    //     dangerMode: false,





    //   })





    //   .then((send) => {





    //     





    //   })





    })





    $("#btn-publish").click(function(){





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





        if (result==true) {





        var kode_sesi_pka = $("#kode_sesi_pka").val();





        $.ajax({ 





            url: base_url + 'pka/publish_sesi_ev_pka',





            type: "post",





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





            data:{kode_sesi:kode_sesi_pka},





            dataType: "json",





            async : 'false',





            success: function(result){





              if (result) {





                Command: toastr["success"]("Selamat Anda Berhasil Mempublis", "Berhasil");





                data_sesi_pka();





                $("#dari").attr("readonly",true);





                $("#sampai").attr("readonly",true);





                $("#keterangan").attr("readonly",true);





                $("#btn-edit").show();





                $("#btn-update").hide();





                $("#btn-batal").hide();





              }else{





                Command: toastr["error"]("Maaf Anda Gagal Mempublis", "Error");





              }





            },





            error: function(jqXHR, textStatus, errorThrown) {





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





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





            },





            beforeSend: function () {





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





            },





            complete: function () {





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





            }





          });





        }





      })





    });











































































































    // data_sesi_pka = function(){





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





    //     $.ajax({ 





    //         url: base_url + 'pka/data_sesi_pka',





    //         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','"++"');\"><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_sesi_pka','popupedit','`+result[i].id_sesi_pka+`');" class="btn btn-info btn-circle btn-sm">





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





    //                                 </a>`;





    //                 var link_hapus = `<a href="javascript:void(0)" title="Hapus" onclick="getpopup('popup/edit_sesi_pka','popupedit','`+result[i].id_sesi_pka+`');" class="btn btn-danger btn-circle btn-sm">





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





    //                                 </a>`;





    //                 var link_publis = `<a href="javascript:void(0)" title="Publish" onclick="getpopup('popup/edit_sesi_pka','popupedit','`+result[i].id_sesi_pka+`');" class="btn btn-success btn-circle btn-sm">





    //                                   <i class="fas fa-paper-plane"></i>





    //                                 </a>`;





    //                 var periode = result[i].dari_tgl+" - "+result[i].sampai_tgl;





    //                 data.push([no,result[i].kode_sesi_pka,periode,result[i].keterangan,result[i].tgl_dibuat,link_edit+" "+link_hapus]);





    //             }





    //             $('#tabel_data_user').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_sesi_pka("semua");





  });





</script>





