Skip to content
Open
9 changes: 9 additions & 0 deletions controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,15 @@ public function customers()
return $this->render('/admin/customers', ['customers' => $customers]);

}
public function serviceCentre()
{
// Fetch all service centre records
$serviceCentres = Admin::findAllServiceCentres();
// Render the all the customer in the database
$this->setLayout('auth');
return $this->render('/admin/admin-service-centre', ['serviceCentres' => $serviceCentres]);

}

public function technicians()
{
Expand Down
7 changes: 7 additions & 0 deletions models/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ public static function findAllTechnicians()
$statement->execute();
return $statement->fetchAll(\PDO::FETCH_ASSOC);
}
public static function findAllServiceCentres()
{
$sql = "SELECT ser_cen_id, name, email, phone_no, address, reg_date FROM service_center";
$statement = (new Admin)->prepare($sql);
$statement->execute();
return $statement->fetchAll(\PDO::FETCH_ASSOC);
}

public static function deleteCustomerById($cus_id)
{
Expand Down
7 changes: 6 additions & 1 deletion public/css/admin/customers.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@ body {
background-color: #f9f9f9;
}

.button {
.delete-btn {
padding: 8px 16px;
cursor: pointer;
background-color: #e3342f;
color: white;
border: none;
border-radius: 5px;
transition: background-color 0.3s;
}

.button.dark {
Expand Down
1 change: 1 addition & 0 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
$app->router->get('/admin-dashboard', [AdminController::class, 'adminDashboard']);
$app->router->get('/customers', [AdminController::class, 'customers']);
$app->router->get('/technicians', [AdminController::class, 'technicians']);
$app->router->get('/admin-service-centre', [AdminController::class, 'serviceCentre']);
$app->router->post('/admin/delete-technician', [AdminController::class, 'deleteTechnician']);
$app->router->get('/admin-settings', [AdminController::class, 'adminSettings']);
$app->router->get('/admin-profile', [AdminController::class, 'adminProfile']);
Expand Down
3 changes: 2 additions & 1 deletion views/admin/admin-login.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Technician Sign Up</title>
<title>Admin login</title>

<link rel="stylesheet" href="/css/admin/admin-login.css">
<link rel="stylesheet" href="/css/base/_reset.css">
Expand Down Expand Up @@ -69,6 +69,7 @@ class="<?php echo $model->hasError('password') ? 'invalid ' : '' ?>">
<button type="submit" class="btn">Log in</button>
</div>


</form>
</div>
</div>
Expand Down
73 changes: 73 additions & 0 deletions views/admin/admin-service-centre.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/css/admin/customers.css">
<link rel="stylesheet" href="/css/admin/admin-dashboard.css">
<title>Admin service center management</title>
</head>
<body>

<?php
include_once 'components/sidebar.php';
include_once 'components/header.php';
?>
<div class="customers-container">

<div id="customers-table">
<table class="table">
<thead>
<tr>
<th>Service Center ID</th>
<th>Name</th>
<th>Email</th>
<th>Phone Number</th>
<th>Address</th>
<th>Registered Date</th>
<th>Actions</th>
</tr>
</thead>
<tbody id="table-body">
<?php if (!empty($serviceCentres)): ?>
<?php foreach ($serviceCentres as $serviceCentres): ?>
<tr data-service_Centre-id="<?= htmlspecialchars($serviceCentres['ser_cen_id']) ?>">
<td><?= htmlspecialchars($serviceCentres['ser_cen_id']) ?></td>
<td><?= htmlspecialchars($serviceCentres['name']) ?></td>
<td><?= htmlspecialchars($serviceCentres['email']) ?></td>
<td><?= htmlspecialchars($serviceCentres['phone_no']) ?></td>
<td><?= htmlspecialchars($serviceCentres['address']) ?></td>
<td><?= htmlspecialchars($serviceCentres['reg_date']) ?></td>
<td>
<button class="delete-btn">Delete</button>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="7">No Service Centers found.</td>
</tr>
<?php endif; ?>
</tbody>
</table>
<p id="no-packages-message" style="display: none;">You have no packages yet!</p>
</div>

<!-- Modal -->
<div id="delete-modal" class="modal hidden">
<div class="modal-content">
<h3>Are you sure you want to delete this service centre?</h3>
<div class="modal-buttons">
<button id="confirm-delete" class="button failure">Yes</button>
<button id="cancel-delete" class="button gray">No, cancel</button>
</div>
</div>
</div>
</div>

<script src="/js/admin/technicians.js"></script>
<!-- Icons-->
<script type="module" src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.js"></script>
</body>
</html>
9 changes: 8 additions & 1 deletion views/admin/components/sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@
<span class="title">Technicians</span>
</a>
</li>

<li>
<a href="/admin-service-centre">
<span class="icon">
<ion-icon name="home-outline"></ion-icon>
</span>
<span class="title">Service Centres</span>
</a>
</li>

<li>
<a href="/admin-reports">
Expand Down