From 7fc94f241ba42dc666e65bdfaf184ff18190ab31 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Mon, 1 Dec 2025 07:41:47 +0000 Subject: [PATCH] Scaffolding --- assets/css/eventix.css | 25 ++++ assets/js/main.js | 2 + config.php | 23 ++++ db/config.php | 43 ++++--- db/migrate.php | 20 ++++ db/migrations/001_initial_schema.sql | 76 ++++++++++++ includes/footer.php | 5 + includes/header.php | 12 ++ includes/layout.php | 0 index.php | 167 ++++----------------------- qr_scan.php | 0 rsvp.php | 0 wati_webhook.php | 0 13 files changed, 212 insertions(+), 161 deletions(-) create mode 100644 assets/css/eventix.css create mode 100644 assets/js/main.js create mode 100644 config.php create mode 100644 db/migrate.php create mode 100644 db/migrations/001_initial_schema.sql create mode 100644 includes/footer.php create mode 100644 includes/header.php create mode 100644 includes/layout.php create mode 100644 qr_scan.php create mode 100644 rsvp.php create mode 100644 wati_webhook.php diff --git a/assets/css/eventix.css b/assets/css/eventix.css new file mode 100644 index 0000000..b266a35 --- /dev/null +++ b/assets/css/eventix.css @@ -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; +} diff --git a/assets/js/main.js b/assets/js/main.js new file mode 100644 index 0000000..81243ed --- /dev/null +++ b/assets/js/main.js @@ -0,0 +1,2 @@ +// Eventix main javascript file +console.log("Eventix JS loaded."); diff --git a/config.php b/config.php new file mode 100644 index 0000000..ee78f98 --- /dev/null +++ b/config.php @@ -0,0 +1,23 @@ + 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()); + } +} \ No newline at end of file diff --git a/db/migrate.php b/db/migrate.php new file mode 100644 index 0000000..db860bb --- /dev/null +++ b/db/migrate.php @@ -0,0 +1,20 @@ +Connected to database successfully.

"; + + $sqlFile = __DIR__ . '/migrations/001_initial_schema.sql'; + if (!file_exists($sqlFile)) { + die("

Migration file not found: $sqlFile

"); + } + + $sql = file_get_contents($sqlFile); + $pdo->exec($sql); + + echo "

Database migration completed successfully!

"; + +} catch (PDOException $e) { + die("

Database operation failed: " . $e->getMessage() . "

"); +} diff --git a/db/migrations/001_initial_schema.sql b/db/migrations/001_initial_schema.sql new file mode 100644 index 0000000..7339500 --- /dev/null +++ b/db/migrations/001_initial_schema.sql @@ -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; diff --git a/includes/footer.php b/includes/footer.php new file mode 100644 index 0000000..e907527 --- /dev/null +++ b/includes/footer.php @@ -0,0 +1,5 @@ + + + + + diff --git a/includes/header.php b/includes/header.php new file mode 100644 index 0000000..d480673 --- /dev/null +++ b/includes/header.php @@ -0,0 +1,12 @@ + + + + + + + <?php echo isset($page_title) ? htmlspecialchars($page_title) . ' - Eventix' : 'Eventix'; ?> + + + + +
diff --git a/includes/layout.php b/includes/layout.php new file mode 100644 index 0000000..e69de29 diff --git a/index.php b/index.php index 7205f3d..7f425a5 100644 --- a/index.php +++ b/index.php @@ -1,150 +1,25 @@ -$phpVersion = PHP_VERSION; -$now = date('Y-m-d H:i:s'); -?> - - - - - - New Style - - - - - - - - - - - - - - - - - - - - - -
-
-

Analyzing your requirements and generating your website…

-
- Loading… + + +
+
+
+

Welcome to Eventix

+

The application scaffolding is complete. You can now run the database migration to set up the required tables.

+

This page will become the main admin dashboard for managing events and guests.

+ Run Database Migration
-

AI is collecting your requirements and applying the first changes.

-

This page will update automatically as the plan is implemented.

-

Runtime: PHP — UTC

-
-
- Page updated: (UTC) -
- - +
+ + \ No newline at end of file diff --git a/qr_scan.php b/qr_scan.php new file mode 100644 index 0000000..e69de29 diff --git a/rsvp.php b/rsvp.php new file mode 100644 index 0000000..e69de29 diff --git a/wati_webhook.php b/wati_webhook.php new file mode 100644 index 0000000..e69de29