From ecbc40d1e6611b7e63bc7393509ab844d5959b51 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Thu, 27 Nov 2025 10:28:21 +0000 Subject: [PATCH] Auto commit: 2025-11-27T10:28:21.198Z --- assets/css/custom.css | 56 ++++ assets/js/main.js | 1 + db/config.php | 21 ++ db/migrations/001_create_employees_table.sql | 9 + index.php | 304 ++++++++++--------- 5 files changed, 249 insertions(+), 142 deletions(-) create mode 100644 assets/css/custom.css create mode 100644 assets/js/main.js create mode 100644 db/migrations/001_create_employees_table.sql diff --git a/assets/css/custom.css b/assets/css/custom.css new file mode 100644 index 0000000..098fd20 --- /dev/null +++ b/assets/css/custom.css @@ -0,0 +1,56 @@ +:root { + --bs-primary: #4F46E5; + --bs-primary-rgb: 79, 70, 229; + --bs-secondary: #10B981; + --bs-light: #F3F4F6; + --bs-dark: #111827; + --bs-font-sans-serif: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; +} + +body { + background-color: var(--bs-light); + font-family: var(--bs-font-sans-serif); + color: var(--bs-dark); + display: flex; + flex-direction: column; + min-height: 100vh; +} + +.navbar { + background-color: var(--bs-primary); +} + +.navbar-brand { + font-weight: 700; +} + +.card { + border: none; + border-radius: 0.5rem; +} + +.form-control { + border-radius: 0.375rem; +} + +.btn-primary { + background-color: var(--bs-primary); + border-color: var(--bs-primary); + border-radius: 0.375rem; + font-weight: 500; + transition: background-color 0.2s ease-in-out; +} + +.btn-primary:hover { + background-color: #4338CA; /* A slightly darker indigo */ + border-color: #4338CA; +} + +.table { + font-size: 0.9rem; +} + +.table th { + font-weight: 500; + color: #6B7280; /* Subtle Text color */ +} diff --git a/assets/js/main.js b/assets/js/main.js new file mode 100644 index 0000000..78fb68d --- /dev/null +++ b/assets/js/main.js @@ -0,0 +1 @@ +// main.js - for future interactivity diff --git a/db/config.php b/db/config.php index 4e3b824..04ecc46 100644 --- a/db/config.php +++ b/db/config.php @@ -5,6 +5,26 @@ define('DB_NAME', 'app_36360'); define('DB_USER', 'app_36360'); define('DB_PASS', '87b9c9ae-1c07-4a75-9acd-f1a9fa52ffb4'); +/** + * Runs database migrations. + * @param PDO $pdo + */ +function run_migrations(PDO $pdo) { + $pdo->exec("CREATE TABLE IF NOT EXISTS schema_migrations (version VARCHAR(255) PRIMARY KEY)"); + $appliedVersions = $pdo->query("SELECT version FROM schema_migrations")->fetchAll(PDO::FETCH_COLUMN); + + $migrationFiles = glob(__DIR__ . '/migrations/*.sql'); + foreach ($migrationFiles as $file) { + $version = basename($file); + if (!in_array($version, $appliedVersions)) { + $script = file_get_contents($file); + $pdo->exec($script); + $stmt = $pdo->prepare("INSERT INTO schema_migrations (version) VALUES (?)"); + $stmt->execute([$version]); + } + } +} + function db() { static $pdo; if (!$pdo) { @@ -12,6 +32,7 @@ function db() { PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, ]); + run_migrations($pdo); } return $pdo; } diff --git a/db/migrations/001_create_employees_table.sql b/db/migrations/001_create_employees_table.sql new file mode 100644 index 0000000..9bce76b --- /dev/null +++ b/db/migrations/001_create_employees_table.sql @@ -0,0 +1,9 @@ +CREATE TABLE IF NOT EXISTS employees ( + id INT AUTO_INCREMENT PRIMARY KEY, + first_name VARCHAR(100) NOT NULL, + last_name VARCHAR(100) NOT NULL, + email VARCHAR(100) UNIQUE NOT NULL, + designation VARCHAR(100), + base_salary DECIMAL(10, 2) NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); diff --git a/index.php b/index.php index 7205f3d..59dd84d 100644 --- a/index.php +++ b/index.php @@ -1,150 +1,170 @@ prepare("INSERT INTO employees (first_name, last_name, email, designation, base_salary) VALUES (?, ?, ?, ?, ?)"); + $stmt->execute([$first_name, $last_name, $email, $designation, $base_salary]); + $success_message = "Employee ''' . htmlspecialchars($first_name . ' ' . $last_name) . ''' added successfully!"; + } catch (PDOException $e) { + if ($e->errorInfo[1] == 1062) { // Duplicate entry + $errors[] = "An employee with this email already exists."; + } else { + $errors[] = "Database error: " . $e->getMessage(); + } + } + } +} + +// Fetch all employees +$stmt = $pdo->query("SELECT id, first_name, last_name, email, designation, base_salary FROM employees ORDER BY created_at DESC"); +$employees = $stmt->fetchAll(); + +$project_name = htmlspecialchars($_SERVER['PROJECT_NAME'] ?? 'SalaryBook'); +$project_description = htmlspecialchars($_SERVER['PROJECT_DESCRIPTION'] ?? 'Smart Payroll Management System'); ?> - + - - - New Style - - - - - - - - - - - - - - - - - - - + + + <?= $project_name ?> - Employee Management + + + + + + + + -
-
-

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

-
-
- + + + +
+ + + + + + + + +
+
+
+
+

Add New Employee

+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+
+
+ +
+
+
+

Current Employees

+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
NameEmailDesignationSalary
No employees found. Add one to get started!
$
+
+
+
+
+
+
+ + + + + - + \ No newline at end of file