<?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" role="document">



    <div class="modal-content">



      <form id="tambah_sesi_pka">



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



        <h5 class="modal-title">Tambah Sesi 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">



        



          <div class="row">



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



                      <label for="exampleInputEmail1">Kode Sesi</label>



                      <input type="text" class="form-control" id="kode_sesi" name="kode_sesi" value="<?=$token?>" readonly>



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



                    </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 timepicker" id="dari" name="dari" aria-describedby="emailHelp" placeholder="" required>



                      <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 timepicker" id="sampai" name="sampai" aria-describedby="emailHelp" placeholder="" required>



                      <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></textarea>



                    </div>



          </div>



      </div>



      <div class="modal-footer">



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



        <input type="submit" class="btn btn-primary" value="Simpan" />



        



      </div>



    </form>



    </div>



  </div>



</div>



<script type="text/javascript">



  $(document).ready(function(){



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



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



    var time = function(){



      $('.timepicker').datepicker({



          format: 'dd MM yyyy',



          todayHighlight:true,



          toggleActive:true,



          daysOfWeekDisabled:'0',



          autoclose:true,



          language:'id'



      });



    }



    time();



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



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



      swal({



        title: "Yakin?",



        text: "Apakah anda yakin akan menambah data...?",



        icon: "warning",



        buttons: true,



        dangerMode: false,



      })



      .then((send) => {



        if (send) {



          $.ajax({



                url             : base_url + 'pka/tambah_sesi_pka', 



                type            : "POST",



                dataType        : 'json',



                mimeType        : 'multipart/form-data',



                data            : form_data,



                contentType     : false,



                cache           : false,



                processData     : false,



                success         : function(response){



                  swal.close();



                    if(response == true){



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



                        swal.close();



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



                        getcontens('page/sesi_pka');



                    }else{



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



                    }



                },



                error: function(jqXHR, textStatus, errorThrown) {



                  swal.close();



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



                }



          });



        } else {



          swal("Anda Batal Mengirim");



        }



      });



          



        return false;



    })



  



  })



</script>