automatic date on part from ConsegnaRichiesta
This commit is contained in:
@@ -32,6 +32,16 @@ $(document).ready(function () {
|
||||
return id === "new" || id === "" || id === null ? null : id;
|
||||
}
|
||||
|
||||
// Legge ConsegnaRichiesta del record corrente dalla griglia (fixed field data)
|
||||
function getConsegnaRichiestaDefault() {
|
||||
const iddatadb = $("#partsModal").data("iddatadb");
|
||||
if (!iddatadb) return "";
|
||||
if (typeof getGridRecordById !== "function") return "";
|
||||
const record = getGridRecordById(iddatadb);
|
||||
if (!record || !record.fixedFields) return "";
|
||||
return record.fixedFields.ConsegnaRichiesta || "";
|
||||
}
|
||||
|
||||
function loadPartsExtraField(iddatadb, done) {
|
||||
partsExtraField = null;
|
||||
|
||||
@@ -1251,6 +1261,13 @@ $(document).ready(function () {
|
||||
initializeSelect2($select, nextPartNumber, "", null, selectedMacro);
|
||||
initializeExtraFieldSelect2($newRow);
|
||||
|
||||
// Default: data di consegna richiesta dal record (solo se il campo è vuoto)
|
||||
const $dateInput = $newRow.find(".part-dateexpiry");
|
||||
if ($dateInput.length && !$dateInput.val()) {
|
||||
const consegna = getConsegnaRichiestaDefault();
|
||||
if (consegna) $dateInput.val(consegna);
|
||||
}
|
||||
|
||||
updateRowButtons();
|
||||
|
||||
if (!isLoadingPartsRecord) {
|
||||
@@ -1581,6 +1598,13 @@ $(document).ready(function () {
|
||||
`#partsTableBody tr[data-part-id="${part.id}"]`,
|
||||
);
|
||||
setRowMix($row, part.mix === "Y" ? "Y" : "N");
|
||||
// Default consegna richiesta se la parte non ha già una data
|
||||
if (!(part.dateexpiry || "")) {
|
||||
const consegnaDef = getConsegnaRichiestaDefault();
|
||||
if (consegnaDef) {
|
||||
$row.find(".part-dateexpiry").val(consegnaDef);
|
||||
}
|
||||
}
|
||||
if (
|
||||
part.extra_value_id !== undefined &&
|
||||
part.extra_value_id !== null
|
||||
|
||||
Reference in New Issue
Block a user