diff --git a/lib/util.php b/lib/util.php index fd3686934..7d337e513 100644 --- a/lib/util.php +++ b/lib/util.php @@ -69,6 +69,34 @@ if (!function_exists('str_contains')) { } } +if (!function_exists('str_to_lower')) { + /** + * Converts a string in the lower-case version. + * + * @param string $string + * + * @return bool + */ + function str_to_lower($string) + { + return S::create($string)->toLowerCase(); + } +} + +if (!function_exists('str_to_upper')) { + /** + * Converts a string in the upper-case version. + * + * @param string $string + * + * @return bool + */ + function str_to_upper($string) + { + return S::create($string)->toUpperCase(); + } +} + if (!function_exists('random_string')) { /** * Generates a string of random characters. diff --git a/modules/articoli/import.php b/modules/articoli/import.php index 6117a66c9..b0510e0ea 100644 --- a/modules/articoli/import.php +++ b/modules/articoli/import.php @@ -123,8 +123,6 @@ return [ 'names' => [ 'Unità di misura', 'Unità misura', - 'unità misura', - 'unità di misura', 'Unit` di misura', 'um', ], @@ -132,18 +130,10 @@ return [ [ 'field' => 'prezzo_acquisto', 'label' => 'Prezzo acquisto', - 'names' => [ - 'Prezzo Acquisto', - 'prezzo acquisto', - ], ], [ 'field' => 'prezzo_vendita', 'label' => 'Prezzo vendita', - 'names' => [ - 'Prezzo Vendita', - 'prezzo vendita', - ], ], [ 'field' => 'peso_lordo', @@ -158,7 +148,7 @@ return [ 'label' => 'Volume (M3)', 'names' => [ 'Volume (M3)', - 'volume', + 'Volume', ], ], [ @@ -168,7 +158,6 @@ return [ 'Categoria', 'id_categoria', 'idcategoria', - 'categoria', ], ], [ diff --git a/modules/custom_fields/edit.php b/modules/custom_fields/edit.php index aaaeabf4e..7502b091d 100644 --- a/modules/custom_fields/edit.php +++ b/modules/custom_fields/edit.php @@ -8,7 +8,7 @@ include_once __DIR__.'/../../core.php'; -
+
{[ "type": "select", "label": "", "name": "module_id", "values": "query=SELECT id, name as text FROM zz_modules WHERE enabled = 1", "value": "$id_module$" ]}
@@ -45,6 +45,43 @@ include_once __DIR__.'/../../core.php';
+ +
+
+

tr('Contenuto'), + ]); ?>

+
+ +
+

:

+
    + tr('Nome'), + 'html_name' => tr('Nome HTML'), +]; + +foreach ($list as $key => $value) { + echo ' +
  • '.tr('_TEXT_ con il valore del campo "_FIELD_"', [ + '_TEXT_' => '|'.$key.'|', + '_FIELD_' => $value, + ]).'
  • '; +} + +echo ' +
  • '.tr('_TEXT_ con il valore impostato per il record', [ + '_TEXT_' => '|value', + ]).'
  • '; + +?> +
+
+
+ +
+ diff --git a/modules/import/actions.php b/modules/import/actions.php index f6cc18e5b..b3789b2b7 100644 --- a/modules/import/actions.php +++ b/modules/import/actions.php @@ -20,6 +20,9 @@ switch (post('op')) { 'headers' => $first_row, ]); + // Gestione automatica dei valori convertiti + $csv = Filter::parse($csv); + // Interpretazione dei dati $data = []; foreach ($csv as $row) { diff --git a/modules/import/edit.php b/modules/import/edit.php index a479a6560..916f747d4 100644 --- a/modules/import/edit.php +++ b/modules/import/edit.php @@ -65,7 +65,7 @@ if (empty($id_record)) { // Individuazione delle corrispondenze $selected = null; foreach ($fields as $key => $value) { - if (in_array($rows[0][$column], $value['names'])) { + if (in_array(str_to_lower($rows[0][$column]), $value['names'])) { $first_row = 1; $selected = $key; break; diff --git a/src/Import.php b/src/Import.php index 9cedc55a0..86e02a021 100644 --- a/src/Import.php +++ b/src/Import.php @@ -77,11 +77,20 @@ class Import // Impostazione automatica dei nomi "ufficiali" dei campi foreach ($fields as $key => $value) { if (!isset($value['names'])) { - $fields[$key]['names'] = [ + $names = [ $value['field'], $value['label'], ]; + } else { + $names = $value['names']; } + + // Impostazione dei nomi in minuscolo + foreach ($names as $k => $v) { + $names[$k] = str_to_lower($v); + } + + $fields[$key]['names'] = $names; } return $fields;