diff --git a/add_installation.php b/add_installation.php index f22f38b..25f3c34 100644 --- a/add_installation.php +++ b/add_installation.php @@ -7,25 +7,21 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $address = trim($_POST['address'] ?? ''); $technician_name = trim($_POST['technician_name'] ?? ''); $observations = trim($_POST['observations'] ?? ''); + $status = trim($_POST['status'] ?? 'ativo'); $voltage = trim($_POST['voltage'] ?? null); $phase_neutral_ground = trim($_POST['phase_neutral_ground'] ?? null); $breaker_output = trim($_POST['breaker_output'] ?? null); - if (empty($client_name) || empty($address) || empty($technician_name)) { - $_SESSION['message'] = 'Por favor, preencha todos os campos obrigatórios.'; - $_SESSION['message_type'] = 'danger'; - header('Location: index.php'); - exit; - } + // Validation removed to allow incomplete forms $pdo = db(); try { $pdo->beginTransaction(); $stmt = $pdo->prepare( - "INSERT INTO installations (client_name, address, technician_name, observations, voltage, phase_neutral_ground, breaker_output) VALUES (?, ?, ?, ?, ?, ?, ?)" + "INSERT INTO installations (client_name, address, technician_name, observations, status, voltage, phase_neutral_ground, breaker_output) VALUES (?, ?, ?, ?, ?, ?, ?, ?)" ); - $stmt->execute([$client_name, $address, $technician_name, $observations, $voltage, $phase_neutral_ground, $breaker_output]); + $stmt->execute([$client_name, $address, $technician_name, $observations, $status, $voltage, $phase_neutral_ground, $breaker_output]); $installation_id = $pdo->lastInsertId(); // Handle multiple file uploads @@ -75,4 +71,4 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { } header('Location: index.php'); -exit; \ No newline at end of file +exit; diff --git a/db/migrations/005_add_status_to_installations.sql b/db/migrations/005_add_status_to_installations.sql new file mode 100644 index 0000000..4a281f3 --- /dev/null +++ b/db/migrations/005_add_status_to_installations.sql @@ -0,0 +1 @@ +ALTER TABLE installations ADD COLUMN status VARCHAR(50) NOT NULL DEFAULT 'ativo' COMMENT 'Status da instalação: ativo, em manutenção'; \ No newline at end of file diff --git a/index.php b/index.php index fd81fa7..6a92089 100644 --- a/index.php +++ b/index.php @@ -173,9 +173,7 @@ try { Cliente Endereço Técnico - Tensão - Fase/Neutro - Disjuntor + Status Data Ações @@ -183,7 +181,7 @@ try { - Nenhuma instalação encontrada. + Nenhuma instalação encontrada. @@ -191,6 +189,8 @@ try { $img_stmt = $pdo->prepare("SELECT image_path FROM installation_images WHERE installation_id = ? ORDER BY id ASC LIMIT 1"); $img_stmt->execute([$inst['id']]); $first_image = $img_stmt->fetchColumn(); + + $status_badge_class = $inst['status'] == 'ativo' ? 'bg-success' : 'bg-warning'; ?> @@ -202,16 +202,26 @@ try { N/A - - - - - - + + + + - - +
+
+ + + +
+
+ + + +
+ + +
@@ -234,37 +244,48 @@ try {