<?php
	include "php_class/class_mysql.php";
	include "php_class/class_absen.php";
	$dataabsen = new dataabsen;
	$dataabsen2 = new dataabsen;
	$dataabsen3 = new dataabsen;
	$dataabsen4 = new dataabsen;
	include "php_class/class_jadwal.php";
	$DataJadwal = new dataJadwal;
?>
<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>

<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(){
	var base = <?php echo json_encode($base);?>;
	
	$("#example1").dataTable();
		$("#setting").click(function(){
			$("#myModal").modal('show');
		});
	
	/*$('.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+'query-absen-dosen-hadir/'+ kode;
	});
	
	$('#nonaktif').click(function(){
		var kode = $('#kodekunci').val();
		window.location=''+base+'query-absen-dosen-tidak-hadir/'+ kode;
	});
	
	$('#newdata').click(function(){
		var kode = $('#kodekunci').val();
		window.location=''+base+'add-detil-jadwal/'+ kode +'';
	});

  });
   
</script>
<section class="content-header">
  <h1>
    Rekap Kehadiran Dosen
  </h1>
  <ol class="breadcrumb">
    <li><a href="<?php echo $base?>index"><i class="fa fa-dashboard"></i> Home</a></li>
    <li class="active">Rekap Data Kehadiran Dosen</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-7" >
							<?php 
							$tanggalawal = $_POST['tanggalawal'];
							$tanggalawal = substr($tanggalawal, 0, 10);
							$tanggalakhir = $_POST['tanggalakhir'];
							$tanggalakhir = substr($tanggalakhir, 0, 10);
							
							$hari = $_POST['hari'];
							$tahun = $_POST['tahun'];
							$semester = $_POST['semester'];
							$program = $_POST['program'];
							$jurusan = $_POST['jurusan'];
							
							
								if ($tahun == '' ){
									$tahun = '2016/2017';
								}
								if ($semester == '' ){
									$semester = 'GENAP';
								}					
								if ($hari == '' ){
									$hari = 'SEMUA';
								}
								if ($tanggalawal == '' ){
									$tanggalawal = date('Y-m-d');
								}
								if ($tanggalakhir == '' ){
									$tanggalakhir = date('Y-m-d');
								}
								if($program == ''){
									$program = 'SEMUA';
								}
								if($jurusan == ''){
									$jurusan = 'SEMUA';	
								}
					

									echo "<H3 style='margin-bottom:15px;'>Hari : ".$hari."</h3>";
									echo "<H5 style='margin-bottom:15px;'>Tanggal Awal : ".$tanggalawal."</h5>";
									echo "<H5 style='margin-bottom:15px;'>Tanggal Akhir : ".$tanggalakhir."</h5>";
									echo "<H5 style='margin-bottom:15px;'>Tahun Akademik : ".$tahun."</h5>";
									echo "<H5 style='margin-bottom:15px;'>Semester Akademik : ".$semester."</h5>";
									echo "<H5 style='margin-bottom:15px;'>Program : ".$semester."</h5>";
									echo "<H5 style='margin-bottom:15px;'>Jurusan : ".$jurusan."</h5>";
								
								
							?>
                        </div>
                        <div class="col-sm-5">
            <button type="submit" class="btn btn-success" id="setting" style="margin-top:20px; float:right"> <i class="glyphicon glyphicon glyphicon glyphicon-edit" style="padding-right:4px;"></i>Setting</button>
                        </div>
                	</div>        
			</div>
        <div class="box-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>Mata Kuliah</th>
                    <th>Kelas</th>
                    <th>Hari</th>
                    <th>Waktu</th>
                    <th>Jumlah Kehadiran</th>
                </tr>
            </thead>
            <tbody>
            <?php
            	$JumlahData = $dataabsen->get_data_jadwal_rekap('',$a,'jumlah', $semester, $tahun, $jurusan, $program, $tanggalawal, $tanggalakhir, $hari);
				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 "</tr>";	
				}else{
					for ($a=1;$a<=$JumlahData;$a++){
						$id = $dataabsen->get_data_jadwal_rekap('id',$a,'', $semester, $tahun, $jurusan, $program, $tanggalawal, $tanggalakhir, $hari);
						$dosen = $dataabsen->get_data_jadwal_rekap('dosen', $a, '', $semester, $tahun, $jurusan, $program, $tanggalawal, $tanggalakhir, $hari);
						$matakuliah = $dataabsen->get_data_jadwal_rekap('matakuliah',$a,'', $semester, $tahun, $jurusan, $program, $tanggalawal, $tanggalakhir, $hari);
						$kelas = $dataabsen->get_data_jadwal_rekap('kelas',$a,'', $semester, $tahun, $jurusan, $program, $tanggalawal, $tanggalakhir, $hari);
						$haris = $dataabsen->get_data_jadwal_rekap('hari',$a,'', $semester, $tahun, $jurusan, $program, $tanggalawal, $tanggalakhir, $hari);
						$waktu = $dataabsen->get_data_jadwal_rekap('waktu',$a,'', $semester, $tahun, $jurusan, $program, $tanggalawal, $tanggalakhir, $hari);
						$jumlah = $dataabsen->get_data_jadwal_rekap('jumlah',$a,'', $semester, $tahun, $jurusan, $program, $tanggalawal, $tanggalakhir, $hari);
						
						echo "<tr id='".$id."' class='odd gradeX'>";
						echo "<td id='".$id."' class='context'>".$a."</td>";
						echo "<td id='".$id."' class='context'>".$dosen."</td>";
						echo "<td id='".$id."' class='context'>".$matakuliah."</td>";
						echo "<td id='".$id."' class='context'>".$kelas."</td>";
						echo "<td id='".$id."' class='context'>".$haris."</td>";
						echo "<td id='".$id."' class='context'>".$waktu."</td>";
						echo "<td id='".$id."' class='context'><strong>".$jumlah."</strong></td>";
						echo "</tr>";
					}
				}
			?>
        	</tbody>
          </table>
          </div>
         </div>
        <div class="box-body">
					<div class="row">
                        <div class="col-sm-7" >
                        </div>
                        <div class="col-sm-5">
                          <form action="<?php echo $base?>laporan-kehadiran-dosen.php" method="post" name="cmb" style="float:right; " id="cmb" target="_blank">
                                    <input type="hidden" name="semester" value="<?php echo $semester?>" />
                                    <input type="hidden" name="tahun" value="<?php echo $tahun?>" />
                                    <input type="hidden" name="jurusan" value="<?php echo $jurusan?>" />
                                    <input type="hidden" name="program" value="<?php echo $program?>" />
                                    <input type="hidden" name="tanggalawal" value="<?php echo $tanggalawal?>" />
                                    <input type="hidden" name="tanggalakhir" value="<?php echo $tanggalakhir?>" />
                                    <input type="hidden" name="hari" value="<?php echo $hari?>" />
                                    <input type="hidden" name="program" value="<?php echo $program?>" />
                                <button type="submit" class="btn btn-primary" id="OK" style="margin-top:20px;"> <i class="glyphicon glyphicon-print"></i> Cetak Laporan</button>
                         </form>   
                          <form action="<?php echo $base?>tabel-kehadiran-dosen.php" method="post" name="cmb" style="float:right; " id="cmb" target="_blank">
                                    <input type="hidden" name="semester" value="<?php echo $semester?>" />
                                    <input type="hidden" name="tahun" value="<?php echo $tahun?>" />
                                    <input type="hidden" name="jurusan" value="<?php echo $jurusan?>" />
                                    <input type="hidden" name="program" value="<?php echo $program?>" />
                                    <input type="hidden" name="tanggalawal" value="<?php echo $tanggalawal?>" />
                                    <input type="hidden" name="tanggalakhir" value="<?php echo $tanggalakhir?>" />
                                    <input type="hidden" name="hari" value="<?php echo $hari?>" />
                                    <input type="hidden" name="program" value="<?php echo $program?>" />
                                <button type="submit" class="btn btn-success" id="OK" style="margin-top:20px; margin-right:10px"> <i class="glyphicon glyphicon-print"></i> Export Excel</button>
                         </form>   

                        </div>
                	</div>        
			</div>
          <div id="menuklik" class="modal fade" role="dialog">
          	<div class="modal-dialog modal-sm">
                <div class="modal-content">
                	<div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                        <h5 class="modal-title">Aksi</h5>
                    </div>
                  	<div class="modal-body">
                        <input type="hidden" value="" id="kodekunci">
                        <div align="center">
                        <p><button type="button" class="btn btn-success" id="editdata">Hadir</button></p>
                        <p><button type="button" class="btn btn-warning" id="nonaktif">Tidak Hadir</button></p>
                        </div>
                        
                     </div>
                </div>
            </div>
          </div>
          
          
        </div><!-- /.box-body -->
      </div><!-- /.box -->
    </div><!-- /.col -->
  </div><!-- /.row -->
  
</section>
 
<div id="myModal" 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">Setting</h4>
      </div>
      <div class="modal-body">
          <form action="<?php echo $base?>data-rekap-absen-dosen" method="post" name="cmb" style="margin-bottom:35px;" id="cmb">
            <div class="form-group">
                <label class="control-label">Tahun Akademik</label>
                <select class="form-control" name="tahun">
                <?php 
                    if ($tahun != "") {
                        echo "<option value='".$tahun."'>".$tahun."</option>";
                    }
					    $DataJadwal2 = new dataJadwal; 
						$JumlahData = $DataJadwal2->get_all_tahun('',$a,'jumlah');	
                            for ($a=1;$a<=$JumlahData;$a++){
                            $tahun = $DataJadwal2->get_all_tahun('tahun',$a,'');
                       		echo "<option value=".$tahun.">".$tahun."</option>";
                        }
                ?>
                </select>
			</div>
            <div class="form-group">
                <label class="control-label">Semester</label>
                <select class="form-control" name="semester">
                <?php 
                    if ($semester != "") {
                        echo "<option value='".$semester."'>".$semester."</option>";
                    }
                ?>
                	<option value="GENAP">GENAP</option>
                    <option value="GANJIL">GANJIL</option>
                </select>
			</div>
            <div class="form-group">
                <label class="control-label">Hari</label>
                <select class="form-control" name="hari">
                <?php 
                    if ($hari != "") {
                        echo "<option value='".$hari."'>".$hari."</option>";
                    }
                ?>
                	<option value="SEMUA">SEMUA</option>
                    <option value="SENIN">SENIN</option>
                    <option value="SELASA">SELASA</option>
                    <option value="RABU">RABU</option>
                    <option value="KAMIS">KAMIS</option>
                    <option value="JUMAT">JUMAT</option>
                    <option value="SABTU">SABTU</option>
                </select>
			</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="tglProposal2">
                        <input required="required" class="form-control" type="text" value="<?php echo $tanggalawal?>" placeholder="tanggal proposal" readonly id="tglProposal">
                        <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="tglProposal2" name="tanggalawal" value="<?php echo $tanggalawal?>" />
                        <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="tglProposal1">
                        <input required="required" class="form-control" type="text" value="<?php echo $tanggalakhir?>" placeholder="tanggal proposal" readonly id="tglProposal1">
                        <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="tglProposal1" name="tanggalakhir" value="<?php echo $tanggalakhir?>" />
                        <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">Program</label>
                <select class="form-control" name="program">
                <?php 
                    if ($program != "") {
                        echo "<option value='".$program."'>".$program."</option>";
                    }
                ?>
                	<option value="SEMUA">SEMUA</option>
                    <option value="REGULER">REGULER</option>
                    <option value="R. SORE">R. SORE</option>
                </select>
			</div>
            <div class="form-group">
                <label class="control-label">Jurusan</label>
                <select class="form-control" name="jurusan">
                    <option value="SEMUA">SEMUA</option>
                    <option value="AKUNTANSI">AKUNTANSI</option>
                    <option value="MANAJEMEN">MANAJEMEN</option>
                    <option value="IESP">IESP</option>
                </select>
			</div>
                <button type="submit" class="btn btn-primary" id="OK" style="margin-top:20px;"> <i class="glyphicon glyphicon glyphicon-ok-circle"></i> OK</button>
         </form>   
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" id="closemodal" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>
