fxied column order LIMS
This commit is contained in:
@@ -20,9 +20,10 @@ $db = DBHandlerSelect::getInstance();
|
|||||||
$pdo = $db->getConnection();
|
$pdo = $db->getConnection();
|
||||||
|
|
||||||
// Recupera tutti i mapping dal template, includendo is_visible_import
|
// Recupera tutti i mapping dal template, includendo is_visible_import
|
||||||
$stmt = $pdo->prepare("SELECT id, excel_column, data_type, is_required, manual_default, is_manual, field_label, field_id, main_field, is_visible_import, auto_value
|
$stmt = $pdo->prepare("SELECT id, excel_column, data_type, is_required, manual_default, is_manual, field_label, field_id, field_order, main_field, is_visible_import, auto_value
|
||||||
FROM template_mapping
|
FROM template_mapping
|
||||||
WHERE template_id = ?");
|
WHERE template_id = ?
|
||||||
|
ORDER BY field_order ASC, id ASC");
|
||||||
$stmt->execute([$template_id]);
|
$stmt->execute([$template_id]);
|
||||||
$allMappings = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$allMappings = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
@@ -252,18 +253,27 @@ foreach ($importedData as $index => $row) {
|
|||||||
// Build columns in display order
|
// Build columns in display order
|
||||||
$gridColumns = [];
|
$gridColumns = [];
|
||||||
|
|
||||||
// 1. Main fields, maximum 2
|
// 1. Main fields first, immediately after buttons
|
||||||
foreach ($mainFieldMappings as $mainMapping) {
|
foreach ($allMappings as $mapping) {
|
||||||
$gridColumns[] = [
|
if (
|
||||||
'type' => 'main_field',
|
(int)$mapping['is_visible_import'] === 1
|
||||||
'key' => (string)$mainMapping['id'],
|
&& (string)$mapping['main_field'] === '1'
|
||||||
'label' => $mainMapping['field_label'],
|
&& trim((string)$mapping['field_label']) !== 'Tested Component:'
|
||||||
'dataType' => $mainMapping['data_type'],
|
) {
|
||||||
'isManual' => (bool)$mainMapping['is_manual'],
|
$gridColumns[] = [
|
||||||
'isRequired' => (bool)$mainMapping['is_required'],
|
'type' => 'main_field',
|
||||||
'fieldId' => $mainMapping['field_id'] ?? null,
|
'key' => (string)$mapping['id'],
|
||||||
'width' => 150,
|
'label' => $mapping['field_label'],
|
||||||
];
|
'dataType' => $mapping['data_type'],
|
||||||
|
'isManual' => (bool)$mapping['is_manual'],
|
||||||
|
'isRequired' => (bool)$mapping['is_required'],
|
||||||
|
'fieldId' => $mapping['field_id'] ?? null,
|
||||||
|
'fieldOrder' => (int)($mapping['field_order'] ?? 9999),
|
||||||
|
'manualDefault' => $mapping['manual_default'] ?? '',
|
||||||
|
'autoValue' => $mapping['auto_value'] ?? 'none',
|
||||||
|
'width' => 150,
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Status
|
// 2. Status
|
||||||
@@ -275,50 +285,30 @@ $gridColumns[] = ['type' => 'idclient', 'key' => 'idclient', 'label' => 'Client'
|
|||||||
// 4. Cliente Fornitore
|
// 4. Cliente Fornitore
|
||||||
$gridColumns[] = ['type' => 'cliente_fornitore_id', 'key' => 'cliente_fornitore_id', 'label' => $slugMapping['ClienteFornitore'] ?? 'ClienteFornitore', 'width' => 300];
|
$gridColumns[] = ['type' => 'cliente_fornitore_id', 'key' => 'cliente_fornitore_id', 'label' => $slugMapping['ClienteFornitore'] ?? 'ClienteFornitore', 'width' => 300];
|
||||||
|
|
||||||
// 5. Auto fields
|
// 5. Other custom fields in schema order
|
||||||
foreach ($allMappings as $mapping) {
|
foreach ($allMappings as $mapping) {
|
||||||
if (
|
if (
|
||||||
!$mapping['is_manual']
|
(int)$mapping['is_visible_import'] === 1
|
||||||
&& $mapping['main_field'] != 1
|
&& (string)$mapping['main_field'] !== '1'
|
||||||
&& $mapping['is_visible_import'] == 1
|
|
||||||
&& trim((string)$mapping['field_label']) !== 'Tested Component:'
|
&& trim((string)$mapping['field_label']) !== 'Tested Component:'
|
||||||
) {
|
) {
|
||||||
|
$isMainField = ((string)$mapping['main_field'] === '1');
|
||||||
|
|
||||||
$gridColumns[] = [
|
$gridColumns[] = [
|
||||||
'type' => 'detail',
|
'type' => $isMainField ? 'main_field' : 'detail',
|
||||||
'key' => (string)$mapping['id'],
|
'key' => (string)$mapping['id'],
|
||||||
'label' => $mapping['field_label'],
|
'label' => $mapping['field_label'],
|
||||||
'dataType' => $mapping['data_type'],
|
'dataType' => $mapping['data_type'],
|
||||||
'isManual' => false,
|
'isManual' => (bool)$mapping['is_manual'],
|
||||||
'isRequired' => (bool)$mapping['is_required'],
|
'isRequired' => (bool)$mapping['is_required'],
|
||||||
'fieldId' => $mapping['field_id'] ?? null,
|
'fieldId' => $mapping['field_id'] ?? null,
|
||||||
|
'fieldOrder' => (int)($mapping['field_order'] ?? 9999),
|
||||||
|
'manualDefault' => $mapping['manual_default'] ?? '',
|
||||||
'autoValue' => $mapping['auto_value'] ?? 'none',
|
'autoValue' => $mapping['auto_value'] ?? 'none',
|
||||||
'width' => 150,
|
'width' => 150,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. Manual fields
|
|
||||||
foreach ($allMappings as $mapping) {
|
|
||||||
if (
|
|
||||||
$mapping['is_manual']
|
|
||||||
&& $mapping['main_field'] != 1
|
|
||||||
&& $mapping['is_visible_import'] == 1
|
|
||||||
&& trim((string)$mapping['field_label']) !== 'Tested Component:'
|
|
||||||
) {
|
|
||||||
$gridColumns[] = [
|
|
||||||
'type' => 'detail',
|
|
||||||
'key' => (string)$mapping['id'],
|
|
||||||
'label' => $mapping['field_label'],
|
|
||||||
'dataType' => $mapping['data_type'],
|
|
||||||
'isManual' => true,
|
|
||||||
'isRequired' => (bool)$mapping['is_required'],
|
|
||||||
'fieldId' => $mapping['field_id'] ?? null,
|
|
||||||
'manualDefault' => $mapping['manual_default'] ?? '',
|
|
||||||
'width' => 150,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 7. Tested Component
|
// 7. Tested Component
|
||||||
$gridColumns[] = ['type' => 'tested_component', 'key' => 'tested_component', 'label' => 'Tested Component', 'width' => 150];
|
$gridColumns[] = ['type' => 'tested_component', 'key' => 'tested_component', 'label' => 'Tested Component', 'width' => 150];
|
||||||
|
|
||||||
|
|||||||
@@ -46,8 +46,8 @@
|
|||||||
{
|
{
|
||||||
"IdSchemaCustomFields": 48,
|
"IdSchemaCustomFields": 48,
|
||||||
"ConteggioClienti": 0,
|
"ConteggioClienti": 0,
|
||||||
"Nome": "Standard Generico \/ Generic Standard",
|
"Nome": "Standard \/ Generico",
|
||||||
"Descrizione": "Schema per tutti i campioni di qualsiasi matrice escluso cuoio\/pelle\r\n\r\n"
|
"Descrizione": "\r\n"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"IdSchemaCustomFields": 49,
|
"IdSchemaCustomFields": 49,
|
||||||
@@ -882,6 +882,24 @@
|
|||||||
"ConteggioClienti": 0,
|
"ConteggioClienti": 0,
|
||||||
"Nome": "LIMS-CIM - MAX MARA",
|
"Nome": "LIMS-CIM - MAX MARA",
|
||||||
"Descrizione": "Schema per MAX MARA scambio dati Database"
|
"Descrizione": "Schema per MAX MARA scambio dati Database"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"IdSchemaCustomFields": 203,
|
||||||
|
"ConteggioClienti": 0,
|
||||||
|
"Nome": "Vince",
|
||||||
|
"Descrizione": "Schema per tutti i campioni di VINCE\r\n\r\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"IdSchemaCustomFields": 204,
|
||||||
|
"ConteggioClienti": 0,
|
||||||
|
"Nome": "Max Mara",
|
||||||
|
"Descrizione": "Schema da usare per Max Mara\r\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"IdSchemaCustomFields": 205,
|
||||||
|
"ConteggioClienti": 0,
|
||||||
|
"Nome": "Chanel Flammability",
|
||||||
|
"Descrizione": "Schema per Chanel Flammability\r\n"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -82,6 +82,7 @@ try {
|
|||||||
template_id,
|
template_id,
|
||||||
schema_id,
|
schema_id,
|
||||||
field_id,
|
field_id,
|
||||||
|
field_order,
|
||||||
data_type,
|
data_type,
|
||||||
is_required,
|
is_required,
|
||||||
default_value,
|
default_value,
|
||||||
@@ -97,6 +98,7 @@ try {
|
|||||||
:template_id,
|
:template_id,
|
||||||
:schema_id,
|
:schema_id,
|
||||||
:field_id,
|
:field_id,
|
||||||
|
:field_order,
|
||||||
:data_type,
|
:data_type,
|
||||||
:is_required,
|
:is_required,
|
||||||
:default_value,
|
:default_value,
|
||||||
@@ -116,6 +118,7 @@ try {
|
|||||||
UPDATE template_mapping
|
UPDATE template_mapping
|
||||||
SET
|
SET
|
||||||
schema_id = :schema_id,
|
schema_id = :schema_id,
|
||||||
|
field_order = :field_order,
|
||||||
data_type = :data_type,
|
data_type = :data_type,
|
||||||
is_required = :is_required,
|
is_required = :is_required,
|
||||||
default_value = :default_value,
|
default_value = :default_value,
|
||||||
@@ -172,6 +175,7 @@ try {
|
|||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
':schema_id' => $schema_id,
|
':schema_id' => $schema_id,
|
||||||
|
':field_order' => (int)($field['Ordine'] ?? 9999),
|
||||||
':data_type' => $newDataType,
|
':data_type' => $newDataType,
|
||||||
':is_required' => !empty($custom_field['ObbligatorioWeb']) ? 1 : 0,
|
':is_required' => !empty($custom_field['ObbligatorioWeb']) ? 1 : 0,
|
||||||
':default_value' => $custom_field['ValoreDefault'] ?? null,
|
':default_value' => $custom_field['ValoreDefault'] ?? null,
|
||||||
@@ -234,7 +238,6 @@ try {
|
|||||||
|
|
||||||
$response["success"] = true;
|
$response["success"] = true;
|
||||||
$response["message"] = "Schema JSON updated, mappings synchronized, removed fields deleted, and changed fields updated successfully.";
|
$response["message"] = "Schema JSON updated, mappings synchronized, removed fields deleted, and changed fields updated successfully.";
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
if (isset($pdo) && $pdo->inTransaction()) {
|
if (isset($pdo) && $pdo->inTransaction()) {
|
||||||
$pdo->rollback();
|
$pdo->rollback();
|
||||||
|
|||||||
Reference in New Issue
Block a user