<?php
spl_autoload_register(function ($mod) {
	require('../../../../bootstrap/asset/mod/' . $mod . '.php');
});
?>

<div class="modal fade middle mt-5" id="generateKategori" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false">
	<div class="modal-dialog modal-md">
		<div class="modal-content bg-secondary">
			<form action="" method="post">
				<?php
				//require('layout/class.php');
				$csrf = new csrf;
				$csrf->token();
				?>
				<div class="modal-header">
					<h5 class="modal-title" style="font-family:'Courier New', Courier, monospace"><span class="bi bi-people"></span> Generate Kategori Siswa</h5>
					<button type="button" class="close" data-dismiss="modal" aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
				</div>
				<div class="modal-body" align="left">
					<div class="row">
						<label for="exampleEmail" class="col-sm-12 col-form-label">Lanjut Generate Kategori Siswa? </label>
					</div>
				</div>
				<div class="modal-footer justify-content-between">
					<div class="float-right">
						<button type="submit" class="btn btn-light btn-xs " name="generateKategori"><i class="bi-save"></i> GENERATE KATEGORI SISWA</button>
					</div>
					<div class="float-left">
						<button type="button" class="badge badge-pill badge-secondary" data-dismiss="modal"><span class="badge badge-pill badge-secondary">CLOSE</span></button>
					</div>

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

<div class="modal fade middle mt-5" id="deleteAll" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false">
	<div class="modal-dialog modal-md">
		<div class="modal-content bg-danger">
			<form action="" method="post">

				<div class="modal-header">
					<h5 class="modal-title" style="font-family:'Courier New', Courier, monospace"><span class="bi bi-trash"></span> Kosongkan Data Siswa</h5>
					<button type="button" class="close" data-dismiss="modal" aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
				</div>
				<div class="modal-body" align="left">

					<div class="row mx-2">
						<label for="exampleEmail" class="col-sm-12 col-form-label"> <i class="bi-exclamation-triangle"></i> Yakin akan menghapus seluruh Data Siswa? </label>
					</div>

				</div>
				<div class="modal-footer justify-content-between">
					<div class="float-right">
						<button type="submit" class="btn btn-light btn-xs" name="deleteAll"><i class="bi-trash"></i> HAPUS SEMUA SISWA</button>
					</div>
					<div class="float-left">
						<button type="button" class="badge badge-pill badge-secondary" data-dismiss="modal"><span class="badge badge-pill badge-secondary">CLOSE</span></button>
					</div>

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

<?php

if (isset($_POST['deleteAll'])) {
	$tahun = $_SESSION['tahun'];
	$tahun_tabel = substr($tahun, 2, 2) . substr($tahun, 7, 2);
	$tb_siswa = "tb_siswa" . $tahun_tabel;
	$tb_siswa_min = "tb_siswa_min" . $tahun_tabel;

	$siswa = new siswa();
	$siswa->deleteAll($tb_siswa);
	$siswa->deleteAll($tb_siswa_min);
	$direct = new toast();
	echo  $direct->redirect('toast', 'delete', 'seting/siswa/siswa_read');
};
