<?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-daftar-ulang.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_grup.php";
	include "php_class/class_transaksi.php";
	
	$DataTransaksi = new DataTransaksi;
	$datagrup = new DataGrup;
	$DataMahasiswa = new DataMahasiswa;
	$DataTemplate = new DataTemplate;
	$DataTemplate2 = new DataTemplate;
	$DataTemplate3 = new DataTemplate;
	$DataTemplate4 = new DataTemplate;
	$DataTemplate5 = new DataTemplate;
	$DataTemplate6 = new DataTemplate;
	$DataTemplate7 = new DataTemplate;
	$DataTemplate8 = new DataTemplate;
	$DataTemplate9 = new DataTemplate;

							$operator = $_POST['operator'];
							list($idOperator, $NamaOperator) = explode('-', $operator);

							$kegiatan = $_POST['kegiatan'];
							$kegiatan1 = $kegiatan;	
							$jurusan = $_POST['jurusan'];
							$cetakjurusan = $jurusan;
							$tglawal = $_POST['tglawal'];
							$tglawal = 	substr($tglawal, 0, 10);
							$tglakhir = $_POST['tglakhir'];
							$tglakhir = substr($tglakhir, 0, 10);
							
								if ($idOperator == ""){
									$NamaOperator = "Semua Operator";	
								}

								if ($jurusan == "" ){
									$cetakjurusan = 'Semua';
									}					
								
								if ($kegiatan == ""){
									$kegiatan = 'Semua';
									$kegiatan1 = '';
									}								
								
								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 Transaksi</th>
                                    <th>Nama Mahasiswa</th>
                                    <th>NPM</th>
                                    <th>Kegiatan</th>
                                    <th>Jumlah Bayar</th>
                            <?php
								$ids = 'G0022';
								$JumlahData = $datagrup->get_detil('',$a,'jumlah', $ids);
									for ($a=1;$a<=$JumlahData;$a++){
                                        $namaTrx = $datagrup->get_detil('NamaTRX',$a,'', $ids);
                                        $BiayaReguler = $datagrup->get_detil('BiayaReguler',$a,'', $ids);
                                        $BiayaNonReguler = $datagrup->get_detil('BiayaNonReguler',$a,'', $ids);
                                        echo "<th>".$namaTrx."</th>";
                                    }
                            ?>
                                </tr>
                            </thead>
                            <tbody>
                            <?php
								$total = 0;
								$jumlahtotal = 0;
								
								$JumlahData = $DataMahasiswa->get_all_trans_total('',$a,'jumlah', $tglawal, $tglakhir, $kegiatan1, $jurusan, $idOperator);
                                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++){
										$no = $DataMahasiswa->get_all_trans_total('NoTRX',$a,'', $tglawal, $tglakhir, $kegiatan1, $jurusan, $idOperator);
                                        $tglTRX = $DataMahasiswa->get_all_trans_total('tgInput',$a,'', $tglawal, $tglakhir, $kegiatan1, $jurusan, $idOperator);
										$NPM = $DataMahasiswa->get_all_trans_total('NPM',$a,'', $tglawal, $tglakhir, $kegiatan1, $jurusan, $idOperator);
                                        $jumlah = $DataMahasiswa->get_all_trans_total('total',$a,'', $tglawal, $tglakhir, $kegiatan1, $jurusan, $idOperator);
										$NamaMhs = $DataMahasiswa->get_all_trans_total('Nama',$a,'', $tglawal, $tglakhir, $kegiatan1, $jurusan, $idOperator);
										$kegiatan = $DataMahasiswa->get_all_trans_total('Des',$a,'', $tglawal, $tglakhir, $kegiatan1, $jurusan, $idOperator);
										$jumlahtotal = $jumlahtotal + $jumlah;

                                        echo "<tr id='".$no."' class='odd gradeX context'>";
                                        echo "<td>".$no."</td>";
                                        echo "<td>".$NamaMhs."</td>";
                                        echo "<td>".$NPM."</td>";
										echo "<td>".$kegiatan."</td>";
                                        echo "<td>".number_format($jumlah)."</td>";
                                        $BiayaReguler = $DataTemplate->get_template_single_by_id('BiayaReguler', 20);
                                        echo "<td>".number_format($BiayaReguler)."</td>";
                                        $BiayaReguler = $DataTemplate2->get_template_single_by_id('BiayaReguler', 16);
                                        echo "<td>".number_format($BiayaReguler)."</td>";
                                        $BiayaReguler = $DataTemplate3->get_template_single_by_id('BiayaReguler', 21);
                                        echo "<td>".number_format($BiayaReguler)."</td>";
                                        $BiayaReguler = $DataTemplate4->get_template_single_by_id('BiayaReguler', 22);
                                        echo "<td>".number_format($BiayaReguler)."</td>";
                                        $BiayaReguler = $DataTemplate5->get_template_single_by_id('BiayaReguler', 47);
                                        echo "<td>".number_format($BiayaReguler)."</td>";
                                        $BiayaReguler = $DataTemplate6->get_template_single_by_id('BiayaReguler', 49);
                                        echo "<td>".number_format($BiayaReguler)."</td>";
                                        $BiayaReguler = $DataTemplate7->get_template_single_by_id('BiayaReguler', 17);
                                        echo "<td>".number_format($BiayaReguler)."</td>";
                                        $BiayaReguler = $DataTemplate8->get_template_single_by_id('BiayaReguler', 50);
                                        echo "<td>".number_format($BiayaReguler)."</td>";
                                        $BiayaReguler = $DataTemplate9->get_template_single_by_id('BiayaReguler', 48);
                                        echo "<td>".number_format($BiayaReguler)."</td>";
	                                    echo "</tr>";	

									}
                                }
                            ?>




                            </tbody>
                          </table>
