<?php
	include "php_class/class_mysql.php";
	include "php_class/class_jadwal.php";
	$DataJadwal = new dataJadwal;
	$DataJadwal2 = new dataJadwal;
	$DataJadwal3 = new dataJadwal;
?>
<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').click(function(e){
		var kode = $(this).attr('id');
		$('#kodekunci').val(kode);
   		$("#menuklik").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+'edit-jadwal/'+ kode +'';
	});
	
	$('#nonaktif').click(function(){
		var kode = $('#kodekunci').val();
		if (confirm("Anda yakin me-nonaktifkan data dengan kode " + kode+"?")){
			window.location=''+base+'query-delete-jadwal/'+ kode +'';	
		}
	});
	
	$('#newdata').click(function(){
		var kode = $('#kodekunci').val();
		window.location=''+base+'add-detil-jadwal/'+ kode +'';
	});

  });
   
</script>
<section class="content-header">
  <h1>
    Data Surat Keputusan
  </h1>
  <ol class="breadcrumb">
    <li><a href="<?php echo $base?>index"><i class="fa fa-dashboard"></i> Home</a></li>
    <li class="active"> Data Surat Keputusan</li>
  </ol>
</section>
<section class="content">
  <div class="row">
    <div class="col-xs-12">
     
      <div class="box">
        <div class="box-header">
        </div><!-- /.box-header -->
        <div class="box-body">
					<div class="row">
                        <div class="col-sm-7" >
							<?php 
							$program = $_POST['program'];
							$tahun = $_POST['tahun'];
							$semester = $_POST['semester'];
							
								if ($tahun == '' ){
									$tahun = '2016/2017';
								}
								if ($semester == '' ){
									$semester = 'GENAP';
								}					
								if ($program == 'Reguler') {
									$program = 'Reguler';	
									$pr = 1;
								} else{
									$program = 'R. Sore - Eksekutif';
									$pr = 2;
								}	
											
									echo "<H3 style='margin-bottom:15px;'>Program : ".$program."</h3>";	
									echo "<H5 style='margin-bottom:15px;'>Tahun Akademik : ".$tahun."</h5>";
									echo "<H5 style='margin-bottom:15px;'>Semester Akademik : ".$semester."</h5>";
									
							?>
                        </div>
                        <div class="col-sm-5">
            <button type="submit" class="btn btn-primary" 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 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 Dosen</th>
                    <th>Semester Akademik</th>
                    <th>Hari</th>
                    <th>Tahun</th>
                    <th>Aksi</th>
                </tr>
            </thead>
            <tbody>
            <?php
            	$JumlahData = $DataJadwal->get_data_sk('',$a,'jumlah', $tahun, $semester, $program);
				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 "</tr>";	
				}else{
					for ($a=1;$a<=$JumlahData;$a++){
						$id = $DataJadwal->get_data_sk('id',$a,'', $tahun, $semester, $program);
						$dosen = $DataJadwal->get_data_sk('dosen', $a, '', $tahun, $semester, $program);
						$semester1 = $DataJadwal->get_data_sk('sm', $a, '', $tahun, $semester, $program);
						$hari1 = $DataJadwal->get_data_sk('hari', $a, '', $tahun, $semester, $program);
						$tahun1 = $DataJadwal->get_data_sk('tahun', $a, '', $tahun, $semester, $program);
						
						echo "<tr id='".$id."' class='odd gradeX'>";
						echo "<td>".$id."</td>";
						echo "<td>".$dosen."</td>";
						echo "<td>".$semester1."</td>";
						echo "<td>".$hari1."</td>";
						echo "<td>".$tahun1."</td>";
						echo "<td><a href='setting-tugas-mengajar/$id/$pr' target='_blank''>Cetak</a></td>";
						echo "</tr>";
					}
				}
			?>
        	</tbody>
          </table>
          </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-default" id="nonaktif">Print</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-surat-keputusan" method="post" name="cmb" style="margin-bottom:35px;" id="cmb">
            <div class="form-group">
                <label class="control-label">Kelas</label>
                <select class="form-control" name="program"  >
                <?php 
                    if ($program != "") {
                        echo "<option value='".$program."'>".$program."</option>";
                    }
                ?>
                    <option value="Reguler">Reguler</option>
                    <option value="R. Malam - Eksekutif">R. Malam - Eksekutif</option>
                </select>
            </div>
            <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>";
                    }
					    $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>

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