<?php
// 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-skripsi.xls");
 
// Add data table
?>
<?php
	include "php_class/class_mysql.php";
	include "php_class/class_template.php";
	include "php_class/class_mahasiswa.php";
	include "php_class/class_proposal.php";
	$DataProposal = new DataProposal;
	$DataMahasiswa = new DataMahasiswa;

							$program = $_POST['program'];
							$kegiatan = $_POST['kegiatan'];
							$jurusan = $_POST['jurusan'];
							$cetakjurusan = $jurusan;
							$tglawal = $_POST['tglawal'];
							$tglawal = 	substr($tglawal, 0, 10);
							$tglakhir = $_POST['tglakhir'];
							$tglakhir = substr($tglakhir, 0, 10);
							
								if ($program == '121') {
									$program1 = 'Reguler';	
								} else{
									$program1 = 'R. Malam - Eksekutif';
									$program = '122';	
								}					
								
								if ($kegiatan == "" ){
									$cetakkegiatan = 'Pendaftaran Proposal';
									$kegiatan = 'proposal';
								}else if ($kegiatan == 'proposal'){
									$cetakkegiatan = 'Pendaftaran Proposal';	
								}else if ($kegiatan == 'skripsi'){
									$cetakkegiatan = 'Pendaftaran Skripsi';		
								}					

								if ($jurusan == "" ){
									$cetakjurusan = 'Semua';
									}					
								
								if ($tglawal == "") {
									$tglawal = date('Y-m-d');
								}

								if ($tglakhir == "") {
									$tglakhir = date('Y-m-d');
								}
								
								$haritglAwal = substr($tglawal, 8, 2);
								$bulantglAwal = substr($tglawal, 5, 2);
								$tahuntglAwal = substr($tglawal, 0, 4);
								$cetaktglAwal = $haritglAwal."-".$bulantglAwal."-".$tahuntglAwal; 
								
								$haritglAkhir = substr($tglakhir, 8, 2);
								$bulantglAkhir = substr($tglakhir, 5, 2);
								$tahuntglAkhir = substr($tglakhir, 0, 4);
								$cetaktglAkhir = $haritglAkhir."-".$bulantglAkhir."-".$tahuntglAkhir; 

?>


                          <table border="1">
                             <thead>
                                <tr>
                                    <th>NO</th>
                                    <th>Nama Mahasiswa</th>
                                    <th>NPM</th>
                                    <th>Tanggal Proposal</th>
                                    <th>Judul</th>
                                    <th>Pendamping 1</th>
                                    <th>Pendamping 2</th>
                                    <th>Pendamping 3</th>
                                    <th>Pendamping 4</th>
                                    <th>Pendamping 5</th>
                                </tr>
                            </thead>
                            <tbody>
                            <?php
								$total = 0;
								$jumlahtotal = 0;
								
								$JumlahData = $DataProposal->get_skripsi_total('',$a,'jumlah', $tglawal, $tglakhir, $program, $jurusan, $kegiatan);
                                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 "<td></td>";
									echo "<td></td>";
                                    echo "</tr>";	
                                }else{
                                    
									for ($a=1;$a<=$JumlahData;$a++){
                                        $tglTRX = $DataProposal->get_skripsi_total('tanggalProposal',$a,'', $tglawal, $tglakhir, $program, $jurusan, $kegiatan);
										$NPM = $DataProposal->get_skripsi_total('NPM',$a,'', $tglawal, $tglakhir, $program, $jurusan, $kegiatan);
										$NamaMhs = $DataProposal->get_skripsi_total('namaMhs',$a,'', $tglawal, $tglakhir, $program, $jurusan, $kegiatan);
										$judul = $DataProposal->get_skripsi_total('judul',$a,'', $tglawal, $tglakhir, $program, $jurusan, $kegiatan);
										$namaPendamping1 = $DataProposal->get_skripsi_total('namaPendamping1',$a,'', $tglawal, $tglakhir, $program, $jurusan, $kegiatan);
										$namaPendamping2 = $DataProposal->get_skripsi_total('namaPendamping2',$a,'', $tglawal, $tglakhir, $program, $jurusan, $kegiatan);
										$namaPendamping3 = $DataProposal->get_skripsi_total('namaPendamping3',$a,'', $tglawal, $tglakhir, $program, $jurusan, $kegiatan);
										$namaPendamping4 = $DataProposal->get_skripsi_total('namaPendamping4',$a,'', $tglawal, $tglakhir, $program, $jurusan, $kegiatan);
										$namaPendamping5 = $DataProposal->get_skripsi_total('namaPendamping5',$a,'', $tglawal, $tglakhir, $program, $jurusan, $kegiatan);

  


                                        echo "<tr class='odd gradeX context'>";
                                        echo "<td>".$a."</td>";
                                        echo "<td>".$NamaMhs."</td>";
                                        echo "<td>".$NPM."</td>";
										echo "<td>".$tglTRX."</td>";
										echo "<td>".$judul."</td>";
										echo "<td>".$namaPendamping1."</td>";
										echo "<td>".$namaPendamping2."</td>";
										echo "<td>".$namaPendamping3."</td>";
										echo "<td>".$namaPendamping4."</td>";
										echo "<td>".$namaPendamping5."</td>";
                                        echo "</tr>";
                                    }
                                }
                            ?>
                            </tbody>
                          </table>
