versao 14

This commit is contained in:
Flatlogic Bot 2025-10-29 16:36:48 +00:00
parent 190ee537e4
commit 9fcffa06dc
2 changed files with 139 additions and 3 deletions

View File

@ -24,7 +24,7 @@ $macro_areas = $stmt->fetchAll(PDO::FETCH_ASSOC);
<div class="d-sm-flex align-items-center justify-content-between mb-4"> <div class="d-sm-flex align-items-center justify-content-between mb-4">
<h1 class="h3 mb-0">Macro Áreas</h1> <h1 class="h3 mb-0">Macro Áreas</h1>
<div> <div>
<button class="btn btn-secondary btn-icon-split btn-sm"> <button id="printButton" class="btn btn-secondary btn-icon-split btn-sm">
<span class="icon text-white-50"><i data-lucide="file-text" style="color: #FFFFFF;"></i></span> <span class="icon text-white-50"><i data-lucide="file-text" style="color: #FFFFFF;"></i></span>
<span class="text">Imprimir Lista</span> <span class="text">Imprimir Lista</span>
</button> </button>
@ -123,6 +123,29 @@ document.addEventListener('DOMContentLoaded', function () {
} }
} }
}); });
// Print functionality
const printButton = document.getElementById('printButton');
printButton.addEventListener('click', function() {
fetch('print_macro_areas.php')
.then(response => response.text())
.then(html => {
const printWindow = window.open('', '_blank');
printWindow.document.write(html);
printWindow.document.close();
printWindow.focus(); // Required for some browsers
// Use a small timeout to ensure content is loaded before printing
setTimeout(() => {
printWindow.print();
}, 250);
printWindow.addEventListener('afterprint', () => {
printWindow.close();
});
})
.catch(error => console.error('Error fetching print content:', error));
});
}); });
</script> </script>
@ -135,8 +158,8 @@ document.addEventListener('DOMContentLoaded', function () {
border-left: 0; border-left: 0;
} }
.btn-sm i[data-lucide] { .btn-sm i[data-lucide] {
width: 11px; width: 18px;
height: 11px; height: 18px;
} }
/* Custom styles for status badges */ /* Custom styles for status badges */
.badge-status-ativo { .badge-status-ativo {

113
print_macro_areas.php Normal file
View File

@ -0,0 +1,113 @@
<?php
require_once 'includes/session.php';
require_once 'db/config.php';
$pdo = db();
$stmt = $pdo->query('SELECT * FROM macro_areas ORDER BY nome ASC');
$macro_areas = $stmt->fetchAll(PDO::FETCH_ASSOC);
$total = count($macro_areas);
$active = 0;
$archived = 0;
foreach ($macro_areas as $area) {
if ($area['ativo']) {
$active++;
} else {
$archived++;
}
}
?>
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<title>Lista de Macro Áreas</title>
<style>
body {
font-family: sans-serif;
color: #333;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
th, td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}
th {
background-color: #f2f2f2;
}
h1 {
font-size: 24px;
}
.header {
margin-bottom: 20px;
font-size: 12px;
color: #666;
}
.summary {
margin-top: 20px;
font-size: 14px;
}
@page {
margin: 10mm;
}
@media print {
body {
margin: 0;
}
.no-print {
display: none;
}
}
</style>
</head>
<body>
<div style="text-align: center; margin-bottom: 20px;">
<img src="assets/pasted-20251029-150345-2b427067.png" alt="Logotipo Galilei" style="max-width: 150px; height: auto;">
</div>
<h1>Lista de Macro Áreas</h1>
<div class="header">
Gerado em: <?php echo date('d/m/Y H:i:s'); ?>
</div>
<table>
<thead>
<tr>
<th>#</th>
<th>Nome</th>
<th>Descrição</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php $count = 1; foreach ($macro_areas as $area): ?>
<tr>
<td><?php echo $count++; ?></td>
<td><strong><?php echo htmlspecialchars($area['nome']); ?></strong></td>
<td><?php echo htmlspecialchars($area['descricao']); ?></td>
<td><?php echo $area['ativo'] ? 'Ativo' : 'Arquivado'; ?></td>
</tr>
<?php endforeach; ?>
<?php if (empty($macro_areas)): ?>
<tr>
<td colspan="4" style="text-align: center;">Nenhuma macro área encontrada.</td>
</tr>
<?php endif; ?>
</tbody>
</table>
<div class="summary">
<p>
<strong>Total de Macro Áreas:</strong> <?php echo $total; ?> |
<strong>Ativas:</strong> <?php echo $active; ?> |
<strong>Arquivadas:</strong> <?php echo $archived; ?>
</p>
</div>
</body>
</html>