';
if ($user->rights->import->run)
{
- print ''.$langs->trans("RunImportFile").'';
+ if (empty($nboferrors))
+ {
+ print ''.$langs->trans("RunImportFile").'';
+ }
+ else
+ {
+ print ''.$langs->trans("RunImportFile").'';
+ }
}
else
{
diff --git a/htdocs/includes/modules/import/import_csv.modules.php b/htdocs/includes/modules/import/import_csv.modules.php
index 52359f3a6b5..d473a894370 100644
--- a/htdocs/includes/modules/import/import_csv.modules.php
+++ b/htdocs/includes/modules/import/import_csv.modules.php
@@ -272,6 +272,8 @@ class ImportCsv extends ModeleImports
*/
function import_insert($arrayrecord,$array_match_file_to_database,$objimport,$maxfields,$importid)
{
+ global $langs,$conf;
+
$error=0;
$warning=0;
$this->errors=array();
@@ -288,8 +290,8 @@ class ImportCsv extends ModeleImports
if (sizeof($arrayrecord) == 0 ||
(sizeof($arrayrecord) == 1 && empty($arrayrecord[0]['val'])))
{
- print 'W';
- $this->warnings[$warning]['lib']='Empty line';
+ //print 'W';
+ $this->warnings[$warning]['lib']=$langs->trans('EmptyLine');
$this->warnings[$warning]['type']='EMPTY';
$warning++;
}
@@ -310,7 +312,7 @@ class ImportCsv extends ModeleImports
if ($key <= $maxfields)
{
if ($listfields) { $listfields.=', '; $listvalues.=', '; }
- $listfields.=$val;
+ $listfields.=eregi_replace('^.*\.','',$val);
$newval='';
if ($arrayrecord[($key-1)]['type'] < 0)
{
@@ -331,7 +333,7 @@ class ImportCsv extends ModeleImports
// Required field is ok
if (eregi('\*',$objimport->array_import_fields[0][$val]) && empty($newval))
{
- $this->errors[$error]['lib']='ErrorMissingMandatoryValue field nb '.$key.' target='.$val;
+ $this->errors[$error]['lib']=$langs->trans('ErrorMissingMandatoryValue',$key);
$this->errors[$error]['type']='NOTNULL';
$errorforthistable++;
$error++;
@@ -349,7 +351,7 @@ class ImportCsv extends ModeleImports
{
if ($listfields)
{
- $sql='INSERT INTO '.$tablename.'('.$listfields.') VALUES('.$listvalues.')';
+ $sql='INSERT INTO '.$tablename.'('.$listfields.',import_key) VALUES('.$listvalues.",'".$importid."')";
dol_syslog("import_csv.modules sql=".$sql);
//print '> '.join(',',$arrayrecord);
@@ -362,12 +364,13 @@ class ImportCsv extends ModeleImports
$resql=$this->db->query($sql);
if ($resql)
{
- print '.';
+ //print '.';
}
else
{
- print 'E';
- $this->errors[$error]['lib']='ErrorSQL '.$this->db->lasterror();
+ //print 'E';
+print $sql;
+ $this->errors[$error]['lib']=$this->db->lasterror();
$this->errors[$error]['type']='SQL';
$error++;
}
diff --git a/htdocs/langs/en_US/exports.lang b/htdocs/langs/en_US/exports.lang
index f7a6d16e4c8..531cd3f23fb 100644
--- a/htdocs/langs/en_US/exports.lang
+++ b/htdocs/langs/en_US/exports.lang
@@ -86,3 +86,8 @@ SelectFormat=Choose this import file format
RunImportFile=Launch import file
NowClickToRunTheImport=Check result of import simulation. If everything is ok, launch the definitive import.
DataLoadedWithId=All data will be loaded with the following import id: %s
+ErrorMissingMandatoryValue=Mandatory data is empty in source file for field %s.
+TooMuchErrors=There is still %s other source lines with errors but output has been limited.
+TooMuchWarnings=There is still %s other source lines with warnings but output has been limited.
+EmptyLine=Empty line
+CorrectErrorBeforeRunningImport=You must first correct all errors before running definitive import.
\ No newline at end of file
diff --git a/htdocs/langs/fr_FR/exports.lang b/htdocs/langs/fr_FR/exports.lang
index 4e3df02047d..2a0df76793b 100644
--- a/htdocs/langs/fr_FR/exports.lang
+++ b/htdocs/langs/fr_FR/exports.lang
@@ -85,4 +85,9 @@ SelectAtLeastOneField=Basculer au moins un champ source dans la colonne des cham
SelectFormat=Choisir ce format de fichier import
RunImportFile=Lancer l'import en base
NowClickToRunTheImport=Vérifiez le résultat de la simulation. Si tout est ok, lancer l'import définitif en base.
-DataLoadedWithId=Toutes les données seront importées avec l'id d'import suivant: %s
\ No newline at end of file
+DataLoadedWithId=Toutes les données seront importées avec l'id d'import suivant: %s
+ErrorMissingMandatoryValue=Donnée obligatoire non renseignées dans le fichier source, champ numéro %s.
+TooMuchErrors=Il y a encore %s autres lignes en erreur mais leur affichage a été limité.
+TooMuchWarnings=Il y a encore %s autres lignes en warnings mais leur affichage a été limité.
+EmptyLine=Ligne vide
+CorrectErrorBeforeRunningImport=Vous devez d'abord corriger toutes les erreurs avant de pouvoir lancer l'import définitif.