From 8d8325fe955841a24d058aa64c42161953d87671 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Oct 2009 11:48:20 +0000 Subject: [PATCH] Work on import module --- htdocs/imports/import.class.php | 8 +++++--- htdocs/imports/import.php | 4 +++- htdocs/includes/modules/modProduit.class.php | 1 + htdocs/includes/modules/modSociete.class.php | 1 + 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/imports/import.class.php b/htdocs/imports/import.class.php index d907e267a31..2337c44dcd5 100644 --- a/htdocs/imports/import.class.php +++ b/htdocs/imports/import.class.php @@ -26,12 +26,12 @@ /** * \class Import - * \brief Classe permettant la gestion des imports + * \brief Class to manage imports */ class Import { /** - * \brief Constructeur de la classe + * \brief Constructor * \param DB Database handler */ function Import($DB) @@ -126,7 +126,9 @@ class Import $this->array_import_code[$i]=$module->import_code[$r]; // Libelle du dataset export $this->array_import_label[$i]=$module->getDatasetLabel($r); - // Tableau des champ a exporter (cle=champ, valeur=libelle) + // Array of tables to import (key=alias, value=tablename) + $this->array_import_tables[$i]=$module->import_tables_array[$r]; + // Array of fiels to import (key=field, value=label) $this->array_import_fields[$i]=$module->import_fields_array[$r]; // Tableau des entites a exporter (cle=champ, valeur=entite) $this->array_import_entities[$i]=$module->import_entities_array[$r]; diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 6da18d36fe1..22886a0a4b3 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -717,6 +717,8 @@ if ($step == 4 && $datatoimport) $i++; $entity=$objimport->array_import_entities[0][$code]; + $tablealias=eregi_replace('\..*$','',$code); + $tablename=$objimport->array_import_tables[0][$tablealias]; $entityicon=$entitytoicon[$entity]?$entitytoicon[$entity]:$entity; $entitylang=$entitytolang[$entity]?$entitytolang[$entity]:$entity; @@ -724,7 +726,7 @@ if ($step == 4 && $datatoimport) print ''; $text=$langs->trans($label); if (eregi('\*$',$label)) $text=''.$text.''; - $htmltext=$langs->trans("Table").": ?
".$langs->trans("Field").': '.$code; + $htmltext=$langs->trans("Table").": ".$tablename."
".$langs->trans("Field").': '.$code; print $html->textwithpicto($text,$htmltext); print ''; diff --git a/htdocs/includes/modules/modProduit.class.php b/htdocs/includes/modules/modProduit.class.php index 119faa13c6d..24c4fe6fe5e 100644 --- a/htdocs/includes/modules/modProduit.class.php +++ b/htdocs/includes/modules/modProduit.class.php @@ -153,6 +153,7 @@ class modProduit extends DolibarrModules $this->import_code[$r]=$this->rights_class.'_'.$r; $this->import_label[$r]="Products"; // Translation key //$this->import_permission[$r]=array(array("societe","import")); + $this->import_tables_array[$r]=array('p'=>MAIN_DB_PREFIX.'produit'); $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.duration'=>"Duration"); $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.duration'=>"product"); $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.duration'=>"1y"); diff --git a/htdocs/includes/modules/modSociete.class.php b/htdocs/includes/modules/modSociete.class.php index 58e2968ed6a..2b8f4a0ba6f 100644 --- a/htdocs/includes/modules/modSociete.class.php +++ b/htdocs/includes/modules/modSociete.class.php @@ -232,6 +232,7 @@ 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('p'=>MAIN_DB_PREFIX.'societe'); $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",'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_type'=>"ThirdPartyType",'s.fk_effectif'=>"Effectif","s.fk_status"=>"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",'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_type'=>"company",'s.fk_effectif'=>"company","s.fk_status"=>"company",'s.fk_prospectlevel'=>'company','s.fk_stcomm'=>'company'); $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",'p.code'=>"US",'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_type'=>"XXX",'s.fk_effectif'=>"YYY","s.fk_status"=>"ZZZ",'s.fk_prospectlevel'=>'AAA','s.fk_stcomm'=>'BBB');