fixed view and multi
This commit is contained in:
parent
dd9d109dee
commit
77e5820dcc
@ -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]);
|
||||
|
||||
@ -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
|
||||
|
||||
@ -167,7 +167,7 @@ $rows_special = array_filter($rows, function ($r) {
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<div class="wrapper toggled">
|
||||
<?php include('include/navbar.php'); ?>
|
||||
<?php include('include/topbar.php'); ?>
|
||||
|
||||
@ -191,6 +191,7 @@ $rows_special = array_filter($rows, function ($r) {
|
||||
<table id="tabSpecialManager" class="table table-hover align-middle mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Conf. Ord.</th>
|
||||
<th>Matrice</th>
|
||||
<th>Mescola</th>
|
||||
<th>Linea</th>
|
||||
@ -220,6 +221,7 @@ $rows_special = array_filter($rows, function ($r) {
|
||||
data-id="<?= (int)$r['id'] ?>"
|
||||
data-seconds="<?= $sec ?>"
|
||||
style="--rowcolor: <?= htmlspecialchars($r['line_color']) ?>;">
|
||||
<td><?= htmlspecialchars($r['conferma_ordine'] ?? '') ?></td>
|
||||
<td><?= htmlspecialchars($r['matrice']) ?></td>
|
||||
<?php
|
||||
$mescRaw = $r['mescole_list'] ?? '';
|
||||
@ -306,6 +308,7 @@ $rows_special = array_filter($rows, function ($r) {
|
||||
<table id="tabManager" class="table table-hover align-middle" style="width:100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Conf. Ord.</th>
|
||||
<th>Matrice</th>
|
||||
<th>Mescola</th>
|
||||
<th>Linea</th>
|
||||
@ -334,6 +337,7 @@ $rows_special = array_filter($rows, function ($r) {
|
||||
<tr data-id="<?= (int)$r['id'] ?>"
|
||||
data-status="<?= (int)$r['id_status'] ?>"
|
||||
style="background-color: <?= htmlspecialchars($r['line_color']) ?>;">
|
||||
<td><?= htmlspecialchars($r['conferma_ordine'] ?? '') ?></td>
|
||||
<td><?= htmlspecialchars($r['matrice']) ?></td>
|
||||
<?php
|
||||
$mescRaw = $r['mescole_list'] ?? '';
|
||||
@ -615,7 +619,54 @@ $rows_special = array_filter($rows, function ($r) {
|
||||
$("#imagePreviewModal").hide();
|
||||
}
|
||||
});
|
||||
|
||||
// ===== MODALE MESCOLE (Multi) =====
|
||||
$(document).on("click", ".showMescole", function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
// prendo la stringa grezza dall’attributo, NON .data()
|
||||
const raw = $(this).attr("data-list") || "[]";
|
||||
let list = [];
|
||||
|
||||
try {
|
||||
list = JSON.parse(raw);
|
||||
} catch (err) {
|
||||
console.error("Errore parsing mescole:", err, raw);
|
||||
list = [];
|
||||
}
|
||||
|
||||
let html = "";
|
||||
list.forEach(m => {
|
||||
html += `<li style="margin:4px 0;">${m}</li>`;
|
||||
});
|
||||
|
||||
$("#mescoleList").html(html || '<li style="margin:4px 0;">Nessuna mescola</li>');
|
||||
|
||||
const modalEl = document.getElementById('mescoleModal');
|
||||
const modal = bootstrap.Modal.getOrCreateInstance(modalEl);
|
||||
modal.show();
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- MODALE MESCOLE -->
|
||||
<div class="modal fade" id="mescoleModal" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Mescole utilizzate</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Chiudi"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<ul id="mescoleList" style="padding-left:1rem;"></ul>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary btn-sm" data-bs-dismiss="modal">Chiudi</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@ -220,7 +220,7 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<div class="wrapper toggled">
|
||||
<?php include('include/navbar.php'); ?>
|
||||
<?php include('include/topbar.php'); ?>
|
||||
|
||||
|
||||
@ -895,7 +895,7 @@ if (!empty($_GET['ajax'])) {
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<div class="wrapper toggled">
|
||||
<?php include('include/navbar.php'); ?>
|
||||
<?php include('include/topbar.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'])) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="it">
|
||||
@ -337,7 +355,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<div class="wrapper toggled">
|
||||
<?php include('include/navbar.php');
|
||||
include('include/topbar.php'); ?>
|
||||
<div class="page-wrapper">
|
||||
@ -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'])) {
|
||||
<table id="tabSpecial" class="table table-hover align-middle" style="width:100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Conf. Ord.</th>
|
||||
<th>Matrice</th>
|
||||
<th>Mescola</th>
|
||||
<th>Linea</th>
|
||||
@ -433,7 +453,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
||||
|
||||
|
||||
|
||||
|
||||
<td><?= htmlspecialchars($r['conferma_ordine']) ?></td>
|
||||
<td><?= htmlspecialchars($r['matrice']) ?></td>
|
||||
<td><?= htmlspecialchars($r['mescola']) ?></td>
|
||||
<td data-line-id="<?= $r['id_linea'] ?>"><?= htmlspecialchars($r['linea']) ?></td>
|
||||
@ -494,6 +514,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
||||
<tr>
|
||||
<th style="width:30px;"></th>
|
||||
<th>Priority</th>
|
||||
<th>Conf. Ord.</th>
|
||||
<th>Matrice</th>
|
||||
<th>Mescola</th>
|
||||
<th>Linea</th>
|
||||
@ -535,6 +556,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
||||
<tr>
|
||||
<th style="width:30px;"></th>
|
||||
<th></th>
|
||||
<th>Conf. Ord.</th>
|
||||
<th>Matrice</th>
|
||||
<th>Mescola</th>
|
||||
<th>Linea</th>
|
||||
@ -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'])) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
@ -875,6 +925,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Conferma d'ordine</label>
|
||||
<input type="text" class="form-control" name="conferma_ordine">
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Data</label>
|
||||
<input type="date" class="form-control" name="Data" required>
|
||||
|
||||
@ -49,11 +49,19 @@ $statusNome = $r['status_nome'];
|
||||
<!-- RIGA VISIBILE -->
|
||||
<div class="record-summary">
|
||||
<div class="summary-grid">
|
||||
<div>
|
||||
<strong>Conf. Ord.</strong>
|
||||
<span data-field="conferma_ordine">
|
||||
<?= htmlspecialchars($r['conferma_ordine'] ?? '') ?>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div><strong>Linea</strong> <span><?= htmlspecialchars($r['linea']) ?></span></div>
|
||||
<div><strong>Matrice</strong> <span><?= htmlspecialchars($r['matrice']) ?></span></div>
|
||||
|
||||
<?php
|
||||
// Ricostruzione mescole con nuova struttura
|
||||
$mescRaw = $r['mescole_list'] ?? ''; // il campo viene da GROUP_CONCAT
|
||||
$mescRaw = $r['mescole_list'] ?? ''; // il campo viene da GROUP_CONCAT
|
||||
$mescArray = $mescRaw !== '' ? explode(' | ', $mescRaw) : [];
|
||||
$mescCount = count($mescArray);
|
||||
?>
|
||||
@ -76,6 +84,7 @@ $statusNome = $r['status_nome'];
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div><strong>Cliente</strong> <span><?= htmlspecialchars($r['cliente'] ?? '-') ?></span></div>
|
||||
<div><strong>Zibo</strong> <span><?= $dataZibo ?></span></div>
|
||||
<div><strong>Data Cl.</strong> <span><?= $dataCliente ?></span></div>
|
||||
@ -91,6 +100,7 @@ $statusNome = $r['status_nome'];
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- RIGA ESPANSA -->
|
||||
<div class="record-expanded">
|
||||
<?php if ($isInProduction || $isPaused): ?>
|
||||
|
||||
@ -14,7 +14,13 @@
|
||||
<td></td>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<td>
|
||||
<span class="view"><?= htmlspecialchars($r['conferma_ordine']) ?></span>
|
||||
<input class="inline-edit form-control form-control-sm"
|
||||
type="text"
|
||||
name="conferma_ordine"
|
||||
value="<?= htmlspecialchars($r['conferma_ordine']) ?>">
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<span class='view'><?= $r['matrice'] ?></span>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user