<?php



        $token = "";



        $codeAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";



        $codeAlphabet.= "0123456789";



        $max = strlen($codeAlphabet) - 1;



        for ($i=0; $i < 8; $i++) {



            $token .= $codeAlphabet[mt_rand(0, $max)];



        } 



?>



<div class="modal" tabindex="-1" role="dialog" id="<?=$id_modal?>">



  <div class="modal-dialog modal-lg" role="document">



    <form id="update_evaluasi_pka">



    <div class="modal-content">



      <div class="modal-header bg-info text-light">



        <h5 class="modal-title">Revisi Evaluasi PKA</h5>



        <button type="button" class="close" data-dismiss="modal" aria-label="Close">



          <span aria-hidden="true">&times;</span>



        </button>



      </div>



      <div class="modal-body">



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



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



        <div id="page"></div>



        



        



      </div>



      <div class="modal-footer">



        <!-- <button type="button" class="btn btn-success" onclick="window.open('<?=base_url("laporan_excel/laporan_ev_pka_excel/$id_row")?>', 



                         'newwindow', 



                         'width=1000,height=600'); 



              return false;"><i class="fas fa-file-excel"></i> Cetak Excel</button> -->



        <button type="button" class="btn btn-secondary" data-dismiss="modal">Batal</button>



        <input type="submit" class="btn btn-info" value="Update Evaluasi"/>



        



        



      </div>



    </div>



  </form>



  </div>



</div>



