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

437 lines
12 KiB
HTML
Executable File

<!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 Kelas</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">
<h4 class="box-title"><button type="button"
class="btn btn-info btn-rounded waves-effect waves-light" onclick="addKelasOpenModal()">Tambah Kelas</button></h4>
<!-- /.box-title -->
<table id="example" class="table table-striped table-bordered display" style="width:100%">
<thead>
<tr>
<th>Nama Kelas</th>
<th>Aksi</th>
</tr>
</thead>
<tbody id="tbody">
</tbody>
</table>
</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="boostrapModal-3" tabindex="-1" role="dialog" aria-labelledby="myModalLabel-2">
<div class="modal-dialog modal-sm" 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="myModalLabel-2">Form Tambah Kelas</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label class="control-label">Nama Kelas</label>
<input type="text" class="form-control" placeholder="Masukkan Nama Kelas" id="nama-kelas">
<input type="hidden" id="id-kelas">
</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-kelas"
onclick="tambahKelas()">Tambah kelas</button>
<button type="button" class="btn btn-primary btn-sm waves-effect waves-light" id="btn-update-kelas" onclick="updateKelas()">Update kelas</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>
function addKelasOpenModal() {
$('#boostrapModal-3').modal('show');
$('#nama-kelas').val('')
$('#myModalLabel-2').html('Form Tambah Kelas')
$('#id-kelas').val('')
$('#btn-update-kelas').hide()
$('#btn-tambah-kelas').show()
}
function tambahKelas() {
let kelas = $('#nama-kelas').val();
if (kelas == '') {
swal({
type: "warning",
title: "Kelas harus diisi",
// text: "Kelas harus diisi"
})
return
}
swal({
type: "info",
title: "Yakin?",
text: "Kelas akan ditambahkan",
showCancelButton: !0,
// confirmButtonColor: "#DD6B55",
confirmButtonText: "Ya",
cancelButtonText: "Tidak",
}, function (y) {
if (y) {
$.ajax({
url: '/admin/kelas',
type: 'POST',
data: {
kelas: kelas
},
beforeSend: function () {
// close modal
$('#boostrapModal-3').modal('hide')
blockUI('Loading')
},
success: function (data) {
console.log(data)
$.unblockUI();
swal({
type: "success",
title: "Sukses",
text: "Kelas ditambahkan",
timer: 2000,
showConfirmButton: !1
})
getKelas()
},
error: function (jqXHR, textStatus, errorThrown) {
$.unblockUI();
swal({
type: "error",
title: "Error",
text: errorThrown,
timer: 2000,
showConfirmButton: !1
// close after 2 seconds
}, function () {
// open modal
$('#boostrapModal-3').modal('show')
$('#nama-kelas').val(kelas)
// close swal
swal.close()
})
}
})
}
})
}
function edit_kelas_open_modal(id, kelas) {
$('#boostrapModal-3').modal('show');
$('#nama-kelas').val(kelas)
$('#id-kelas').val(id)
$('#myModalLabel-2').html('Form Edit Kelas')
$('#btn-update-kelas').show()
$('#btn-tambah-kelas').hide()
}
function updateKelas() {
let id = $('#id-kelas').val();
let kelas = $('#nama-kelas').val();
if (kelas == '') {
swal({
type: "warning",
title: "Kelas harus diisi",
// text: "Kelas harus diisi"
})
return
}
swal({
type: "info",
title: "Yakin?",
text: "Kelas akan diupdate",
showCancelButton: !0,
// confirmButtonColor: "#DD6B55",
confirmButtonText: "Ya",
cancelButtonText: "Tidak",
} , function (y) {
if (y) {
$.ajax({
url: '/admin/kelas',
type: 'PUT',
data: {
id: id,
kelas: kelas
},
beforeSend: function () {
// close modal
$('#boostrapModal-3').modal('hide')
blockUI('Loading')
},
success: function (data) {
console.log(data)
$.unblockUI();
swal({
type: "success",
title: "Sukses",
text: "Kelas diupdate",
timer: 2000,
showConfirmButton: !1
})
getKelas()
},
error: function (jqXHR, textStatus, errorThrown) {
$.unblockUI();
swal({
type: "error",
title: "Error",
text: errorThrown,
timer: 2000,
showConfirmButton: !1
})
$('#boostrapModal-3').modal('show')
$('#nama-kelas').val(kelas)
// close swal
}
})
}
})
}
function deleteKelas(id) {
swal({
type: "warning",
title: "Yakin?",
text: "Kelas akan dihapus",
showCancelButton: !0,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Ya",
cancelButtonText: "Tidak",
confirmButtonColor: "#f60e0e"
} , function (y) {
if (y) {
$.ajax({
url: '/admin/kelas/' + id,
type: 'DELETE',
beforeSend: function () {
blockUI('Loading')
},
success: function (data) {
console.log(data)
$.unblockUI();
swal({
type: "success",
title: "Sukses",
text: "Kelas dihapus",
timer: 2000,
showConfirmButton: !1
})
getKelas()
},
error: function (jqXHR, textStatus, errorThrown) {
$.unblockUI();
swal({
type: "error",
title: "Error",
text: errorThrown,
timer: 2000,
showConfirmButton: !1
})
}
})
}
})
}
function getKelas() {
$.ajax({
url: '/admin/kelas/get',
type: 'GET',
beforeSend: function () {
//
$('#tbody').html('<tr><td colspan="3"><center>Loading...</center></td></tr>')
},
success: function (json) {
// console.log(data)
const data = json.data
if (data.length == 0) {
let html = 'Belum ada kelas yang ditambahkan'
$('#tbody').html('<tr><td colspan="3"><center>' + html + '</center></td></tr>')
return;
}
let html = ''
for (let i = 0; i < data.length; i++) {
html += '<tr>' +
// '<td>' + (i + 1) + '</td>' +
'<td>' + data[i].nama_kelas + '</td>' +
'<td>' +
`<button type='button' onclick='edit_kelas_open_modal(${data[i].id_kelas}, "${data[i].nama_kelas}")' title='Edit Kelas' class='btn btn-info btn-circle btn-sm waves-effect waves-light'><i class='ico zmdi zmdi-info'></i></button> ` +
`<button type='button' onclick='deleteKelas(${data[i].id_kelas})' title='Hapus Kelas' class='btn btn-danger btn-circle btn-sm waves-effect waves-light'><i class='ico zmdi zmdi-delete'></i></button>` +
'</td>' +
'</tr>'
}
$('#tbody').html(html)
},
error: function (jqXHR, textStatus, errorThrown) {
// $.unblockUI();
$('#tbody').html('<tr><td colspan="3"><center>Error loading data</center></td></tr>')
}
})
}
getKelas()
</script>
</body>
</html>