diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index c47343df638eb690c81c4c0b0e59fbe055c530df..6ddd135c9593f7581df1b9a987c9aae3753210c0 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -169,6 +169,40 @@ class modProduct extends DolibarrModules if (! empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc'; $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity("product", 1).')'; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + // multiline format, you need one line per translated product + $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('l.lang'=>'language', 'l.label'=>'translated_label','l.description'=>'translated_description','l.note'=>'translated_note')); + $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('l.lang'=>'Text', 'l.label'=>'Text','l.description'=>'Text','l.note'=>'Text')); + $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('l.lang'=>'translation', 'l.label'=>'translation','l.description'=>'translation','l.note'=>'translation')); + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid'; + + // single line format, just use one column per translation + $sql="SELECT lang FROM ".MAIN_DB_PREFIX."product_lang GROUP BY lang"; + $langs = array(); + $resql=$this->db->query($sql); + if ($resql) { + while ($obj=$this->db->fetch_object($resql)) { + // list all language, you need at least one translation available to detect the language + $name = $obj->lang; + array_push($langs, $name); + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."product_lang as $name ON $name.fk_product = p.rowid AND $name.lang='$name'"; + // translate the label + $this->export_fields_array[$r][$name.".label"]=$name."_label"; + $this->export_TypeFields_array[$r][$name.".label"]='Text'; + $this->export_entities_array[$r][$name.".label"]='translation'; + // translate the description + $this->export_fields_array[$r][$name.".description"]=$name."_description"; + $this->export_TypeFields_array[$r][$name.".description"]='Text'; + $this->export_entities_array[$r][$name.".description"]='translation'; + // translate the note + $this->export_fields_array[$r][$name.".note"]=$name."_note"; + $this->export_TypeFields_array[$r][$name.".note"]='Text'; + $this->export_entities_array[$r][$name.".note"]='translation'; + } + } + } + if (! empty($conf->global->PRODUIT_MULTIPRICES)) { // Exports product multiprice @@ -189,7 +223,7 @@ class modProduct extends DolibarrModules 'pr.price_ttc'=>"product", 'pr.price_min'=>"product",'pr.price_min_ttc'=>"product", 'pr.tva_tx'=>'product', - 'pr.recuperableonly'=>'product', + 'pr.recuperableonly'=>'product', 'pr.date_price'=>"product"); $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; @@ -291,6 +325,26 @@ class modProduct extends DolibarrModules 'pr.date_price'=>'2013-04-10'); } + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $this->import_tables_array[$r]['l']=MAIN_DB_PREFIX.'product_lang'; + // multiline translation, one line per translation + $this->import_fields_array[$r]['l.lang']='language'; + $this->import_fields_array[$r]['l.label']='translated_label'; + $this->import_fields_array[$r]['l.description']='translated_description'; + $this->import_fields_array[$r]['l.note']='translated_note'; + $this->import_examplevalues_array[$r]['l.lang']='en_US'; + + // single line translation, one column per translation + foreach($langs as $l) { + $this->import_tables_array[$r][$l] = MAIN_DB_PREFIX.'product_lang'; + $this->import_fields_array[$r][$l.'.label']=$l.'_label'; + $this->import_fields_array[$r][$l.'.description']=$l.'_description'; + $this->import_fields_array[$r][$l.'.note']=$l.'_note'; + $this->import_fieldshidden_array[$r][$l.'.lang']="'$l'"; + $this->import_fieldshidden_array[$r][$l.'.fk_product']='lastrowid-'.MAIN_DB_PREFIX.'product'; + } + } } diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql index 7cd50efc72dee9ee8cc40d439d70970753b88ec6..1592ca69c63dc22d50f9aedc906e67ec5a1a3c5e 100644 --- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql +++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql @@ -250,6 +250,7 @@ ALTER TABLE llx_propaldet ADD COLUMN multicurrency_total_ht double(24,8) DEFAULT ALTER TABLE llx_propaldet ADD COLUMN multicurrency_total_tva double(24,8) DEFAULT 0; ALTER TABLE llx_propaldet ADD COLUMN multicurrency_total_ttc double(24,8) DEFAULT 0; +<<<<<<< HEAD -- Add for recurring template invoices @@ -302,3 +303,5 @@ ALTER TABLE llx_supplier_proposaldet ADD COLUMN multicurrency_subprice double(24 ALTER TABLE llx_supplier_proposaldet ADD COLUMN multicurrency_total_ht double(24,8) DEFAULT 0; ALTER TABLE llx_supplier_proposaldet ADD COLUMN multicurrency_total_tva double(24,8) DEFAULT 0; ALTER TABLE llx_supplier_proposaldet ADD COLUMN multicurrency_total_ttc double(24,8) DEFAULT 0; + +ALTER TABLE llx_product_lang ADD COLUMN import_key varchar(14) DEFAULT NULL; diff --git a/htdocs/install/mysql/tables/llx_product_lang.sql b/htdocs/install/mysql/tables/llx_product_lang.sql index 8b4371c83b775c7719ae779ee6e36aabbd099667..7363a65a95ca67b9a262488cb8661ae2dad46176 100644 --- a/htdocs/install/mysql/tables/llx_product_lang.sql +++ b/htdocs/install/mysql/tables/llx_product_lang.sql @@ -25,5 +25,6 @@ create table llx_product_lang lang varchar(5) DEFAULT 0 NOT NULL, label varchar(255) NOT NULL, description text, - note text + note text, + import_key varchar(14) DEFAULT NULL )ENGINE=innodb;