Compare commits

..

No commits in common. "ai-dev" and "master" have entirely different histories.

11 changed files with 462 additions and 931 deletions

View File

@ -1,111 +1,346 @@
:root {
--primary: #0F172A;
--secondary: #64748B;
--success: #10B981;
--danger: #EF4444;
--warning: #F59E0B;
--info: #3B82F6;
--light: #F8FAFC;
--border: #E2E8F0;
--radius: 6px;
--color-bg: #ffffff;
--color-text: #1a1a1a;
--color-primary: #2563EB; /* Vibrant Blue */
--color-secondary: #000000;
--color-accent: #A3E635; /* Lime Green */
--color-surface: #f8f9fa;
--font-heading: 'Space Grotesk', sans-serif;
--font-body: 'Inter', sans-serif;
--border-width: 2px;
--shadow-hard: 5px 5px 0px #000;
--shadow-hover: 8px 8px 0px #000;
--radius-pill: 50rem;
--radius-card: 1rem;
}
body {
font-family: 'Inter', system-ui, -apple-system, sans-serif;
background-color: var(--light);
color: var(--primary);
font-size: 14px;
line-height: 1.5;
font-family: var(--font-body);
background-color: var(--color-bg);
color: var(--color-text);
overflow-x: hidden;
}
.card {
border: 1px solid var(--border);
border-radius: var(--radius);
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
h1, h2, h3, h4, h5, h6, .navbar-brand {
font-family: var(--font-heading);
letter-spacing: -0.03em;
}
.btn {
border-radius: var(--radius);
font-weight: 500;
padding: 0.5rem 1rem;
transition: all 0.2s;
}
.btn-primary {
background-color: var(--primary);
border-color: var(--primary);
}
.btn-primary:hover {
background-color: #1E293B;
border-color: #1E293B;
}
.form-control, .form-select {
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 0.5rem 0.75rem;
}
.form-control:focus {
border-color: var(--info);
box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}
/* Utilities */
.text-primary { color: var(--color-primary) !important; }
.bg-black { background-color: #000 !important; }
.text-white { color: #fff !important; }
.shadow-hard { box-shadow: var(--shadow-hard); }
.border-2-black { border: var(--border-width) solid #000; }
.py-section { padding-top: 5rem; padding-bottom: 5rem; }
/* Navbar */
.navbar {
border-bottom: 1px solid var(--border);
background-color: #fff;
background: rgba(255, 255, 255, 0.9);
backdrop-filter: blur(10px);
border-bottom: var(--border-width) solid transparent;
transition: all 0.3s;
padding-top: 1rem;
padding-bottom: 1rem;
}
.navbar.scrolled {
border-bottom-color: #000;
padding-top: 0.5rem;
padding-bottom: 0.5rem;
}
.brand-text {
font-size: 1.5rem;
font-weight: 800;
}
.nav-link {
color: var(--secondary);
font-weight: 500;
font-weight: 500;
color: var(--color-text);
margin-left: 1rem;
position: relative;
}
.nav-link.active {
color: var(--primary);
.nav-link:hover, .nav-link.active {
color: var(--color-primary);
}
.step-indicator {
display: flex;
justify-content: space-between;
margin-bottom: 2rem;
position: relative;
/* Buttons */
.btn {
font-weight: 700;
font-family: var(--font-heading);
padding: 0.8rem 2rem;
border-radius: var(--radius-pill);
border: var(--border-width) solid #000;
transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
box-shadow: var(--shadow-hard);
}
.step-indicator::before {
content: '';
position: absolute;
top: 50%;
left: 0;
right: 0;
height: 2px;
background: var(--border);
z-index: 1;
transform: translateY(-50%);
.btn:hover {
transform: translate(-2px, -2px);
box-shadow: var(--shadow-hover);
}
.step {
width: 32px;
height: 32px;
border-radius: 50%;
background: #fff;
border: 2px solid var(--border);
display: flex;
align-items: center;
justify-content: center;
z-index: 2;
font-weight: bold;
color: var(--secondary);
.btn:active {
transform: translate(2px, 2px);
box-shadow: 0 0 0 #000;
}
.step.active {
border-color: var(--primary);
color: var(--primary);
.btn-primary {
background-color: var(--color-primary);
border-color: #000;
color: #fff;
}
.step.completed {
background: var(--primary);
border-color: var(--primary);
color: #fff;
}
.btn-primary:hover {
background-color: #1d4ed8;
border-color: #000;
color: #fff;
}
.btn-outline-dark {
background-color: #fff;
color: #000;
}
.btn-cta {
background-color: var(--color-accent);
color: #000;
}
.btn-cta:hover {
background-color: #8cc629;
color: #000;
}
/* Hero Section */
.hero-section {
min-height: 100vh;
padding-top: 80px;
}
.background-blob {
position: absolute;
border-radius: 50%;
filter: blur(80px);
opacity: 0.6;
z-index: 1;
}
.blob-1 {
top: -10%;
right: -10%;
width: 600px;
height: 600px;
background: radial-gradient(circle, var(--color-accent), transparent);
}
.blob-2 {
bottom: 10%;
left: -10%;
width: 500px;
height: 500px;
background: radial-gradient(circle, var(--color-primary), transparent);
}
.highlight-text {
background: linear-gradient(120deg, transparent 0%, transparent 40%, var(--color-accent) 40%, var(--color-accent) 100%);
background-repeat: no-repeat;
background-size: 100% 40%;
background-position: 0 88%;
padding: 0 5px;
}
.dot { color: var(--color-primary); }
.badge-pill {
display: inline-block;
padding: 0.5rem 1rem;
border: 2px solid #000;
border-radius: 50px;
font-weight: 700;
background: #fff;
box-shadow: 4px 4px 0 #000;
font-family: var(--font-heading);
font-size: 0.9rem;
}
/* Marquee */
.marquee-container {
overflow: hidden;
white-space: nowrap;
border-top: 2px solid #000;
border-bottom: 2px solid #000;
}
.rotate-divider {
transform: rotate(-2deg) scale(1.05);
z-index: 10;
position: relative;
margin-top: -50px;
margin-bottom: 30px;
}
.marquee-content {
display: inline-block;
animation: marquee 20s linear infinite;
font-family: var(--font-heading);
font-weight: 700;
font-size: 1.5rem;
letter-spacing: 2px;
}
@keyframes marquee {
0% { transform: translateX(0); }
100% { transform: translateX(-50%); }
}
/* Portfolio Cards */
.project-card {
border: 2px solid #000;
border-radius: var(--radius-card);
overflow: hidden;
background: #fff;
transition: transform 0.3s ease;
box-shadow: var(--shadow-hard);
height: 100%;
display: flex;
flex-direction: column;
}
.project-card:hover {
transform: translateY(-10px);
box-shadow: 8px 8px 0 #000;
}
.card-img-holder {
height: 250px;
display: flex;
align-items: center;
justify-content: center;
border-bottom: 2px solid #000;
position: relative;
font-size: 4rem;
}
.placeholder-art {
transition: transform 0.3s ease;
}
.project-card:hover .placeholder-art {
transform: scale(1.2) rotate(10deg);
}
.bg-soft-blue { background-color: #e0f2fe; }
.bg-soft-green { background-color: #dcfce7; }
.bg-soft-purple { background-color: #f3e8ff; }
.bg-soft-yellow { background-color: #fef9c3; }
.category-tag {
position: absolute;
top: 15px;
right: 15px;
background: #000;
color: #fff;
padding: 5px 12px;
border-radius: 20px;
font-size: 0.75rem;
font-weight: 700;
}
.card-body { padding: 1.5rem; }
.link-arrow {
text-decoration: none;
color: #000;
font-weight: 700;
display: inline-flex;
align-items: center;
margin-top: auto;
}
.link-arrow i { transition: transform 0.2s; margin-left: 5px; }
.link-arrow:hover i { transform: translateX(5px); }
/* About */
.about-image-stack {
position: relative;
height: 400px;
width: 100%;
}
.stack-card {
position: absolute;
width: 80%;
height: 100%;
border-radius: var(--radius-card);
border: 2px solid #000;
box-shadow: var(--shadow-hard);
left: 10%;
transform: rotate(-3deg);
background-size: cover;
}
/* Forms */
.form-control {
border: 2px solid #000;
border-radius: 0.5rem;
padding: 1rem;
font-weight: 500;
background: #f8f9fa;
}
.form-control:focus {
box-shadow: 4px 4px 0 var(--color-primary);
border-color: #000;
background: #fff;
}
/* Animations */
.animate-up {
opacity: 0;
transform: translateY(30px);
animation: fadeUp 0.8s ease forwards;
}
.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
@keyframes fadeUp {
to {
opacity: 1;
transform: translateY(0);
}
}
/* Social */
.social-links a {
transition: transform 0.2s;
display: inline-block;
}
.social-links a:hover {
transform: scale(1.2) rotate(10deg);
color: var(--color-accent) !important;
}
/* Responsive */
@media (max-width: 991px) {
.rotate-divider {
transform: rotate(0);
margin-top: 0;
margin-bottom: 2rem;
}
.hero-section {
padding-top: 120px;
text-align: center;
min-height: auto;
padding-bottom: 100px;
}
.display-1 { font-size: 3.5rem; }
.blob-1 { width: 300px; height: 300px; right: -20%; }
.blob-2 { width: 300px; height: 300px; left: -20%; }
}

View File

@ -1,132 +0,0 @@
<?php
declare(strict_types=1);
require_once __DIR__ . '/db/config.php';
require_once __DIR__ . '/includes/auth.php';
requireLogin();
$user = getCurrentUser();
$companyId = $user['company_id'];
$error = '';
// Fetch clients for selection
$stmt = db()->prepare("SELECT id, name FROM clients WHERE company_id = ? AND is_active = 1 ORDER BY name ASC");
$stmt->execute([$companyId]);
$clients = $stmt->fetchAll();
// Fetch statuses for selection
$stmt = db()->prepare("SELECT id, name, is_default FROM job_statuses WHERE company_id = ? ORDER BY sort_order ASC");
$stmt->execute([$companyId]);
$statuses = $stmt->fetchAll();
// Fetch company settings
$stmt = db()->prepare("SELECT uprn_required FROM companies WHERE id = ?");
$stmt->execute([$companyId]);
$company = $stmt->fetch();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$clientId = $_POST['client_id'] ?? '';
$statusId = $_POST['status_id'] ?? '';
$uprn = $_POST['uprn'] ?? '';
$address = $_POST['address'] ?? '';
$description = $_POST['description'] ?? '';
if (empty($clientId) || empty($statusId) || empty($address)) {
$error = 'Please fill in all required fields.';
} elseif ($company['uprn_required'] && empty($uprn)) {
$error = 'UPRN is required for this company.';
} else {
try {
db()->beginTransaction();
// 1. Insert Job
$stmt = db()->prepare("
INSERT INTO jobs (company_id, client_id, status_id, uprn, address, description)
VALUES (?, ?, ?, ?, ?, ?)
");
$stmt->execute([$companyId, $clientId, $statusId, $uprn, $address, $description]);
$jobId = db()->lastInsertId();
// 2. Add Mandatory Folders
$stmt = db()->prepare("SELECT name FROM required_folders WHERE company_id = ?");
$stmt->execute([$companyId]);
$reqFolders = $stmt->fetchAll();
$folderStmt = db()->prepare("INSERT INTO job_folders (job_id, name, is_required) VALUES (?, ?, ?)");
foreach ($reqFolders as $rf) {
$folderStmt->execute([$jobId, $rf['name'], 1]);
}
// 3. Log activity
$logStmt = db()->prepare("INSERT INTO job_logs (job_id, user_id, action, details) VALUES (?, ?, ?, ?)");
$logStmt->execute([$jobId, $user['id'], 'created', 'Job created manually by user.']);
db()->commit();
header('Location: dashboard.php');
exit;
} catch (Exception $e) {
db()->rollBack();
$error = "Database error: " . $e->getMessage();
}
}
}
$pageTitle = "Create New Job";
require_once __DIR__ . '/includes/header.php';
?>
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card shadow-sm">
<div class="card-header bg-white py-3">
<h4 class="fw-bold m-0">Create New Job</h4>
</div>
<div class="card-body p-4">
<?php if ($error): ?>
<div class="alert alert-danger"><?= htmlspecialchars($error) ?></div>
<?php endif; ?>
<form method="POST">
<div class="row g-3">
<div class="col-md-6">
<label class="form-label fw-bold">Client <span class="text-danger">*</span></label>
<select name="client_id" class="form-select" required>
<option value="">Select Client...</option>
<?php foreach ($clients as $c): ?>
<option value="<?= $c['id'] ?>"><?= htmlspecialchars($c['name']) ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-md-6">
<label class="form-label fw-bold">Status <span class="text-danger">*</span></label>
<select name="status_id" class="form-select" required>
<?php foreach ($statuses as $s): ?>
<option value="<?= $s['id'] ?>" <?= $s['is_default'] ? 'selected' : '' ?>><?= htmlspecialchars($s['name']) ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-12">
<label class="form-label fw-bold">UPRN <?= $company['uprn_required'] ? '<span class="text-danger">*</span>' : '' ?></label>
<input type="text" name="uprn" class="form-control" placeholder="Unique Property Reference Number" <?= $company['uprn_required'] ? 'required' : '' ?>>
</div>
<div class="col-12">
<label class="form-label fw-bold">Property Address <span class="text-danger">*</span></label>
<textarea name="address" class="form-control" rows="2" placeholder="Full property address" required></textarea>
</div>
<div class="col-12">
<label class="form-label fw-bold">Job Description</label>
<textarea name="description" class="form-control" rows="4" placeholder="Briefly describe the repair required..."></textarea>
</div>
</div>
<div class="d-flex justify-content-between mt-5">
<a href="dashboard.php" class="btn btn-outline-secondary">Cancel</a>
<button type="submit" class="btn btn-primary px-5">Create Job</button>
</div>
</form>
</div>
</div>
</div>
</div>
<?php require_once __DIR__ . '/includes/footer.php'; ?>

View File

@ -1,82 +0,0 @@
<?php
declare(strict_types=1);
require_once __DIR__ . '/db/config.php';
require_once __DIR__ . '/includes/auth.php';
requireLogin();
$pageTitle = "Dashboard";
$user = getCurrentUser();
$companyId = $user['company_id'];
// Fetch jobs for this company
$stmt = db()->prepare("
SELECT j.*, c.name as client_name, s.name as status_name
FROM jobs j
JOIN clients c ON j.client_id = c.id
JOIN job_statuses s ON j.status_id = s.id
WHERE j.company_id = ?
ORDER BY j.created_at DESC
");
$stmt->execute([$companyId]);
$jobs = $stmt->fetchAll();
require_once __DIR__ . '/includes/header.php';
?>
<div class="d-flex justify-content-between align-items-center mb-4">
<h2 class="fw-bold m-0">Jobs Overview</h2>
<a href="create-job.php" class="btn btn-primary">
<i class="bi bi-plus-lg"></i> Create New Job
</a>
</div>
<?php if (empty($jobs)): ?>
<div class="card p-5 text-center">
<div class="mb-3">
<i class="bi bi-clipboard2-plus text-secondary display-1"></i>
</div>
<h4>No jobs found</h4>
<p class="text-secondary">Get started by creating your first repair job.</p>
<div class="mt-3">
<a href="create-job.php" class="btn btn-primary">Create First Job</a>
</div>
</div>
<?php else: ?>
<div class="card shadow-sm overflow-hidden">
<div class="table-responsive">
<table class="table table-hover align-middle mb-0">
<thead class="table-light">
<tr>
<th>Job ID</th>
<th>Client</th>
<th>Address</th>
<th>Status</th>
<th>UPRN</th>
<th>Created</th>
<th class="text-end">Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($jobs as $job): ?>
<tr>
<td>#<?= $job['id'] ?></td>
<td><?= htmlspecialchars($job['client_name']) ?></td>
<td><?= htmlspecialchars($job['address']) ?></td>
<td>
<span class="badge bg-secondary"><?= htmlspecialchars($job['status_name']) ?></span>
</td>
<td><?= htmlspecialchars($job['uprn'] ?? 'N/A') ?></td>
<td><?= date('d M Y', strtotime($job['created_at'])) ?></td>
<td class="text-end">
<a href="view-job.php?id=<?= $job['id'] ?>" class="btn btn-sm btn-outline-primary">View Details</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<?php endif; ?>
<?php require_once __DIR__ . '/includes/footer.php'; ?>

View File

@ -1,113 +0,0 @@
-- Initialize company setup (companies, statuses, folders) and core user management.
-- Designed for multi-tenant applications where each company has isolated data.
-- Companies Table: Stores information about each client company.
CREATE TABLE IF NOT EXISTS companies (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL UNIQUE,
uprn_required BOOLEAN DEFAULT FALSE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Job Statuses Table: Stores custom job statuses defined by each company.
CREATE TABLE IF NOT EXISTS job_statuses (
id INT AUTO_INCREMENT PRIMARY KEY,
company_id INT NOT NULL,
name VARCHAR(255) NOT NULL,
is_default BOOLEAN DEFAULT FALSE,
sort_order INT DEFAULT 0,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (company_id) REFERENCES companies(id) ON DELETE CASCADE,
UNIQUE KEY (company_id, name)
);
-- Required Folders Table: Stores mandatory folder structures defined by each company.
CREATE TABLE IF NOT EXISTS required_folders (
id INT AUTO_INCREMENT PRIMARY KEY,
company_id INT NOT NULL,
name VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (company_id) REFERENCES companies(id) ON DELETE CASCADE,
UNIQUE KEY (company_id, name)
);
-- Users Table: Stores user accounts. Each user belongs to a specific company.
CREATE TABLE IF NOT EXISTS users (
id INT AUTO_INCREMENT PRIMARY KEY,
company_id INT NOT NULL,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
role ENUM('admin', 'standard') DEFAULT 'standard', -- Admin can manage company settings, standard users manage jobs.
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (company_id) REFERENCES companies(id) ON DELETE CASCADE
);
-- Clients Table: Stores clients for each company. Clients can be added, edited, but not deleted.
CREATE TABLE IF NOT EXISTS clients (
id INT AUTO_INCREMENT PRIMARY KEY,
company_id INT NOT NULL,
name VARCHAR(255) NOT NULL,
contact_person VARCHAR(255) DEFAULT NULL,
email VARCHAR(255) DEFAULT NULL,
phone VARCHAR(255) DEFAULT NULL,
is_active BOOLEAN DEFAULT TRUE, -- Clients can be marked inactive instead of deleted.
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (company_id) REFERENCES companies(id) ON DELETE CASCADE,
UNIQUE KEY (company_id, name) -- Ensure client names are unique per company
);
-- Jobs Table: Core entity for the application.
CREATE TABLE IF NOT EXISTS jobs (
id INT AUTO_INCREMENT PRIMARY KEY,
company_id INT NOT NULL,
client_id INT NOT NULL,
status_id INT NOT NULL,
uprn VARCHAR(255) DEFAULT NULL, -- Unique Property Reference Number
address TEXT NOT NULL,
description TEXT,
works_approved BOOLEAN DEFAULT FALSE,
is_completed BOOLEAN DEFAULT FALSE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (company_id) REFERENCES companies(id) ON DELETE CASCADE,
FOREIGN KEY (client_id) REFERENCES clients(id),
FOREIGN KEY (status_id) REFERENCES job_statuses(id)
);
-- Job Folders Table: Mandatory and custom folders for each job.
CREATE TABLE IF NOT EXISTS job_folders (
id INT AUTO_INCREMENT PRIMARY KEY,
job_id INT NOT NULL,
name VARCHAR(255) NOT NULL,
is_required BOOLEAN DEFAULT FALSE, -- If true, it's a company-wide mandatory folder.
is_completed BOOLEAN DEFAULT FALSE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (job_id) REFERENCES jobs(id) ON DELETE CASCADE
);
-- Job Files Table: Files uploaded to job folders.
CREATE TABLE IF NOT EXISTS job_files (
id INT AUTO_INCREMENT PRIMARY KEY,
folder_id INT NOT NULL,
user_id INT NOT NULL,
filename VARCHAR(255) NOT NULL,
file_path VARCHAR(255) NOT NULL,
file_size INT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (folder_id) REFERENCES job_folders(id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(id)
);
-- Job Logs Table: Server-side logging for all job activities.
CREATE TABLE IF NOT EXISTS job_logs (
id INT AUTO_INCREMENT PRIMARY KEY,
job_id INT NOT NULL,
user_id INT NOT NULL,
action VARCHAR(255) NOT NULL, -- e.g., 'created', 'status_updated', 'file_uploaded'
details TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (job_id) REFERENCES jobs(id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(id)
);

View File

@ -1,35 +0,0 @@
<?php
declare(strict_types=1);
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
function isLoggedIn(): bool {
return isset($_SESSION['user_id']);
}
function requireLogin(): void {
if (!isLoggedIn()) {
header('Location: login.php');
exit;
}
}
function getCurrentUser(): ?array {
if (!isLoggedIn()) return null;
static $user;
if (!$user) {
$stmt = db()->prepare("SELECT u.*, c.name as company_name FROM users u JOIN companies c ON u.company_id = c.id WHERE u.id = ?");
$stmt->execute([$_SESSION['user_id']]);
$user = $stmt->fetch();
}
return $user;
}
function logout(): void {
session_destroy();
header('Location: login.php');
exit;
}

View File

@ -1,8 +0,0 @@
</div>
<footer class="container py-4 border-top text-center text-secondary small">
&copy; <?= date('Y') ?> RepairsPro Multi-Tenant Application.
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script src="assets/js/main.js?v=<?= time() ?>"></script>
</body>
</html>

View File

@ -1,40 +0,0 @@
<?php
require_once __DIR__ . '/auth.php';
$currentUser = getCurrentUser();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?= $pageTitle ?? 'RepairsPro' ?></title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css?v=<?= time() ?>">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
</head>
<body class="bg-light">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark mb-4">
<div class="container">
<a class="navbar-brand fw-bold" href="dashboard.php">RepairsPro</a>
<button class="navbar-expand-lg navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav me-auto">
<li class="nav-item"><a class="nav-link" href="dashboard.php">Dashboard</a></li>
<li class="nav-item"><a class="nav-link" href="clients.php">Clients</a></li>
<?php if ($currentUser['role'] === 'admin'): ?>
<li class="nav-item"><a class="nav-link" href="settings.php">Settings</a></li>
<?php endif; ?>
</ul>
<div class="navbar-nav ms-auto">
<span class="navbar-text me-3">
<i class="bi bi-person-circle"></i> <?= htmlspecialchars($currentUser['name']) ?> (<?= htmlspecialchars($currentUser['company_name']) ?>)
</span>
<a href="logout.php" class="btn btn-outline-light btn-sm">Logout</a>
</div>
</div>
</div>
</nav>
<div class="container pb-5">

215
index.php
View File

@ -1,83 +1,150 @@
<?php
declare(strict_types=1);
require_once __DIR__ . '/db/config.php';
require_once __DIR__ . '/includes/auth.php';
@ini_set('display_errors', '1');
@error_reporting(E_ALL);
@date_default_timezone_set('UTC');
// Check if any company exists
$stmt = db()->query("SELECT COUNT(*) FROM companies");
$companyCount = $stmt->fetchColumn();
if ($companyCount == 0) {
header('Location: setup.php');
exit;
}
if (isLoggedIn()) {
header('Location: dashboard.php');
exit;
}
$pageTitle = "RepairsPro - Multi-Tenant Management";
$phpVersion = PHP_VERSION;
$now = date('Y-m-d H:i:s');
?>
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?= $pageTitle ?></title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css?v=<?= time() ?>">
<style>
.hero-section { background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%); color: white; padding: 100px 0; }
</style>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>New Style</title>
<?php
// Read project preview data from environment
$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>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand fw-bold" href="#">RepairsPro</a>
<div class="ms-auto">
<a href="login.php" class="btn btn-primary">Sign In</a>
</div>
</div>
</nav>
<header class="hero-section text-center">
<div class="container">
<h1 class="display-3 fw-bold mb-4">Master Your Repair Workflow</h1>
<p class="lead mb-5 opacity-75">Multi-tenant isolation, custom folder structures, and immutable audit logs.</p>
<a href="login.php" class="btn btn-primary btn-lg px-5">Get Started</a>
</div>
</header>
<main class="container py-5">
<div class="row g-4 text-center mt-4">
<div class="col-md-4">
<div class="card p-4 h-100 border-0 shadow-sm">
<div class="mb-3"><i class="bi bi-shield-check display-4 text-primary"></i></div>
<h5 class="fw-bold">Data Isolation</h5>
<p class="text-secondary small">Company-specific data silos ensure security and privacy for all your records.</p>
</div>
</div>
<div class="col-md-4">
<div class="card p-4 h-100 border-0 shadow-sm">
<div class="mb-3"><i class="bi bi-folder-check display-4 text-primary"></i></div>
<h5 class="fw-bold">Mandatory Folders</h5>
<p class="text-secondary small">Automatically enforce standard folder structures for every single job.</p>
</div>
</div>
<div class="col-md-4">
<div class="card p-4 h-100 border-0 shadow-sm">
<div class="mb-3"><i class="bi bi-clock-history display-4 text-primary"></i></div>
<h5 class="fw-bold">Audit Logging</h5>
<p class="text-secondary small">Every status change and file upload is recorded for compliance and tracking.</p>
</div>
</div>
</div>
</main>
<footer class="container py-5 border-top text-center text-secondary">
<p>&copy; <?= date('Y') ?> RepairsPro Multi-Tenant Application.</p>
</footer>
<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>
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
<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>
</main>
<footer>
Page updated: <?= htmlspecialchars($now) ?> (UTC)
</footer>
</body>
</html>
</html>

View File

@ -1,80 +0,0 @@
<?php
declare(strict_types=1);
require_once __DIR__ . '/db/config.php';
require_once __DIR__ . '/includes/auth.php';
if (isLoggedIn()) {
header('Location: dashboard.php');
exit;
}
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$email = $_POST['email'] ?? '';
$password = $_POST['password'] ?? '';
if (empty($email) || empty($password)) {
$error = 'Please fill in all fields.';
} else {
$stmt = db()->prepare("SELECT * FROM users WHERE email = ?");
$stmt->execute([$email]);
$user = $stmt->fetch();
if ($user && password_verify($password, $user['password'])) {
$_SESSION['user_id'] = $user['id'];
$_SESSION['company_id'] = $user['company_id'];
$_SESSION['user_role'] = $user['role'];
header('Location: dashboard.php');
exit;
} else {
$error = 'Invalid email or password.';
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login - RepairsPro</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css?v=<?= time() ?>">
<style>
body { background-color: #f8fafc; height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 400px; padding: 2rem; border-radius: 8px; box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1); background: #fff; }
</style>
</head>
<body>
<div class="login-card">
<div class="text-center mb-4">
<h2 class="fw-bold">RepairsPro</h2>
<p class="text-secondary">Sign in to your account</p>
</div>
<?php if ($error): ?>
<div class="alert alert-danger py-2 small"><?= htmlspecialchars($error) ?></div>
<?php endif; ?>
<form method="POST">
<div class="mb-3">
<label class="form-label small fw-bold">Email address</label>
<input type="email" name="email" class="form-control" required autofocus>
</div>
<div class="mb-3">
<label class="form-label small fw-bold">Password</label>
<input type="password" name="password" class="form-control" required>
</div>
<div class="d-grid gap-2 mt-4">
<button type="submit" class="btn btn-primary">Sign In</button>
</div>
</form>
<div class="mt-4 text-center">
<p class="small text-secondary">Forgot your password? <br>Contact your company administrator.</p>
</div>
</div>
</body>
</html>

View File

@ -1,4 +0,0 @@
<?php
declare(strict_types=1);
require_once __DIR__ . '/includes/auth.php';
logout();

277
setup.php
View File

@ -1,277 +0,0 @@
<?php
declare(strict_types=1);
require_once __DIR__ . '/db/config.php';
session_start();
$error = '';
$success = '';
$step = $_GET['step'] ?? 1;
$companyId = $_SESSION['company_id'] ?? null;
// Redirect to index if setup is complete and companyId is not in session
if ($step > 1 && !$companyId) {
header('Location: index.php');
exit;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if ($step == 1) {
$companyName = $_POST['company_name'] ?? '';
$uprnRequired = isset($_POST['uprn_required']) ? 1 : 0;
$statuses = $_POST['statuses'] ?? [];
$folders = $_POST['folders'] ?? [];
$defaultStatusIndex = (int)($_POST['default_status'] ?? 0);
if (empty($companyName)) {
$error = "Company name is required.";
} elseif (empty(array_filter($statuses, 'trim'))) {
$error = "At least one job status is required.";
} elseif (empty(array_filter($folders, 'trim'))) {
$error = "At least one required folder is required.";
} else {
try {
db()->beginTransaction();
// 1. Create Company
$stmt = db()->prepare("INSERT INTO companies (name, uprn_required) VALUES (?, ?)");
$stmt->execute([$companyName, $uprnRequired]);
$companyId = db()->lastInsertId();
$_SESSION['company_id'] = $companyId; // Store company ID in session for next steps
// 2. Insert Statuses
$stmt = db()->prepare("INSERT INTO job_statuses (company_id, name, is_default, sort_order) VALUES (?, ?, ?, ?)");
foreach ($statuses as $index => $statusName) {
$statusName = trim($statusName);
if ($statusName === '') continue;
$isDefault = ($index === $defaultStatusIndex) ? 1 : 0;
$stmt->execute([$companyId, $statusName, $isDefault, $index]);
}
// 3. Insert Folders
$stmt = db()->prepare("INSERT INTO required_folders (company_id, name) VALUES (?, ?)");
foreach ($folders as $folderName) {
$folderName = trim($folderName);
if ($folderName === '') continue;
$stmt->execute([$companyId, $folderName]);
}
// 4. Create first Admin user (simplified for demo)
$adminEmail = 'admin@' . strtolower(str_replace(' ', '', $companyName)) . '.com';
$stmt = db()->prepare("INSERT INTO users (company_id, name, email, password, role) VALUES (?, ?, ?, ?, ?)");
$stmt->execute([$companyId, 'Admin User', $adminEmail, password_hash('password123', PASSWORD_DEFAULT), 'admin']);
db()->commit();
header('Location: setup.php?step=2'); // Redirect to next step
exit;
} catch (Exception $e) {
db()->rollBack();
$error = "Database error: " . $e->getMessage();
}
}
} elseif ($step == 2) {
// Step 2: Client Setup
$clientNames = $_POST['client_names'] ?? [];
$contactPeople = $_POST['contact_people'] ?? [];
$clientEmails = $_POST['client_emails'] ?? [];
$clientPhones = $_POST['client_phones'] ?? [];
if (empty(array_filter($clientNames, 'trim'))) {
$error = "At least one client is required.";
} else {
try {
db()->beginTransaction();
$stmt = db()->prepare("INSERT INTO clients (company_id, name, contact_person, email, phone) VALUES (?, ?, ?, ?, ?)");
foreach ($clientNames as $index => $clientName) {
$clientName = trim($clientName);
if ($clientName === '') continue;
$contactPerson = trim($contactPeople[$index] ?? '');
$clientEmail = trim($clientEmails[$index] ?? '');
$clientPhone = trim($clientPhones[$index] ?? '');
$stmt->execute([$companyId, $clientName, $contactPerson, $clientEmail, $clientPhone]);
}
db()->commit();
session_destroy(); // Clear session after successful setup
$success = "Company setup successfully! You can now log in.";
header('Refresh: 2; URL=index.php'); // Redirect to index
exit;
} catch (Exception $e) {
db()->rollBack();
$error = "Database error: " . $e->getMessage();
}
}
}
}
$pageTitle = "Company Onboarding";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?= $pageTitle ?> - RepairsPro</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css?v=<?= time() ?>">
<style>
.setup-container { max-width: 800px; margin: 50px auto; }
.dynamic-row { display: flex; gap: 10px; margin-bottom: 10px; align-items: center; }
.client-input-group { display: flex; gap: 10px; flex-wrap: wrap; }
</style>
</head>
<body>
<div class="container">
<div class="setup-container">
<div class="card p-4">
<h2 class="fw-bold mb-4">Company Onboarding - Step <?= $step ?></h2>
<?php if ($error): ?>
<div class="alert alert-danger"><?= htmlspecialchars($error) ?></div>
<?php endif; ?>
<?php if ($success): ?>
<div class="alert alert-success"><?= htmlspecialchars($success) ?></div>
<?php else: // Display forms if not success ?>
<?php if ($step == 1): // Step 1: Company Info, Statuses, Folders ?>
<form method="POST" id="onboardingFormStep1">
<div class="mb-4">
<label class="form-label fw-bold">Company Name</label>
<input type="text" name="company_name" class="form-control" placeholder="e.g. London Repairs Ltd" required>
</div>
<div class="mb-4">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" name="uprn_required" id="uprnCheck">
<label class="form-check-label fw-bold" for="uprnCheck">Require Job UPRN?</label>
</div>
<small class="text-secondary">If enabled, every job must have a unique UPRN.</small>
</div>
<hr>
<div class="mb-4">
<label class="form-label fw-bold">Job Statuses</label>
<p class="small text-secondary">Define the workflow stages for your jobs.</p>
<div id="status-container">
<div class="dynamic-row">
<input type="radio" name="default_status" value="0" checked title="Set as default">
<input type="text" name="statuses[]" class="form-control" value="To Be Surveyed" required>
</div>
<div class="dynamic-row">
<input type="radio" name="default_status" value="1" title="Set as default">
<input type="text" name="statuses[]" class="form-control" value="Booking Required">
<button type="button" class="btn btn-sm btn-outline-danger remove-btn">&times;</button>
</div>
</div>
<button type="button" class="btn btn-sm btn-outline-primary mt-2" onclick="addRow('status-container', 'statuses[]', true)">+ Add Status</button>
</div>
<hr>
<div class="mb-4">
<label class="form-label fw-bold">Required Folders</label>
<p class="small text-secondary">These folders will appear on every job automatically.</p>
<div id="folder-container">
<div class="dynamic-row">
<input type="text" name="folders[]" class="form-control" value="Photos" required>
</div>
<div class="dynamic-row">
<input type="text" name="folders[]" class="form-control" value="Quote">
<button type="button" class="btn btn-sm btn-outline-danger remove-btn">&times;</button>
</div>
</div>
<button type="button" class="btn btn-sm btn-outline-primary mt-2" onclick="addRow('folder-container', 'folders[]', false)">+ Add Folder</button>
</div>
<div class="d-grid gap-2 mt-5">
<button type="submit" class="btn btn-primary btn-lg">Next: Setup Clients</button>
</div>
</form>
<?php elseif ($step == 2): // Step 2: Client Setup ?>
<form method="POST" id="onboardingFormStep2">
<p class="small text-secondary">Add your initial clients. You can add more later.</p>
<div id="client-container">
<div class="dynamic-row client-input-group">
<input type="text" name="client_names[]" class="form-control flex-grow-1" placeholder="Client Name" required>
<input type="text" name="contact_people[]" class="form-control" placeholder="Contact Person">
<input type="email" name="client_emails[]" class="form-control" placeholder="Email">
<input type="text" name="client_phones[]" class="form-control" placeholder="Phone">
<button type="button" class="btn btn-sm btn-outline-danger remove-btn">&times;</button>
</div>
</div>
<button type="button" class="btn btn-sm btn-outline-primary mt-2" onclick="addClientRow()">+ Add Client</button>
<div class="d-grid gap-2 mt-5">
<button type="submit" class="btn btn-success btn-lg">Complete Onboarding</button>
</div>
</form>
<?php endif; ?>
<?php endif; // End of forms ?>
</div>
</div>
</div>
<script>
function addRow(containerId, name, hasRadio) {
const container = document.getElementById(containerId);
const count = container.children.length;
const div = document.createElement('div');
div.className = 'dynamic-row';
let html = '';
if (hasRadio) {
html += `<input type="radio" name="default_status" value="${count}">`;
}
html += `<input type="text" name="${name}" class="form-control" required>`;
html += `<button type="button" class="btn btn-sm btn-outline-danger remove-btn">&times;</button>`;
div.innerHTML = html;
container.appendChild(div);
div.querySelector('.remove-btn').onclick = function() {
div.remove();
// Re-index radios if necessary
if (hasRadio) {
Array.from(container.children).forEach((row, idx) => {
const radio = row.querySelector('input[type="radio"]');
if (radio) radio.value = idx;
});
}
};
}
function addClientRow() {
const container = document.getElementById('client-container');
const div = document.createElement('div');
div.className = 'dynamic-row client-input-group';
div.innerHTML = `
<input type="text" name="client_names[]" class="form-control flex-grow-1" placeholder="Client Name" required>
<input type="text" name="contact_people[]" class="form-control" placeholder="Contact Person">
<input type="email" name="client_emails[]" class="form-control" placeholder="Email">
<input type="text" name="client_phones[]" class="form-control" placeholder="Phone">
<button type="button" class="btn btn-sm btn-outline-danger remove-btn">&times;</button>
`;
container.appendChild(div);
div.querySelector('.remove-btn').onclick = function() { div.remove(); };
}
// Attach remove events to existing buttons (for statuses and folders initially)
document.querySelectorAll('#status-container .remove-btn, #folder-container .remove-btn').forEach(btn => {
btn.onclick = function() { btn.parentElement.remove(); };
});
// Initial client row for step 2 if no clients are pre-filled
if (document.getElementById('client-container') && document.getElementById('client-container').children.length === 0) {
// addClientRow(); // Only add if step 2 is active and no existing clients (for initial load)
}
</script>
</body>
</html>