325 lines
13 KiB
PHP
325 lines
13 KiB
PHP
<?php include('include/headscript.php'); ?>
|
|
<!doctype html>
|
|
<html lang="it">
|
|
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<link rel="icon" href="assets/images/favicon-32x32.png" type="image/png" />
|
|
<?php include('cssinclude.php'); ?>
|
|
<title>Tutti i Dati di Produzione - <?= htmlspecialchars($titlewebsite, ENT_QUOTES, 'UTF-8'); ?></title>
|
|
|
|
<!-- jQuery -->
|
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
|
|
|
<!-- Bootstrap -->
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
|
|
|
<!-- DataTables -->
|
|
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.6/css/dataTables.bootstrap5.min.css">
|
|
<script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
|
|
<script src="https://cdn.datatables.net/1.13.6/js/dataTables.bootstrap5.min.js"></script>
|
|
|
|
<!-- Select2 -->
|
|
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
|
|
<link href="https://cdn.jsdelivr.net/npm/select2-bootstrap-5-theme@1.3.0/dist/select2-bootstrap-5-theme.min.css" rel="stylesheet" />
|
|
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.full.min.js"></script>
|
|
|
|
<!-- SweetAlert2 -->
|
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
|
|
|
<style>
|
|
body {
|
|
background: linear-gradient(135deg, #f2f6f9, #e6eef5);
|
|
font-size: 1rem;
|
|
}
|
|
|
|
.page-content {
|
|
padding: 1rem;
|
|
}
|
|
|
|
.card {
|
|
border-radius: 16px;
|
|
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
|
|
}
|
|
|
|
.card-header {
|
|
background: transparent;
|
|
border: none;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.back-dashboard {
|
|
background-color: #cfe3ff !important;
|
|
color: #1f2d3d !important;
|
|
border: 1px solid #bcd4f4 !important;
|
|
border-radius: 10px;
|
|
font-weight: 600;
|
|
font-size: 1rem;
|
|
padding: 8px 16px;
|
|
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
|
|
transition: all 0.2s ease-in-out;
|
|
}
|
|
|
|
.back-dashboard:hover {
|
|
background-color: #b9d3ff !important;
|
|
transform: translateY(-2px);
|
|
}
|
|
|
|
.filters {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 10px;
|
|
align-items: center;
|
|
margin-bottom: 15px;
|
|
}
|
|
|
|
.filters label {
|
|
font-weight: 500;
|
|
color: #333;
|
|
margin-right: 5px;
|
|
}
|
|
|
|
.filters input,
|
|
.filters select {
|
|
border-radius: 8px;
|
|
padding: 8px;
|
|
font-size: 1rem;
|
|
}
|
|
|
|
.select2-container--bootstrap-5 .select2-selection {
|
|
min-height: 45px;
|
|
padding: 8px 10px;
|
|
font-size: 1rem;
|
|
border-radius: 8px;
|
|
}
|
|
|
|
.badge-status {
|
|
padding: 6px 10px;
|
|
border-radius: 8px;
|
|
font-weight: 600;
|
|
font-size: 0.85rem;
|
|
}
|
|
|
|
.badge-yes {
|
|
background-color: #d1f5e1;
|
|
color: #128346;
|
|
}
|
|
|
|
.badge-no {
|
|
background-color: #ececec;
|
|
color: #555;
|
|
}
|
|
|
|
table.dataTable tbody tr:hover {
|
|
background-color: #f5faff;
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.filters {
|
|
flex-direction: column;
|
|
align-items: stretch;
|
|
}
|
|
|
|
.filters>* {
|
|
width: 100%;
|
|
}
|
|
|
|
.back-dashboard {
|
|
width: 100%;
|
|
text-align: center;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div class="wrapper">
|
|
<?php include('include/navbar.php'); ?>
|
|
<?php include('include/topbar.php'); ?>
|
|
|
|
<div class="page-wrapper">
|
|
<div class="page-content">
|
|
<div class="card p-3">
|
|
<div class="card-header d-flex justify-content-between align-items-center">
|
|
<h5 class="mb-0">Tutti i Dati di Produzione</h5>
|
|
<button type="button" class="btn back-dashboard" onclick="location.href='production_dashboard.php'">
|
|
↩️ Torna alla Dashboard
|
|
</button>
|
|
</div>
|
|
|
|
<!-- FILTRI -->
|
|
<div class="filters">
|
|
<div>
|
|
<label for="filterData">Data:</label>
|
|
<input type="date" id="filterData" class="form-control">
|
|
</div>
|
|
|
|
<div style="min-width:180px;">
|
|
<label for="filterMatrice">Matrice:</label>
|
|
<select id="filterMatrice" class="form-select">
|
|
<option value="">Tutte</option>
|
|
<?php
|
|
$db = DBHandlerSelect::getInstance();
|
|
$pdo = $db->getConnection();
|
|
$stmt = $pdo->query("SELECT id, nome FROM matrice ORDER BY nome ASC");
|
|
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
echo "<option value='" . htmlspecialchars($row['nome']) . "'>" . htmlspecialchars($row['nome']) . "</option>";
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
|
|
<div style="min-width:180px;">
|
|
<label for="filterMescola">Mescola:</label>
|
|
<select id="filterMescola" class="form-select">
|
|
<option value="">Tutte</option>
|
|
<?php
|
|
$stmt = $pdo->query("SELECT id, nome FROM mescole ORDER BY nome ASC");
|
|
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
echo "<option value='" . htmlspecialchars($row['nome']) . "'>" . htmlspecialchars($row['nome']) . "</option>";
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
|
|
<div>
|
|
<label for="filterFermo">Fermo macchina:</label>
|
|
<select id="filterFermo" class="form-select">
|
|
<option value="">Tutti</option>
|
|
<option value="Sì">Sì</option>
|
|
<option value="No">No</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div>
|
|
<button id="resetFiltri" class="btn btn-outline-secondary">🔄 Reset Filtri</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- TABELLA -->
|
|
<div class="table-responsive">
|
|
<table id="tabellaProduzione" class="table table-striped align-middle text-center" style="width:100%;">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>Data</th>
|
|
<th>Matrice</th>
|
|
<th>Mescola</th>
|
|
<th>Fermo</th>
|
|
<th>Ora Inizio</th>
|
|
<th>Ora Fine</th>
|
|
<th>Kg</th>
|
|
<th>Mt</th>
|
|
<th>Scarto</th>
|
|
<th>Note</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
$sql = "SELECT p.*, m.nome AS matrice_nome, ms.nome AS mescola_nome
|
|
FROM productiondata p
|
|
JOIN matrice m ON p.idmatrice = m.id
|
|
JOIN mescole ms ON p.idmescola = ms.id
|
|
ORDER BY p.Data DESC, p.hour ASC";
|
|
$stmt = $pdo->query($sql);
|
|
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
$dataFormat = date("d/m/Y", strtotime($row['Data']));
|
|
$hourStart = date("H:i", strtotime($row['hour']));
|
|
$hourEnd = date("H:i", strtotime($row['hourprod']));
|
|
$badge = $row['fermomacchina']
|
|
? "<span class='badge-status badge-yes'>Sì</span>"
|
|
: "<span class='badge-status badge-no'>No</span>";
|
|
$notePreview = !empty($row['note'])
|
|
? "<button class='btn btn-sm btn-outline-primary view-note' data-note='" . htmlspecialchars($row['note'], ENT_QUOTES) . "'>📝</button>"
|
|
: "-";
|
|
|
|
echo "<tr>
|
|
<td>{$dataFormat}</td>
|
|
<td>" . htmlspecialchars($row['matrice_nome']) . "</td>
|
|
<td>" . htmlspecialchars($row['mescola_nome']) . "</td>
|
|
<td>{$badge}</td>
|
|
<td>{$hourStart}</td>
|
|
<td>{$hourEnd}</td>
|
|
<td>" . htmlspecialchars($row['kgprod']) . "</td>
|
|
<td>" . htmlspecialchars($row['mtprod']) . "</td>
|
|
<td>" . htmlspecialchars($row['scarto']) . "</td>
|
|
<td>{$notePreview}</td>
|
|
</tr>";
|
|
}
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php include('include/footer.php'); ?>
|
|
</div>
|
|
<?php include('jsinclude.php'); ?>
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
const table = $('#tabellaProduzione').DataTable({
|
|
order: [
|
|
[0, 'desc']
|
|
],
|
|
pageLength: 25,
|
|
responsive: true,
|
|
language: {
|
|
url: 'https://cdn.datatables.net/plug-ins/1.13.6/i18n/it-IT.json'
|
|
}
|
|
});
|
|
|
|
$('#filterMatrice, #filterMescola, #filterFermo').select2({
|
|
theme: 'bootstrap-5',
|
|
width: 'resolve'
|
|
});
|
|
|
|
$.fn.dataTable.ext.search.push(function(settings, data) {
|
|
const dataFiltro = $('#filterData').val();
|
|
const matrice = $('#filterMatrice').val();
|
|
const mescola = $('#filterMescola').val();
|
|
const fermo = $('#filterFermo').val();
|
|
|
|
const dataColonna = data[0];
|
|
const matriceColonna = data[1];
|
|
const mescolaColonna = data[2];
|
|
const fermoColonna = data[3];
|
|
|
|
let match = true;
|
|
if (dataFiltro) {
|
|
const convertita = dataFiltro.split('-').reverse().join('/');
|
|
match = match && dataColonna.includes(convertita);
|
|
}
|
|
if (matrice) match = match && matriceColonna === matrice;
|
|
if (mescola) match = match && mescolaColonna === mescola;
|
|
if (fermo) match = match && fermoColonna.includes(fermo);
|
|
return match;
|
|
});
|
|
|
|
$('#filterData, #filterMatrice, #filterMescola, #filterFermo').on('change keyup', () => table.draw());
|
|
|
|
$('#resetFiltri').on('click', function() {
|
|
$('#filterData').val('');
|
|
$('#filterMatrice, #filterMescola, #filterFermo').val('').trigger('change');
|
|
table.draw();
|
|
});
|
|
|
|
$('#tabellaProduzione tbody').on('click', '.view-note', function() {
|
|
const noteText = $(this).data('note') || 'Nessuna nota disponibile';
|
|
Swal.fire({
|
|
title: "Note di Produzione",
|
|
html: `<div style='text-align:left;font-size:1.1rem;'>${noteText}</div>`,
|
|
icon: "info",
|
|
confirmButtonText: "Chiudi",
|
|
confirmButtonColor: "#3085d6",
|
|
width: "90%",
|
|
background: "#f9fbfd"
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|