diff --git a/public/userarea/delete_tool.php b/public/userarea/delete_tool.php
new file mode 100644
index 0000000..662c85e
--- /dev/null
+++ b/public/userarea/delete_tool.php
@@ -0,0 +1,47 @@
+getConnection();
+
+ $id = (int)($_POST['id'] ?? 0);
+ $name = trim($_POST['name'] ?? '');
+ $tool_type = trim($_POST['tool_type'] ?? '');
+ $description = trim($_POST['description'] ?? '');
+ $is_active = isset($_POST['is_active']) ? (int)$_POST['is_active'] : 1;
+
+ if ($id <= 0) {
+ echo json_encode(['success' => false, 'message' => 'Invalid ID.']);
+ exit;
+ }
+
+ if ($name === '') {
+ echo json_encode(['success' => false, 'message' => 'Name is required.']);
+ exit;
+ }
+
+ $sql = "UPDATE production_tools
+ SET name = :name,
+ tool_type = :tool_type,
+ description = :description,
+ is_active = :is_active
+ WHERE id = :id";
+ $stmt = $pdo->prepare($sql);
+ $stmt->execute([
+ 'name' => $name,
+ 'tool_type' => $tool_type ?: null,
+ 'description' => $description ?: null,
+ 'is_active' => $is_active,
+ 'id' => $id
+ ]);
+
+ echo json_encode(['success' => true]);
+} catch (Exception $e) {
+ echo json_encode(['success' => false, 'message' => $e->getMessage()]);
+}
diff --git a/public/userarea/edit_tool.php b/public/userarea/edit_tool.php
new file mode 100644
index 0000000..ef65b01
--- /dev/null
+++ b/public/userarea/edit_tool.php
@@ -0,0 +1,57 @@
+getConnection();
+
+ $id = (int)($_POST['id'] ?? 0);
+ $name = trim($_POST['name'] ?? '');
+ $registrationNumber = trim($_POST['registration_number'] ?? '');
+ $serialNumber = trim($_POST['serial_number'] ?? '');
+ $toolType = trim($_POST['tool_type'] ?? '');
+ $manufacturer = trim($_POST['manufacturer'] ?? '');
+ $description = trim($_POST['description'] ?? '');
+ $isActive = isset($_POST['is_active']) ? (int)$_POST['is_active'] : 1;
+
+ if ($id <= 0) {
+ echo json_encode(['success' => false, 'message' => 'Invalid ID.']);
+ exit;
+ }
+
+ if ($name === '') {
+ echo json_encode(['success' => false, 'message' => 'Name is required.']);
+ exit;
+ }
+
+ $sql = "UPDATE production_tools
+ SET name = :name,
+ registration_number = :registration_number,
+ serial_number = :serial_number,
+ tool_type = :tool_type,
+ manufacturer = :manufacturer,
+ description = :description,
+ is_active = :is_active
+ WHERE id = :id";
+
+ $stmt = $pdo->prepare($sql);
+ $stmt->execute([
+ 'name' => $name,
+ 'registration_number' => $registrationNumber ?: null,
+ 'serial_number' => $serialNumber ?: null,
+ 'tool_type' => $toolType ?: null,
+ 'manufacturer' => $manufacturer ?: null,
+ 'description' => $description ?: null,
+ 'is_active' => $isActive,
+ 'id' => $id
+ ]);
+
+ echo json_encode(['success' => true]);
+} catch (Exception $e) {
+ echo json_encode(['success' => false, 'message' => $e->getMessage()]);
+}
diff --git a/public/userarea/production_line_view2.php b/public/userarea/production_line_view2.php
index 52e5aea..8f9e722 100644
--- a/public/userarea/production_line_view2.php
+++ b/public/userarea/production_line_view2.php
@@ -264,31 +264,47 @@ if (!empty($_GET['ajax'])) {
$lineRaw = $_GET['line'] ?? '';
$lineArray = $lineRaw !== '' ? explode(',', $lineRaw) : [];
+ // --- RECORD IN PRODUZIONE (2,7,8)
// --- RECORD IN PRODUZIONE (2,7,8)
$sql = "SELECT
- p.*,
- m.nome AS matrice,
- m.photo AS matrice_photo,
- (
- SELECT GROUP_CONCAT(m.nome ORDER BY m.nome SEPARATOR ' | ')
+ p.*,
+ m.nome AS matrice,
+ m.photo AS matrice_photo,
+ (
+ SELECT GROUP_CONCAT(mes.nome ORDER BY mes.nome SEPARATOR ' | ')
FROM productiondata_mescole pm
- JOIN mescole m ON m.id = pm.id_mescola
+ JOIN mescole mes ON mes.id = pm.id_mescola
WHERE pm.id_productiondata = p.id
- ) AS mescole_list,
- l.name AS linea,
- c.nome AS cliente,
- s.nome AS status_nome,
- s.badge_color,
- s.line_color,
- p.tempo_totale_produzione
- FROM productiondata p
- LEFT JOIN matrice m ON p.idmatrice = m.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
- WHERE p.id_status IN (2, 7, 8)
- " . (!empty($lineArray) ? " AND p.id_linea IN (" . implode(',', array_map('intval', $lineArray)) . ")" : "") . "
- ORDER BY l.line_number, p.Data";
+ ) AS mescole_list,
+ l.name AS linea,
+ c.nome AS cliente,
+ s.nome AS status_nome,
+ s.badge_color,
+ s.line_color,
+ p.tempo_totale_produzione,
+
+ -- 🔧 ADD: tools list & count
+ (
+ SELECT GROUP_CONCAT(t.name ORDER BY t.name SEPARATOR ' | ')
+ FROM productiondata_tools pt
+ JOIN production_tools t ON t.id = pt.tool_id
+ WHERE pt.productiondata_id = p.id
+ ) AS tools_list,
+ (
+ SELECT COUNT(*)
+ FROM productiondata_tools pt
+ WHERE pt.productiondata_id = p.id
+ ) AS tools_count
+
+ FROM productiondata p
+ LEFT JOIN matrice m ON p.idmatrice = m.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
+ WHERE p.id_status IN (2, 7, 8)
+ " . (!empty($lineArray) ? " AND p.id_linea IN (" . implode(',', array_map('intval', $lineArray)) . ")" : "") . "
+ ORDER BY l.line_number, p.Data";
+
$stmt = $pdo->prepare($sql);
$stmt->execute();
@@ -312,30 +328,44 @@ if (!empty($_GET['ajax'])) {
// --- RECORD IN STATO 6 ORDINATI PER PRIORITY
$sql2 = "SELECT
- p.*,
- m.nome AS matrice,
- m.photo AS matrice_photo,
- (
- SELECT GROUP_CONCAT(m2.nome ORDER BY m2.nome SEPARATOR ' | ')
- FROM productiondata_mescole pm
- JOIN mescole m2 ON m2.id = pm.id_mescola
- WHERE pm.id_productiondata = p.id
- ) AS mescole_list,
- l.name AS linea,
- c.nome AS cliente,
- s.nome AS status_nome,
- s.badge_color,
- s.line_color,
- p.tempo_totale_produzione
- FROM productiondata p
- LEFT JOIN matrice m ON p.idmatrice = m.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
- WHERE p.id_status = 6
- " . (!empty($lineArray) ? " AND p.id_linea IN (" . implode(',', array_map('intval', $lineArray)) . ")" : "") . "
- ORDER BY p.priority ASC
- ";
+ p.*,
+ m.nome AS matrice,
+ m.photo AS matrice_photo,
+ (
+ SELECT GROUP_CONCAT(mes.nome ORDER BY mes.nome SEPARATOR ' | ')
+ FROM productiondata_mescole pm
+ JOIN mescole mes ON mes.id = pm.id_mescola
+ WHERE pm.id_productiondata = p.id
+ ) AS mescole_list,
+ l.name AS linea,
+ c.nome AS cliente,
+ s.nome AS status_nome,
+ s.badge_color,
+ s.line_color,
+ p.tempo_totale_produzione,
+
+ -- 🔧 ADD: tools list & count
+ (
+ SELECT GROUP_CONCAT(t.name ORDER BY t.name SEPARATOR ' | ')
+ FROM productiondata_tools pt
+ JOIN production_tools t ON t.id = pt.tool_id
+ WHERE pt.productiondata_id = p.id
+ ) AS tools_list,
+ (
+ SELECT COUNT(*)
+ FROM productiondata_tools pt
+ WHERE pt.productiondata_id = p.id
+ ) AS tools_count
+
+ FROM productiondata p
+ LEFT JOIN matrice m ON p.idmatrice = m.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
+ WHERE p.id_status = 6
+ " . (!empty($lineArray) ? " AND p.id_linea IN (" . implode(',', array_map('intval', $lineArray)) . ")" : "") . "
+ ORDER BY p.priority ASC
+ ";
$stmt2 = $pdo->prepare($sql2);
$stmt2->execute();
@@ -479,10 +509,12 @@ if (!empty($_GET['ajax'])) {
#recordsContainer {
flex: 1;
overflow-y: auto;
- padding: 1rem 1.5rem;
+ /* top right bottom left */
+ padding: 1rem 1.5rem 5rem 1.5rem;
background: #f8fafc;
}
+
.record-card {
margin-bottom: 1rem;
border-radius: 1rem;
@@ -893,6 +925,11 @@ if (!empty($_GET['ajax'])) {
font-weight: 700;
font-size: 1rem;
}
+
+ .photo-tools-row .qc-right {
+ margin-left: auto;
+ /* la porta tutta a destra */
+ }
@@ -1260,6 +1297,22 @@ if (!empty($_GET['ajax'])) {
startAllTimers();
setupEventHandlers();
+ // 🔧 Sposta l'icona qualità all'estrema destra della riga
+ $('.photo-tools-row').each(function() {
+ const $row = $(this);
+ const $qc = $row.find('.qc-btn').last(); // assume che il bottone qualità abbia classe .qc-btn
+
+ if ($qc.length) {
+ // la stacco dal gruppo foto
+ $qc.detach();
+ // la ri-attacco come ultimo elemento della riga
+ $qc.appendTo($row);
+ // le do la classe che la spinge a destra
+ $qc.addClass('qc-right');
+ }
+ });
+
+
$(document).on("click", ".photo-btn", function(e) {
e.stopPropagation();
diff --git a/public/userarea/production_tools.php b/public/userarea/production_tools.php
new file mode 100644
index 0000000..40872ce
--- /dev/null
+++ b/public/userarea/production_tools.php
@@ -0,0 +1,393 @@
+
+
+
+
+
+
+
+
+
+ Gestione Strumenti Aggiuntivi - = htmlspecialchars($titlewebsite, ENT_QUOTES, 'UTF-8'); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Elenco Strumenti
+
+ ➕ Aggiungi Strumento
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/public/userarea/render_production_card.php b/public/userarea/render_production_card.php
index 56e645e..8523ae0 100644
--- a/public/userarea/render_production_card.php
+++ b/public/userarea/render_production_card.php
@@ -90,6 +90,29 @@ if ($matricePhoto) {
$mescArray = $mescRaw !== '' ? explode(' | ', $mescRaw) : [];
$mescCount = count($mescArray);
?>
+
+
Mescola
@@ -141,7 +164,6 @@ if ($matricePhoto) {
$paramsLinea = $r['params_linea'] ?? [];
// 🔥 Carica già anche eventuali foto di slot parametri
- // (necessario perché param_grid.php usa $photosSlots)
$photosSlots = [];
$stmt = $pdo->prepare("
SELECT param_position, filename
@@ -154,13 +176,10 @@ if ($matricePhoto) {
$photosSlots[(int)$p['param_position']] = $p['filename'];
}
- // 👉 Include la griglia parametri con le variabili già disponibili
$paramsLinea = $r['param_slots'] ?? [];
include __DIR__ . "/components/param_grid.php";
?>
-
-
= $r['kg_sp'] ?>
= $r['metri'] ?>
@@ -177,15 +196,67 @@ if ($matricePhoto) {
-
+
+
+
+
+
+
AVVIA PRODUZIONE
+
+
+ = htmlspecialchars($toolName) ?>
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/public/userarea/save_tool.php b/public/userarea/save_tool.php
new file mode 100644
index 0000000..ba785be
--- /dev/null
+++ b/public/userarea/save_tool.php
@@ -0,0 +1,45 @@
+getConnection();
+
+ $name = trim($_POST['name'] ?? '');
+ $registrationNumber = trim($_POST['registration_number'] ?? '');
+ $serialNumber = trim($_POST['serial_number'] ?? '');
+ $toolType = trim($_POST['tool_type'] ?? '');
+ $manufacturer = trim($_POST['manufacturer'] ?? '');
+ $description = trim($_POST['description'] ?? '');
+ $isActive = isset($_POST['is_active']) ? (int)$_POST['is_active'] : 1;
+
+ if ($name === '') {
+ echo json_encode(['success' => false, 'message' => 'Name is required.']);
+ exit;
+ }
+
+ $sql = "INSERT INTO production_tools
+ (name, registration_number, serial_number, tool_type, manufacturer, description, is_active)
+ VALUES
+ (:name, :registration_number, :serial_number, :tool_type, :manufacturer, :description, :is_active)";
+
+ $stmt = $pdo->prepare($sql);
+ $stmt->execute([
+ 'name' => $name,
+ 'registration_number' => $registrationNumber ?: null,
+ 'serial_number' => $serialNumber ?: null,
+ 'tool_type' => $toolType ?: null,
+ 'manufacturer' => $manufacturer ?: null,
+ 'description' => $description ?: null,
+ 'is_active' => $isActive
+ ]);
+
+ echo json_encode(['success' => true]);
+} catch (Exception $e) {
+ echo json_encode(['success' => false, 'message' => $e->getMessage()]);
+}