status added
This commit is contained in:
@@ -20,9 +20,7 @@ $statusProgrammatoId = $statusProgrammato['id'];
|
||||
$statusProduzioneId = $statusProduzione['id'];
|
||||
$statusPausaId = $statusPausa['id'];
|
||||
|
||||
// --- DATA E LINEA SELEZIONATE ---
|
||||
$selected_date = $_GET['date'] ?? date('Y-m-d');
|
||||
$selected_line = $_GET['line'] ?? '';
|
||||
|
||||
|
||||
// --- AVVIO / RIPRESA PRODUZIONE ---
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['start_production'])) {
|
||||
@@ -174,64 +172,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['save_final_data']))
|
||||
exit;
|
||||
}
|
||||
|
||||
// --- AJAX: carica record giorno successivo ---
|
||||
if (!empty($_GET['ajax_next'])) {
|
||||
|
||||
$date = $_GET['date'] ?? date('Y-m-d');
|
||||
$lineRaw = $_GET['line'] ?? '';
|
||||
$lineArray = $lineRaw !== '' ? explode(',', $lineRaw) : [];
|
||||
|
||||
$sql = "SELECT
|
||||
p.*,
|
||||
m.nome AS matrice,
|
||||
ms.nome AS mescola,
|
||||
l.name AS linea,
|
||||
c.nome AS cliente,
|
||||
s.nome AS status_nome,
|
||||
s.badge_color,
|
||||
s.line_color,
|
||||
p.tempo_totale_produzione
|
||||
FROM productiondata p
|
||||
LEFT JOIN matrice m ON p.idmatrice = m.id
|
||||
LEFT JOIN mescole ms ON p.idmescola = ms.id
|
||||
LEFT JOIN production_lines l ON p.id_linea = l.id
|
||||
LEFT JOIN clients c ON p.id_cliente = c.id
|
||||
LEFT JOIN production_status s ON p.id_status = s.id
|
||||
WHERE p.data_produzione = :date
|
||||
AND p.id_status IN (:programmato, :produzione, :pausa)"
|
||||
. (!empty($lineArray) ? " AND p.id_linea IN (" . implode(',', array_map('intval', $lineArray)) . ")" : "")
|
||||
. " ORDER BY l.line_number, p.Data";
|
||||
|
||||
$params = [
|
||||
':date' => $date,
|
||||
':programmato' => $statusProgrammatoId,
|
||||
':produzione' => $statusProduzioneId,
|
||||
':pausa' => $statusPausaId
|
||||
];
|
||||
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
|
||||
$recordsNext = $stmt->fetchAll();
|
||||
|
||||
if (empty($recordsNext)) {
|
||||
exit; // ritorna vuoto
|
||||
}
|
||||
|
||||
foreach ($recordsNext as $r) {
|
||||
include __DIR__ . "/render_production_card.php";
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
// --- AJAX PRINCIPALE: carica i record della data selezionata ---
|
||||
if (!empty($_GET['ajax'])) {
|
||||
|
||||
$date = $_GET['date'] ?? date('Y-m-d');
|
||||
$lineRaw = $_GET['line'] ?? '';
|
||||
$lineArray = $lineRaw !== '' ? explode(',', $lineRaw) : [];
|
||||
|
||||
// --- RECORD IN PRODUZIONE (2,7,8)
|
||||
$sql = "SELECT
|
||||
p.*,
|
||||
m.nome AS matrice,
|
||||
@@ -248,34 +195,55 @@ if (!empty($_GET['ajax'])) {
|
||||
LEFT JOIN production_lines l ON p.id_linea = l.id
|
||||
LEFT JOIN clients c ON p.id_cliente = c.id
|
||||
LEFT JOIN production_status s ON p.id_status = s.id
|
||||
WHERE p.data_produzione = :date
|
||||
AND p.id_status IN (:programmato, :produzione, :pausa)"
|
||||
. (!empty($lineArray) ? " AND p.id_linea IN (" . implode(',', array_map('intval', $lineArray)) . ")" : "")
|
||||
. " ORDER BY l.line_number, p.Data";
|
||||
|
||||
$params = [
|
||||
':date' => $date,
|
||||
':programmato' => $statusProgrammatoId,
|
||||
':produzione' => $statusProduzioneId,
|
||||
':pausa' => $statusPausaId
|
||||
];
|
||||
WHERE p.id_status IN (2, 7, 8)
|
||||
" . (!empty($lineArray) ? " AND p.id_linea IN (" . implode(',', array_map('intval', $lineArray)) . ")" : "") . "
|
||||
ORDER BY l.line_number, p.Data";
|
||||
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
$stmt->execute();
|
||||
$records = $stmt->fetchAll();
|
||||
|
||||
if (empty($records)) {
|
||||
exit;
|
||||
}
|
||||
|
||||
foreach ($records as $r) {
|
||||
include __DIR__ . "/render_production_card.php";
|
||||
}
|
||||
|
||||
// --- RECORD IN STATO 6 ORDINATI PER PRIORITY
|
||||
$sql2 = "SELECT
|
||||
p.*,
|
||||
m.nome AS matrice,
|
||||
ms.nome AS mescola,
|
||||
l.name AS linea,
|
||||
c.nome AS cliente,
|
||||
s.nome AS status_nome,
|
||||
s.badge_color,
|
||||
s.line_color,
|
||||
p.tempo_totale_produzione
|
||||
FROM productiondata p
|
||||
LEFT JOIN matrice m ON p.idmatrice = m.id
|
||||
LEFT JOIN mescole ms ON p.idmescola = ms.id
|
||||
LEFT JOIN production_lines l ON p.id_linea = l.id
|
||||
LEFT JOIN clients c ON p.id_cliente = c.id
|
||||
LEFT JOIN production_status s ON p.id_status = s.id
|
||||
WHERE p.id_status = 6
|
||||
" . (!empty($lineArray) ? " AND p.id_linea IN (" . implode(',', array_map('intval', $lineArray)) . ")" : "") . "
|
||||
ORDER BY p.priority ASC";
|
||||
|
||||
$stmt2 = $pdo->prepare($sql2);
|
||||
$stmt2->execute();
|
||||
$recordsPriority = $stmt2->fetchAll();
|
||||
|
||||
if (!empty($recordsPriority)) {
|
||||
echo '<div style="margin:20px 0; font-size:1.3rem; font-weight:700; color:#1e40af;">Programmato (in ordine di priorità)</div>';
|
||||
foreach ($recordsPriority as $r) {
|
||||
include __DIR__ . "/render_production_card.php";
|
||||
}
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
@@ -287,7 +255,7 @@ if (!empty($_GET['ajax'])) {
|
||||
<title>Linea Produzione - Tablet</title>
|
||||
<?php include('cssinclude.php'); ?>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
|
||||
|
||||
<style>
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
@@ -757,10 +725,6 @@ if (!empty($_GET['ajax'])) {
|
||||
</div>
|
||||
|
||||
<div class="filters">
|
||||
<div class="filter-group">
|
||||
<label for="filterDate">Giornata</label>
|
||||
<input type="text" id="filterDate" placeholder="gg/mm/aaaa">
|
||||
</div>
|
||||
<div class="filter-group">
|
||||
<label>Linee</label>
|
||||
|
||||
@@ -877,7 +841,7 @@ if (!empty($_GET['ajax'])) {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1006,17 +970,11 @@ if (!empty($_GET['ajax'])) {
|
||||
$("#photoModal").removeClass("active");
|
||||
});
|
||||
</script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
|
||||
|
||||
<?php include('jsinclude.php'); ?>
|
||||
<script>
|
||||
$(function() {
|
||||
|
||||
const datePicker = flatpickr("#filterDate", {
|
||||
dateFormat: "d/m/Y",
|
||||
defaultDate: "<?= date('d/m/Y') ?>",
|
||||
onChange: loadRecords
|
||||
});
|
||||
|
||||
$('#filterLine').on('change', loadRecords);
|
||||
const beep = $('#beepSound')[0];
|
||||
let timers = {};
|
||||
@@ -1067,46 +1025,18 @@ if (!empty($_GET['ajax'])) {
|
||||
|
||||
// --- CARICA RECORD ---
|
||||
function loadRecords() {
|
||||
const date = datePicker.selectedDates[0];
|
||||
const isoDate = date ? new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).toISOString().split('T')[0] : '<?= date('Y-m-d') ?>';
|
||||
const line = $('#filterLine').val();
|
||||
|
||||
$('#recordsContainer').html('<div class="text-center p-5"><i class="bi bi-hourglass-split" style="font-size:2.5rem;color:#94a3b8;"></i></div>');
|
||||
|
||||
const line = $('#filterLine').val();
|
||||
|
||||
$.get('', {
|
||||
ajax: 1,
|
||||
date: isoDate,
|
||||
line: line
|
||||
}, function(html) {
|
||||
// Il primo HTML (oggi / data selezionata)
|
||||
let htmlOggi = html;
|
||||
|
||||
// Ora carichiamo DOMANI
|
||||
const dateObj = new Date(isoDate);
|
||||
dateObj.setDate(dateObj.getDate() + 1);
|
||||
const tomorrow = dateObj.toISOString().split('T')[0];
|
||||
|
||||
$.get('', {
|
||||
ajax_next: 1,
|
||||
date: tomorrow,
|
||||
line: line
|
||||
}, function(htmlNext) {
|
||||
|
||||
let titoloNext = `
|
||||
<div style="margin:20px 0; font-size:1.4rem; font-weight:700; color:#1e40af;">
|
||||
Programmazione giorno successivo (${formatItalianDate(tomorrow)})
|
||||
</div>
|
||||
`;
|
||||
|
||||
|
||||
$('#recordsContainer').html(
|
||||
htmlOggi +
|
||||
(htmlNext.trim() !== '' ? titoloNext + htmlNext : '')
|
||||
);
|
||||
|
||||
startAllTimers();
|
||||
setupEventHandlers();
|
||||
});
|
||||
// 🔥 INSERIRE L’HTML NEL CONTAINER
|
||||
$('#recordsContainer').html(html);
|
||||
|
||||
startAllTimers();
|
||||
setupEventHandlers();
|
||||
|
||||
Reference in New Issue
Block a user