Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6ec0c2062e | |||
| 03771e3ca8 |
@@ -18,10 +18,9 @@ $(document).ready(function () {
|
|||||||
let fabricCanvas = null;
|
let fabricCanvas = null;
|
||||||
let descriptionTextbox = null;
|
let descriptionTextbox = null;
|
||||||
let markerObjects = {};
|
let markerObjects = {};
|
||||||
let nextMarkerId = 1;
|
|
||||||
let partsListData = [];
|
let partsListData = [];
|
||||||
// DIMENSIONE GLOBALE MARKER
|
// DIMENSIONE GLOBALE MARKER
|
||||||
let globalMarkerSize = 16;
|
let globalMarkerSize = 24;
|
||||||
|
|
||||||
// ===================
|
// ===================
|
||||||
// MODAL INITIALIZATION
|
// MODAL INITIALIZATION
|
||||||
@@ -33,7 +32,7 @@ $(document).ready(function () {
|
|||||||
trfHeader,
|
trfHeader,
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#annotationsModal").attr("data-iddatadb", iddatadb);
|
$("#annotationsModal").attr('data-iddatadb', iddatadb);
|
||||||
|
|
||||||
if (!iddatadb && !idquotations) {
|
if (!iddatadb && !idquotations) {
|
||||||
const errorMsg = $(
|
const errorMsg = $(
|
||||||
@@ -137,7 +136,7 @@ $(document).ready(function () {
|
|||||||
}
|
}
|
||||||
descriptionTextbox = null;
|
descriptionTextbox = null;
|
||||||
markerObjects = {};
|
markerObjects = {};
|
||||||
globalMarkerSize = 16;
|
globalMarkerSize = 24;
|
||||||
$("#photoSelectorContainerAnnotations").empty().hide();
|
$("#photoSelectorContainerAnnotations").empty().hide();
|
||||||
$("#samplePhotoAnnotations").attr("src", "");
|
$("#samplePhotoAnnotations").attr("src", "");
|
||||||
$("#partsListAnnotations").empty();
|
$("#partsListAnnotations").empty();
|
||||||
@@ -160,20 +159,6 @@ $(document).ready(function () {
|
|||||||
.on("input", "#markerSizeSlider", function () {
|
.on("input", "#markerSizeSlider", function () {
|
||||||
globalMarkerSize = parseInt($(this).val());
|
globalMarkerSize = parseInt($(this).val());
|
||||||
$("#markerSizeValue").text(globalMarkerSize + "px");
|
$("#markerSizeValue").text(globalMarkerSize + "px");
|
||||||
|
|
||||||
partsListData.forEach(function (part) {
|
|
||||||
if (part && part.part_number != null) {
|
|
||||||
partSizes[part.part_number] = globalMarkerSize;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#partsListAnnotations .marker-size-slider").val(
|
|
||||||
globalMarkerSize,
|
|
||||||
);
|
|
||||||
$("#partsListAnnotations .marker-size-value").text(
|
|
||||||
globalMarkerSize + "px",
|
|
||||||
);
|
|
||||||
|
|
||||||
updateMarkers();
|
updateMarkers();
|
||||||
markUnsaved();
|
markUnsaved();
|
||||||
});
|
});
|
||||||
@@ -381,13 +366,22 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
const partColor =
|
const partColor =
|
||||||
partColors[selectedPartNumber] || "#ff0000";
|
partColors[selectedPartNumber] || "#ff0000";
|
||||||
photoAnnotations[currentPhoto].markers.push({
|
const existingMarker = photoAnnotations[
|
||||||
id: nextMarkerId++,
|
currentPhoto
|
||||||
partNumber: selectedPartNumber,
|
].markers.find((m) => m.partNumber == selectedPartNumber);
|
||||||
x,
|
|
||||||
y,
|
if (existingMarker) {
|
||||||
color: partColor,
|
existingMarker.x = x;
|
||||||
});
|
existingMarker.y = y;
|
||||||
|
existingMarker.color = partColor;
|
||||||
|
} else {
|
||||||
|
photoAnnotations[currentPhoto].markers.push({
|
||||||
|
partNumber: selectedPartNumber,
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
color: partColor,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
console.log("Marker aggiunto/spostato:", {
|
console.log("Marker aggiunto/spostato:", {
|
||||||
partNumber: selectedPartNumber,
|
partNumber: selectedPartNumber,
|
||||||
@@ -397,6 +391,8 @@ $(document).ready(function () {
|
|||||||
});
|
});
|
||||||
updateMarkers();
|
updateMarkers();
|
||||||
markUnsaved();
|
markUnsaved();
|
||||||
|
selectedPartNumber = null;
|
||||||
|
$("#partsListAnnotations li").removeClass("active");
|
||||||
});
|
});
|
||||||
|
|
||||||
fabricCanvas.upperCanvasEl.focus();
|
fabricCanvas.upperCanvasEl.focus();
|
||||||
@@ -554,15 +550,10 @@ $(document).ready(function () {
|
|||||||
});
|
});
|
||||||
modal.show();
|
modal.show();
|
||||||
} else {
|
} else {
|
||||||
let iddatadb =
|
let iddatadb = $("#annotationsModal").attr('data-iddatadb');
|
||||||
$("#annotationsModal").attr("data-iddatadb");
|
|
||||||
|
$("button.parts-btn[data-iddatadb='" + iddatadb + "']").trigger('click');
|
||||||
$(
|
}
|
||||||
"button.parts-btn[data-iddatadb='" +
|
|
||||||
iddatadb +
|
|
||||||
"']",
|
|
||||||
).trigger("click");
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
).fail(function (xhr) {
|
).fail(function (xhr) {
|
||||||
console.error("Errore caricamento modale parti:", xhr);
|
console.error("Errore caricamento modale parti:", xhr);
|
||||||
@@ -669,21 +660,8 @@ $(document).ready(function () {
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const $listItem = $(this);
|
const $listItem = $(this);
|
||||||
const partNumber = $listItem.data("part-number");
|
selectedPartNumber = $listItem.data("part-number");
|
||||||
|
|
||||||
if (
|
|
||||||
selectedPartNumber == partNumber &&
|
|
||||||
$listItem.hasClass("active")
|
|
||||||
) {
|
|
||||||
selectedPartNumber = null;
|
|
||||||
$listItem.removeClass("active");
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
selectedPartNumber = partNumber;
|
|
||||||
$listItem.addClass("active").siblings().removeClass("active");
|
$listItem.addClass("active").siblings().removeClass("active");
|
||||||
console.log(
|
console.log(
|
||||||
"Parte selezionata tramite riga:",
|
"Parte selezionata tramite riga:",
|
||||||
@@ -733,23 +711,12 @@ $(document).ready(function () {
|
|||||||
.find(".selected-color")
|
.find(".selected-color")
|
||||||
.css("background-color", color);
|
.css("background-color", color);
|
||||||
|
|
||||||
let currentPhoto = $("#samplePhotoAnnotations").attr("src");
|
// Se il marker è già presente, aggiorna anche sul canvas
|
||||||
let annotations = photoAnnotations[currentPhoto];
|
if (markerObjects[partNumber]) {
|
||||||
|
const group = markerObjects[partNumber];
|
||||||
if (annotations) {
|
const circle = group.item(0); // il cerchio
|
||||||
annotations.markers.forEach(function (m) {
|
circle.set("fill", color);
|
||||||
if (m.partNumber == partNumber) {
|
circle.set("stroke", color);
|
||||||
m.color = color;
|
|
||||||
let group = markerObjects[m.id];
|
|
||||||
|
|
||||||
if (group) {
|
|
||||||
let circle = group.item(0);
|
|
||||||
|
|
||||||
circle.set("fill", color);
|
|
||||||
circle.set("stroke", color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
fabricCanvas.renderAll();
|
fabricCanvas.renderAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -937,9 +904,9 @@ $(document).ready(function () {
|
|||||||
"updateMarkers chiamato, markerObjects:",
|
"updateMarkers chiamato, markerObjects:",
|
||||||
Object.keys(markerObjects),
|
Object.keys(markerObjects),
|
||||||
);
|
);
|
||||||
for (let markerId in markerObjects) {
|
for (let partNumber in markerObjects) {
|
||||||
fabricCanvas.remove(markerObjects[markerId]);
|
fabricCanvas.remove(markerObjects[partNumber]);
|
||||||
delete markerObjects[markerId];
|
delete markerObjects[partNumber];
|
||||||
}
|
}
|
||||||
markerObjects = {};
|
markerObjects = {};
|
||||||
|
|
||||||
@@ -1020,9 +987,6 @@ $(document).ready(function () {
|
|||||||
lockRotation: true,
|
lockRotation: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
group.markerId = marker.id;
|
|
||||||
group.partNumber = marker.partNumber;
|
|
||||||
|
|
||||||
group.on("moving", function () {
|
group.on("moving", function () {
|
||||||
marker.x = this.left / photoData.scale;
|
marker.x = this.left / photoData.scale;
|
||||||
marker.y = this.top / photoData.scale;
|
marker.y = this.top / photoData.scale;
|
||||||
@@ -1035,7 +999,7 @@ $(document).ready(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
fabricCanvas.add(group);
|
fabricCanvas.add(group);
|
||||||
markerObjects[marker.id] = group;
|
markerObjects[marker.partNumber] = group;
|
||||||
});
|
});
|
||||||
|
|
||||||
fabricCanvas.renderAll();
|
fabricCanvas.renderAll();
|
||||||
@@ -1189,9 +1153,9 @@ $(document).ready(function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let markerId in markerObjects) {
|
for (let partNumber in markerObjects) {
|
||||||
fabricCanvas.remove(markerObjects[markerId]);
|
fabricCanvas.remove(markerObjects[partNumber]);
|
||||||
delete markerObjects[markerId];
|
delete markerObjects[partNumber];
|
||||||
}
|
}
|
||||||
markerObjects = {};
|
markerObjects = {};
|
||||||
|
|
||||||
@@ -1226,9 +1190,9 @@ $(document).ready(function () {
|
|||||||
photoAnnotations[currentPhoto].markers.length > 0
|
photoAnnotations[currentPhoto].markers.length > 0
|
||||||
) {
|
) {
|
||||||
const lastMarker = photoAnnotations[currentPhoto].markers.pop();
|
const lastMarker = photoAnnotations[currentPhoto].markers.pop();
|
||||||
if (markerObjects[lastMarker.id]) {
|
if (markerObjects[lastMarker.partNumber]) {
|
||||||
fabricCanvas.remove(markerObjects[lastMarker.id]);
|
fabricCanvas.remove(markerObjects[lastMarker.partNumber]);
|
||||||
delete markerObjects[lastMarker.id];
|
delete markerObjects[lastMarker.partNumber];
|
||||||
fabricCanvas.renderAll();
|
fabricCanvas.renderAll();
|
||||||
}
|
}
|
||||||
console.log("Ultimo marker rimosso:", lastMarker);
|
console.log("Ultimo marker rimosso:", lastMarker);
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
include('include/headscript.php');
|
||||||
|
|
||||||
|
$dbHandler = DBHandlerSelect::getInstance();
|
||||||
|
$pdo = $dbHandler->getConnection();
|
||||||
|
|
||||||
|
// Recupera l'ID dell'utente loggato
|
||||||
|
$user_id = $iduserlogin ?? 1;
|
||||||
|
|
||||||
|
if (!$user_id) {
|
||||||
|
echo json_encode(['success' => false, 'message' => "ID dell'utente autenticato mancante"]);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$stmt = $pdo->prepare(
|
||||||
|
"SELECT DISTINCT q.*
|
||||||
|
FROM quotations q
|
||||||
|
INNER JOIN identification_parts ip
|
||||||
|
ON ip.idquotations = q.id
|
||||||
|
AND ip.iddatadb IS NULL
|
||||||
|
WHERE q.iduser = :iduser"
|
||||||
|
);
|
||||||
|
$stmt->execute([':iduser' => $user_id]);
|
||||||
|
$quotations = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'quotations' => $quotations]);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Errore nel caricamento delle quotations: ' . $e->getMessage()]);
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
<!-- SLIDER PER DIMENSIONE MARKER -->
|
<!-- SLIDER PER DIMENSIONE MARKER -->
|
||||||
<div style="display: flex; align-items: center; gap: 10px; margin-left: 20px;">
|
<div style="display: flex; align-items: center; gap: 10px; margin-left: 20px;">
|
||||||
<label for="markerSizeSlider" style="margin: 0; font-size: 0.9rem; white-space: nowrap;">Dimensione marker:</label>
|
<label for="markerSizeSlider" style="margin: 0; font-size: 0.9rem; white-space: nowrap;">Dimensione marker:</label>
|
||||||
<input type="range" id="markerSizeSlider" min="16" max="48" value="16" step="2" style="width: 120px;">
|
<input type="range" id="markerSizeSlider" min="16" max="48" value="24" step="2" style="width: 120px;">
|
||||||
<span id="markerSizeValue" style="font-weight: bold; min-width: 30px;">24px</span>
|
<span id="markerSizeValue" style="font-weight: bold; min-width: 30px;">24px</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
<div style="display: flex; align-items: center;">
|
<div style="display: flex; align-items: center;">
|
||||||
<button type="button" class="btn btn-info btn-sm" id="renumberPartsBtn" style="padding: 0.1rem 0.5rem; font-size: 0.8rem;">Rinumera Parti</button>
|
<button type="button" class="btn btn-info btn-sm" id="renumberPartsBtn" style="padding: 0.1rem 0.5rem; font-size: 0.8rem;">Rinumera Parti</button>
|
||||||
<button type="button" class="btn btn-secondary btn-sm ms-2" id="toggleVoiceBtn" style="padding: 0.1rem 0.5rem; font-size: 0.8rem;"><i class="fas fa-microphone"></i> Voce</button>
|
<button type="button" class="btn btn-secondary btn-sm ms-2" id="toggleVoiceBtn" style="padding: 0.1rem 0.5rem; font-size: 0.8rem;"><i class="fas fa-microphone"></i> Voce</button>
|
||||||
|
<button type="button" class="btn btn-info btn-sm ms-2 d-none" id="quotationeBtn" style="padding: 0.1rem 0.5rem; font-size: 0.8rem;">Add Quotation</button>
|
||||||
<button type="button" class="btn btn-primary btn-sm ms-2" id="showHideImageBtn" style="padding: 0.1rem 0.5rem; font-size: 0.8rem;">
|
<button type="button" class="btn btn-primary btn-sm ms-2" id="showHideImageBtn" style="padding: 0.1rem 0.5rem; font-size: 0.8rem;">
|
||||||
<i class="fas fa-eye-slash" style="font-size: 0.8rem;"></i>
|
<i class="fas fa-eye-slash" style="font-size: 0.8rem;"></i>
|
||||||
<i class="fas fa-image ms-1" style="font-size: 0.8rem;"></i>
|
<i class="fas fa-image ms-1" style="font-size: 0.8rem;"></i>
|
||||||
@@ -145,6 +146,24 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- Finestra modale "Aggiungi preventivo" -->
|
||||||
|
<div class="modal fade" id="addQuotationModal" tabindex="-1" aria-labelledby="addQuotationModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-md">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="addQuotationModalLabel">Choose a quotation</h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<select id="addQuotationSelect" class="form-control form-control-sm" style="width: 100% !important; min-width: 100% !important"></select>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary btn-sm" data-bs-dismiss="modal">Annulla</button>
|
||||||
|
<button type="button" class="btn btn-primary btn-sm" id="addQuotationBtn">Confirm</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
/* --- Base --- */
|
/* --- Base --- */
|
||||||
@@ -161,6 +180,14 @@
|
|||||||
max-width: 100% !important
|
max-width: 100% !important
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#addQuotationModal {
|
||||||
|
z-index: 1060 !important
|
||||||
|
}
|
||||||
|
|
||||||
|
#addQuotationModal .modal-backdrop {
|
||||||
|
z-index: 1055 !important
|
||||||
|
}
|
||||||
|
|
||||||
/* Tabelle */
|
/* Tabelle */
|
||||||
#partsTable tr {
|
#partsTable tr {
|
||||||
display: table-row !important
|
display: table-row !important
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ $(document).ready(function () {
|
|||||||
let unsavedChanges = false;
|
let unsavedChanges = false;
|
||||||
let matrici = [];
|
let matrici = [];
|
||||||
let macroMatrici = [];
|
let macroMatrici = [];
|
||||||
|
let quotations = [];
|
||||||
|
|
||||||
// --- ROW ID helpers: niente più cache impazzita di jQuery .data() ---
|
// --- ROW ID helpers: niente più cache impazzita di jQuery .data() ---
|
||||||
function getPartId($row) {
|
function getPartId($row) {
|
||||||
@@ -141,7 +142,7 @@ $(document).ready(function () {
|
|||||||
// ===================
|
// ===================
|
||||||
// MODAL HANDLING
|
// MODAL HANDLING
|
||||||
// ===================
|
// ===================
|
||||||
function loadParts(iddatadb, idquotations) {
|
function loadParts(iddatadb, idquotations, callback = null) {
|
||||||
if (iddatadb) {
|
if (iddatadb) {
|
||||||
if (matrici.length === 0) {
|
if (matrici.length === 0) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@@ -153,14 +154,14 @@ $(document).ready(function () {
|
|||||||
loadMacroMatrici();
|
loadMacroMatrici();
|
||||||
initializeGlobalSelect2();
|
initializeGlobalSelect2();
|
||||||
loadPhoto(iddatadb, idquotations);
|
loadPhoto(iddatadb, idquotations);
|
||||||
loadExistingParts(iddatadb, idquotations);
|
loadExistingParts(iddatadb, idquotations, callback);
|
||||||
},
|
},
|
||||||
error: function (xhr, status, error) {
|
error: function (xhr, status, error) {
|
||||||
matrici = [];
|
matrici = [];
|
||||||
loadMacroMatrici();
|
loadMacroMatrici();
|
||||||
initializeGlobalSelect2();
|
initializeGlobalSelect2();
|
||||||
loadPhoto(iddatadb, idquotations);
|
loadPhoto(iddatadb, idquotations);
|
||||||
loadExistingParts(iddatadb, idquotations);
|
loadExistingParts(iddatadb, idquotations, callback);
|
||||||
const errorMsg = $(
|
const errorMsg = $(
|
||||||
'<div class="alert alert-danger temp-alert" role="alert">Errore nel caricamento delle matrici: ' +
|
'<div class="alert alert-danger temp-alert" role="alert">Errore nel caricamento delle matrici: ' +
|
||||||
error +
|
error +
|
||||||
@@ -180,11 +181,11 @@ $(document).ready(function () {
|
|||||||
loadMacroMatrici();
|
loadMacroMatrici();
|
||||||
initializeGlobalSelect2();
|
initializeGlobalSelect2();
|
||||||
loadPhoto(iddatadb, idquotations);
|
loadPhoto(iddatadb, idquotations);
|
||||||
loadExistingParts(iddatadb, idquotations);
|
loadExistingParts(iddatadb, idquotations, callback);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
loadPhoto(iddatadb, idquotations);
|
loadPhoto(iddatadb, idquotations);
|
||||||
loadExistingParts(iddatadb, idquotations);
|
loadExistingParts(iddatadb, idquotations, callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -589,6 +590,8 @@ $(document).ready(function () {
|
|||||||
if (response.success) {
|
if (response.success) {
|
||||||
$saveStatus.show();
|
$saveStatus.show();
|
||||||
setTimeout(() => $saveStatus.hide(), 2000);
|
setTimeout(() => $saveStatus.hide(), 2000);
|
||||||
|
|
||||||
|
if (!$("#quotationeBtn").hasClass('d-none')) $("#quotationeBtn").addClass("d-none");
|
||||||
} else {
|
} else {
|
||||||
const errorMsg = $(
|
const errorMsg = $(
|
||||||
'<div class="alert alert-danger temp-alert" role="alert">Errore nel salvataggio: ' +
|
'<div class="alert alert-danger temp-alert" role="alert">Errore nel salvataggio: ' +
|
||||||
@@ -1155,7 +1158,7 @@ $(document).ready(function () {
|
|||||||
saveRow($(this).closest("tr"));
|
saveRow($(this).closest("tr"));
|
||||||
});
|
});
|
||||||
|
|
||||||
function loadExistingParts(iddatadb, idquotations) {
|
function loadExistingParts(iddatadb, idquotations, callback = null) {
|
||||||
const endpoint = idquotations
|
const endpoint = idquotations
|
||||||
? "load_parts_quotation.php"
|
? "load_parts_quotation.php"
|
||||||
: "load_parts.php";
|
: "load_parts.php";
|
||||||
@@ -1233,8 +1236,11 @@ $(document).ready(function () {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
addNewRow(1, false); // Riga iniziale normale
|
addNewRow(1, false); // Riga iniziale normale
|
||||||
|
$("#quotationeBtn").removeClass("d-none");
|
||||||
}
|
}
|
||||||
updateRowButtons();
|
updateRowButtons();
|
||||||
|
|
||||||
|
if (callback) callback();
|
||||||
},
|
},
|
||||||
error: function (xhr, status, error) {
|
error: function (xhr, status, error) {
|
||||||
const errorMsg = $(
|
const errorMsg = $(
|
||||||
@@ -1787,6 +1793,122 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
// Esporta la funzione loadParts per essere usata da import_Edit2.php
|
// Esporta la funzione loadParts per essere usata da import_Edit2.php
|
||||||
window.loadParts = loadParts;
|
window.loadParts = loadParts;
|
||||||
|
|
||||||
|
$(document).on("click", "#quotationeBtn", function () {
|
||||||
|
$("#addQuotationModal").modal("show");
|
||||||
|
|
||||||
|
if (quotations.length > 0) {
|
||||||
|
reloadQuotations();
|
||||||
|
} else {
|
||||||
|
$.ajax({
|
||||||
|
url: "load_quotations.php",
|
||||||
|
method: "GET",
|
||||||
|
success: function (response) {
|
||||||
|
quotations = response?.quotations || [];
|
||||||
|
|
||||||
|
reloadQuotations();
|
||||||
|
},
|
||||||
|
error: function (xhr, status, error) {
|
||||||
|
console.error("Errore AJAX caricamento quotations:", error, xhr.responseText);
|
||||||
|
let message = `
|
||||||
|
<div class="alert alert-danger temp-alert" role="alert">
|
||||||
|
Errore nel caricamento delle quotations: ${error} (${xhr.status})
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
$("#partsModal .modal-body").prepend(errorMsg);
|
||||||
|
|
||||||
|
setTimeout(function () {
|
||||||
|
message.fadeOut(500, function () {
|
||||||
|
$(this).remove();
|
||||||
|
});
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on("click", "#addQuotationBtn", function () {
|
||||||
|
const quotationId = $("#addQuotationSelect").val();
|
||||||
|
|
||||||
|
if (quotationId && confirm("Confermo di collegare la quotazione al campione?")) {
|
||||||
|
$("#addQuotationModal").modal("hide");
|
||||||
|
|
||||||
|
loadParts(null, quotationId, () => {
|
||||||
|
$("#quotationeBtn").addClass("d-none");
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
$("#partsTableBody tr").each(function () {
|
||||||
|
$(this).find(".save-loading").show();
|
||||||
|
});
|
||||||
|
|
||||||
|
let photoList = $('#photoSelector option').map(function () {
|
||||||
|
return this.value?.split('/')?.pop();
|
||||||
|
}).get();
|
||||||
|
|
||||||
|
if (!photoList.length) {
|
||||||
|
let path = $('#samplePhoto').attr("src")?.split('/')?.pop();
|
||||||
|
|
||||||
|
if (path) photoList = [path];
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "save_parts_photo_iddatadb.php",
|
||||||
|
method: "POST",
|
||||||
|
data: JSON.stringify({
|
||||||
|
iddatadb: $("#partsModal").data("iddatadb"),
|
||||||
|
photoList,
|
||||||
|
partIds: $('#partsTableBody tr').map(function () {
|
||||||
|
return $(this).data("part-id");
|
||||||
|
}).get(),
|
||||||
|
}),
|
||||||
|
success: function () {
|
||||||
|
$("#partsTableBody tr").each(function () {
|
||||||
|
let $row = $(this);
|
||||||
|
let $saveStatus = $row.find(".save-status");
|
||||||
|
let $saveLoading = $row.find(".save-loading");
|
||||||
|
|
||||||
|
$saveLoading.hide();
|
||||||
|
$saveStatus.show();
|
||||||
|
|
||||||
|
setTimeout(() => $saveStatus.hide(), 2000);
|
||||||
|
});
|
||||||
|
}, error: function (xhr, status, error) {
|
||||||
|
let message = `
|
||||||
|
<div class="alert alert-danger temp-alert" role="alert">
|
||||||
|
Errore di salvataggio: ${error} (${xhr.status})
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
$("#partsModal .modal-body").prepend(message);
|
||||||
|
|
||||||
|
setTimeout(function () {
|
||||||
|
message.fadeOut(500, function () {
|
||||||
|
$(this).remove();
|
||||||
|
});
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function reloadQuotations() {
|
||||||
|
if (quotations.length > 0) {
|
||||||
|
$("#addQuotationSelect").empty();
|
||||||
|
|
||||||
|
$("#addQuotationSelect").append("<option value=''>Seleziona Quotation</option>");
|
||||||
|
|
||||||
|
quotations.forEach(quotation => {
|
||||||
|
if (quotation?.description) {
|
||||||
|
$("#addQuotationSelect").append(`<option value='${quotation?.id}'>${quotation?.description}</option>`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#addQuotationSelect").select2();
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on("change", ".propagate-date-input", function () {
|
$(document).on("change", ".propagate-date-input", function () {
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
include('include/headscript.php');
|
||||||
|
|
||||||
|
$dbHandler = DBHandlerSelect::getInstance();
|
||||||
|
$pdo = $dbHandler->getConnection();
|
||||||
|
|
||||||
|
$data = json_decode(file_get_contents('php://input'), true);
|
||||||
|
|
||||||
|
$iddatadb = $data['iddatadb'] ?? null;
|
||||||
|
$partIds = $data['partIds'] ?? [];
|
||||||
|
$photoList = $data['photoList'] ?? null;
|
||||||
|
|
||||||
|
if ($iddatadb) {
|
||||||
|
if (count($partIds) != 0) {
|
||||||
|
$idList = array_values(array_map('intval', $partIds));
|
||||||
|
$placeholders = [];
|
||||||
|
$parameters = [':iddatadb' => $iddatadb];
|
||||||
|
|
||||||
|
foreach ($idList as $index => $id) {
|
||||||
|
$paramName = ":id{$index}";
|
||||||
|
$placeholders[] = $paramName;
|
||||||
|
$parameters[$paramName] = $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = 'UPDATE identification_parts SET iddatadb = :iddatadb WHERE id IN (' . implode(',', $placeholders) . ')';
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->execute($parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($photoList) != 0) {
|
||||||
|
$placeholders = [];
|
||||||
|
$parameters = [':iddatadb' => $iddatadb];
|
||||||
|
|
||||||
|
foreach ($photoList as $index => $photo) {
|
||||||
|
$paramName = ":photo{$index}";
|
||||||
|
$placeholders[] = $paramName;
|
||||||
|
$parameters[$paramName] = $photo;
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt = $pdo->prepare('UPDATE datadb_photos SET iddatadb = :iddatadb WHERE file_path IN (' . implode(',', $placeholders) . ')');
|
||||||
|
$stmt->execute($parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => '']);
|
||||||
|
} else {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Dati mancanti']);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user