<?php
	include "php_class/class_mysql.php";
	include "php_class/class_pegawai.php";
	$DataPegawai = new DataPegawai;
	include "php_class/class_dosen.php";
	$DataDosen = new dataDosen;
?>
<link href="<?php echo $base?>plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<link href="<?php echo $base?>plugins/iCheck/all.css" rel="stylesheet" type="text/css" />
<link href="<?php echo $base?>plugins/timepicker/bootstrap-timepicker.min.css" rel="stylesheet"/>
<script src="<?php echo $base?>plugins/input-mask/jquery.inputmask.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/input-mask/jquery.inputmask.date.extensions.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/input-mask/jquery.inputmask.extensions.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/timepicker/bootstrap-timepicker.min.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/iCheck/icheck.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="<?php echo $base?>plugins/autocomplete/shieldui-all.css" />
<link href="<?php echo $base?>bootstrap/css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
<script type="text/javascript" src="<?php echo $base?>bootstrap/js/bootstrap-datetimepicker.js" charset="UTF-8"></script>
<script type="text/javascript" src="<?php echo $base?>bootstrap/js/locales/bootstrap-datetimepicker.id.js" charset="UTF-8"></script>
<script type="text/javascript" src="<?php echo $base?>plugins/autocomplete/shieldui-all.min.js"></script>
<script type="text/javascript">
  $(document).ready(function(){
	var base = <?php echo json_encode($base);?>;
	
	$("#example1").dataTable();
	
	/*$('.context').bind('contextmenu', function(e){
		e.preventDefault();
    	var kode = $(this).attr('id');
		$('#kodekunci').val(kode);
   		$("#menuklik").modal('show');
	});*/
	
	$('#editdata').click(function(){
		var kode = $('#kodekunci').val();
		window.location=''+base+'edit-nilai-pegawai/'+ kode +'';
	});
	
	$('#nonaktif').click(function(){
		var kode = $('#kodekunci').val();
		if (confirm("Anda yakin me-nonaktifkan data dengan kode " + kode+"?")){
			window.location=''+base+'query-nonaktif-operator/'+ kode +'';	
		}
	});
	
	$('#newdata').click(function(){
		window.location=''+base+'add-operator';
	});

  });
   
</script>
<section class="content-header">
  <h1>
    Data Penilaian Pegawai
  </h1>
  <ol class="breadcrumb">
    <li><a href="<?php echo $base?>index"><i class="fa fa-dashboard"></i> Home</a></li>
    <li class="active">Data Penilaian Pegawai</li>
  </ol>
