Migliorie generiche

This commit is contained in:
Thomas Zilio 2017-09-19 18:14:23 +02:00
parent 0e8a0e9136
commit 0bb3e9cb74
7 changed files with 20 additions and 19 deletions

View File

@ -143,14 +143,14 @@ if (!empty($module_query) && $module_query != 'menu' && $module_query != 'custom
// Formattazione automatica
if (!empty($total['format'][$pos]) && !empty($value)) {
if (Translator::getFormatter()->isStandardNumber($value)) {
$value = Translator::numberToLocale($value);
} elseif (Translator::getFormatter()->isStandardTimestamp($value)) {
$value = Translator::timestampToLocale($value);
} elseif (Translator::getFormatter()->isStandardDate($value)) {
if (Translator::getFormatter()->isStandardDate($value)) {
$value = Translator::dateToLocale($value);
} elseif (Translator::getFormatter()->isStandardTime($value)) {
$value = Translator::timeToLocale($value);
} elseif (Translator::getFormatter()->isStandardTimestamp($value)) {
$value = Translator::timestampToLocale($value);
} elseif (Translator::getFormatter()->isStandardNumber($value)) {
$value = Translator::numberToLocale($value);
}
}

View File

@ -24,7 +24,7 @@ $HTMLWrapper = null;
$HTMLHandlers = [];
$HTMLManagers = [];
// Lingua del progetto
// Lingua del progetto (per la traduzione e la conversione numerica)
$lang = 'it';
// Personalizzazione della formattazione di date e numeri
// Personalizzazione della formattazione di timestamp, date e orari
$formatter = [];

View File

@ -276,4 +276,3 @@ if (!API::isAPIRequest()) {
$post = Filter::getPOST();
$get = Filter::getGET();
}

View File

@ -293,7 +293,7 @@ if ($records[0]['stato'] != 'Pagato' && $records[0]['stato'] != 'Emessa') {
</a>';
echo '
<a class="btn btn-sm btn-primary" data-href="'.$rootdir.'/modules/fatture/add_riga.php?id_module='.$id_module.'&id_record=='.$id_record.'" data-toggle="modal" data-title="Aggiungi riga" data-target="#bs-popup">
<a class="btn btn-sm btn-primary" data-href="'.$rootdir.'/modules/fatture/add_riga.php?id_module='.$id_module.'&id_record='.$id_record.'" data-toggle="modal" data-title="Aggiungi riga" data-target="#bs-popup">
<i class="fa fa-plus"></i> Riga generica
</a>';
}

View File

@ -114,14 +114,14 @@ class Filter
$output = trim(self::getPurifier()->purify($input));
if (!empty($output)) {
if (Translator::getFormatter()->isFormattedNumber($output)) {
$output = Translator::numberToEnglish($output);
} elseif (Translator::getFormatter()->isFormattedTimestamp($output)) {
$output = Translator::timestampToEnglish($output);
} elseif (Translator::getFormatter()->isFormattedDate($output)) {
if (Translator::getFormatter()->isFormattedDate($output)) {
$output = Translator::dateToEnglish($output);
} elseif (Translator::getFormatter()->isFormattedTime($output)) {
$output = Translator::timeToEnglish($output);
} elseif (Translator::getFormatter()->isFormattedTimestamp($output)) {
$output = Translator::timestampToEnglish($output);
} elseif (Translator::getFormatter()->isFormattedNumber($output)) {
$output = Translator::numberToEnglish($output);
}
}
}

View File

@ -73,7 +73,7 @@ class Formatter
$this->numberFormatter->setAttribute(NumberFormatter::FRACTION_DIGITS, $original);
}
return $result;
return is_numeric($value) ? $result : false;
}
/**
@ -85,7 +85,7 @@ class Formatter
*/
public function parseNumber($value)
{
return $this->numberFormatter->parse($value);
return ctype_digit(str_replace(array_values($this->getNumberSeparators()), '', $value)) ? $this->numberFormatter->parse($value) : false;
}
/**
@ -99,7 +99,7 @@ class Formatter
{
$result = $this->formatNumber($value);
return is_numeric($value) && !empty($result);
return !empty($result);
}
/**

View File

@ -456,7 +456,7 @@ class Modules
*
* @return string
*/
public static function link($modulo, $id_record, $testo = null, $alternativo = true, $extra = null, $blank = true)
public static function link($modulo, $id_record = null, $testo = null, $alternativo = true, $extra = null, $blank = true)
{
$testo = isset($testo) ? nl2br($testo) : tr('Visualizza scheda');
$alternativo = is_bool($alternativo) && $alternativo ? $testo : $alternativo;
@ -471,7 +471,9 @@ class Modules
$extra .= !empty($blank) ? ' target="_blank"' : '';
if (!empty($module) && in_array($module['permessi'], ['r', 'rw'])) {
return '<a href="'.ROOTDIR.'/editor.php?id_module='.$module['id'].'&id_record='.$id_record.'" '.$extra.'>'.$testo.'</a>';
$link = !empty($id_record) ? 'editor.php?id_module='.$module['id'].'&id_record='.$id_record : 'controller.php?id_module='.$module['id'];
return '<a href="'.ROOTDIR.'/'.$link.'" '.$extra.'>'.$testo.'</a>';
} else {
return $alternativo;
}