school-administrarion/routes/ui/admin/siswa.html

428 lines
15 KiB
HTML
Raw Normal View History

2024-05-07 19:49:43 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="description" content="">
<meta name="author" content="">
<title>Halaman Kelas</title>
<!-- Main Styles -->
<link rel="stylesheet" href="/styles/style.min.css">
<!-- mCustomScrollbar -->
<link rel="stylesheet" href="/plugin/mCustomScrollbar/jquery.mCustomScrollbar.min.css">
<!-- Waves Effect -->
<link rel="stylesheet" href="/plugin/waves/waves.min.css">
<!-- Sweet Alert -->
<link rel="stylesheet" href="/plugin/sweet-alert/sweetalert.css">
<link rel="stylesheet" href="/fonts/fontello/fontello.css">
<link rel="stylesheet" href="/plugin/datatables/media/css/dataTables.bootstrap.min.css">
<link rel="stylesheet" href="/fonts/material-design-iconic-font/css/material-design-iconic-font.min.css">
</head>
<body>
<div class="main-menu">
<header class="header">
<a href="/admin" class="logo">Sekolah</a>
<button type="button" class="button-close fa fa-times js__menu_close"></button>
<div class="user">
<a href="#" class="avatar"><img src="http://placehold.it/80x80" alt=""><span
class="status online"></span></a>
<h5 class="name"><a href="profile.html">Admin</a></h5>
<h5 class="position">Admin</h5>
</div>
<!-- /.user -->
</header>
<!-- /.header -->
<div class="content">
<div class="navigation">
<h5 class="title">Navigasi</h5>
<!-- /.title -->
<ul class="menu js__accordion">
<li>
<a class="waves-effect" href="/admin"><i class="menu-icon fa fa-home"></i><span>Halaman
Utama</span></a>
</li>
<li class="current active">
<a class="waves-effect" href="/admin/kelas"><i
class="menu-icon zmdi zmdi-collection-text"></i><span>Pengaturan Kelas</span></a>
</li>
<li>
<a class="waves-effect" href="/admin/siswa"><i
class="menu-icon fa fa-users"></i><span>Siswa</span></a>
</li>
<li>
<a class="waves-effect" href="#" onclick="logout()"><i
class="menu-icon ico icon-logout"></i><span>Logout</span></a>
</li>
</ul>
</div>
<!-- /.navigation -->
</div>
<!-- /.content -->
</div>
<!-- /.main-menu -->
<div class="fixed-navbar">
<div class="pull-left">
<button type="button"
class="menu-mobile-button glyphicon glyphicon-menu-hamburger js__menu_mobile"></button>
<h1 class="page-title">Halaman Siswa</h1>
<!-- /.page-title -->
</div>
<!-- /.pull-left -->
<div class="pull-right">
<a href="#" class="ico-item ico icon-logout" onclick="logout()"></a>
</div>
<!-- /.pull-right -->
</div>
<!-- /.fixed-navbar -->
<div id="wrapper">
<div class="main-content">
<div class="row small-spacing">
<div class="col-xs-12">
<div class="box-content card">
<h4 class="box-title">Form Siswa</h4>
<!-- /.box-title -->
<div class="card-content">
<div class="form-group">
<button type="button" class="btn btn-info btn-rounded waves-effect waves-light"
onclick="addSiswaOpenModal()">Tambah Siswa</button>
</div>
<table id="siswa" class="table table-striped table-bordered display" style="width:100%">
<thead>
<tr>
<th>NIS</th>
<th>Nama</th>
<th>Kelas</th>
<th>Angkatan</th>
<th>Aksi</th>
</tr>
</thead>
<tbody id="tbody">
</tbody>
</table>
</div>
</div>
<!-- /.box-content -->
</div>
</div>
<footer class="footer">
<ul class="list-inline">
<li>2024 © Sekolah.</li>
<!-- <li><a href="#">Privacy</a></li>
<li><a href="#">Terms</a></li>
<li><a href="#">Help</a></li> -->
</ul>
</footer>
</div>
<!-- /.main-content -->
</div><!--/#wrapper -->
<div class="modal fade" id="modal-tambah-siswa" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="modal-tambah-siswa-title">Modal title</h4>
</div>
<div class="modal-body">
<div class="form-group">
<!-- show the upload -->
<div id="show-upload" style="display: none">
<center>
<div id="preview" style="height: 200px; width: 150px"></div>
</center>
</div>
</div>
<div class="form-group">
<!-- create upload -->
<label for="modal-tambah-siswa-nama">Gambar</label>
<input type="file" class="form-control" id="gambar" accept="image/*"
onchange="showUpload(this)">
</div>
<div class="form-group">
<label for="modal-tambah-siswa-nama">NIS</label>
<input type="text" class="form-control" id="nis" oninput="numberOnly(this)" maxlength="10"
placeholder="Masukkan NIS">
</div>
<div class="form-group">
<label for="modal-tambah-siswa-nama">Nama</label>
<input type="text" class="form-control" id="nama" placeholder="Masukkan Nama">
</div>
<div class="form-group">
<label for="modal-tambah-siswa-nama">Kelas</label>
<select class="form-control" id="kelas">
<option value="" disabled selected>-Pilih Kelas</option>
<option value="10">7</option>
<option value="11">8</option>
<option value="12">9</option>
</select>
</div>
<div class="form-group">
<label for="modal-tambah-siswa-nama">Nama Kelas</label>
<select class="form-control" id="nama-kelas">
</select>
</div>
<div class="form-group">
<label for="modal-tambah-siswa-nama">Angkatan</label>
<select class="form-control" id="angkatan">
</select>
</div>
<hr>
<div class="form-group">
<label for="modal-tambah-siswa-nama">NIK</label>
<input type="text" class="form-control" id="nik" oninput="numberOnly(this)" maxlength="16"
placeholder="Masukkan NIK">
</div>
<div class="form-group">
<label for="modal-tambah-siswa-nama">Tempat Lahir</label>
<input type="text" class="form-control" id="tempat-lahir" placeholder="Masukkan Tempat Lahir">
</div>
<div class="form-group">
<label for="modal-tambah-siswa-nama">Tanggal Lahir</label>
<input type="date" class="form-control" id="tanggal-lahir">
</div>
<div class="form-group">
<label for="modal-tambah-siswa-nama">Jenis Kelamin</label>
<select class="form-control" id="jenis-kelamin">
<option value="" disabled selected>-Pilih Jenis Kelamin</option>
<option value="Laki-laki">Laki-laki</option>
<option value="Perempuan">Perempuan</option>
</select>
</div>
<div class="form-group">
<label for="modal-tambah-siswa-nama">Agama</label>
<select class="form-control" id="agama">
<option value="" disabled selected>-Pilih Agama</option>
<option value="Islam">Islam</option>
<option value="Kristen">Kristen</option>
<option value="Katolik">Katolik</option>
<option value="Hindu">Hindu</option>
<option value="Budha">Budha</option>
</select>
</div>
<div class="form-group">
<label for="modal-tambah-siswa-nama">Nama Orang Tua</label>
<input type="text" class="form-control" id="orang-tua1" placeholder="Masukkan Orang Tua">
</div>
<div class="form-group">
<label for="modal-tambah-siswa-nama">Nama Orang Tua</label>
<input type="text" class="form-control" id="orang-tua2" placeholder="Masukkan Orang Tua">
</div>
<div class="form-group">
<label for="modal-tambah-siswa-nama">No HP Orang Tua</label>
<input type="text" class="form-control" id="no-hp-orang-tua"
placeholder="Masukkan No HP Orang Tua">
</div>
<div class="form-group">
<label for="modal-tambah-siswa-nama">Alamat</label>
<textarea class="form-control" id="alamat" placeholder="Masukkan Alamat"
style="resize: none"></textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default btn-sm waves-effect waves-light"
data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary btn-sm waves-effect waves-light"
id="btn-tambah-mahasiswa" onclick="tambahSiswa()">Tambah Mahasiswa</button>
</div>
</div>
</div>
</div>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="/script/html5shiv.min.js"></script>
<script src="/script/respond.min.js"></script>
<![endif]-->
<!--
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="/scripts/jquery.min.js"></script>
<script src="/scripts/modernizr.min.js"></script>
<script src="/plugin/bootstrap/js/bootstrap.min.js"></script>
<script src="/plugin/mCustomScrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
<script src="/plugin/nprogress/nprogress.js"></script>
<script src="/plugin/sweet-alert/sweetalert.min.js"></script>
<script src="/plugin/waves/waves.min.js"></script>
<!-- Full Screen Plugin -->
<script src="/plugin/fullscreen/jquery.fullscreen-min.js"></script>
<script src="/plugin/datatables/media/js/jquery.dataTables.min.js"></script>
<script src="/plugin/datatables/media/js/dataTables.bootstrap.min.js"></script>
<script src="/plugin/datatables/extensions/Responsive/js/dataTables.responsive.min.js"></script>
<script src="/block/jquery.blockUI.js"></script>
<script src="/scripts/main.min.js"></script>
<script src="/my-js.js"></script>
<script>
$('#siswa').DataTable({
})
function fistLoad() {
// get today year
var today = new Date();
const year = today.getFullYear();
var html_angkatan = "<option value='' disabled selected>-Pilih Angkatan-</option>"
// loop the year to 2015
for (let i = year; i >= 2015; i--) {
html_angkatan += `<option value="${i}">${i}</option>`
}
$('#angkatan').html(html_angkatan)
$.ajax({
type: 'GET',
url: '/admin/kelas/get',
dataType: 'json',
beforeSend: function () {
},
success: function (json) {
const data = json.data
var html = "<option value='' disabled selected>-Pilih Nama Kelas-</option>"
for (let i = 0; i < data.length; i++) {
html += `<option value="${data[i].id_kelas}">${data[i].nama_kelas}</option>`
}
$('#nama-kelas').html(html)
},
})
}
fistLoad()
function addSiswaOpenModal() {
$('#modal-tambah-siswa-title').text('Form Tambah Siswa');
$('#modal-tambah-siswa-nis').val('');
$("#show-upload").hide();
$('#gambar').val('');
$('#modal-tambah-siswa').modal('show');
}
function numberOnly(element) { //only number and remove comma
element.value = element.value.replace(/[^0-9]/g, '');
element.value = element.value.replace(/,/g, '');
}
function showUpload(element) {
var file = element.files[0];
if (file) {
var reader = new FileReader();
reader.onload = function (event) {
var imageUrl = event.target.result;
// Create an image element
var img = document.createElement('img');
img.src = imageUrl;
img.style.maxWidth = '100%'; // Make the image fit the width of the div
img.style.maxHeight = '100%'; // Make the image fit the height of the div
// Get the preview div
var previewDiv = document.getElementById('preview');
$('#show-upload').show();
// Clear any existing content in the preview div
previewDiv.innerHTML = '';
// Append the image to the preview div
previewDiv.appendChild(img);
}
reader.readAsDataURL(file);
}
}
function tambahSiswa() {
if ($("gambar").val() == '') return alert('Upload Gambar');
if ($('#nis').val() == '') return alert('Masukkan NIS');
if ($('#nama').val() == '') return alert('Masukkan Nama');
if ($("#kelas").val() == '') return alert('Pilih Kelas');
if ($("#nama-kelas").val() == '') return alert('Pilih Nama Kelas');
if ($('#angkatan').val() == '') return alert('Pilih Angkatan');
if ($('#nik').val() == '') return alert('Masukkan NIK');
if ($('#nik').val() < 16) return alert('NIK Minimal 16 Digit');
if ($('#tempat-lahir').val() == '') return alert('Masukkan Tempat Lahir');
if ($('#tanggal-lahir').val() == '') return alert('Masukkan Tanggal Lahir');
if ($('#jenis-kelamin').val() == '') return alert('Pilih Jenis Kelamin');
if ($('#agama').val() == '') return alert('Pilih Agama');
if ($('#orang-tua1').val() == '') return alert('Masukkan Orang Tua 1');
if ($('#orang-tua2').val() == '') return alert('Masukkan Orang Tua 2');
if ($('#no-hp-orang-tua').val() == '') return alert('Masukkan No HP Orang Tua');
if ($('#no-hp-orang-tua').val() < 11) return alert('No HP Orang Tua Minimal 11 Digit');
if ($('#alamat').val() == '') return alert('Masukkan Alamat');
// create a FormData and using ajax to upload file
var formData = new FormData();
formData.append('gambar', $("#gambar")[0].files[0]); // Assuming "gambar" is the file input id
formData.append('nis', $('#nis').val());
formData.append('nama', $('#nama').val());
formData.append('kelas', $("#kelas").val());
formData.append('nama_kelas', $("#nama-kelas").val());
formData.append('angkatan', $('#angkatan').val());
formData.append('nik', $('#nik').val());
formData.append('tempat_lahir', $('#tempat-lahir').val());
formData.append('tanggal_lahir', $('#tanggal-lahir').val());
formData.append('jenis_kelamin', $('#jenis-kelamin').val());
formData.append('agama', $('#agama').val());
formData.append('orang_tua1', $('#orang-tua1').val());
formData.append('orang_tua2', $('#orang-tua2').val());
formData.append('no_hp_orang_tua', $('#no-hp-orang-tua').val());
formData.append('alamat', $('#alamat').val());
// Performing AJAX upload
$.ajax({
url: '/admin/siswa',
type: 'POST',
data: formData,
processData: false,
contentType: false,
beforeSend: function () {
$('#boostrapModal-3').modal('hide')
blockUI('Loading')
},
success: function (response) {
// Handle success response
console.log(response);
},
error: function (xhr, status, error) {
// Handle error
console.error(xhr.responseText);
}
});
}
</script>
</body>
</html>