added multiple imballaggi
This commit is contained in:
@@ -9,6 +9,17 @@ $pdo = $db->getConnection();
|
||||
// --- LISTE LINEE ---
|
||||
$linee = $pdo->query("SELECT id, name, color FROM production_lines ORDER BY line_number")->fetchAll();
|
||||
|
||||
// --- LINEA PREFERITA DELL'UTENTE (NULL = Tutte) ---
|
||||
$preferredLineId = null;
|
||||
if (!empty($iduserlogin)) {
|
||||
$stmtPref = $pdo->prepare("SELECT preferred_line_id FROM auth_users WHERE id = :uid LIMIT 1");
|
||||
$stmtPref->execute(['uid' => (int)$iduserlogin]);
|
||||
$val = $stmtPref->fetchColumn();
|
||||
if ($val !== false && $val !== null) {
|
||||
$preferredLineId = (int)$val;
|
||||
}
|
||||
}
|
||||
|
||||
// --- STATUS DINAMICI ---
|
||||
$statusProgrammato = $pdo->query("SELECT id, nome, badge_color, line_color FROM production_status WHERE id = 6 LIMIT 1")->fetch();
|
||||
$statusProduzione = $pdo->query("SELECT id, nome, badge_color, line_color FROM production_status WHERE id = 2 LIMIT 1")->fetch();
|
||||
@@ -988,6 +999,38 @@ if (!empty($_GET['ajax'])) {
|
||||
color: #475569 !important;
|
||||
}
|
||||
|
||||
/* --- TAB LINEE (selezione singola) --- */
|
||||
.line-tab {
|
||||
flex: 1 1 auto;
|
||||
min-width: 130px;
|
||||
padding: 0.9rem 0.5rem;
|
||||
font-size: 1.3rem;
|
||||
font-weight: 800;
|
||||
border: 2px solid #e2e8f0;
|
||||
border-radius: 0.9rem 0.9rem 0 0;
|
||||
background: #f1f5f9;
|
||||
color: #64748b;
|
||||
cursor: pointer;
|
||||
transition: 0.15s;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.line-tab:hover {
|
||||
background: #e2e8f0;
|
||||
}
|
||||
|
||||
.line-tab.active {
|
||||
background: var(--line-color, #1d4ed8);
|
||||
color: #fff;
|
||||
border-color: transparent;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
/* il tab "TUTTI" attivo usa un blu neutro */
|
||||
.line-tab[data-line="all"].active {
|
||||
background: #1d4ed8;
|
||||
}
|
||||
|
||||
|
||||
/* Modale più grande e ottimizzata */
|
||||
.custom-modal .modal-content.final-wide {
|
||||
@@ -1329,25 +1372,21 @@ if (!empty($_GET['ajax'])) {
|
||||
</div>
|
||||
|
||||
<div class="filters">
|
||||
<div class="filter-group">
|
||||
<label>Linee</label>
|
||||
|
||||
<div id="lineButtons" style="display:flex; gap:0.8rem;">
|
||||
<div class="filter-group" style="flex:1 1 100%;">
|
||||
<div id="lineTabs" style="display:flex; gap:0.6rem; flex-wrap:wrap;">
|
||||
<button class="line-tab" data-line="all">TUTTI</button>
|
||||
<?php foreach ($linee as $l): ?>
|
||||
<button
|
||||
class="line-btn active"
|
||||
data-line="<?= $l['id'] ?>"
|
||||
<button class="line-tab"
|
||||
data-line="<?= (int)$l['id'] ?>"
|
||||
style="--line-color: <?= htmlspecialchars($l['color']) ?>;">
|
||||
<?= htmlspecialchars($l['name']) ?>
|
||||
</button>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<!-- Campo nascosto che userà JS per passare le linee selezionate -->
|
||||
<input type="hidden" id="filterLine" value="">
|
||||
<input type="hidden" id="preferredLine" value="<?= $preferredLineId !== null ? (int)$preferredLineId : '' ?>">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="recordsContainer">
|
||||
@@ -1671,43 +1710,32 @@ if (!empty($_GET['ajax'])) {
|
||||
beep.play().catch(() => {});
|
||||
}
|
||||
|
||||
// --- BOTTONI LINEE ---
|
||||
let selectedLines = [];
|
||||
// --- TAB LINEE (selezione singola) ---
|
||||
// Imposta il filtro nascosto in base al tab: "all" = vuoto (tutte), altrimenti l'id.
|
||||
function setActiveTab($tab) {
|
||||
$('#lineTabs .line-tab').removeClass('active');
|
||||
$tab.addClass('active');
|
||||
const line = $tab.data('line');
|
||||
$('#filterLine').val(line === 'all' ? '' : String(line));
|
||||
}
|
||||
|
||||
// inizialmente selezioniamo tutte
|
||||
$('#lineButtons .line-btn').each(function() {
|
||||
selectedLines.push($(this).data('line'));
|
||||
});
|
||||
$('#filterLine').val(selectedLines.join(','));
|
||||
|
||||
|
||||
// logica pulsanti
|
||||
$(document).on('click', '.line-btn', function() {
|
||||
const id = $(this).data('line');
|
||||
|
||||
if ($(this).hasClass('active')) {
|
||||
// se la deseleziono
|
||||
$(this).removeClass('active').addClass('inactive');
|
||||
selectedLines = selectedLines.filter(l => l !== id);
|
||||
} else {
|
||||
// se la seleziono
|
||||
$(this).removeClass('inactive').addClass('active');
|
||||
selectedLines.push(id);
|
||||
}
|
||||
|
||||
// assicurati che non sia vuoto
|
||||
if (selectedLines.length === 0) {
|
||||
// se deselezionano tutto → riseleziona tutto
|
||||
$('#lineButtons .line-btn').removeClass('inactive').addClass('active');
|
||||
selectedLines = $('#lineButtons .line-btn').map(function() {
|
||||
return $(this).data('line');
|
||||
}).get();
|
||||
}
|
||||
|
||||
$('#filterLine').val(selectedLines.join(','));
|
||||
// Click sui tab
|
||||
$(document).on('click', '.line-tab', function() {
|
||||
setActiveTab($(this));
|
||||
loadRecords();
|
||||
});
|
||||
|
||||
// Tab iniziale: preferita dell'utente se impostata, altrimenti "TUTTI"
|
||||
(function initLineTab() {
|
||||
const pref = $('#preferredLine').val();
|
||||
let $start = $('#lineTabs .line-tab[data-line="all"]');
|
||||
if (pref !== '') {
|
||||
const $prefTab = $('#lineTabs .line-tab[data-line="' + pref + '"]');
|
||||
if ($prefTab.length) $start = $prefTab;
|
||||
}
|
||||
setActiveTab($start);
|
||||
})();
|
||||
|
||||
function escapeHtml(str) {
|
||||
return String(str || '')
|
||||
.replace(/&/g, '&')
|
||||
|
||||
Reference in New Issue
Block a user