diff --git a/assets/css/custom.css b/assets/css/custom.css index 0d42a8a..0cd1f11 100644 --- a/assets/css/custom.css +++ b/assets/css/custom.css @@ -298,3 +298,66 @@ body { background-repeat: no-repeat; background-position: center; } + +/* + * Macro Áreas Module Styles + * -------------------------------------------------- + */ + +body { + background-color: #eeeeee; +} + +/* Titles and Text */ +.h1, .h2, .h3, .h4, .h5, .h6, h1, h2, h3, h4, h5, h6 { + color: #10403B; +} + +/* Primary Buttons */ +.btn-primary { + background-color: #005C53; + border-color: #005C53; + color: #FFFFFF; +} +.btn-primary:hover { + background-color: #00443e; + border-color: #00443e; +} +.btn-primary .fas { + color: #FFFFFF; +} + +/* Card Styles */ +.card { + border: 1px solid #005C53; +} +.card-header { + background-color: #8AA6A3; + color: #FFFFFF; +} +.card-header .m-0.font-weight-bold { + color: #FFFFFF; +} + + +/* Table Styles */ +.table thead th { + background-color: #8AA6A3; + color: #FFFFFF; + border-color: #8AA6A3; +} + +/* Badge Styles */ +.badge-status-ativo { + background-color: #8AA6A3; + color: #FFFFFF; +} +.badge-status-arquivado { + background-color: #f0f0f0; /* gray-100 */ + color: #333; /* gray-800 */ +} + +/* Action Icons */ +.table .btn .fas { + color: #4C5958; +} \ No newline at end of file diff --git a/macro_areas.php b/macro_areas.php index 00b0f97..73d701f 100644 --- a/macro_areas.php +++ b/macro_areas.php @@ -3,8 +3,54 @@ require_once 'includes/session.php'; require_once 'db/config.php'; include_once 'includes/header.php'; -// Fetch macro areas from the database +// Helper function to generate a slug +function slugify($text) { + $text = preg_replace('~[\\pL\\d]+~u', '-', $text); // Added 'u' modifier for UTF-8 + $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); + $text = preg_replace('~[^\\w]+~', '-', $text); + $text = trim($text, '-'); + $text = preg_replace('~-~', '-', $text); // Simplified to just '-' as it's already trimmed + $text = strtolower($text); + return $text ?: 'n-a'; +} + $pdo = db(); + +// Handle form submission (Create/Update) +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $id = $_POST['id'] ?? null; + $nome = $_POST['nome'] ?? ''; + $descricao = $_POST['descricao'] ?? ''; + $ativo = isset($_POST['ativo']) ? 1 : 0; + + if ($nome) { // Basic validation + if ($id) { + // Update + $stmt = $pdo->prepare('UPDATE macro_areas SET nome = ?, descricao = ?, ativo = ? WHERE id = ?'); + $stmt->execute([$nome, $descricao, $ativo, $id]); + } else { + // Create + $slug = slugify($nome); + $stmt = $pdo->prepare('INSERT INTO macro_areas (nome, descricao, slug, ativo, created_by) VALUES (?, ?, ?, ?, ?)'); + $stmt->execute([$nome, $descricao, $slug, $ativo, $_SESSION['user_email'] ?? 'system']); + } + } + // Redirect to avoid form resubmission + header("Location: macro_areas.php"); + exit; +} + +// Handle deletion +if (isset($_GET['delete'])) { + $id = $_GET['delete']; + $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); @@ -13,18 +59,22 @@ $macro_areas = $stmt->fetchAll(PDO::FETCH_ASSOC);
-

Macro Áreas

- - - - - Nova Macro Área - +

Macro Áreas

+
+ + +
-
Registros
+
Registros
@@ -34,32 +84,38 @@ $macro_areas = $stmt->fetchAll(PDO::FETCH_ASSOC); Nome Descrição Status - Ações + Ações - + - - Ativo - - Arquivado - + - + + - + Nenhuma macro área encontrada. @@ -69,10 +125,76 @@ $macro_areas = $stmt->fetchAll(PDO::FETCH_ASSOC);
-
- - + + + + + + \ No newline at end of file