From a69b2a94374f59ab8edfa6b575184521fc309f9e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@users.sourceforge.net> Date: Thu, 30 Sep 2010 19:25:58 +0000 Subject: [PATCH] New: Can import members with assistant --- htdocs/exports/class/export.class.php | 2 +- htdocs/imports/class/import.class.php | 8 ++--- .../modules/DolibarrModules.class.php | 34 +++++++++++++++---- htdocs/includes/modules/modAdherent.class.php | 15 ++++++++ htdocs/includes/modules/modProduct.class.php | 2 +- htdocs/langs/en_US/members.lang | 1 + htdocs/langs/en_US/products.lang | 2 ++ htdocs/langs/fr_FR/companies.lang | 1 + htdocs/langs/fr_FR/members.lang | 1 + htdocs/langs/fr_FR/products.lang | 2 ++ 10 files changed, 56 insertions(+), 12 deletions(-) diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index d1cc1ed4d9f..1d2b1b1df02 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -143,7 +143,7 @@ class Export // Code du dataset export $this->array_export_code[$i]=$module->export_code[$r]; // Libelle du dataset export - $this->array_export_label[$i]=$module->getDatasetLabel($r); + $this->array_export_label[$i]=$module->getExportDatasetLabel($r); // Tableau des champ a exporter (cle=champ, valeur=libelle) $this->array_export_fields[$i]=$module->export_fields_array[$r]; // Tableau des entites a exporter (cle=champ, valeur=entite) diff --git a/htdocs/imports/class/import.class.php b/htdocs/imports/class/import.class.php index 20b8d2ce176..cd828131738 100644 --- a/htdocs/imports/class/import.class.php +++ b/htdocs/imports/class/import.class.php @@ -53,9 +53,9 @@ class Import /** - * \brief Load description of an importable dataset - * \param user Object user making import - * \param filter Load a particular dataset only + * Load description of an importable dataset + * @param user Object user making import + * @param filter Load a particular dataset only */ function load_arrays($user,$filter='') { @@ -137,7 +137,7 @@ class Import // Code du dataset export $this->array_import_code[$i]=$module->import_code[$r]; // Libelle du dataset export - $this->array_import_label[$i]=$module->getDatasetLabel($r); + $this->array_import_label[$i]=$module->getImportDatasetLabel($r); // Array of tables to import (key=alias, value=tablename) $this->array_import_tables[$i]=$module->import_tables_array[$r]; // Array of tables creator field to import (key=alias, value=creator field) diff --git a/htdocs/includes/modules/DolibarrModules.class.php b/htdocs/includes/modules/DolibarrModules.class.php index 3571186603b..fb594b29066 100644 --- a/htdocs/includes/modules/DolibarrModules.class.php +++ b/htdocs/includes/modules/DolibarrModules.class.php @@ -303,8 +303,8 @@ class DolibarrModules /** - * \brief Retourne la liste des fichiers lang en rapport avec le module - * \return array Tableau des fichier lang + * Return list of lang files related to module + * @return array Array of lang files */ function getLangFilesArray() { @@ -312,10 +312,10 @@ class DolibarrModules } /** - * \brief Retourne le libelle d'un lot de donnees exportable - * \return string Libelle du lot de donnees + * Return translated label of a export dataset + * @return string Label of databaset */ - function getDatasetLabel($r) + function getExportDatasetLabel($r) { global $langs; @@ -333,7 +333,29 @@ class DolibarrModules } - /** + /** + * Return translated label of an import dataset + * @return string Label of databaset + */ + function getImportDatasetLabel($r) + { + global $langs; + + $langstring="ImportDataset_".$this->import_code[$r]; + //print "x".$langstring; + if ($langs->trans($langstring) == $langstring) + { + // Traduction non trouvee + return $langs->trans($this->import_label[$r]); + } + else + { + // Traduction trouvee + return $langs->trans($langstring); + } + } + + /** * \brief Insert line in dolibarr_modules table. * \return int Nb of errors (0 if OK) * \remarks Storage is made for information only, table is not required for Dolibarr usage. diff --git a/htdocs/includes/modules/modAdherent.class.php b/htdocs/includes/modules/modAdherent.class.php index 07a6b5a36f0..6e64499301b 100644 --- a/htdocs/includes/modules/modAdherent.class.php +++ b/htdocs/includes/modules/modAdherent.class.php @@ -204,6 +204,21 @@ class modAdherent extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'adherent_options as ao ON a.rowid = ao.fk_member'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'cotisation as c ON c.fk_adherent = a.rowid'; $this->export_sql_end[$r] .=' WHERE a.fk_adherent_type = ta.rowid'; + + // Imports + //-------- + $r=0; + + $r++; + $this->import_code[$r]=$this->rights_class.'_'.$r; + $this->import_label[$r]="Members"; // Translation key + $this->import_icon[$r]=$this->picto; + $this->import_tables_array[$r]=array('a'=>MAIN_DB_PREFIX.'adherent'); + $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'=>"Civility",'a.nom'=>"Lastname*",'a.prenom'=>"Firstname",'a.login'=>"Login*","a.pass"=>"Password","a.fk_adherent_type"=>"MemberType*",'a.morphy'=>'MorPhy*','a.societe'=>'Company','a.adresse'=>"Address",'a.cp'=>"Zip",'a.ville'=>"Town",'a.pays'=>"Country",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.naiss'=>"Birthday",'a.statut'=>"Status*",'a.photo'=>"Photo",'a.note'=>"Note",'a.datec'=>'DateCreation'); + $this->import_entities_array[$r]=array(); // We define here only fields that use another picto + $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]$'); + $this->import_examplevalues_array[$r]=array('a.civilite'=>"MR",'a.nom'=>'Smith','a.prenom'=>'John','a.login'=>'jsmith','a.pass'=>'passofjsmith','a.fk_adherent_type'=>'1','a.morphy'=>'"mor" or "phy"','a.societe'=>'JS company','a.adresse'=>'21 jump street','a.cp'=>'55000','a.ville'=>'New York','a.pays'=>'US','a.email'=>'jsmith@example.com','a.naiss'=>'1972-10-10','a.statut'=>"0 or 1",'a.note'=>"This is a comment on member",'a.datec'=>'2008-12-31'); } diff --git a/htdocs/includes/modules/modProduct.class.php b/htdocs/includes/modules/modProduct.class.php index e793e43eb61..02cc139cc25 100644 --- a/htdocs/includes/modules/modProduct.class.php +++ b/htdocs/includes/modules/modProduct.class.php @@ -162,7 +162,7 @@ class modProduct 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_icon[$r]=$this->picto; $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.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.duration'=>"Duration",'p.weight'=>"Weight",'p.volume'=>"Volume",'p.datec'=>'DateCreation*'); diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 940a15467b9..7b85de1e8f0 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -113,6 +113,7 @@ PublicMemberList=Public member list BlankSubscriptionForm=Subscription form MemberPublicLinks=Public links/pages ExportDataset_member_1=Members and subscriptions +ImportDataset_member_1=Members LastMembers=Last %s members LastMembersModified=Last %s modified members AttributeName=Attribute name diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 8544781dc84..3c9ba5910a8 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -131,6 +131,8 @@ DeletePicture=Delete a picture ConfirmDeletePicture=Are you sure you want to delete this picture ? ExportDataset_produit_1=Products ExportDataset_service_1=Services +ImportDataset_produit_1=Products +ImportDataset_service_1=Services DeleteProductLine=Delete product line ConfirmDeleteProductLine=Are you sure you want to delete this product line? NoProductMatching=No product/service match your criteria diff --git a/htdocs/langs/fr_FR/companies.lang b/htdocs/langs/fr_FR/companies.lang index 41b29003097..3d68c584168 100644 --- a/htdocs/langs/fr_FR/companies.lang +++ b/htdocs/langs/fr_FR/companies.lang @@ -273,6 +273,7 @@ DolibarrLogin=Login Dolibarr NoDolibarrAccess=Pas d'accès Dolibarr ExportDataset_company_1=Tiers (sociétés/institutions) et attributs ExportDataset_company_2=Contacts (de tiers) et attributs +ImportDataset_company_1=Tiers (sociétés/institutions) et attributs PriceLevel=Niveau de prix DeliveriesAddress=Adresse(s) de livraison DeliveryAddress=Adresse de livraison diff --git a/htdocs/langs/fr_FR/members.lang b/htdocs/langs/fr_FR/members.lang index 10cf7b72898..3184c9da197 100644 --- a/htdocs/langs/fr_FR/members.lang +++ b/htdocs/langs/fr_FR/members.lang @@ -113,6 +113,7 @@ PublicMemberList=Liste des membres publics BlankSubscriptionForm=Formulaire inscription MemberPublicLinks=Liens/pages publiques ExportDataset_member_1=Adhérents et adhésions +ImportDataset_member_1=Adhérents LastMembers=Les %s derniers adhérents LastMembersModified=Les %s derniers adhérents modifiés AttributeName=Nom de l'attribut diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index 983bf64c9c2..d0584f9a283 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -131,6 +131,8 @@ DeletePicture=Supprimer une photo ConfirmDeletePicture=Êtes-vous sûr de vouloir supprimer cette photo ? ExportDataset_produit_1=Produits ExportDataset_service_1=Services +ImportDataset_produit_1=Produits +ImportDataset_service_1=Services DeleteProductLine=Supprimer ligne produit ConfirmDeleteProductLine=Êtes-vous sûr de vouloir effacer cette ligne produit ? NoProductMatching=Aucun produit/service ne répond au critère -- GitLab