<?php
session_start();
error_reporting(0);
include "config/koneksi.php";
include "config/library.php";
include "config/fungsi_indotgl.php";
include "config/fungsi_seo.php";
if (isset($_SESSION[id])) {
	if ($_SESSION['level'] == 'admin') {
		$iden = mysqli_fetch_array(mysqli_query($conn,"SELECT * FROM users where username='$_SESSION[id]'"));
		$nama =  $iden['nama_lengkap'];
		$level = 'Administrator';
		$foto = 'dist/img/user.png';
	}

	$idt = mysqli_fetch_array(mysqli_query($conn,"SELECT * FROM identitas "));
	$dBayar = mysqli_fetch_array(mysqli_query($conn,"SELECT * FROM jenis_bayar WHERE idJenisBayar='$_GET[jenisBayar]'"));
?>
	<!DOCTYPE html>
	<html>

	<head>
		<title>Cetak - Rekapitulasi Pembayaran Siswa</title>
		<link rel="stylesheet" href="bootstrap/css/printer.css">
	</head>

	<body>
		<?php
		$tahun = $_GET['tahun'];
		$jenis = $_GET['jenisBayar'];
		//$tgl=$_GET['tgl'];
		$tgl1 = $_GET['tgl1'];
		$tgl2 = $_GET['tgl2'];
		?>
		<div class="col-xs-12">
			<table width="100%">
				<tr>
					<td width="100px" align="left"><img src="./gambar/logo/<?php echo $idt['logo_kiri']; ?>" height="60px"></td>
					<td valign="top">
						<h3 align="center" style="margin-bottom:8px ">
							<?php echo $idt['nmSekolah']; ?>
						</h3>
						<center><?php echo $idt['alamat']; ?></center>
					</td>
					<td width="100px" align="right"><img src="./gambar/logo/<?php echo $idt['logo_kanan']; ?>" height="60px"></td>
				</tr>
			</table>
			<hr>
			<h3 align="center">
				REKAPITULASI PEMBAYARAN <?php echo strtoupper($dBayar['nmJenisBayar']); ?>
				<br>
				<?php
				$sqlLap = mysqli_query($conn,"SELECT * FROM view_laporan_bayar_bulanan 
						WHERE idJenisBayar='$_GET[jenis]' AND idTahunAjaran='$_GET[tahun]' AND idSiswa='$_GET[siswa]' AND (DATE(tagihan_bulanan.tglBayar) BETWEEN '$tgl1' AND '$tgl2') AND statusBayar='1' ORDER BY urutan ASC");
				while ($rt = mysqli_fetch_array($sqlLap)) { //while per page

					$tahun = $_GET['tahun'];
					$jenis = $_GET['jenisBayar'];
					$kelas = $_GET['kelas'];

				?>
			</h3>
			<hr />
			<div class="col-xs-12">
				<table width="100%">
					<tr>
						<td width="100px" align="left"><img src="./gambar/logo/<?php echo $idt['logo_kiri']; ?>" height="40px"></td>
						<td valign="top">
							<h3 align="center" style="margin-bottom:8px ">
								<?php echo $idt['nmSekolah']; ?>
							</h3>
							<center><?php echo $idt['alamat']; ?></center>
						</td>
						<td width="100px" align="right"><img src="./gambar/logo/<?php echo $idt['logo_kanan']; ?>" height="40px"></td>
					</tr>
				</table>
				<hr style="margin:4px" />
				<center><b>Bukti Pembayaran : <?php echo $dBayar['nmJenisBayar']; ?></b></center>
				<hr style="margin:4px" />
				<div class="box box-info box-solid">
					<div class="box-header with-border">
						<table width="100%" style="margin-top:10px;margin-bottom:10px;">
							<tr>
								<td width="80px">Nama Siswa</td>
								<td width="8"> : </td>
								<td> <?php echo $dsw['nmSiswa']; ?></td>
								<td></td>
								<td align="right">Kelas : <?php echo $dsw['nmKelas']; ?></td>
							</tr>
							<tr>
								<td>NIS/NISN</td>
								<td>: </td>
								<td> <?php echo $dsw['nisSiswa']; ?>/<?php echo $dsw['nisnSiswa']; ?></td>
								<td></td>
								<td></td>
							</tr>
						</table>
					</div><!-- /.box-header -->
					<div class="box-body">
						<table class="table table-bordered table-striped">
							<thead>
								<tr>
									<th>Bulan</th>
									<th>Tgl Bayar</th>
									<th>Opsi Bayar</th>
									<th>Tagihan/Status</th>
								</tr>
							</thead>
							<tbody>
								<?php
								if ($rt['statusBayar'] == '1') {
									$stTagihan = buatRp($rt['jumlahBayar']) . "/Lunas";
								} else {
									$stTagihan = buatRp($rt['jumlahBayar']);
								}
								echo "<tr>
						<td>$rt[nmBulan]</td>
						<td align='center'>$rt[tglBayar]</td>
						<td align='center'>$rt[caraBayar]</td>
						<td align='right'>$stTagihan</td>
						</tr>";
								?>
							</tbody>
						</table>
					</div><!-- /.box-body -->
				</div><!-- /.box -->
			</div>
			<br />
			<table width="100%">
				<tr>
					<td align="center">
						<br />Kepala Sekolah,<br /><br /><br /><br />
						<b><u><?php echo $idt['nmKepsek']; ?></u></b>
					</td>
					<td align="center" width="400px">
						<?php echo $idt['kabupaten']; ?>, <?php echo tgl_raport(date("Y-m-d")); ?>
						<br />Bendahara Sekolah,<br /><br /><br /><br />
						<b><u><?php echo $idt['nmBendahara']; ?></u></b>

					</td>
				</tr>
			</table>
			<!--<footer></footer>-->
			<hr style="margin:20px 0px; border-style: dashed;">
		<?php
				} //end while per page
		?>
	</body>
	<script>
		window.print()
	</script>

	</html>
<?php
} else {
	include "login.php";
}
?>