</section>
<section class="content">
  <div class="row">
    <div class="col-xs-12">
     
      <div class="box">
        <div class="box-body">
					<div class="row">
                        <div class="col-sm-12" >
                        <?php
                        	$idPegawai = $_POST['idPegawai'];
							$Nama = $_POST['nama'];
							$tglAwal = $_POST['tglAwal'];
							$tglAkhir = $_POST['tglAkhir'];
						?>
                	<form method="post" action="<?php echo $base?>data-rekap-penilaian-pegawai">
                            <input type="hidden" name="idPegawai" value="<?php echo $idPegawai?>" id="idPegawai">
                            <div class="form-group">
                                <label class="control-label">Nama Pegawai</label>
                                <input type="text" name="nama"  class="form-control"  placeholder="nama pegawai" id="nama" value="<?php echo $Nama?>">
                            </div>
                             <div class="form-group">
                                <label class="control-label">Tanggal Awal</label>
                                <div class="input-group date form_date" data-date="" data-date-format="yyyy-mm-dd" data-link-field="tgl">
                                    <input required="required" class="form-control" type="text" placeholder="tanggal penilaian" readonly id="tgl" value="<?php echo $tglAwal?>">
                                    <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
                                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                                    <input type="hidden" id="tgl" name="tglAwal" value="<?php echo $tglAwal?>" />
                                    <script type="text/javascript">
                                        $('.form_date').datetimepicker({
                                            language:  'id',
                                            weekStart: 1,
                                            todayBtn:  1,
                                            autoclose: 1,
                                            todayHighlight: 1,
                                            startView: 2,
                                            minView: 2,
                                            forceParse: 0
                                        });
                                    </script>  
                                </div>
                             </div>
                             <div class="form-group">
                                <label class="control-label">Tanggal akhir</label>
                                <div class="input-group date form_date" data-date="" data-date-format="yyyy-mm-dd" data-link-field="tgl2">
                                    <input required="required" class="form-control" type="text" placeholder="tanggal penilaian" readonly id="tgl2" value="<?php echo $tglAkhir?>">
                                    <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
                                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                                    <input type="hidden" id="tgl2" name="tglAkhir" value="<?php echo $tglAkhir?>" />
                                    <script type="text/javascript">
                                        $('.form_date').datetimepicker({
                                            language:  'id',
                                            weekStart: 1,
                                            todayBtn:  1,
                                            autoclose: 1,
                                            todayHighlight: 1,
                                            startView: 2,
                                            minView: 2,
                                            forceParse: 0
                                        });
                                    </script>  
                                </div>
                             </div>

                         <div class="form-group">
                            <button type="submit" class="btn btn-default"><i class='glyphicon glyphicon-ok'></i> OK</button>
                         </div>
    				</form>
                        </div>
                    </div >	 
        <div class="table-responsive" style="margin-top:30px;">
          <table id="example1" class="table table-bordered table-striped table-hover">
             <thead>
                <tr>
                    <th>No</th>
                    <th>Nama Pegawai</th>
                    <th>Tanggal</th>
                    <th>Nilai 1</th>
                    <th>Nilai 2</th>
                    <th>Nilai 3</th>
                    <th>Nilai 4</th>
                    <th>Nilai 5</th>
                </tr>
            </thead>
            <tbody>
            <?php
            	$JumlahData = $DataPegawai->get_Nilai_Pegawai_tgl('',$a,'jumlah', $idPegawai, $tglAwal, $tglAkhir);
				if ($JumlahData<=0){
					echo "<tr class='odd gradeX'>";
					echo "<td>No Data</td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "</tr>";	
				}else{
					for ($a=1;$a<=$JumlahData;$a++){
						$id = $DataPegawai->get_Nilai_Pegawai_tgl('id',$a,'', $idPegawai, $tglAwal, $tglAkhir);
						$idPegawai = $DataPegawai->get_Nilai_Pegawai_tgl('idPegawai', $a, '', $idPegawai, $tglAwal, $tglAkhir);
						$tanggal = $DataPegawai->get_Nilai_Pegawai_tgl('tanggal', $a, '', $idPegawai, $tglAwal, $tglAkhir);
						$nilai1 = $DataPegawai->get_Nilai_Pegawai_tgl('nilai1',$a,'', $idPegawai, $tglAwal, $tglAkhir);
						$nilai2 = $DataPegawai->get_Nilai_Pegawai_tgl('nilai2',$a,'', $idPegawai, $tglAwal, $tglAkhir);
						$nilai3 = $DataPegawai->get_Nilai_Pegawai_tgl('nilai3',$a,'', $idPegawai, $tglAwal, $tglAkhir);
						$nilai4 = $DataPegawai->get_Nilai_Pegawai_tgl('nilai4',$a,'', $idPegawai, $tglAwal, $tglAkhir);
						$nilai5 = $DataPegawai->get_Nilai_Pegawai_tgl('nilai5',$a,'', $idPegawai, $tglAwal, $tglAkhir);
						$Nama = $DataPegawai->get_Nilai_Pegawai_tgl('Nama',$a,'', $idPegawai, $tglAwal, $tglAkhir);

						echo "<tr id='".$id."' class='odd gradeX context'>";
						echo "<td>".$a."</td>";
						echo "<td>".$Nama."</td>";
						echo "<td>".$tanggal."</td>";
						echo "<td>".$nilai1."</td>";
						echo "<td>".$nilai2."</td>";
						echo "<td>".$nilai3."</td>";
						echo "<td>".$nilai4."</td>";
						echo "<td>".$nilai5."</td>";
						echo "</tr>";
					}
				}
			?>
        	</tbody>
          </table>
          </div>
                    <div class="col-sm-7" >
                    	<div style="margin-top:20px;">* tombol cetak akan muncul jika jumlah data ditabel sama dengan 6</div>
                    </div>
                    <div class="col-sm-5">
                        <?php 
							if ($JumlahData == 6){
						?>
                                  <form action="<?php echo $base?>laporan-penilaian-pegawai.php" method="post" name="cmb" style="float:right" id="cmb" target="_blank">
                                            <input type="hidden" name="tglAwal" value="<?php echo $tglAwal?>" />
                                            <input type="hidden" name="tglAkhir" value="<?php echo $tglAkhir?>" />
                                        	<input type="hidden" name="idPegawai" value="<?php echo $idPegawai?>">
                                        <button type="submit" class="btn btn-primary" id="OK" style="margin-top:20px;"> <i class="glyphicon glyphicon-print"></i> Cetak</button>
                                 </form>   
                          <?php } ?>	       

                    </div>

          
        </div><!-- /.box-body -->
      </div><!-- /.box -->
    </div><!-- /.col -->
  </div><!-- /.row -->
  
