1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-02-01 16:36:45 +01:00

Miglioramenti distribuiti

This commit is contained in:
Thomas Zilio 2018-09-04 10:03:02 +02:00
parent 377998d7ce
commit 9509355260
6 changed files with 81 additions and 15 deletions

View File

@ -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')) { if (!function_exists('random_string')) {
/** /**
* Generates a string of random characters. * Generates a string of random characters.

View File

@ -123,8 +123,6 @@ return [
'names' => [ 'names' => [
'Unità di misura', 'Unità di misura',
'Unità misura', 'Unità misura',
'unità misura',
'unità di misura',
'Unit` di misura', 'Unit` di misura',
'um', 'um',
], ],
@ -132,18 +130,10 @@ return [
[ [
'field' => 'prezzo_acquisto', 'field' => 'prezzo_acquisto',
'label' => 'Prezzo acquisto', 'label' => 'Prezzo acquisto',
'names' => [
'Prezzo Acquisto',
'prezzo acquisto',
],
], ],
[ [
'field' => 'prezzo_vendita', 'field' => 'prezzo_vendita',
'label' => 'Prezzo vendita', 'label' => 'Prezzo vendita',
'names' => [
'Prezzo Vendita',
'prezzo vendita',
],
], ],
[ [
'field' => 'peso_lordo', 'field' => 'peso_lordo',
@ -158,7 +148,7 @@ return [
'label' => 'Volume (M3)', 'label' => 'Volume (M3)',
'names' => [ 'names' => [
'Volume (M3)', 'Volume (M3)',
'volume', 'Volume',
], ],
], ],
[ [
@ -168,7 +158,6 @@ return [
'Categoria', 'Categoria',
'id_categoria', 'id_categoria',
'idcategoria', 'idcategoria',
'categoria',
], ],
], ],
[ [

View File

@ -8,7 +8,7 @@ include_once __DIR__.'/../../core.php';
<input type="hidden" name="backto" value="record-edit"> <input type="hidden" name="backto" value="record-edit">
<input type="hidden" name="id_record" value="<?php echo $id_record; ?>"> <input type="hidden" name="id_record" value="<?php echo $id_record; ?>">
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
{[ "type": "select", "label": "<?php echo tr('Modulo'); ?>", "name": "module_id", "values": "query=SELECT id, name as text FROM zz_modules WHERE enabled = 1", "value": "$id_module$" ]} {[ "type": "select", "label": "<?php echo tr('Modulo'); ?>", "name": "module_id", "values": "query=SELECT id, name as text FROM zz_modules WHERE enabled = 1", "value": "$id_module$" ]}
</div> </div>
@ -45,6 +45,43 @@ include_once __DIR__.'/../../core.php';
</div> </div>
</form> </form>
<!-- Campi extra -->
<div class="box box-info">
<div class="box-header">
<h3 class="box-title"><?php echo tr('Istruzioni per il campo _FIELD_', [
'_FIELD_' => tr('Contenuto'),
]); ?></h3>
</div>
<div class="box-body">
<p><?php echo tr('Le seguenti sequenze di testo vengono sostituite nel seguente modo'); ?>:</p>
<ul>
<?php
$list = [
'name' => tr('Nome'),
'html_name' => tr('Nome HTML'),
];
foreach ($list as $key => $value) {
echo '
<li>'.tr('_TEXT_ con il valore del campo "_FIELD_"', [
'_TEXT_' => '<code>|'.$key.'|</code>',
'_FIELD_' => $value,
]).'</li>';
}
echo '
<li>'.tr('_TEXT_ con il valore impostato per il record', [
'_TEXT_' => '<code>|value</code>',
]).'</li>';
?>
</ul>
</div>
</div>
<hr>
<a class="btn btn-danger ask" data-backto="record-list"> <a class="btn btn-danger ask" data-backto="record-list">
<i class="fa fa-trash"></i> <?php echo tr('Elimina'); ?> <i class="fa fa-trash"></i> <?php echo tr('Elimina'); ?>
</a> </a>

View File

@ -20,6 +20,9 @@ switch (post('op')) {
'headers' => $first_row, 'headers' => $first_row,
]); ]);
// Gestione automatica dei valori convertiti
$csv = Filter::parse($csv);
// Interpretazione dei dati // Interpretazione dei dati
$data = []; $data = [];
foreach ($csv as $row) { foreach ($csv as $row) {

View File

@ -65,7 +65,7 @@ if (empty($id_record)) {
// Individuazione delle corrispondenze // Individuazione delle corrispondenze
$selected = null; $selected = null;
foreach ($fields as $key => $value) { 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; $first_row = 1;
$selected = $key; $selected = $key;
break; break;

View File

@ -77,11 +77,20 @@ class Import
// Impostazione automatica dei nomi "ufficiali" dei campi // Impostazione automatica dei nomi "ufficiali" dei campi
foreach ($fields as $key => $value) { foreach ($fields as $key => $value) {
if (!isset($value['names'])) { if (!isset($value['names'])) {
$fields[$key]['names'] = [ $names = [
$value['field'], $value['field'],
$value['label'], $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; return $fields;