Fix: Some minors fixes on import module and test to be sure we can enhance module to import when there is several tables.
This commit is contained in:
parent
510ab36b0a
commit
2cd1bc975e
@ -46,7 +46,7 @@ $entitytoicon=array(
|
||||
'account'=>'account',
|
||||
'payment'=>'payment',
|
||||
'product'=>'product','stock'=>'generic','warehouse'=>'stock',
|
||||
'category'=>'generic',
|
||||
'category'=>'category',
|
||||
'other'=>'generic',
|
||||
);
|
||||
$entitytolang=array( // Translation code
|
||||
@ -410,22 +410,22 @@ if ($step == 2 && $datatoexport)
|
||||
|
||||
$i++;
|
||||
|
||||
$entity=$objexport->array_export_entities[0][$code];
|
||||
$entity=(! empty($objexport->array_export_entities[0][$code])?$objexport->array_export_entities[0][$code]:$objexport->array_export_icon[0]);
|
||||
$entityicon=$entitytoicon[$entity]?$entitytoicon[$entity]:$entity;
|
||||
$entitylang=$entitytolang[$entity]?$entitytolang[$entity]:$entity;
|
||||
|
||||
print '<td nowrap="nowrap">'.img_object('',$entityicon).' '.$langs->trans($entitylang).'</td>';
|
||||
$text=$langs->trans($label);
|
||||
$tablename=getablenamefromfield($code,$sqlmaxforexport);
|
||||
$htmltext ='<b>'.$langs->trans("Name").":</b> ".$text.'<br>';
|
||||
$htmltext.='<b>'.$langs->trans("Table")." -> ".$langs->trans("Field").":</b> ".$tablename." -> ".preg_replace('/^.*\./','',$code)."<br>";
|
||||
if ((isset($array_selected[$code]) && $array_selected[$code]) || $modelchoice == 1)
|
||||
{
|
||||
// Selected fields
|
||||
print '<td> </td>';
|
||||
print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?step=2&datatoexport='.$datatoexport.'&action=unselectfield&field='.$code.'">'.img_left().'</a></td>';
|
||||
print '<td>';
|
||||
$text=$langs->trans($label);
|
||||
$tablename=getablenamefromfield($code,$sqlmaxforexport);
|
||||
$htmltext =$langs->trans("Table").": <b>".$tablename."</b><br>";
|
||||
$htmltext.=$langs->trans("Field").': <b>'.$code."</b><br>";
|
||||
print $html->textwithpicto($text,$htmltext);
|
||||
print $html->textwithpicto($text,$htmltext);
|
||||
//print ' ('.$code.')';
|
||||
print '</td>';
|
||||
$bit=1;
|
||||
@ -434,10 +434,6 @@ if ($step == 2 && $datatoexport)
|
||||
{
|
||||
// Fields not selected
|
||||
print '<td>';
|
||||
$text=$langs->trans($label);
|
||||
$tablename=getablenamefromfield($code,$sqlmaxforexport);
|
||||
$htmltext =$langs->trans("Table").": <b>".$tablename."</b><br>";
|
||||
$htmltext.=$langs->trans("Field").': <b>'.$code."</b><br>";
|
||||
print $html->textwithpicto($text,$htmltext);
|
||||
//print ' ('.$code.')';
|
||||
print '</td>';
|
||||
@ -550,7 +546,7 @@ if ($step == 3 && $datatoexport)
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
$entity=$objexport->array_export_entities[0][$code];
|
||||
$entity=(! empty($objexport->array_export_entities[0][$code])?$objexport->array_export_entities[0][$code]:$objexport->array_export_icon[0]);
|
||||
$entityicon=$entitytoicon[$entity]?$entitytoicon[$entity]:$entity;
|
||||
$entitylang=$entitytolang[$entity]?$entitytolang[$entity]:$entity;
|
||||
|
||||
@ -559,9 +555,9 @@ if ($step == 3 && $datatoexport)
|
||||
print '<td>';
|
||||
$text=$langs->trans($objexport->array_export_fields[0][$code]);
|
||||
$tablename=getablenamefromfield($code,$sqlmaxforexport);
|
||||
$htmltext =$langs->trans("Table").": <b>".$tablename."</b><br>";
|
||||
$htmltext.=$langs->trans("Field").': <b>'.$code."</b><br>";
|
||||
print $html->textwithpicto($text,$htmltext);
|
||||
$htmltext ='<b>'.$langs->trans("Name").":</b> ".$text.'<br>';
|
||||
$htmltext.='<b>'.$langs->trans("Table")." -> ".$langs->trans("Field").":</b> ".$tablename." -> ".preg_replace('/^.*\./','',$code)."<br>";
|
||||
print $html->textwithpicto($text,$htmltext);
|
||||
//print ' ('.$code.')';
|
||||
print '</td>';
|
||||
|
||||
@ -799,10 +795,11 @@ function getablenamefromfield($code,$sqlmaxforexport)
|
||||
{
|
||||
$newsql=$sqlmaxforexport;
|
||||
$newsql=preg_replace('/^(.*) FROM /i','',$newsql);
|
||||
$newsql=preg_replace('/ WHERE (.*)$/i','',$newsql);
|
||||
$newsql=preg_replace('/WHERE (.*)$/i','',$newsql); // We must keep the ' ' before WHERE
|
||||
$alias=preg_replace('/\.(.*)$/i','',$code);
|
||||
//print $newsql.' '.$alias;
|
||||
if (preg_match('/([a-zA-Z_]+) as /i'.$alias.'[, \)]',$newsql,$reg))
|
||||
$regexstring='/([a-zA-Z_]+) as '.$alias.'[, \)]/i';
|
||||
if (preg_match($regexstring,$newsql,$reg))
|
||||
{
|
||||
return $reg[1];
|
||||
}
|
||||
|
||||
@ -39,6 +39,7 @@ class Import
|
||||
var $array_import_entities;
|
||||
var $array_import_regex;
|
||||
var $array_import_examplevalues;
|
||||
var $array_import_convertvalue;
|
||||
|
||||
|
||||
/**
|
||||
@ -147,8 +148,10 @@ class Import
|
||||
$this->array_import_entities[$i]=$module->import_entities_array[$r];
|
||||
// Tableau des alias a exporter (cle=champ, valeur=alias)
|
||||
$this->array_import_regex[$i]=$module->import_regex_array[$r];
|
||||
// Tableau des alias a exporter (cle=champ, valeur=alias)
|
||||
// Tableau des alias a exporter (cle=champ, valeur=exemple)
|
||||
$this->array_import_examplevalues[$i]=$module->import_examplevalues_array[$r];
|
||||
// Tableau des regles de conversion d'une valeur depuis une autre source (cle=champ, valeur=tableau des regles)
|
||||
$this->array_import_convertvalue[$i]=$module->import_convertvalue_array[$r];
|
||||
|
||||
dol_syslog("Import loaded for module ".$modulename." with index ".$i.", dataset=".$module->import_code[$r].", nb of fields=".sizeof($module->import_fields_code[$r]));
|
||||
$i++;
|
||||
|
||||
@ -76,7 +76,7 @@ $importmodelid=isset($_POST["importmodelid"])? $_POST["importmodelid"] : '';
|
||||
$excludefirstline=isset($_GET["excludefirstline"])? $_GET["excludefirstline"] : (isset($_POST["excludefirstline"])?$_POST["excludefirstline"]:0);
|
||||
|
||||
$objimport=new Import($db);
|
||||
$objimport->load_arrays($user,$datatoimport);
|
||||
$objimport->load_arrays($user,($step==1?'':$datatoimport));
|
||||
|
||||
$objmodelimport=new ModeleImports();
|
||||
|
||||
@ -833,7 +833,7 @@ if ($step == 4 && $datatoimport)
|
||||
|
||||
$i++;
|
||||
|
||||
$entity=$objimport->array_import_entities[0][$code];
|
||||
$entity=(! empty($objimport->array_import_entities[0][$code])?$objimport->array_import_entities[0][$code]:$objimport->array_import_icon[0]);
|
||||
$tablealias=preg_replace('/(\..*)$/i','',$code);
|
||||
$tablename=$objimport->array_import_tables[0][$tablealias];
|
||||
$entityicon=$entitytoicon[$entity]?$entitytoicon[$entity]:$entity;
|
||||
@ -851,11 +851,11 @@ if ($step == 4 && $datatoimport)
|
||||
if ($mandatoryfieldshavesource) $mandatoryfieldshavesource=(! empty($valforsourcefieldnb[$i]) && ($valforsourcefieldnb[$i] <= sizeof($fieldssource)));
|
||||
//print 'xx'.($i).'-'.$valforsourcefieldnb[$i].'-'.$mandatoryfieldshavesource;
|
||||
}
|
||||
$htmltext =$langs->trans("Label").": <b>".$langs->trans($newlabel)."</b><br>";
|
||||
$htmltext.=$langs->trans("Table")." -> ".$langs->trans("Field").": <b>".$tablename."</b> -> <b>".preg_replace('/^.*\./','',$code)."</b><br>";
|
||||
$htmltext.=$langs->trans("Required").': <b>'.yn(preg_match('/\*$/',$label)).'</b>';
|
||||
$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>'.$langs->trans("Note").'/'.$langs->trans("Example").': '.$note;
|
||||
if ($note) $htmltext.='<br><b>'.$langs->trans("Note").'/'.$langs->trans("Example").':</b> '.$note;
|
||||
$text.=$more;
|
||||
print $html->textwithpicto($text,$htmltext);
|
||||
print '</td>';
|
||||
|
||||
@ -361,6 +361,14 @@ class ImportCsv extends ModeleImports
|
||||
{
|
||||
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.
|
||||
// This is used when insert must be done when a parent row already exists
|
||||
// TODO
|
||||
|
||||
// If some values need to be found somewhere than in source file: Might be lastinsert id from previous insert
|
||||
// This is used when insert must be done in several tables
|
||||
// TODO
|
||||
|
||||
// Build SQL request
|
||||
$sql ='INSERT INTO '.$tablename.'('.$listfields.', import_key';
|
||||
if (! empty($objimport->array_import_tables_creator[0][$alias])) $sql.=', '.$objimport->array_import_tables_creator[0][$alias];
|
||||
|
||||
@ -115,9 +115,10 @@ class modCategorie extends DolibarrModules
|
||||
$r++;
|
||||
$this->export_code[$r]='category_'.$r;
|
||||
$this->export_label[$r]='CatSupList';
|
||||
$this->export_icon[$r]='category';
|
||||
$this->export_permission[$r]=array(array("categorie","lire"));
|
||||
$this->export_fields_array[$r]=array('u.rowid'=>"CategId",'u.label'=>"Label",'u.description'=>"Description",'s.rowid'=>'IdThirdParty','s.nom'=>'Name','s.prefix_comm'=>"Prefix",'s.client'=>"Customer",'s.datec'=>"DateCreation",'s.tms'=>"DateLastModification",'s.code_client'=>"CustomerCode",'s.address'=>"Address",'s.cp'=>"Zip",'s.ville'=>"Town",'p.libelle'=>"Country",'p.code'=>"CountryCode",'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");
|
||||
$this->export_entities_array[$r]=array('u.rowid'=>"category",'u.label'=>"category",'u.description'=>"category",'s.rowid'=>'company','s.nom'=>'company','s.prefix_comm'=>"company",'s.client'=>"company",'s.datec'=>"company",'s.tms'=>"company",'s.code_client'=>"company",'s.address'=>"company",'s.cp'=>"company",'s.ville'=>"company",'p.libelle'=>"company",'p.code'=>"company",'s.tel'=>"company",'s.fax'=>"company",'s.url'=>"company",'s.email'=>"company",'s.siret'=>"company",'s.siren'=>"company",'s.ape'=>"company",'s.idprof4'=>"company",'s.tva_intra'=>"company",'s.capital'=>"company",'s.note'=>"company");
|
||||
$this->export_entities_array[$r]=array('s.rowid'=>'company','s.nom'=>'company','s.prefix_comm'=>"company",'s.client'=>"company",'s.datec'=>"company",'s.tms'=>"company",'s.code_client'=>"company",'s.address'=>"company",'s.cp'=>"company",'s.ville'=>"company",'p.libelle'=>"company",'p.code'=>"company",'s.tel'=>"company",'s.fax'=>"company",'s.url'=>"company",'s.email'=>"company",'s.siret'=>"company",'s.siren'=>"company",'s.ape'=>"company",'s.idprof4'=>"company",'s.tva_intra'=>"company",'s.capital'=>"company",'s.note'=>"company"); // We define here only fields that use another picto
|
||||
$this->export_alias_array[$r]=array('u.rowid'=>"idcateg",'u.label'=>"label",'u.description'=>"description",'s.rowid'=>'idsoc','s.nom'=>'name','s.prefix_comm'=>"prefix",'s.client'=>"iscustomer",'s.datec'=>"datecreation",'s.tms'=>"datelastmodification",'s.code_client'=>"customercode",'s.address'=>"address",'s.cp'=>"zip",'s.ville'=>"town",'p.libelle'=>"country",'p.code'=>"countrycode",'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'=>"vatintra",'s.capital'=>"capital",'s.note'=>"note");
|
||||
$this->export_sql_start[$r]='SELECT DISTINCT ';
|
||||
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_fournisseur as cf, '.MAIN_DB_PREFIX.'societe as s LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_pays as p ON s.fk_pays = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code';
|
||||
@ -127,10 +128,11 @@ class modCategorie extends DolibarrModules
|
||||
$r++;
|
||||
$this->export_code[$r]='category_'.$r;
|
||||
$this->export_label[$r]='CatCusList';
|
||||
$this->export_icon[$r]='category';
|
||||
$this->export_permission[$r]=array(array("categorie","lire"));
|
||||
$this->export_fields_array[$r]=array('u.rowid'=>"CategId",'u.label'=>"Label",'u.description'=>"Description",'s.rowid'=>'IdThirdParty','s.nom'=>'Name','s.prefix_comm'=>"Prefix",'s.client'=>"Customer",'s.datec'=>"DateCreation",'s.tms'=>"DateLastModification",'s.code_client'=>"CustomerCode",'s.address'=>"Address",'s.cp'=>"Zip",'s.ville'=>"Town",'p.libelle'=>"Country",'p.code'=>"CountryCode",'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_prospectlevel'=>'ProspectLevel','fk_stcomm'=>'ProspectStatus');
|
||||
$this->export_entities_array[$r]=array('u.rowid'=>"category",'u.label'=>"category",'u.description'=>"category",'s.rowid'=>'company','s.nom'=>'company','s.prefix_comm'=>"company",'s.client'=>"company",'s.datec'=>"company",'s.tms'=>"company",'s.code_client'=>"company",'s.address'=>"company",'s.cp'=>"company",'s.ville'=>"company",'p.libelle'=>"company",'p.code'=>"company",'s.tel'=>"company",'s.fax'=>"company",'s.url'=>"company",'s.email'=>"company",'s.siret'=>"company",'s.siren'=>"company",'s.ape'=>"company",'s.idprof4'=>"company",'s.tva_intra'=>"company",'s.capital'=>"company",'s.note'=>"company",'s.fk_prospectlevel'=>'company','fk_stcomm'=>'company');
|
||||
$this->export_alias_array[$r]=array('u.rowid'=>"idcateg",'u.label'=>"label",'u.description'=>"description",'s.rowid'=>'idsoc','s.nom'=>'name','s.prefix_comm'=>"prefix",'s.client'=>"iscustomer",'s.datec'=>"datecreation",'s.tms'=>"datelastmodification",'s.code_client'=>"customercode",'s.address'=>"address",'s.cp'=>"zip",'s.ville'=>"town",'p.libelle'=>"country",'p.code'=>"countrycode",'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'=>"vatintra",'s.capital'=>"capital",'s.note'=>"note",'s.fk_prospectlevel'=>'prospectlevel','fk_stcomm'=>'prospectstatus');
|
||||
$this->export_fields_array[$r]=array('u.rowid'=>"CategId",'u.label'=>"Label",'u.description'=>"Description",'s.rowid'=>'IdThirdParty','s.nom'=>'Name','s.prefix_comm'=>"Prefix",'s.client'=>"Customer",'s.datec'=>"DateCreation",'s.tms'=>"DateLastModification",'s.code_client'=>"CustomerCode",'s.address'=>"Address",'s.cp'=>"Zip",'s.ville'=>"Town",'p.libelle'=>"Country",'p.code'=>"CountryCode",'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_prospectlevel'=>'ProspectLevel','s.fk_stcomm'=>'ProspectStatus');
|
||||
$this->export_entities_array[$r]=array('s.rowid'=>'company','s.nom'=>'company','s.prefix_comm'=>"company",'s.client'=>"company",'s.datec'=>"company",'s.tms'=>"company",'s.code_client'=>"company",'s.address'=>"company",'s.cp'=>"company",'s.ville'=>"company",'p.libelle'=>"company",'p.code'=>"company",'s.tel'=>"company",'s.fax'=>"company",'s.url'=>"company",'s.email'=>"company",'s.siret'=>"company",'s.siren'=>"company",'s.ape'=>"company",'s.idprof4'=>"company",'s.tva_intra'=>"company",'s.capital'=>"company",'s.note'=>"company",'s.fk_prospectlevel'=>'company','s.fk_stcomm'=>'company'); // We define here only fields that use another picto
|
||||
$this->export_alias_array[$r]=array('u.rowid'=>"idcateg",'u.label'=>"label",'u.description'=>"description",'s.rowid'=>'idsoc','s.nom'=>'name','s.prefix_comm'=>"prefix",'s.client'=>"iscustomer",'s.datec'=>"datecreation",'s.tms'=>"datelastmodification",'s.code_client'=>"customercode",'s.address'=>"address",'s.cp'=>"zip",'s.ville'=>"town",'p.libelle'=>"country",'p.code'=>"countrycode",'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'=>"vatintra",'s.capital'=>"capital",'s.note'=>"note",'s.fk_prospectlevel'=>'prospectlevel','s.fk_stcomm'=>'prospectstatus');
|
||||
$this->export_sql_start[$r]='SELECT DISTINCT ';
|
||||
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_societe as cf, '.MAIN_DB_PREFIX.'societe as s LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_pays as p ON s.fk_pays = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code';
|
||||
$this->export_sql_end[$r] .=' WHERE u.rowid = cf.fk_categorie AND cf.fk_societe = s.rowid';
|
||||
@ -139,9 +141,10 @@ class modCategorie extends DolibarrModules
|
||||
$r++;
|
||||
$this->export_code[$r]='category_'.$r;
|
||||
$this->export_label[$r]='CatProdList';
|
||||
$this->export_icon[$r]='category';
|
||||
$this->export_permission[$r]=array(array("categorie","lire"));
|
||||
$this->export_fields_array[$r]=array('u.rowid'=>"CategId",'u.label'=>"Label",'u.description'=>"Description",'p.rowid'=>'ProductId','p.ref'=>'Ref');
|
||||
$this->export_entities_array[$r]=array('u.rowid'=>"category",'u.label'=>"category",'u.description'=>"category",'p.rowid'=>'product','p.ref'=>'product');
|
||||
$this->export_entities_array[$r]=array('p.rowid'=>'product','p.ref'=>'product'); // We define here only fields that use another picto
|
||||
$this->export_alias_array[$r]=array('u.rowid'=>"idcateg",'u.label'=>"label",'u.description'=>"description",'p.rowid'=>'idprod','p.ref'=>'ref');
|
||||
$this->export_sql_start[$r]='SELECT DISTINCT ';
|
||||
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_product as cp, '.MAIN_DB_PREFIX.'product as p';
|
||||
|
||||
@ -152,11 +152,12 @@ class modProduit extends DolibarrModules
|
||||
$r++;
|
||||
$this->import_code[$r]=$this->rights_class.'_'.$r;
|
||||
$this->import_label[$r]="Products"; // Translation key
|
||||
$this->import_icon[$r]='product';
|
||||
$this->import_tables_array[$r]=array('p'=>MAIN_DB_PREFIX.'product');
|
||||
$this->import_tables_creator_array[$r]=array('p'=>'fk_user_author'); // Fields to store import user id
|
||||
$this->import_fields_array[$r]=array('p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.note'=>"Note",'p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC",'p.tva_tx'=>'VAT','p.envente'=>"OnSell*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.duration'=>"Duration",'p.weight'=>"Weight",'p.volume'=>"Volume",'p.datec'=>'DateCreation*');
|
||||
//if ($conf->barcode->enabled) $this->import_fields_array[$r]=
|
||||
$this->import_entities_array[$r]=array('p.ref'=>"product",'p.label'=>"product",'p.description'=>"product",'p.note'=>"product",'p.price'=>"product",'p.price_ttc'=>"product",'p.tva_tx'=>'product','p.envente'=>"product",'p.fk_product_type'=>"product",'p.finished'=>"product",'p.duration'=>"product",'p.weight'=>'product','p.volume'=>'product','p.datec'=>"product");
|
||||
$this->import_entities_array[$r]=array(); // We define here only fields that use another picto
|
||||
$this->import_regex_array[$r]=array('p.ref'=>'[^ ]','p.envente'=>'^[0|1]','p.fk_product_type'=>'^[0|1]','p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
|
||||
$this->import_examplevalues_array[$r]=array('p.ref'=>"PR123456",'p.label'=>"My product",'p.description'=>"This is a description example for record",'p.note'=>"Some note",'p.price'=>"100",'p.price_ttc'=>"110",'p.tva_tx'=>'10','p.envente'=>"0 or 1",'p.fk_product_type'=>"0 for product, 1 for service",'p.finished'=>'','p.duration'=>"1y",'p.datec'=>'2008-12-31');
|
||||
}
|
||||
|
||||
@ -194,7 +194,7 @@ class modSociete extends DolibarrModules
|
||||
$this->export_icon[$r]='company';
|
||||
$this->export_permission[$r]=array(array("societe","export"));
|
||||
$this->export_fields_array[$r]=array('s.rowid'=>"Id",'s.nom'=>"Name",'s.prefix_comm'=>"Prefix",'s.client'=>"Customer",'s.fournisseur'=>"Supplier",'s.datec'=>"DateCreation",'s.tms'=>"DateLastModification",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode",'s.address'=>"Address",'s.cp'=>"Zip",'s.ville'=>"Town",'p.libelle'=>"Country",'p.code'=>"CountryCode",'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",'t.libelle'=>"ThirdPartyType",'ce.code'=>"Effectif","cfj.libelle"=>"JuridicalStatus",'s.fk_prospectlevel'=>'ProspectLevel','fk_stcomm'=>'ProspectStatus');
|
||||
$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>"company",'s.prefix_comm'=>"company",'s.client'=>"company",'s.fournisseur'=>"company",'s.datec'=>"company",'s.tms'=>"company",'s.code_client'=>"company",'s.code_fournisseur'=>"company",'s.address'=>"company",'s.cp'=>"company",'s.ville'=>"company",'p.libelle'=>"company",'p.code'=>"company",'s.tel'=>"company",'s.fax'=>"company",'s.url'=>"company",'s.email'=>"company",'s.siret'=>"company",'s.siren'=>"company",'s.ape'=>"company",'s.idprof4'=>"company",'s.tva_intra'=>"company",'s.capital'=>"company",'s.note'=>"company",'t.libelle'=>"company",'ce.code'=>"company","cfj.libelle"=>"company",'s.fk_prospectlevel'=>'company','fk_stcomm'=>'company');
|
||||
$this->export_entities_array[$r]=array(); // We define here only fields that use another picto
|
||||
$this->export_alias_array[$r]=array('s.rowid'=>"socid",'s.nom'=>"name",'s.prefix_comm'=>"prefix",'s.client'=>"iscustomer",'s.fournisseur'=>"issupplier",'s.datec'=>"datecreation",'s.tms'=>"datelastmodification",'s.code_client'=>"customercode",'s.code_fournisseur'=>"suppliercode",'s.address'=>"address",'s.cp'=>"zip",'s.ville'=>"town",'p.libelle'=>"country",'p.code'=>"countrycode",'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'=>"vatintra",'s.capital'=>"capital",'s.note'=>"note",'t.libelle'=>"thirdpartytype",'ce.code'=>"effectif","cfj.libelle"=>"juridicalstatus",'s.fk_prospectlevel'=>'prospectlevel','fk_stcomm'=>'prospectstatus');
|
||||
|
||||
$this->export_sql_start[$r]='SELECT DISTINCT ';
|
||||
@ -212,7 +212,7 @@ class modSociete extends DolibarrModules
|
||||
$this->export_icon[$r]='contact';
|
||||
$this->export_permission[$r]=array(array("societe","contact","export"));
|
||||
$this->export_fields_array[$r]=array('c.rowid'=>"IdContact",'c.civilite'=>"CivilityCode",'c.name'=>'Lastname','c.firstname'=>'Firstname','c.datec'=>"DateCreation",'c.tms'=>"DateLastModification",'c.priv'=>"ContactPrivate",'c.address'=>"Address",'c.cp'=>"Zip",'c.ville'=>"Town",'c.phone'=>"Phone",'c.fax'=>"Fax",'c.email'=>"EMail",'p.libelle'=>"Country",'p.code'=>"CountryCode",'s.rowid'=>"IdCompany",'s.nom'=>"CompanyName",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode");
|
||||
$this->export_entities_array[$r]=array('c.rowid'=>"contact",'c.civilite'=>"contact",'c.name'=>'contact','c.firstname'=>'contact','c.datec'=>"contact",'c.tms'=>"contact",'c.priv'=>"contact",'c.address'=>"contact",'c.cp'=>"contact",'c.ville'=>"contact",'c.phone'=>"contact",'c.fax'=>"contact",'c.email'=>"contact",'p.libelle'=>"contact",'p.code'=>"contact",'s.rowid'=>"company",'s.nom'=>"company",'s.code_client'=>"company",'s.code_fournisseur'=>"company");
|
||||
$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>"company",'s.code_client'=>"company",'s.code_fournisseur'=>"company"); // We define here only fields that use another picto
|
||||
$this->export_alias_array[$r]=array('c.rowid'=>"contactid",'c.civilite'=>"civilitycode",'c.name'=>'lastname','c.firstname'=>'firstname','c.datec'=>"datecreation",'c.tms'=>"datelastmodification",'c.priv'=>"private",'c.address'=>"address",'c.cp'=>"zip",'c.ville'=>"town",'c.phone'=>"phone",'c.fax'=>"fax",'c.email'=>"email",'p.libelle'=>"country",'p.code'=>"countrycode",'s.rowid'=>"socid",'s.nom'=>"companyname",'s.code_client'=>"customercode",'s.code_fournisseur'=>"suppliercode");
|
||||
|
||||
$this->export_sql_start[$r]='SELECT DISTINCT ';
|
||||
@ -232,14 +232,24 @@ class modSociete extends DolibarrModules
|
||||
$this->import_label[$r]='ImportDataset_company_1';
|
||||
$this->import_icon[$r]='company';
|
||||
//$this->import_permission[$r]=array(array("societe","export"));
|
||||
$this->import_tables_array[$r]=array('s'=>MAIN_DB_PREFIX.'societe');
|
||||
$this->import_tables_array[$r]=array('s'=>MAIN_DB_PREFIX.'societe'); // List of tables to insert into (insert done in same order)
|
||||
$this->import_fields_array[$r]=array('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_entities_array[$r]=array('s.nom'=>"company",'s.prefix_comm'=>"company",'s.client'=>"company",'s.fournisseur'=>"company",'s.datec'=>"company",'s.code_client'=>"company",'s.code_fournisseur'=>"company",'s.address'=>"company",'s.cp'=>"company",'s.ville'=>"company",'s.tel'=>"company",'s.fax'=>"company",'s.url'=>"company",'s.email'=>"company",'s.siret'=>"company",'s.siren'=>"company",'s.ape'=>"company",'s.idprof4'=>"company",'s.tva_intra'=>"company",'s.capital'=>"company",'s.note'=>"company",'s.fk_typent'=>"company",'s.fk_effectif'=>"company","s.fk_forme_juridique"=>"company",'s.fk_prospectlevel'=>'company','s.fk_stcomm'=>'company');
|
||||
$this->import_entities_array[$r]=array(); // We define here only fields that use another picto
|
||||
$this->import_examplevalues_array[$r]=array('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_sql_start[$r]='INSERT INTO '.MAIN_DB_PREFIX.'societe as s';
|
||||
//$this->import_sql_end[$r] ='';
|
||||
|
||||
// Import list of contact and attributes
|
||||
/* $r++;
|
||||
$this->import_code[$r]=$this->rights_class.'_'.$r;
|
||||
$this->import_label[$r]='ImportDataset_company_2';
|
||||
$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_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');
|
||||
// If value for some fields need to be found differently than directly in file, we declare rules to find it (might be class and function to find id or might be a lastinsert id).
|
||||
$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('class'=>'Societe','method'=>'fetch'));
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user