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