<?php
	include "php_class/class_mysql.php";
	include "php_class/class_proposal.php";
	$DataProposal = new DataProposal;
?>
<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();
	
	$('.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-operator/'+ 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 +'';	
		}
	});
	
	$('#cetak').click(function(){
		var kode = $('#kodekunci').val();
		window.location=''+base+'cetak-proposal/'+ kode +'';
	});

  });
   
</script>
<section class="content-header">
  <h1>
    Data Proposal
  </h1>
  <ol class="breadcrumb">
    <li><a href="<?php echo $base?>index"><i class="fa fa-dashboard"></i> Home</a></li>
    <li class="active">Data Proposal</li>
  </ol>
</section>
<section class="content">
  <div class="row">
    <div class="col-xs-12">
     
      <div class="box">
        <div class="box-header">
            <div class="row">
                <div class="col-sm-7" >
					<div class="form-group">
                     <?php 
					 
                        $tahun = $_POST['tahun'];
                     ?>
                          <form action="<?php echo $base?>data-proposal" method="post" name="cmb1" style="margin-bottom:35px;">
                            <label for="Operator" class="control-label">Tahun Pendaftaran</label>
                            <select class="form-control" name="idAngkatan" onChange="cmb1.submit();">
                                <?php
                                    if ($tahun == "") {
                                        $tahun = date('Y');
                                        }
                                        echo "<option value='".$tahun."'>".$tahun."</option>";
							
							$JumlahData = $DataProposal->get_tahun_proposal('',$a,'jumlah');	
                            for ($a=1;$a<=$JumlahData;$a++){
                            	$tahun = $DataProposal->get_tahun_proposal('tahun',$a,'');

							echo "<option value=".$tahun.">".$tahun."</option>";
							}
		
                                ?>
                            </select>
                         
                         </form>
                         </div>  
        	</div>
            <div class="col-sm-5">
                  <a style="float:right"  href="<?php echo $base?>add-proposal" class="btn btn-primary">
                    <i class="glyphicon glyphicon-plus-sign"></i>
                        Daftar Proposal
                  </a>
			</div>
        </div><!-- /.box-header -->
        <div class="box-body">
        <div class="table-responsive">
          <table id="example1" class="table table-bordered table-striped table-hover">
             <thead>
                <tr>
                    <th>NPM</th>
                    <th>Nama Mahasiswa</th>
                    <th>Tanggal</th>
                </tr>
            </thead>
            <tbody>
            <?php
            	$JumlahData = $DataProposal->get_proposal('',$a,'jumlah', $tahun);
				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 = $DataProposal->get_proposal('id',$a,'', $tahun);
						$NPM = $DataProposal->get_proposal('NPM',$a,'', $tahun);
						$namaMhs = $DataProposal->get_proposal('namaMhs',$a,'', $tahun);
						$idMhs = $DataProposal->get_proposal('idMhs',$a,'', $tahun);
						$isAktif = $DataProposal->get_proposal('isAktif',$a,'', $tahun);
						$tanggalProposal = $DataProposal->get_proposal('tanggalProposal', $a, '', $tahun);
						
						if ($isAktif=='1'){
							$Status = 'Aktif';
						}else{
							$Status ='Non Aktif';
						}
						echo "<tr id='".$idMhs."' class='odd gradeX context'>";
						echo "<td>".$NPM."</td>";
						echo "<td>".$namaMhs."</td>";
						echo "<td>".$tanggalProposal."</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-primary" id="cetak"><i class='glyphicon glyphicon-print'></i>Cetak</button></p>
                        </div>
                        
                     </div>
                </div>
            </div>
          </div>
          
          
        </div><!-- /.box-body -->
      </div><!-- /.box -->
    </div><!-- /.col -->
  </div><!-- /.row -->
  
</section>
 
