<?php
error_reporting(0);
// The function header by sending raw excel
header("Content-type: application/vnd-ms-excel");
 
// Defines the name of the export file "codelution-export.xls"
header("Content-Disposition: attachment; filename=data-ijin-cuti.xls");
 
// Add data table
	include "php_class/class_mysql.php";
	include "php_class/class_surat.php";
	
	$DataSurat = new DataSurat;
	$tglawal = $_POST['tglawal'];
	$tglakhir = $_POST['tglakhir'];
	
	if($tglawal == ''){
		$tglawal = date("Y-m-d");	
	}
	if($tglakhir == ''){
		$tglakhir = date("Y-m-d");	
	}
	?>
          <table>
             <thead>
                <tr>
                    <th>No</th>
                    <th>Nama Dosen</th>
                    <th>NIP</th>
                    <th>Atasan Langsung</th>
                    <th>NIP  Atasan Langsung</th>
                    <th>Tanggal Awal</th>
                    <th>Tanggal Akhir</th>
                    <th>Lama Ijin</th>
                    <th>Alasan</th>
                </tr>
            </thead>
            <tbody>
            <?php				
			
            	$JumlahData = $DataSurat->get_cuti_all('',$a,'jumlah', $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 "</tr>";	
				}else{
					for ($a=1;$a<=$JumlahData;$a++){
						$id = $DataSurat->get_cuti_all('id',$a,'', $tglawal, $tglakhir);
						$dosen = $DataSurat->get_cuti_all('dosen',$a,'', $tglawal, $tglakhir);
						$nipdosen = $DataSurat->get_cuti_all('nipdosen',$a,'', $tglawal, $tglakhir);
						$atasan = $DataSurat->get_cuti_all('atasan',$a,'', $tglawal, $tglakhir);
						$nipatasan = $DataSurat->get_cuti_all('nipatasan',$a,'', $tglawal, $tglakhir);
						$tglawal = $DataSurat->get_cuti_all('tglawal',$a,'', $tglawal, $tglakhir);
						$tglakhir = $DataSurat->get_cuti_all('tglakhir',$a,'', $tglawal, $tglakhir);
						$cuti = $DataSurat->get_cuti_all('cuti',$a,'', $tglawal, $tglakhir);
						$alasan = $DataSurat->get_cuti_all('alasan',$a,'', $tglawal, $tglakhir);
						
						echo "<tr id='".$id."' class='odd gradeX context'>";
						echo "<td>".$a."</td>";
						echo "<td>".$dosen."</td>";
						echo "<td>".$nipdosen."</td>";
						echo "<td>".$atasan."</td>";
						echo "<td>".$nipatasan."</td>";
						echo "<td>".$tglawal."</td>";
						echo "<td>".$tglakhir."</td>";
						echo "<td>".$cuti."</td>";
						echo "<td>".$alasan."</td>";
						echo "</tr>";
					}
				}
			?>
        	</tbody>
          </table>
