Better error message

This commit is contained in:
Laurent Destailleur 2022-05-31 18:08:53 +02:00
parent 98ebe0cff4
commit a253938db9
3 changed files with 16 additions and 15 deletions

View File

@ -183,6 +183,21 @@ function isASecretKey($keyname)
return preg_match('/(_pass|password|_pw|_key|securekey|serverkey|secret\d?|p12key|exportkey|_PW_[a-z]+|token)$/i', $keyname);
}
/**
* Return a numeric value into an Excel like column number. So 1 return 'A', 2 returns 'B'..., 27 return 'AA'
*
* @param int|string $n Numeric value
* @return string Column in Excel format
*/
function num2Alpha($n)
{
for ($r = ""; $n >= 0; $n = intval($n / 26) - 1)
$r = chr($n % 26 + 0x41) . $r;
return $r;
}
/**
* Return information about user browser
*

View File

@ -446,7 +446,7 @@ class ImportXlsx extends ModeleImports
// Is it a required field ?
if (preg_match('/\*/', $objimport->array_import_fields[0][$val]) && ((string) $newval == '')) {
$this->errors[$error]['lib'] = $langs->trans('ErrorMissingMandatoryValue', $key);
$this->errors[$error]['lib'] = $langs->trans('ErrorMissingMandatoryValue', num2Alpha($key));
$this->errors[$error]['type'] = 'NOTNULL';
$errorforthistable++;
$error++;

View File

@ -2349,20 +2349,6 @@ function show_elem($fieldssource, $pos, $key, $var, $nostyle = '')
}
/**
* Return a numeric into an Excel like column number
*
* @param string $n Numeric value
* @return string Column in Excel format
*/
function num2Alpha($n)
{
for ($r = ""; $n >= 0; $n = intval($n / 26) - 1)
$r = chr($n%26 + 0x41) . $r;
return $r;
}
/**
* Return not used field number
*