<?php
/**
 * =====================================================
 * SIMPAS v1.0
 * Modul : Cetak Laporan Absensi
 * File   : cetak.php
 * =====================================================
 */

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

$tgl1 = $_GET['tgl1'];
$tgl2 = $_GET['tgl2'];

$query = mysqli_query($conn,"
SELECT
a.*,
s.nis,
s.nama_siswa,
k.nama_kelas

FROM absensi a

LEFT JOIN siswa s
ON a.id_siswa=s.id_siswa

LEFT JOIN kelas k
ON s.id_kelas=k.id_kelas

WHERE
a.tanggal BETWEEN '$tgl1' AND '$tgl2'

ORDER BY
a.tanggal ASC,
s.nama_siswa ASC
");

?>
<!DOCTYPE html>
<html>

<head>

<meta charset="utf-8">

<title>

Cetak Laporan Absensi

</title>

<style>

body{

    font-family:Arial,Helvetica,sans-serif;
    font-size:13px;

}

h2{

    margin-bottom:0;

}

table{

    width:100%;
    border-collapse:collapse;
    margin-top:20px;

}

table th,
table td{

    border:1px solid #000;
    padding:6px;

}

.text-center{

    text-align:center;

}

</style>

</head>

<body>

<h2 class="text-center">

SMP Negeri 2 Teluk Kuantan

</h2>

<p class="text-center">

LAPORAN ABSENSI SISWA

<br>

Periode

<?= date('d-m-Y',strtotime($tgl1)); ?>

s/d

<?= date('d-m-Y',strtotime($tgl2)); ?>

</p>

<table>

<thead>

<tr>

<th>No</th>

<th>Tanggal</th>

<th>NIS</th>

<th>Nama</th>

<th>Kelas</th>

<th>Jam Masuk</th>

<th>Jam Pulang</th>

<th>Status</th>

</tr>

</thead>

<tbody>

<?php

$no=1;

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

?>

<tr>

<td class="text-center">

<?= $no++; ?>

</td>

<td>

<?= date('d-m-Y',strtotime($row['tanggal'])); ?>

</td>

<td>

<?= $row['nis']; ?>

</td>

<td>

<?= $row['nama_siswa']; ?>

</td>

<td>

<?= $row['nama_kelas']; ?>

</td>

<td class="text-center">

<?= $row['jam_masuk']; ?>

</td>

<td class="text-center">

<?= empty($row['jam_pulang']) ? '-' : $row['jam_pulang']; ?>

</td>

<td class="text-center">

<?= $row['status']; ?>

</td>

</tr>

<?php } ?>

</tbody>

</table>
<br><br><br>

<table style="width:100%; border:none;">

<tr>

<td style="border:none; width:60%;">

</td>

<td style="border:none; text-align:center;">

Teluk Kuantan,
<?= date('d-m-Y'); ?>

<br><br>

Kepala Sekolah

<br><br><br><br><br>

_________________________

</td>

</tr>

</table>

<script>

window.print();

</script>

</body>

</html>