From 5e6f0c0b7aefbf9cc4861af312fd6a63ebe251f4 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Fri, 3 Oct 2025 12:46:21 +0000 Subject: [PATCH] Inicial --- add_client.php | 33 ++++++++ assets/css/custom.css | 36 ++++++++ assets/js/main.js | 15 ++++ clients.php | 139 +++++++++++++++++++++++++++++++ db/config.php | 55 +++++++++---- index.php | 187 ++++++++++-------------------------------- 6 files changed, 307 insertions(+), 158 deletions(-) create mode 100644 add_client.php create mode 100644 assets/css/custom.css create mode 100644 assets/js/main.js create mode 100644 clients.php diff --git a/add_client.php b/add_client.php new file mode 100644 index 0000000..45d6362 --- /dev/null +++ b/add_client.php @@ -0,0 +1,33 @@ +prepare($sql); + $stmt->execute([$name, $company_name, $email, $phone, $status, $color, $notes]); + + header('Location: clients.php?success=client_added'); + exit; + } catch (PDOException $e) { + // In a real app, log this error. + header('Location: clients.php?error=db_error'); + exit; + } +} +?> \ No newline at end of file diff --git a/assets/css/custom.css b/assets/css/custom.css new file mode 100644 index 0000000..5fb2242 --- /dev/null +++ b/assets/css/custom.css @@ -0,0 +1,36 @@ +body { + background-color: #ecf0f1; + color: #2c3e50; + font-family: 'Helvetica Neue', Arial, sans-serif; +} + +h1, h2, h3, h4, h5, h6 { + font-family: 'Georgia', serif; +} + +.navbar { + box-shadow: 0 2px 4px rgba(0,0,0,.1); +} + +.card { + border-radius: 8px; + border: none; + box-shadow: 0 4px 8px rgba(0,0,0,.05); +} + +.btn { + border-radius: 5px; +} + +.form-control, .form-select { + border-radius: 5px; +} + +.modal-content { + border-radius: 8px; +} + +.badge { + padding: 0.4em 0.6em; + font-size: 0.9em; +} diff --git a/assets/js/main.js b/assets/js/main.js new file mode 100644 index 0000000..285dc94 --- /dev/null +++ b/assets/js/main.js @@ -0,0 +1,15 @@ +// In the future, we can add interactivity here, for example, form validation or dynamic table updates. + +document.addEventListener('DOMContentLoaded', function () { + // Example: Client-side validation for the add client form + const addClientForm = document.getElementById('addClientForm'); + if (addClientForm) { + addClientForm.addEventListener('submit', function (event) { + const nameInput = document.getElementById('name'); + if (nameInput.value.trim() === '') { + alert('Client name is required.'); + event.preventDefault(); // Stop form submission + } + }); + } +}); diff --git a/clients.php b/clients.php new file mode 100644 index 0000000..307c45c --- /dev/null +++ b/clients.php @@ -0,0 +1,139 @@ + + + + + + Lovable - Clients + + + + + + + + +
+
+

Clients

+ +
+ +
+
+
+ + + + + + + + + + + + + query("SELECT * FROM clients ORDER BY created_at DESC"); + while ($row = $stmt->fetch()) { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + ?> + +
NameCompanyEmailPhoneStatusActions
  " . htmlspecialchars($row['name']) . "" . htmlspecialchars($row['company_name']) . "" . htmlspecialchars($row['email']) . "" . htmlspecialchars($row['phone']) . "" . htmlspecialchars($row['status']) . ""; + echo ""; + echo ""; + echo "
+
+
+
+
+ + + + + + + + + \ No newline at end of file diff --git a/db/config.php b/db/config.php index 89075af..e2f04da 100644 --- a/db/config.php +++ b/db/config.php @@ -1,17 +1,44 @@ PDO::ERRMODE_EXCEPTION, - PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, - ]); - } - return $pdo; + $dsn = "mysql:host=$host;dbname=$db;charset=$charset"; + $options = [ + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, + PDO::ATTR_EMULATE_PREPARES => false, + ]; + try { + return new PDO($dsn, $user, $pass, $options); + } catch (\PDOException $e) { + throw new \PDOException($e->getMessage(), (int)$e->getCode()); + } } + +try { + $pdo = db_connect(); + $pdo->exec("CREATE DATABASE IF NOT EXISTS lovable"); + $pdo->exec("USE lovable"); + $pdo->exec(" + CREATE TABLE IF NOT EXISTS clients ( + id INT AUTO_INCREMENT PRIMARY KEY, + user_id INT NOT NULL DEFAULT 1, + name VARCHAR(255) NOT NULL, + company_name VARCHAR(255), + email VARCHAR(255), + phone VARCHAR(50), + status ENUM('Active', 'Inactive') DEFAULT 'Active', + color VARCHAR(7) DEFAULT '#3498db', + notes TEXT, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP + ) + "); +} catch (\PDOException $e) { + // In a real app, log this error. For now, we'll just die. + die("DB setup failed: " . $e->getMessage()); +} +?> \ No newline at end of file diff --git a/index.php b/index.php index 7205f3d..8d5f0fc 100644 --- a/index.php +++ b/index.php @@ -1,150 +1,49 @@ - - + - - - New Style - - - - - - - - - - - - - - - - - - - + + + Controle de atividades + + + + + + + + + -
-
-

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 Lovable

+

Your new tool for managing client activities.

+ Go to Clients +
+
+ + + - + \ No newline at end of file