<?php
include("sess_check.php");

// deskripsi halaman
$pagedesc = "Data Konsumen";
include("layout_top.php");
include("dist/function/format_tanggal.php");
include("dist/function/format_rupiah.php");
?>
<!-- top of file -->
<!-- Page Content -->
<div id="page-wrapper">
	<div class="container-fluid">
		<div class="row">
			<div class="col-lg-12">
				<h1 class="page-header">Informasi Siswa</h1>
			</div><!-- /.col-lg-12 -->
		</div><!-- /.row -->

		<div class="row">
			<div class="col-lg-12"><?php include("layout_alert.php"); ?></div>
		</div>

		<div class="row">
			<div class="col-lg-12">
				<div class="panel panel-default">
					<div class="panel-body">
						<?php
						mysql_connect("localhost", "root", "");
						mysql_select_db("mansapas");

						$bagianWhere = "";

						if (isset($_POST['nisCat'])) {
							$nis = $_POST['nis'];
							if (empty($bagianWhere)) {
								$bagianWhere .= "nis = '$nis'";
							}
						}


						$query = "SELECT siswa.nis, siswa.nama_lengkap, kelas.keterangan,tingkatan.tingkatan, masuk.tahun_ajaran FROM siswa INNER JOIN kelas on kelas.id_kelas=siswa.id_kelas INNER JOIN tingkatan on tingkatan.id_tingkatan=kelas.id_tingkatan INNER JOIN masuk on masuk.id_tahun=tingkatan.id_tahun WHERE " . $bagianWhere;
						$hasil = mysql_query($query);
						echo "<table class='table table-hover'>";
						echo "<tr><th scop='col'>nis</th><th scop='col'>Nama Lengkap</th><th scop='col'>Tingkatan Kelas</th><th scop='col'>Kelas</th><th scop='col'>Tahun Ajaran</th>
           						</tr>";
						while ($data = mysql_fetch_array($hasil)) {
							echo "<tr><td>$data[nis]</td><td>$data[nama_lengkap]</td><td>$data[tingkatan]</td><td>$data[keterangan]</td><td>$data[tahun_ajaran]</td></tr>";
						}
						echo "</table>";
						?>

					</div>
				</div>
			</div>


			<div class="col-md-12">
				<div class="panel panel-default">
					<div class="panel-body">
						<?php
						mysql_connect("localhost", "root", "");
						mysql_select_db("mansapas");

						$bagianWhere = "";

						if (isset($_POST['nisCat'])) {
							$nis = $_POST['nis'];
							if (empty($bagianWhere)) {
								$bagianWhere .= "nis = '$nis'";
							}
						}


						$query = "SELECT trx.tgl_trx, trx.nis, trx.id_trx, tmp_spp.id_trx, spp.id_spp, spp.biaya, bulan.bulan, tmp_spp.status FROM trx INNER JOIN tmp_spp on tmp_spp.id_trx=trx.id_trx INNER JOIN spp on spp.id_spp=tmp_spp.id_spp INNER join bulan on bulan.id_bulan=spp.id_bulan WHERE " . $bagianWhere;
						$hasil = mysql_query($query);
						echo "<table class='table table-hover'>";
						echo "<tr><th scop='col'>Tanggal</th><th scop='col'>Bulan</th><th scop='col'>Sudah Bayar</th><th scop='col'>Status</th>
           						</tr>";
						while ($data = mysql_fetch_array($hasil)) {
							echo "<tr><td>$data[tgl_trx]</td><td>$data[bulan]</td><td>$data[biaya]</td><td>$data[status]</td></tr>";
						}
						echo "</table>";
						?>

					</div>
				</div>
			</div>

			<div class="col-md-12">
				<div class="panel panel-default">
					<div class="panel-body">
						<?php
						mysql_connect("localhost", "root", "");
						mysql_select_db("mansapas");

						$bagianWhere = "";

						if (isset($_POST['nisCat'])) {
							$nis = $_POST['nis'];
							if (empty($bagianWhere)) {
								$bagianWhere .= "nis = '$nis'";
							}
						}


						$query = "SELECT trx_lainya.tgl_trx, trx_lainya.id_trx_lainya, trx_lainya.nis, tmp_lainya.id_tmp_lainya, lainya.id_lainya, lainya.biaya, SUM(trx_lainya.tagihan) as total, jenis_pembayaran.id_jenis, jenis_pembayaran.jenis_pembayaran FROM trx_lainya INNER JOIN tmp_lainya on tmp_lainya.id_trx_lainya=trx_lainya.id_trx_lainya INNER JOIN lainya on lainya.id_lainya=tmp_lainya.id_lainya INNER JOIN jenis_pembayaran ON jenis_pembayaran.id_jenis=lainya.id_jenis WHERE " . $bagianWhere;
						$hasil = mysql_query($query);
						echo "<table class='table table-hover'>";
						echo "<tr><th scop='col'>Tanggal</th><th scop='col'>Nama Pembayaran</th><th scop='col'>Total Angsuran</th><th scop='col'>Sudah Dibayar</th>
           						</tr>";
						while ($data = mysql_fetch_array($hasil)) {
							echo "<tr><td>$data[tgl_trx]</td><td>$data[jenis_pembayaran]</td><td>$data[biaya]</td><td>$data[total]</td></tr>";
						}
						echo "</table>";
						?>

					</div>
				</div>
			</div>



			<div class="col-lg-6">
				<form class="form-horizontal" action="tmp_insert.php" method="POST" enctype="multipart/form-data">
					<div class="panel panel-default">
						<div class="panel-heading">
							<h3>Tambah Data Pembayaran SPP</h3>
						</div>
						<div class="panel-body">

							<div class="form-group">
								<label class="control-label col-sm-3">Pilih Bulan</label>
								<div class="col-sm-4">
									<?php
									mysql_connect("localhost", "root", "");
									mysql_select_db("mansapas");

									$query = "SELECT siswa.nis, spp.id_spp, kelas.keterangan, tingkatan.tingkatan, spp.biaya, bulan.bulan FROM siswa INNER JOIN kelas ON kelas.id_kelas=siswa.id_kelas INNER JOIN tingkatan ON tingkatan.id_tingkatan=kelas.id_tingkatan INNER JOIN spp on spp.id_tingkatan=tingkatan.id_tingkatan INNER JOIN bulan on bulan.id_bulan=spp.id_bulan WHERE " . $bagianWhere;
									$hasil = mysql_query($query);
									$no = 1;
									while ($data = mysql_fetch_array($hasil)) {
										echo "<input type='checkbox' value='$data[id_spp]' name='bulan$no' /> $data[bulan]<br />";
										$no++;
									}
									?>
									<input type="hidden" name="jumspp" value="<?php echo $no - 1; ?>" />
								</div>
							</div>

						</div>
						<div class="panel-footer">
							<button type="submit" name="simpan" class="btn btn-success">Simpan</button>

						</div>
					</div><!-- /.panel -->
				</form>
			</div>

			<div class="col-lg-6">
				<form class="form-horizontal" action="tmp_lainya_insert.php" method="POST" enctype="multipart/form-data">
					<div class="panel panel-default">
						<div class="panel-heading">
							<h3>Tambah Data Pembayaran Lain-lain</h3>
						</div>
						<div class="panel-body">

							<div class="form-group">

								<div class="col-sm-10">
									<?php
									mysql_connect("localhost", "root", "");
									mysql_select_db("mansapas");

									$query = "SELECT lainya.*, tingkatan.*, masuk.*, status.* FROM lainya, tingkatan, masuk, status WHERE lainya.id_tingkatan=tingkatan.id_tingkatan AND masuk.id_tahun=tingkatan.id_tahun AND status.id_status=masuk.id_status AND status.status BETWEEN 'Aktif' AND 'Aktif' ORDER by lainya.id_lainya ASC";
									$hasil = mysql_query($query);
									$no = 1;
									while ($data = mysql_fetch_array($hasil)) {
										echo "<input type='checkbox' value='$data[id_lainya]' name='nama_pembayaran$no' /> $data[nama_pembayaran]<br />";
										echo "<input type='text' class='form-control' name='bayar$no' /><br />";
										$no++;
									}
									?>
									<input type="hidden" name="jumlainya" value="<?php echo $no - 1; ?>" />
								</div>
							</div>

						</div>
						<div class="panel-footer">
							<button type="submit" name="simpan" class="btn btn-success">Simpan</button>

						</div>
					</div><!-- /.panel -->
				</form>
			</div>

		</div>
	</div> <!-- Large modal -->
	<div class="modal fade bs-example-modal" id="myModal" tabindex="-1" role="dialog" aria-hidden="true">
		<div class="modal-dialog modal-lg">
			<div class="modal-content">
				<div class="modal-body">
					<p>One fine body…</p>
				</div>
			</div>
		</div>
	</div>
</div><!-- /.panel -->
</div><!-- /.col-lg-12 -->
</div><!-- /.row -->
</div><!-- /.container-fluid -->
</div><!-- /#page-wrapper -->
<!-- bottom of file -->
<script type="text/javascript">
	$(document).ready(function() {
		$('#tabel-data').DataTable({
			"responsive": true,
			"processing": true,
			"columnDefs": [{
				"orderable": false,
				"targets": [4]
			}]
		});

		$('#tabel-data').parent().addClass("table-responsive");
	});
</script>
<script>
	var app = {
		code: '0'
	};

	$('[data-load-code]').on('click', function(e) {
		e.preventDefault();
		var $this = $(this);
		var code = $this.data('load-code');
		if (code) {
			$($this.data('remote-target')).load('karyawan_detail.php?code=' + code);
			app.code = code;

		}
	});
</script>
<?php
include("layout_bottom.php");
?>