Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Connection
- require_once('../config/connection.php');
- // Helper
- require_once('../config/helper.php');
- // Authentication user
- if (authentication() === false) {
- // Redirect to dashboard
- header('Location: ' . BASE_URL);
- exit;
- }
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <!-- Load head.php -->
- <?php include_once("../templates/head.php") ?>
- <style>
- /* Set height iframe in modal */
- .embed-responsive {
- height: 500px !important;
- }
- /* Highlight new data in tableForm */
- .highlight {
- animation: fade 2s forwards;
- background-color: rgba(242, 245, 169, 1);
- }
- @keyframes fade {
- from {
- background-color: rgba(242, 245, 169, 1);
- }
- to {
- background-color: #fff;
- }
- }
- .back:hover {
- text-decoration: none;
- }
- </style>
- </head>
- <body>
- <div class="container-fluid" id="wrapper">
- <div class="row">
- <!-- Load sidebar.php -->
- <?php include_once("../templates/sidebar.php") ?>
- <main class="col-xs-12 col-sm-8 col-lg-9 col-xl-10 pt-3 pl-4 ml-auto">
- <!-- Load header.php -->
- <header class="page-header row justify-center">
- <div class="col-md-6 col-lg-8">
- <h1 class="float-left text-center text-md-left" style="text-transform: uppercase; letter-spacing: .1rem;">Ruang</h1>
- </div>
- <div class="dropdown user-dropdown col-md-6 col-lg-4 text-center text-md-right"><a class="btn btn-stripped dropdown-toggle" href="#" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
- <img src="<?= BASE_URL; ?>assets/images/profile/default.png" alt="profile photo" class="circle float-left profile-photo" width="50" height="auto">
- <div class="username mt-1 buttonAnimation" data-animation="pulse">
- <h4 class="mb-1"><?= getMyName(); ?>
- <?php
- // // Warning for member new (status : 2)
- if (getMyStatusActive() == 2) {
- ?>
- <span class="badge badge-dark">1</span>
- <?php
- }
- ?>
- </h4>
- <h6 class="text-muted">
- <?= myLevelName(); ?>
- </h6>
- </div>
- </a>
- <div class="dropdown-menu dropdown-menu-right" style="margin-right: 1.5rem;" aria-labelledby="dropdownMenuLink">
- <a class="dropdown-item" href="<?= BASE_URL . 'profile'; ?>">
- <em class="fa fa-user-circle mr-1"></em> Lihat Profil
- <?php
- // // Warning for member new (status : 2)
- if (getMyStatusActive() == 2) {
- ?>
- <span class="badge badge-dark">1</span>
- <?php
- }
- ?>
- </a>
- <a class="dropdown-item" href="<?= BASE_URL . 'config/functions/logout.php'; ?>">
- <em class="fa fa-power-off mr-1"></em> Keluar
- </a>
- </div>
- </div>
- <div class="clear"></div>
- </header>
- <section class="row">
- <div class="col-sm-12">
- <section class="row">
- <div class="col-lg-12">
- <div class="card mb-4 animated zoomIn" data-appear="appear" data-animation="zoomIn">
- <div class="card-block">
- <div class="row">
- <h3 class="card-title ml-3">Data Ruang</h3>
- <div class="col-1 text-right p-1 ml-3">
- <button type="button" class="btn btn-sm btn-primary margin" data-toggle="modal" data-target="#modalAddRuang"><span class="fa fa-plus"></span> Ruang Baru</button>
- </div>
- </div>
- <table id="table_id" class="table table-striped table-bordered" cellspacing="0" width="100%">
- <thead>
- <tr>
- <th class="w-1 pl-4" width="5%">No</th>
- <th width="10%">Kode</th>
- <th width="20%">Nama Ruangan</th>
- <th width="15%">Kapasitas</th>
- <th width="20%">Ruang Cadangan</th>
- <th width="20%">Program Studi</th>
- <th width="10%">Aksi</th>
- </tr>
- </thead>
- <tbody>
- <?php
- $no = 1;
- // Get data m_ruang
- $getMRuang = mysqli_query($link, "SELECT m_ruang.kode, m_ruang.name, m_ruang.capacity, m_ruang.is_backup, m_prodi.name AS prodi, m_users.fullname AS user, m_ruang.registered_date FROM m_ruang INNER JOIN m_prodi ON m_ruang.prodi_id = m_prodi.id INNER JOIN m_users ON m_ruang.user_id = m_users.id ORDER BY m_ruang.registered_date DESC");
- while ($row = mysqli_fetch_assoc($getMRuang)) {
- // New data highlight
- echo "<tr class='data_" . $row['kode'];
- if ($no == 1 && isset($_SESSION['newRuang'])) {
- echo "highlight";
- }
- echo "'>";
- echo '<td class="text-center">' . $no . '</td>';
- echo '<td class="kodeRuang">' . $row['kode'] . '</td>';
- echo '<td class="nameRuang">' . $row['name'] . '</td>';
- echo '<td class="capacityRuang">' . $row['capacity'] . '</td>';
- echo '<td class="backupRuang">';
- if ($row['is_backup'] == 1) {
- echo 'Tidak';
- } else {
- echo 'Iya';
- }
- echo '</td>';
- echo '<td class="prodiRuang">' . $row['prodi'] . '<span class="d-none prodi">' . $row['prodi'] . '</span><span class="d-none regDate">' . $row['registered_date'] . '</span><span class="d-none byUser">' . $row['user'] . '</span></td>';
- echo '<td class="text-center"><button type="button" class="btn btn-secondary btn-sm detail-ruang" item="' . $row['kode'] . '" data-toggle="modal" data-target="#exampleModal1" id="' . $row['kode'] . '">Lihat</button></td>';
- echo "</tr>";
- $no++;
- }
- ?>
- </tbody>
- </table>
- </div>
- </div>
- <!-- Modal Add Ruang -->
- <div class="modal fade" id="modalAddRuang" tabindex="-1" role="dialog" aria-labelledby="modalAddRuang" aria-hidden="true">
- <div class="modal-dialog" role="document">
- <div class="modal-content">
- <div class="modal-header modal-add">
- <h5 class="modal-title" id="modalAddRuang">Tambah Ruang</h5>
- <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true" style="color: white">×</span></button>
- </div>
- <form action="<?= BASE_URL . 'config/functions/ruang_add.php'; ?>" method="POST" id="formAddRuang">
- <div class="modal-body">
- <div class="row">
- <div class="col-4">
- <div class="form-group">
- <label for="iKode" style="font-size: 14px;">Kode</label>
- <input type="text" class="form-control" maxlength="20" id="iKode" name="iKode" autocomplete="off" style="font-size: 14px;">
- <small id="kodeInfo" class="form-text text-danger" style="display: none;">Kode tidak boleh kosong!</small>
- </div>
- </div>
- <div class="col-8">
- <div class="form-group">
- <label for="iNameRuang" style="font-size: 14px;">Nama Ruangan</label>
- <input type="text" class="form-control" id="iNameRuang" name="iNameRuang" autocomplete="off" style="font-size: 14px;">
- <small id="ruangInfo" class="form-text text-danger" style="display: none;">Nama Ruangan tidak boleh kosong!</small>
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-6">
- <div class="form-group">
- <label for="iKapasitas" style="font-size: 14px;">Kapasitas</label>
- <input type="text" class="form-control" id="iKapasitas" name="iKapasitas" autocomplete="off" style="font-size: 14px;">
- <small id="kapasitasInfo" class="form-text text-danger" style="display: none;">Kapasitas tidak boleh kosong!</small>
- </div>
- </div>
- <div class="col-6">
- <div class="form-group">
- <label for="iJenis" style="font-size: 14px;">Ruang Cadangan</label>
- <div class="custom-control custom-radio">
- <input type="radio" id="checkAllow" name="jenis" class="custom-control-input" value="0">
- <label class="custom-control-label" for="checkAllow" style="font-size: 14px;">Iya</label>
- </div>
- <div class="custom-control custom-radio">
- <input type="radio" id="checkNotAllow" name="jenis" class="custom-control-input" value="1" checked>
- <label class="custom-control-label" for="checkNotAllow" style="font-size: 14px;">Tidak</label>
- </div>
- </div>
- </div>
- </div>
- <div class="form-group">
- <label for="iProdi" style="font-size: 14px;">Program Studi</label>
- <select class="form-control custom-select status" id="iProdi" name="iProdi" style="font-size: 14px;" required>
- <option value="">--[Pilih]--</option>
- <?php
- // Get data program studi
- $getProdi = mysqli_query($link, "SELECT * FROM m_prodi");
- while ($row = mysqli_fetch_assoc($getProdi)) {
- echo '<option value="' . $row['id'] . '">' . $row['name'] . '</option>';
- }
- ?>
- </select>
- <small id="prodiInfo" class="form-text text-danger" style="display: none;">Program Studi tidak boleh kosong!</small>
- </div>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-secondary" data-dismiss="modal">Tutup</button>
- <button type="button" id="addRuang" class="btn btn-primary">Simpan</button>
- </div>
- </form>
- </div>
- </div>
- </div>
- <!-- End Modal -->
- <!-- Modal Preview Ruang -->
- <div class="modal fade" id="exampleModal1" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel1" aria-hidden="true">
- <div class="modal-dialog modal-lg" role="document">
- <div class="modal-content">
- <div class="modal-header modal-add">
- <h5 class="modal-title" id="exampleModalLabel1"><span id="detailRuangHeader"></span></h5>
- <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true" style="color: white">×</span></button>
- </div>
- <div class="modal-body p-0">
- <div class="row">
- <div class="col-md-2"></div>
- <div class="col-md-8 p-5 pl-0 ml-0">
- <table class="table table-hover table-sm">
- <tbody>
- <tr class="table-secondary">
- <td colspan="3" class="text-center"><b>Detail Ruang</b></td>
- </tr>
- <tr>
- <td width="40%">Kode</td>
- <td>:</td>
- <td id="dKode"></td>
- </tr>
- <tr>
- <td>Nama Ruangan</td>
- <td>:</td>
- <td id="dNameRuang"></td>
- </tr>
- <tr>
- <td>Kapasitas</td>
- <td>:</td>
- <td id="dCapacity"></td>
- </tr>
- <tr>
- <td>Jenis Ruangan</td>
- <td>:</td>
- <td id="dBackup"></td>
- </tr>
- <tr>
- <td>Program Studi</td>
- <td>:</td>
- <td id="dProdi"></td>
- </tr>
- <tr>
- <td>Ditambahkan oleh</td>
- <td>:</td>
- <td id="dByUser"></td>
- </tr>
- <tr>
- <td>Ditambahkan pada</td>
- <td>:</td>
- <td id="dAddDate"></td>
- </tr>
- </tbody>
- </table>
- </div>
- <div class="col-md-2">
- </div>
- </div>
- </div>
- <div class="modal-footer" style="justify-content: flex-end;">
- <button type="button" class="btn btn-secondary" data-dismiss="modal">Tutup</button>
- <?php
- if ($_SESSION['level'] == 1) {
- ?>
- <button type="button" class="btn btn-danger" id="deleteRuang">Hapus Ruang</button>
- <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#showModalEdit" id="showEditRuang">Ubah Data Ruang</button>
- <?php
- }
- ?>
- </div>
- </div>
- </div>
- </div>
- <!-- End modal -->
- <!-- Update Ruang -->
- <div class="modal fade" id="showModalEdit" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
- <div class="modal-dialog" role="document">
- <div class="modal-content">
- <div class="modal-header modal-add">
- <h5 class="modal-title" id="exampleModalLabel">Edit MK : <span id="detailRuangHeaderEdit">-</span></h5>
- <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true" style="color:white">×</span>
- </button>
- </div>
- <form action="<?= BASE_URL . 'config/functions/ruang_update.php'; ?>" method="POST" id="formEditRuang">
- <div class="modal-body p-0">
- <div class="card-body pt-2">
- <b>Data Ruang</b>
- <div class="alert alert-icon alert-warning mt-2" style="font-size: 12px;" role="alert">
- <i class="fa fa-exclamation-triangle mr-2" aria-hidden="true"></i> <b>Mohon Perhatian : </b> Segala perubahan yang dilakukan tidak merubah data jadwal yang sudah dibuat.
- </div>
- <div class="row">
- <div class="col-4">
- <div class="form-group">
- <label class="form-label" for="iEKode" style="font-size: 14px; font-weight: normal;">Kode</label>
- <input type="text" class="form-control" name="iEKode" id="iEKode" style="font-size: 14px;" readonly>
- </div>
- </div>
- <div class="col-8">
- <div class="form-group">
- <label class="form-label" for="iENameRuang" style="font-size: 14px; font-weight: normal;">Nama Ruangan</label>
- <input type="text" class="form-control" id="iENameRuang" name="iENameRuang" style="font-size: 14px;">
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-6">
- <div class="form-group">
- <label for="iECapacity" style="font-size: 14px;">Kapasitas</label>
- <input type="number" min="1" class="form-control" id="iECapacity" name="iECapacity" autocomplete="off" style="font-size: 14px;">
- </div>
- </div>
- <div class="col-6">
- <div class="form-group">
- <label for="iEBackup" style="font-size: 14px;">Ruang Cadangan</label>
- <div class="custom-control custom-radio">
- <input type="radio" id="checkAllow" name="iEBackup" class="custom-control-input" value="0">
- <label class="custom-control-label" for="checkAllow" style="font-size: 14px;">Iya</label>
- </div>
- <div class="custom-control custom-radio">
- <input type="radio" id="checkNotAllow" name="iEBackup" class="custom-control-input" value="1" checked>
- <label class="custom-control-label" for="checkNotAllow" style="font-size: 14px;">Tidak</label>
- </div>
- </div>
- </div>
- </div>
- <div class="form-group">
- <label for="iEProdi" style="font-size: 14px;">Program Studi</label>
- <select class="form-control custom-select" name="iEProdi" id="iEProdi" style="font-size: 14px;">
- <?php
- // Get data m_prodi
- $getMProdi = mysqli_query($link, "SELECT * FROM m_prodi");
- $listNo = 0;
- while ($row = mysqli_fetch_assoc($getMProdi)) {
- echo '<option value="' . $row['id'] . '" class="list_' . $listNo . '">' . $row['name'] . '</option>';
- $listNo++;
- }
- ?>
- </select>
- </div>
- </div>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-secondary" data-dismiss="modal">Tutup</button>
- <!-- <input type="hidden" name="lab_id" value="<?= $labs['id']; ?>"> -->
- <button type="button" id="editMk" class="btn btn-primary">Simpan Perubahan</button>
- </div>
- </form>
- </div>
- </div>
- </div>
- </div>
- <!-- End modal -->
- </div>
- </section>
- </div>
- </section>
- </main>
- </div>
- </div>
- <?php include_once("../templates/foot.php") ?>
- <script>
- $(document).ready(function() {
- // Datatables
- $('#table_id').DataTable({
- "oLanguage": {
- "sInfo": "Total _TOTAL_ data, menampilkan data (_START_ sampai _END_)",
- "sInfoFiltered": " - filtering from _MAX_ records",
- "sSearch": "Pencarian :",
- "sInfoEmpty": "Belum ada data untuk saat ini",
- "sLengthMenu": "Menampilkan _MENU_",
- "oPaginate": {
- "sPrevious": "Sebelumnya",
- "sNext": "Selanjutnya"
- },
- "sZeroRecords": "Tidak ada data"
- }
- });
- // Add MK
- $('#addRuang').click(function(e) {
- var isValid = true;
- // Validation add Mk
- if ($('#iKode').val() == '') {
- $('#iKode').css('borderColor', 'red');
- $('#kodeInfo').fadeIn();
- isValid = false;
- e.preventDefault();
- }
- if ($('#iNameRuang').val() == '') {
- $('#iNameRuang').css('borderColor', 'red');
- $('#ruangInfo').fadeIn();
- isValid = false;
- e.preventDefault();
- }
- if ($('#iKapasitas').val() == '') {
- $('#iKapasitas').css('borderColor', 'red');
- $('#kapasitasInfo').fadeIn();
- isValid = false;
- e.preventDefault();
- }
- if ($('#jenis').val() == '') {
- $('#jenis').css('borderColor', 'red');
- isValid = false;
- e.preventDefault();
- }
- if ($('#iProdi').val() == '') {
- $('#iProdi').css('borderColor', 'red');
- $('#prodiInfo').fadeIn();
- isValid = false;
- e.preventDefault();
- }
- // Mk action and remove border red
- $('#iKode').focus(function() {
- $(this).css('borderColor', '#D2D2D2');
- $('#kodeInfo').fadeOut();
- });
- $('#iKode').keyup(function() {
- $('#kodeInfo').fadeOut();
- });
- $('#iNameRuang').focus(function() {
- $(this).css('borderColor', '#D2D2D2');
- $('#ruangInfo').fadeOut();
- });
- $('#iNameRuang').keyup(function() {
- $('#ruangInfo').fadeOut();
- });
- $('#iKapasitas').focus(function() {
- $(this).css('borderColor', '#D2D2D2');
- $('#kapasitasInfo').fadeOut();
- });
- $('#iKapasitas').keyup(function() {
- $('#kapasitasInfo').fadeOut();
- });
- $('#jenis').focus(function() {
- $(this).css('borderColor', '#D2D2D2');
- });
- $('#iProdi').focus(function() {
- $(this).css('borderColor', '#D2D2D2');
- $('#prodiInfo').fadeOut();
- });
- $('#iProdi').keyup(function() {
- $('#prodiInfo').fadeOut();
- });
- // Check validate if mk empty
- if ($('#iKode').val() != '') {
- $.post("<?= BASE_URL . 'config/functions/ruang_addCheckKode.php'; ?>", {
- kode_ruang: $('#iKode').val()
- },
- function(data, status) {
- if (data > 0) {
- $('#iKode').css('borderColor', 'red');
- swal('Terjadi Kesalahan', 'Maaf, Kode sudah digunakan Ruangan lain', 'error');
- } else if (data == 0 && isValid === true) {
- $('#formAddRuang').submit();
- }
- });
- }
- });
- // Detail Mk
- $(document).on('click', '.detail-ruang', function() {
- var getIdItem = $(this).attr('item');
- var rowUnique = 'tr.data_' + getIdItem;
- $('#detailRuangHeader').text($(rowUnique + ' td.nameRuang').text() + ' (' + $(rowUnique + ' td.kodeRuang').text() + ')');
- $('#dKode').text($(rowUnique + ' td.kodeRuang').text());
- $('#dNameRuang').text($(rowUnique + ' td.nameRuang').text());
- $('#dCapacity').text($(rowUnique + ' td.capacityRuang').text());
- $('#dBackup').text($(rowUnique + ' td.backupRuang').text());
- $('#dProdi').text($(rowUnique + ' .prodiMk').text());
- $('#dByUser').text($(rowUnique + ' .by_user').text());
- $('#dAddDate').text($(rowUnique + ' .regDate').text());
- $('#showEditRuang').attr('item', getIdItem);
- $('#deleteRuang').attr('item', getIdItem);
- });
- // Edit Mk
- $('#showEditRuang').click(function() {
- $('#exampleModal1').modal('toggle');
- var getIdItem = $(this).attr('item');
- var rowUnique = 'tr.data_' + getIdItem;
- $('#detailRuangHeaderEdit').text($(rowUnique + ' td.nameRuang').text() + ' (' + $(rowUnique + ' td.kodeRuang').text() + ')');
- $('#iEKode').val($(rowUnique + ' td.kodeRuang').text());
- $('#iENameRuang').val($(rowUnique + ' td.nameRuang').text());
- $('#iECapacity').val($(rowUnique + ' td.capacityRuang').text());
- $('#checkAllow').val($(rowUnique + ' td.backupRuang').text());
- $('#checkNotAllow').val($(rowUnique + ' td.backupRuang').text());
- // $('#iEProdi').val($(rowUnique + ' .prodiMk').text());
- for (var i = 1; i < $('#labs option').length; i++) {
- if ($('#iEProdi').text() == $('#labs option')[i].label) {
- $('#labs option.list_' + i).attr('selected', 'selected');
- }
- }
- });
- // Action edit Mk
- $('#editMk').click(function(e) {
- // Validation form
- if ($('#iEKode').val() == '') {
- $(this).css('borderColor', 'red');
- e.preventDefault();
- }
- if ($('#iENameRuang').val() == '') {
- $(this).css('borderColor', 'red');
- e.preventDefault();
- }
- if ($('#iECapacity').val() == '') {
- $(this).css('borderColor', 'red');
- e.preventDefault();
- }
- if ($('#iEProdi').val() == '') {
- $(this).css('borderColor', 'red');
- e.preventDefault();
- }
- $('#iEKode').focus(function() {
- $(this).css('borderColor', '#D2D2D2');
- });
- $('#iENameRuang').focus(function() {
- $(this).css('borderColor', '#D2D2D2');
- });
- $('#iECapacity').focus(function() {
- $(this).css('borderColor', '#D2D2D2');
- });
- $('#iEProdi').focus(function() {
- $(this).css('borderColor', '#D2D2D2');
- });
- $('#formEditRuang').submit();
- });
- // Delete Mk
- $('#deleteMk').click(function() {
- swal({
- title: "Apakah Anda yakin Menghapus?",
- text: "Menghapus Mata Kuliah ini membuat Mata Kuliah ini tidak tersedia pada proses pembuatan Jadwal. Seluruh transaksi dengan Mata Kuliah ini juga akan dihapus secara otomatis.",
- icon: "warning",
- buttons: true,
- dangerMode: true,
- });
- });
- <?php
- // Message success update form
- if (isset($_SESSION['updateSucessfully'])) {
- echo "setTimeout(function(){ swal('Berhasil', 'Perubahan data telah disimpan!', 'success'); $('tr.data_" . $_SESSION['updateSucessfully'] . "').addClass('highlight'); }, 500); ";
- unset($_SESSION['updateSucessfully']);
- }
- ?>
- <?php
- // Message success for new data
- if (isset($_SESSION['newRuang'])) {
- echo "swal('Berhasil', 'Data Dosen telah ditambahkan', 'success')";
- unset($_SESSION['newRuang']);
- }
- ?>
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement