Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
efcbe8235d | ||
|
|
45c3a6c25b | ||
|
|
bda7319921 | ||
|
|
fa1ebff600 | ||
|
|
11ca3a78b6 | ||
|
|
afd1bcd526 | ||
|
|
6a23c0b811 |
57
api/login.php
Normal file
57
api/login.php
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/../session_config.php';
|
||||||
|
|
||||||
|
// Set headers
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
// Database connection
|
||||||
|
require_once '../db/config.php'; // Adjust path as needed
|
||||||
|
|
||||||
|
// Get JSON input
|
||||||
|
$input = json_decode(file_get_contents('php://input'), true);
|
||||||
|
|
||||||
|
if (!$input || !isset($input['email']) || !isset($input['password'])) {
|
||||||
|
http_response_code(400);
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Email and password are required.']);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$email = trim($input['email']);
|
||||||
|
$password = $input['password'];
|
||||||
|
|
||||||
|
$pdo = db();
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Query user from database
|
||||||
|
$stmt = $pdo->prepare("SELECT * FROM users WHERE email = ? LIMIT 1");
|
||||||
|
$stmt->execute([$email]);
|
||||||
|
$user = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if ($user && password_verify($password, $user['password'])) {
|
||||||
|
// Regenerate session ID for security
|
||||||
|
session_regenerate_id(true);
|
||||||
|
|
||||||
|
// Set session variables
|
||||||
|
$_SESSION['user_id'] = $user['id'];
|
||||||
|
$_SESSION['role'] = $user['role'];
|
||||||
|
$_SESSION['user_name'] = $user['name'];
|
||||||
|
$_SESSION['email'] = $user['email'];
|
||||||
|
$_SESSION['logged_in'] = true;
|
||||||
|
|
||||||
|
// Force session to be written
|
||||||
|
session_write_close();
|
||||||
|
|
||||||
|
echo json_encode([
|
||||||
|
'success' => true,
|
||||||
|
'message' => 'Login successful',
|
||||||
|
'redirect' => 'index.php'
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
http_response_code(401);
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Invalid email or password.']);
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
error_log("Login error: " . $e->getMessage());
|
||||||
|
http_response_code(500);
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Server error occurred.']);
|
||||||
|
}
|
||||||
93
assets/css/style.css
Normal file
93
assets/css/style.css
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
:root {
|
||||||
|
--main-bg-color: #F8F9FA;
|
||||||
|
--primary-color: #0F2A44;
|
||||||
|
--secondary-color: #1F7A5A;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: 'Poppins', sans-serif;
|
||||||
|
background-color: var(--main-bg-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
#wrapper {
|
||||||
|
overflow-x: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebar-wrapper {
|
||||||
|
min-height: 100vh;
|
||||||
|
margin-left: -15rem;
|
||||||
|
transition: margin 0.25s ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebar-wrapper .sidebar-heading {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebar-wrapper .list-group {
|
||||||
|
width: 15rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#page-content-wrapper {
|
||||||
|
min-width: 100vw;
|
||||||
|
}
|
||||||
|
|
||||||
|
#wrapper.toggled #sidebar-wrapper {
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebar-wrapper .list-group-item {
|
||||||
|
border: none;
|
||||||
|
color: #ced4da;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebar-wrapper .list-group-item:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.1);
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebar-wrapper .list-group-item.active {
|
||||||
|
background-color: var(--secondary-color) !important;
|
||||||
|
color: white;
|
||||||
|
font-weight: bold;
|
||||||
|
border-left: 5px solid white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.primary-text {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.second-text {
|
||||||
|
color: var(--primary-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-control, .form-select {
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary {
|
||||||
|
background-color: var(--primary-color);
|
||||||
|
border-color: var(--primary-color);
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary:hover {
|
||||||
|
background-color: #0b1f33;
|
||||||
|
border-color: #0b1f33;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-container {
|
||||||
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-card {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 450px;
|
||||||
|
}
|
||||||
45
auth.php
Normal file
45
auth.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/session_config.php';
|
||||||
|
|
||||||
|
function check_auth() {
|
||||||
|
// Check if user is logged in
|
||||||
|
if (!isset($_SESSION['logged_in']) || !$_SESSION['logged_in'] || !isset($_SESSION['role']) || !isset($_SESSION['user_id'])) {
|
||||||
|
// Store the current page to redirect after login
|
||||||
|
$_SESSION['redirect_after_login'] = $_SERVER['REQUEST_URI'];
|
||||||
|
header('Location: login.php');
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_user_role() {
|
||||||
|
return $_SESSION['role'] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_user_id() {
|
||||||
|
return $_SESSION['user_id'] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_user_name() {
|
||||||
|
return $_SESSION['user_name'] ?? 'User';
|
||||||
|
}
|
||||||
|
|
||||||
|
function is_logged_in() {
|
||||||
|
return isset($_SESSION['logged_in']) && $_SESSION['logged_in'] === true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function logout() {
|
||||||
|
$_SESSION = array();
|
||||||
|
|
||||||
|
if (ini_get("session.use_cookies")) {
|
||||||
|
$params = session_get_cookie_params();
|
||||||
|
setcookie(session_name(), '', time() - 42000,
|
||||||
|
$params["path"], $params["domain"],
|
||||||
|
$params["secure"], $params["httponly"]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
session_destroy();
|
||||||
|
header('Location: login.php');
|
||||||
|
exit();
|
||||||
|
}
|
||||||
227
index.php
227
index.php
@ -1,150 +1,87 @@
|
|||||||
<?php
|
<?php
|
||||||
declare(strict_types=1);
|
require_once 'auth.php';
|
||||||
@ini_set('display_errors', '1');
|
check_auth();
|
||||||
@error_reporting(E_ALL);
|
|
||||||
@date_default_timezone_set('UTC');
|
include 'partials/header.php';
|
||||||
|
include 'partials/sidebar.php';
|
||||||
|
|
||||||
|
$role = $_SESSION['role'] ?? 'guest';
|
||||||
|
$welcome_message = "Welcome to your dashboard!";
|
||||||
|
|
||||||
|
$cards = [];
|
||||||
|
if ($role === 'accountant') {
|
||||||
|
$cards = [
|
||||||
|
'Total Fees Expected' => ['value' => '$1,250,000', 'icon' => 'bi-cash-stack', 'color' => 'success'],
|
||||||
|
'Total Fees Collected' => ['value' => '$980,000', 'icon' => 'bi-check-circle', 'color' => 'info'],
|
||||||
|
'Outstanding Balances' => ['value' => '$270,000', 'icon' => 'bi-exclamation-triangle', 'color' => 'warning'],
|
||||||
|
'Term Expenses' => ['value' => '$150,000', 'icon' => 'bi-wallet2', 'color' => 'danger'],
|
||||||
|
];
|
||||||
|
} elseif ($role === 'secretary') {
|
||||||
|
$cards = [
|
||||||
|
'Total Students' => ['value' => '1,520', 'icon' => 'bi-people-fill', 'color' => 'primary'],
|
||||||
|
'Total Staff' => ['value' => '85', 'icon' => 'bi-person-badge', 'color' => 'info'],
|
||||||
|
'Attendance Today' => ['value' => '98%', 'icon' => 'bi-calendar-check', 'color' => 'success'],
|
||||||
|
'Pending Admissions' => ['value' => '12', 'icon' => 'bi-person-plus', 'color' => 'warning'],
|
||||||
|
];
|
||||||
|
} elseif ($role === 'headteacher') {
|
||||||
|
$cards = [
|
||||||
|
'Total Students' => ['value' => '1,520', 'icon' => 'bi-people-fill', 'color' => 'primary'],
|
||||||
|
'Total Staff' => ['value' => '85', 'icon' => 'bi-person-badge', 'color' => 'info'],
|
||||||
|
'Financial Snapshot' => ['value' => 'On Track', 'icon' => 'bi-pie-chart', 'color' => 'success'],
|
||||||
|
'Academic Performance' => ['value' => 'Excelling', 'icon' => 'bi-graph-up', 'color' => 'secondary'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
$phpVersion = PHP_VERSION;
|
|
||||||
$now = date('Y-m-d H:i:s');
|
|
||||||
?>
|
?>
|
||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
<div class="row g-3 my-2">
|
||||||
<head>
|
<?php foreach ($cards as $title => $data): ?>
|
||||||
<meta charset="utf-8" />
|
<div class="col-md-3">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<div class="p-3 bg-white shadow-sm d-flex justify-content-around align-items-center rounded">
|
||||||
<title>New Style</title>
|
<div>
|
||||||
<?php
|
<h3 class="fs-2"><?php echo $data['value']; ?></h3>
|
||||||
// Read project preview data from environment
|
<p class="fs-5"><?php echo $title; ?></p>
|
||||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
|
||||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
|
||||||
?>
|
|
||||||
<?php if ($projectDescription): ?>
|
|
||||||
<!-- Meta description -->
|
|
||||||
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
|
|
||||||
<!-- Open Graph meta tags -->
|
|
||||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
|
||||||
<!-- Twitter meta tags -->
|
|
||||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if ($projectImageUrl): ?>
|
|
||||||
<!-- Open Graph image -->
|
|
||||||
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
|
||||||
<!-- Twitter image -->
|
|
||||||
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
|
||||||
<?php endif; ?>
|
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
|
||||||
<style>
|
|
||||||
:root {
|
|
||||||
--bg-color-start: #6a11cb;
|
|
||||||
--bg-color-end: #2575fc;
|
|
||||||
--text-color: #ffffff;
|
|
||||||
--card-bg-color: rgba(255, 255, 255, 0.01);
|
|
||||||
--card-border-color: rgba(255, 255, 255, 0.1);
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
font-family: 'Inter', sans-serif;
|
|
||||||
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
|
||||||
color: var(--text-color);
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
min-height: 100vh;
|
|
||||||
text-align: center;
|
|
||||||
overflow: hidden;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
body::before {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
|
|
||||||
animation: bg-pan 20s linear infinite;
|
|
||||||
z-index: -1;
|
|
||||||
}
|
|
||||||
@keyframes bg-pan {
|
|
||||||
0% { background-position: 0% 0%; }
|
|
||||||
100% { background-position: 100% 100%; }
|
|
||||||
}
|
|
||||||
main {
|
|
||||||
padding: 2rem;
|
|
||||||
}
|
|
||||||
.card {
|
|
||||||
background: var(--card-bg-color);
|
|
||||||
border: 1px solid var(--card-border-color);
|
|
||||||
border-radius: 16px;
|
|
||||||
padding: 2rem;
|
|
||||||
backdrop-filter: blur(20px);
|
|
||||||
-webkit-backdrop-filter: blur(20px);
|
|
||||||
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
|
|
||||||
}
|
|
||||||
.loader {
|
|
||||||
margin: 1.25rem auto 1.25rem;
|
|
||||||
width: 48px;
|
|
||||||
height: 48px;
|
|
||||||
border: 3px solid rgba(255, 255, 255, 0.25);
|
|
||||||
border-top-color: #fff;
|
|
||||||
border-radius: 50%;
|
|
||||||
animation: spin 1s linear infinite;
|
|
||||||
}
|
|
||||||
@keyframes spin {
|
|
||||||
from { transform: rotate(0deg); }
|
|
||||||
to { transform: rotate(360deg); }
|
|
||||||
}
|
|
||||||
.hint {
|
|
||||||
opacity: 0.9;
|
|
||||||
}
|
|
||||||
.sr-only {
|
|
||||||
position: absolute;
|
|
||||||
width: 1px; height: 1px;
|
|
||||||
padding: 0; margin: -1px;
|
|
||||||
overflow: hidden;
|
|
||||||
clip: rect(0, 0, 0, 0);
|
|
||||||
white-space: nowrap; border: 0;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 3rem;
|
|
||||||
font-weight: 700;
|
|
||||||
margin: 0 0 1rem;
|
|
||||||
letter-spacing: -1px;
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 0.5rem 0;
|
|
||||||
font-size: 1.1rem;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
background: rgba(0,0,0,0.2);
|
|
||||||
padding: 2px 6px;
|
|
||||||
border-radius: 4px;
|
|
||||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
||||||
}
|
|
||||||
footer {
|
|
||||||
position: absolute;
|
|
||||||
bottom: 1rem;
|
|
||||||
font-size: 0.8rem;
|
|
||||||
opacity: 0.7;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<main>
|
|
||||||
<div class="card">
|
|
||||||
<h1>Analyzing your requirements and generating your website…</h1>
|
|
||||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
|
||||||
<span class="sr-only">Loading…</span>
|
|
||||||
</div>
|
</div>
|
||||||
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
|
<i class="<?php echo $data['icon']; ?> fs-1 text-<?php echo $data['color']; ?>"></i>
|
||||||
<p class="hint">This page will update automatically as the plan is implemented.</p>
|
|
||||||
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
|
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</div>
|
||||||
<footer>
|
<?php endforeach; ?>
|
||||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
</div>
|
||||||
</footer>
|
|
||||||
</body>
|
<div class="row my-5">
|
||||||
</html>
|
<h3 class="fs-4 mb-3">Recent Activity (Placeholder)</h3>
|
||||||
|
<div class="col">
|
||||||
|
<table class="table bg-white rounded shadow-sm table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col" width="50">#</th>
|
||||||
|
<th scope="col">Item</th>
|
||||||
|
<th scope="col">Details</th>
|
||||||
|
<th scope="col">Date</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">1</th>
|
||||||
|
<td>Sample Item 1</td>
|
||||||
|
<td>Details about the item go here.</td>
|
||||||
|
<td>01/04/2026</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">2</th>
|
||||||
|
<td>Sample Item 2</td>
|
||||||
|
<td>Details about the item go here.</td>
|
||||||
|
<td>01/04/2026</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">3</th>
|
||||||
|
<td>Sample Item 3</td>
|
||||||
|
<td>Details about the item go here.</td>
|
||||||
|
<td>01/04/2026</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php include 'partials/footer.php'; ?>
|
||||||
105
login.php
Normal file
105
login.php
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
<?php
|
||||||
|
require_once 'session_config.php';
|
||||||
|
|
||||||
|
// If already logged in, redirect to dashboard
|
||||||
|
if (isset($_SESSION['logged_in']) && $_SESSION['logged_in'] === true) {
|
||||||
|
$redirect = $_SESSION['redirect_after_login'] ?? 'index.php';
|
||||||
|
unset($_SESSION['redirect_after_login']);
|
||||||
|
header('Location: ' . $redirect);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
include 'partials/header.php';
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="container-fluid login-container">
|
||||||
|
<div class="card shadow-lg login-card p-4">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="text-center mb-4">
|
||||||
|
<i class="bi-building fs-1" style="color: var(--primary-color);"></i>
|
||||||
|
<h1 class="h3 mb-3 fw-bold">Providencia ERP</h1>
|
||||||
|
<p class="text-muted">Please sign in to continue</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="error-message" class="alert alert-danger" style="display: none;"></div>
|
||||||
|
|
||||||
|
<form id="login-form">
|
||||||
|
<div class="form-floating mb-3">
|
||||||
|
<input type="email" class="form-control" id="email" name="email" placeholder="name@example.com" required>
|
||||||
|
<label for="email">Email address</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-floating mb-3">
|
||||||
|
<input type="password" class="form-control" id="password" name="password" placeholder="Password" required>
|
||||||
|
<label for="password">Password</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-grid">
|
||||||
|
<button class="btn btn-primary btn-lg" type="submit" id="submit-btn">
|
||||||
|
<span id="btn-text">Sign in</span>
|
||||||
|
<span id="btn-spinner" class="spinner-border spinner-border-sm" style="display: none;"></span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<div class="mt-3 text-center">
|
||||||
|
<small class="text-muted">Hint: Try one of these emails with the password 'password':<br>
|
||||||
|
accountant@example.com<br>
|
||||||
|
secretary@example.com<br>
|
||||||
|
headteacher@example.com
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
document.getElementById('login-form').addEventListener('submit', async function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
const email = document.getElementById('email').value;
|
||||||
|
const password = document.getElementById('password').value;
|
||||||
|
const errorDiv = document.getElementById('error-message');
|
||||||
|
const submitBtn = document.getElementById('submit-btn');
|
||||||
|
const btnText = document.getElementById('btn-text');
|
||||||
|
const btnSpinner = document.getElementById('btn-spinner');
|
||||||
|
|
||||||
|
errorDiv.style.display = 'none';
|
||||||
|
submitBtn.disabled = true;
|
||||||
|
btnText.style.display = 'none';
|
||||||
|
btnSpinner.style.display = 'inline-block';
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch('api/login.php', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ email, password }),
|
||||||
|
credentials: 'same-origin' // Important for sessions
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await response.json();
|
||||||
|
|
||||||
|
if (response.ok && result.success) {
|
||||||
|
// Add a small delay to ensure session is written
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.href = result.redirect || 'index.php';
|
||||||
|
}, 100);
|
||||||
|
} else {
|
||||||
|
errorDiv.textContent = result.message || 'Invalid email or password.';
|
||||||
|
errorDiv.style.display = 'block';
|
||||||
|
submitBtn.disabled = false;
|
||||||
|
btnText.style.display = 'inline';
|
||||||
|
btnSpinner.style.display = 'none';
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Login error:', error);
|
||||||
|
errorDiv.textContent = 'Failed to connect to the server. Please try again.';
|
||||||
|
errorDiv.style.display = 'block';
|
||||||
|
submitBtn.disabled = false;
|
||||||
|
btnText.style.display = 'inline';
|
||||||
|
btnSpinner.style.display = 'none';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<?php include 'partials/footer.php'; ?>
|
||||||
5
logout.php
Normal file
5
logout.php
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
session_destroy();
|
||||||
|
header('Location: login.php');
|
||||||
|
exit();
|
||||||
8
partials/footer.php
Normal file
8
partials/footer.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- /#page-content-wrapper -->
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
15
partials/header.php
Normal file
15
partials/header.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Providencia School ERP</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700&display=swap" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="assets/css/style.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="d-flex" id="wrapper">
|
||||||
83
partials/sidebar.php
Normal file
83
partials/sidebar.php
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
$role = $_SESSION['role'] ?? 'guest';
|
||||||
|
|
||||||
|
$nav_items = [];
|
||||||
|
|
||||||
|
if ($role === 'accountant') {
|
||||||
|
$nav_items = [
|
||||||
|
'Dashboard' => 'bi-grid-fill',
|
||||||
|
'Students' => 'bi-people-fill',
|
||||||
|
'Fees Management' => 'bi-receipt',
|
||||||
|
'Invoices' => 'bi-file-earmark-text-fill',
|
||||||
|
'Payments' => 'bi-credit-card-fill',
|
||||||
|
'Expenses' => 'bi-wallet2',
|
||||||
|
'Payroll' => 'bi-cash-stack',
|
||||||
|
'Financial Reports' => 'bi-graph-up',
|
||||||
|
'Settings' => 'bi-gear-fill',
|
||||||
|
];
|
||||||
|
} elseif ($role === 'secretary') {
|
||||||
|
$nav_items = [
|
||||||
|
'Dashboard' => 'bi-grid-fill',
|
||||||
|
'Students' => 'bi-people-fill',
|
||||||
|
'Admissions' => 'bi-person-plus-fill',
|
||||||
|
'Classes' => 'bi-collection-fill',
|
||||||
|
'Staff Management' => 'bi-person-badge',
|
||||||
|
'Attendance' => 'bi-check-circle-fill',
|
||||||
|
'Timetable' => 'bi-calendar3',
|
||||||
|
'Documents' => 'bi-folder-fill',
|
||||||
|
'Settings' => 'bi-gear-fill',
|
||||||
|
];
|
||||||
|
} elseif ($role === 'headteacher') {
|
||||||
|
$nav_items = [
|
||||||
|
'Dashboard' => 'bi-grid-fill',
|
||||||
|
'Academic Management' => 'bi-book-half',
|
||||||
|
'Staff Oversight' => 'bi-eye-fill',
|
||||||
|
'Finance Overview' => 'bi-pie-chart-fill',
|
||||||
|
'Reports & Analytics' => 'bi-bar-chart-line-fill',
|
||||||
|
'Approvals' => 'bi-check2-square',
|
||||||
|
'System Settings' => 'bi-sliders',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!-- Sidebar -->
|
||||||
|
<div class="bg-dark" id="sidebar-wrapper">
|
||||||
|
<div class="sidebar-heading text-center py-4 primary-text fs-4 fw-bold text-uppercase border-bottom">
|
||||||
|
<i class="bi-building me-2"></i>Providencia
|
||||||
|
</div>
|
||||||
|
<div class="list-group list-group-flush my-3">
|
||||||
|
<?php foreach ($nav_items as $item => $icon): ?>
|
||||||
|
<a href="#" class="list-group-item list-group-item-action bg-transparent second-text fw-bold <?php echo ($item === 'Dashboard') ? 'active' : ''; ?>">
|
||||||
|
<i class="<?php echo $icon; ?> me-2"></i><?php echo $item; ?>
|
||||||
|
</a>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- /#sidebar-wrapper -->
|
||||||
|
|
||||||
|
<!-- Page Content -->
|
||||||
|
<div id="page-content-wrapper">
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-light bg-transparent py-4 px-4">
|
||||||
|
<div class="d-flex align-items-center">
|
||||||
|
<h2 class="fs-2 m-0">Dashboard</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||||
|
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
|
||||||
|
<li class="nav-item dropdown">
|
||||||
|
<a class="nav-link dropdown-toggle second-text fw-bold" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||||
|
<i class="bi-person-circle me-2"></i><?php echo ucfirst($role); ?>
|
||||||
|
</a>
|
||||||
|
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||||
|
<li><a class="dropdown-item" href="#">Profile</a></li>
|
||||||
|
<li><a class="dropdown-item" href="logout.php">Logout</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
<div class="container-fluid px-4">
|
||||||
3
session_config.php
Normal file
3
session_config.php
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
?>
|
||||||
Loading…
x
Reference in New Issue
Block a user