From 2835cd98646782dea8640e18ac42762b3d23d8fb Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Fri, 24 Oct 2025 09:53:19 +0000 Subject: [PATCH] R0 --- add_plant.php | 123 ++++++++++++ assets/css/custom.css | 10 + assets/js/main.js | 0 db/config.php | 12 ++ db/migrations/001_create_plants_table.sql | 8 + index.php | 221 +++++++++------------- 6 files changed, 238 insertions(+), 136 deletions(-) create mode 100644 add_plant.php create mode 100644 assets/css/custom.css create mode 100644 assets/js/main.js create mode 100644 db/migrations/001_create_plants_table.sql diff --git a/add_plant.php b/add_plant.php new file mode 100644 index 0000000..d35423d --- /dev/null +++ b/add_plant.php @@ -0,0 +1,123 @@ +prepare('INSERT INTO plants (name, location, capacity, commissioning_date) VALUES (?, ?, ?, ?)'); + $stmt->execute([$name, $location, $capacity, $commissioning_date]); + $success = 'Plant registered successfully!'; + } catch (PDOException $e) { + $errors[] = 'Database error: ' . $e->getMessage(); + } + } +} +?> + + + + + + Solyug Tracker - Add Plant + + + + + + + + + + + + + + +
+
+
+
+
+

Register New Solar Plant

+
+
+ +
+ +

+ +
+ + +
+

+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+
+
+
+
+ + + + + diff --git a/assets/css/custom.css b/assets/css/custom.css new file mode 100644 index 0000000..b15f7ef --- /dev/null +++ b/assets/css/custom.css @@ -0,0 +1,10 @@ +body { + background-color: #F8F9FA; +} + +.jumbotron { + padding: 4rem 2rem; + margin-bottom: 2rem; + background-color: #FFFFFF; + border-radius: .3rem; +} diff --git a/assets/js/main.js b/assets/js/main.js new file mode 100644 index 0000000..e69de29 diff --git a/db/config.php b/db/config.php index cc9229f..c070b5b 100644 --- a/db/config.php +++ b/db/config.php @@ -15,3 +15,15 @@ function db() { } return $pdo; } + +function run_migrations() { + $pdo = db(); + $migrations_dir = __DIR__ . '/migrations'; + $files = glob($migrations_dir . '/*.sql'); + foreach ($files as $file) { + $sql = file_get_contents($file); + $pdo->exec($sql); + } +} + +run_migrations(); diff --git a/db/migrations/001_create_plants_table.sql b/db/migrations/001_create_plants_table.sql new file mode 100644 index 0000000..293114b --- /dev/null +++ b/db/migrations/001_create_plants_table.sql @@ -0,0 +1,8 @@ +CREATE TABLE IF NOT EXISTS plants ( + id INT AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(255) NOT NULL, + location VARCHAR(255) NOT NULL, + capacity DECIMAL(10, 2) NOT NULL, + commissioning_date DATE NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); \ No newline at end of file diff --git a/index.php b/index.php index 7205f3d..71f8aa5 100644 --- a/index.php +++ b/index.php @@ -4,147 +4,96 @@ declare(strict_types=1); @error_reporting(E_ALL); @date_default_timezone_set('UTC'); -$phpVersion = PHP_VERSION; -$now = date('Y-m-d H:i:s'); +require_once 'db/config.php'; + +$plants = []; +try { + $pdo = db(); + $stmt = $pdo->query('SELECT * FROM plants ORDER BY created_at DESC'); + $plants = $stmt->fetchAll(); +} catch (PDOException $e) { + // If the table doesn't exist, we can ignore the error for now +} + ?> - + - - - New Style - - - - - - - - - - - - - - - - - - - + + + Solyug Tracker + + + + + + + + + + -
-
-

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

+ + +
+
+

Welcome to Solyug Tracker

+

Your central hub for monitoring and managing your solar plant portfolio.

+
+

Start by adding a new solar plant to your portfolio.

+ Add New Plant +
+ +
+

Recently Added Plants

+ +
+ No plants have been registered yet. +
+ + + + + + + + + + + + + + + + + + + + +
NameLocationCapacity (kW)Commissioning Date
+ +
-
- + + +