From 140149344e79ff9ebdc2ed170f1daa8853dab4d0 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Thu, 4 Dec 2025 16:34:54 +0000 Subject: [PATCH] 1.0 --- assets/css/custom.css | 33 +++++ assets/js/main.js | 1 + db/setup.php | 108 ++++++++++++++++ index.php | 284 +++++++++++++++++++++--------------------- 4 files changed, 284 insertions(+), 142 deletions(-) create mode 100644 assets/css/custom.css create mode 100644 assets/js/main.js create mode 100644 db/setup.php diff --git a/assets/css/custom.css b/assets/css/custom.css new file mode 100644 index 0000000..6fa8d64 --- /dev/null +++ b/assets/css/custom.css @@ -0,0 +1,33 @@ +body { + background-color: #f8f9fa; +} + +.navbar { + box-shadow: 0 2px 4px rgba(0,0,0,.04); +} + +.card-header { + background-color: #ffffff; + border-bottom: 1px solid #dee2e6; +} + +.status-badge { + font-size: 0.8rem; + padding: 0.3em 0.6em; +} + +.action-icon { + color: #6c757d; + text-decoration: none; + margin: 0 4px; + transition: color 0.2s; +} + +.action-icon:hover { + color: #0d6efd; +} + +.action-icon.disabled { + color: #adb5bd; + pointer-events: none; +} diff --git a/assets/js/main.js b/assets/js/main.js new file mode 100644 index 0000000..a4251e0 --- /dev/null +++ b/assets/js/main.js @@ -0,0 +1 @@ +// This file can be used for custom JavaScript interactions in the future. diff --git a/db/setup.php b/db/setup.php new file mode 100644 index 0000000..71adaa6 --- /dev/null +++ b/db/setup.php @@ -0,0 +1,108 @@ +query("SELECT 1 FROM equivalence_catalog LIMIT 1"); + if ($stmt !== false && $stmt->fetch()) { + // Tables seem to exist, do nothing + return; + } + + } catch (PDOException $e) { + // Table doesn't exist, proceed with creation. This is expected on first run. + } + + try { + $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + // 1. Shipping Lines Table + $pdo->exec("CREATE TABLE IF NOT EXISTS shipping_lines ( + ShippingLineCode VARCHAR(10) PRIMARY KEY, + ShippingLineName VARCHAR(255) NOT NULL, + IsActive BOOLEAN NOT NULL DEFAULT TRUE + )"); + + // 2. Customs Container Types Table + $pdo->exec("CREATE TABLE IF NOT EXISTS customs_container_types ( + CustomsKey VARCHAR(10) PRIMARY KEY, + CustomsDescription VARCHAR(255) NOT NULL, + IsActive BOOLEAN NOT NULL DEFAULT TRUE + )"); + + // 3. N4 Container Types Table + $pdo->exec("CREATE TABLE IF NOT EXISTS n4_container_types ( + N4Key VARCHAR(10) PRIMARY KEY, + N4Description VARCHAR(255) NOT NULL, + IsActive BOOLEAN NOT NULL DEFAULT TRUE, + CustomsKeyFK VARCHAR(10), + FOREIGN KEY (CustomsKeyFK) REFERENCES customs_container_types(CustomsKey) + )"); + + // 4. Equivalence Catalog Table + $pdo->exec("CREATE TABLE IF NOT EXISTS equivalence_catalog ( + EquivalenceID INT AUTO_INCREMENT PRIMARY KEY, + ShippingLineCode VARCHAR(10), + CustomsKeyFK VARCHAR(10), + N4KeyFK VARCHAR(10), + EffectiveDate DATE NOT NULL, + IsActive BOOLEAN NOT NULL DEFAULT TRUE, + FOREIGN KEY (ShippingLineCode) REFERENCES shipping_lines(ShippingLineCode), + FOREIGN KEY (CustomsKeyFK) REFERENCES customs_container_types(CustomsKey), + FOREIGN KEY (N4KeyFK) REFERENCES n4_container_types(N4Key), + UNIQUE (ShippingLineCode, CustomsKeyFK, N4KeyFK) + )"); + + // 5. Audit Log Table + $pdo->exec("CREATE TABLE IF NOT EXISTS audit_log ( + LogID INT AUTO_INCREMENT PRIMARY KEY, + EquivalenceIDFK INT, + Timestamp DATETIME DEFAULT CURRENT_TIMESTAMP, + `User` VARCHAR(255), + Action VARCHAR(50), + OldValue TEXT, + NewValue TEXT, + FOREIGN KEY (EquivalenceIDFK) REFERENCES equivalence_catalog(EquivalenceID) ON DELETE SET NULL + )"); + + // --- MOCK DATA INSERTION --- + + // Shipping Lines + $pdo->exec("INSERT INTO shipping_lines (ShippingLineCode, ShippingLineName) VALUES + ('MSCU', 'Mediterranean Shipping Company'), + ('ONEY', 'Ocean Network Express'), + ('MAEU', 'Maersk Line')"); + + // Customs Types + $pdo->exec("INSERT INTO customs_container_types (CustomsKey, CustomsDescription) VALUES + ('20GP', '20ft General Purpose'), + ('40HC', '40ft High Cube'), + ('20RF', '20ft Reefer')"); + + // N4 Types + $pdo->exec("INSERT INTO n4_container_types (N4Key, N4Description, CustomsKeyFK) VALUES + ('GP20', 'General Purpose 20 FT', '20GP'), + ('DV20', 'Dry Van 20 FT', '20GP'), + ('HC40', 'High Cube 40 FT', '40HC'), + ('HQ40', 'High Quality 40 FT', '40HC'), + ('RF20', 'Refrigerated 20 FT', '20RF')"); + + // Equivalence Mappings + $pdo->exec("INSERT INTO equivalence_catalog (ShippingLineCode, CustomsKeyFK, N4KeyFK, EffectiveDate, IsActive) VALUES + ('MSCU', '20GP', 'GP20', '2023-01-01', TRUE), + ('MSCU', '40HC', 'HC40', '2023-01-01', TRUE), + ('ONEY', '20GP', 'DV20', '2023-05-15', TRUE), + ('ONEY', '40HC', 'HQ40', '2023-05-15', FALSE), + ('MAEU', '20RF', 'RF20', '2024-02-20', TRUE)"); + + } catch (PDOException $e) { + // In a real app, you'd log this error. + // For this setup, we can die to see the error clearly. + die("DB Setup Failed: " . $e->getMessage()); + } +} + +// Run the setup +setup_database(); diff --git a/index.php b/index.php index 7205f3d..1e9140d 100644 --- a/index.php +++ b/index.php @@ -1,150 +1,150 @@ query(" + SELECT + eq.EquivalenceID, + sl.ShippingLineName, + cc.CustomsDescription, + n4.N4Description, + eq.EffectiveDate, + eq.IsActive + FROM + equivalence_catalog eq + JOIN + shipping_lines sl ON eq.ShippingLineCode = sl.ShippingLineCode + JOIN + customs_container_types cc ON eq.CustomsKeyFK = cc.CustomsKey + JOIN + n4_container_types n4 ON eq.N4KeyFK = n4.N4Key + ORDER BY + sl.ShippingLineName, eq.EffectiveDate DESC + "); + $equivalences = $stmt->fetchAll(PDO::FETCH_ASSOC); +} catch (PDOException $e) { + // For now, just show a simple error. + die("Could not fetch data: " . $e->getMessage()); +} -$phpVersion = PHP_VERSION; -$now = date('Y-m-d H:i:s'); ?> - + - - - New Style - - - - - - - - - - - - - - - - - - - + + + Container Equivalence Catalog + + + -
-
-

Analyzing your requirements and generating your website…

-
- Loading… -
-

AI is collecting your requirements and applying the first changes.

-

This page will update automatically as the plan is implemented.

-

Runtime: PHP — UTC

-
-
- + + + +
+
+
+
+

Shipping Line Equivalence Catalog

+ +
+
+
+
+ + +
+
+
+ +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Shipping LineCustoms DescriptionN4 DescriptionEffective DateStatusActions
No equivalence records found. The database might be empty.
+ + Active + + Inactive + + + + + +
+
+
+ +
+
+ + + - + \ No newline at end of file