fixed dashboard
This commit is contained in:
parent
85c8ddc985
commit
711d3d5f73
@ -108,9 +108,9 @@ class LoginController extends Controller
|
|||||||
|
|
||||||
// Reindirizza in base al ruolo
|
// Reindirizza in base al ruolo
|
||||||
if ($user->hasRole('Admin')) {
|
if ($user->hasRole('Admin')) {
|
||||||
return redirect()->to('userarea/import_dashboard.php');
|
return redirect()->to('userarea/production_dashboard.php');
|
||||||
} elseif ($user->hasRole('User')) {
|
} elseif ($user->hasRole('User')) {
|
||||||
return redirect()->to('userarea/import_dashboard.php');
|
return redirect()->to('userarea/production_dashboard.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Se il ruolo non è specificato, reindirizza alla home predefinita
|
// Se il ruolo non è specificato, reindirizza alla home predefinita
|
||||||
|
|||||||
@ -1,7 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
include('../class/db-functions.php');
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
// Evita che warning PHP rovinino il json
|
||||||
|
error_reporting(0);
|
||||||
|
ini_set('display_errors', 0);
|
||||||
|
|
||||||
|
require_once(__DIR__ . '/../class/db-functions.php');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!isset($_GET['id'])) {
|
if (!isset($_GET['id'])) {
|
||||||
echo json_encode(['success' => false, 'message' => 'ID matrice non fornito.']);
|
echo json_encode(['success' => false, 'message' => 'ID matrice non fornito.']);
|
||||||
@ -9,19 +14,24 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$idMatrice = intval($_GET['id']);
|
$idMatrice = intval($_GET['id']);
|
||||||
|
|
||||||
$db = DBHandlerSelect::getInstance();
|
$db = DBHandlerSelect::getInstance();
|
||||||
$pdo = $db->getConnection();
|
$pdo = $db->getConnection();
|
||||||
|
|
||||||
// Tutte le mescole
|
// tutte le mescole
|
||||||
$stmt = $pdo->query("SELECT id, nome FROM mescole ORDER BY nome ASC");
|
$stmt = $pdo->query("SELECT id, nome FROM mescole ORDER BY nome ASC");
|
||||||
$tutte = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$tutte = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
// Mescole già associate
|
// mescole associate
|
||||||
$stmt = $pdo->prepare("SELECT idmescola FROM matrice_mescole WHERE idmatrice = ?");
|
$stmt = $pdo->prepare("SELECT idmescola FROM matrice_mescole WHERE idmatrice = ?");
|
||||||
$stmt->execute([$idMatrice]);
|
$stmt->execute([$idMatrice]);
|
||||||
$associate = $stmt->fetchAll(PDO::FETCH_COLUMN);
|
$associate = $stmt->fetchAll(PDO::FETCH_COLUMN);
|
||||||
|
|
||||||
echo json_encode(['success' => true, 'tutte' => $tutte, 'associate' => $associate]);
|
echo json_encode([
|
||||||
|
'success' => true,
|
||||||
|
'tutte' => $tutte,
|
||||||
|
'associate' => $associate
|
||||||
|
]);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
echo json_encode(['success' => false, 'message' => 'Errore: ' . $e->getMessage()]);
|
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,25 +14,17 @@
|
|||||||
<!-- user, admin, superuser menù -->
|
<!-- user, admin, superuser menù -->
|
||||||
<?php if ((Auth::user()->hasRole('Admin')) || (Auth::user()->hasRole('User')) || (Auth::user()->hasRole('Superuser'))) : ?>
|
<?php if ((Auth::user()->hasRole('Admin')) || (Auth::user()->hasRole('User')) || (Auth::user()->hasRole('Superuser'))) : ?>
|
||||||
<li>
|
<li>
|
||||||
<a href="javascript:;" class="has-arrow">
|
<a href="production_dashboard.php">
|
||||||
<div class="parent-icon"><i class='bx bx-home-alt'></i>
|
<div class="parent-icon"><i class="bx bx-home-alt"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="menu-title">Dashboard</div>
|
<div class="menu-title">Dashboard</div>
|
||||||
</a>
|
</a>
|
||||||
<ul>
|
|
||||||
<!-- <li> <a href="index.php"><i class='bx bx-radio-circle'></i>Default</a>
|
|
||||||
</li> -->
|
|
||||||
<li> <a href="import_dashboard.php"><i class='bx bx-radio-circle'></i>XLS Import</a>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
|
|
||||||
</ul>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="javascript:;" class="has-arrow">
|
<a href="javascript:;" class="has-arrow">
|
||||||
<div class="parent-icon"><i class="bx bx-category"></i>
|
<div class="parent-icon"><i class="bx bx-category"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="menu-title">Templates</div>
|
<div class="menu-title">Programmazione</div>
|
||||||
</a>
|
</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li> <a href="templates_dashboard.php"><i class='bx bx-radio-circle'></i><?= htmlspecialchars($dashtemplate, ENT_QUOTES, 'UTF-8'); ?></a>
|
<li> <a href="templates_dashboard.php"><i class='bx bx-radio-circle'></i><?= htmlspecialchars($dashtemplate, ENT_QUOTES, 'UTF-8'); ?></a>
|
||||||
@ -46,10 +38,17 @@
|
|||||||
<a href="javascript:;" class="has-arrow">
|
<a href="javascript:;" class="has-arrow">
|
||||||
<div class="parent-icon"><i class="bx bx-category"></i>
|
<div class="parent-icon"><i class="bx bx-category"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="menu-title">Other Functions</div>
|
<div class="menu-title">Funzioni</div>
|
||||||
</a>
|
</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li> <a href="quotations.php"><i class='bx bx-radio-circle'></i><?php echo $quotationstitle; ?></a>
|
<li>
|
||||||
|
<a href="mescole.php"><i class='bx bx-radio-circle'></i>Mescole</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="matrici.php"><i class='bx bx-radio-circle'></i>Matrici</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="linee.php"><i class='bx bx-radio-circle'></i>Linee di produzione</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -344,8 +344,13 @@
|
|||||||
const linee = $('#lineeSelect').val();
|
const linee = $('#lineeSelect').val();
|
||||||
fetch('save_matrice_linee.php', {
|
fetch('save_matrice_linee.php', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: {
|
||||||
body: JSON.stringify({ id, linee })
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
id,
|
||||||
|
linee
|
||||||
|
})
|
||||||
}).then(r => r.json()).then(d => {
|
}).then(r => r.json()).then(d => {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
icon: d.success ? 'success' : 'error',
|
icon: d.success ? 'success' : 'error',
|
||||||
@ -360,33 +365,43 @@
|
|||||||
const id = $(this).data('id');
|
const id = $(this).data('id');
|
||||||
const nome = $(this).data('nome');
|
const nome = $(this).data('nome');
|
||||||
$('#idMatriceMescole').val(id);
|
$('#idMatriceMescole').val(id);
|
||||||
$('.modal-title').text('Associa Mescole a ' + nome);
|
|
||||||
|
$('#associaMescoleModal .modal-title').text('Associa Mescole a ' + nome);
|
||||||
|
|
||||||
fetch('get_mescole_matrice.php?id=' + id)
|
fetch('get_mescole_matrice.php?id=' + id)
|
||||||
.then(r => r.json())
|
.then(r => r.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
const sel = $('#mescoleSelect');
|
const sel = $('#mescoleSelect');
|
||||||
sel.empty();
|
sel.empty();
|
||||||
|
|
||||||
data.tutte.forEach(m => {
|
data.tutte.forEach(m => {
|
||||||
const selected = data.associate.includes(m.id.toString()) ? 'selected' : '';
|
const selected = data.associate.includes(m.id.toString()) ? 'selected' : '';
|
||||||
sel.append(`<option value="${m.id}" ${selected}>${m.nome}</option>`);
|
sel.append(`<option value="${m.id}" ${selected}>${m.nome}</option>`);
|
||||||
});
|
});
|
||||||
|
|
||||||
sel.select2({
|
sel.select2({
|
||||||
theme: 'bootstrap-5',
|
theme: 'bootstrap-5',
|
||||||
width: '100%'
|
width: '100%'
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#associaMescoleModal').modal('show');
|
$('#associaMescoleModal').modal('show');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$('#associaMescoleForm').on('submit', e => {
|
$('#associaMescoleForm').on('submit', e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const id = $('#idMatriceMescole').val();
|
const id = $('#idMatriceMescole').val();
|
||||||
const mescole = $('#mescoleSelect').val();
|
const mescole = $('#mescoleSelect').val();
|
||||||
fetch('save_matrice_mescole.php', {
|
fetch('save_matrice_mescole.php', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: {
|
||||||
body: JSON.stringify({ id, mescole })
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
id,
|
||||||
|
mescole
|
||||||
|
})
|
||||||
}).then(r => r.json()).then(d => {
|
}).then(r => r.json()).then(d => {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
icon: d.success ? 'success' : 'error',
|
icon: d.success ? 'success' : 'error',
|
||||||
|
|||||||
@ -162,11 +162,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.btn-programmazione {
|
.btn-programmazione {
|
||||||
background: linear-gradient(135deg, #d1b3ffff, #e2ccffff);
|
background: linear-gradient(135deg, #7c7afaff, #7c7afaff);
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-status {
|
.btn-status {
|
||||||
background: linear-gradient(135deg, #ffd5f6ff, #ffe4faff);
|
background: linear-gradient(135deg, #61ce5dff, #61ce5dff);
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
@ -241,17 +241,17 @@
|
|||||||
|
|
||||||
<!-- ===== PRIMA RIGA ===== -->
|
<!-- ===== PRIMA RIGA ===== -->
|
||||||
<div class="dashboard-grid">
|
<div class="dashboard-grid">
|
||||||
|
<button class="dash-btn btn-programmazione" onclick="location.href='produzione_programmazione.php'">
|
||||||
<button class="dash-btn btn-inserisci" onclick="location.href='production_add.php'">
|
<div class="dash-icon">🗓️</div>
|
||||||
<div class="dash-icon">➕</div>
|
<div>Programmazione</div>
|
||||||
<div>Inserisci Dati Produzione</div>
|
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button class="dash-btn btn-visualizza" onclick="location.href='production_all.php'">
|
<button class="dash-btn btn-status" onclick="location.href='production_line_view.php'">
|
||||||
<div class="dash-icon">📊</div>
|
<div class="dash-icon">⚙️</div>
|
||||||
<div>Riepilogo Produzione</div>
|
<div>Line View</div>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|
||||||
<button class="dash-btn btn-statistiche" onclick="location.href='production_stats.php'">
|
<button class="dash-btn btn-statistiche" onclick="location.href='production_stats.php'">
|
||||||
<div class="dash-icon">📈</div>
|
<div class="dash-icon">📈</div>
|
||||||
<div>Statistiche</div>
|
<div>Statistiche</div>
|
||||||
@ -276,19 +276,20 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- ===== TERZA RIGA (solo 2 bottoni centrati) ===== -->
|
<!-- ===== TERZA RIGA (solo 2 bottoni centrati) =====
|
||||||
<div class="dashboard-grid-bottom">
|
<div class="dashboard-grid-bottom">
|
||||||
<div></div> <!-- spaziatore per centratura -->
|
|
||||||
<button class="dash-btn btn-programmazione" onclick="location.href='produzione_programmazione.php'">
|
<button class="dash-btn btn-inserisci" onclick="location.href='production_add.php'">
|
||||||
<div class="dash-icon">🗓️</div>
|
<div class="dash-icon">➕</div>
|
||||||
<div>Programmazione</div>
|
<div>Inserisci Dati Produzione</div>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button class="dash-btn btn-status" onclick="location.href='status.php'">
|
<button class="dash-btn btn-visualizza" onclick="location.href='production_all.php'">
|
||||||
<div class="dash-icon">⚙️</div>
|
<div class="dash-icon">📊</div>
|
||||||
<div>Status Macchine</div>
|
<div>Riepilogo Produzione</div>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
<div></div>
|
||||||
|
</div> -->
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
1144
public/userarea/production_line_view.php
Normal file
1144
public/userarea/production_line_view.php
Normal file
File diff suppressed because it is too large
Load Diff
@ -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.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/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 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>
|
<style>
|
||||||
.inline-edit {
|
.inline-edit {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-sm {
|
.btn-xs {
|
||||||
border-radius: .5rem;
|
padding: 0.15rem 0.35rem;
|
||||||
font-size: .8rem;
|
font-size: 0.7rem;
|
||||||
padding: .35rem .65rem;
|
line-height: 1.2;
|
||||||
|
border-radius: .4rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-xs i {
|
||||||
|
font-size: 0.85rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table td,
|
.table td,
|
||||||
@ -126,8 +132,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
|||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn i {
|
.btn-clear-filters {
|
||||||
font-size: 1rem;
|
margin-left: 0.5rem;
|
||||||
|
padding: 0.25rem 0.5rem;
|
||||||
|
font-size: 0.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.badge {
|
.badge {
|
||||||
@ -158,7 +166,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
|||||||
font-size: 0.75rem !important;
|
font-size: 0.75rem !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TESTO PICCOLO NEI DROPDOWN SELECT2 */
|
|
||||||
.select2-container--bootstrap-5 .select2-dropdown .select2-results__option {
|
.select2-container--bootstrap-5 .select2-dropdown .select2-results__option {
|
||||||
font-size: 0.75rem !important;
|
font-size: 0.75rem !important;
|
||||||
padding: 0.2rem 0.5rem !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 {
|
.select2-container--bootstrap-5 .select2-selection__placeholder {
|
||||||
font-size: 0.75rem !important;
|
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>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
@ -195,8 +231,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
|||||||
<th>Mescola</th>
|
<th>Mescola</th>
|
||||||
<th>Linea</th>
|
<th>Linea</th>
|
||||||
<th>Cliente</th>
|
<th>Cliente</th>
|
||||||
<th>Zibo</th>
|
<th>Data Zibo</th>
|
||||||
<th>Cliente</th>
|
<th>Data Cliente</th>
|
||||||
<th>mt</th>
|
<th>mt</th>
|
||||||
<th>kg sp</th>
|
<th>kg sp</th>
|
||||||
<th>kg p</th>
|
<th>kg p</th>
|
||||||
@ -208,7 +244,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
|||||||
</tr>
|
</tr>
|
||||||
<!-- FILTRI SOPRA -->
|
<!-- FILTRI SOPRA -->
|
||||||
<tr class="filters-row bg-light">
|
<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">
|
<th><select class="filter-select form-select form-select-sm select2">
|
||||||
<option value="">Tutti</option><?= selectOptions($matrici) ?>
|
<option value="">Tutti</option><?= selectOptions($matrici) ?>
|
||||||
</select></th>
|
</select></th>
|
||||||
@ -222,14 +258,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
|||||||
<option value="">Tutti</option>
|
<option value="">Tutti</option>
|
||||||
<option value="">-</option><?= selectOptions($clienti) ?>
|
<option value="">-</option><?= selectOptions($clienti) ?>
|
||||||
</select></th>
|
</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="gg/mm/aaaa"></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="mt"></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 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="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="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="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">
|
<th><select class="filter-select form-select form-select-sm select2">
|
||||||
<option value="">Tutti</option><?= selectOptions($status_list, null, 'id', 'nome') ?>
|
<option value="">Tutti</option><?= selectOptions($status_list, null, 'id', 'nome') ?>
|
||||||
</select></th>
|
</select></th>
|
||||||
@ -259,9 +295,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
|||||||
$lineColor = htmlspecialchars($r['line_color'] ?? '#ffffff');
|
$lineColor = htmlspecialchars($r['line_color'] ?? '#ffffff');
|
||||||
$badgeColor = htmlspecialchars($r['badge_color'] ?? '#6c757d');
|
$badgeColor = htmlspecialchars($r['badge_color'] ?? '#6c757d');
|
||||||
$statusName = htmlspecialchars(ucfirst($r['status_nome'] ?? 'N/D'));
|
$statusName = htmlspecialchars(ucfirst($r['status_nome'] ?? 'N/D'));
|
||||||
|
$hasNote = !empty($r['note_extra']);
|
||||||
|
|
||||||
echo "<tr data-id='{$r['id']}' style='background-color: {$lineColor} !important;'>
|
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>
|
<input class='inline-edit form-control form-control-sm' name='Data' type='date' value='{$r['Data']}'></td>
|
||||||
<td><span class='view'>{$r['matrice']}</span>
|
<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>
|
<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>
|
<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>
|
<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>
|
<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>
|
<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>
|
<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['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_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['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'>{$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>
|
<td>
|
||||||
<input class='inline-edit form-control form-control-sm' name='note_extra' value='" . htmlspecialchars($r['note_extra'] ?? '') . "'></td>
|
<span class='view'>
|
||||||
<td><span class='view'>" . date('d/m', strtotime($r['data_produzione'])) . "</span>
|
<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>
|
<input class='inline-edit form-control form-control-sm' name='data_produzione' type='date' value='{$r['data_produzione']}'></td>
|
||||||
<td>
|
<td>
|
||||||
<span class='badge view' style='background-color: {$badgeColor}; color: #fff;'>{$statusName}</span>
|
<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>
|
<select class='inline-edit form-select form-select-sm select2' name='id_status'>" . selectOptions($status_list, $r['id_status'], 'id', 'nome') . "</select>
|
||||||
</td>
|
</td>
|
||||||
<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-xs 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-xs 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-xs 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-danger delete-row' title='Elimina'><i class='bi bi-trash-fill'></i></button>
|
||||||
</td>
|
</td>
|
||||||
</tr>";
|
</tr>";
|
||||||
}
|
}
|
||||||
@ -316,12 +359,31 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
|||||||
<?php include('include/footer.php'); ?>
|
<?php include('include/footer.php'); ?>
|
||||||
</div>
|
</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://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.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/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/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/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.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'); ?>
|
<?php include('jsinclude.php'); ?>
|
||||||
|
|
||||||
@ -362,7 +424,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
|||||||
],
|
],
|
||||||
pageLength: 25,
|
pageLength: 25,
|
||||||
lengthMenu: [10, 25, 50, 100],
|
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() {
|
initComplete: function() {
|
||||||
// Inizializza Select2
|
// Inizializza Select2
|
||||||
$('.filters-row .select2').select2({
|
$('.filters-row .select2').select2({
|
||||||
@ -371,9 +433,22 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
|||||||
minimumResultsForSearch: 10
|
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) {
|
$('.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.length) return;
|
||||||
|
|
||||||
if (input.is('select')) {
|
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 ---
|
// --- INLINE EDIT ---
|
||||||
let original = {};
|
let original = {};
|
||||||
$('#tabProgrammazione').on('click', '.edit-row', function() {
|
$('#tabProgrammazione').on('click', '.edit-row', function() {
|
||||||
const tr = $(this).closest('tr');
|
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('.view').hide();
|
||||||
tr.find('.inline-edit').show();
|
tr.find('.inline-edit').show();
|
||||||
tr.find('.edit-row').addClass('d-none');
|
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() {
|
$('#tabProgrammazione').on('click', '.cancel-row', function() {
|
||||||
const tr = $(this).closest('tr');
|
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('.inline-edit').hide();
|
||||||
tr.find('.edit-row').removeClass('d-none');
|
tr.find('.edit-row').removeClass('d-none');
|
||||||
tr.find('.save-row, .cancel-row').addClass('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');
|
$.post('', data, r => r.success ? location.reload() : alert(r.msg || 'Errore'), 'json');
|
||||||
});
|
});
|
||||||
|
|
||||||
// --- RESTO INVARIATO ---
|
// --- ELIMINAZIONE ---
|
||||||
let deleteRow;
|
let deleteRow;
|
||||||
$('#tabProgrammazione').on('click', '.delete-row', function(e) {
|
$('#tabProgrammazione').on('click', '.delete-row', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@ -454,6 +567,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
|||||||
}, 'json');
|
}, 'json');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// --- MODALE AGGIUNGI ---
|
||||||
$('#modalNuovo').on('shown.bs.modal', function() {
|
$('#modalNuovo').on('shown.bs.modal', function() {
|
||||||
$(this).find('.select2').each(function() {
|
$(this).find('.select2').each(function() {
|
||||||
if (!$(this).hasClass('select2-hidden-accessible')) {
|
if (!$(this).hasClass('select2-hidden-accessible')) {
|
||||||
@ -484,7 +598,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['action'])) {
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- MODALE AGGIUNGI (identico) -->
|
<!-- MODALE AGGIUNGI -->
|
||||||
<div class="modal fade" id="modalNuovo" tabindex="-1" aria-labelledby="modalNuovoLabel" aria-hidden="true">
|
<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-dialog modal-xl" style="max-width: 95vw;">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
|
|||||||
53
public/userarea/update_linea.php
Normal file
53
public/userarea/update_linea.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
require_once(__DIR__ . '/class/db-functions.php');
|
||||||
|
|
||||||
|
try {
|
||||||
|
$db = DBHandlerSelect::getInstance();
|
||||||
|
$pdo = $db->getConnection();
|
||||||
|
|
||||||
|
// Validazione base
|
||||||
|
if (empty($_POST['id']) || !is_numeric($_POST['id'])) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'ID non valido.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$id = (int)$_POST['id'];
|
||||||
|
$lineNumber = trim($_POST['lineNumber'] ?? '');
|
||||||
|
$lineName = trim($_POST['lineName'] ?? '');
|
||||||
|
$model = trim($_POST['model'] ?? '');
|
||||||
|
$brand = trim($_POST['brand'] ?? '');
|
||||||
|
$status = trim($_POST['status'] ?? '');
|
||||||
|
|
||||||
|
if ($lineNumber === '' || $lineName === '') {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Numero linea e nome sono obbligatori.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Query UPDATE
|
||||||
|
$sql = "UPDATE production_lines
|
||||||
|
SET line_number = :line_number,
|
||||||
|
name = :name,
|
||||||
|
model = :model,
|
||||||
|
brand = :brand,
|
||||||
|
status = :status
|
||||||
|
WHERE id = :id";
|
||||||
|
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->execute([
|
||||||
|
':line_number' => $lineNumber,
|
||||||
|
':name' => $lineName,
|
||||||
|
':model' => $model,
|
||||||
|
':brand' => $brand,
|
||||||
|
':status' => $status,
|
||||||
|
':id' => $id
|
||||||
|
]);
|
||||||
|
|
||||||
|
echo json_encode(['success' => true]);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo json_encode([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Errore server: ' . $e->getMessage()
|
||||||
|
]);
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user