mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Fix: Better error message during import of csv with records split onto
several lines.
This commit is contained in:
parent
4c1f301f4e
commit
271dcf578f
|
|
@ -267,6 +267,9 @@ class ImportCsv extends ModeleImports
|
|||
$arrayres=fgetcsv($this->handle,100000,$this->separator,$this->enclosure,$this->escape);
|
||||
}
|
||||
|
||||
// End of file
|
||||
if ($arrayres === false) return false;
|
||||
|
||||
//var_dump($this->handle);
|
||||
//var_dump($arrayres);exit;
|
||||
$newarrayres=array();
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ class modAdherent extends DolibarrModules
|
|||
$this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon
|
||||
$this->import_tables_array[$r]=array('a'=>MAIN_DB_PREFIX.'adherent','extra'=>MAIN_DB_PREFIX.'adherent_extrafields');
|
||||
$this->import_tables_creator_array[$r]=array('a'=>'fk_user_author'); // Fields to store import user id
|
||||
$this->import_fields_array[$r]=array('a.civilite'=>"UserTitle",'a.nom'=>"Lastname*",'a.firstname'=>"Firstname",'a.login'=>"Login*","a.pass"=>"Password","a.fk_adherent_type"=>"MemberType*",'a.morphy'=>'Nature*','a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town",'a.country'=>"Country",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status*",'a.photo'=>"Photo",'a.note'=>"Note",'a.datec'=>'DateCreation','a.datefin'=>'DateEndSubscription');
|
||||
$this->import_fields_array[$r]=array('a.civilite'=>"UserTitle",'a.lastname'=>"Lastname*",'a.firstname'=>"Firstname",'a.login'=>"Login*","a.pass"=>"Password","a.fk_adherent_type"=>"MemberType*",'a.morphy'=>'Nature*','a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town",'a.country'=>"Country",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status*",'a.photo'=>"Photo",'a.note'=>"Note",'a.datec'=>'DateCreation','a.datefin'=>'DateEndSubscription');
|
||||
// Add extra fields
|
||||
$sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'member'";
|
||||
$resql=$this->db->query($sql);
|
||||
|
|
@ -223,7 +223,7 @@ class modAdherent extends DolibarrModules
|
|||
// End add extra fields
|
||||
$this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'adherent'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
|
||||
$this->import_regex_array[$r]=array('a.civilite'=>'code@'.MAIN_DB_PREFIX.'c_civilite','a.fk_adherent_type'=>'rowid@'.MAIN_DB_PREFIX.'adherent_type','a.morphy'=>'(phy|mor)','a.statut'=>'^[0|1]','a.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','a.datefin'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
|
||||
$this->import_examplevalues_array[$r]=array('a.civilite'=>"MR",'a.nom'=>'Smith','a.firstname'=>'John','a.login'=>'jsmith','a.pass'=>'passofjsmith','a.fk_adherent_type'=>'1','a.morphy'=>'"mor" or "phy"','a.societe'=>'JS company','a.address'=>'21 jump street','a.zip'=>'55000','a.town'=>'New York','a.country'=>'1','a.email'=>'jsmith@example.com','a.birth'=>'1972-10-10','a.statut'=>"0 or 1",'a.note'=>"This is a comment on member",'a.datec'=>dol_print_date($now,'%Y-%m-%d'),'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'),'%Y-%m-%d'));
|
||||
$this->import_examplevalues_array[$r]=array('a.civilite'=>"MR",'a.lastname'=>'Smith','a.firstname'=>'John','a.login'=>'jsmith','a.pass'=>'passofjsmith','a.fk_adherent_type'=>'1','a.morphy'=>'"mor" or "phy"','a.societe'=>'JS company','a.address'=>'21 jump street','a.zip'=>'55000','a.town'=>'New York','a.country'=>'1','a.email'=>'jsmith@example.com','a.birth'=>'1972-10-10','a.statut'=>"0 or 1",'a.note'=>"This is a comment on member",'a.datec'=>dol_print_date($now,'%Y-%m-%d'),'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'),'%Y-%m-%d'));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1307,13 +1307,19 @@ if ($step == 5 && $datatoimport)
|
|||
$result=$obj->import_open_file($pathfile,$langs);
|
||||
if ($result > 0)
|
||||
{
|
||||
$sourcelinenb=0;
|
||||
$sourcelinenb=0; $endoffile=0;
|
||||
// Loop on each input file record
|
||||
while ($sourcelinenb < $nboflines)
|
||||
while ($sourcelinenb < $nboflines && ! $endoffile)
|
||||
{
|
||||
$sourcelinenb++;
|
||||
// Read line and stor it into $arrayrecord
|
||||
$arrayrecord=$obj->import_read_record();
|
||||
if ($arrayrecord === false)
|
||||
{
|
||||
$arrayofwarnings[$sourcelinenb][0]=array('lib'=>'File has '.$nboflines.' lines. However we reach end of file after record '.$sourcelinenb.'. This may occurs when some records are split onto several lines.','type'=>'EOF_RECORD_ON_SEVERAL_LINES');
|
||||
$endoffile++;
|
||||
continue;
|
||||
}
|
||||
if ($excludefirstline && $sourcelinenb == 1) continue;
|
||||
|
||||
//
|
||||
|
|
@ -1615,11 +1621,17 @@ if ($step == 6 && $datatoimport)
|
|||
$result=$obj->import_open_file($pathfile,$langs);
|
||||
if ($result > 0)
|
||||
{
|
||||
$sourcelinenb=0;
|
||||
while ($sourcelinenb < $nboflines)
|
||||
$sourcelinenb=0; $endoffile=0;
|
||||
while ($sourcelinenb < $nboflines && ! $endoffile)
|
||||
{
|
||||
$sourcelinenb++;
|
||||
$arrayrecord=$obj->import_read_record();
|
||||
if ($arrayrecord === false)
|
||||
{
|
||||
$arrayofwarnings[$sourcelinenb][0]=array('lib'=>'File has '.$nboflines.' lines. However we reach end of file after record '.$sourcelinenb.'. This may occurs when some records are split onto several lines.','type'=>'EOF_RECORD_ON_SEVERAL_LINES');
|
||||
$endoffile++;
|
||||
continue;
|
||||
}
|
||||
if ($excludefirstline && $sourcelinenb == 1) continue;
|
||||
|
||||
$result=$obj->import_insert($arrayrecord,$array_match_file_to_database,$objimport,count($fieldssource),$importid);
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ ErrorContactEMail=A technical error occured. Please, contact administrator to fo
|
|||
ErrorWrongValueForField=Wrong value for field number <b>%s</b> (value '<b>%s</b>' does not match regex rule <b>%s</b>)
|
||||
ErrorFieldValueNotIn=Wrong value for field number <b>%s</b> (value '<b>%s</b>' is not a value available into field <b>%s</b> of table <b>%s</b>)
|
||||
ErrorFieldRefNotIn=Wrong value for field number <b>%s</b> (value '<b>%s</b>' is not a <b>%s</b> existing ref)
|
||||
ErrorsOnXLines=Errors on <b>%s</b> source lines
|
||||
ErrorsOnXLines=Errors on <b>%s</b> source record(s)
|
||||
ErrorFileIsInfectedWithAVirus=The antivirus program was not able to validate the file (file might be infected by a virus)
|
||||
ErrorSpecialCharNotAllowedForField=Special characters are not allowed for field "%s"
|
||||
ErrorDatabaseParameterWrong=Database setup parameter '<b>%s</b>' has a value not compatible to use Dolibarr (must have value '<b>%s</b>').
|
||||
|
|
@ -131,7 +131,7 @@ WarningBuildScriptNotRunned=Script <b>%s</b> was not yet ran to build graphics,
|
|||
WarningBookmarkAlreadyExists=A bookmark with this title or this target (URL) already exists.
|
||||
WarningPassIsEmpty=Warning, database password is empty. This is a security hole. You should add a password to your database and change your conf.php file to reflect this.
|
||||
WarningConfFileMustBeReadOnly=Warning, your config file (<b>htdocs/conf/conf.php</b>) can be overwritten by the web server. This is a serious security hole. Modify permissions on file to be in read only mode for operating system user used by Web server. If you use Windows and FAT format for your disk, you must know that this file system does not allow to add permissions on file, so can't be completely safe.
|
||||
WarningsOnXLines=Warnings on <b>%s</b> source lines
|
||||
WarningsOnXLines=Warnings on <b>%s</b> source record(s)
|
||||
WarningNoDocumentModelActivated=No model, for document generation, has been activated. A model will be choosed by default until you check your module setup.
|
||||
WarningLockFileDoesNotExists=Warning, once setup is finished, you must disable install/migrate tools by adding a file <b>install.lock</b> into directory <b>%s</b>. Missing this file is a security hole.
|
||||
WarningUntilDirRemoved=All security warnings (visible by admin users only) will remain active as long as the vulnerability is present (or that constant MAIN_REMOVE_INSTALL_WARNING is added in Setup->Other setup).
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ ErrorContactEMail=Une erreur technique est apparue. Merci de contacter l'adminis
|
|||
ErrorWrongValueForField=Mauvaise valeur pour le champ numéro <b>%s</b> (la valeur '<b>%s</b>' ne respecte pas la règle <b>%s</b>)
|
||||
ErrorFieldValueNotIn=Mauvaise valeur pour le champ numéro <b>%s</b> (la valeur '<b>%s</b>' n'est pas une valeure présente dans le champ <b>%s</b> de la table <b>%s</b>)
|
||||
ErrorFieldRefNotIn=Mauvaise valeur pour le champ numéro <b>%s</b> (la valeur '<b>%s</b>' n'est pas une référence existante comme <b>%s</b>)
|
||||
ErrorsOnXLines=Erreurs sur <b>%s</b> lignes sources
|
||||
ErrorsOnXLines=Erreurs sur <b>%s</b> enregistrement(s) source
|
||||
ErrorFileIsInfectedWithAVirus=L'antivirus n'a pas pu valider ce fichier (il est probablement infecté par un virus) !
|
||||
ErrorSpecialCharNotAllowedForField=Les caractères spéciaux ne sont pas admis pour le champ "%s"
|
||||
ErrorDatabaseParameterWrong=Le paramètre de configuration de la base de donnée '<b>%s</b>' a une valeur non compatible pour une utilisation de Dolibarr (doit avoir la valeur '<b>%s</b>').
|
||||
|
|
@ -132,7 +132,7 @@ WarningBuildScriptNotRunned=Le script <b>%s</b> n'a pas encore été lancé pour
|
|||
WarningBookmarkAlreadyExists=Un marque-page avec ce titre ou cette destination (URL) existe déjà.
|
||||
WarningPassIsEmpty=Attention, le mot de passe de la base de données Dolibarr est vide. Cela représente une faille de sécurité. Il est recommandé d'ajouter manuellement un mot de passe à la base et de modifier le fichier conf.php pour refléter ce changement.
|
||||
WarningConfFileMustBeReadOnly=Attention, votre fichier de configuration (<b>htdocs/conf/conf.php</b>) est accessible en écriture au serveur Web. Ceci représente une faille sérieuse de sécurité. Modifiez les permissions pour qu'il soit en lecture seule pour le compte sous lequel tourne le serveur Web et non lisible pour les autres.<br>Si vous êtes sous Windows sur un disque dur utilisant un formatage FAT, sachez que ce système de fichier ne permet pas de protéger des fichiers et n'offre donc aucune solution pour réduire les risques de manipulation de ce fichier.
|
||||
WarningsOnXLines=Alertes sur <b>%s</b> lignes sources
|
||||
WarningsOnXLines=Alertes sur <b>%s</b> enregistrement(s) source
|
||||
WarningNoDocumentModelActivated=Aucun modèle, pour la génération de document, n'a été activé. Un modèle sera pris par défaut en attendant la correction de configuration du module.
|
||||
WarningLockFileDoesNotExists=Attention, une fois l'installation terminée, les outils d'installation/migration doivent être désactivés en ajoutant un fichier <b>install.lock</b> dans le répertoire <b>%s</b>. L'absence de ce fichier représente une faille de sécurité.
|
||||
WarningUntilDirRemoved=Les alertes de sécurité sont visibles par les administrateurs uniquement et resteront actives tant que la vulnérabilité sera avérée (ou que la constante MAIN_REMOVE_INSTALL_WARNING aura été définie dans Configuration->Divers)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user