</section>
 
<link href="<?php echo $base?>plugins/datatables/dataTables.bootstrap.css" rel="stylesheet" type="text/css" />
<script src="<?php echo $base?>plugins/datatables/jquery.dataTables.min.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/datatables/dataTables.bootstrap.min.js" type="text/javascript"></script>
<script type="text/javascript">
  $(document).ready(function(){
	$("#example1").dataTable();
	
  });
	$("#nama").click(function(){
		$("#myModal1").modal('show');
	});

</script>

<div id="myModal1" class="modal fade" role="dialog">
  <div class="modal-dialog modal-lg">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Daftar Pegawai</h4>
      </div>
      <div class="modal-body">
      	<div class="table-responsive">
          <table id="example1" class="table table-bordered table-striped table-hover">
             <thead>
                <tr>
                    <th>No</th>
                    <th>Nama Dosen</th>
                    <th>NIK / NIP</th>
                </tr>
            </thead>
            <tbody>
            <?php
            	$JumlahData = $DataDosen->get_data_dosen('',$a,'jumlah');
				if ($JumlahData<=0){
					echo "<tr class='odd gradeX'>";
					echo "<td>No Data</td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "</tr>";	
				}else{
					for ($a=1;$a<=$JumlahData;$a++){
						$id = $DataDosen->get_data_dosen('Id',$a,'');
						$NIDN = $DataDosen->get_data_dosen('NIDN', $a, '');
						$Nama = $DataDosen->get_data_dosen('Nama',$a,'');
						$NIK = $DataDosen->get_data_dosen('NIP',$a,'');
						
						echo "<tr ids='".$id."-".$Nama."-".$NIK."' class='odd gradeX context pilih1'>";
						echo "<td>".$id."</td>";
						echo "<td>".$Nama."</td>";
						echo "<td>".$NIK."</td>";
						echo "</tr>";
					}
				}
			?>
        	</tbody>
          </table>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" id="closemodal" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>
<script>
	$(document).ready(function(){
		$('.pilih1').click(function(){
			var kode = $(this).attr('ids');
			var pecah = kode.split("-");	
				kodeDosen = pecah[0];
				bendahara = pecah[1];
				nip = pecah[2];
				
			$('#idPegawai').val(kodeDosen);
			$('#nama').val(bendahara);
			$('#nik').val(nip);			
			$('#myModal1').modal('hide')
		});
	});
</script>
