<?php
/**
 * =====================================================
 * SIMPAS v1.0
 * Modul : Jadwal Absensi
 * File   : index.php
 * =====================================================
 */

include "../../config/koneksi.php";
include "../../config/session.php";

include "../../templates/header.php";
include "../../templates/navbar.php";
include "../../templates/sidebar.php";

$query = mysqli_query($conn,"
SELECT *
FROM jadwal_absensi
ORDER BY FIELD(
hari,
'Senin',
'Selasa',
'Rabu',
'Kamis',
'Jumat',
'Sabtu',
'Minggu'
)
");
?>

<div class="content-wrapper">

<section class="content-header">

<div class="container-fluid">

<div class="row mb-2">

<div class="col-sm-6">

<h1>Jadwal Absensi</h1>

</div>

<div class="col-sm-6 text-right">

<a href="tambah.php" class="btn btn-success">

<i class="fas fa-plus"></i>

Tambah Jadwal

</a>

</div>

</div>

</div>

</section>

<section class="content">

<div class="container-fluid">

<div class="card shadow">

<div class="card-header">

<h3 class="card-title">

Pengaturan Jam Absensi

</h3>

</div>

<div class="card-body">

<div class="table-responsive">

<table
id="tabelJadwal"
class="table table-bordered table-striped">

<thead>

<tr>

<th width="5%">No</th>
<th>Hari</th>
<th>Masuk Mulai</th>
<th>Masuk Selesai</th>
<th>Pulang Mulai</th>
<th>Pulang Selesai</th>
<th>Status</th>
<th width="15%">Aksi</th>

</tr>

</thead>

<tbody>

<?php

$no=1;

while($row=mysqli_fetch_assoc($query)){

?>

<tr>

<td><?= $no++; ?></td>

<td><?= $row['hari']; ?></td>

<td><?= date('H:i',strtotime($row['jam_masuk_mulai'])); ?></td>

<td><?= date('H:i',strtotime($row['jam_masuk_selesai'])); ?></td>

<td><?= date('H:i',strtotime($row['jam_pulang_mulai'])); ?></td>

<td><?= date('H:i',strtotime($row['jam_pulang_selesai'])); ?></td>

<td>

<?php

if($row['aktif']=="Y"){

?>

<span class="badge badge-success">

Aktif

</span>

<?php

}else{

?>

<span class="badge badge-danger">

Nonaktif

</span>

<?php

}

?>

</td>

<td>

<a
href="edit.php?id=<?= $row['id_jadwal']; ?>"
class="btn btn-primary btn-sm">

<i class="fas fa-edit"></i>

Edit

</a>

<a
href="hapus.php?id=<?= $row['id_jadwal']; ?>"
class="btn btn-danger btn-sm"
onclick="return confirm('Hapus jadwal ini?')">

<i class="fas fa-trash"></i>

Hapus

</a>

</td>

</tr>

<?php

}

?>

</tbody>

</table>

</div>

</div>

</div>

</div>

</section>

</div>

<script>

$(function(){

$('#tabelJadwal').DataTable({

responsive:true,
autoWidth:false,
pageLength:10

});

});

</script>

<?php

include "../../templates/footer.php";

?>