Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/admin updated #40

Closed
wants to merge 12 commits into from
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
DB_DSN = mysql:host=localhost;port=3306;dbname=fixmedb
DB_USER = root
DB_PASSWORD =
DB_PASSWORD =Nimal@123
13 changes: 13 additions & 0 deletions public/css/admin/admin-promotions.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
body {
font-family: Arial, sans-serif;
background-color: #f9f9f9;
}



.table {
width: 100%;
border-collapse: collapse;
border-radius: 40px;

}
77 changes: 77 additions & 0 deletions public/css/admin/reports.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/* General Reset */
body {
margin: 0;
font-family: Arial, sans-serif;
background-color: #f5f5f5;
}

/* Centering Container */
.promotion-container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh; /* Full viewport height */
background-color: #f5f5f5; /* Light background */
}

/* Promotion Form Styling */
.promotion-form {
background-color: #ffffff; /* White background */
padding: 30px;
border-radius: 8px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); /* Subtle shadow */
width: 400px;
}

.promotion-form h2 {
text-align: center;
margin-bottom: 20px;
color: #010336; /* Deep blue */
}

/* Form Group Styling */
.form-group {
margin-bottom: 15px;
}

.form-group label {
display: block;
font-weight: bold;
margin-bottom: 5px;
color: #333333; /* Darker text */
}

.form-group input,
.form-group select {
width: 100%;
padding: 10px;
border: 1px solid #cccccc;
border-radius: 5px;
box-sizing: border-box;
font-size: 16px;
}

.form-group input:focus,
.form-group select:focus {
border-color: #010336; /* Highlighted border */
outline: none;
box-shadow: 0 0 5px rgba(1, 3, 54, 0.2);
}

/* Button Styling */
button {
width: 100%;
padding: 12px;
background-color: #010336; /* Deep blue */
color: #ffffff; /* White text */
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
font-weight: bold;
}

button:hover {
background-color: #002080; /* Slightly lighter blue */
transition: background-color 0.3s;
}
35 changes: 35 additions & 0 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@
$app->router->post('/update-admin-profile', [AdminController::class, 'updateAdminProfile']);

/* Admin Routes */

$app->router->get('/customers', [AdminController::class, 'customers']);
$app->router->post('/admin/delete-customer', [AdminController::class, 'deleteCustomer']);

$app->router->get('/admin-services', [AdminController::class, 'manageServices']);
$app->router->post('/admin-services-add', [AdminController::class, 'addService']);
$app->router->post('/admin-services-edit', [AdminController::class, 'editService']);
Expand Down Expand Up @@ -150,6 +154,37 @@
$app->router->post('/service-centre-login', [AuthController::class, 'serviceCentreLogin']);
$app->router->get('/service-center-logout', [AuthController::class, 'serviceCenterLogout']);


/*routes related to the product(service center)*/
$app->router->get('/service-center-create-product', [ServiceCentreController::class, 'serviceCenterCreateProduct']);
$app->router->post('/service-center-create-product', [ProductController::class, 'create']);
$app->router->get('/market-place-home', [ProductController::class, 'index']);
$app->router->get('/service-center-create-product', [ProductController::class, 'filterProductsById']);
$app->router->get('/service-center-update-product', [ProductController::class,'update']);
$app->router->get('/service-center-update-product', [ServiceCentreController::class, 'update']);
$app->router->post('/service-center-update-product', [ProductController::class, 'update']);
$app->router->post('/service-center-delete-product', [ProductController::class, 'delete']);



/** Admin Routes */
$app->router->get('/customers', [AdminController::class, 'customers']);
$app->router->post('/admin/delete-customer', [AdminController::class, 'deleteCustomer']);



$app->router->get('/admin-services', [AdminController::class, 'manageServices']);
$app->router->post('/admin-services-add', [AdminController::class, 'addService']);
$app->router->post('/admin-services-edit', [AdminController::class, 'editService']);
$app->router->post('/admin-services-delete', [AdminController::class, 'deleteService']);

$app->router->get('/admin-reports', [AdminController::class, 'viewReports']);
$app->router->post('/admin-reports-generate', [AdminController::class, 'generateReport']);

$app->router->post('/admin-settings-update', [AdminController::class, 'updateSettings']);

$app->router->get('/admin-promotions', [AdminController::class, 'promotions']);

