<?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-beban-tugas.xls");

	error_reporting(0);
	include "php_class/class_mysql.php";
	include "php_class/class_jadwal.php";
	include "php_class/class_dosen.php";	
	$DataDosen = new dataDosen;
	$DataDosen1 = new dataDosen;
	$DataDosen2 = new dataDosen;
	$DataJadwal = new dataJadwal;
	$DataJadwal2 = new dataJadwal;
	$DataJadwal3 = new dataJadwal;
	$DataJadwal4 = new dataJadwal;

	$semester = $_POST['semester'];;
	$tahun = $_POST['tahun'];
	$status = 'Dosen Dalam';
	$jurusan = $_POST['jurusan'];
	$program = $_POST['program'];
	//echo $program;
	
?>

<table width="100%" border="0">
  <tr>
    <td>Form B Dosen Dalam</td>
  </tr>
  <tr>
    <td>UNIVERSITAS WARMADEWA</td>
  </tr>
  <tr>
    <td>FAKULTAS EKONOMI</td>
  </tr>
  <tr>
    <td>JURUSAN <?php echo $jurusan?></td>
  </tr>
</table>
<table width="100%" border="1" style="border-collapse:collapse; margin-top:30px">
 <thead> 
  <tr>
    <td>NO</td>
    <td>DOSEN PENGAJAR</td>
    <td>GOL</td>
    <td>INSTANSI</td>
    <td>MATA KULIAH</td>
    <td>SMT</td>
    <td>JUR</td>
    <td>KLS</td>
    <td>SKS</td>
    <td>TTL SKS</td>
    <td>NO. REK</td>
  </tr>
</thead>
  		<?php
        $Jumlah1 = $DataJadwal->get_beban_rekap_formb('',$b,'jumlah', $semester, $tahun, $jurusan, $program, $status);
		for ($b=1;$b<=$Jumlah1;$b++){
		$nama1 = $DataJadwal->get_beban_rekap_formb('nama', $b, '', $semester, $tahun, $jurusan, $program, $status);
		$golongan = $DataJadwal->get_beban_rekap_formb('gol',$b,'', $semester, $tahun, $jurusan, $program, $status);
		$norek = $DataJadwal->get_beban_rekap_formb('norek',$b,'', $semester, $tahun, $jurusan, $program, $status);
		$subunitkerja = $DataJadwal->get_beban_rekap_formb('subunitkerja',$b,'', $semester, $tahun, $jurusan, $program, $status);
		
			$totalsks = 0;
			$Jumlah2 = $DataJadwal2->get_data_sk_nama_rekap('',$a,'jumlah', $nama1, $semester, $tahun, $program, $jurusan);
				for ($c=1;$c<=$Jumlah2;$c++){
					$matakuliah = $DataJadwal2->get_data_sk_nama_rekap('matakuliah',$c,'', $nama, $semester, $tahun, $program, $jurusan);
					$kelas = $DataJadwal2->get_data_sk_nama_rekap('kelas', $c, '', $nama, $semester, $tahun, $program, $jurusan);
					$sks = $DataJadwal2->get_data_sk_nama_rekap('sks',$c,'', $nama, $semester, $tahun, $program, $jurusan);
					$hari = $DataJadwal2->get_data_sk_nama_rekap('hari',$c,'', $nama, $semester, $tahun, $program, $jurusan);
					$ruang = $DataJadwal2->get_data_sk_nama_rekap('ruang',$c,'', $nama, $semester, $tahun, $program, $jurusan);
					$waktu = $DataJadwal2->get_data_sk_nama_rekap('waktu',$c,'', $nama, $semester, $tahun, $program, $jurusan);
					$sm = $DataJadwal2->get_data_sk_nama_rekap('semester',$c,'', $nama, $semester, $tahun, $program, $jurusan);
					$totalsks = $totalsks + $sks;

					if($c > 1){
						$nomer = '';	
					}else{
						$nomer = $b	;
					}
    ?>
  <tr>
    <td><?php echo $nomer?></td>
    <td><?php echo $nama1?></td>
    <td><?php echo $golongan?></td>
    <td><?php echo $subunitkerja?></td>
    <td><?php echo $matakuliah?></td>
    <td><?php echo $sm?></td>
    <td>
		<?php
			$sb = substr($kelas, 0, 1);
			if($sb == 'D'){
				$jur = 'AKUN';	
			}elseif($sb == 'B'){
				$jur = 'IESP';	
			}else{
				$jur = 'MAN';	
			}
			echo $jur;
		?>
    </td>
    <td><?php echo $kelas?></td>
    <td><?php echo $sks?></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <?php
   }
    ?>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><?php echo $totalsks?></td>
    <td><?php echo $norek?></td>
  </tr>
  <?php 
			$JmlTotal = $JmlTotal +  $totalsks;

  } ?>
  <tr>
    <td colspan="8">TOTAL SKS</td>
    <td><?php echo $JmlTotal?></td>
    <td><?php echo $JmlTotal?></td>
    <td>&nbsp;</td>
  </tr>
</table>