added Fatturazione in export and fixed attivo inattivo, added desxription to parts
This commit is contained in:
@@ -157,6 +157,7 @@ try {
|
|||||||
d.anagrafica_certest_service_id,
|
d.anagrafica_certest_service_id,
|
||||||
d.cliente_fornitore_id,
|
d.cliente_fornitore_id,
|
||||||
d.clienteAnalisi,
|
d.clienteAnalisi,
|
||||||
|
d.ClienteFatturazione,
|
||||||
d.consegna_richiesta
|
d.consegna_richiesta
|
||||||
FROM datadb as d
|
FROM datadb as d
|
||||||
INNER JOIN excel_templates as et ON d.templateid = et.id
|
INNER JOIN excel_templates as et ON d.templateid = et.id
|
||||||
@@ -180,11 +181,12 @@ try {
|
|||||||
$anagraficaService = !empty($result['anagrafica_certest_service_id']) ? (int) $result['anagrafica_certest_service_id'] : null;
|
$anagraficaService = !empty($result['anagrafica_certest_service_id']) ? (int) $result['anagrafica_certest_service_id'] : null;
|
||||||
$clienteFornitore = !empty($result['cliente_fornitore_id']) ? (int) $result['cliente_fornitore_id'] : null;
|
$clienteFornitore = !empty($result['cliente_fornitore_id']) ? (int) $result['cliente_fornitore_id'] : null;
|
||||||
$clienteAnalisi = !empty($result['clienteAnalisi']) ? (int) $result['clienteAnalisi'] : null;
|
$clienteAnalisi = !empty($result['clienteAnalisi']) ? (int) $result['clienteAnalisi'] : null;
|
||||||
|
$clienteFatturazione = !empty($result['ClienteFatturazione']) ? (int) $result['ClienteFatturazione'] : null;
|
||||||
$consegnaRichiesta = !empty($result['consegna_richiesta']) ? $result['consegna_richiesta'] : null;
|
$consegnaRichiesta = !empty($result['consegna_richiesta']) ? $result['consegna_richiesta'] : null;
|
||||||
|
|
||||||
// 🔹 STEP 3: Fetch Parts (including idmatrice and part id for custom fields)
|
// 🔹 STEP 3: Fetch Parts (including idmatrice and part id for custom fields)
|
||||||
$stmt = $pdo->prepare("
|
$stmt = $pdo->prepare("
|
||||||
SELECT id AS part_id, part_number, part_description, material, color, mix, idmatrice, dateexpiry
|
SELECT id AS part_id, part_number, part_description, material, color, mix, idmatrice, dateexpiry, note
|
||||||
FROM identification_parts
|
FROM identification_parts
|
||||||
WHERE iddatadb = :iddatadb
|
WHERE iddatadb = :iddatadb
|
||||||
AND part_description IS NOT NULL
|
AND part_description IS NOT NULL
|
||||||
@@ -274,6 +276,7 @@ try {
|
|||||||
"AnagraficaCertestService" => $anagraficaService,
|
"AnagraficaCertestService" => $anagraficaService,
|
||||||
"ClienteFornitore" => $clienteFornitore, // PLACEHOLDER — to be implemented
|
"ClienteFornitore" => $clienteFornitore, // PLACEHOLDER — to be implemented
|
||||||
"ClienteAnalisi" => $clienteAnalisi, // PLACEHOLDER — to be implemented
|
"ClienteAnalisi" => $clienteAnalisi, // PLACEHOLDER — to be implemented
|
||||||
|
"ClienteFatturazione" => $clienteFatturazione,
|
||||||
// DeliveryRequest goes to Campione, not CommessaWeb
|
// DeliveryRequest goes to Campione, not CommessaWeb
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -306,13 +309,17 @@ try {
|
|||||||
throw new Exception("Invalid or missing idmatrice for part: " . ($part["part_number"] ?? "Unknown"));
|
throw new Exception("Invalid or missing idmatrice for part: " . ($part["part_number"] ?? "Unknown"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$partDescription = $part["part_description"] ?? "";
|
||||||
|
$partNote = trim((string)($part["note"] ?? ""));
|
||||||
|
$noteWebValue = $partNote !== "" ? $partDescription . " - " . $partNote : $partDescription;
|
||||||
|
|
||||||
$campionePayload = [
|
$campionePayload = [
|
||||||
"Commessa" => $commessaId,
|
"Commessa" => $commessaId,
|
||||||
"Matrice" => $matriceId,
|
"Matrice" => $matriceId,
|
||||||
"SottoMatrice" => null,
|
"SottoMatrice" => null,
|
||||||
"SchemaCustomField" => $schemaId,
|
"SchemaCustomField" => $schemaId,
|
||||||
// "Riferimento" => $part["part_description"] ?? "",
|
// "Riferimento" => $part["part_description"] ?? "",
|
||||||
"NoteWeb" => $part["part_description"] ?? "",
|
"NoteWeb" => $noteWebValue,
|
||||||
"ConsegnaRichiesta" => !empty($part["dateexpiry"]) ? $part["dateexpiry"] : $consegnaRichiesta,
|
"ConsegnaRichiesta" => !empty($part["dateexpiry"]) ? $part["dateexpiry"] : $consegnaRichiesta,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -162,8 +162,8 @@
|
|||||||
// Mappa: quale filtro Inattivo applicare per ogni campo cliente
|
// Mappa: quale filtro Inattivo applicare per ogni campo cliente
|
||||||
const clientFieldTipoMap = {
|
const clientFieldTipoMap = {
|
||||||
ClienteFornitore: "attivo",
|
ClienteFornitore: "attivo",
|
||||||
ClienteAnalisi: "attivo",
|
ClienteAnalisi: "inattivo",
|
||||||
ClienteFatturazione: "inattivo",
|
ClienteFatturazione: "attivo",
|
||||||
};
|
};
|
||||||
|
|
||||||
// Select2 AJAX config factory for client selects (parametrizzata su "tipo")
|
// Select2 AJAX config factory for client selects (parametrizzata su "tipo")
|
||||||
|
|||||||
@@ -2501,9 +2501,9 @@ $apiSampleJson = $template['api_sample_json'] ?? '';
|
|||||||
return v === true || v === 1 || v === '1' || v === 'true';
|
return v === true || v === 1 || v === '1' || v === 'true';
|
||||||
};
|
};
|
||||||
|
|
||||||
// Fornitore e Analisi: solo clienti ATTIVI (Inattivo = false)
|
// Fornitore e Fatturazione: solo clienti ATTIVI (Inattivo = false)
|
||||||
// Fatturazione: solo clienti INATTIVI (Inattivo = true)
|
// Analisi: solo clienti INATTIVI (Inattivo = true)
|
||||||
const filtered = (key === 'ClienteFatturazione') ?
|
const filtered = (key === 'ClienteAnalisi') ?
|
||||||
list.filter(isInattivo) :
|
list.filter(isInattivo) :
|
||||||
list.filter(x => !isInattivo(x));
|
list.filter(x => !isInattivo(x));
|
||||||
|
|
||||||
|
|||||||
@@ -208,6 +208,23 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
#partsModalLabel {
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
#trfHeader {
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- Base --- */
|
||||||
|
#partsModal {
|
||||||
|
z-index: 1060 !important
|
||||||
|
}
|
||||||
|
|
||||||
/* --- Base --- */
|
/* --- Base --- */
|
||||||
#partsModal {
|
#partsModal {
|
||||||
z-index: 1060 !important
|
z-index: 1060 !important
|
||||||
|
|||||||
@@ -595,12 +595,8 @@ $(document).ready(function () {
|
|||||||
return iddatadb ? "#" + iddatadb : "";
|
return iddatadb ? "#" + iddatadb : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prefer main field value if available
|
// "Numero" identifier (no longer falls back to mainFieldValue,
|
||||||
if (record.mainFieldValue) {
|
// since main fields are now shown separately alongside it)
|
||||||
return record.mainFieldValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fallbacks
|
|
||||||
if (record.importreferencecode) {
|
if (record.importreferencecode) {
|
||||||
return record.importreferencecode;
|
return record.importreferencecode;
|
||||||
}
|
}
|
||||||
@@ -612,12 +608,37 @@ $(document).ready(function () {
|
|||||||
return "#" + iddatadb;
|
return "#" + iddatadb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Builds "Label1: value1 — Label2: value2" from window.gridMeta.mainFieldMappings
|
||||||
|
function getMainFieldsSummary(iddatadb) {
|
||||||
|
const record = getGridRecordById(iddatadb);
|
||||||
|
const mappings =
|
||||||
|
(window.gridMeta && window.gridMeta.mainFieldMappings) || [];
|
||||||
|
|
||||||
|
if (!record || !mappings.length) return "";
|
||||||
|
|
||||||
|
const parts = mappings
|
||||||
|
.map((mapping) => {
|
||||||
|
const value = record.details
|
||||||
|
? record.details[String(mapping.id)]
|
||||||
|
: "";
|
||||||
|
if (!value) return null;
|
||||||
|
return (
|
||||||
|
(mapping.label || mapping.field_label || "") + ": " + value
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.filter(Boolean);
|
||||||
|
|
||||||
|
return parts.join(" — ");
|
||||||
|
}
|
||||||
|
|
||||||
function updatePartsRecordHeader(iddatadb) {
|
function updatePartsRecordHeader(iddatadb) {
|
||||||
const list = getVisiblePartsRecordList();
|
const list = getVisiblePartsRecordList();
|
||||||
const currentId = parseInt(iddatadb, 10);
|
const currentId = parseInt(iddatadb, 10);
|
||||||
const currentIndex = list.indexOf(currentId);
|
const currentIndex = list.indexOf(currentId);
|
||||||
|
|
||||||
$("#trfHeader").text(getRecordHeaderLabel(currentId));
|
const mainSummary = getMainFieldsSummary(currentId);
|
||||||
|
|
||||||
|
$("#trfHeader").text(mainSummary || getRecordHeaderLabel(currentId));
|
||||||
|
|
||||||
if (list.length <= 1 || currentIndex === -1) {
|
if (list.length <= 1 || currentIndex === -1) {
|
||||||
$("#partsRecordCounter").text("-");
|
$("#partsRecordCounter").text("-");
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ $fixedAliasMap = [
|
|||||||
'ClienteResponsabile' => 'cliente_responsabile_id',
|
'ClienteResponsabile' => 'cliente_responsabile_id',
|
||||||
'ClienteFornitore' => 'cliente_fornitore_id',
|
'ClienteFornitore' => 'cliente_fornitore_id',
|
||||||
'ClienteAnalisi' => 'clienteAnalisi',
|
'ClienteAnalisi' => 'clienteAnalisi',
|
||||||
|
'ClienteFatturazione' => 'ClienteFatturazione',
|
||||||
'MoltiplicatorePrezzo' => 'moltiplicatore_prezzo_id',
|
'MoltiplicatorePrezzo' => 'moltiplicatore_prezzo_id',
|
||||||
'AnagraficaCertestObject' => 'anagrafica_certest_object_id',
|
'AnagraficaCertestObject' => 'anagrafica_certest_object_id',
|
||||||
'AnagraficaCertestService' => 'anagrafica_certest_service_id',
|
'AnagraficaCertestService' => 'anagrafica_certest_service_id',
|
||||||
@@ -162,7 +163,7 @@ try {
|
|||||||
SELECT iddatadb, templateid, consegna_richiesta,
|
SELECT iddatadb, templateid, consegna_richiesta,
|
||||||
cliente_responsabile_id, moltiplicatore_prezzo_id,
|
cliente_responsabile_id, moltiplicatore_prezzo_id,
|
||||||
anagrafica_certest_object_id, anagrafica_certest_service_id,
|
anagrafica_certest_object_id, anagrafica_certest_service_id,
|
||||||
cliente_fornitore_id, clienteAnalisi
|
cliente_fornitore_id, clienteAnalisi, ClienteFatturazione
|
||||||
FROM datadb
|
FROM datadb
|
||||||
WHERE iddatadb IN ($placeholders)
|
WHERE iddatadb IN ($placeholders)
|
||||||
");
|
");
|
||||||
|
|||||||
Reference in New Issue
Block a user