/* Admin Auth routes */
$app->router->get('/admin-login', [AuthController::class, 'adminLogin']);
$app->router->post('/admin-login', [AuthController::class, 'adminLogin']);
Expand Down
4 changes: 2 additions & 2 deletions public/js/admin/chart.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const chartData = {
labels: ["Customers", "Technician", "Service Centre", ],
data: [30, 17, 10],
labels: ["Five star reviews", "Four star reviews", "Three star reviews", "Two star reviews","One star reviews"],
data: [30, 17, 10,22,42],
};

const myChart = document.querySelector(".my-chart");
Expand Down
103 changes: 88 additions & 15 deletions views/admin/admin-promotions.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,96 @@
<?php
// Database connection details
$servername = "localhost";
$username = "root";
$password = "Nimal@123";
$dbname = "fixmedb";

try {
// Create a new PDO instance
$pdo = new PDO("mysql:host=$servername;dbname=$dbname;charset=utf8", $username, $password);
// Set the PDO error mode to exception
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

// SQL query to fetch data from the 'promotions' table
$stmt = $pdo->prepare("SELECT promotion_id, admin_id, description, price, media, created_at, updated_at FROM promotion");
$stmt->execute();

// Fetch all rows as an associative array
$promotions = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
// Handle connection errors
echo "Connection failed: " . $e->getMessage();
$promotions = []; // Fallback to an empty array
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Promotions</title>
<link rel="stylesheet" href="/css/admin/admin-dashboard.css">
</head>
<body>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Promotions</title>
<link rel="stylesheet" href="/css/admin/admin-dashboard.css">
<link rel="stylesheet" href="/css/admin/customers.css">
</head>
<body>
<?php
include_once 'components/sidebar.php';
include_once 'components/header.php';
?>



<!-- Icons-->
<div id="customers-table">
<table class="table">
<thead>
<tr>
<th>Promotion ID</th>
<th>Admin ID</th>
<th>Description</th>
<th>Discount</th>
<th>Media</th>
<th>Created Date</th>
<th>Updated Date</th>
<th>Actions</th>
</tr>
</thead>
<tbody id="table-body">
<?php if (!empty($promotions)): ?>
<?php foreach ($promotions as $promotion): ?>
<tr data-promotion-id="<?= htmlspecialchars($promotion['promotion_id']) ?>">
<td><?= htmlspecialchars($promotion['promotion_id']) ?></td>
<td><?= htmlspecialchars($promotion['admin_id']) ?></td>
<td><?= htmlspecialchars($promotion['description']) ?></td>
<td><?= htmlspecialchars($promotion['price']) ?></td>
<td><?= htmlspecialchars($promotion['media']) ?></td>
<td><?= htmlspecialchars($promotion['created_at']) ?></td>
<td><?= htmlspecialchars($promotion['updated_at']) ?></td>
<td>
<button class="delete-btn">Delete</button>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="8">No Promotions found.</td>
</tr>
<?php endif; ?>
</tbody>
</table>

<!-- Modal -->
<div id="delete-modal" class="modal hidden">
<div class="modal-content">
<h3>Are you sure you want to delete this Promotion?</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/customers.js"></script>
<script src="/js/admin/main.js"></script>
<script type="module" src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.js"></script>
</body>
</html>
</body>
</html>
45 changes: 43 additions & 2 deletions views/admin/reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,55 @@
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Reports</title>
<link rel="stylesheet" href="/css/admin/admin-dashboard.css">
<link rel="stylesheet" href="/css/admin/reports.css">
</head>
<body>
<?php
include_once 'components/sidebar.php';
include_once 'components/header.php';
?>
<!-- <script src="/js/admin/main.js"></script> -->

<div class="promotion-container">
<div class="promotion-form">
<h2>Create Report</h2>
<form>
<div class="form-group">
<label for="username">Username</label>
<input type="text" id="username" name="username" placeholder="Enter username" required />
</div>

<div class="form-group">
<label for="role">Role</label>
<select id="role" name="role">
<option>Select Role</option>
<option>Customer</option>
<option>Technician</option>
<option>Service Centre</option>
</select>
</div>
<div class="form-group">
<label for="start-date">Start Date</label>
<input type="date" id="start-date" name="start-date" />
</div>
<div class="form-group">
<label for="end-date">End Date</label>
<input type="date" id="end-date" name="end-date" />
</div>
<div class="form-group">
<button type="submit">Generate Report</button>
</div>
</form>
</div>
</div>





<script src="/js/admin/main.js"></script>

</body>





Expand Down
2 changes: 1 addition & 1 deletion views/admin/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@



<script src="/js/admin/main.js"></script>
<!-- Icons-->
<script type="module" src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.js"></script>
Expand Down