From 1bda30e957133222f123c3b337e23585813cab8b Mon Sep 17 00:00:00 2001 From: kapsona777 Date: Mon, 25 Aug 2025 19:39:53 +0400 Subject: [PATCH] fixed saving and modifying parts --- public/userarea/parts.js | 11 ++++++----- public/userarea/save_parts.php | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/public/userarea/parts.js b/public/userarea/parts.js index 7ef40fc..3bb60a6 100644 --- a/public/userarea/parts.js +++ b/public/userarea/parts.js @@ -179,7 +179,7 @@ $(document).ready(function () { function addNewRow(nextPartNumber, isMix = false) { const description = isMix ? "Mix" : ""; const newRow = ` - + @@ -290,13 +290,14 @@ $(document).ready(function () { contentType: "application/json", success: function (response) { if (response.success) { - // თუ ახალია, backend-მა მოგვცა ახალი ID - if (response.part_id) { - $row.data("part-id", response.part_id); - } $saveLoading.hide(); $saveStatus.show(); updatePartsList(); + // თუ ახალია, backend-მა მოგვცა ახალი ID + if (response.part_id) { + $row.attr("data-part-id", response.part_id); + $row.data("part-id", response.part_id); + } setTimeout(() => $saveStatus.hide(), 2000); } else { alert("Errore nel salvataggio: " + response.message); diff --git a/public/userarea/save_parts.php b/public/userarea/save_parts.php index 4247806..65e07cc 100644 --- a/public/userarea/save_parts.php +++ b/public/userarea/save_parts.php @@ -37,7 +37,7 @@ if ($partDescription) { ':part_description' => $partDescription, ':mix' => $mix ]); - echo json_encode(['success' => true, 'message' => 'Parte aggiornata con successo']); + echo json_encode(['success' => true, 'part_id' => $partId, 'part_number'=>$partNumber, 'message' => 'Parte aggiornata con successo']); } else { // INSERT თუ ახალია $stmt = $pdo->prepare("INSERT INTO identification_parts @@ -50,7 +50,7 @@ if ($partDescription) { ':mix' => $mix ]); $newId = $pdo->lastInsertId(); - echo json_encode(['success' => true, 'message' => 'Parte salvata con successo', 'part_id' => $newId]); + echo json_encode(['success' => true, 'part_id' => $newId, 'part_number'=>$partNumber, 'message' => 'Parte salvata con successo']); } } catch (PDOException $e) { echo json_encode(['success' => false, 'message' => 'Errore nel salvataggio: ' . $e->getMessage()]);