From d4df585e3c00427b125e320dc307bb107180ce3f Mon Sep 17 00:00:00 2001 From: simnandez Date: Fri, 26 Oct 2012 18:34:49 +0200 Subject: [PATCH] New: More import options. Customer and suppliers categories --- htdocs/core/modules/modCategorie.class.php | 70 ++++++++++--------- .../install/mysql/migration/3.2.0-3.3.0.sql | 2 + .../tables/llx_categorie_fournisseur.sql | 4 +- .../mysql/tables/llx_categorie_societe.sql | 4 +- 4 files changed, 46 insertions(+), 34 deletions(-) diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index 4cdc10e2357..67f10c599d4 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -197,38 +197,44 @@ class modCategorie extends DolibarrModules ); $this->import_examplevalues_array[$r]=array('cp.fk_categorie'=>"Imported category",'cp.fk_product'=>"PREF123456"); } - - //Customers - $r++; - $this->import_code[$r]=$this->rights_class.'_'.$r; - $this->import_label[$r]="Clientes por categoría"; // Translation key - $this->import_icon[$r]=$this->picto; - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r]=array('co'=>MAIN_DB_PREFIX.'categorie_societe'); - $this->import_fields_array[$r]=array('co.fk_categorie'=>"Categorie*",'co.fk_societe'=>"Tercero*" - ); - - $this->import_convertvalue_array[$r]=array( - 'co.fk_categorie'=>array('rule'=>'fetchidfromref','classfile'=>'/categories/class/categorie.class.php','class'=>'Categorie','method'=>'fetch','element'=>'category'), - 'co.fk_societe'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty') - ); - $this->import_examplevalues_array[$r]=array('co.fk_categorie'=>"Nombre categoría",'co.fk_societe'=>"Nombre cliente"); - - // Suppliers - $r++; - $this->import_code[$r]=$this->rights_class.'_'.$r; - $this->import_label[$r]="Proveedores por categoría"; // Translation key - $this->import_icon[$r]=$this->picto; - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r]=array('co'=>MAIN_DB_PREFIX.'categorie_fournisseur'); - $this->import_fields_array[$r]=array('co.fk_categorie'=>"Categorie*",'co.fk_societe'=>"Tercero*" - ); - - $this->import_convertvalue_array[$r]=array( - 'co.fk_categorie'=>array('rule'=>'fetchidfromref','classfile'=>'/categories/class/categorie.class.php','class'=>'Categorie','method'=>'fetch','element'=>'category'), - 'co.fk_societe'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty') - ); - $this->import_examplevalues_array[$r]=array('co.fk_categorie'=>"Nombre categoria",'co.fk_societe'=>"Nombre proveedor"); + + if (! empty($conf->societe->enabled)) + { + //Customers + $r++; + $this->import_code[$r]=$this->rights_class.'_'.$r; + $this->import_label[$r]="CatCusList"; // Translation key + $this->import_icon[$r]=$this->picto; + $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r]=array('cs'=>MAIN_DB_PREFIX.'categorie_societe'); + $this->import_fields_array[$r]=array('cs.fk_categorie'=>"Categorie*",'cs.fk_societe'=>"ThirdParty*" + ); + + $this->import_convertvalue_array[$r]=array( + 'cs.fk_categorie'=>array('rule'=>'fetchidfromref','classfile'=>'/categories/class/categorie.class.php','class'=>'Categorie','method'=>'fetch','element'=>'category'), + 'cs.fk_societe'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty') + ); + $this->import_examplevalues_array[$r]=array('cs.fk_categorie'=>"Imported category",'cs.fk_societe'=>"MyBigCompany"); + } + + if (! empty($conf->fournisseur->enabled)) + { + // Suppliers + $r++; + $this->import_code[$r]=$this->rights_class.'_'.$r; + $this->import_label[$r]="CatSupList"; // Translation key + $this->import_icon[$r]=$this->picto; + $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r]=array('cs'=>MAIN_DB_PREFIX.'categorie_fournisseur'); + $this->import_fields_array[$r]=array('cs.fk_categorie'=>"Categorie*",'co.fk_societe'=>"Supplier*" + ); + + $this->import_convertvalue_array[$r]=array( + 'cs.fk_categorie'=>array('rule'=>'fetchidfromref','classfile'=>'/categories/class/categorie.class.php','class'=>'Categorie','method'=>'fetch','element'=>'category'), + 'cs.fk_societe'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty') + ); + $this->import_examplevalues_array[$r]=array('cs.fk_categorie'=>"Imported category",'cs.fk_societe'=>"MyBigCompany"); + } } diff --git a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql index d9dd806d397..16b325b5376 100755 --- a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql +++ b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql @@ -773,6 +773,8 @@ ALTER TABLE llx_product_fournisseur_price ADD COLUMN import_key varchar(14) AFTE ALTER TABLE llx_product_stock ADD COLUMN import_key varchar(14) AFTER pmp; ALTER TABLE llx_societe_rib ADD COLUMN import_key varchar(14) AFTER adresse_proprio; ALTER TABLE llx_categorie_product ADD COLUMN import_key varchar(14) AFTER fk_product; +ALTER TABLE llx_categorie_societe ADD COLUMN import_key varchar(14) AFTER fk_societe; +ALTER TABLE llx_categorie_fournisseur ADD COLUMN import_key varchar(14) AFTER fk_societe; -- Export filter ALTER TABLE llx_export_model ADD COLUMN filter text AFTER field; diff --git a/htdocs/install/mysql/tables/llx_categorie_fournisseur.sql b/htdocs/install/mysql/tables/llx_categorie_fournisseur.sql index 535972686c2..36b1e7ab37b 100644 --- a/htdocs/install/mysql/tables/llx_categorie_fournisseur.sql +++ b/htdocs/install/mysql/tables/llx_categorie_fournisseur.sql @@ -2,6 +2,7 @@ -- Copyright (C) 2006 Rodolphe Quiedeville -- Copyright (C) 2012 Laurent Destailleur -- Copyright (C) 2012 Regis Houssin +-- Copyright (C) 2012 Juanjo Menent -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -21,5 +22,6 @@ create table llx_categorie_fournisseur ( fk_categorie integer NOT NULL, - fk_societe integer NOT NULL + fk_societe integer NOT NUL, + import_key varchar(14) )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_categorie_societe.sql b/htdocs/install/mysql/tables/llx_categorie_societe.sql index 1e9da3f158e..46d5a51ea06 100644 --- a/htdocs/install/mysql/tables/llx_categorie_societe.sql +++ b/htdocs/install/mysql/tables/llx_categorie_societe.sql @@ -1,5 +1,6 @@ -- ============================================================================ -- Copyright (C) 2007 Patrick Raguin +-- Copyright (C) 2012 Juanjo Menent -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -19,5 +20,6 @@ create table llx_categorie_societe ( fk_categorie integer NOT NULL, - fk_societe integer NOT NULL + fk_societe integer NOT NULL, + import_key varchar(14) )ENGINE=innodb;