update mescole and photo diagram
@ -13,11 +13,12 @@ foreach ($programmati as $p) {
|
||||
$stmt->execute([$p["priority"], $p["id"]]);
|
||||
}
|
||||
|
||||
foreach ($daProgrammare as $id) {
|
||||
$stmt = $pdo->prepare("UPDATE productiondata SET id_status=1, priority=NULL WHERE id=?");
|
||||
$stmt->execute([$id]);
|
||||
foreach ($daProgrammare as $p) {
|
||||
$stmt = $pdo->prepare("UPDATE productiondata SET id_status=1, priority=? WHERE id=?");
|
||||
$stmt->execute([$p["priority"], $p["id"]]);
|
||||
}
|
||||
|
||||
|
||||
$pdo->commit();
|
||||
|
||||
echo json_encode(["success" => true]);
|
||||
|
||||
BIN
public/userarea/assets/placeholder-photo.png
Normal file
|
After Width: | Height: | Size: 1.0 MiB |
43
public/userarea/components/param_grid.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
// Recupero foto esistenti
|
||||
$photosSlots = [];
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT param_position, filename
|
||||
FROM production_photos
|
||||
WHERE production_id = ?
|
||||
AND photo_type = 'parametri_macchina'
|
||||
");
|
||||
$stmt->execute([$r['id']]);
|
||||
|
||||
foreach ($stmt->fetchAll() as $p) {
|
||||
$photosSlots[(int)$p['param_position']] = $p['filename'];
|
||||
}
|
||||
|
||||
// Slot dinamici per la linea
|
||||
$slots = $r['param_slots'] ?? [];
|
||||
|
||||
if (empty($slots)) {
|
||||
echo "<div style='color:#999; padding:8px;'>Nessun parametro configurato per questa linea.</div>";
|
||||
return;
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="param-grid" style="grid-template-columns: repeat(<?= count($slots) ?>, 1fr);">
|
||||
<?php foreach ($slots as $slot): ?>
|
||||
<?php
|
||||
$pos = (int)$slot['position'];
|
||||
$label = htmlspecialchars($slot['short_label']);
|
||||
$img = $photosSlots[$pos] ?? null;
|
||||
?>
|
||||
<div class="param-slot" data-slot="<?= $pos ?>" data-production="<?= $r['id'] ?>">
|
||||
<div class="thumb">
|
||||
<?php if ($img): ?>
|
||||
<img src="photos/<?= htmlspecialchars($img) ?>" class="thumb-img">
|
||||
<?php else: ?>
|
||||
<img src="assets/placeholder-photo.png" class="thumb-img">
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="param-label"><?= $label ?></div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
@ -1,4 +1,4 @@
|
||||
<div class="photo-actions" style="margin-top:12px; display:flex; gap:12px;">
|
||||
<div class="photo-actions" style="margin-top:12px; display:flex; gap:12px; width:100%; align-items:center;">
|
||||
|
||||
<!-- Lotto mescola -->
|
||||
<button class="photo-btn"
|
||||
@ -24,4 +24,17 @@
|
||||
<i class="bi bi-exclamation-triangle" style="font-size:1.8rem; color:#b91c1c;"></i>
|
||||
</button>
|
||||
|
||||
<!-- 🔥 SPAZIO PER PORTARE A DESTRA -->
|
||||
<div style="flex-grow:1;"></div>
|
||||
|
||||
<!-- 🔵 ICONA QUALITÀ -->
|
||||
<button class="photo-btn qc-btn"
|
||||
data-production="<?= $r['id'] ?>"
|
||||
title="Controlli Qualità">
|
||||
<i class="bi bi-droplet-half"></i>
|
||||
</button>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
@ -20,24 +20,41 @@
|
||||
⚠️ Errore durante il caricamento.
|
||||
</div>
|
||||
|
||||
|
||||
<form id="photoForm" enctype="multipart/form-data">
|
||||
|
||||
<input type="hidden" name="production_id" id="photoProductionId">
|
||||
<input type="hidden" name="photo_type" id="photoType">
|
||||
<input type="hidden" name="param_position" id="photoParamPosition">
|
||||
|
||||
<!-- ✅ input file DENTRO al form -->
|
||||
<input type="file" name="photo" id="photoInput"
|
||||
accept="image/*;capture=camera"
|
||||
style="display:none;">
|
||||
|
||||
<div class="mb-3">
|
||||
<label><strong>Carica o scatta una foto:</strong></label>
|
||||
<input type="file" name="photo" accept="image/*;capture=camera"
|
||||
class="input-big" required>
|
||||
<button type="button" class="modal-btn" id="choosePhotoBtn">Scegli foto</button>
|
||||
<span id="selectedPhotoName" style="margin-left:8px; font-size:0.85rem; color:#64748b;"></span>
|
||||
</div>
|
||||
|
||||
<!-- 🔥 loader -->
|
||||
<div id="photoLoading"
|
||||
style="display:none; margin-top:10px; font-size:0.9rem; color:#64748b;">
|
||||
⏳ Caricamento in corso...
|
||||
</div>
|
||||
|
||||
<div id="singlePhotoInfo"
|
||||
style="display:none; margin-top:10px; font-size:0.9rem; color:#b91c1c; text-align:left;">
|
||||
Per questo parametro è già presente una foto.
|
||||
Se vuoi sostituirla, chiedi all'amministratore di cancellare quella esistente.
|
||||
</div>
|
||||
|
||||
|
||||
<div class="modal-buttons" style="margin-top:1.5rem;">
|
||||
<button type="button" id="photoCancel" class="modal-btn modal-cancel">Annulla</button>
|
||||
<button type="submit" class="modal-btn modal-confirm">Carica</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<hr style="margin:1.5rem 0;">
|
||||
|
||||
<h4 style="font-size:1rem; margin-bottom:0.7rem;">Foto già registrate per questa tipologia</h4>
|
||||
@ -46,9 +63,5 @@
|
||||
style="display:flex; flex-wrap:wrap; gap:10px; max-height:220px; overflow-y:auto; padding:4px 0;">
|
||||
<!-- thumbnails caricati via JS -->
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@ -8,22 +8,39 @@ try {
|
||||
|
||||
$production_id = isset($_GET['production_id']) ? (int)$_GET['production_id'] : 0;
|
||||
$photo_type = $_GET['photo_type'] ?? '';
|
||||
$slot = isset($_GET['param_position']) ? (int)$_GET['param_position'] : null;
|
||||
|
||||
if ($production_id <= 0 || $photo_type === '') {
|
||||
throw new Exception("Parametri non validi");
|
||||
}
|
||||
|
||||
$stmt = $pdo->prepare("
|
||||
// QUERY BASE
|
||||
$sql = "
|
||||
SELECT id, filename, photo_type, created_at, elaborato
|
||||
FROM production_photos
|
||||
WHERE production_id = :prod AND photo_type = :ptype
|
||||
ORDER BY created_at DESC, id DESC
|
||||
");
|
||||
$stmt->execute([
|
||||
WHERE production_id = :prod
|
||||
AND photo_type = :ptype
|
||||
";
|
||||
|
||||
// SE È PARAMETRO MACCHINA → FILTRO PER POSIZIONE
|
||||
if ($photo_type === 'parametri_macchina') {
|
||||
$sql .= " AND param_position = :slot";
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY created_at DESC, id DESC";
|
||||
|
||||
$stmt = $pdo->prepare($sql);
|
||||
|
||||
$params = [
|
||||
':prod' => $production_id,
|
||||
':ptype' => $photo_type
|
||||
]);
|
||||
];
|
||||
|
||||
if ($photo_type === 'parametri_macchina') {
|
||||
$params[':slot'] = $slot;
|
||||
}
|
||||
|
||||
$stmt->execute($params);
|
||||
$photos = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
echo json_encode([
|
||||
|
||||
@ -8,22 +8,33 @@ $linee = $pdo->query("SELECT id, line_number, name FROM production_lines ORDER B
|
||||
$status_list = $pdo->query("SELECT id, nome, badge_color, line_color FROM production_status ORDER BY ordinamento, nome")->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// --- CARICO TUTTE LE PRODUZIONI UNA VOLTA SOLA ---
|
||||
$sql = "SELECT
|
||||
$sql = "
|
||||
SELECT
|
||||
p.*,
|
||||
m.nome AS matrice,
|
||||
ms.nome AS mescola,
|
||||
l.name AS linea,
|
||||
c.nome AS cliente,
|
||||
s.nome AS status_nome,
|
||||
COALESCE(s.badge_color, '#6c757d') AS badge_color,
|
||||
COALESCE(s.line_color, '#ffffff') AS line_color
|
||||
COALESCE(s.line_color, '#ffffff') AS line_color,
|
||||
|
||||
/* 🔥 NUOVA LISTA MESCOLE MULTI */
|
||||
GROUP_CONCAT(ms.nome ORDER BY ms.nome SEPARATOR ' | ') AS mescole_list
|
||||
|
||||
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
|
||||
ORDER BY p.data_produzione DESC, p.Data DESC, p.id DESC";
|
||||
|
||||
/* NUOVA JOIN A TABELLA MESCOLE */
|
||||
LEFT JOIN productiondata_mescole pm ON p.id = pm.id_productiondata
|
||||
LEFT JOIN mescole ms ON pm.id_mescola = ms.id
|
||||
|
||||
GROUP BY p.id
|
||||
ORDER BY p.data_produzione DESC, p.Data DESC, p.id DESC
|
||||
";
|
||||
|
||||
|
||||
$rows = $pdo->query($sql)->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
@ -210,7 +221,24 @@ $rows_special = array_filter($rows, function ($r) {
|
||||
data-seconds="<?= $sec ?>"
|
||||
style="--rowcolor: <?= htmlspecialchars($r['line_color']) ?>;">
|
||||
<td><?= htmlspecialchars($r['matrice']) ?></td>
|
||||
<td><?= htmlspecialchars($r['mescola']) ?></td>
|
||||
<?php
|
||||
$mescRaw = $r['mescole_list'] ?? '';
|
||||
$mescArray = $mescRaw !== '' ? explode(' | ', $mescRaw) : [];
|
||||
$mescCount = count($mescArray);
|
||||
?>
|
||||
<td>
|
||||
<?php if ($mescCount === 0): ?>
|
||||
<span style="color:#999;">N/A</span>
|
||||
<?php elseif ($mescCount === 1): ?>
|
||||
<?= htmlspecialchars($mescArray[0]) ?>
|
||||
<?php else: ?>
|
||||
<button class="btn btn-warning btn-sm showMescole"
|
||||
data-list="<?= htmlspecialchars(json_encode($mescArray), ENT_QUOTES) ?>">
|
||||
Multi (<?= $mescCount ?>)
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
|
||||
<td><?= htmlspecialchars($r['linea']) ?></td>
|
||||
<td><?= htmlspecialchars($r['cliente']) ?></td>
|
||||
<td><?= htmlspecialchars($r['data_zibo']) ?></td>
|
||||
@ -307,7 +335,24 @@ $rows_special = array_filter($rows, function ($r) {
|
||||
data-status="<?= (int)$r['id_status'] ?>"
|
||||
style="background-color: <?= htmlspecialchars($r['line_color']) ?>;">
|
||||
<td><?= htmlspecialchars($r['matrice']) ?></td>
|
||||
<td><?= htmlspecialchars($r['mescola']) ?></td>
|
||||
<?php
|
||||
$mescRaw = $r['mescole_list'] ?? '';
|
||||
$mescArray = $mescRaw !== '' ? explode(' | ', $mescRaw) : [];
|
||||
$mescCount = count($mescArray);
|
||||
?>
|
||||
<td>
|
||||
<?php if ($mescCount === 0): ?>
|
||||
<span style="color:#999;">N/A</span>
|
||||
<?php elseif ($mescCount === 1): ?>
|
||||
<?= htmlspecialchars($mescArray[0]) ?>
|
||||
<?php else: ?>
|
||||
<button class="btn btn-warning btn-sm showMescole"
|
||||
data-list="<?= htmlspecialchars(json_encode($mescArray), ENT_QUOTES) ?>">
|
||||
Multi (<?= $mescCount ?>)
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
|
||||
<td><?= htmlspecialchars($r['linea']) ?></td>
|
||||
<td><?= htmlspecialchars($r['cliente']) ?></td>
|
||||
<td><?= htmlspecialchars($r['data_zibo']) ?></td>
|
||||
|
||||
69
public/userarea/match_matrici_foto.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
require_once("include/headscript.php");
|
||||
|
||||
$db = DBHandlerSelect::getInstance();
|
||||
$pdo = $db->getConnection();
|
||||
|
||||
$folder = __DIR__ . "/photos/matrici/"; // cartella corretta
|
||||
$files = scandir($folder);
|
||||
|
||||
function normalize($str)
|
||||
{
|
||||
$str = strtolower($str);
|
||||
$str = preg_replace('/[^a-z0-9]/', '', $str); // rimuove tutto ciò che non è alfanumerico
|
||||
return $str;
|
||||
}
|
||||
|
||||
// Carico matrici
|
||||
$sql = "SELECT id, nome FROM matrice";
|
||||
$matrici = $pdo->query($sql)->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
$matched = [];
|
||||
$unmatchedPhotos = [];
|
||||
|
||||
foreach ($files as $file) {
|
||||
|
||||
// ignora file nascosti, . e ..
|
||||
if ($file === "." || $file === "..") continue;
|
||||
|
||||
$fileNoExt = pathinfo($file, PATHINFO_FILENAME);
|
||||
$normFile = normalize($fileNoExt);
|
||||
|
||||
$found = false;
|
||||
|
||||
foreach ($matrici as $m) {
|
||||
|
||||
$normNome = normalize($m['nome']);
|
||||
|
||||
if ($normNome === "") continue; // evita errori su record vuoti
|
||||
|
||||
// MATCHING: inizia con oppure contiene
|
||||
if (strpos($normFile, $normNome) === 0 || strpos($normFile, $normNome) !== false) {
|
||||
|
||||
$update = $pdo->prepare("UPDATE matrice SET photo = ? WHERE id = ?");
|
||||
$update->execute([$file, $m['id']]);
|
||||
|
||||
$matched[] = [$file, $m['nome']];
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$found) {
|
||||
$unmatchedPhotos[] = $file;
|
||||
}
|
||||
}
|
||||
|
||||
// RISULTATO:
|
||||
|
||||
echo "<h2>✔ FOTO ASSOCIATE</h2>";
|
||||
if (empty($matched)) echo "Nessuna foto trovata";
|
||||
foreach ($matched as $m) {
|
||||
echo "✔ <strong>{$m[0]}</strong> → Matrice: <strong>{$m[1]}</strong><br>";
|
||||
}
|
||||
|
||||
echo "<hr><h2>❌ FOTO NON ASSOCIATE</h2>";
|
||||
if (empty($unmatchedPhotos)) echo "Tutte le foto hanno trovato una matrice!";
|
||||
foreach ($unmatchedPhotos as $u) {
|
||||
echo "❌ <strong>$u</strong><br>";
|
||||
}
|
||||
@ -38,18 +38,10 @@
|
||||
.back-dashboard {
|
||||
background-color: #b9ebc7 !important;
|
||||
color: #1f2d3d !important;
|
||||
border: 1px solid #a1d7b4 !important;
|
||||
border-radius: 10px;
|
||||
font-weight: 600;
|
||||
font-size: 1rem;
|
||||
padding: 10px 18px;
|
||||
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
|
||||
transition: all 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
.back-dashboard:hover {
|
||||
background-color: #a1dfb1 !important;
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.btn-add {
|
||||
@ -57,29 +49,13 @@
|
||||
color: #fff;
|
||||
border-radius: 8px;
|
||||
padding: 10px 20px;
|
||||
font-weight: 500;
|
||||
transition: all 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
.btn-add:hover {
|
||||
background-color: #157347;
|
||||
transform: scale(1.02);
|
||||
}
|
||||
|
||||
.table thead {
|
||||
background-color: #b9ebc7;
|
||||
color: #1f2d3d;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.table tbody td {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
border-radius: 16px;
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
border: none;
|
||||
background: none;
|
||||
@ -88,26 +64,26 @@
|
||||
margin: 0 4px;
|
||||
}
|
||||
|
||||
.action-btn.edit {
|
||||
.edit {
|
||||
color: #0d6efd;
|
||||
}
|
||||
|
||||
.action-btn.delete {
|
||||
.delete {
|
||||
color: #dc3545;
|
||||
}
|
||||
|
||||
.action-btn.linee {
|
||||
.linee {
|
||||
color: #198754;
|
||||
}
|
||||
|
||||
.action-btn.mescole {
|
||||
.mescole {
|
||||
color: #ff9800;
|
||||
}
|
||||
|
||||
.dataTables_filter input {
|
||||
border-radius: 8px;
|
||||
padding: 6px 10px;
|
||||
border: 1px solid #ced4da;
|
||||
.thumb-img:hover {
|
||||
transform: scale(1.05);
|
||||
transition: 0.2s;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
@ -120,14 +96,14 @@
|
||||
<div class="page-wrapper">
|
||||
<div class="page-content">
|
||||
<div class="card p-3">
|
||||
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<h5 class="mb-0">Gestione Matrici</h5>
|
||||
<button type="button" class="btn back-dashboard" onclick="location.href='production_dashboard.php'">
|
||||
↩️ Torna alla Dashboard
|
||||
</button>
|
||||
<button type="button" class="btn back-dashboard" onclick="location.href='production_dashboard.php'">↩️ Torna alla Dashboard</button>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<h6 class="fw-semibold mb-0">Elenco Completo</h6>
|
||||
<button class="btn btn-add" data-bs-toggle="modal" data-bs-target="#addMatriceModal">➕ Aggiungi Matrice</button>
|
||||
@ -138,33 +114,98 @@
|
||||
<table id="tabellaMatrici" class="table table-striped align-middle text-center">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Nome Matrice</th>
|
||||
<th>Foto</th>
|
||||
<th>Nome</th>
|
||||
<th>Cliente</th>
|
||||
<th>Data</th>
|
||||
<th>Azioni</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
<?php
|
||||
$db = DBHandlerSelect::getInstance();
|
||||
$pdo = $db->getConnection();
|
||||
|
||||
$stmt = $pdo->query("SELECT * FROM matrice ORDER BY id DESC");
|
||||
|
||||
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='3' class='text-muted'>Nessuna matrice presente</td></tr>";
|
||||
echo "<tr><td colspan='5' class='text-muted'>Nessuna matrice presente</td></tr>";
|
||||
} else {
|
||||
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
echo "<tr>
|
||||
<td>{$row['id']}</td>
|
||||
<td>" . htmlspecialchars($row['nome']) . "</td>
|
||||
<td>
|
||||
<button class='action-btn edit' data-id='{$row['id']}' data-nome='" . htmlspecialchars($row['nome'], ENT_QUOTES) . "'><i class='fa-solid fa-pen-to-square'></i></button>
|
||||
<button class='action-btn delete' data-id='{$row['id']}'><i class='fa-solid fa-trash'></i></button>
|
||||
<button class='action-btn linee' data-id='{$row['id']}' data-nome='" . htmlspecialchars($row['nome'], ENT_QUOTES) . "'><i class='fa-solid fa-sitemap'></i></button>
|
||||
<button class='action-btn mescole' data-id='{$row['id']}' data-nome='" . htmlspecialchars($row['nome'], ENT_QUOTES) . "'><i class='fa-solid fa-flask'></i></button>
|
||||
</td>
|
||||
</tr>";
|
||||
|
||||
$dataIT = formatDateIT($row['data_produzione']);
|
||||
|
||||
// gestione foto
|
||||
$foto = $row['photo'] ?? '';
|
||||
$pathFoto = "photos/matrici/" . $foto;
|
||||
$placeholder = "assets/images/no-photo.png";
|
||||
|
||||
if ($foto && file_exists($pathFoto)) {
|
||||
$thumb = $pathFoto;
|
||||
$hasPhoto = true;
|
||||
} else {
|
||||
$thumb = $placeholder;
|
||||
$hasPhoto = false;
|
||||
}
|
||||
|
||||
echo "<tr>";
|
||||
|
||||
// colonna FOTO
|
||||
echo "<td>
|
||||
<img src='" . htmlspecialchars($thumb, ENT_QUOTES) . "'
|
||||
class='thumb-img'
|
||||
data-full='" . htmlspecialchars($thumb, ENT_QUOTES) . "'
|
||||
style='height:60px; cursor:pointer; border-radius:6px; opacity:" . ($hasPhoto ? "1" : "0.6") . ";'
|
||||
title='" . ($hasPhoto ? "Clicca per ingrandire" : "") . "'>
|
||||
</td>";
|
||||
|
||||
// colonna NOME
|
||||
echo "<td>" . htmlspecialchars($row['nome']) . "</td>";
|
||||
|
||||
// colonna CLIENTE
|
||||
echo "<td>" . htmlspecialchars($row['cliente']) . "</td>";
|
||||
|
||||
// colonna DATA
|
||||
echo "<td>{$dataIT}</td>";
|
||||
|
||||
// colonna AZIONI
|
||||
echo "<td>
|
||||
<button class='action-btn edit'
|
||||
data-id='{$row['id']}'
|
||||
data-nome='" . htmlspecialchars($row['nome'], ENT_QUOTES) . "'
|
||||
data-cliente='" . htmlspecialchars($row['cliente'], ENT_QUOTES) . "'
|
||||
data-data='{$dataIT}'>
|
||||
<i class='fa-solid fa-pen-to-square'></i>
|
||||
</button>
|
||||
|
||||
<button class='action-btn delete' data-id='{$row['id']}'>
|
||||
<i class='fa-solid fa-trash'></i>
|
||||
</button>
|
||||
|
||||
<button class='action-btn linee' data-id='{$row['id']}' data-nome='" . htmlspecialchars($row['nome'], ENT_QUOTES) . "'>
|
||||
<i class='fa-solid fa-sitemap'></i>
|
||||
</button>
|
||||
|
||||
<button class='action-btn mescole' data-id='{$row['id']}' data-nome='" . htmlspecialchars($row['nome'], ENT_QUOTES) . "'>
|
||||
<i class='fa-solid fa-flask'></i>
|
||||
</button>
|
||||
</td>";
|
||||
|
||||
echo "</tr>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@ -176,82 +217,59 @@
|
||||
<?php include('include/footer.php'); ?>
|
||||
</div>
|
||||
|
||||
<!-- MODALE AGGIUNTA / MODIFICA -->
|
||||
<div class="modal fade" id="addMatriceModal" tabindex="-1" aria-labelledby="addMatriceLabel" aria-hidden="true">
|
||||
<!-- MODALE AGGIUNTA / MODIFICA MATRICE -->
|
||||
<div class="modal fade" id="addMatriceModal" tabindex="-1">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
|
||||
<div class="modal-header" style="background-color:#b9ebc7;">
|
||||
<h5 class="modal-title" id="addMatriceLabel">Aggiungi / Modifica Matrice</h5>
|
||||
<h5 class="modal-title">Aggiungi / Modifica Matrice</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<form id="addMatriceForm">
|
||||
<input type="hidden" id="idMatriceEdit">
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="nomeMatrice" class="form-label fw-semibold">Nome Matrice</label>
|
||||
<input type="text" class="form-control" id="nomeMatrice" name="nomeMatrice" required>
|
||||
<label class="fw-semibold">Nome Matrice</label>
|
||||
<input type="text" class="form-control" id="nomeMatrice" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="fw-semibold">Cliente</label>
|
||||
<input type="text" class="form-control" id="clienteMatrice">
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="fw-semibold">Data</label>
|
||||
<input type="text" class="form-control" id="dataMatrice" placeholder="dd/mm/yyyy">
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
<button type="submit" class="btn btn-add">💾 Salva</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- MODALE ASSOCIA LINEE -->
|
||||
<div class="modal fade" id="associaLineeModal" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header" style="background-color:#b9ebc7;">
|
||||
<h5 class="modal-title">Associa Linee</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="associaLineeForm">
|
||||
<input type="hidden" id="idMatriceLinee">
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold">Linee di Produzione</label>
|
||||
<select id="lineeSelect" name="linee[]" class="form-select" multiple required style="width:100%;"></select>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<button type="submit" class="btn btn-add">💾 Salva Associazioni</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- MODALE ASSOCIA MESCOLE -->
|
||||
<div class="modal fade" id="associaMescoleModal" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header" style="background-color:#b9ebc7;">
|
||||
<h5 class="modal-title">Associa Mescole</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="associaMescoleForm">
|
||||
<input type="hidden" id="idMatriceMescole">
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold">Mescole</label>
|
||||
<select id="mescoleSelect" name="mescole[]" class="form-select" multiple required style="width:100%;"></select>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<button type="submit" class="btn btn-add">💾 Salva Associazioni</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include('jsinclude.php'); ?>
|
||||
|
||||
<script>
|
||||
/* Format date dd/mm/yyyy → yyyy-mm-dd */
|
||||
function convertToMySQLDate(dateStr) {
|
||||
if (!dateStr) return "";
|
||||
const parts = dateStr.split("/");
|
||||
if (parts.length !== 3) return "";
|
||||
return parts[2] + "-" + parts[1] + "-" + parts[0];
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
const table = $('#tabellaMatrici').DataTable({
|
||||
|
||||
$('#tabellaMatrici').DataTable({
|
||||
order: [
|
||||
[0, 'desc']
|
||||
],
|
||||
@ -260,158 +278,83 @@
|
||||
}
|
||||
});
|
||||
|
||||
// === ADD / EDIT MATRICE ===
|
||||
$(document).on('click', '.edit', function() {
|
||||
$('#idMatriceEdit').val($(this).data('id'));
|
||||
$('#nomeMatrice').val($(this).data('nome'));
|
||||
$('#addMatriceModal').modal('show');
|
||||
// === EDIT MATRICE ===
|
||||
$(document).on("click", ".edit", function() {
|
||||
$("#idMatriceEdit").val($(this).data("id"));
|
||||
$("#nomeMatrice").val($(this).data("nome"));
|
||||
$("#clienteMatrice").val($(this).data("cliente"));
|
||||
$("#dataMatrice").val($(this).data("data"));
|
||||
$("#addMatriceModal").modal("show");
|
||||
});
|
||||
|
||||
$('#addMatriceForm').on('submit', function(e) {
|
||||
// === SALVA MATRICE ===
|
||||
$("#addMatriceForm").on("submit", function(e) {
|
||||
e.preventDefault();
|
||||
const id = $('#idMatriceEdit').val();
|
||||
const nome = $('#nomeMatrice').val().trim();
|
||||
if (nome === "") return;
|
||||
|
||||
fetch('save_matrice.php', {
|
||||
method: 'POST',
|
||||
let id = $("#idMatriceEdit").val();
|
||||
let nome = $("#nomeMatrice").val().trim();
|
||||
let cliente = $("#clienteMatrice").val().trim();
|
||||
let dataIT = $("#dataMatrice").val().trim();
|
||||
let dataSQL = convertToMySQLDate(dataIT);
|
||||
|
||||
fetch("save_matrice.php", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
"Content-Type": "application/x-www-form-urlencoded"
|
||||
},
|
||||
body: 'id=' + id + '&nome=' + encodeURIComponent(nome)
|
||||
}).then(r => r.json()).then(data => {
|
||||
body: "id=" + id + "&nome=" + encodeURIComponent(nome) + "&cliente=" + encodeURIComponent(cliente) + "&data=" + encodeURIComponent(dataSQL)
|
||||
})
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
Swal.fire({
|
||||
icon: data.success ? 'success' : 'error',
|
||||
title: data.success ? 'Salvata!' : 'Errore',
|
||||
text: data.message || (data.success ? 'Matrice salvata correttamente.' : 'Errore durante il salvataggio.')
|
||||
icon: data.success ? "success" : "error",
|
||||
title: data.success ? "Salvato!" : "Errore",
|
||||
text: data.message || ""
|
||||
}).then(() => location.reload());
|
||||
});
|
||||
});
|
||||
|
||||
// === DELETE MATRICE ===
|
||||
$(document).on('click', '.delete', function() {
|
||||
const id = $(this).data('id');
|
||||
$(document).on("click", ".delete", function() {
|
||||
const id = $(this).data("id");
|
||||
|
||||
Swal.fire({
|
||||
icon: 'warning',
|
||||
title: 'Eliminare questa matrice?',
|
||||
text: 'L\'operazione non è reversibile.',
|
||||
icon: "warning",
|
||||
title: "Eliminare questa matrice?",
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Sì, elimina',
|
||||
cancelButtonText: 'Annulla',
|
||||
confirmButtonColor: '#d33'
|
||||
confirmButtonColor: "#d33"
|
||||
}).then(res => {
|
||||
if (res.isConfirmed) {
|
||||
fetch('delete_matrice.php?id=' + id)
|
||||
fetch("delete_matrice.php?id=" + id)
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
Swal.fire({
|
||||
icon: data.success ? 'success' : 'error',
|
||||
title: data.success ? 'Eliminata!' : 'Errore',
|
||||
text: data.message || ''
|
||||
icon: data.success ? "success" : "error",
|
||||
title: data.success ? "Eliminata!" : "Errore"
|
||||
}).then(() => location.reload());
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// === ASSOCIA LINEE ===
|
||||
$(document).on('click', '.linee', function() {
|
||||
const id = $(this).data('id');
|
||||
const nome = $(this).data('nome');
|
||||
$('#idMatriceLinee').val(id);
|
||||
$('.modal-title').text('Associa Linee a ' + nome);
|
||||
|
||||
fetch('get_linee_matrice.php?id=' + id)
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
const sel = $('#lineeSelect');
|
||||
sel.empty();
|
||||
data.tutte.forEach(l => {
|
||||
const selected = data.associate.includes(l.id.toString()) ? 'selected' : '';
|
||||
sel.append(`<option value="${l.id}" ${selected}>${l.name} (${l.brand || ''})</option>`);
|
||||
});
|
||||
sel.select2({
|
||||
theme: 'bootstrap-5',
|
||||
width: '100%'
|
||||
});
|
||||
$('#associaLineeModal').modal('show');
|
||||
});
|
||||
});
|
||||
|
||||
$('#associaLineeForm').on('submit', e => {
|
||||
e.preventDefault();
|
||||
const id = $('#idMatriceLinee').val();
|
||||
const linee = $('#lineeSelect').val();
|
||||
fetch('save_matrice_linee.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
id,
|
||||
linee
|
||||
})
|
||||
}).then(r => r.json()).then(d => {
|
||||
Swal.fire({
|
||||
icon: d.success ? 'success' : 'error',
|
||||
title: d.success ? 'Salvato!' : 'Errore',
|
||||
text: d.message || ''
|
||||
}).then(() => location.reload());
|
||||
});
|
||||
});
|
||||
|
||||
// === ASSOCIA MESCOLE ===
|
||||
$(document).on('click', '.mescole', function() {
|
||||
const id = $(this).data('id');
|
||||
const nome = $(this).data('nome');
|
||||
$('#idMatriceMescole').val(id);
|
||||
|
||||
$('#associaMescoleModal .modal-title').text('Associa Mescole a ' + nome);
|
||||
|
||||
fetch('get_mescole_matrice.php?id=' + id)
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
const sel = $('#mescoleSelect');
|
||||
sel.empty();
|
||||
|
||||
data.tutte.forEach(m => {
|
||||
const selected = data.associate.includes(m.id.toString()) ? 'selected' : '';
|
||||
sel.append(`<option value="${m.id}" ${selected}>${m.nome}</option>`);
|
||||
});
|
||||
|
||||
sel.select2({
|
||||
theme: 'bootstrap-5',
|
||||
width: '100%'
|
||||
});
|
||||
|
||||
$('#associaMescoleModal').modal('show');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$('#associaMescoleForm').on('submit', e => {
|
||||
e.preventDefault();
|
||||
const id = $('#idMatriceMescole').val();
|
||||
const mescole = $('#mescoleSelect').val();
|
||||
fetch('save_matrice_mescole.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
id,
|
||||
mescole
|
||||
})
|
||||
}).then(r => r.json()).then(d => {
|
||||
Swal.fire({
|
||||
icon: d.success ? 'success' : 'error',
|
||||
title: d.success ? 'Salvato!' : 'Errore',
|
||||
text: d.message || ''
|
||||
}).then(() => location.reload());
|
||||
});
|
||||
});
|
||||
// thumbnail click → open modal with big photo
|
||||
$(document).on("click", ".thumb-img", function() {
|
||||
let full = $(this).data("full");
|
||||
$("#fotoGrande").attr("src", full);
|
||||
$("#fotoModal").modal("show");
|
||||
});
|
||||
</script>
|
||||
<!-- MODALE FOTO GRANDE -->
|
||||
<div class="modal fade" id="fotoModal" tabindex="-1">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||||
<div class="modal-content p-0" style="background:transparent; border:none;">
|
||||
<img id="fotoGrande" src="" style="width:100%; border-radius:10px;">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@ -75,19 +75,6 @@
|
||||
border-radius: 16px;
|
||||
}
|
||||
|
||||
.dataTables_filter input {
|
||||
border-radius: 8px;
|
||||
padding: 6px 10px;
|
||||
border: 1px solid #ced4da;
|
||||
}
|
||||
|
||||
.dataTables_wrapper .dataTables_length select {
|
||||
border-radius: 8px;
|
||||
padding: 5px;
|
||||
border: 1px solid #ced4da;
|
||||
}
|
||||
|
||||
/* Centra il testo degli header della tabella */
|
||||
#tabellaMescole thead th {
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
@ -123,6 +110,7 @@
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Nome Mescola</th>
|
||||
<th>Nome Uscita</th>
|
||||
<th>Linee Associate</th>
|
||||
<th>Azioni</th>
|
||||
</tr>
|
||||
@ -132,22 +120,25 @@
|
||||
$db = DBHandlerSelect::getInstance();
|
||||
$pdo = $db->getConnection();
|
||||
$sql = "
|
||||
SELECT m.id, m.nome,
|
||||
SELECT m.id, m.nome, m.nomeuscita,
|
||||
GROUP_CONCAT(pl.name SEPARATOR ', ') AS linee
|
||||
FROM mescole m
|
||||
LEFT JOIN mescole_lines ml ON m.id = ml.idmescola
|
||||
LEFT JOIN production_lines pl ON ml.idlinea = pl.id
|
||||
GROUP BY m.id
|
||||
ORDER BY m.id DESC";
|
||||
|
||||
$stmt = $pdo->query($sql);
|
||||
if ($stmt->rowCount() === 0) {
|
||||
echo "<tr><td colspan='4' class='text-muted'>Nessuna mescola presente</td></tr>";
|
||||
echo "<tr><td colspan='5' class='text-muted'>Nessuna mescola presente</td></tr>";
|
||||
} else {
|
||||
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
$linee = $row['linee'] ? htmlspecialchars($row['linee']) : '<span class="text-muted">Nessuna</span>';
|
||||
|
||||
echo "<tr>
|
||||
<td>{$row['id']}</td>
|
||||
<td>" . htmlspecialchars($row['nome']) . "</td>
|
||||
<td>" . htmlspecialchars($row['nomeuscita']) . "</td>
|
||||
<td>{$linee}</td>
|
||||
<td>
|
||||
<button class='btn btn-sm btn-outline-primary associa-linee'
|
||||
@ -155,6 +146,13 @@
|
||||
data-nome='" . htmlspecialchars($row['nome'], ENT_QUOTES) . "'>
|
||||
⚙️ Associa Linee
|
||||
</button>
|
||||
|
||||
<button class='btn btn-sm btn-outline-secondary edit-mescola'
|
||||
data-id='{$row['id']}'
|
||||
data-nome='" . htmlspecialchars($row['nome'], ENT_QUOTES) . "'
|
||||
data-nomeuscita='" . htmlspecialchars($row['nomeuscita'], ENT_QUOTES) . "'>
|
||||
✏️ Modifica
|
||||
</button>
|
||||
</td>
|
||||
</tr>";
|
||||
}
|
||||
@ -163,6 +161,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -172,48 +171,92 @@
|
||||
</div>
|
||||
|
||||
<!-- MODALE AGGIUNTA MESCOLA -->
|
||||
<div class="modal fade" id="addMescolaModal" tabindex="-1" aria-labelledby="addMescolaLabel" aria-hidden="true">
|
||||
<div class="modal fade" id="addMescolaModal" tabindex="-1">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header" style="background-color:#cfe3ff;">
|
||||
<h5 class="modal-title" id="addMescolaLabel">Aggiungi Nuova Mescola</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Chiudi"></button>
|
||||
<h5 class="modal-title">Aggiungi Nuova Mescola</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<form id="addMescolaForm">
|
||||
<div class="mb-3">
|
||||
<label for="nomeMescola" class="form-label fw-semibold">Nome Mescola</label>
|
||||
<input type="text" class="form-control" id="nomeMescola" name="nomeMescola" required>
|
||||
<label class="form-label fw-semibold">Nome Mescola</label>
|
||||
<input type="text" class="form-control" id="nomeMescola" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold">Nome Uscita</label>
|
||||
<input type="text" class="form-control" id="nomeUscita" required>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
<button type="submit" class="btn btn-add">💾 Salva</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- MODALE EDIT -->
|
||||
<div class="modal fade" id="editMescolaModal" tabindex="-1">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header" style="background-color:#cfe3ff;">
|
||||
<h5 class="modal-title">Modifica Mescola</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<form id="editMescolaForm">
|
||||
<input type="hidden" id="editIdMescola">
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold">Nome Mescola</label>
|
||||
<input type="text" class="form-control" id="editNomeMescola" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold">Nome Uscita</label>
|
||||
<input type="text" class="form-control" id="editNomeUscita" required>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
<button type="submit" class="btn btn-add">💾 Salva Modifiche</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- MODALE ASSOCIA LINEE -->
|
||||
<div class="modal fade" id="associaLineeModal" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal fade" id="associaLineeModal" tabindex="-1">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header" style="background-color:#cfe3ff;">
|
||||
<h5 class="modal-title">Associa Linee alla Mescola</h5>
|
||||
<h5 class="modal-title">Associa Linee</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<form id="associaLineeForm">
|
||||
<input type="hidden" id="idMescolaLinee">
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold">Linee di Produzione</label>
|
||||
<select id="lineeSelect" name="linee[]" class="form-select" multiple required style="width:100%;"></select>
|
||||
<label class="form-label fw-semibold">Linee</label>
|
||||
<select id="lineeSelect" class="form-select" multiple style="width:100%;"></select>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
<button type="submit" class="btn btn-add">💾 Salva Associazioni</button>
|
||||
<button type="submit" class="btn btn-add">💾 Salva</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -221,7 +264,7 @@
|
||||
<?php include('jsinclude.php'); ?>
|
||||
|
||||
<script>
|
||||
// Inizializza DataTables
|
||||
/* ----------------- DATATABLE ----------------- */
|
||||
$(document).ready(function() {
|
||||
$('#tabellaMescole').DataTable({
|
||||
order: [
|
||||
@ -234,62 +277,86 @@
|
||||
});
|
||||
});
|
||||
|
||||
// Inserimento mescola
|
||||
/* -------- AGGIUNTA MESCOLA -------- */
|
||||
$("#addMescolaForm").on("submit", function(e) {
|
||||
e.preventDefault();
|
||||
const nome = $("#nomeMescola").val().trim();
|
||||
|
||||
if (nome === "") {
|
||||
Swal.fire({
|
||||
icon: "warning",
|
||||
title: "Attenzione",
|
||||
text: "Inserisci il nome della mescola.",
|
||||
confirmButtonColor: "#3085d6"
|
||||
});
|
||||
return;
|
||||
}
|
||||
let nome = $("#nomeMescola").val().trim();
|
||||
let nomeuscita = $("#nomeUscita").val().trim();
|
||||
|
||||
fetch("save_mescola.php", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded"
|
||||
},
|
||||
body: "nome=" + encodeURIComponent(nome)
|
||||
body: `nome=${encodeURIComponent(nome)}&nomeuscita=${encodeURIComponent(nomeuscita)}`
|
||||
})
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
Swal.fire({
|
||||
icon: "success",
|
||||
title: "Salvata!",
|
||||
text: "La nuova mescola è stata aggiunta correttamente.",
|
||||
title: "Salvato!",
|
||||
confirmButtonColor: "#3085d6"
|
||||
}).then(() => location.reload());
|
||||
})
|
||||
.then(() => location.reload());
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Errore",
|
||||
text: data.message || "Errore durante il salvataggio.",
|
||||
confirmButtonColor: "#d33"
|
||||
text: data.message
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Errore di connessione",
|
||||
text: "Impossibile contattare il server.",
|
||||
confirmButtonColor: "#d33"
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Apertura modale Associa Linee
|
||||
/* -------- APERTURA MODALE EDIT -------- */
|
||||
$(document).on("click", ".edit-mescola", function() {
|
||||
$("#editIdMescola").val($(this).data("id"));
|
||||
$("#editNomeMescola").val($(this).data("nome"));
|
||||
$("#editNomeUscita").val($(this).data("nomeuscita"));
|
||||
$("#editMescolaModal").modal("show");
|
||||
});
|
||||
|
||||
/* -------- SALVATAGGIO EDIT -------- */
|
||||
$("#editMescolaForm").on("submit", function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
let id = $("#editIdMescola").val();
|
||||
let nome = $("#editNomeMescola").val().trim();
|
||||
let nomeuscita = $("#editNomeUscita").val().trim();
|
||||
|
||||
fetch("update_mescola.php", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded"
|
||||
},
|
||||
body: `id=${id}&nome=${encodeURIComponent(nome)}&nomeuscita=${encodeURIComponent(nomeuscita)}`
|
||||
})
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
Swal.fire({
|
||||
icon: "success",
|
||||
title: "Aggiornato!",
|
||||
confirmButtonColor: "#3085d6"
|
||||
})
|
||||
.then(() => location.reload());
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Errore",
|
||||
text: data.message
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/* -------- MODALE ASSOCIA LINEE -------- */
|
||||
$(document).on("click", ".associa-linee", function() {
|
||||
|
||||
const idMescola = $(this).data("id");
|
||||
const nomeMescola = $(this).data("nome");
|
||||
$("#idMescolaLinee").val(idMescola);
|
||||
$(".modal-title").text("Associa Linee a " + nomeMescola);
|
||||
|
||||
fetch("get_linee_mescola.php?id=" + idMescola)
|
||||
.then(r => r.json())
|
||||
@ -299,26 +366,24 @@
|
||||
|
||||
data.tutte_linee.forEach(l => {
|
||||
const selected = data.associate.includes(l.id.toString()) ? "selected" : "";
|
||||
select.append(`<option value="${l.id}" ${selected}>${l.name} (${l.brand || ''})</option>`);
|
||||
select.append(`<option value="${l.id}" ${selected}>${l.name}</option>`);
|
||||
});
|
||||
|
||||
select.select2({
|
||||
theme: "bootstrap-5",
|
||||
width: "100%",
|
||||
placeholder: "Seleziona o rimuovi linee di produzione",
|
||||
allowClear: true,
|
||||
closeOnSelect: false
|
||||
width: "100%"
|
||||
});
|
||||
|
||||
$("#associaLineeModal").modal("show");
|
||||
});
|
||||
});
|
||||
|
||||
// Salvataggio associazioni (aggiungi/rimuovi)
|
||||
/* -------- SALVATAGGIO LINEE -------- */
|
||||
$("#associaLineeForm").on("submit", function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const idMescola = $("#idMescolaLinee").val();
|
||||
const linee = $("#lineeSelect").val() || []; // se deselezionate tutte, array vuoto
|
||||
const linee = $("#lineeSelect").val() || [];
|
||||
|
||||
fetch("save_mescola_linee.php", {
|
||||
method: "POST",
|
||||
@ -335,26 +400,16 @@
|
||||
if (data.success) {
|
||||
Swal.fire({
|
||||
icon: "success",
|
||||
title: "Aggiornato!",
|
||||
text: "Associazioni aggiornate correttamente.",
|
||||
confirmButtonColor: "#3085d6"
|
||||
}).then(() => location.reload());
|
||||
title: "Aggiornato!"
|
||||
})
|
||||
.then(() => location.reload());
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Errore",
|
||||
text: data.message || "Errore durante l'aggiornamento.",
|
||||
confirmButtonColor: "#d33"
|
||||
text: data.message
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Errore di connessione",
|
||||
text: "Impossibile contattare il server.",
|
||||
confirmButtonColor: "#d33"
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
BIN
public/userarea/photos/4-10-1764689959.jpg
Normal file
|
After Width: | Height: | Size: 3.8 MiB |
BIN
public/userarea/photos/4-11-1764689976.jpg
Normal file
|
After Width: | Height: | Size: 4.0 MiB |
BIN
public/userarea/photos/4-12-1764690370.jpg
Normal file
|
After Width: | Height: | Size: 4.3 MiB |
BIN
public/userarea/photos/4-6-1764174320.png
Normal file
|
After Width: | Height: | Size: 82 KiB |
BIN
public/userarea/photos/4-8-1764689628.jpg
Normal file
|
After Width: | Height: | Size: 3.7 MiB |
BIN
public/userarea/photos/4-9-1764689649.jpg
Normal file
|
After Width: | Height: | Size: 3.8 MiB |
BIN
public/userarea/photos/matrici/00002P etichetta.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
public/userarea/photos/matrici/00049P.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
public/userarea/photos/matrici/00099P.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
public/userarea/photos/matrici/001028C.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
public/userarea/photos/matrici/00254S.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
public/userarea/photos/matrici/00292P-1.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
public/userarea/photos/matrici/00387C.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
public/userarea/photos/matrici/00394C-2 .png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
public/userarea/photos/matrici/00407P-1.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
public/userarea/photos/matrici/00513P-2.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
public/userarea/photos/matrici/00569P.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
public/userarea/photos/matrici/00621P una uscita.png
Normal file
|
After Width: | Height: | Size: 898 B |
BIN
public/userarea/photos/matrici/00666P.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
public/userarea/photos/matrici/00669C.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
public/userarea/photos/matrici/00670P.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
public/userarea/photos/matrici/00671Pbis.png
Normal file
|
After Width: | Height: | Size: 463 B |
BIN
public/userarea/photos/matrici/00672S.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
public/userarea/photos/matrici/00673P.png
Normal file
|
After Width: | Height: | Size: 435 B |
BIN
public/userarea/photos/matrici/00674P.png
Normal file
|
After Width: | Height: | Size: 861 B |
BIN
public/userarea/photos/matrici/00676P.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
public/userarea/photos/matrici/00677P.png
Normal file
|
After Width: | Height: | Size: 450 B |
BIN
public/userarea/photos/matrici/00679P-1.png
Normal file
|
After Width: | Height: | Size: 806 B |
BIN
public/userarea/photos/matrici/00679P.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
public/userarea/photos/matrici/00680C.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
public/userarea/photos/matrici/00681S.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
public/userarea/photos/matrici/00682P.png
Normal file
|
After Width: | Height: | Size: 838 B |
BIN
public/userarea/photos/matrici/00684P.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
public/userarea/photos/matrici/00685P-1.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
public/userarea/photos/matrici/00686S.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
public/userarea/photos/matrici/00687C.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
public/userarea/photos/matrici/00689S.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
public/userarea/photos/matrici/00690S.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
public/userarea/photos/matrici/00691S.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
public/userarea/photos/matrici/00692S.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
public/userarea/photos/matrici/00693C.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
public/userarea/photos/matrici/00695S.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
public/userarea/photos/matrici/00696C.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
public/userarea/photos/matrici/00698C.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
public/userarea/photos/matrici/00700P-1.png
Normal file
|
After Width: | Height: | Size: 953 B |
BIN
public/userarea/photos/matrici/00700P.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
public/userarea/photos/matrici/00701C.png
Normal file
|
After Width: | Height: | Size: 895 B |
BIN
public/userarea/photos/matrici/00702S.png
Normal file
|
After Width: | Height: | Size: 867 B |
BIN
public/userarea/photos/matrici/00703C-1.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
public/userarea/photos/matrici/00704P-1 DCL.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
public/userarea/photos/matrici/00705P.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
public/userarea/photos/matrici/00706P.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
public/userarea/photos/matrici/00707P.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
public/userarea/photos/matrici/00708C.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
public/userarea/photos/matrici/00709C.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
public/userarea/photos/matrici/00710P.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
public/userarea/photos/matrici/00711C.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
public/userarea/photos/matrici/00712P.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
public/userarea/photos/matrici/00713C.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
public/userarea/photos/matrici/00714S.png
Normal file
|
After Width: | Height: | Size: 680 B |
BIN
public/userarea/photos/matrici/00716P-2.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
public/userarea/photos/matrici/00716P-3.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
public/userarea/photos/matrici/00716P.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
public/userarea/photos/matrici/00718S.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
public/userarea/photos/matrici/00722P.png
Normal file
|
After Width: | Height: | Size: 921 B |
BIN
public/userarea/photos/matrici/00723C.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
public/userarea/photos/matrici/00724S.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
public/userarea/photos/matrici/00725P.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
public/userarea/photos/matrici/00726C.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
public/userarea/photos/matrici/00727P.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
public/userarea/photos/matrici/00728C.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
public/userarea/photos/matrici/00729P.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
public/userarea/photos/matrici/00731C.png
Normal file
|
After Width: | Height: | Size: 957 B |
BIN
public/userarea/photos/matrici/00732P.png
Normal file
|
After Width: | Height: | Size: 660 B |
BIN
public/userarea/photos/matrici/00734P.png
Normal file
|
After Width: | Height: | Size: 342 B |
BIN
public/userarea/photos/matrici/00735P.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
public/userarea/photos/matrici/00737P.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
public/userarea/photos/matrici/00738P.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
public/userarea/photos/matrici/00739P.png
Normal file
|
After Width: | Height: | Size: 889 B |
BIN
public/userarea/photos/matrici/00740C-1.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
public/userarea/photos/matrici/00747P.png
Normal file
|
After Width: | Height: | Size: 955 B |
BIN
public/userarea/photos/matrici/00749P.png
Normal file
|
After Width: | Height: | Size: 436 B |
BIN
public/userarea/photos/matrici/00750P.png
Normal file
|
After Width: | Height: | Size: 590 B |
BIN
public/userarea/photos/matrici/00751P.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
public/userarea/photos/matrici/00752P.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
public/userarea/photos/matrici/00753S.png
Normal file
|
After Width: | Height: | Size: 768 B |
BIN
public/userarea/photos/matrici/00754S.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
public/userarea/photos/matrici/00755P.png
Normal file
|
After Width: | Height: | Size: 992 B |
BIN
public/userarea/photos/matrici/00756P.png
Normal file
|
After Width: | Height: | Size: 562 B |
BIN
public/userarea/photos/matrici/00757P.png
Normal file
|
After Width: | Height: | Size: 768 B |