From 22e5b90fe4cf1c1ff183f177d2a0dac7f9143266 Mon Sep 17 00:00:00 2001 From: solocla Date: Tue, 3 Feb 2026 16:04:45 +0100 Subject: [PATCH] loopkup, foglio di lavoro --- public/userarea/lookup_values.php | 643 ++++++++++++++ public/userarea/manage-worksheet.php | 1008 ++++++++++++++++++++++ public/userarea/production_dashboard.php | 18 + public/userarea/skill_matrix.php | 63 +- public/userarea/skills.php | 530 ++++++++++++ public/userarea/worksheets.php | 273 ++++++ 6 files changed, 2505 insertions(+), 30 deletions(-) create mode 100644 public/userarea/lookup_values.php create mode 100644 public/userarea/manage-worksheet.php create mode 100644 public/userarea/skills.php create mode 100644 public/userarea/worksheets.php diff --git a/public/userarea/lookup_values.php b/public/userarea/lookup_values.php new file mode 100644 index 0000000..bb800f3 --- /dev/null +++ b/public/userarea/lookup_values.php @@ -0,0 +1,643 @@ +getConnection(); + +/** + * ws_lookup_options manager page + * Table expected: + * - id (AI) + * - category (varchar) + * - value (varchar) + * - label (varchar) + * - sort_order (int) + * - is_default (tinyint 0/1) + * - is_active (tinyint 0/1) + */ + +// AJAX HANDLERS +if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['ajax']) && $_POST['ajax'] == '1') { + header('Content-Type: application/json; charset=utf-8'); + + $action = $_POST['action'] ?? ''; + + try { + + if ($action === 'add') { + $category = trim($_POST['category'] ?? ''); + $value = trim($_POST['value'] ?? ''); + $label = trim($_POST['label'] ?? ''); + $sort_order = (int)($_POST['sort_order'] ?? 100); + $is_default = (int)($_POST['is_default'] ?? 0) ? 1 : 0; + $is_active = (int)($_POST['is_active'] ?? 1) ? 1 : 0; + + if ($category === '' || $value === '' || $label === '') { + echo json_encode(['success' => false, 'message' => 'Compila category, value e label']); + exit; + } + + $pdo->beginTransaction(); + + // If set as default, unset other defaults in same category (simple & reliable) + if ($is_default === 1) { + $stmt = $pdo->prepare("UPDATE ws_lookup_options SET is_default = 0 WHERE category = ?"); + $stmt->execute([$category]); + } + + $stmt = $pdo->prepare(" + INSERT INTO ws_lookup_options + (category, value, label, sort_order, is_default, is_active) + VALUES (?, ?, ?, ?, ?, ?) + "); + $stmt->execute([$category, $value, $label, $sort_order, $is_default, $is_active]); + + $pdo->commit(); + echo json_encode(['success' => true]); + exit; + } + + if ($action === 'edit') { + $id = (int)($_POST['id'] ?? 0); + $category = trim($_POST['category'] ?? ''); + $value = trim($_POST['value'] ?? ''); + $label = trim($_POST['label'] ?? ''); + $sort_order = (int)($_POST['sort_order'] ?? 100); + $is_default = (int)($_POST['is_default'] ?? 0) ? 1 : 0; + $is_active = (int)($_POST['is_active'] ?? 1) ? 1 : 0; + + if ($id <= 0 || $category === '' || $value === '' || $label === '') { + echo json_encode(['success' => false, 'message' => 'Dati non validi']); + exit; + } + + $pdo->beginTransaction(); + + // If set as default, unset other defaults in same category (excluding current) + if ($is_default === 1) { + $stmt = $pdo->prepare("UPDATE ws_lookup_options SET is_default = 0 WHERE category = ? AND id <> ?"); + $stmt->execute([$category, $id]); + } + + $stmt = $pdo->prepare(" + UPDATE ws_lookup_options SET + category = ?, + value = ?, + label = ?, + sort_order = ?, + is_default = ?, + is_active = ? + WHERE id = ? + "); + $stmt->execute([$category, $value, $label, $sort_order, $is_default, $is_active, $id]); + + $pdo->commit(); + echo json_encode(['success' => true]); + exit; + } + + if ($action === 'delete') { + $id = (int)($_POST['id'] ?? 0); + if ($id <= 0) { + echo json_encode(['success' => false, 'message' => 'ID non valido']); + exit; + } + + $stmt = $pdo->prepare("DELETE FROM ws_lookup_options WHERE id = ?"); + $stmt->execute([$id]); + + echo json_encode(['success' => true]); + exit; + } + + echo json_encode(['success' => false, 'message' => 'Azione sconosciuta']); + exit; + } catch (Exception $e) { + if ($pdo->inTransaction()) $pdo->rollBack(); + echo json_encode(['success' => false, 'message' => $e->getMessage()]); + exit; + } +} + +// Categories list (static for now, easy to extend) +$categories = [ + 'marking' => 'Marchiatura', + 'lubrication_type' => 'Lubrificazione', + 'control_frequency_cut' => 'Frequenza controllo (taglio)', + 'control_frequency_drawing' => 'Frequenza controllo disegno', + 'control_frequency_jig' => 'Frequenza controllo in dima', + 'control_mode_jig' => 'Modalità controllo in dima', + 'box_type' => 'Tipo scatola', + 'pallet_type' => 'Tipo bancale', + 'requested_package_code' => 'Confezione richiesta', +]; + +// Selected category filter +$categoryFilter = trim($_GET['cat'] ?? ''); +if ($categoryFilter !== '' && !array_key_exists($categoryFilter, $categories)) { + $categoryFilter = ''; +} + +// Load options +$params = []; +$sql = " + SELECT id, category, value, label, sort_order, is_default, is_active, created_at, updated_at + FROM ws_lookup_options +"; +if ($categoryFilter !== '') { + $sql .= " WHERE category = ? "; + $params[] = $categoryFilter; +} +$sql .= " ORDER BY category ASC, sort_order ASC, label ASC, id ASC "; + +$stmt = $pdo->prepare($sql); +$stmt->execute($params); +$options = $stmt->fetchAll(PDO::FETCH_ASSOC); + +function h($v) +{ + return htmlspecialchars((string)$v, ENT_QUOTES); +} +?> + + + + + + + + Lookup Worksheet + + + + + + + + + + + + + + + + +
+ + + +
+
+
+
+
+
Lookup Worksheet
+
Gestione valori predefiniti (tendine) per i campi dei fogli di lavoro
+
+ +
+ +
+
+
+
Categoria
+ +
+ + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
IDCategoryValueLabelOrdineDefaultAttivoAzioni
+ +
+ +
+
+ + +
+
+ +
+ Suggerimento: imposta Default solo per 1 valore per categoria (questa pagina lo gestisce automaticamente). +
+ +
+
+
+
+ + +
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/userarea/manage-worksheet.php b/public/userarea/manage-worksheet.php new file mode 100644 index 0000000..64ad7f6 --- /dev/null +++ b/public/userarea/manage-worksheet.php @@ -0,0 +1,1008 @@ +getConnection(); + +$worksheet_id = isset($_GET['id']) && is_numeric($_GET['id']) ? (int)$_GET['id'] : 0; + +// AJAX HANDLERS +if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['ajax']) && $_POST['ajax'] == '1') { + // Ensure clean JSON output (remove any echoed HTML/notices) + while (ob_get_level()) { + ob_end_clean(); + } + header('Content-Type: application/json; charset=utf-8'); + + header('Content-Type: application/json'); + + $action = $_POST['action'] ?? ''; + + try { + // Save header (insert/update) + if ($action === 'save_header') { + $idmatrice = (int)($_POST['idmatrice'] ?? 0); + if ($idmatrice <= 0) { + echo json_encode(['success' => false, 'message' => 'Seleziona una matrice/profilo']); + exit; + } + + $id = (int)($_POST['id'] ?? 0); + + $worksheet_date = $_POST['worksheet_date'] !== '' ? $_POST['worksheet_date'] : null; + $customer_name = trim($_POST['customer_name'] ?? ''); + $profile_code = trim($_POST['profile_type_code'] ?? ''); + $marking = ($_POST['marking'] ?? '') !== '' ? $_POST['marking'] : null; + + $prod_control = trim($_POST['prod_control_measure_settings'] ?? ''); + + $freq_cut = trim($_POST['control_frequency_cut'] ?? ''); + $freq_draw = trim($_POST['control_frequency_drawing'] ?? ''); + $freq_jig = trim($_POST['control_frequency_jig'] ?? ''); + $mode_jig = trim($_POST['control_mode_jig'] ?? ''); + + $box_type = trim($_POST['box_type'] ?? ''); + $pkg_box = $_POST['packages_or_pieces_per_box'] !== '' ? (int)$_POST['packages_or_pieces_per_box'] : null; + $m_box = $_POST['meters_per_box'] !== '' ? (int)$_POST['meters_per_box'] : null; + + $pallet_type = trim($_POST['pallet_type'] ?? ''); + $per_pallet = $_POST['boxes_or_packages_per_pallet'] !== '' ? (int)$_POST['boxes_or_packages_per_pallet'] : null; + + $sp_exp_kg = $_POST['speed_expected_kg_h'] !== '' ? (float)$_POST['speed_expected_kg_h'] : null; + $sp_act_kg = $_POST['speed_actual_kg_h'] !== '' ? (float)$_POST['speed_actual_kg_h'] : null; + $sp_exp_m = $_POST['speed_expected_m_h'] !== '' ? (float)$_POST['speed_expected_m_h'] : null; + $sp_act_m = $_POST['speed_actual_m_h'] !== '' ? (float)$_POST['speed_actual_m_h'] : null; + + $approved_by = trim($_POST['approved_by'] ?? ''); + $notes = trim($_POST['notes'] ?? ''); + + if ($id > 0) { + $stmt = $pdo->prepare(" + UPDATE work_sheets SET + idmatrice = ?, + worksheet_date = ?, + customer_name = ?, + profile_type_code = ?, + marking = ?, + prod_control_measure_settings = ?, + control_frequency_cut = ?, + control_frequency_drawing = ?, + control_frequency_jig = ?, + control_mode_jig = ?, + box_type = ?, + packages_or_pieces_per_box = ?, + meters_per_box = ?, + pallet_type = ?, + boxes_or_packages_per_pallet = ?, + speed_expected_kg_h = ?, + speed_actual_kg_h = ?, + speed_expected_m_h = ?, + speed_actual_m_h = ?, + approved_by = ?, + notes = ? + WHERE id = ? + "); + $stmt->execute([ + $idmatrice, + $worksheet_date, + $customer_name !== '' ? $customer_name : null, + $profile_code !== '' ? $profile_code : null, + $marking, + $prod_control !== '' ? $prod_control : null, + $freq_cut !== '' ? $freq_cut : null, + $freq_draw !== '' ? $freq_draw : null, + $freq_jig !== '' ? $freq_jig : null, + $mode_jig !== '' ? $mode_jig : null, + $box_type !== '' ? $box_type : null, + $pkg_box, + $m_box, + $pallet_type !== '' ? $pallet_type : null, + $per_pallet, + $sp_exp_kg, + $sp_act_kg, + $sp_exp_m, + $sp_act_m, + $approved_by !== '' ? $approved_by : null, + $notes !== '' ? $notes : null, + $id + ]); + + echo json_encode(['success' => true, 'id' => $id]); + exit; + } + + $stmt = $pdo->prepare(" + INSERT INTO work_sheets + (idmatrice, worksheet_date, customer_name, profile_type_code, marking, + prod_control_measure_settings, control_frequency_cut, control_frequency_drawing, control_frequency_jig, control_mode_jig, + box_type, packages_or_pieces_per_box, meters_per_box, + pallet_type, boxes_or_packages_per_pallet, + speed_expected_kg_h, speed_actual_kg_h, speed_expected_m_h, speed_actual_m_h, + approved_by, notes) + VALUES + (?, ?, ?, ?, ?, + ?, ?, ?, ?, ?, + ?, ?, ?, + ?, ?, + ?, ?, ?, ?, + ?, ?) + "); + $stmt->execute([ + $idmatrice, + $worksheet_date, + $customer_name !== '' ? $customer_name : null, + $profile_code !== '' ? $profile_code : null, + $marking, + $prod_control !== '' ? $prod_control : null, + $freq_cut !== '' ? $freq_cut : null, + $freq_draw !== '' ? $freq_draw : null, + $freq_jig !== '' ? $freq_jig : null, + $mode_jig !== '' ? $mode_jig : null, + $box_type !== '' ? $box_type : null, + $pkg_box, + $m_box, + $pallet_type !== '' ? $pallet_type : null, + $per_pallet, + $sp_exp_kg, + $sp_act_kg, + $sp_exp_m, + $sp_act_m, + $approved_by !== '' ? $approved_by : null, + $notes !== '' ? $notes : null + ]); + + $newId = (int)$pdo->lastInsertId(); + echo json_encode(['success' => true, 'id' => $newId]); + exit; + } + + // Add or edit mix row + if ($action === 'save_mix_row') { + $worksheet_id = (int)($_POST['worksheet_id'] ?? 0); + if ($worksheet_id <= 0) { + echo json_encode(['success' => false, 'message' => 'Salva prima il foglio (testata)']); + exit; + } + + $row_id = (int)($_POST['row_id'] ?? 0); + $idmescola = (int)($_POST['idmescola'] ?? 0); + $pos = 0; // auto-assign + + + if ($idmescola <= 0) { + echo json_encode(['success' => false, 'message' => 'Seleziona una mescola']); + exit; + } + if ($pos <= 0) $pos = 1; + + $mix_weight = $_POST['mix_weight_g_m'] !== '' ? (float)$_POST['mix_weight_g_m'] : null; + $density = trim($_POST['required_density'] ?? ''); + $hardness = trim($_POST['required_hardness_shore_a'] ?? ''); + + $lub_type = ($_POST['lubrication_type'] ?? '') !== '' ? $_POST['lubrication_type'] : null; + $lub_note = trim($_POST['lubrication_notes'] ?? ''); + + $pkg_code = trim($_POST['requested_package_code'] ?? ''); + $m_pkg = $_POST['meters_per_package'] !== '' ? (int)$_POST['meters_per_package'] : null; + $m_pkg_note = trim($_POST['meters_per_package_notes'] ?? ''); + $m_pkg_tol = trim($_POST['meters_per_package_tolerance'] ?? ''); + + // Use transaction to keep constraints consistent + $pdo->beginTransaction(); + + if ($row_id > 0) { + + // Auto-assign mix_position = max + 1 for this worksheet + $stmtPos = $pdo->prepare(" + SELECT IFNULL(MAX(mix_position), 0) + 1 + FROM work_sheet_mescole + WHERE worksheet_id = ? + FOR UPDATE + "); + $stmtPos->execute([$worksheet_id]); + $pos = (int)$stmtPos->fetchColumn(); + if ($pos <= 0) $pos = 1; + + + $stmt = $pdo->prepare(" + UPDATE work_sheet_mescole SET + idmescola = ?, + mix_weight_g_m = ?, + required_density = ?, + required_hardness_shore_a = ?, + lubrication_type = ?, + lubrication_notes = ?, + requested_package_code = ?, + meters_per_package = ?, + meters_per_package_notes = ?, + meters_per_package_tolerance = ? + WHERE id = ? AND worksheet_id = ? + "); + + $stmt->execute([ + $idmescola, + $mix_weight, + $density !== '' ? $density : null, + $hardness !== '' ? $hardness : null, + $lub_type, + $lub_note !== '' ? $lub_note : null, + $pkg_code !== '' ? $pkg_code : null, + $m_pkg, + $m_pkg_note !== '' ? $m_pkg_note : null, + $m_pkg_tol !== '' ? $m_pkg_tol : null, + $row_id, + $worksheet_id + ]); + + + $pdo->commit(); + echo json_encode(['success' => true]); + exit; + } + + // If position already used, auto-assign next (max+1) + $chk = $pdo->prepare("SELECT COUNT(*) FROM work_sheet_mescole WHERE worksheet_id = ? AND mix_position = ?"); + $chk->execute([$worksheet_id, $pos]); + if ((int)$chk->fetchColumn() > 0) { + $mx = $pdo->prepare("SELECT IFNULL(MAX(mix_position),0) + 1 FROM work_sheet_mescole WHERE worksheet_id = ?"); + $mx->execute([$worksheet_id]); + $pos = (int)$mx->fetchColumn(); + } + + + + $stmt = $pdo->prepare(" + INSERT INTO work_sheet_mescole + (worksheet_id, idmescola, mix_position, mix_weight_g_m, required_density, required_hardness_shore_a, + lubrication_type, lubrication_notes, + requested_package_code, meters_per_package, meters_per_package_notes, meters_per_package_tolerance) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + "); + $stmt->execute([ + $worksheet_id, + $idmescola, + $pos, + $mix_weight, + $density !== '' ? $density : null, + $hardness !== '' ? $hardness : null, + $lub_type, + $lub_note !== '' ? $lub_note : null, + $pkg_code !== '' ? $pkg_code : null, + $m_pkg, + $m_pkg_note !== '' ? $m_pkg_note : null, + $m_pkg_tol !== '' ? $m_pkg_tol : null + ]); + + $pdo->commit(); + echo json_encode(['success' => true]); + exit; + } + + // Delete mix row + if ($action === 'delete_mix_row') { + $row_id = (int)($_POST['row_id'] ?? 0); + if ($row_id <= 0) { + echo json_encode(['success' => false, 'message' => 'ID riga non valido']); + exit; + } + + $stmt = $pdo->prepare("DELETE FROM work_sheet_mescole WHERE id = ?"); + $stmt->execute([$row_id]); + + echo json_encode(['success' => true]); + exit; + } + + echo json_encode(['success' => false, 'message' => 'Azione sconosciuta']); + exit; + } catch (Exception $e) { + if ($pdo->inTransaction()) $pdo->rollBack(); + echo json_encode(['success' => false, 'message' => $e->getMessage()]); + exit; + } +} + +// Load matrices dropdown +$matrici = $pdo->query(" + SELECT id, nome, cliente + FROM matrice + ORDER BY nome ASC +")->fetchAll(PDO::FETCH_ASSOC); + +// Load mescole dropdown for modal +$mescole = $pdo->query(" + SELECT id, nome, nomeuscita + FROM mescole + ORDER BY nome ASC +")->fetchAll(PDO::FETCH_ASSOC); + +// Load worksheet (edit) +$worksheet = null; +$mixRows = []; + +if ($worksheet_id > 0) { + $stmt = $pdo->prepare(" + SELECT ws.*, m.nome AS matrice_nome + FROM work_sheets ws + LEFT JOIN matrice m ON ws.idmatrice = m.id + WHERE ws.id = ? + "); + $stmt->execute([$worksheet_id]); + $worksheet = $stmt->fetch(PDO::FETCH_ASSOC); + + if ($worksheet) { + $stmt = $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 + "); + $stmt->execute([$worksheet_id]); + $mixRows = $stmt->fetchAll(PDO::FETCH_ASSOC); + } else { + $worksheet_id = 0; + } +} + +// Helpers +function h($v) +{ + return htmlspecialchars((string)$v, ENT_QUOTES); +} +$isEdit = ($worksheet_id > 0); +?> + + + + + + + + + <?= $isEdit ? 'Modifica Foglio di Lavoro' : 'Nuovo Foglio di Lavoro' ?> + + + + + + + + + + + + + + + + + + +
+ + + +
+
+ +
+
+
+
+
Prima salva la testata, poi aggiungi le mescole con il modale
+
+
+ +
+
+ +
+ +
+ + +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ + +
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ + +
+ +
+ + +
+
+
+ +
+ + +
+
Mescole associate al foglio
+
Usa “Aggiungi Mescola” per inserire una o più righe
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PosMescolaPeso (g/m)DensitàDurezzaLubr.Confez.m/conf.Azioni
+ + +
+ +
+ + +
+
+ +
+
+ +
+
+ + +
+ + + + + + + + + + \ No newline at end of file diff --git a/public/userarea/production_dashboard.php b/public/userarea/production_dashboard.php index 7c5323f..7c4ce10 100644 --- a/public/userarea/production_dashboard.php +++ b/public/userarea/production_dashboard.php @@ -341,12 +341,30 @@
+ +
+ +
+ + +
+ + diff --git a/public/userarea/skill_matrix.php b/public/userarea/skill_matrix.php index 796d055..40e12a4 100644 --- a/public/userarea/skill_matrix.php +++ b/public/userarea/skill_matrix.php @@ -7,7 +7,7 @@ include('include/headscript.php'); $db = DBHandlerSelect::getInstance(); $pdo = $db->getConnection(); -// AJAX salvataggio singolo (ora gestisce anche testo libero) +// AJAX salvataggio singolo if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['ajax']) && $_POST['ajax'] == '1') { header('Content-Type: application/json'); @@ -20,8 +20,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['ajax']) && $_POST['aj $pdo->prepare("DELETE FROM employee_skills WHERE employee_id = ? AND skill_id = ?") ->execute([$employee_id, $skill_id]); - // Salva solo se c'è valore (non vuoto) - if ($level !== '') { + if ($level !== '' && $level !== '–') { $pdo->prepare("INSERT INTO employee_skills (employee_id, skill_id, level) VALUES (?, ?, ?)") ->execute([$employee_id, $skill_id, $level]); } @@ -47,7 +46,7 @@ $employees = $pdo->query(" $skills = $pdo->query(" SELECT s.id, - s.name AS nome_completo, + s.name, COALESCE(s.abbreviato, SUBSTRING(s.name, 1, 12)) AS acronimo, pl.line_number, pl.name AS linea @@ -154,10 +153,9 @@ while ($r = $stmt->fetch(PDO::FETCH_ASSOC)) { .table input[type="text"] { background: #fffacd; - /* giallo chiaro per distinguere il campo testo */ } - /* COLORI LIVELLI (solo per select) */ + /* COLORI LIVELLI */ .level-Q { background: #d4edda; color: #155724; @@ -195,6 +193,14 @@ while ($r = $stmt->fetch(PDO::FETCH_ASSOC)) { color: #6c757d; } + /* Cella vuota / trattino */ + td:empty, + td select option[value="–"]:checked~select, + td input[value=""] { + background: #f8f9fa !important; + color: #6c757d; + } + .table-responsive { overflow-x: auto; } @@ -229,7 +235,7 @@ while ($r = $stmt->fetch(PDO::FETCH_ASSOC)) { + title=""> @@ -240,29 +246,33 @@ while ($r = $stmt->fetch(PDO::FETCH_ASSOC)) { - + - - - + + - + + @@ -282,7 +292,7 @@ while ($r = $stmt->fetch(PDO::FETCH_ASSOC)) { + + + + + + + + + + + +
+ + + +
+
+
+
+
Gestione Skills
+ +
+ +
+
+
Elenco Skills
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
IDAbbreviatoOrdinamentoLineaAttrezzaturaNota ToolAzioni
+ + + + () + + + - + + + + +
+
+
+
+
+
+ + +
+ + + + + + + + + + + + + \ No newline at end of file diff --git a/public/userarea/worksheets.php b/public/userarea/worksheets.php new file mode 100644 index 0000000..a8bea84 --- /dev/null +++ b/public/userarea/worksheets.php @@ -0,0 +1,273 @@ +getConnection(); + +// AJAX HANDLERS +if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['ajax']) && $_POST['ajax'] == '1') { + header('Content-Type: application/json'); + + $action = $_POST['action'] ?? ''; + + try { + if ($action === 'delete') { + $id = (int)($_POST['id'] ?? 0); + if ($id <= 0) { + echo json_encode(['success' => false, 'message' => 'ID non valido']); + exit; + } + + // Delete header (rows will be deleted by FK cascade if constraints exist) + $stmt = $pdo->prepare("DELETE FROM work_sheets WHERE id = ?"); + $stmt->execute([$id]); + + echo json_encode(['success' => true]); + exit; + } + + echo json_encode(['success' => false, 'message' => 'Azione sconosciuta']); + exit; + } catch (Exception $e) { + echo json_encode(['success' => false, 'message' => $e->getMessage()]); + exit; + } +} + +// Worksheets list + row count +$worksheets = $pdo->query(" + SELECT + ws.id, + ws.worksheet_date, + ws.customer_name, + ws.profile_type_code, + ws.approved_by, + ws.created_at, + m.nome AS matrice_nome, + m.cliente AS matrice_cliente, + (SELECT COUNT(*) FROM work_sheet_mescole wsm WHERE wsm.worksheet_id = ws.id) AS mixes_count + FROM work_sheets ws + LEFT JOIN matrice m ON ws.idmatrice = m.id + ORDER BY ws.id DESC +")->fetchAll(PDO::FETCH_ASSOC); +?> + + + + + + + + + Fogli di Lavoro + + + + + + + + + + + + + + + + + + + +
+ + + +
+
+
+
+
Fogli di Lavoro
+ +
+ +
+
+
Storico
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IDDataMatrice/ProfiloClienteCodice ProfiloMescoleVistoCreatoAzioni
+ + + +
+
+ +
+
+
+
+ + +
+ + + + + + + \ No newline at end of file