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.cliente_fornitore_id,
|
||||
d.clienteAnalisi,
|
||||
d.ClienteFatturazione,
|
||||
d.consegna_richiesta
|
||||
FROM datadb as d
|
||||
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;
|
||||
$clienteFornitore = !empty($result['cliente_fornitore_id']) ? (int) $result['cliente_fornitore_id'] : 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;
|
||||
|
||||
// 🔹 STEP 3: Fetch Parts (including idmatrice and part id for custom fields)
|
||||
$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
|
||||
WHERE iddatadb = :iddatadb
|
||||
AND part_description IS NOT NULL
|
||||
@@ -274,6 +276,7 @@ try {
|
||||
"AnagraficaCertestService" => $anagraficaService,
|
||||
"ClienteFornitore" => $clienteFornitore, // PLACEHOLDER — to be implemented
|
||||
"ClienteAnalisi" => $clienteAnalisi, // PLACEHOLDER — to be implemented
|
||||
"ClienteFatturazione" => $clienteFatturazione,
|
||||
// DeliveryRequest goes to Campione, not CommessaWeb
|
||||
];
|
||||
|
||||
@@ -306,13 +309,17 @@ try {
|
||||
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 = [
|
||||
"Commessa" => $commessaId,
|
||||
"Matrice" => $matriceId,
|
||||
"SottoMatrice" => null,
|
||||
"SchemaCustomField" => $schemaId,
|
||||
// "Riferimento" => $part["part_description"] ?? "",
|
||||
"NoteWeb" => $part["part_description"] ?? "",
|
||||
"NoteWeb" => $noteWebValue,
|
||||
"ConsegnaRichiesta" => !empty($part["dateexpiry"]) ? $part["dateexpiry"] : $consegnaRichiesta,
|
||||
];
|
||||
|
||||
|
||||
@@ -162,8 +162,8 @@
|
||||
// Mappa: quale filtro Inattivo applicare per ogni campo cliente
|
||||
const clientFieldTipoMap = {
|
||||
ClienteFornitore: "attivo",
|
||||
ClienteAnalisi: "attivo",
|
||||
ClienteFatturazione: "inattivo",
|
||||
ClienteAnalisi: "inattivo",
|
||||
ClienteFatturazione: "attivo",
|
||||
};
|
||||
|
||||
// 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';
|
||||
};
|
||||
|
||||
// Fornitore e Analisi: solo clienti ATTIVI (Inattivo = false)
|
||||
// Fatturazione: solo clienti INATTIVI (Inattivo = true)
|
||||
const filtered = (key === 'ClienteFatturazione') ?
|
||||
// Fornitore e Fatturazione: solo clienti ATTIVI (Inattivo = false)
|
||||
// Analisi: solo clienti INATTIVI (Inattivo = true)
|
||||
const filtered = (key === 'ClienteAnalisi') ?
|
||||
list.filter(isInattivo) :
|
||||
list.filter(x => !isInattivo(x));
|
||||
|
||||
|
||||
@@ -208,6 +208,23 @@
|
||||
</div>
|
||||
|
||||
<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 --- */
|
||||
#partsModal {
|
||||
z-index: 1060 !important
|
||||
|
||||
@@ -595,12 +595,8 @@ $(document).ready(function () {
|
||||
return iddatadb ? "#" + iddatadb : "";
|
||||
}
|
||||
|
||||
// Prefer main field value if available
|
||||
if (record.mainFieldValue) {
|
||||
return record.mainFieldValue;
|
||||
}
|
||||
|
||||
// Fallbacks
|
||||
// "Numero" identifier (no longer falls back to mainFieldValue,
|
||||
// since main fields are now shown separately alongside it)
|
||||
if (record.importreferencecode) {
|
||||
return record.importreferencecode;
|
||||
}
|
||||
@@ -612,12 +608,37 @@ $(document).ready(function () {
|
||||
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) {
|
||||
const list = getVisiblePartsRecordList();
|
||||
const currentId = parseInt(iddatadb, 10);
|
||||
const currentIndex = list.indexOf(currentId);
|
||||
|
||||
$("#trfHeader").text(getRecordHeaderLabel(currentId));
|
||||
const mainSummary = getMainFieldsSummary(currentId);
|
||||
|
||||
$("#trfHeader").text(mainSummary || getRecordHeaderLabel(currentId));
|
||||
|
||||
if (list.length <= 1 || currentIndex === -1) {
|
||||
$("#partsRecordCounter").text("-");
|
||||
|
||||
@@ -129,6 +129,7 @@ $fixedAliasMap = [
|
||||
'ClienteResponsabile' => 'cliente_responsabile_id',
|
||||
'ClienteFornitore' => 'cliente_fornitore_id',
|
||||
'ClienteAnalisi' => 'clienteAnalisi',
|
||||
'ClienteFatturazione' => 'ClienteFatturazione',
|
||||
'MoltiplicatorePrezzo' => 'moltiplicatore_prezzo_id',
|
||||
'AnagraficaCertestObject' => 'anagrafica_certest_object_id',
|
||||
'AnagraficaCertestService' => 'anagrafica_certest_service_id',
|
||||
@@ -162,7 +163,7 @@ try {
|
||||
SELECT iddatadb, templateid, consegna_richiesta,
|
||||
cliente_responsabile_id, moltiplicatore_prezzo_id,
|
||||
anagrafica_certest_object_id, anagrafica_certest_service_id,
|
||||
cliente_fornitore_id, clienteAnalisi
|
||||
cliente_fornitore_id, clienteAnalisi, ClienteFatturazione
|
||||
FROM datadb
|
||||
WHERE iddatadb IN ($placeholders)
|
||||
");
|
||||
|
||||
Reference in New Issue
Block a user