Scaffolding

This commit is contained in:
Flatlogic Bot 2025-12-01 07:41:47 +00:00
parent 473407fa53
commit 7fc94f241b
13 changed files with 212 additions and 161 deletions

25
assets/css/eventix.css Normal file
View File

@ -0,0 +1,25 @@
/*
Palette:
- Beige: #F5F5DC
- Black: #1a1a1a
- Accent: #D2B48C (Tan)
*/
body {
background-color: #F5F5DC; /* Beige */
color: #1a1a1a;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.navbar {
background-color: #1a1a1a !important; /* Important to override bootstrap */
}
.btn-primary {
background-color: #D2B48C;
border-color: #D2B48C;
}
.btn-primary:hover {
background-color: #C1A37E;
border-color: #C1A37E;
}

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

@ -0,0 +1,2 @@
// Eventix main javascript file
console.log("Eventix JS loaded.");

23
config.php Normal file
View File

@ -0,0 +1,23 @@
<?php
// Main application configuration
// Show errors for debugging, turn off in production
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
// Timezone
date_default_timezone_set('Asia/Muscat');
// Base URL - autodetect
define('BASE_URL', (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://" . $_SERVER['HTTP_HOST']);
// WATI API Configuration - REQUIRED
define('WATI_API_ENDPOINT', getenv('WATI_API_ENDPOINT') ?: 'https://api.wati.io');
define('WATI_ACCESS_TOKEN', getenv('WATI_ACCESS_TOKEN') ?: 'YOUR_WATI_ACCESS_TOKEN');
// Webhook validation token
define('WATI_WEBHOOK_TOKEN', getenv('WATI_WEBHOOK_TOKEN') ?: 'YOUR_WATI_WEBHOOK_SECRET');
// Database connection
require_once __DIR__ . '/db/config.php';

View File

@ -1,17 +1,30 @@
<?php
// Generated by setup_mariadb_project.sh — edit as needed.
define('DB_HOST', '127.0.0.1');
define('DB_NAME', 'app_36526');
define('DB_USER', 'app_36526');
define('DB_PASS', '43839e03-6faf-418a-9e7f-98f920f5f78d');
// Database configuration
function db(): PDO {
static $pdo = null;
if ($pdo !== null) {
return $pdo;
}
function db() {
static $pdo;
if (!$pdo) {
$pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4', DB_USER, DB_PASS, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
]);
}
return $pdo;
}
$host = getenv('DB_HOST') ?: '127.0.0.1';
$port = getenv('DB_PORT') ?: '3306';
$dbname = getenv('DB_NAME') ?: 'flatlogic';
$user = getenv('DB_USER') ?: 'flatlogic';
$pass = getenv('DB_PASS') ?: 'flatlogic';
$charset = 'utf8mb4';
$dsn = "mysql:host=$host;port=$port;dbname=$dbname;charset=$charset";
$options = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
try {
$pdo = new PDO($dsn, $user, $pass, $options);
return $pdo;
} catch (PDOException $e) {
// In a real app, you'd log this error and show a generic message
throw new PDOException($e->getMessage(), (int)$e->getCode());
}
}

20
db/migrate.php Normal file
View File

@ -0,0 +1,20 @@
<?php
require_once __DIR__ . '/../config.php';
try {
$pdo = db();
echo "<p>Connected to database successfully.</p>";
$sqlFile = __DIR__ . '/migrations/001_initial_schema.sql';
if (!file_exists($sqlFile)) {
die("<p>Migration file not found: $sqlFile</p>");
}
$sql = file_get_contents($sqlFile);
$pdo->exec($sql);
echo "<p>Database migration completed successfully!</p>";
} catch (PDOException $e) {
die("<p>Database operation failed: " . $e->getMessage() . "</p>");
}

View File

