Explanation in import module is more clear.

This commit is contained in:
Laurent Destailleur 2009-11-09 22:10:39 +00:00
parent c431935de0
commit be1545b9db
7 changed files with 79 additions and 17 deletions

View File

@ -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 ='<b>'.$langs->trans("Label").":</b> ".$langs->trans($newlabel)."<br>";
$htmltext.='<b>'.$langs->trans("Table")." -> ".$langs->trans("Field").":</b> ".$tablename." -> ".preg_replace('/^.*\./','',$code)."</b><br>";
$htmltext.='<b>'.$langs->trans("Required").':</b> '.yn(preg_match('/\*$/',$label));
$note=$objimport->array_import_examplevalues[0][$code];
if ($note) $htmltext.='<br><b>'.$langs->trans("Note").'/'.$langs->trans("Example").':</b> '.$note;
$text.=$more;
print $html->textwithpicto($text,$htmltext);
print $text;
print '</td>';
// Info field
print '<td style="font-weight: normal" align="right">';
$filecolumn=$array_match_database_to_file[$code];
$htmltext ='<b><u>'.$langs->trans("FieldSource").'</u></b><br>';
if ($filecolumn > sizeof($fieldssource)) $htmltext.=$langs->trans("DataComeFromNoWhere").'<br>';
else
{
if (empty($objimport->array_import_convertvalue[0][$code])) // If source file does not need convertion
{
$htmltext.=$langs->trans("DataComeFromFileFieldNb",$filecolumn).'<br>';
}
else
{
if ($objimport->array_import_convertvalue[0][$code]['rule']=='fetchfromref') $htmltext.=$langs->trans("DataComeFromIdFoundFromRef",$filecolumn,$langs->transnoentitiesnoconv($entitylang)).'<br>';
}
}
$htmltext.=$langs->trans("SourceRequired").': <b>'.yn(preg_match('/\*$/',$label)).'</b>';
$example=$objimport->array_import_examplevalues[0][$code];
if ($example) $htmltext.='<br>'.$langs->trans("SourceExample").': <b>'.$example.'</b><br>';
$htmltext.='<br>';
$htmltext.='<b><u>'.$langs->trans("FieldTarget").'</u></b><br>';
if (empty($objimport->array_import_convertvalue[0][$code])) // If source file does not need convertion
{
$htmltext.=$langs->trans("DataIsInsertedInto").'<br>';
}
else
{
if ($objimport->array_import_convertvalue[0][$code]['rule']=='fetchfromref') $htmltext.=$langs->trans("DataIDSourceIsInsertedInto").'<br>';
}
$htmltext.=$langs->trans("FieldTitle").": <b>".$langs->trans($newlabel)."</b><br>";
$htmltext.=$langs->trans("Table")." -> ".$langs->trans("Field").': <b>'.$tablename." -> ".preg_replace('/^.*\./','',$code)."</b><br>";
print $html->textwithpicto($more,$htmltext);
print '</td>';
print '</tr>';

View File

@ -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

View File

@ -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');
*/

View File

@ -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)

View File

@ -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 "<b>%s</b>" 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 <b>import_key='%s'</b>.
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 id of parent object to use (So the objet <b>%s</b> 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

View File

@ -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)

View File

@ -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 "<b>%s</b>" 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 <b>%s</b>.
YouCanUseImportIdToFindRecord=Vous pourrez retrouver les enregistrements issus de cet import dans votre base par un filtrage sur le champ <b>import_key='%s'</b>.
NbOfLinesOK=Nombre de lignes sans erreurs ni warning: <b>%s</b>.
NbOfLinesImported=Nombre de lignes importées avec succès: <b>%s</b>.
NbOfLinesImported=Nombre de lignes importées avec succès: <b>%s</b>.
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 <b>%s</b> du fichier source.
DataComeFromIdFoundFromRef=La valeur issue du champ numéro <b>%s</b> du fichier source sera utilisée pour trouver l'id de l'objet père à utiliser (L'objet <b>%s</b> 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