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