diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php
index b200dc583f5..4f4833f30e7 100644
--- a/htdocs/imports/import.php
+++ b/htdocs/imports/import.php
@@ -639,7 +639,7 @@ if ($step == 4 && $datatoimport)
//var_dump($array_match_file_to_database);
- // Is it a first time in page
+ // Is it a first time in page (if yes, we must initialize array_match_file_to_database)
if (sizeof($array_match_file_to_database) == 0)
{
// This is first input in screen, we need to define
@@ -671,6 +671,8 @@ if ($step == 4 && $datatoimport)
// Save the match array in session. We now will use the array in session.
$_SESSION["dol_array_match_file_to_database"]=$serialized_array_match_file_to_database;
}
+ $array_match_database_to_file=array_flip($array_match_file_to_database);
+
//print $serialized_array_match_file_to_database;
//print $_SESSION["dol_array_match_file_to_database"];
//var_dump($array_match_file_to_database);exit;
@@ -791,7 +793,7 @@ if ($step == 4 && $datatoimport)
foreach ($array_match_file_to_database as $key => $val)
{
$var=!$var;
- show_elem($fieldssource,$lefti,$key,$val,$var); // key is field number is source file
+ show_elem($fieldssource,$lefti,$key,$val,$var); // key is field number in source file
//print '> '.$lefti.'-'.$key.'-'.$val;
$listofkeys[$key]=1;
$fieldsplaced[$key]=1;
@@ -851,13 +853,40 @@ if ($step == 4 && $datatoimport)
if ($mandatoryfieldshavesource) $mandatoryfieldshavesource=(! empty($valforsourcefieldnb[$i]) && ($valforsourcefieldnb[$i] <= sizeof($fieldssource)));
//print 'xx'.($i).'-'.$valforsourcefieldnb[$i].'-'.$mandatoryfieldshavesource;
}
- $htmltext =''.$langs->trans("Label").": ".$langs->trans($newlabel)."
";
- $htmltext.=''.$langs->trans("Table")." -> ".$langs->trans("Field").": ".$tablename." -> ".preg_replace('/^.*\./','',$code)."
";
- $htmltext.=''.$langs->trans("Required").': '.yn(preg_match('/\*$/',$label));
- $note=$objimport->array_import_examplevalues[0][$code];
- if ($note) $htmltext.='
'.$langs->trans("Note").'/'.$langs->trans("Example").': '.$note;
- $text.=$more;
- print $html->textwithpicto($text,$htmltext);
+ print $text;
+ print '';
+ // Info field
+ print '
';
+ $filecolumn=$array_match_database_to_file[$code];
+ $htmltext =''.$langs->trans("FieldSource").' ';
+ if ($filecolumn > sizeof($fieldssource)) $htmltext.=$langs->trans("DataComeFromNoWhere").' ';
+ else
+ {
+ if (empty($objimport->array_import_convertvalue[0][$code])) // If source file does not need convertion
+ {
+ $htmltext.=$langs->trans("DataComeFromFileFieldNb",$filecolumn).' ';
+ }
+ else
+ {
+ if ($objimport->array_import_convertvalue[0][$code]['rule']=='fetchfromref') $htmltext.=$langs->trans("DataComeFromIdFoundFromRef",$filecolumn,$langs->transnoentitiesnoconv($entitylang)).' ';
+ }
+ }
+ $htmltext.=$langs->trans("SourceRequired").': '.yn(preg_match('/\*$/',$label)).'';
+ $example=$objimport->array_import_examplevalues[0][$code];
+ if ($example) $htmltext.=' '.$langs->trans("SourceExample").': '.$example.' ';
+ $htmltext.=' ';
+ $htmltext.=''.$langs->trans("FieldTarget").' ';
+ if (empty($objimport->array_import_convertvalue[0][$code])) // If source file does not need convertion
+ {
+ $htmltext.=$langs->trans("DataIsInsertedInto").' ';
+ }
+ else
+ {
+ if ($objimport->array_import_convertvalue[0][$code]['rule']=='fetchfromref') $htmltext.=$langs->trans("DataIDSourceIsInsertedInto").' ';
+ }
+ $htmltext.=$langs->trans("FieldTitle").": ".$langs->trans($newlabel)." ";
+ $htmltext.=$langs->trans("Table")." -> ".$langs->trans("Field").': '.$tablename." -> ".preg_replace('/^.*\./','',$code)." ";
+ print $html->textwithpicto($more,$htmltext);
print ' | ';
print '';
diff --git a/htdocs/includes/modules/import/import_csv.modules.php b/htdocs/includes/modules/import/import_csv.modules.php
index 8a6e53007e2..dc3c05b52af 100644
--- a/htdocs/includes/modules/import/import_csv.modules.php
+++ b/htdocs/includes/modules/import/import_csv.modules.php
@@ -286,8 +286,10 @@ class ImportCsv extends ModeleImports
//var_dump($array_match_file_to_database);
//var_dump($arrayrecord);
+ $array_match_database_to_file=array_flip($array_match_file_to_database);
$sort_array_match_file_to_database=$array_match_file_to_database;
ksort($sort_array_match_file_to_database);
+
//var_dump($sort_array_match_file_to_database);
if (sizeof($arrayrecord) == 0 ||
@@ -309,7 +311,7 @@ class ImportCsv extends ModeleImports
$listvalues='';
$i=0;
$errorforthistable=0;
- // Loop on each fields in the match array
+ // Loop on each fields in the match array ($key = 1..n, $val=alias of field)
foreach($sort_array_match_file_to_database as $key => $val)
{
if ($key <= $maxfields)
@@ -357,16 +359,21 @@ class ImportCsv extends ModeleImports
}
$i++;
}
+
if (! $errorforthistable)
{
if ($listfields)
{
- // If some values need to be found somewhere than in source file: Might be a rowid found from a fetch on a reference.
+ // If some values need to be found somewhere else than in source file: Case we need a rowid found from a fetch on a reference.
// This is used when insert must be done when a parent row already exists
// $objimport->array_import_convertvalue=array('s.fk_soc'=>array('rule'=>'fetchfromref',file='/societe.class.php','class'=>'Societe','method'=>'fetch'));
- // TODO
+ foreach($objimport->array_import_convertvalue as $alias => $rulearray)
+ {
+ if (empty($rulearray['rule']) || $rulearray['rule']!='fetchfromref') continue;
+ dol_syslog("We need to get rowid from ref=".$alias." using value found in column ".$array_match_database_to_file." in source file, so ".$arrayrecord[$array_match_database_to_file]['val']);
+ }
- // If some values need to be found somewhere than in source file: Might be lastinsert id from previous insert
+ // If some values need to be found somewhere else than in source file: Case we need lastinsert id from previous insert
// This is used when insert must be done in several tables
// $objimport->array_import_convertvalue=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
// TODO
diff --git a/htdocs/includes/modules/modSociete.class.php b/htdocs/includes/modules/modSociete.class.php
index 57604d49030..0359cb47b52 100644
--- a/htdocs/includes/modules/modSociete.class.php
+++ b/htdocs/includes/modules/modSociete.class.php
@@ -244,11 +244,11 @@ class modSociete extends DolibarrModules
$this->import_icon[$r]='contact';
//$this->import_permission[$r]=array(array("societe","export"));
$this->import_tables_array[$r]=array('s'=>MAIN_DB_PREFIX.'socpeople'); // List of tables to insert into (insert done in same order)
- $this->import_fields_array[$r]=array('s.fk_soc'=>'ThirdPartyName*','s.nom'=>"Name*",'s.prefix_comm'=>"Prefix",'s.client'=>"Customer*",'s.fournisseur'=>"Supplier*",'s.datec'=>"DateCreation",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode",'s.address'=>"Address",'s.cp'=>"Zip",'s.ville'=>"Town",'s.tel'=>"Phone",'s.fax'=>"Fax",'s.url'=>"Url",'s.email'=>"Email",'s.siret'=>"IdProf1",'s.siren'=>"IdProf2",'s.ape'=>"IdProf3",'s.idprof4'=>"IdProf4",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital",'s.note'=>"Note",'s.fk_typent'=>"ThirdPartyType",'s.fk_effectif'=>"Effectif","s.fk_forme_juridique"=>"JuridicalStatus",'s.fk_prospectlevel'=>'ProspectLevel','s.fk_stcomm'=>'ProspectStatus');
+ $this->import_fields_array[$r]=array('s.fk_soc'=>'ThirdPartyName*','s.civilite'=>'Civility','s.name'=>"Name*",'s.firstname'=>"Firstname",'s.address'=>"Address",'s.cp'=>"Zip",'s.ville'=>"Town",'s.fk_pays'=>"CountryCode",'s.birthday'=>"BirthdayDate",'s.poste'=>"Role",'s.phone'=>"Phone",'s.phone_perso'=>"PhonePerso",'s.phone_mobile'=>"PhoneMobile",'s.fax'=>"Fax",'s.email'=>"Email",'s.note'=>"Note");
$this->import_entities_array[$r]=array('s.fk_soc'=>'company'); // We define here only fields that use another picto
- $this->import_examplevalues_array[$r]=array('t.nom'=>'A third party ref','s.nom'=>"A company",'s.prefix_comm'=>"comp",'s.client'=>'0 or 1','s.fournisseur'=>'0 or 1','s.datec'=>dol_print_date(mktime(),'YYYY-MM-DD'),'s.code_client'=>"CU01-0001",'s.code_fournisseur'=>"SU01-0001",'s.address'=>"61 jump street",'s.cp'=>"123456",'s.ville'=>"Big town",'s.tel'=>"0101010101",'s.fax'=>"0101010102",'s.url'=>"http://mycompany.com",'s.email'=>"test@mycompany.com",'s.siret'=>"",'s.siren'=>"",'s.ape'=>"",'s.idprof4'=>"",'s.tva_intra'=>"FR0123456789",'s.capital'=>"10000",'s.note'=>"This is an example of note for record",'s.fk_typent'=>"2",'s.fk_effectif'=>"3","s.fk_forme_juridique"=>"1",'s.fk_prospectlevel'=>'AAA','s.fk_stcomm'=>'BBB');
+ $this->import_examplevalues_array[$r]=array('s.fk_soc'=>'The Big Company','s.civilite'=>"MR",'s.name'=>"Smith",'s.firstname'=>'John','s.address'=>'61 jump street','s.cp'=>'75000','s.ville'=>'Bigtown','s.fk_pays'=>'0','s.datec'=>'1972-10-10','s.poste'=>"Director",'s.phone'=>"5551122",'s.phone_perso'=>"5551133",'s.phone_mobile'=>"5551144",'s.fax'=>"5551155",'s.email'=>"johnsmith@email.com",'s.note'=>"My comments");
// If value for some fields are a ref to found the key of parent
- //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'fetchfromref',file='/societe.class.php','class'=>'Societe','method'=>'fetch'));
+ $this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'fetchfromref','file'=>'/societe.class.php','class'=>'Societe','method'=>'fetch'));
// If value for some fields must be the previous inserted record (lastinsertid)
//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
*/
diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang
index 58c5e01c443..c9e8ea9d322 100644
--- a/htdocs/langs/en_US/companies.lang
+++ b/htdocs/langs/en_US/companies.lang
@@ -33,6 +33,7 @@ Company=Company
CompanyName=Company name
Companies=Companies
CountryIsInEEC=Country is inside European Economic Community
+ThirdPartyName=Third party name
ThirdParty=Third party
ThirdParties=Third parties
ThirdPartyAll=Third parties (all)
diff --git a/htdocs/langs/en_US/exports.lang b/htdocs/langs/en_US/exports.lang
index 4a3c0b21687..ae4aa035ff9 100644
--- a/htdocs/langs/en_US/exports.lang
+++ b/htdocs/langs/en_US/exports.lang
@@ -28,6 +28,8 @@ Dataset=Dataset
ChooseFieldsOrdersAndTitle=Choose fields order...
FieldsOrder=Fields order
FieldsTitle=Fields title
+FieldOrder=Field order
+FieldTitle=Field title
ChooseExportFormat=Choose export format
NowClickToGenerateToBuildExportFile=Now, select file format in combo box and click on "Generate" to build export file...
AvailableFormats=Available formats
@@ -73,6 +75,9 @@ ErrorImportDuplicateProfil=Failed to save this import profile with this name. An
ImportSummary=Import setup summary
TablesTarget=Targeted tables
FieldsTarget=Targeted fields
+TableTarget=Targeted table
+FieldTarget=Targeted field
+FieldSource=Source field
DoNotImportFirstLine=Do not import first line of source file
NbOfSourceLines=Number of lines in source file
NowClickToTestTheImport=Check import parameters you have defined. If they are correct, click on button "%s" to launch a simulation of import process (no data will be changed in your database, it's only a simulation for the moment)...
@@ -94,3 +99,10 @@ CorrectErrorBeforeRunningImport=You must first correct all errors before running
YouCanUseImportIdToFindRecord=You can find all imported records in your database by filtering on field import_key='%s'.
NbOfLinesOK=Number of lines with no errors and no warnings: %s.
NbOfLinesImported=Number of lines successfully imported: %s.
+DataComeFromNoWhere=Value to insert comes from nowhere in source file.
+DataComeFromFileFieldNb=Value to insert comes from field number %s in source file.
+DataComeFromIdFoundFromRef=Value that comes from field number %s of source file will be used to find id of parent object to use (So the objet %s that has the ref. from source file must exists into Dolibarr).
+DataIsInsertedInto=Data coming from source file will be inserted into the following field:
+DataIDSourceIsInsertedInto=The id of parent object found using the data in source file, will be inserted into the following field:
+SourceRequired=Data value is mandatory
+SourceExample=Example of possible data value
\ No newline at end of file
diff --git a/htdocs/langs/fr_FR/companies.lang b/htdocs/langs/fr_FR/companies.lang
index 358ca945498..874be4eb20c 100644
--- a/htdocs/langs/fr_FR/companies.lang
+++ b/htdocs/langs/fr_FR/companies.lang
@@ -34,6 +34,7 @@ Company=Société
CompanyName=Raison sociale
Companies=Sociétés
CountryIsInEEC=Pays de la Communauté Economique Européenne
+ThirdPartyName=Nom du tiers
ThirdParty=Tiers
ThirdParties=Tiers
ThirdPartyAll=Tiers (tous)
diff --git a/htdocs/langs/fr_FR/exports.lang b/htdocs/langs/fr_FR/exports.lang
index 4996b5add43..2e2559c13b9 100644
--- a/htdocs/langs/fr_FR/exports.lang
+++ b/htdocs/langs/fr_FR/exports.lang
@@ -28,6 +28,8 @@ Dataset=Lot de données
ChooseFieldsOrdersAndTitle=Choisissez l'ordre des champs...
FieldsOrder=Ordre des champs
FieldsTitle=Titre champs
+FieldOrder=Ordre du champ
+FieldTitle=Titre champ
ChooseExportFormat=Choisissez le format d'export
NowClickToGenerateToBuildExportFile=Maintenant, sélectionner le format d'export dans la liste déroulante et cliquez sur "Générer" pour fabriquer le fichier export...
AvailableFormats=Formats dispo.
@@ -73,6 +75,9 @@ ErrorImportDuplicateProfil=Impossible de sauvegarder le profil d'import sous ce
ImportSummary=Résumé de la configuration d'import
TablesTarget=Tables cibles
FieldsTarget=Champs cibles
+TableTarget=Table cible
+FieldTarget=Champ cible
+FieldSource=Champ source
DoNotImportFirstLine=Ne pas importer la première ligne du fichier source
NbOfSourceLines=Nombre de lignes du fichier source
NowClickToTestTheImport=Vérifiez les paramètres d'import que vous avez défini. S'ils vous conviennent, cliquez sur le bouton "%s" pour lancer une simulation d'import (aucune donnée ne sera modifié, il s'agit dans un premier temps d'une simple simulation)...
@@ -94,4 +99,11 @@ CorrectErrorBeforeRunningImport=Vous devez d'abord corriger toutes les erreurs a
FileWasImported=Le fichier a été importé sous le numéro d'import %s.
YouCanUseImportIdToFindRecord=Vous pourrez retrouver les enregistrements issus de cet import dans votre base par un filtrage sur le champ import_key='%s'.
NbOfLinesOK=Nombre de lignes sans erreurs ni warning: %s.
-NbOfLinesImported=Nombre de lignes importées avec succès: %s.
\ No newline at end of file
+NbOfLinesImported=Nombre de lignes importées avec succès: %s.
+DataComeFromNoWhere=La valeur à insérer n'est issue d'aucun champ du fichier source.
+DataComeFromFileFieldNb=La valeur à insérer sera issue du champ numéro %s du fichier source.
+DataComeFromIdFoundFromRef=La valeur issue du champ numéro %s du fichier source sera utilisée pour trouver l'id de l'objet père à utiliser (L'objet %s ayant la réf. issue du fichier source doit donc exister dans Dolibarr).
+DataIsInsertedInto=La donnée issue du fichier source sera insérée dans le champ suivant:
+DataIDSourceIsInsertedInto=L'id de l'objet père retrouvé à partir de la donnée source, sera insérée dans le champ suivant:
+SourceRequired=Donnée source obligatoire
+SourceExample=Exemple de donnée source possible
\ No newline at end of file