Merge branch 'Dolibarr:develop' into dolibarr_fixbugs
This commit is contained in:
commit
3976087c78
@ -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 0 return 'A', 1 returns 'B'..., 26 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
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2009-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
/* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2009-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2012-2016 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
@ -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 - 1));
|
||||
$this->errors[$error]['type'] = 'NOTNULL';
|
||||
$errorforthistable++;
|
||||
$error++;
|
||||
|
||||
@ -1743,7 +1743,7 @@ if ($step == 5 && $datatoimport) {
|
||||
}
|
||||
//print $code.'-'.$label;
|
||||
$alias = preg_replace('/(\..*)$/i', '', $label);
|
||||
$listfields[$i] = $langs->trans("Field").' '.$code.'->'.$label;
|
||||
$listfields[$i] = $langs->trans("Column").' '.num2Alpha($code - 1).' -> '.$label;
|
||||
}
|
||||
print count($listfields) ? (join(', ', $listfields)) : $langs->trans("Error");
|
||||
print '</td></tr>';
|
||||
@ -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
|
||||
*
|
||||
|
||||
@ -82,7 +82,7 @@ SelectFormat=Choose this import file format
|
||||
RunImportFile=Import Data
|
||||
NowClickToRunTheImport=Check the results of the import simulation. Correct any errors and re-test.<br>When the simulation reports no errors you may proceed to import the data into the database.
|
||||
DataLoadedWithId=The imported data will have an additional field in each database table with this import id: <b>%s</b>, to allow it to be searchable in the case of investigating a problem related to this import.
|
||||
ErrorMissingMandatoryValue=Mandatory data is empty in the source file for field <b>%s</b>.
|
||||
ErrorMissingMandatoryValue=Mandatory data is empty in the source file in column <b>%s</b>.
|
||||
TooMuchErrors=There are still <b>%s</b> other source lines with errors but output has been limited.
|
||||
TooMuchWarnings=There are still <b>%s</b> other source lines with warnings but output has been limited.
|
||||
EmptyLine=Empty line (will be discarded)
|
||||
@ -92,9 +92,9 @@ YouCanUseImportIdToFindRecord=You can find all the imported records in your data
|
||||
NbOfLinesOK=Number of lines with no errors and no warnings: <b>%s</b>.
|
||||
NbOfLinesImported=Number of lines successfully imported: <b>%s</b>.
|
||||
DataComeFromNoWhere=Value to insert comes from nowhere in source file.
|
||||
DataComeFromFileFieldNb=Value to insert comes from field number <b>%s</b> in source file.
|
||||
DataComeFromIdFoundFromRef=Value that comes from field number <b>%s</b> of source file will be used to find the id of the parent object to use (so the object <b>%s</b> that has the ref. from source file must exist in the database).
|
||||
DataComeFromIdFoundFromCodeId=Code that comes from field number <b>%s</b> of source file will be used to find the id of the parent object to use (so the code from source file must exist in the dictionary <b>%s</b>). Note that if you know the id, you can also use it in the source file instead of the code. Import should work in both cases.
|
||||
DataComeFromFileFieldNb=Value to insert comes from column <b>%s</b> in source file.
|
||||
DataComeFromIdFoundFromRef=Value that comes from column <b>%s</b> of source file will be used to find the id of the parent object to use (so the object <b>%s</b> that has the ref. from source file must exist in the database).
|
||||
DataComeFromIdFoundFromCodeId=Code that comes from column <b>%s</b> of source file will be used to find the id of the parent object to use (so the code from source file must exist in the dictionary <b>%s</b>). Note that if you know the id, you can also use it in the source file instead of the code. Import should work in both cases.
|
||||
DataIsInsertedInto=Data coming from source file will be inserted into the following field:
|
||||
DataIDSourceIsInsertedInto=The id of the parent object, that was found using the data in the source file, will be inserted into the following field:
|
||||
DataCodeIDSourceIsInsertedInto=The id of the parent line, that was found from code, will be inserted into the following field:
|
||||
|
||||
@ -166,6 +166,26 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* testNum2Alpha
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testNum2Alpha()
|
||||
{
|
||||
$result = num2Alpha(0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, 'A', 'Check num2Alpha 0');
|
||||
|
||||
$result = num2Alpha(5);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, 'F', 'Check num2Alpha 5');
|
||||
|
||||
$result = num2Alpha(26);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, 'AA', 'Check num2Alpha 26');
|
||||
}
|
||||
|
||||
/**
|
||||
* testIsValidEmail
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user