Inventário de Equipamentos
+ +| Nome | +Categoria | +Nº de Série | +Status | +Ações | +
|---|
diff --git a/api/equipamento_handler.php b/api/equipamento_handler.php new file mode 100644 index 0000000..ce5c19c --- /dev/null +++ b/api/equipamento_handler.php @@ -0,0 +1,38 @@ + false, 'message' => 'Invalid request']; +$pdoconn = db(); +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $data = json_decode(file_get_contents('php://input'), true); + + if (empty($data['nome']) || empty($data['status'])) { + $response['message'] = 'Nome and status are required.'; + } else { + try { + $sql = "INSERT INTO equipamentos (nome, categoria, numero_serie, status) VALUES (:nome, :categoria, :numero_serie, :status)"; + $stmt = $pdoconn->prepare($sql); + $stmt->execute([ + ':nome' => $data['nome'], + ':categoria' => $data['categoria'] ?? null, + ':numero_serie' => $data['numero_serie'] ?? null, + ':status' => $data['status'] + ]); + $response = ['success' => true, 'message' => 'Equipamento adicionado com sucesso!']; + } catch (PDOException $e) { + $response['message'] = 'Database error: ' . $e->getMessage(); + } + } +} elseif ($_SERVER['REQUEST_METHOD'] === 'GET') { + try { + $stmt = $pdoconn->query("SELECT id, nome, categoria, numero_serie, status FROM equipamentos ORDER BY created_at DESC"); + $equipamentos = $stmt->fetchAll(); + $response = ['success' => true, 'data' => $equipamentos]; + } catch (PDOException $e) { + $response['message'] = 'Database error: ' . $e->getMessage(); + } +} + +echo json_encode($response); +?> \ No newline at end of file diff --git a/assets/css/custom.css b/assets/css/custom.css new file mode 100644 index 0000000..4d42fc8 --- /dev/null +++ b/assets/css/custom.css @@ -0,0 +1,65 @@ +body { + background-color: #F1FAEE; /* Off-white */ + font-family: 'Inter', sans-serif; + color: #1D3557; /* Dark blue text for contrast */ +} + +.toast-container { + position: fixed; + top: 1rem; + right: 1rem; + z-index: 1055; +} + +.navbar { + box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075); + background-color: #ffffff; +} + +.hero { + background: linear-gradient(45deg, #E63946, #D62828); /* Vibrant Red Gradient */ + color: white; + padding: 6rem 0; + text-align: center; +} + +.hero h1 { + font-weight: 700; + font-size: 3.5rem; +} + +.hero p { + font-size: 1.25rem; + margin-bottom: 2rem; +} + +/* Button override */ +.btn-primary { + background-color: #E63946; + border-color: #E63946; +} + +.btn-primary:hover { + background-color: #D62828; + border-color: #D62828; +} + +/* Table header */ +.table > thead { + background-color: #E63946; + color: #ffffff; +} + +.table > thead th { + color: #ffffff; +} + +/* Modal Header */ +.modal-header { + background-color: #E63946; + color: #ffffff; +} + +.modal-header .btn-close { + filter: invert(1) grayscale(100%) brightness(200%); +} \ No newline at end of file diff --git a/assets/js/main.js b/assets/js/main.js new file mode 100644 index 0000000..41b04e9 --- /dev/null +++ b/assets/js/main.js @@ -0,0 +1,107 @@ +document.addEventListener('DOMContentLoaded', function () { + const addEquipmentForm = document.getElementById('addEquipmentForm'); + const addEquipmentModal = new bootstrap.Modal(document.getElementById('addEquipmentModal')); + + if (addEquipmentForm) { + addEquipmentForm.addEventListener('submit', function (e) { + e.preventDefault(); + + const formData = new FormData(addEquipmentForm); + const data = Object.fromEntries(formData.entries()); + + fetch('/api/equipamento_handler.php', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify(data), + }) + .then(response => response.json()) + .then(result => { + showToast(result.message, result.success ? 'success' : 'danger'); + if (result.success) { + addEquipmentModal.hide(); + addEquipmentForm.reset(); + loadEquipment(); + } + }) + .catch(error => { + showToast('An error occurred.', 'danger'); + console.error('Error:', error); + }); + }); + } + + if (document.getElementById('equipmentTableBody')) { + loadEquipment(); + } +}); + +function loadEquipment() { + const tableBody = document.getElementById('equipmentTableBody'); + if (!tableBody) return; + + fetch('/api/equipamento_handler.php') + .then(response => response.json()) + .then(result => { + if (result.success) { + tableBody.innerHTML = ''; + if (result.data.length === 0) { + tableBody.innerHTML = '
| Nome | +Categoria | +Nº de Série | +Status | +Ações | +
|---|
= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.
-This page will update automatically as the plan is implemented.
-Runtime: PHP = htmlspecialchars($phpVersion) ?> — UTC = htmlspecialchars($now) ?>
Controle seu inventário, gerencie contratos e otimize suas operações com Lox.
+ Acessar o Painel +Adicione e gerencie todos os seus equipamentos em um só lugar.
+Crie cotações e converta-as em contratos de locação com facilidade.
+Acompanhe a performance do seu negócio com relatórios detalhados.
+