89 lines
1.8 KiB
PHP
89 lines
1.8 KiB
PHP
<?php
|
|
$sort = $_GET['sort'] ?? "id";
|
|
$order = $_GET['order'] ?? "desc";
|
|
|
|
$page = $_GET['page'] ?? 1;
|
|
|
|
require_once "classes/Record.php";
|
|
|
|
$record = new Record();
|
|
|
|
$status = $_GET['status'] ?? "";
|
|
$search = $_GET['search'] ?? "";
|
|
|
|
$result = $record->getRecords($status,$search,$page,10,$sort,$order);
|
|
$totalRows = $record->countFiltered($status,$search);
|
|
$perPage = 10;
|
|
$totalPages = ceil($totalRows/$perPage);
|
|
|
|
|
|
while($row=$result->fetch_assoc()){
|
|
?>
|
|
|
|
<tr id="row-<?= $row['id'] ?>">
|
|
<td class="select-column d-none">
|
|
<input type="checkbox" class="rowcheck" value="<?= $row['id'] ?>">
|
|
</td>
|
|
|
|
<td><?= $row['id'] ?></td>
|
|
<td><?= $row['name'] ?></td>
|
|
<td><?= $row['email'] ?></td>
|
|
<td><?= $row['phone'] ?></td>
|
|
|
|
<!-- STATUS BADGE -->
|
|
<td>
|
|
<span class="badge <?= $row['status']=="active" ? "bg-success" : "bg-secondary" ?>">
|
|
<?= ucfirst($row['status']) ?>
|
|
</span>
|
|
</td>
|
|
|
|
<!-- ACTION BUTTONS -->
|
|
<td>
|
|
|
|
<?php if($row['is_deleted']==0){ ?>
|
|
|
|
<button class="btn btn-warning btn-sm editBtn" data-id="<?= $row['id'] ?>">
|
|
Edit
|
|
</button>
|
|
|
|
<button class="btn btn-danger btn-sm deleteBtn" data-id="<?= $row['id'] ?>">
|
|
Delete
|
|
</button>
|
|
|
|
<button class="btn btn-info btn-sm changeStatus" data-id="<?= $row['id'] ?>">
|
|
Change Status
|
|
</button>
|
|
|
|
<?php } else { ?>
|
|
|
|
<button class="btn btn-success btn-sm restoreBtn" data-id="<?= $row['id'] ?>">
|
|
Restore
|
|
</button>
|
|
|
|
<?php } ?>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<?php } ?>
|
|
|
|
<?php
|
|
echo "<script>
|
|
$('#pagination-area').html(`
|
|
<nav>
|
|
<ul class=\"pagination justify-content-center\">";
|
|
|
|
for($i=1;$i<=$totalPages;$i++){
|
|
$active = $i==$page?'active':'';
|
|
echo "<li class='page-item $active'>
|
|
<a class='page-link page-btn' data-page='$i' href='#'>$i</a>
|
|
</li>";
|
|
}
|
|
|
|
echo "</ul>
|
|
</nav>
|
|
`);
|
|
</script>";
|
|
?>
|