fixed Mix
This commit is contained in:
parent
813bd66f96
commit
0f0c6a04b7
@ -614,17 +614,11 @@ $(document).ready(function () {
|
||||
partsListData.forEach((part) => {
|
||||
const partNumber = part.part_number;
|
||||
const partDescription = part.part_description;
|
||||
const isMixPart = String(part.mix || "N").toUpperCase() === "Y";
|
||||
|
||||
const partColor =
|
||||
partColors[partNumber] ||
|
||||
(partDescription.toLowerCase().startsWith("mix")
|
||||
? "#0000ff"
|
||||
: "#ff0000");
|
||||
if (
|
||||
partNumber &&
|
||||
partDescription &&
|
||||
(showMixParts ||
|
||||
!partDescription.toLowerCase().startsWith("mix"))
|
||||
) {
|
||||
partColors[partNumber] || (isMixPart ? "#0000ff" : "#ff0000");
|
||||
if (partNumber && partDescription && (showMixParts || !isMixPart)) {
|
||||
const colorOptions = predefinedColors
|
||||
.map(
|
||||
(color) =>
|
||||
@ -922,11 +916,10 @@ $(document).ready(function () {
|
||||
) {
|
||||
partsListData = response.parts;
|
||||
response.parts.forEach((part) => {
|
||||
const defaultColor = part.part_description
|
||||
.toLowerCase()
|
||||
.startsWith("mix")
|
||||
? "#0000ff"
|
||||
: "#ff0000";
|
||||
const isMixPart =
|
||||
String(part.mix || "N").toUpperCase() === "Y";
|
||||
const defaultColor = isMixPart ? "#0000ff" : "#ff0000";
|
||||
|
||||
partColors[part.part_number] = defaultColor;
|
||||
});
|
||||
updatePartsList();
|
||||
@ -1003,11 +996,10 @@ $(document).ready(function () {
|
||||
(p) => p.part_number == marker.partNumber,
|
||||
);
|
||||
const partDescription = part ? part.part_description : "";
|
||||
if (
|
||||
!showMixParts &&
|
||||
partDescription &&
|
||||
partDescription.toLowerCase().startsWith("mix")
|
||||
) {
|
||||
const isMixPart =
|
||||
part && String(part.mix || "N").toUpperCase() === "Y";
|
||||
|
||||
if (!showMixParts && isMixPart) {
|
||||
console.log("Ignoro marker per parte Mix:", marker.partNumber);
|
||||
return;
|
||||
}
|
||||
@ -1115,11 +1107,10 @@ $(document).ready(function () {
|
||||
}
|
||||
|
||||
const partsList = partsListData
|
||||
.filter(
|
||||
(part) =>
|
||||
showMixParts ||
|
||||
!part.part_description.toLowerCase().startsWith("mix"),
|
||||
)
|
||||
.filter((part) => {
|
||||
const isMixPart = String(part.mix || "N").toUpperCase() === "Y";
|
||||
return showMixParts || !isMixPart;
|
||||
})
|
||||
.map((part) => `${part.part_number} ${part.part_description}`);
|
||||
|
||||
const text = partsList.join("\n");
|
||||
|
||||
@ -33,7 +33,7 @@ try {
|
||||
if ($extraFieldId) {
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT
|
||||
p.id, p.iddatadb, p.part_number, p.part_description, p.idmatrice, p.note, p.dateexpiry,
|
||||
p.id, p.iddatadb, p.part_number, p.part_description, p.mix, p.idmatrice, p.note, p.dateexpiry,
|
||||
cf.value_id AS extra_value_id,
|
||||
cf.value_text AS extra_value_text
|
||||
FROM identification_parts p
|
||||
@ -48,7 +48,7 @@ try {
|
||||
]);
|
||||
} else {
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT id, iddatadb, part_number, part_description, idmatrice, note, dateexpiry,
|
||||
SELECT id, iddatadb, part_number, part_description, mix, idmatrice, note, dateexpiry,
|
||||
NULL AS extra_value_id, NULL AS extra_value_text
|
||||
FROM identification_parts
|
||||
WHERE iddatadb = :iddatadb
|
||||
|
||||
@ -235,6 +235,17 @@ $(document).ready(function () {
|
||||
$row.data("__pid", id);
|
||||
}
|
||||
|
||||
function setRowMix($row, isMix) {
|
||||
const mixValue = isMix === true || isMix === "Y" ? "Y" : "N";
|
||||
$row.attr("data-is-mix", mixValue);
|
||||
$row.data("is-mix", mixValue);
|
||||
}
|
||||
|
||||
function getRowMix($row) {
|
||||
const value = $row.attr("data-is-mix") || $row.data("is-mix");
|
||||
return value === "Y" ? "Y" : "N";
|
||||
}
|
||||
|
||||
// ===================
|
||||
// VOICE RECOGNITION SETUP
|
||||
// ===================
|
||||
@ -698,7 +709,7 @@ $(document).ready(function () {
|
||||
const $saveLoading = $row.find(".save-loading");
|
||||
const iddatadb = $("#partsModal").data("iddatadb");
|
||||
const idquotations = $("#partsModal").data("idquotations");
|
||||
const isMix = partDescription.startsWith("Mix") ? "Y" : "N";
|
||||
const isMix = getRowMix($row);
|
||||
|
||||
// EXTRA FIELD (0/1)
|
||||
const extra_field_id = $row.find(".part-extra-field-id").val() || null;
|
||||
@ -837,11 +848,7 @@ $(document).ready(function () {
|
||||
|
||||
let $mixRow = $("#partsTableBody tr")
|
||||
.filter(function () {
|
||||
return $(this)
|
||||
.find(".part-description")
|
||||
.val()
|
||||
.trim()
|
||||
.startsWith("Mix");
|
||||
return getRowMix($(this)) === "Y";
|
||||
})
|
||||
.last();
|
||||
|
||||
@ -897,7 +904,7 @@ $(document).ready(function () {
|
||||
function addNewRow(nextPartNumber, isMix = false) {
|
||||
const description = isMix ? "Mix" : "";
|
||||
const newRow = `
|
||||
<tr data-part-id="new">
|
||||
<tr data-part-id="new" data-is-mix="${isMix ? "Y" : "N"}">
|
||||
<td><input type="number" class="form-control form-control-sm part-number" value="${nextPartNumber || 1}" style="width: 80px;"></td>
|
||||
<td><input type="text" class="form-control form-control-sm part-description" value="${description}" placeholder="Inserisci descrizione"></td>
|
||||
<td>
|
||||
@ -918,6 +925,7 @@ $(document).ready(function () {
|
||||
</tr>`;
|
||||
$("#partsTableBody").append(newRow);
|
||||
const $newRow = $("#partsTableBody tr:last");
|
||||
setRowMix($newRow, isMix ? "Y" : "N");
|
||||
const $select = $newRow.find(".part-matrice");
|
||||
const selectedMacro = $("#macro-matrice-filter").val() || "";
|
||||
|
||||
@ -1394,7 +1402,7 @@ $(document).ready(function () {
|
||||
? $("<div>").text(part.note).html()
|
||||
: "";
|
||||
const newRow = `
|
||||
<tr data-part-id="${part.id}" data-note="${escapedNote}">
|
||||
<tr data-part-id="${part.id}" data-note="${escapedNote}" data-is-mix="${part.mix === "Y" ? "Y" : "N"}">
|
||||
<td><input type="number" class="form-control form-control-sm part-number" value="${part.part_number || ""}" style="width: 80px;"></td>
|
||||
<td><input type="text" class="form-control form-control-sm part-description" value="${escapedDescription}" placeholder="Inserisci descrizione"></td>
|
||||
<td>
|
||||
@ -1418,7 +1426,7 @@ $(document).ready(function () {
|
||||
const $row = $(
|
||||
`#partsTableBody tr[data-part-id="${part.id}"]`,
|
||||
);
|
||||
|
||||
setRowMix($row, part.mix === "Y" ? "Y" : "N");
|
||||
if (
|
||||
part.extra_value_id !== undefined &&
|
||||
part.extra_value_id !== null
|
||||
@ -1883,7 +1891,7 @@ $(document).ready(function () {
|
||||
id: part.partId,
|
||||
part_number: index + 1,
|
||||
part_description: part.partDescription,
|
||||
mix: part.partDescription.startsWith("Mix") ? "Y" : "N",
|
||||
mix: getRowMix($rows.eq(index)),
|
||||
idmatrice: partMatrice[index + 1] || null,
|
||||
note: part.note,
|
||||
dateexpiry: part.dateexpiry,
|
||||
@ -2238,7 +2246,7 @@ $(document).on("change", ".propagate-date-input", function () {
|
||||
const partId = $row.data("part-id");
|
||||
const partNumber = $row.find(".part-number").val();
|
||||
const partDescription = $row.find(".part-description").val().trim();
|
||||
const mix = partDescription.startsWith("Mix") ? "Y" : "N";
|
||||
const mix = $row.attr("data-is-mix") === "Y" ? "Y" : "N";
|
||||
const idmatrice = $row.find(".part-matrice").val() || null;
|
||||
const note = $row.data("note") || null;
|
||||
|
||||
@ -2349,7 +2357,7 @@ $(document).on("click", ".save-common-note-btn", function () {
|
||||
const partId = $row.data("part-id");
|
||||
const partNumber = $row.find(".part-number").val();
|
||||
const partDescription = $row.find(".part-description").val().trim();
|
||||
const mix = partDescription.startsWith("Mix") ? "Y" : "N";
|
||||
const mix = $row.attr("data-is-mix") === "Y" ? "Y" : "N";
|
||||
const idmatrice = $row.find(".part-matrice").val() || null;
|
||||
const dateexpiry = $row.find(".part-dateexpiry").val() || null;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user