From 5f577e0d7fb34f7414d98b47f418a39b37366705 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Wed, 29 Oct 2025 16:09:14 +0000 Subject: [PATCH] versao 10 --- macro_areas.php | 145 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 100 insertions(+), 45 deletions(-) diff --git a/macro_areas.php b/macro_areas.php index dd94044..70a5c57 100644 --- a/macro_areas.php +++ b/macro_areas.php @@ -5,20 +5,14 @@ include_once 'includes/header.php'; // Helper function to generate a slug from a string function generateSlug($string) { - // Normalize to ASCII $string = iconv('UTF-8', 'ASCII//TRANSLIT', $string); - // Convert to lowercase $string = strtolower($string); - // Remove characters that are not letters, numbers, or hyphens $string = preg_replace('/[^a-z0-9_\-]+/', '-', $string); - // Remove duplicate hyphens $string = preg_replace('/-+/', '-', $string); - // Trim hyphens from the beginning and end $string = trim($string, '-'); return $string; } - $pdo = db(); $error = null; @@ -30,26 +24,22 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $ativo = isset($_POST['ativo']) ? 1 : 0; $slug = generateSlug($nome); - // Basic validation if (empty($nome)) { $error = "O campo Nome é obrigatório."; } else { - // Check for duplicates $stmt = $pdo->prepare('SELECT id FROM macro_areas WHERE (nome = ? OR slug = ?) AND id <> ?'); $stmt->execute([$nome, $slug, $id ?: 0]); if ($stmt->fetch()) { $error = "Já existe uma Macro Área com este nome."; } else { if ($id) { - // Update $stmt = $pdo->prepare('UPDATE macro_areas SET nome = ?, slug = ?, descricao = ?, ativo = ? WHERE id = ?'); $stmt->execute([$nome, $slug, $descricao, $ativo, $id]); } else { - // Create $stmt = $pdo->prepare('INSERT INTO macro_areas (nome, slug, descricao, ativo, user_id) VALUES (?, ?, ?, ?, ?)'); $stmt->execute([$nome, $slug, $descricao, $ativo, $_SESSION['user_id'] ?? 1]); + $_SESSION['show_new_modal'] = true; } - // Redirect to avoid form resubmission header("Location: macro_areas.php"); exit; } @@ -59,31 +49,27 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { // Handle deletion if (isset($_GET['delete'])) { $id = $_GET['delete']; - // It's a good practice to check for dependencies before deleting $stmt = $pdo->prepare('DELETE FROM macro_areas WHERE id = ?'); $stmt->execute([$id]); header("Location: macro_areas.php"); exit; } - -// Fetch macro areas from the database $stmt = $pdo->query('SELECT * FROM macro_areas ORDER BY nome ASC'); $macro_areas = $stmt->fetchAll(PDO::FETCH_ASSOC); ?>
-

Macro Áreas

@@ -97,8 +83,14 @@ $macro_areas = $stmt->fetchAll(PDO::FETCH_ASSOC);
-
-
Registros
+
+
+ Lista de Macro Áreas +
+
+ + +
@@ -111,7 +103,7 @@ $macro_areas = $stmt->fetchAll(PDO::FETCH_ASSOC); Ações - + fetchAll(PDO::FETCH_ASSOC); - - - + + @@ -187,22 +179,37 @@ $macro_areas = $stmt->fetchAll(PDO::FETCH_ASSOC); +#searchInput { + border-left: 0; +} +.btn-sm i[data-lucide] { + width: 16px; + height: 16px; +} + \ No newline at end of file