<?php

session_start();

include '../config/koneksi.php';

$user_id = $_SESSION['id'];

$data = mysqli_query(

    $conn,

    "SELECT * FROM berkas
     WHERE user_id='$user_id'
     AND status='diterima'
     ORDER BY id DESC"
);

?>

<!DOCTYPE html>
<html>

<head>

<title>History User</title>

<link rel="stylesheet"
href="../assets/style.css">

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

</head>

<body>

<div class="wrapper">



<!-- SIDEBAR -->

<div class="sidebar">

<h2>BPKAD</h2>



<a href="dashboard.php">

<i class="fa-solid fa-house"></i>

Dashboard

</a>



<a href="history.php">

<i class="fa-solid fa-clock-rotate-left"></i>

History

</a>



<a href="../logout.php">

<i class="fa-solid fa-right-from-bracket"></i>

Logout

</a>

</div>





<!-- CONTENT -->

<div class="content">



<div class="topbar">

<h1>History Berkas User</h1>

</div>





<div class="table-container">

<table>

<tr>

<th>No</th>
<th>Nomor Surat</th>
<th>Nama Berkas</th>
<th>Asal Kantor</th>
<th>File</th>
<th>Status</th>
<th>Tanggal Upload</th>
<th>Keterangan Admin</th>

</tr>

<?php

$no = 1;

while($d = mysqli_fetch_assoc($data)){

?>

<tr>

<td>

<?= $no++; ?>

</td>



<td>

<?= $d['nomor_surat']; ?>

</td>



<td>

<?= $d['nama_berkas']; ?>

</td>



<td>

<?= $d['asal_kantor']; ?>

</td>



<td>

<a href="../uploads/<?php echo $d['file']; ?>"
target="_blank">

Lihat File

</a>

</td>



<td class="<?= $d['status']; ?>">

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

</td>



<td>

<?= date(
'd-m-Y H:i',
strtotime($d['tanggal_upload'])
); ?>

</td>



<td>

<?php

if(!empty($d['keterangan'])){

    echo "
    <div class='keterangan-box'>
    ".$d['keterangan']."
    </div>
    ";

}else{

    echo "
    <div class='pending-box'>
    Tidak ada keterangan
    </div>
    ";
}

?>

</td>

</tr>

<?php } ?>

</table>

</div>

</div>

</div>

<script src="../assets/script.js"></script>

</body>
</html>