Compare commits

...

1 Commits

Author SHA1 Message Date
Flatlogic Bot
2f8b1db200 rep 2025-10-07 18:45:08 +00:00
5 changed files with 313 additions and 142 deletions

1
assets/css/style.css Normal file
View File

@ -0,0 +1 @@
/* Custom Styles */

1
assets/js/main.js Normal file
View File

@ -0,0 +1 @@
// Custom Scripts

89
database/demo.sql Normal file
View File

@ -0,0 +1,89 @@
CREATE DATABASE IF NOT EXISTS `service_portal_db`;
USE `service_portal_db`;
CREATE TABLE IF NOT EXISTS `settings` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`company_name` varchar(255) DEFAULT 'Your Company',
`company_email` varchar(255) DEFAULT 'contact@example.com',
`company_whatsapp` varchar(255) DEFAULT '1234567890',
`upi_id` varchar(255) DEFAULT 'your-upi@ok',
`terms_conditions` text,
`footer_text` varchar(255) DEFAULT '© 2025 Your Company. All Rights Reserved.',
`smtp_host` varchar(255) DEFAULT NULL,
`smtp_port` int(11) DEFAULT NULL,
`smtp_user` varchar(255) DEFAULT NULL,
`smtp_pass` varchar(255) DEFAULT NULL,
`logo_path` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
INSERT INTO `settings` (`id`, `company_name`, `company_email`, `company_whatsapp`, `upi_id`, `terms_conditions`, `footer_text`) VALUES
(1, 'Service Portal', 'contact@serviceportal.com', '9876543210', 'upi@okaxis', '1. All services are subject to our terms and conditions.
2. Warranty is applicable only on parts replaced.
3. No warranty on software-related issues.', '© 2025 Service Portal. All Rights Reserved.');
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`email` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`role` enum('admin','technician') DEFAULT 'admin',
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
INSERT INTO `users` (`id`, `email`, `password`, `role`) VALUES
(1, 'admin@example.com', '$2y$10$g.pA/P1v2RFAzZkC.3r.A.tclHl8tXpr./3v5b2dD2a.i5.Myw0jS', 'admin'); -- password is admin123
CREATE TABLE IF NOT EXISTS `bookings` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`booking_id` varchar(10) NOT NULL,
`customer_name` varchar(255) NOT NULL,
`customer_mobile` varchar(20) NOT NULL,
`customer_email` varchar(255) DEFAULT NULL,
`device_type` varchar(100) NOT NULL,
`service_type` enum('Normal','Revisit','Warranty') NOT NULL,
`problem_details` text,
`photo_path` varchar(255) DEFAULT NULL,
`status` enum('Booked','Pending','In Progress','Waiting for Parts','On Testing','Completed','Payment','Cancelled') DEFAULT 'Booked',
`parts_cost` decimal(10,2) DEFAULT '0.00',
`labour_cost` decimal(10,2) DEFAULT '0.00',
`total_cost` decimal(10,2) GENERATED ALWAYS AS (`parts_cost` + `labour_cost`) STORED,
`invoice_pdf_path` varchar(255) DEFAULT NULL,
`proof_photos_path` text,
`assigned_to` int(11) DEFAULT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `booking_id` (`booking_id`),
KEY `assigned_to` (`assigned_to`),
CONSTRAINT `bookings_ibfk_1` FOREIGN KEY (`assigned_to`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
INSERT INTO `bookings` (`booking_id`, `customer_name`, `customer_mobile`, `customer_email`, `device_type`, `service_type`, `problem_details`, `status`) VALUES
('BK-1001', 'John Doe', '1234567890', 'john.doe@example.com', 'Laptop', 'Normal', 'Screen flickering issue.', 'Booked'),
('BK-1002', 'Jane Smith', '0987654321', 'jane.smith@example.com', 'Smartphone', 'Revisit', 'Battery draining too fast after last service.', 'In Progress');
CREATE TABLE IF NOT EXISTS `device_types` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
INSERT INTO `device_types` (`name`) VALUES
('Laptop'),
('Smartphone'),
('Tablet'),
('Desktop PC');
CREATE TABLE IF NOT EXISTS `invoices` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`booking_id` int(11) NOT NULL,
`invoice_data` text,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `booking_id` (`booking_id`),
CONSTRAINT `invoices_ibfk_1` FOREIGN KEY (`booking_id`) REFERENCES `bookings` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
INSERT INTO `invoices` (`booking_id`, `invoice_data`) VALUES
(2, 'Some sample invoice data for booking BK-1002');

212
index.php
View File

@ -1,150 +1,78 @@
<?php
declare(strict_types=1);
@ini_set('display_errors', '1');
@error_reporting(E_ALL);
@date_default_timezone_set('UTC');
$phpVersion = PHP_VERSION;
$now = date('Y-m-d H:i:s');
$project_image_url = isset($_SERVER['PROJECT_IMAGE_URL']) ? $_SERVER['PROJECT_IMAGE_URL'] : 'https://picsum.photos/1200/630';
?>
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<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>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Service Portal - Your One-Stop Repair Solution</title>
<meta name="description" content="Effortlessly book and track your device repairs. Built with Flatlogic Generator.">
<meta name="keywords" content="device repair, service portal, booking system, repair tracking, Flatlogic, php project">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:title" content="Service Portal - Your One-Stop Repair Solution">
<meta property="og:description" content="Effortlessly book and track your device repairs. Built with Flatlogic Generator.">
<meta property="og:image" content="<?php echo htmlspecialchars($project_image_url); ?>">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:title" content="Service Portal - Your One-Stop Repair Solution">
<meta property="twitter:description" content="Effortlessly book and track your device repairs. Built with Flatlogic Generator.">
<meta property="twitter:image" content="<?php echo htmlspecialchars($project_image_url); ?>">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="assets/css/style.css?v=<?php echo time(); ?>" rel="stylesheet">
<style>
body {
background-color: #F4F7F6;
font-family: 'Helvetica Neue', Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
text-align: center;
}
.welcome-container {
max-width: 600px;
padding: 40px;
background: #FFFFFF;
border-radius: 0.5rem;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}
h1 {
font-family: 'Georgia', serif;
font-weight: bold;
font-size: 3rem;
color: #333;
}
p {
font-size: 1.2rem;
color: #555;
}
.btn-primary {
background-image: linear-gradient(135deg, #4A90E2, #50E3C2);
border: none;
padding: 15px 30px;
font-size: 1.2rem;
border-radius: 50px;
transition: transform 0.2s;
}
.btn-primary:hover {
transform: scale(1.05);
}
</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>
<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 class="welcome-container">
<h1>Welcome to the Service Portal</h1>
<p class="lead my-4">Your application is almost ready. The first step is to set up your database.</p>
<a href="installer/install.php" class="btn btn-primary">Go to Installer</a>
</div>
</main>
<footer>
Page updated: <?= htmlspecialchars($now) ?> (UTC)
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
</body>
</html>
</html>

152
installer/install.php Normal file
View File

@ -0,0 +1,152 @@
<?php
$db_host = '127.0.0.1';
$db_user = 'root';
$db_pass = 'root';
$db_name = 'service_portal_db';
$sql_file = __DIR__ . '/../database/demo.sql';
$message = '';
$error = false;
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['install'])) {
try {
// 1. Connect to MySQL server
$pdo = new PDO("mysql:host=$db_host", $db_user, $db_pass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// 2. Read SQL file
$sql = file_get_contents($sql_file);
if ($sql === false) {
throw new Exception("Cannot read SQL file: $sql_file");
}
// 3. Execute SQL commands
$pdo->exec($sql);
$message = 'Installation successful! Database and tables created, and demo data imported.';
$error = false;
} catch (PDOException $e) {
$message = "Database error: " . $e->getMessage();
$error = true;
} catch (Exception $e) {
$message = "General error: " . $e->getMessage();
$error = true;
}
}
$extensions = [
'pdo_mysql' => 'PDO MySQL for database connection',
'gd' => 'GD for image processing',
'mbstring' => 'MBString for multibyte strings',
'openssl' => 'OpenSSL for security',
'json' => 'JSON for data interchange',
'fileinfo' => 'FileInfo for file type detection',
'zip' => 'Zip for archive handling',
'dom' => 'DOM for XML/HTML processing',
'ctype' => 'Ctype for character type checking',
];
$php_version = phpversion();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Service Portal Installer</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<style>
body {
background-color: #F4F7F6;
font-family: 'Helvetica Neue', Arial, sans-serif;
}
.installer-container {
max-width: 800px;
margin: 50px auto;
background: #FFFFFF;
padding: 40px;
border-radius: 0.5rem;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}
h1, h2 {
font-family: 'Georgia', serif;
color: #333;
}
.btn-primary {
background-image: linear-gradient(135deg, #4A90E2, #50E3C2);
border: none;
padding: 15px 30px;
font-size: 1.2rem;
}
.list-group-item {
display: flex;
justify-content: space-between;
align-items: center;
}
.badge-success { background-color: #50E3C2; color: white; }
.badge-danger { background-color: #E24A4A; color: white; }
</style>
</head>
<body>
<div class="installer-container">
<h1 class="text-center mb-4">Service Portal Installer</h1>
<div class="card mb-4">
<div class="card-header"><h2>1. System Requirements</h2></div>
<div class="card-body">
<ul class="list-group">
<li class="list-group-item">
PHP Version (>= 8.0)
<?php if (version_compare($php_version, '8.0.0', '>=')): ?>
<span class="badge badge-success"> (<?php echo $php_version; ?>)</span>
<?php else: ?>
<span class="badge badge-danger"> (<?php echo $php_version; ?>)</span>
<?php endif; ?>
</li>
<?php foreach ($extensions as $ext => $desc): ?>
<li class="list-group-item">
<?php echo $desc; ?> (<?php echo $ext; ?>)
<?php if (extension_loaded($ext)): ?>
<span class="badge badge-success"> Installed</span>
<?php else: ?>
<span class="badge badge-danger"> Not Installed</span>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</div>
</div>
<div class="card">
<div class="card-header"><h2>2. Database Installation</h2></div>
<div class="card-body text-center">
<p>This will create the `<?php echo $db_name; ?>` database and import the necessary tables and demo data.</p>
<p class="text-muted">Warning: This may overwrite existing data if tables with the same name exist.</p>
<form method="POST">
<button type="submit" name="install" class="btn btn-primary">Install Now</button>
</form>
</div>
</div>
</div>
<?php if ($_SERVER['REQUEST_METHOD'] === 'POST' && $message): ?>
<script>
document.addEventListener('DOMContentLoaded', function() {
Swal.fire({
title: '<?php echo $error ? "Error!" : "Success!"; ?>',
text: '<?php echo addslashes($message); ?>',
icon: '<?php echo $error ? "error" : "success"; ?>',
confirmButtonText: 'OK'
}).then(() => {
if (!<?php echo $error ? 'true' : 'false'; ?>) {
// Optional: redirect to home or admin page
// window.location.href = '/';
}
});
});
</script>
<?php endif; ?>
</body>
</html>