diff --git a/public/userarea/ajax_update_priority.php b/public/userarea/ajax_update_priority.php index 482c88a..7cd5c30 100644 --- a/public/userarea/ajax_update_priority.php +++ b/public/userarea/ajax_update_priority.php @@ -3,22 +3,31 @@ require_once("include/headscript.php"); $db = DBHandlerSelect::getInstance(); $pdo = $db->getConnection(); -$programmati = json_decode($_POST["programmati"], true); -$daProgrammare = json_decode($_POST["daProgrammare"], true); +$programmati = json_decode($_POST["programmati"] ?? '[]', true); +$daProgrammare = json_decode($_POST["daProgrammare"] ?? '[]', true); $pdo->beginTransaction(); foreach ($programmati as $p) { - $stmt = $pdo->prepare("UPDATE productiondata SET id_status=6, priority=? WHERE id=?"); - $stmt->execute([$p["priority"], $p["id"]]); + if (empty($p['id'])) { + continue; + } + $stmt = $pdo->prepare( + "UPDATE productiondata SET id_status=6, priority=? WHERE id=?" + ); + $stmt->execute([(int)$p["priority"], (int)$p["id"]]); } foreach ($daProgrammare as $p) { - $stmt = $pdo->prepare("UPDATE productiondata SET id_status=1, priority=? WHERE id=?"); - $stmt->execute([$p["priority"], $p["id"]]); + if (empty($p['id'])) { + continue; + } + $stmt = $pdo->prepare( + "UPDATE productiondata SET id_status=1, priority=? WHERE id=?" + ); + $stmt->execute([(int)$p["priority"], (int)$p["id"]]); } - $pdo->commit(); echo json_encode(["success" => true]); diff --git a/public/userarea/assets/js/app.js b/public/userarea/assets/js/app.js index 60f9784..5002ea9 100644 --- a/public/userarea/assets/js/app.js +++ b/public/userarea/assets/js/app.js @@ -37,6 +37,16 @@ $(function () { }, )); }), + // NEW: se la pagina parte già con .wrapper.toggled, abilita subito l'hover + $(".wrapper").hasClass("toggled") && + $(".sidebar-wrapper").hover( + function () { + $(".wrapper").addClass("sidebar-hovered"); + }, + function () { + $(".wrapper").removeClass("sidebar-hovered"); + }, + ), $(document).ready(function () { $(window).on("scroll", function () { $(this).scrollTop() > 300 diff --git a/public/userarea/manager_produzione.php b/public/userarea/manager_produzione.php index b8ba1c9..5891ae1 100644 --- a/public/userarea/manager_produzione.php +++ b/public/userarea/manager_produzione.php @@ -167,7 +167,7 @@ $rows_special = array_filter($rows, function ($r) { -
+
@@ -191,6 +191,7 @@ $rows_special = array_filter($rows, function ($r) { + @@ -220,6 +221,7 @@ $rows_special = array_filter($rows, function ($r) { data-id="" data-seconds="" style="--rowcolor: ;"> + + @@ -334,6 +337,7 @@ $rows_special = array_filter($rows, function ($r) { + { + html += `
  • ${m}
  • `; + }); + + $("#mescoleList").html(html || '
  • Nessuna mescola
  • '); + + const modalEl = document.getElementById('mescoleModal'); + const modal = bootstrap.Modal.getOrCreateInstance(modalEl); + modal.show(); + }); + + + + \ No newline at end of file diff --git a/public/userarea/production_dashboard.php b/public/userarea/production_dashboard.php index 127f805..44436c0 100644 --- a/public/userarea/production_dashboard.php +++ b/public/userarea/production_dashboard.php @@ -220,7 +220,7 @@ -
    +
    diff --git a/public/userarea/production_line_view2.php b/public/userarea/production_line_view2.php index 7c4bbc9..5d0e0c9 100644 --- a/public/userarea/production_line_view2.php +++ b/public/userarea/production_line_view2.php @@ -895,7 +895,7 @@ if (!empty($_GET['ajax'])) { -
    +
    diff --git a/public/userarea/produzione_programmazione_drag.php b/public/userarea/produzione_programmazione_drag.php index 4afec16..ea39fa8 100644 --- a/public/userarea/produzione_programmazione_drag.php +++ b/public/userarea/produzione_programmazione_drag.php @@ -24,21 +24,6 @@ function selectOptions($arr, $sel = null, $val = 'id', $txt = 'nome') if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) { $action = $_POST['action']; - $data = [ - 'idmatrice' => $_POST['idmatrice'], - 'id_linea' => $_POST['id_linea'], - 'id_cliente' => $_POST['id_cliente'] ?: null, - 'data_zibo' => $_POST['data_zibo'] ?: null, - 'data_cliente' => $_POST['data_cliente'] ?: null, - 'metri' => $_POST['metri'] ?: 0, - 'kg_sp' => $_POST['kg_sp'] ?: 0, - 'kg_p' => $_POST['kg_p'] ?: 0, - 'ore_previste' => $_POST['ore_previste'] ?: 0, - 'note_extra' => $_POST['note_extra'] ?: null, - 'id_status' => $_POST['id_status'] ?? 1 - ]; - - try { // ============================ @@ -46,24 +31,42 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) { // ============================ if ($action === 'insert') { + $dataInsert = [ + 'Data' => $_POST['Data'], + 'data_produzione' => $_POST['data_produzione'], + 'idmatrice' => $_POST['idmatrice'], + 'id_linea' => $_POST['id_linea'], + 'id_cliente' => $_POST['id_cliente'] ?: null, + 'data_zibo' => $_POST['data_zibo'] ?: null, + 'data_cliente' => $_POST['data_cliente'] ?: null, + 'metri' => $_POST['metri'] ?: 0, + 'kg_sp' => $_POST['kg_sp'] ?: 0, + 'kg_p' => $_POST['kg_p'] ?: 0, + 'ore_previste' => $_POST['ore_previste'] ?: 0, + 'note_extra' => $_POST['note_extra'] ?: null, + 'id_status' => $_POST['id_status'] ?? 1, + 'conferma_ordine' => $_POST['conferma_ordine'] ?: null, + ]; + $sql = "INSERT INTO productiondata - (Data, idmatrice, id_linea, id_cliente, data_zibo, data_cliente, - metri, kg_sp, kg_p, ore_previste, note_extra, data_produzione, id_status) + (Data, data_produzione, conferma_ordine, + idmatrice, id_linea, id_cliente, data_zibo, data_cliente, + metri, kg_sp, kg_p, ore_previste, note_extra, id_status) VALUES - (:Data, :idmatrice, :id_linea, :id_cliente, :data_zibo, :data_cliente, - :metri, :kg_sp, :kg_p, :ore_previste, :note_extra, :data_produzione, :id_status)"; + (:Data, :data_produzione, :conferma_ordine, + :idmatrice, :id_linea, :id_cliente, :data_zibo, :data_cliente, + :metri, :kg_sp, :kg_p, :ore_previste, :note_extra, :id_status)"; $stmt = $pdo->prepare($sql); - $stmt->execute($data); + $stmt->execute($dataInsert); - // QUI devi prendere il nuovo ID + // nuovo ID $idProd = $pdo->lastInsertId(); - // cancella vecchie associazioni (non serve ma per sicurezza) + // reset associazioni mescole $pdo->prepare("DELETE FROM productiondata_mescole WHERE id_productiondata=?") ->execute([$idProd]); - // aggiungi nuove if (!empty($_POST['mescole'])) { $ins = $pdo->prepare("INSERT INTO productiondata_mescole (id_productiondata, id_mescola) VALUES (?, ?)"); foreach ($_POST['mescole'] as $m) { @@ -79,27 +82,41 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) { // ============================ elseif ($action === 'update' && !empty($_POST['id'])) { - $data['id'] = $_POST['id']; + $dataUpdate = [ + 'id' => $_POST['id'], + 'idmatrice' => $_POST['idmatrice'], + 'id_linea' => $_POST['id_linea'], + 'id_cliente' => $_POST['id_cliente'] ?: null, + 'data_zibo' => $_POST['data_zibo'] ?: null, + 'data_cliente' => $_POST['data_cliente'] ?: null, + 'metri' => $_POST['metri'] ?: 0, + 'kg_sp' => $_POST['kg_sp'] ?: 0, + 'kg_p' => $_POST['kg_p'] ?: 0, + 'ore_previste' => $_POST['ore_previste'] ?: 0, + 'note_extra' => $_POST['note_extra'] ?: null, + 'id_status' => $_POST['id_status'] ?? 1, + 'conferma_ordine' => $_POST['conferma_ordine'] ?: null, + ]; $sql = "UPDATE productiondata SET - idmatrice=:idmatrice, - id_linea=:id_linea, - id_cliente=:id_cliente, - data_zibo=:data_zibo, - data_cliente=:data_cliente, - metri=:metri, - kg_sp=:kg_sp, - kg_p=:kg_p, - ore_previste=:ore_previste, - note_extra=:note_extra, - id_status=:id_status - WHERE id = :id - "; + idmatrice = :idmatrice, + id_linea = :id_linea, + id_cliente = :id_cliente, + data_zibo = :data_zibo, + data_cliente = :data_cliente, + metri = :metri, + kg_sp = :kg_sp, + kg_p = :kg_p, + ore_previste = :ore_previste, + note_extra = :note_extra, + id_status = :id_status, + conferma_ordine = :conferma_ordine + WHERE id = :id"; $stmt = $pdo->prepare($sql); - $stmt->execute($data); + $stmt->execute($dataUpdate); - // QUI devi usare L'ID ESISTENTE ! + // ID esistente $idProd = $_POST['id']; $pdo->prepare("DELETE FROM productiondata_mescole WHERE id_productiondata=?") @@ -122,6 +139,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) { } } + ?> @@ -337,7 +355,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) { -
    +
    @@ -371,6 +389,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) { GROUP_CONCAT(ms.id SEPARATOR ',') AS mescole_ids, l.name AS linea, c.nome AS cliente, + p.conferma_ordine, s.nome AS status_nome, COALESCE(s.badge_color, '#6c757d') AS badge_color, COALESCE(s.line_color, '#ffffff') AS line_color @@ -402,6 +421,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
    Conf. Ord. Matrice Mescola Linea
    Conf. Ord. Matrice Mescola Linea
    + @@ -433,7 +453,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) { - + @@ -494,6 +514,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) { + @@ -535,6 +556,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) { + @@ -804,17 +826,32 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) { document.addEventListener("DOMContentLoaded", function() { let sortProgrammati = Sortable.create(document.getElementById("programmatiBlock"), { - group: "prod", + group: { + name: "prod", + pull: true, + put: true + }, + forceFallback: true, + fallbackOnBody: true, + fallbackTolerance: 3, animation: 150, onEnd: updatePriority }); let sortDaProgrammare = Sortable.create(document.getElementById("daProgrammareBlock"), { - group: "prod", + group: { + name: "prod", + pull: true, + put: true + }, + forceFallback: true, + fallbackOnBody: true, + fallbackTolerance: 3, animation: 150, onEnd: updatePriority }); + // disabilito sortable sulla tabella special (è sola lettura) const specialTbody = document.querySelector("#tabSpecial tbody"); if (specialTbody) { @@ -830,24 +867,36 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) { let programmati = []; let daProgrammare = []; - // → Righe nella tabella PROGRAMMATI (status deve diventare 6) + // → PROGRAMMATI (status 6) $("#programmatiBlock tr").each(function(index) { + const id = $(this).data("id"); + + // se il TR non ha data-id (es. riga child DataTables) lo salto + if (typeof id === "undefined" || id === null || id === "") { + return; // continue + } + programmati.push({ - id: $(this).data("id"), + id: id, priority: index + 1, status: 6 }); }); - // → Righe nella tabella DA PROGRAMMARE (status deve diventare 1) + // → DA PROGRAMMARE (status 1) $("#daProgrammareBlock tr").each(function(index) { + const id = $(this).data("id"); + + if (typeof id === "undefined" || id === null || id === "") { + return; // continue + } + daProgrammare.push({ - id: $(this).data("id"), + id: id, priority: index + 1 }); }); - $.post("ajax_update_priority.php", { programmati: JSON.stringify(programmati), daProgrammare: JSON.stringify(daProgrammare) @@ -861,6 +910,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) { } + }); @@ -875,6 +925,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) { - +
    Conf. Ord. Matrice Mescola Linea
    PriorityConf. Ord. Matrice Mescola Linea
    Conf. Ord. Matrice Mescola Linea + + +