fixed dashboard
This commit is contained in:
@@ -70,16 +70,22 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
||||
<link href="https://cdn.jsdelivr.net/npm/select2-bootstrap-5-theme@1.3.0/dist/select2-bootstrap-5-theme.min.css" rel="stylesheet">
|
||||
<link href="https://cdn.datatables.net/1.13.7/css/dataTables.bootstrap5.min.css" rel="stylesheet">
|
||||
<link href="https://cdn.datatables.net/responsive/2.5.0/css/responsive.bootstrap5.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
|
||||
|
||||
<style>
|
||||
.inline-edit {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.btn-sm {
|
||||
border-radius: .5rem;
|
||||
font-size: .8rem;
|
||||
padding: .35rem .65rem;
|
||||
.btn-xs {
|
||||
padding: 0.15rem 0.35rem;
|
||||
font-size: 0.7rem;
|
||||
line-height: 1.2;
|
||||
border-radius: .4rem;
|
||||
}
|
||||
|
||||
.btn-xs i {
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
.table td,
|
||||
@@ -126,8 +132,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.btn i {
|
||||
font-size: 1rem;
|
||||
.btn-clear-filters {
|
||||
margin-left: 0.5rem;
|
||||
padding: 0.25rem 0.5rem;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.badge {
|
||||
@@ -158,7 +166,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
||||
font-size: 0.75rem !important;
|
||||
}
|
||||
|
||||
/* TESTO PICCOLO NEI DROPDOWN SELECT2 */
|
||||
.select2-container--bootstrap-5 .select2-dropdown .select2-results__option {
|
||||
font-size: 0.75rem !important;
|
||||
padding: 0.2rem 0.5rem !important;
|
||||
@@ -167,6 +174,35 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
||||
.select2-container--bootstrap-5 .select2-selection__placeholder {
|
||||
font-size: 0.75rem !important;
|
||||
}
|
||||
|
||||
/* ICONA NOTE */
|
||||
.note-icon {
|
||||
font-size: 1.1rem;
|
||||
cursor: pointer;
|
||||
transition: color 0.2s;
|
||||
color: #6c757d;
|
||||
}
|
||||
|
||||
.note-icon.has-note {
|
||||
color: #dc3545 !important;
|
||||
}
|
||||
|
||||
.note-icon:hover {
|
||||
color: #0056b3;
|
||||
}
|
||||
|
||||
#modalNoteView .modal-body {
|
||||
white-space: pre-wrap;
|
||||
max-height: 60vh;
|
||||
overflow-y: auto;
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
|
||||
/* Flatpickr nei filtri */
|
||||
.flatpickr-input {
|
||||
font-size: 0.75rem !important;
|
||||
padding: 0.15rem 0.3rem !important;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
@@ -195,8 +231,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
||||
<th>Mescola</th>
|
||||
<th>Linea</th>
|
||||
<th>Cliente</th>
|
||||
<th>Zibo</th>
|
||||
<th>Cliente</th>
|
||||
<th>Data Zibo</th>
|
||||
<th>Data Cliente</th>
|
||||
<th>mt</th>
|
||||
<th>kg sp</th>
|
||||
<th>kg p</th>
|
||||
@@ -208,7 +244,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
||||
</tr>
|
||||
<!-- FILTRI SOPRA -->
|
||||
<tr class="filters-row bg-light">
|
||||
<th><input type="text" class="filter-input form-control form-control-sm" placeholder="Filtra"></th>
|
||||
<th><input type="text" class="filter-input form-control form-control-sm" placeholder="gg/mm/aaaa"></th>
|
||||
<th><select class="filter-select form-select form-select-sm select2">
|
||||
<option value="">Tutti</option><?= selectOptions($matrici) ?>
|
||||
</select></th>
|
||||
@@ -222,14 +258,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
||||
<option value="">Tutti</option>
|
||||
<option value="">-</option><?= selectOptions($clienti) ?>
|
||||
</select></th>
|
||||
<th><input type="text" class="filter-input form-control form-control-sm" placeholder="Zibo"></th>
|
||||
<th><input type="text" class="filter-input form-control form-control-sm" placeholder="Cliente"></th>
|
||||
<th><input type="text" class="filter-input form-control form-control-sm" placeholder="gg/mm/aaaa"></th>
|
||||
<th><input type="text" class="filter-input form-control form-control-sm" placeholder="gg/mm/aaaa"></th>
|
||||
<th><input type="text" class="filter-input form-control form-control-sm" placeholder="mt"></th>
|
||||
<th><input type="text" class="filter-input form-control form-control-sm" placeholder="kg sp"></th>
|
||||
<th><input type="text" class="filter-input form-control form-control-sm" placeholder="kg p"></th>
|
||||
<th><input type="text" class="filter-input form-control form-control-sm" placeholder="Ore"></th>
|
||||
<th><input type="text" class="filter-input form-control form-control-sm" placeholder="Note"></th>
|
||||
<th><input type="text" class="filter-input form-control form-control-sm" placeholder="Prod."></th>
|
||||
<th><input type="text" class="filter-input form-control form-control-sm" placeholder="gg/mm/aaaa"></th>
|
||||
<th><select class="filter-select form-select form-select-sm select2">
|
||||
<option value="">Tutti</option><?= selectOptions($status_list, null, 'id', 'nome') ?>
|
||||
</select></th>
|
||||
@@ -259,9 +295,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
||||
$lineColor = htmlspecialchars($r['line_color'] ?? '#ffffff');
|
||||
$badgeColor = htmlspecialchars($r['badge_color'] ?? '#6c757d');
|
||||
$statusName = htmlspecialchars(ucfirst($r['status_nome'] ?? 'N/D'));
|
||||
$hasNote = !empty($r['note_extra']);
|
||||
|
||||
echo "<tr data-id='{$r['id']}' style='background-color: {$lineColor} !important;'>
|
||||
<td><span class='view'>" . date('d/m', strtotime($r['Data'])) . "</span>
|
||||
<td><span class='view'>" . date('d/m/Y', strtotime($r['Data'])) . "</span>
|
||||
<input class='inline-edit form-control form-control-sm' name='Data' type='date' value='{$r['Data']}'></td>
|
||||
<td><span class='view'>{$r['matrice']}</span>
|
||||
<select class='inline-edit form-select form-select-sm select2' name='idmatrice'>" . selectOptions($matrici, $r['idmatrice']) . "</select></td>
|
||||
@@ -271,27 +308,33 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
||||
<select class='inline-edit form-select form-select-sm select2' name='id_linea'>" . selectOptions($linee, $r['id_linea'], 'id', 'name') . "</select></td>
|
||||
<td><span class='view'>" . ($r['cliente'] ?? '-') . "</span>
|
||||
<select class='inline-edit form-select form-select-sm select2' name='id_cliente'><option value=''>-</option>" . selectOptions($clienti, $r['id_cliente']) . "</select></td>
|
||||
<td><span class='view'>" . ($r['data_zibo'] ? date('d/m', strtotime($r['data_zibo'])) : '-') . "</span>
|
||||
<td><span class='view'>" . ($r['data_zibo'] ? date('d/m/Y', strtotime($r['data_zibo'])) : '-') . "</span>
|
||||
<input class='inline-edit form-control form-control-sm' name='data_zibo' type='date' value='{$r['data_zibo']}'></td>
|
||||
<td><span class='view'>" . ($r['data_cliente'] ? date('d/m', strtotime($r['data_cliente'])) : '-') . "</span>
|
||||
<td><span class='view'>" . ($r['data_cliente'] ? date('d/m/Y', strtotime($r['data_cliente'])) : '-') . "</span>
|
||||
<input class='inline-edit form-control form-control-sm' name='data_cliente' type='date' value='{$r['data_cliente']}'></td>
|
||||
<td><span class='view'>{$r['metri']}</span><input class='inline-edit form-control form-control-sm' name='metri' type='number' step='0.01' value='{$r['metri']}'></td>
|
||||
<td><span class='view'>{$r['kg_sp']}</span><input class='inline-edit form-control form-control-sm' name='kg_sp' type='number' step='0.01' value='{$r['kg_sp']}'></td>
|
||||
<td><span class='view'>{$r['kg_p']}</span><input class='inline-edit form-control form-control-sm' name='kg_p' type='number' step='0.01' value='{$r['kg_p']}'></td>
|
||||
<td><span class='view'>{$r['ore_previste']}</span><input class='inline-edit form-control form-control-sm' name='ore_previste' type='number' step='0.01' value='{$r['ore_previste']}'></td>
|
||||
<td><span class='view' style='max-width:120px;white-space:pre-wrap;'>" . htmlspecialchars($r['note_extra'] ?? '') . "</span>
|
||||
<input class='inline-edit form-control form-control-sm' name='note_extra' value='" . htmlspecialchars($r['note_extra'] ?? '') . "'></td>
|
||||
<td><span class='view'>" . date('d/m', strtotime($r['data_produzione'])) . "</span>
|
||||
<td>
|
||||
<span class='view'>
|
||||
<i class='bi bi-file-text note-icon " . ($hasNote ? 'has-note' : '') . "'
|
||||
data-note='" . htmlspecialchars($r['note_extra'] ?? '') . "'
|
||||
data-bs-toggle='modal' data-bs-target='#modalNoteView'></i>
|
||||
</span>
|
||||
<textarea class='inline-edit form-control form-control-sm' name='note_extra' rows='2'>" . htmlspecialchars($r['note_extra'] ?? '') . "</textarea>
|
||||
</td>
|
||||
<td><span class='view'>" . date('d/m/Y', strtotime($r['data_produzione'])) . "</span>
|
||||
<input class='inline-edit form-control form-control-sm' name='data_produzione' type='date' value='{$r['data_produzione']}'></td>
|
||||
<td>
|
||||
<span class='badge view' style='background-color: {$badgeColor}; color: #fff;'>{$statusName}</span>
|
||||
<select class='inline-edit form-select form-select-sm select2' name='id_status'>" . selectOptions($status_list, $r['id_status'], 'id', 'nome') . "</select>
|
||||
</td>
|
||||
<td>
|
||||
<button class='btn btn-sm btn-outline-primary edit-row' title='Modifica'><i class='bi bi-pencil'></i></button>
|
||||
<button class='btn btn-sm btn-success save-row d-none' title='Salva'><i class='bi bi-check-lg'></i></button>
|
||||
<button class='btn btn-sm btn-secondary cancel-row d-none' title='Annulla'><i class='bi bi-x-lg'></i></button>
|
||||
<button class='btn btn-sm btn-outline-danger delete-row' title='Elimina'><i class='bi bi-trash-fill'></i></button>
|
||||
<button class='btn btn-xs btn-outline-primary edit-row' title='Modifica'><i class='bi bi-pencil'></i></button>
|
||||
<button class='btn btn-xs btn-success save-row d-none' title='Salva'><i class='bi bi-check-lg'></i></button>
|
||||
<button class='btn btn-xs btn-secondary cancel-row d-none' title='Annulla'><i class='bi bi-x-lg'></i></button>
|
||||
<button class='btn btn-xs btn-outline-danger delete-row' title='Elimina'><i class='bi bi-trash-fill'></i></button>
|
||||
</td>
|
||||
</tr>";
|
||||
}
|
||||
@@ -316,12 +359,31 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
||||
<?php include('include/footer.php'); ?>
|
||||
</div>
|
||||
|
||||
<!-- MODALE VISUALIZZAZIONE NOTE -->
|
||||
<div class="modal fade" id="modalNoteView" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Note Extra</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body" id="noteContent">
|
||||
<!-- Contenuto caricato via JS -->
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Chiudi</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.full.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.13.7/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.13.7/js/dataTables.bootstrap5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/responsive/2.5.0/js/dataTables.responsive.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/responsive/2.5.0/js/responsive.bootstrap5.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
|
||||
|
||||
<?php include('jsinclude.php'); ?>
|
||||
|
||||
@@ -362,7 +424,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
||||
],
|
||||
pageLength: 25,
|
||||
lengthMenu: [10, 25, 50, 100],
|
||||
dom: '<"row"<"col-sm-12 col-md-6"l><"col-sm-12 col-md-6"f>>rtip',
|
||||
dom: '<"row"<"col-sm-12 col-md-6"l><"col-sm-12 col-md-6"f><"col-sm-12 col-md-3 offset-md-3" B>>rtip',
|
||||
initComplete: function() {
|
||||
// Inizializza Select2
|
||||
$('.filters-row .select2').select2({
|
||||
@@ -371,9 +433,22 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
||||
minimumResultsForSearch: 10
|
||||
});
|
||||
|
||||
// Gestione filtri
|
||||
// Inizializza Flatpickr sui filtri data
|
||||
const dateInputs = $('.filters-row input[placeholder*="aaaa"]');
|
||||
dateInputs.each(function() {
|
||||
flatpickr(this, {
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: true,
|
||||
onChange: function(selectedDates, dateStr, instance) {
|
||||
const colIdx = $(instance.element).closest('th').index();
|
||||
table.column(colIdx).search(dateStr).draw();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Gestione filtri non-data
|
||||
$('.filters-row th').each(function(idx) {
|
||||
const input = $(this).find('input, select');
|
||||
const input = $(this).find('input, select').not('[placeholder*="aaaa"]');
|
||||
if (!input.length) return;
|
||||
|
||||
if (input.is('select')) {
|
||||
@@ -388,14 +463,52 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// AGGIUNGI BOTTONE PULISCI FILTRO
|
||||
$('.dataTables_filter').append(
|
||||
'<button type="button" class="btn btn-outline-secondary btn-sm btn-clear-filters" title="Pulisci tutti i filtri">' +
|
||||
'<i class="bi bi-x-circle"></i> Pulisci</button>'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// --- FUNZIONE PULISCI TUTTI I FILTRO ---
|
||||
$(document).on('click', '.btn-clear-filters', function() {
|
||||
// Svuota tutti i filtri DataTables
|
||||
table.columns().search('').draw();
|
||||
|
||||
// Svuota campi testo
|
||||
$('.filters-row input[type="text"]').val('');
|
||||
|
||||
// Svuota select
|
||||
$('.filters-row select').val('').trigger('change');
|
||||
|
||||
// Svuota Flatpickr (date inputs)
|
||||
$('.filters-row input[placeholder*="aaaa"]').each(function() {
|
||||
const fpInstance = $(this).data('flatpickr');
|
||||
if (fpInstance) {
|
||||
fpInstance.clear();
|
||||
fpInstance.setDate('');
|
||||
} else {
|
||||
$(this).val('');
|
||||
}
|
||||
});
|
||||
|
||||
// Svuota search principale
|
||||
$('.dataTables_filter input').val('');
|
||||
});
|
||||
|
||||
// --- APERTURA MODALE NOTE ---
|
||||
$(document).on('click', '.note-icon', function() {
|
||||
const note = $(this).data('note') || '';
|
||||
$('#noteContent').text(note || '(Nessuna nota)');
|
||||
});
|
||||
|
||||
// --- INLINE EDIT ---
|
||||
let original = {};
|
||||
$('#tabProgrammazione').on('click', '.edit-row', function() {
|
||||
const tr = $(this).closest('tr');
|
||||
original = tr.find('.view').map((i, e) => $(e).text()).get();
|
||||
original = tr.find('.view').map((i, e) => $(e).html()).get();
|
||||
tr.find('.view').hide();
|
||||
tr.find('.inline-edit').show();
|
||||
tr.find('.edit-row').addClass('d-none');
|
||||
@@ -412,7 +525,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
||||
|
||||
$('#tabProgrammazione').on('click', '.cancel-row', function() {
|
||||
const tr = $(this).closest('tr');
|
||||
tr.find('.view').show().each((i, e) => $(e).text(original[i]));
|
||||
tr.find('.view').show().each((i, e) => $(e).html(original[i]));
|
||||
tr.find('.inline-edit').hide();
|
||||
tr.find('.edit-row').removeClass('d-none');
|
||||
tr.find('.save-row, .cancel-row').addClass('d-none');
|
||||
@@ -432,7 +545,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
||||
$.post('', data, r => r.success ? location.reload() : alert(r.msg || 'Errore'), 'json');
|
||||
});
|
||||
|
||||
// --- RESTO INVARIATO ---
|
||||
// --- ELIMINAZIONE ---
|
||||
let deleteRow;
|
||||
$('#tabProgrammazione').on('click', '.delete-row', function(e) {
|
||||
e.preventDefault();
|
||||
@@ -454,6 +567,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
||||
}, 'json');
|
||||
});
|
||||
|
||||
// --- MODALE AGGIUNGI ---
|
||||
$('#modalNuovo').on('shown.bs.modal', function() {
|
||||
$(this).find('.select2').each(function() {
|
||||
if (!$(this).hasClass('select2-hidden-accessible')) {
|
||||
@@ -484,7 +598,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- MODALE AGGIUNGI (identico) -->
|
||||
<!-- MODALE AGGIUNGI -->
|
||||
<div class="modal fade" id="modalNuovo" tabindex="-1" aria-labelledby="modalNuovoLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-xl" style="max-width: 95vw;">
|
||||
<div class="modal-content">
|
||||
|
||||
Reference in New Issue
Block a user