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()]);
|