Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec8571e6d6 | ||
|
|
779bfbbff5 | ||
|
|
72e5e3b59c | ||
|
|
716bb2a115 | ||
|
|
369b14c872 | ||
|
|
ce24996ce4 | ||
|
|
2968f9881d | ||
|
|
21e017feae | ||
|
|
5cd527302b | ||
|
|
74e6e52559 | ||
|
|
0e6b109372 | ||
|
|
d7824332a6 | ||
|
|
8be2551b13 |
174
add_installation.php
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once __DIR__ . '/db/config.php';
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
$client_name = trim($_POST['client_name'] ?? '');
|
||||||
|
$address = trim($_POST['address'] ?? '');
|
||||||
|
$technician_name = trim($_POST['technician_name'] ?? '');
|
||||||
|
$status = trim($_POST['status'] ?? 'ativo');
|
||||||
|
$installation_date = !empty($_POST['installation_date']) ? trim($_POST['installation_date']) : null;
|
||||||
|
|
||||||
|
$pdo = db();
|
||||||
|
try {
|
||||||
|
$pdo->beginTransaction();
|
||||||
|
|
||||||
|
$stmt = $pdo->prepare(
|
||||||
|
"INSERT INTO installations (client_name, address, technician_name, status, created_at) VALUES (?, ?, ?, ?, ?)"
|
||||||
|
);
|
||||||
|
$stmt->execute([$client_name, $address, $technician_name, $status, $installation_date]);
|
||||||
|
$installation_id = $pdo->lastInsertId();
|
||||||
|
|
||||||
|
if (isset($_FILES['images'])) {
|
||||||
|
$upload_dir = __DIR__ . '/assets/uploads/';
|
||||||
|
if (!is_dir($upload_dir)) {
|
||||||
|
mkdir($upload_dir, 0775, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$allowed_ext = ['jpg', 'jpeg', 'png', 'gif'];
|
||||||
|
|
||||||
|
foreach ($_FILES['images']['tmp_name'] as $key => $tmp_name) {
|
||||||
|
if ($_FILES['images']['error'][$key] === UPLOAD_ERR_OK) {
|
||||||
|
$file_name = $_FILES['images']['name'][$key];
|
||||||
|
$file_ext = strtolower(pathinfo($file_name, PATHINFO_EXTENSION));
|
||||||
|
|
||||||
|
if (in_array($file_ext, $allowed_ext)) {
|
||||||
|
$new_file_name = time() . '_' . uniqid() . '_' . basename($file_name);
|
||||||
|
$dest_path = $upload_dir . $new_file_name;
|
||||||
|
|
||||||
|
if (move_uploaded_file($tmp_name, $dest_path)) {
|
||||||
|
$image_path = 'assets/uploads/' . $new_file_name;
|
||||||
|
$img_stmt = $pdo->prepare("INSERT INTO installation_images (installation_id, image_path) VALUES (?, ?)");
|
||||||
|
$img_stmt->execute([$installation_id, $image_path]);
|
||||||
|
} else {
|
||||||
|
throw new Exception('Falha ao mover o arquivo enviado: ' . $file_name);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Exception('Tipo de arquivo inválido: ' . $file_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$pdo->commit();
|
||||||
|
$_SESSION['message'] = 'Instalação registrada com sucesso!';
|
||||||
|
$_SESSION['message_type'] = 'success';
|
||||||
|
header('Location: index.php');
|
||||||
|
exit;
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
if ($pdo->inTransaction()) {
|
||||||
|
$pdo->rollBack();
|
||||||
|
}
|
||||||
|
$_SESSION['message'] = 'Erro ao registrar a instalação: ' . $e->getMessage();
|
||||||
|
$_SESSION['message_type'] = 'danger';
|
||||||
|
header('Location: add_installation.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="pt-BR">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Adicionar Nova Instalação - iload net Solutions</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="sidebar">
|
||||||
|
<a class="navbar-brand" href="index.php">iload net Solutions</a>
|
||||||
|
<ul class="nav flex-column">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="index.php">
|
||||||
|
<i class="bi bi-grid-1x2-fill"></i> Painel de Controle
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link active" href="add_installation.php">
|
||||||
|
<i class="bi bi-plus-circle-fill"></i> Adicionar Instalação
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="main-content">
|
||||||
|
<nav class="top-navbar navbar navbar-expand">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<ul class="navbar-nav ms-auto">
|
||||||
|
<li class="nav-item dropdown">
|
||||||
|
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||||
|
<i class="bi bi-person-circle me-1"></i> Administrador
|
||||||
|
</a>
|
||||||
|
<ul class="dropdown-menu dropdown-menu-end">
|
||||||
|
<li><a class="dropdown-item" href="#">Perfil</a></li>
|
||||||
|
<li><a class="dropdown-item" href="#">Sair</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-lg-8 col-md-10">
|
||||||
|
<div class="card shadow-sm mb-4">
|
||||||
|
<div class="card-header py-3">
|
||||||
|
<h1 class="h3 mb-0 text-gray-800">Registrar Nova Instalação</h1>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<?php if (!empty($_SESSION['message'])): ?>
|
||||||
|
<div class="alert alert-<?php echo $_SESSION['message_type']; ?>">
|
||||||
|
<?php echo $_SESSION['message']; ?>
|
||||||
|
</div>
|
||||||
|
<?php unset($_SESSION['message'], $_SESSION['message_type']); ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
<form action="add_installation.php" method="POST" enctype="multipart/form-data">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="client_name" class="form-label">Nome do Cliente</label>
|
||||||
|
<input type="text" class="form-control" id="client_name" name="client_name" required style="width: 100%;">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="address" class="form-label">Endereço</label>
|
||||||
|
<input type="text" class="form-control" id="address" name="address" required style="width: 100%;">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="technician_name" class="form-label">Nome do Técnico</label>
|
||||||
|
<input type="text" class="form-control" id="technician_name" name="technician_name" required style="width: 100%;">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="installation_date" class="form-label">Data da Instalação</label>
|
||||||
|
<input type="date" class="form-control" id="installation_date" name="installation_date" required style="width: 100%;">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="status" class="form-label">Status</label>
|
||||||
|
<select class="form-select" id="status" name="status" style="width: 100%;">
|
||||||
|
<option value="ativo">Ativo</option>
|
||||||
|
<option value="Manutencao">Manutenção</option>
|
||||||
|
<option value="Manutenção Parcial">Manutenção Parcial</option>
|
||||||
|
<option value="inativo">Inativo</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="images" class="form-label">Imagens da Instalação (múltiplas)</label>
|
||||||
|
<input type="file" class="form-control" id="images" name="images[]" multiple accept="image/*" style="width: 100%;">
|
||||||
|
</div>
|
||||||
|
<hr class="my-4">
|
||||||
|
<div class="d-flex justify-content-end">
|
||||||
|
<a href="index.php" class="btn btn-secondary me-2">Cancelar</a>
|
||||||
|
<button type="submit" class="btn btn-primary">Salvar Instalação</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
105
assets/css/custom.css
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
/* Estilos para os cards de KPI */
|
||||||
|
.kpi-card {
|
||||||
|
border: 1px solid #e3e6f0;
|
||||||
|
border-radius: .35rem;
|
||||||
|
transition: all .3s ease;
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.kpi-card .card-body {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.kpi-icon {
|
||||||
|
width: 50px;
|
||||||
|
height: 50px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border-radius: 50%;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 24px;
|
||||||
|
margin-right: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.kpi-value {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #5a5c69;
|
||||||
|
}
|
||||||
|
|
||||||
|
.kpi-label {
|
||||||
|
font-size: .8rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #858796;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Remove o sublinhado dos links nos cards de KPI */
|
||||||
|
a.kpi-link,
|
||||||
|
a.kpi-link:hover {
|
||||||
|
text-decoration: none;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Estilos gerais */
|
||||||
|
body {
|
||||||
|
background-color: #f8f9fc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar {
|
||||||
|
width: 250px;
|
||||||
|
background-color: #4e73df;
|
||||||
|
position: fixed;
|
||||||
|
height: 100%;
|
||||||
|
padding-top: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar .navbar-brand {
|
||||||
|
color: #fff;
|
||||||
|
font-weight: 700;
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar .nav-link {
|
||||||
|
color: rgba(255,255,255,.8);
|
||||||
|
padding: .75rem 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar .nav-link.active,
|
||||||
|
.sidebar .nav-link:hover {
|
||||||
|
color: #fff;
|
||||||
|
background-color: rgba(255,255,255,.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar .nav-link i {
|
||||||
|
margin-right: .5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-content {
|
||||||
|
margin-left: 250px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-navbar {
|
||||||
|
background-color: #fff;
|
||||||
|
border-bottom: 1px solid #e3e6f0;
|
||||||
|
padding: .5rem 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container-fluid {
|
||||||
|
padding: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Estilos para telas pequenas (dispositivos móveis) */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.sidebar {
|
||||||
|
display: none; /* Esconde o menu lateral */
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-content {
|
||||||
|
margin-left: 0; /* Remove a margem do conteúdo principal */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 65 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 72 KiB |
|
After Width: | Height: | Size: 91 KiB |
|
After Width: | Height: | Size: 96 KiB |
|
After Width: | Height: | Size: 73 KiB |
|
After Width: | Height: | Size: 69 KiB |
|
After Width: | Height: | Size: 51 KiB |
|
After Width: | Height: | Size: 53 KiB |
|
After Width: | Height: | Size: 124 KiB |
|
After Width: | Height: | Size: 88 KiB |
|
After Width: | Height: | Size: 106 KiB |
|
After Width: | Height: | Size: 62 KiB |
|
After Width: | Height: | Size: 71 KiB |
|
After Width: | Height: | Size: 70 KiB |
|
After Width: | Height: | Size: 70 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 71 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 102 KiB |
|
After Width: | Height: | Size: 122 KiB |
|
After Width: | Height: | Size: 147 KiB |
|
After Width: | Height: | Size: 62 KiB |
|
After Width: | Height: | Size: 80 KiB |
|
After Width: | Height: | Size: 63 KiB |
|
After Width: | Height: | Size: 98 KiB |
|
After Width: | Height: | Size: 63 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 59 KiB |
|
After Width: | Height: | Size: 92 KiB |
|
After Width: | Height: | Size: 67 KiB |
|
After Width: | Height: | Size: 112 KiB |
|
After Width: | Height: | Size: 102 KiB |
|
After Width: | Height: | Size: 79 KiB |
|
After Width: | Height: | Size: 142 KiB |
|
After Width: | Height: | Size: 136 KiB |
|
After Width: | Height: | Size: 150 KiB |
|
After Width: | Height: | Size: 71 KiB |
|
After Width: | Height: | Size: 83 KiB |
|
After Width: | Height: | Size: 96 KiB |
|
After Width: | Height: | Size: 96 KiB |
|
After Width: | Height: | Size: 66 KiB |
|
After Width: | Height: | Size: 91 KiB |
|
After Width: | Height: | Size: 130 KiB |
|
After Width: | Height: | Size: 87 KiB |
|
After Width: | Height: | Size: 61 KiB |
|
After Width: | Height: | Size: 112 KiB |
|
After Width: | Height: | Size: 89 KiB |
|
After Width: | Height: | Size: 119 KiB |
|
After Width: | Height: | Size: 102 KiB |
|
After Width: | Height: | Size: 118 KiB |
|
After Width: | Height: | Size: 79 KiB |
|
After Width: | Height: | Size: 78 KiB |
|
After Width: | Height: | Size: 89 KiB |
|
After Width: | Height: | Size: 87 KiB |
|
After Width: | Height: | Size: 89 KiB |
|
After Width: | Height: | Size: 68 KiB |
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 78 KiB |
|
After Width: | Height: | Size: 58 KiB |
|
After Width: | Height: | Size: 110 KiB |
|
After Width: | Height: | Size: 77 KiB |
|
After Width: | Height: | Size: 47 KiB |
|
After Width: | Height: | Size: 43 KiB |
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 58 KiB |
|
After Width: | Height: | Size: 59 KiB |
|
After Width: | Height: | Size: 166 KiB |
|
After Width: | Height: | Size: 63 KiB |
|
After Width: | Height: | Size: 159 KiB |
|
After Width: | Height: | Size: 112 KiB |
|
After Width: | Height: | Size: 68 KiB |
|
After Width: | Height: | Size: 93 KiB |
|
After Width: | Height: | Size: 85 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 106 KiB |
|
After Width: | Height: | Size: 73 KiB |
|
After Width: | Height: | Size: 87 KiB |
|
After Width: | Height: | Size: 60 KiB |
|
After Width: | Height: | Size: 60 KiB |
|
After Width: | Height: | Size: 60 KiB |
|
After Width: | Height: | Size: 85 KiB |
|
After Width: | Height: | Size: 87 KiB |
|
After Width: | Height: | Size: 70 KiB |
|
After Width: | Height: | Size: 88 KiB |
|
After Width: | Height: | Size: 118 KiB |
|
After Width: | Height: | Size: 73 KiB |
|
After Width: | Height: | Size: 122 KiB |
|
After Width: | Height: | Size: 122 KiB |
|
After Width: | Height: | Size: 99 KiB |
|
After Width: | Height: | Size: 130 KiB |
|
After Width: | Height: | Size: 141 KiB |
|
After Width: | Height: | Size: 102 KiB |
|
After Width: | Height: | Size: 120 KiB |