@ -0,0 +1,76 @@
CREATE TABLE IF NOT EXISTS `events` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`code` VARCHAR(255) UNIQUE,
`name_en` VARCHAR(255) NOT NULL,
`name_ar` VARCHAR(255) NOT NULL,
`date_time` DATETIME NOT NULL,
`venue_en` VARCHAR(255) NOT NULL,
`venue_ar` VARCHAR(255) NOT NULL,
`maps_url` VARCHAR(2048),
`default_language` ENUM('Arabic', 'English') NOT NULL DEFAULT 'Arabic',
`inviter_wa_number` VARCHAR(20),
`status` ENUM('Draft', 'Active', 'Closed') NOT NULL DEFAULT 'Draft',
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS `guests` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`event_id` INT NOT NULL,
`code` VARCHAR(255),
`name_en` VARCHAR(255),
`name_ar` VARCHAR(255),
`country_code` VARCHAR(10),
`phone` VARCHAR(20) NOT NULL,
`language` ENUM('Arabic', 'English') NOT NULL DEFAULT 'Arabic',
`rsvp` ENUM('No Reply', 'Attending', 'Not Attending') NOT NULL DEFAULT 'No Reply',
`rsvp_source` VARCHAR(50),
`rsvp_at` DATETIME NULL,
`qr_token` VARCHAR(255) UNIQUE,
`rsvp_token` VARCHAR(255) UNIQUE,
`scanned` TINYINT(1) DEFAULT 0,
`scanned_at` DATETIME NULL,
`wati_broadcast_id` VARCHAR(64) NULL,
`wati_message_id` VARCHAR(64) NULL,
`wati_reply_wa_id` VARCHAR(64) NULL,
`notes` TEXT NULL,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (`event_id`) REFERENCES `events`(`id`) ON DELETE CASCADE,
UNIQUE (`event_id`, `code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS `users` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`name` VARCHAR(255) NOT NULL,
`email` VARCHAR(255) UNIQUE NOT NULL,
`password_hash` VARCHAR(255) NOT NULL,
`role` ENUM('admin', 'inviter', 'scanner') NOT NULL DEFAULT 'admin',
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS `action_log` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`guest_id` INT NULL,
`event_id` INT NULL,
`user_id` INT NULL,
`action_type` VARCHAR(100) NOT NULL,
`old_value` TEXT,
`new_value` TEXT,
`source` VARCHAR(50),
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (`guest_id`) REFERENCES `guests`(`id`) ON DELETE SET NULL,
FOREIGN KEY (`event_id`) REFERENCES `events`(`id`) ON DELETE SET NULL,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS `wati_reply_sessions` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`original_local_message_id` VARCHAR(64) NOT NULL,
`reply_whatsapp_message_id` VARCHAR(64) UNIQUE NOT NULL,
`reply_timestamp` DATETIME NOT NULL,
`raw` TEXT,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
INDEX (`original_local_message_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

5
includes/footer.php Normal file
View File

@ -0,0 +1,5 @@
</div> <!-- /container-fluid -->
<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>

12
includes/header.php Normal file
View File

@ -0,0 +1,12 @@
<?php require_once __DIR__ . '/../config.php'; ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo isset($page_title) ? htmlspecialchars($page_title) . ' - Eventix' : 'Eventix'; ?></title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="/assets/css/eventix.css?v=<?php echo time(); ?>">
</head>
<body>
<div class="container-fluid px-0">

0
includes/layout.php Normal file
View File

167
index.php
View File

@ -1,150 +1,25 @@
<?php
declare(strict_types=1);
@ini_set('display_errors', '1');
@error_reporting(E_ALL);
@date_default_timezone_set('UTC');
$page_title = 'Admin Dashboard';
include __DIR__ . '/includes/header.php';
?>
$phpVersion = PHP_VERSION;
$now = date('Y-m-d H:i:s');
?>
<!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>
</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>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark mb-4">
<div class="container">
<a class="navbar-brand" href="/">Eventix Dashboard</a>
</div>
</nav>
<main class="container">
<div class="p-5 mb-4 bg-light rounded-3">
<div class="container-fluid py-5">
<h1 class="display-5 fw-bold">Welcome to Eventix</h1>
<p class="col-md-8 fs-4">The application scaffolding is complete. You can now run the database migration to set up the required tables.</p>
<p>This page will become the main admin dashboard for managing events and guests.</p>
<a href="/db/migrate.php" class="btn btn-primary btn-lg" target="_blank">Run Database Migration</a>
</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>
</main>
<?php
include __DIR__ . '/includes/footer.php';
?>

0
qr_scan.php Normal file
View File

0
rsvp.php Normal file
View File

0
wati_webhook.php Normal file
View File