<script type="text/javascript">



  $(document).ready(function(){



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



    var id_modal = "<?=$id_modal?>";



    var no_pka   = "<?=$id_row?>";



    var time = function(){



        $('.timepicker').datepicker({



            format: 'dd MM yyyy',



            todayHighlight:true,



            toggleActive:true,



            daysOfWeekDisabled:'0',



            autoclose:true,



            language:'id'



        });



    }



    time();



    







    var file = function(){



      $.ajax({



                url             : base_url + 'pka/ambil_detail_pka_evaluasi/'+no_pka, 



                type            : "POST",



                dataType        : 'json',



                mimeType        : 'multipart/form-data',



                // data            : form_data,



                contentType     : false,



                cache           : false,



                processData     : false,



                success         : function(result){



                  // alert(JSON.stringify(result));



                  var data = [];



                  var p = 0;







                  $("#no_pka").val(no_pka);



                  $("#jml_page").val(result.length);



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



                    // alert(result[i].kode_pka)



                    p++;



                    card = `



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



          <!-- Card Header - Accordion -->



          <a href="#page_`+p+`" class="d-block card-header py-3"  data-toggle="collapse" role="button" aria-expanded="true" aria-controls="page_1" style="background-color: #`+randomColor()+`;">



            <h6 class="m-0 text-light"> Page `+p+` </h6>



          </a>



          <!-- Card Content - Collapse -->



          <div class="collapse show" id="page_`+p+`">



            <div class="card-body">



              <div class="row">



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



                            <label for="exampleInputEmail1">Nomor Mata Anggaran</label>



                            <input type="hidden" name="kode_pka[]" value="`+result[i].kode_pka+`">



                            <input type="text" class="form-control" id="kma" value="`+result[i].kma+`" readonly>



                            <!-- <small id="emailHelp" class="form-text text-muted">Data Akan terisi Otomatis.</small> -->



                          </div>



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



                  <div class="row">



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



                      <label for="exampleInputEmail1">Nama Kegiatan</label>



                            <textarea class="form-control" id="nama_kegiatan" name="nama_kegiatan" aria-describedby="emailHelp" placeholder="" readonly>`+result[i].nama_kegiatan+`</textarea>



                    </div>



                    



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



                          <label for="exampleInputEmail1">Tujuan Kegiatan</label>



                            <textarea  class="form-control " id="tujuan_kegiatan" name="tujuan_kegiatan" aria-describedby="emailHelp" placeholder="" readonly>`+result[i].tujuan_kegiatan+` </textarea>



                    </div>



                  </div> 



                </div>



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



                  <div class="row">



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



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



                            <input type="text" class="form-control" id="pencapaian" name="pencapaian[]" aria-describedby="emailHelp" placeholder="" value="`+result[i].pencapaian+`" required>



                    </div>



                    



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



                          <label for="exampleInputEmail1">Analisa Terhadap Pencapaian</label>



                            <textarea class="form-control" id="atp" name="atp[]" aria-describedby="emailHelp" placeholder="" required>`+result[i].atp+`</textarea>



                    </div>



                  </div> 



                </div>



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



                            <label for="exampleInputEmail1">Target Kehadiran</label>



                            <input type="text" class="form-control" id="target_kehadiran" name="target_kehadiran[]" value="`+result[i].target_kehadiran+`" required>



                </div>



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



                            <label for="exampleInputEmail1">Realisasi Kehadiran</label>



                            <input type="text" class="form-control" id="realisasi_kehadiran_`+p+`" name="realisasi_kehadiran[]" value="`+result[i].realisasi_kehadiran+`" required>



                </div>



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



                            <label for="exampleInputEmail1">Target Penerimaan</label>



                            <input type="text" class="form-control" id="target_penerimaan" name="target_penerimaan" onkeyup="formatRp('target_penerimaan')" value="`+formatRupiah(String(result[i].jml_penerimaan))+`" readonly>



                </div>



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



                            <label for="exampleInputEmail1">Realisasi Penerimaan</label>



                            <input type="text" class="form-control" id="realisasi_penerimaan_`+p+`" name="realisasi_penerimaan[]" onkeyup="formatRp('realisasi_penerimaan_`+p+`')"  value="`+formatRupiah(String(result[i].realisasi_penerimaan))+`" max="10" required>



                </div>



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



                            <label for="exampleInputEmail1">Target Pengeluaran</label>



                            <input type="text" class="form-control" id="target_pengeluaran" name="target_pengeluaran" onkeyup="formatRp('target_pengeluaran')" value="`+formatRupiah(String(result[i].jml_pengeluaran))+`" readonly>



                </div>



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



                            <label for="exampleInputEmail1">Realisasi Pengeluaran</label>



                            <input type="text" class="form-control" id="realisasi_pengeluaran_`+p+`" name="realisasi_pengeluaran[]" onkeyup="formatRp('realisasi_pengeluaran_`+p+`')" value="`+formatRupiah(String(result[i].realisasi_pengeluaran))+`" max="10" required>



                </div>



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



                            <label for="exampleFormControlTextarea1">Evaluasi Pengurus Secara Keseluruhan</label>



                            <textarea class="form-control" id="epsk" name="epsk[]" rows="3" required>`+result[i].epsk+`</textarea>



                          </div>



              </div>



            </div>



          </div>



        </div>



                    `;



                    $("#page").append(card);



                  }



                }



      })



    }



    file();















    $("#update_evaluasi_pka").submit(function(){



      var form_data = new FormData($('#update_evaluasi_pka')[0]);



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



        if (result==true) {



          $.ajax({



                url             : base_url + 'pka/update_revisi_evaluasi_pka', 



                type            : "POST",



                dataType        : 'json',



                mimeType        : 'multipart/form-data',



                data            : form_data,



                contentType     : false,



                cache           : false,



                processData     : false,



                success         : function(response){



                    // alert(JSON.stringify(response))



                    if(response == true){



                        $('#'+id_modal).modal('hide');  



                        Command: toastr["success"]("Data Berhasil Dikirim", "Berhasil");



                        getcontens('page/data_refisi_evaluasi_pka');



                    }else{



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



                    }



                },



                error: function(jqXHR, textStatus, errorThrown) {



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



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



                },



                beforeSend: function () {



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



                },



                complete: function () {



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



                }



          });



        }



      });



          



        return false;



      });



    formatRp = function(bbb){



      var ggg = $("#"+bbb).val(); 



      $("#"+bbb).val(formatRupiah(ggg, ''));



    }



    /* Fungsi */



    function formatRupiah(angka, prefix)



    {



        var number_string = angka.replace(/[^,\d]/g, '').toString(),



            split    = number_string.split(','),



            sisa     = split[0].length % 3,



            rupiah     = split[0].substr(0, sisa),



            ribuan     = split[0].substr(sisa).match(/\d{3}/gi);



            



        if (ribuan) {



            separator = sisa ? '.' : '';



            rupiah += separator + ribuan.join('.');



        }



        



        rupiah = split[1] != undefined ? rupiah + ',' + split[1] : rupiah;



        return prefix == undefined ? rupiah : (rupiah ? '' + rupiah : '');



    }



  })



</script>