<?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-pendaftaran.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;

							$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>No Pendaftaran</th>
                                    <th>Kegiatan</th>
                                    <th>Jumlah Bayar</th>

                                    <th>Jurusan</th>
                                    <th>Tempat Lahir</th>
                                    <th>Tanggal Lahir</th>
                                    <th>Jenis Kelamin</th>
                                    <th>Agama</th>

                                    <th>Alamat</th>
                                    <th>No telepon</th>
                                    <th>Email</th>
                                    <th>Asal Sekolah</th>
                                    <th>Nama Ibu</th>
                                    <th>Desa</th>
                                    <th>Kecamatan</th>
                                    <th>Kabupaten</th>
                                    <th>Provinsi</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('noPendaftaran',$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;
             

										$Jurusan = $DataMahasiswa->get_all_trans_total('Jurusan',$a,'', $tglawal, $tglakhir, $kegiatan1, $jurusan, $idOperator);
										$TempatLahir = $DataMahasiswa->get_all_trans_total('TempatLahir',$a,'', $tglawal, $tglakhir, $kegiatan1, $jurusan, $idOperator);
										$TglLahir = $DataMahasiswa->get_all_trans_total('TglLahir',$a,'', $tglawal, $tglakhir, $kegiatan1, $jurusan, $idOperator);
										$JK = $DataMahasiswa->get_all_trans_total('JK',$a,'', $tglawal, $tglakhir, $kegiatan1, $jurusan, $idOperator);
										$Agama = $DataMahasiswa->get_all_trans_total('Agama',$a,'', $tglawal, $tglakhir, $kegiatan1, $jurusan, $idOperator);
										$Alamat = $DataMahasiswa->get_all_trans_total('Alamat',$a,'', $tglawal, $tglakhir, $kegiatan1, $jurusan, $idOperator);
										$NoTelp = $DataMahasiswa->get_all_trans_total('NoTelp',$a,'', $tglawal, $tglakhir, $kegiatan1, $jurusan, $idOperator);
										$Email = $DataMahasiswa->get_all_trans_total('Email',$a,'', $tglawal, $tglakhir, $kegiatan1, $jurusan, $idOperator);
										$AsalSekolah = $DataMahasiswa->get_all_trans_total('AsalSekolah',$a,'', $tglawal, $tglakhir, $kegiatan1, $jurusan, $idOperator);
										$NamaOrangTua = $DataMahasiswa->get_all_trans_total('NamaOrangTua',$a,'', $tglawal, $tglakhir, $kegiatan1, $jurusan, $idOperator);
										$desa = $DataMahasiswa->get_all_trans_total('desa',$a,'', $tglawal, $tglakhir, $kegiatan1, $jurusan, $idOperator);
										$kecamatan = $DataMahasiswa->get_all_trans_total('kecamatan',$a,'', $tglawal, $tglakhir, $kegiatan1, $jurusan, $idOperator);
										$kabupaten = $DataMahasiswa->get_all_trans_total('kabupaten',$a,'', $tglawal, $tglakhir, $kegiatan1, $jurusan, $idOperator);
										$provinsi = $DataMahasiswa->get_all_trans_total('provinsi',$a,'', $tglawal, $tglakhir, $kegiatan1, $jurusan, $idOperator);

                                        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>".$jumlah."</td>";
										echo "<td>".$Jurusan."</td>";
                                        echo "<td>".$TempatLahir."</td>";
                                        echo "<td>".$TglLahir."</td>";
										echo "<td>".$JK."</td>";
                                        echo "<td>".$Agama."</td>";
                                        
										echo "<td>".$Alamat."</td>";
                                        echo "<td>".$NoTelp."</td>";
                                        echo "<td>".$Email."</td>";
                                        echo "<td>".$AsalSekolah."</td>";
										echo "<td>".$NamaOrangTua."</td>";
										echo "<td>".$desa."</td>";
										echo "<td>".$kecamatan."</td>";
                                        echo "<td>".$kabupaten."</td>";
                                        echo "<td>".$provinsi."</td>";
										echo "</tr>";
                                    }
                                }
                            ?>
                            </tbody>
                          </table>
