marici foglio lavoro

This commit is contained in:
Claudio 2026-03-20 22:09:39 +01:00
parent 53b990ff40
commit d2f2a9089e
2 changed files with 1461 additions and 284 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,226 @@
<?php include('include/headscript.php'); ?>
<?php
ob_start();
ini_set('display_errors', 1);
error_reporting(E_ALL);
include('include/headscript.php');
$db = DBHandlerSelect::getInstance();
$pdo = $db->getConnection();
/**
* Helpers
*/
function h($v)
{
return htmlspecialchars((string)$v, ENT_QUOTES, 'UTF-8');
}
function formatDateIT($d)
{
if (!$d || $d === '0000-00-00') return '';
return date("d/m/Y", strtotime($d));
}
function formatDateTimeIT($d)
{
if (!$d || $d === '0000-00-00 00:00:00') return '';
return date("d/m/Y H:i", strtotime($d));
}
function formatNullable($v, $fallback = '—')
{
$v = trim((string)$v);
return $v !== '' ? $v : $fallback;
}
/**
* AJAX HANDLERS
*/
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['ajax']) && $_POST['ajax'] == '1') {
while (ob_get_level()) {
ob_end_clean();
}
header('Content-Type: application/json; charset=utf-8');
$action = $_POST['action'] ?? '';
try {
if ($action === 'get_matrice_worksheets') {
$idmatrice = isset($_POST['idmatrice']) ? (int)$_POST['idmatrice'] : 0;
if ($idmatrice <= 0) {
echo json_encode([
'success' => false,
'message' => 'ID matrice non valido'
]);
exit;
}
$stmt = $pdo->prepare("
SELECT
ws.id,
ws.idmatrice,
ws.worksheet_date,
ws.customer_name,
ws.profile_type_code,
ws.marking,
ws.approved_by,
ws.created_at,
ws.updated_at,
(
SELECT COUNT(*)
FROM work_sheet_mescole wsm
WHERE wsm.worksheet_id = ws.id
) AS mix_count
FROM work_sheets ws
WHERE ws.idmatrice = ?
ORDER BY
CASE WHEN ws.worksheet_date IS NULL THEN 1 ELSE 0 END,
ws.worksheet_date DESC,
ws.id DESC
");
$stmt->execute([$idmatrice]);
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
$data = [];
foreach ($rows as $r) {
$data[] = [
'id' => (int)$r['id'],
'idmatrice' => (int)$r['idmatrice'],
'worksheet_date' => $r['worksheet_date'],
'worksheet_date_it' => formatDateIT($r['worksheet_date']),
'customer_name' => $r['customer_name'] ?? '',
'profile_type_code' => $r['profile_type_code'] ?? '',
'marking' => $r['marking'] ?? '',
'approved_by' => $r['approved_by'] ?? '',
'created_at' => $r['created_at'] ?? '',
'created_at_it' => formatDateTimeIT($r['created_at'] ?? ''),
'updated_at' => $r['updated_at'] ?? '',
'updated_at_it' => formatDateTimeIT($r['updated_at'] ?? ''),
'mix_count' => (int)($r['mix_count'] ?? 0)
];
}
echo json_encode([
'success' => true,
'worksheets' => $data
]);
exit;
}
if ($action === 'get_worksheet_detail') {
$worksheetId = isset($_POST['worksheet_id']) ? (int)$_POST['worksheet_id'] : 0;
if ($worksheetId <= 0) {
echo json_encode([
'success' => false,
'message' => 'ID foglio non valido'
]);
exit;
}
$stmt = $pdo->prepare("
SELECT
ws.*,
m.nome AS matrice_nome,
m.cliente AS matrice_cliente
FROM work_sheets ws
LEFT JOIN matrice m ON m.id = ws.idmatrice
WHERE ws.id = ?
LIMIT 1
");
$stmt->execute([$worksheetId]);
$ws = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$ws) {
echo json_encode([
'success' => false,
'message' => 'Foglio di lavoro non trovato'
]);
exit;
}
$stmtMix = $pdo->prepare("
SELECT
wsm.*,
me.nome AS mescola_nome,
me.nomeuscita AS mescola_uscita
FROM work_sheet_mescole wsm
LEFT JOIN mescole me ON me.id = wsm.idmescola
WHERE wsm.worksheet_id = ?
ORDER BY wsm.mix_position ASC, wsm.id ASC
");
$stmtMix->execute([$worksheetId]);
$mixRows = $stmtMix->fetchAll(PDO::FETCH_ASSOC);
echo json_encode([
'success' => true,
'worksheet' => [
'id' => (int)$ws['id'],
'idmatrice' => (int)$ws['idmatrice'],
'matrice_nome' => $ws['matrice_nome'] ?? '',
'matrice_cliente' => $ws['matrice_cliente'] ?? '',
'worksheet_date' => $ws['worksheet_date'] ?? '',
'worksheet_date_it' => formatDateIT($ws['worksheet_date'] ?? ''),
'customer_name' => $ws['customer_name'] ?? '',
'profile_type_code' => $ws['profile_type_code'] ?? '',
'marking' => $ws['marking'] ?? '',
'prod_control_measure_settings' => $ws['prod_control_measure_settings'] ?? '',
'control_frequency_cut' => $ws['control_frequency_cut'] ?? '',
'control_frequency_drawing' => $ws['control_frequency_drawing'] ?? '',
'control_frequency_jig' => $ws['control_frequency_jig'] ?? '',
'control_mode_jig' => $ws['control_mode_jig'] ?? '',
'requested_package_code' => $ws['requested_package_code'] ?? '',
'meters_per_package' => $ws['meters_per_package'] ?? '',
'meters_per_package_tolerance' => $ws['meters_per_package_tolerance'] ?? '',
'meters_per_package_notes' => $ws['meters_per_package_notes'] ?? '',
'box_type' => $ws['box_type'] ?? '',
'packages_or_pieces_per_box' => $ws['packages_or_pieces_per_box'] ?? '',
'meters_per_box' => $ws['meters_per_box'] ?? '',
'pallet_type' => $ws['pallet_type'] ?? '',
'boxes_or_packages_per_pallet' => $ws['boxes_or_packages_per_pallet'] ?? '',
'speed_expected_kg_h' => $ws['speed_expected_kg_h'] ?? '',
'speed_actual_kg_h' => $ws['speed_actual_kg_h'] ?? '',
'speed_expected_m_h' => $ws['speed_expected_m_h'] ?? '',
'speed_actual_m_h' => $ws['speed_actual_m_h'] ?? '',
'approved_by' => $ws['approved_by'] ?? '',
'notes' => $ws['notes'] ?? '',
'created_at' => $ws['created_at'] ?? '',
'created_at_it' => formatDateTimeIT($ws['created_at'] ?? ''),
'updated_at' => $ws['updated_at'] ?? '',
'updated_at_it' => formatDateTimeIT($ws['updated_at'] ?? '')
],
'mix_rows' => array_map(function ($r) {
return [
'id' => (int)$r['id'],
'mix_position' => (int)$r['mix_position'],
'mescola_nome' => $r['mescola_nome'] ?? '',
'mescola_uscita' => $r['mescola_uscita'] ?? '',
'mix_weight_g_m' => $r['mix_weight_g_m'] ?? '',
'required_density' => $r['required_density'] ?? '',
'required_hardness_shore_a' => $r['required_hardness_shore_a'] ?? '',
'lubrication_type' => $r['lubrication_type'] ?? '',
'lubrication_notes' => $r['lubrication_notes'] ?? ''
];
}, $mixRows)
]);
exit;
}
echo json_encode([
'success' => false,
'message' => 'Azione AJAX sconosciuta'
]);
exit;
} catch (Exception $e) {
echo json_encode([
'success' => false,
'message' => $e->getMessage()
]);
exit;
}
}
?>
<!doctype html>
<html lang="it">
@ -57,6 +279,21 @@
font-weight: 600;
}
.btn-worksheets {
background: linear-gradient(135deg, #0d6efd, #3b82f6);
color: #fff;
border: none;
border-radius: 10px;
padding: 10px 18px;
font-weight: 700;
box-shadow: 0 6px 16px rgba(13, 110, 253, 0.18);
}
.btn-worksheets:hover {
color: #fff;
opacity: .95;
}
.table thead {
background-color: #b9ebc7;
text-align: center;
@ -90,6 +327,10 @@
color: #0dcaf0;
}
.worksheets {
color: #0d6efd;
}
.thumb-img:hover {
transform: scale(1.05);
transition: 0.2s;
@ -172,14 +413,20 @@
#tabellaMatrici th:nth-child(4),
#tabellaMatrici td:nth-child(4) {
width: 220px;
max-width: 220px;
width: 240px;
max-width: 240px;
}
#tabellaMatrici th:nth-child(5),
#tabellaMatrici td:nth-child(5) {
width: 220px;
max-width: 220px;
width: 130px;
max-width: 130px;
}
#tabellaMatrici th:nth-child(6),
#tabellaMatrici td:nth-child(6) {
width: 260px;
max-width: 260px;
}
#tabellaMatrici td:nth-child(1) img {
@ -276,6 +523,16 @@
width: 95vw;
}
.modal-worksheet-list {
max-width: 980px;
width: 94vw;
}
.modal-worksheet-view {
max-width: 1500px;
width: 97vw;
}
.section-box {
background: #f8fafc;
border: 1px solid #e9ecef;
@ -289,6 +546,129 @@
text-align: center;
padding: 18px 8px;
}
.worksheet-chip {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 4px 10px;
border-radius: 999px;
background: #e7f1ff;
color: #0d6efd;
font-weight: 700;
font-size: .82rem;
}
.worksheet-counter-badge {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 34px;
height: 34px;
border-radius: 999px;
background: linear-gradient(135deg, #0d6efd, #3b82f6);
color: #fff;
font-weight: 800;
font-size: .95rem;
box-shadow: 0 4px 12px rgba(13, 110, 253, 0.22);
}
.worksheet-counter-zero {
background: #e9ecef;
color: #6c757d;
box-shadow: none;
}
.worksheet-list-table th {
background: #e7f1ff !important;
color: #0b3d91;
}
.readonly-card {
border: 1px solid #e9ecef;
border-radius: 16px;
background: #fff;
overflow: hidden;
box-shadow: 0 2px 8px rgba(0, 0, 0, .04);
height: 100%;
}
.readonly-card-header {
background: linear-gradient(135deg, #e7f1ff, #d6e9ff);
color: #0b3d91;
font-weight: 800;
padding: 12px 16px;
border-bottom: 1px solid #cfe2ff;
}
.readonly-card-body {
padding: 16px;
}
.readonly-grid {
display: grid;
grid-template-columns: 220px 1fr;
gap: 8px 16px;
}
.readonly-label {
font-weight: 700;
color: #495057;
}
.readonly-value {
color: #1f2d3d;
word-break: break-word;
}
.worksheet-open-link {
background: #fff;
border: 1px solid #b6d4fe;
color: #0d6efd;
font-weight: 700;
border-radius: 10px;
padding: 9px 14px;
text-decoration: none;
display: inline-flex;
align-items: center;
gap: 8px;
}
.worksheet-open-link:hover {
color: #0a58ca;
background: #f4f9ff;
}
.worksheet-title-box {
background: linear-gradient(135deg, #0d6efd, #3b82f6);
color: #fff;
border-radius: 18px;
padding: 18px 20px;
box-shadow: 0 8px 24px rgba(13, 110, 253, 0.2);
}
.worksheet-title-box small {
color: rgba(255, 255, 255, .9);
}
.mix-readonly-table thead th {
background: #dbeafe !important;
color: #0b3d91;
}
.btn-view-worksheet {
background: linear-gradient(135deg, #0d6efd, #3b82f6);
color: #fff;
border: 0;
border-radius: 8px;
padding: 8px 14px;
font-weight: 700;
}
.btn-view-worksheet:hover {
color: #fff;
opacity: .95;
}
</style>
</head>
@ -321,21 +701,20 @@
<th>Nome</th>
<th>Cliente</th>
<th>Linee</th>
<th>Fogli</th>
<th>Azioni</th>
</tr>
</thead>
<tbody>
<?php
$db = DBHandlerSelect::getInstance();
$pdo = $db->getConnection();
$stmt = $pdo->query("
SELECT
m.*,
COALESCE(lg.linee_associate, '—') AS linee_associate,
COALESCE(mg.mescole_associate, '') AS mescole_associate,
COALESCE(mg.mescole_count, 0) AS mescole_count
COALESCE(mg.mescole_count, 0) AS mescole_count,
COALESCE(wsg.worksheets_count, 0) AS worksheets_count
FROM matrice m
LEFT JOIN (
SELECT
@ -354,19 +733,20 @@
JOIN mescole ms ON ms.id = mm.idmescola
GROUP BY mm.idmatrice
) mg ON mg.idmatrice = m.id
LEFT JOIN (
SELECT
ws.idmatrice,
COUNT(*) AS worksheets_count
FROM work_sheets ws
GROUP BY ws.idmatrice
) wsg ON wsg.idmatrice = m.id
ORDER BY
CASE WHEN TRIM(COALESCE(m.nome, '')) = '' THEN 1 ELSE 0 END,
m.nome ASC
");
function formatDateIT($d)
{
if (!$d || $d == '0000-00-00') return '';
return date("d/m/Y", strtotime($d));
}
if ($stmt->rowCount() === 0) {
echo "<tr><td colspan='5' class='text-muted'>Nessuna matrice presente</td></tr>";
echo "<tr><td colspan='6' class='text-muted'>Nessuna matrice presente</td></tr>";
} else {
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$dataIT = formatDateIT($row['data_produzione']);
@ -411,6 +791,7 @@
$lineeTxt = $row['linee_associate'] ?? '—';
$mescoleTxt = $row['mescole_associate'] ?? '';
$mescoleCount = (int)($row['mescole_count'] ?? 0);
$worksheetsCount = (int)($row['worksheets_count'] ?? 0);
$btnMescole = '';
if ($mescoleCount > 0) {
@ -428,6 +809,26 @@
. $btnMescole
. "</td>";
echo "<td>
<div class='d-flex justify-content-center align-items-center gap-2'>
<span class='worksheet-counter-badge " . ($worksheetsCount <= 0 ? "worksheet-counter-zero" : "") . "'>{$worksheetsCount}</span>";
if ($worksheetsCount > 0) {
echo "<button type='button'
class='btn btn-sm btn-outline-primary show-worksheets'
data-id='" . (int)$row['id'] . "'
data-nome='" . htmlspecialchars($row['nome'], ENT_QUOTES) . "'
data-bs-toggle='tooltip'
data-bs-title='Apri fogli di lavoro collegati'>
<i class='fa-solid fa-clipboard-list'></i>
</button>";
} else {
echo "<span class='text-muted small'>—</span>";
}
echo " </div>
</td>";
echo "<td>
<button class='action-btn edit'
data-id='{$row['id']}'
@ -458,6 +859,13 @@
<i class='fa-solid fa-flask'></i>
</button>
<button class='action-btn worksheets'
data-id='{$row['id']}'
data-nome='" . htmlspecialchars($row['nome'], ENT_QUOTES) . "'
data-bs-toggle='tooltip' data-bs-title='Fogli di lavoro profilo'>
<i class='fa-solid fa-clipboard-list'></i>
</button>
<button class='action-btn files'
data-id='{$row['id']}'
data-nome='" . htmlspecialchars($row['nome'], ENT_QUOTES) . "'
@ -696,6 +1104,67 @@
</div>
</div>
<!-- MODALE LISTA FOGLI DI LAVORO -->
<div class="modal fade" id="worksheetsListModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-worksheet-list">
<div class="modal-content">
<div class="modal-header" style="background:linear-gradient(135deg,#e7f1ff,#d6e9ff);">
<div>
<h5 class="modal-title mb-0">
<i class="fa-solid fa-clipboard-list me-2"></i>Fogli di lavoro collegati
</h5>
<small class="text-muted">Elenco fogli associati al profilo selezionato</small>
</div>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<input type="hidden" id="wl_idmatrice">
<div class="fw-semibold mb-3" id="wl_matrice_name" style="color:#0b3d91;"></div>
<div id="worksheetsListContainer">
<div class="text-muted">Caricamento fogli di lavoro...</div>
</div>
</div>
</div>
</div>
</div>
<!-- MODALE DETTAGLIO FOGLIO DI LAVORO -->
<div class="modal fade" id="worksheetDetailModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable modal-worksheet-view">
<div class="modal-content" style="min-height:92vh;">
<div class="modal-header" style="background:linear-gradient(135deg,#ede9fe,#ddd6fe);">
<div>
<h5 class="modal-title mb-0">
<i class="fa-solid fa-file-lines me-2"></i>Dettaglio foglio di lavoro
</h5>
<small class="text-muted">Visualizzazione completa in sola lettura</small>
</div>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body" id="worksheetDetailContainer">
<div class="text-muted">Caricamento dettaglio foglio...</div>
</div>
</div>
</div>
</div>
<!-- MODALE PREVIEW FILE -->
<div class="modal fade" id="filePreviewModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable" style="max-width:1400px; width:98vw;">
<div class="modal-content" style="height:92vh;">
<div class="modal-header" style="background-color:#b9ebc7;">
<h5 class="modal-title" id="filePreviewTitle">Anteprima file</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div id="filePreviewContainer" style="height:calc(92vh - 64px); overflow:hidden; background:#f8fafc;"></div>
</div>
</div>
</div>
<?php include('jsinclude.php'); ?>
<script>
@ -752,6 +1221,17 @@
return ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'heic', 'heif'].includes(ext);
}
function valueOrDash(v) {
return (v === null || v === undefined || String(v).trim() === '') ? '—' : escapeHtml(v);
}
function renderReadonlyField(label, value) {
return `
<div class="readonly-label">${escapeHtml(label)}</div>
<div class="readonly-value">${valueOrDash(value)}</div>
`;
}
let selectedAttachmentFiles = [];
function renderSelectedAttachments() {
@ -941,6 +1421,262 @@
modal.show();
}
function loadMatriceWorksheets(idmatrice, matriceNome) {
$("#wl_idmatrice").val(idmatrice);
$("#wl_matrice_name").html(`<span class="worksheet-chip"><i class="fa-solid fa-layer-group"></i>${escapeHtml(matriceNome || '')}</span>`);
$("#worksheetsListContainer").html('<div class="text-muted">Caricamento fogli di lavoro...</div>');
fetch(window.location.href, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: 'ajax=1&action=get_matrice_worksheets&idmatrice=' + encodeURIComponent(idmatrice)
})
.then(r => r.json())
.then(data => {
if (!data.success) {
$("#worksheetsListContainer").html('<div class="text-danger">Errore nel caricamento dei fogli</div>');
return;
}
const rows = data.worksheets || [];
if (!rows.length) {
$("#worksheetsListContainer").html('<div class="text-muted">Nessun foglio di lavoro collegato a questo profilo</div>');
return;
}
let html = `
<div class="table-responsive">
<table class="table table-striped align-middle worksheet-list-table">
<thead>
<tr>
<th style="width:90px;">ID</th>
<th style="width:140px;">Data foglio</th>
<th>Cliente</th>
<th>Codice profilo</th>
<th style="width:110px;">Mescole</th>
<th style="width:230px;">Azioni</th>
</tr>
</thead>
<tbody>
`;
rows.forEach(r => {
html += `
<tr>
<td><strong>#${r.id}</strong></td>
<td>${escapeHtml(r.worksheet_date_it || '—')}</td>
<td title="${escapeHtml(r.customer_name || '')}">${escapeHtml(r.customer_name || '—')}</td>
<td>${escapeHtml(r.profile_type_code || '—')}</td>
<td>${escapeHtml(String(r.mix_count || 0))}</td>
<td class="text-nowrap">
<button type="button"
class="btn btn-view-worksheet open-worksheet-detail"
data-id="${r.id}">
<i class="fa-solid fa-eye me-1"></i>Apri dettaglio
</button>
<a class="worksheet-open-link ms-1"
href="manage-worksheet.php?id=${r.id}"
target="_blank">
<i class="fa-solid fa-arrow-up-right-from-square"></i>Apri pagina
</a>
</td>
</tr>
`;
});
html += `
</tbody>
</table>
</div>
`;
$("#worksheetsListContainer").html(html);
})
.catch(() => {
$("#worksheetsListContainer").html('<div class="text-danger">Errore nel caricamento dei fogli</div>');
});
}
function loadWorksheetDetail(worksheetId) {
$("#worksheetDetailContainer").html('<div class="text-muted">Caricamento dettaglio foglio...</div>');
fetch(window.location.href, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: 'ajax=1&action=get_worksheet_detail&worksheet_id=' + encodeURIComponent(worksheetId)
})
.then(r => r.json())
.then(data => {
if (!data.success) {
$("#worksheetDetailContainer").html('<div class="text-danger">Errore nel caricamento del dettaglio foglio</div>');
return;
}
const ws = data.worksheet || {};
const mixRows = data.mix_rows || [];
let mixHtml = `
<div class="text-muted">Nessuna mescola associata</div>
`;
if (mixRows.length) {
mixHtml = `
<div class="table-responsive">
<table class="table table-striped align-middle mix-readonly-table">
<thead>
<tr>
<th style="width:80px;">Pos</th>
<th>Mescola</th>
<th style="width:120px;">Peso g/m</th>
<th style="width:140px;">Densità</th>
<th style="width:150px;">Durezza</th>
<th style="width:130px;">Lubr.</th>
<th>Note lubr.</th>
</tr>
</thead>
<tbody>
`;
mixRows.forEach(r => {
const nomeMescola = r.mescola_uscita ?
`${escapeHtml(r.mescola_nome || '—')} <div class="small text-muted">${escapeHtml(r.mescola_uscita)}</div>` :
escapeHtml(r.mescola_nome || '—');
mixHtml += `
<tr>
<td>${escapeHtml(String(r.mix_position || ''))}</td>
<td>${nomeMescola}</td>
<td>${valueOrDash(r.mix_weight_g_m)}</td>
<td>${valueOrDash(r.required_density)}</td>
<td>${valueOrDash(r.required_hardness_shore_a)}</td>
<td>${valueOrDash(r.lubrication_type)}</td>
<td>${valueOrDash(r.lubrication_notes)}</td>
</tr>
`;
});
mixHtml += `
</tbody>
</table>
</div>
`;
}
const html = `
<div class="worksheet-title-box mb-4">
<div class="d-flex justify-content-between align-items-start gap-3 flex-wrap">
<div>
<h4 class="mb-1">Foglio di lavoro #${escapeHtml(String(ws.id || ''))}</h4>
<small>Profilo: ${escapeHtml(ws.matrice_nome || '—')} ${ws.matrice_cliente ? '• Cliente matrice: ' + escapeHtml(ws.matrice_cliente) : ''}</small>
</div>
<div>
<a href="manage-worksheet.php?id=${escapeHtml(String(ws.id || ''))}"
target="_blank"
class="worksheet-open-link">
<i class="fa-solid fa-arrow-up-right-from-square"></i>
Apri foglio completo
</a>
</div>
</div>
</div>
<div class="row g-3">
<div class="col-lg-6">
<div class="readonly-card">
<div class="readonly-card-header">Dati principali</div>
<div class="readonly-card-body">
<div class="readonly-grid">
${renderReadonlyField('ID foglio', ws.id)}
${renderReadonlyField('Data foglio', ws.worksheet_date_it)}
${renderReadonlyField('Cliente override', ws.customer_name)}
${renderReadonlyField('Codice profilo', ws.profile_type_code)}
${renderReadonlyField('Marchiatura', ws.marking)}
${renderReadonlyField('Approvato da', ws.approved_by)}
${renderReadonlyField('Creato il', ws.created_at_it)}
${renderReadonlyField('Ultimo aggiornamento', ws.updated_at_it)}
</div>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="readonly-card">
<div class="readonly-card-header">Controlli produzione</div>
<div class="readonly-card-body">
<div class="readonly-grid">
${renderReadonlyField('Taglio', ws.control_frequency_cut)}
${renderReadonlyField('Disegno', ws.control_frequency_drawing)}
${renderReadonlyField('Dima', ws.control_frequency_jig)}
${renderReadonlyField('Modalità dima', ws.control_mode_jig)}
</div>
<hr>
<div class="readonly-label mb-2">Impostazione misure controllo produzione</div>
<div class="readonly-value" style="white-space:pre-wrap;">${valueOrDash(ws.prod_control_measure_settings)}</div>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="readonly-card">
<div class="readonly-card-header">Packaging / Confezionamento</div>
<div class="readonly-card-body">
<div class="readonly-grid">
${renderReadonlyField('Codice confezione', ws.requested_package_code)}
${renderReadonlyField('Metri per confezione', ws.meters_per_package)}
${renderReadonlyField('Tolleranza metri/conf.', ws.meters_per_package_tolerance)}
${renderReadonlyField('Scatola tipo', ws.box_type)}
${renderReadonlyField('Conf./pezzi per scatola', ws.packages_or_pieces_per_box)}
${renderReadonlyField('Metri per scatola', ws.meters_per_box)}
${renderReadonlyField('Bancale tipo', ws.pallet_type)}
${renderReadonlyField('Scatole/conf. per bancale', ws.boxes_or_packages_per_pallet)}
</div>
<hr>
<div class="readonly-label mb-2">Note metri / confezione</div>
<div class="readonly-value" style="white-space:pre-wrap;">${valueOrDash(ws.meters_per_package_notes)}</div>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="readonly-card">
<div class="readonly-card-header">Velocità e note</div>
<div class="readonly-card-body">
<div class="readonly-grid">
${renderReadonlyField('Vel. prevista kg/h', ws.speed_expected_kg_h)}
${renderReadonlyField('Vel. effettiva kg/h', ws.speed_actual_kg_h)}
${renderReadonlyField('Vel. prevista m/h', ws.speed_expected_m_h)}
${renderReadonlyField('Vel. effettiva m/h', ws.speed_actual_m_h)}
</div>
<hr>
<div class="readonly-label mb-2">Note</div>
<div class="readonly-value" style="white-space:pre-wrap;">${valueOrDash(ws.notes)}</div>
</div>
</div>
</div>
<div class="col-12">
<div class="readonly-card">
<div class="readonly-card-header">Mescole associate al foglio</div>
<div class="readonly-card-body">
${mixHtml}
</div>
</div>
</div>
</div>
`;
$("#worksheetDetailContainer").html(html);
})
.catch(() => {
$("#worksheetDetailContainer").html('<div class="text-danger">Errore nel caricamento del dettaglio foglio</div>');
});
}
$(document).ready(function() {
$('#tabellaMatrici').DataTable({
@ -953,7 +1689,7 @@
return data;
}
}, {
targets: 4,
targets: 5,
orderable: false,
searchable: false
}],
@ -1119,7 +1855,6 @@
const $sel = $("#mm_mescole");
$sel.empty();
// Placeholder temporaneo mentre carica
const loadingOption = new Option("Caricamento mescole...", "", false, false);
$sel.append(loadingOption).trigger("change");
@ -1381,6 +2116,22 @@
document.getElementById('filePreviewModal').addEventListener('hidden.bs.modal', function() {
$("#filePreviewContainer").html("");
});
// OPEN WORKSHEETS LIST
$(document).on("click", ".worksheets, .show-worksheets", function() {
const idmatrice = $(this).data("id");
const nome = $(this).data("nome") || "";
loadMatriceWorksheets(idmatrice, nome);
new bootstrap.Modal(document.getElementById('worksheetsListModal')).show();
});
// OPEN WORKSHEET DETAIL
$(document).on("click", ".open-worksheet-detail", function() {
const worksheetId = $(this).data("id");
loadWorksheetDetail(worksheetId);
new bootstrap.Modal(document.getElementById('worksheetDetailModal')).show();
});
});
$(document).on("click", ".thumb-img", function() {
@ -1395,19 +2146,6 @@
});
});
</script>
<!-- MODALE PREVIEW FILE -->
<div class="modal fade" id="filePreviewModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable" style="max-width:1400px; width:98vw;">
<div class="modal-content" style="height:92vh;">
<div class="modal-header" style="background-color:#b9ebc7;">
<h5 class="modal-title" id="filePreviewTitle">Anteprima file</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div id="filePreviewContainer" style="height:calc(92vh - 64px); overflow:hidden; background:#f8fafc;"></div>
</div>
</div>
</div>
</body>
</html>