103 lines
3.8 KiB
PHP
103 lines
3.8 KiB
PHP
|
|
<style>
|
||
|
|
.dark-header thead th {
|
||
|
|
background-color: #343a40;
|
||
|
|
/* Dark gray background */
|
||
|
|
color: white;
|
||
|
|
/* White text color */
|
||
|
|
}
|
||
|
|
</style>
|
||
|
|
|
||
|
|
<div class="container">
|
||
|
|
<h2 class="text-left">Locations <a class="btn btn-primary" href="/<?php echo $_SESSION['role'] ?>/location/add">Add</a></h2>
|
||
|
|
<div class="row mt-2 mb-2">
|
||
|
|
<div class="col-md-6 col-md-offset-3">
|
||
|
|
<form action="?" method="GET">
|
||
|
|
<div class="input-group">
|
||
|
|
<input type="text" name="name" class="form-control mr-2" placeholder="Enter Name" value="<?php echo $data['name']; ?>">
|
||
|
|
<span class="input-group-btn">
|
||
|
|
<button class="btn btn-primary" type="submit">Search</button>
|
||
|
|
</span>
|
||
|
|
</div><!-- /input-group -->
|
||
|
|
</form>
|
||
|
|
</div><!-- /.col-md-6 -->
|
||
|
|
</div><!-- /.row -->
|
||
|
|
<!-- Table Responsive Wrapper -->
|
||
|
|
<div class="table-responsive">
|
||
|
|
<table class="table table-hover dark-header">
|
||
|
|
<thead>
|
||
|
|
<tr>
|
||
|
|
<th>ID</th>
|
||
|
|
<th>Name</th>
|
||
|
|
<th>Location/Account ID</th>
|
||
|
|
<th>Webhook URL</th>
|
||
|
|
<th>API Key</th>
|
||
|
|
|
||
|
|
</tr>
|
||
|
|
</thead>
|
||
|
|
<tbody>
|
||
|
|
<?php foreach ($data['data'] as $key => $value) {
|
||
|
|
echo ' <tr>';
|
||
|
|
echo ' <td>' . $value->id . ' <br/><a class=" text-info" href="/'.
|
||
|
|
$_SESSION['role'] . '/location/edit/' . $value->id .
|
||
|
|
'">edit</a> <a class="text-danger" href="/'. $_SESSION['role']. '/location/delete/' .
|
||
|
|
$value->id . '">delete</a></td>';
|
||
|
|
|
||
|
|
echo ' <td>' . $value->name . ' </td>';
|
||
|
|
echo ' <td>' . $value->location_id . ' </td>';
|
||
|
|
echo ' <td>' . $value->webhook . ' </td>';
|
||
|
|
echo ' <td>' . $value->apikey . ' </td>';
|
||
|
|
|
||
|
|
echo '</tr>';
|
||
|
|
}
|
||
|
|
?>
|
||
|
|
</tbody>
|
||
|
|
</table>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<?php
|
||
|
|
// Retrieve parameters
|
||
|
|
$total = $data['total'];
|
||
|
|
$currentPage = $data['page'];
|
||
|
|
$perPage = 10;
|
||
|
|
|
||
|
|
// Calculate the number of pages
|
||
|
|
$totalPages = ceil($total / $perPage);
|
||
|
|
|
||
|
|
// Define a range of pages to show at any given time
|
||
|
|
$range = 2; // This can be adjusted as needed
|
||
|
|
|
||
|
|
$startPage = ($currentPage - $range) > 0 ? ($currentPage - $range) : 1;
|
||
|
|
$endPage = ($currentPage + $range) < $totalPages ? ($currentPage + $range) : $totalPages;
|
||
|
|
|
||
|
|
?>
|
||
|
|
<!-- Pagination -->
|
||
|
|
<nav aria-label="Page navigation">
|
||
|
|
<ul class="pagination">
|
||
|
|
<li class="ml-2">
|
||
|
|
<a href="?page=1" aria-label="Previous">
|
||
|
|
<span aria-hidden="true">««</span>
|
||
|
|
</a>
|
||
|
|
</li>
|
||
|
|
<li class="ml-2">
|
||
|
|
<a href="?page=<?= ($currentPage - 1) > 0 ? $currentPage - 1 : 1 ?>" aria-label="Previous">
|
||
|
|
<span aria-hidden="true">«</span>
|
||
|
|
</a>
|
||
|
|
</li>
|
||
|
|
<?php
|
||
|
|
for ($i = $startPage; $i <= $endPage; $i++) {
|
||
|
|
echo '<li class="ml-2' . ($currentPage == $i ? ' active' : '') . '"><a href="?page=' . $i . '">' . $i . '</a></li>';
|
||
|
|
}
|
||
|
|
?>
|
||
|
|
<li class="ml-2">
|
||
|
|
<a href="?page=<?= ($currentPage + 1) < $totalPages ? $currentPage + 1 : $totalPages ?>" aria-label="Next">
|
||
|
|
<span aria-hidden="true">»</span>
|
||
|
|
</a>
|
||
|
|
</li>
|
||
|
|
<li class="ml-2">
|
||
|
|
<a href="?page=<?= $totalPages ?>" aria-label="Next">
|
||
|
|
<span aria-hidden="true">»»</span>
|
||
|
|
</a>
|
||
|
|
</li>
|
||
|
|
</ul>
|
||
|
|
</nav>
|
||
|
|
</div>
|