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

// deskripsi halaman
$pagedesc = "Laporan Data Transaksi Lainya";
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">RINCIAN KEBUTUHAN OPERASIONAL KEGIATAN BELAJAR (SPP)</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">
					<div class="panel-heading">
					<a href="newanggaranspp_tambah.php" class="btn btn-success">Tambah</a>
						<a href="importanggaranspp2_tambah.php" class="btn btn-danger">Import</a>
						<a href="laporan_anggaransppperperiodewaka.php" class="btn btn-warning">CetaK Per-Periode</a>
						
						
							</div>
						<form method="get" name="laporan" onSubmit="return valid();">
							<div class="form-group">
							<div class="col-sm-5">
							<input type="text" class="form-control" name="jabatan" placeholder="Masukan Jabatan" required>
									
									
								</div>
								
								<div class="col-sm-2">
									
									<input type="submit" name="submit" value="Lihat Pengeluaran" class="btn btn-primary">
								</div>
							</div>
						</form>
					</div>
				</div>
				<?php
				if (isset($_GET['submit'])) {
					$no = 0;
					$jabatan = $_GET['jabatan'];
					$sql = "SELECT anggaranspp2.*, penanggung_jawab.*, tahun_pelajaran.*, status.* FROM anggaranspp2, penanggung_jawab, tahun_pelajaran, status WHERE anggaranspp2.nip=penanggung_jawab.nip and anggaranspp2.id_tahun=tahun_pelajaran.id_tahun AND tahun_pelajaran.id_status=status.id_status and status.id_status BETWEEN '1' and '1' AND penanggung_jawab.jabatan BETWEEN '$jabatan' and '$jabatan' ORDER BY anggaranspp2.id_anggaranspp2 ASC";
					$ress = mysqli_query($conn, $sql);
				?>

					<div class="row">
						<div class="col-lg-12">
							<div class="panel panel-default">
								<div class="panel-body">
									<table class="table table-striped table-bordered table-hover" id="tabel-data">
										<thead>
											<tr>
												<th width="1%">No</th>
												<th width="5%">Tanggal</th>
												<th width="20%">Uraian</th>
												<th width="5%">Jumlah Anggaran</th>
												<th width="5%">Realisasi</th>
												<th width="10%">Jabatan</th>
												<th width="5%">Opsi</th>
											</tr>
										</thead>
										<tbody>
											<?php
											$ttl = 0;
											$ttl2 = 0;
											$ttl3= 0;
											$ttl4 = 0;
											
											$i = 1;
											while ($data = mysqli_fetch_array($ress)) {
												
												$tot2 = $data['nominal'];
												$tot3 = $data['realisasi'];
												
					
												
												echo '<tr>';
												echo '<td class="text-center">' . $i . '</td>';
												echo '<td class="text-center">' . format_tanggal($data['tanggal']) . '</td>';
												echo '<td class="text-left">' . $data['keterangan'] . '</td>';
												echo '<td class="text-center">'. format_rupiah($data['nominal']) .'</td>';
												echo '<td class="text-center">'. format_rupiah($data['realisasi']) .'</td>';
												echo '<td class="text-center">' . $data['jabatan'] . '</td>';
												echo '<td class="text-center">
												<a href="newanggaranspp_edit.php?newanggaranspp=' . $data['id_anggaranspp2'] . '" class="btn btn-warning btn-xs">Realisasi</a>';?>
													  <a href="newanggaranspp_hapus.php?newanggaranspp=<?php echo $data['id_anggaranspp2'];?>" onclick="return confirm('Apakah anda yakin akan menghapus <?php echo $data['keterangan'];?>?');" class="btn btn-danger btn-xs">Hapus</a></td>
												<?php
													  echo '</td>';
												echo '</tr>';			
												$i++;
												
												$ttl2 +=$tot2;
												$ttl3 = $ttl2 - $ttl;
												$ttl4 +=$tot3;
												
												
											}
											?>
										<tfoot>
											
											<tr>
												<th colspan="6" class="text-center">Total Kebutuhan </th>
												<th class="text-right"><?php echo format_rupiah($ttl2); ?></th>
											</tr>
											<tr>
												<th colspan="6" class="text-center">Total Realisasi </th>
												<th class="text-right"><?php echo format_rupiah($ttl4); ?></th>
											</tr>
											
											
										</tfoot>
										</tbody>
									</table>
									<div class="form-group">
										<a href="laporan_trx_cetak_newanggaranspp.php?jabatan=<?php echo $jabatan; ?>" target="_blank" class="btn btn-warning">Cetak</a>
									</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 -->
				<?php } ?>
			</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'
			};
		</script>
		<?php
		include("layout_bottom.php");
		?>