```php
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

session_start();
require "../config.php";

/* ================= LOGIN ================= */

if(!isset($_SESSION['login'])){
    header("Location: /login.php");
    exit;
}

if($_SESSION['role'] != 'admin3'){
    header("Location: /login.php");
    exit;
}

/* ================= FILTER ================= */

$where = "WHERE status='Diterima'";

/* ================= FILTER TRIWULAN ================= */

if(isset($_GET['triwulan']) && $_GET['triwulan'] != ''){

    $triwulan = $conn->real_escape_string($_GET['triwulan']);

    $where .= " AND laporan_triwulan_ke='$triwulan'";
}

/* ================= FILTER TAHUN ================= */

if(isset($_GET['tahun']) && $_GET['tahun'] != ''){

    $tahun = $conn->real_escape_string($_GET['tahun']);

    $where .= " AND tahun_laporan='$tahun'";
}

/* ================= TOTAL SIDEBAR ================= */

$total = $conn->query("
SELECT COUNT(*) as jml 
FROM rekomtek
")->fetch_assoc()['jml'];

$menunggu = $conn->query("
SELECT COUNT(*) as jml 
FROM rekomtek
WHERE status='Menunggu'
")->fetch_assoc()['jml'];

$diterima = $conn->query("
SELECT COUNT(*) as jml 
FROM rekomtek
WHERE status='Diterima'
")->fetch_assoc()['jml'];

$ditolak = $conn->query("
SELECT COUNT(*) as jml 
FROM rekomtek
WHERE status='Ditolak'
")->fetch_assoc()['jml'];

$selesai = $conn->query("
SELECT COUNT(*) as jml 
FROM rekomtek
WHERE status='Selesai'
")->fetch_assoc()['jml'];

/* ================= DATA ================= */

$data = $conn->query("
SELECT *
FROM rekomtek
$where
ORDER BY id DESC
");

?>

<!DOCTYPE html>
<html lang="id">
<head>

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>Laporan Diterima</title>

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">

<link rel="stylesheet"
href="https://cdn.datatables.net/1.13.8/css/dataTables.bootstrap5.min.css">

<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">

<style>

body{
    background:#f4f6f9;
    font-family:'Segoe UI',sans-serif;
}

.sidebar{
    width:250px;
    height:100vh;
    position:fixed;
    left:0;
    top:0;
    background:#003b7a;
    padding-top:20px;
}

.sidebar h4{
    color:white;
    text-align:center;
    margin-bottom:30px;
    font-weight:bold;
}

.sidebar a{
    display:block;
    color:white;
    padding:14px 20px;
    text-decoration:none;
}

.sidebar a:hover{
    background:rgba(255,255,255,0.15);
}

.sidebar .badge{
    float:right;
}

.main{
    margin-left:250px;
    padding:30px;
}

.table td,
.table th{
    vertical-align:middle;
    white-space:nowrap;
}

</style>

</head>

<body>

<body>

<!-- SIDEBAR -->

<div class="sidebar">

<h4>📁 Admin Laporan Triwulan</h4>


<a href="laporan_masuk">
<i class="fa fa-file-alt"></i>
Laporan Masuk
<span class="badge bg-warning text-dark">
<?= $menunggu ?>
</span>
</a>

<a href="laporan_ditolak">
<i class="fa fa-times-circle"></i>
Laporan Ditolak
<span class="badge bg-danger">
<?= $ditolak ?>
</span>
</a>

<a href="laporan_diterima">
<i class="fa fa-check-circle"></i>
Laporan Diterima
<span class="badge bg-success">
<?= $diterima ?>
</span>
</a>

<a href="rekap_triwulan">

<div class="menu-left">
<i class="fa fa-clipboard-list"></i>
Laporan Triwulan

</div>

</a>

<a href="masa_berlaku_sk">
<i class="fa fa-calendar-times"></i>
SK Perlu Perpanjangan 
</a>

<a href="master_sk">
<i class="fa fa-database"></i>
Master SK
</a>

<a href="/login">
<i class="fa fa-sign-out-alt"></i>
Logout
</a>

</div>

<!-- MAIN -->

<div class="main">

<h3 class="mb-4 fw-bold">
✅ Laporan Diterima
</h3>

<form method="GET" class="row mb-3">

<div class="col-md-3">

<select name="triwulan" class="form-control">

<option value="">-- Pilih Triwulan --</option>

<option value="Triwulan I"
<?= (($_GET['triwulan'] ?? '') == 'Triwulan I') ? 'selected' : '' ?>>
Triwulan I (Januari-Maret)
</option>

<option value="Triwulan II"
<?= (($_GET['triwulan'] ?? '') == 'Triwulan II') ? 'selected' : '' ?>>
Triwulan II (April-Juni)
</option>

<option value="Triwulan III"
<?= (($_GET['triwulan'] ?? '') == 'Triwulan III') ? 'selected' : '' ?>>
Triwulan III (Juli-September)
</option>

<option value="Triwulan IV"
<?= (($_GET['triwulan'] ?? '') == 'Triwulan IV') ? 'selected' : '' ?>>
Triwulan IV (Oktober-Desember)
</option>

</select>

</div>

<div class="col-md-3">

<input
type="text"
name="tahun"
id="tahun"
class="form-control"
placeholder="Pilih Tahun"
value="<?= $_GET['tahun'] ?? '' ?>">

</div>
<div class="col-md-2">

<button class="btn btn-primary w-100">
Cari
</button>

</div>

<div class="col-md-3">

<a href="export_diterima.php?<?= http_build_query($_GET) ?>"
class="btn btn-success w-100">

Export Excel

</a>

</div>

</form>

<!-- TABLE -->

<div class="card shadow border-0">

<div class="card-body">

<div class="table-responsive">

<table id="tabelDiterima"
class="table table-bordered table-striped align-middle">

<thead class="table-dark text-center">

<tr>

<th>No</th>
<th>Kode Tiket</th>
<th>Nomor SK</th>
<th>Sumber Air</th>
<th>Nama Perusahaan</th>
<th>Triwulan</th>
<th>Tahun</th>
<th>Status</th>
<th>Tanggal</th>
<th>Aksi</th>

</tr>

</thead>

<tbody>

<?php
$no =  1;

while($d = $data->fetch_assoc()):
?>

<tr>

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

<td><?= $d['kode_tiket'] ?></td>

<td><?= $d['nomor_sk'] ?></td>

<td><?= $d['sumber_air'] ?></td>

<td><?= $d['nama_perusahaan'] ?></td>

<td><?= $d['laporan_triwulan_ke'] ?></td>

<td><?= $d['tahun_laporan'] ?></td>

<td class="text-center">

<span class="badge bg-success">
<?= $d['status'] ?>
</span>

</td>

<td>
<?= date('d-m-Y', strtotime($d['created_at'])) ?>
</td>

<td class="text-center">

<a href="lihat_rekomtek?id=<?= $d['id'] ?>"
class="btn btn-primary btn-sm">
    <i class="fa fa-eye"></i> Lihat
</a>

<a href="hapus_rekomtek?id=<?= $d['id'] ?>"
class="btn btn-danger btn-sm"
onclick="return confirm('Yakin ingin menghapus data ini?')">
    <i class="fa fa-trash"></i> Hapus
</a>

</td>

</tr>

<?php endwhile; ?>

</tbody>

</table>

</div>
</div>

</div>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-datepicker@1.10.0/dist/css/bootstrap-datepicker.min.css">

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

<script src="https://cdn.jsdelivr.net/npm/bootstrap-datepicker@1.10.0/dist/js/bootstrap-datepicker.min.js"></script>

<script>
$('#tahun').datepicker({
    format: "yyyy",
    viewMode: "years",
    minViewMode: "years",
    autoclose: true
});
</script>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>

<script src="https://cdn.datatables.net/1.13.8/js/jquery.dataTables.min.js"></script>

<script src="https://cdn.datatables.net/1.13.8/js/dataTables.bootstrap5.min.js"></script>

<script>
$(document).ready(function(){

    $('#tabelDiterima').DataTable({
        order: [[8, 'desc']],
        pageLength: 10,
        lengthMenu: [10,25,50,100],
        language:{
            search:"Cari:",
            lengthMenu:"Tampilkan _MENU_ data",
            info:"Menampilkan _START_ sampai _END_ dari _TOTAL_ data",
            paginate:{
                previous:"Sebelumnya",
                next:"Berikutnya"
            }
        }
    });

});
</script>
</body>
</html>
```
