diff --git a/htdocs/admin/produit.php b/htdocs/admin/produit.php index 91fe4999e30..567bece856e 100644 --- a/htdocs/admin/produit.php +++ b/htdocs/admin/produit.php @@ -134,6 +134,20 @@ else if ($_GET["action"] == 'disable_sousproduits') exit; } +// Multilangs +if ($_GET['action'] == 'enable_multilangs') +{ + dolibarr_set_const($db, "PRODUIT_MULTILANGS", "1"); + Header("Location: produit.php"); + +} +else if ($_GET['action'] == 'disable_multilangs') +{ + dolibarr_del_const($db, "PRODUIT_MULTILANGS"); + Header("Location: produit.php"); + exit; +} + /* * Affiche page @@ -237,6 +251,29 @@ print ''; print ''; print ''; +// multilangs activation/desactivation +print '
'; +print ''; +print ''; +print ''; +print ''; +print ''; +print "\n"; +print ""; +print ''; +print ''; +print ""; +print ''; +print '
'.$langs->trans("Name").' '.$langs->trans("Active").'
'.$langs->trans("MultilangsAbility").''; +if($conf->global->PRODUIT_MULTILANGS == 1) + print img_tick(); +print '"; +if($conf->global->PRODUIT_MULTILANGS == 0) +print ''.$langs->trans("Activate").''; +else if($conf->global->PRODUIT_MULTILANGS == 1) + print ''.$langs->trans("Disable").''; +print "
'; + $db->close(); diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 11b70d818ac..268d24ae2fd 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -594,6 +594,20 @@ class Form if ($limit) $sql.= " LIMIT $limit"; $result=$this->db->query($sql); + + // Multilang : on construit une liste des traductions des produits listés + $sqld = "SELECT d.fk_product, d.label"; + $sqld.= " FROM ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."product_det as d "; + $sqld.= " WHERE d.fk_product=p.rowid AND p.envente=1 AND d.lang='". $langs->getDefaultLang() ."'"; + $sqld.= " ORDER BY p.nbvente DESC"; + + // inutile de faire la requete si l'option n'est pas active + if ($conf->global->PRODUIT_MULTILANGS == 1) + { + $resultd = $this->db->query($sqld); + if ( $resultd ) $objtp = $this->db->fetch_object($resultd); + } + if ($result) { print '"; - print ''; + // Gestion multilingue + if($conf->global->PRODUIT_MULTILANGS == 1) + { + print ''; + print ''; + + $langs_available=$langs->get_available_languages(); + $current_lang = $langs->getDefaultLang(); + foreach ($langs_available as $value) + if ( $value != $current_lang ) + { + print ''; + print ''; + print ''; + print ''; + } + } + + print ''; print '
'.$langs->trans("language").'
'.$value.''.$langs->trans("Label").'
'.$langs->trans("Description").'
'.$langs->trans("Note").'
'; print ''; } @@ -593,6 +660,23 @@ if ($_GET["id"] || $_GET["ref"]) // Note print ''.$langs->trans("Note").''.nl2br($product->note).''; + // Multilangs + if ($conf->global->PRODUIT_MULTILANGS == 1) + { + print "\n"; + print ''; + $langs_available=$langs->get_available_languages(); + $current_lang = $langs->getDefaultLang(); + foreach ($langs_available as $value) + if ( $value != $current_lang ) + { + print ''; + print ''; + print ''; + print ''; + } + } + print "
'.$value.''.$langs->trans("Label").''.$product->multilangs[$value]['libelle'].'
'.$langs->trans("Description").''.$product->multilangs[$value]['description'].'
'.$langs->trans("Note").''.$product->multilangs[$value]['note'].'
\n"; print "\n"; @@ -672,6 +756,24 @@ if ($_GET["id"] || $_GET["ref"]) print '"; + + // Gestion multilingue + if($conf->global->PRODUIT_MULTILANGS == 1) + { + print ''; + print ''; + + $langs_available=$langs->get_available_languages(); + $current_lang = $langs->getDefaultLang(); + foreach ($langs_available as $value) + if ( $value != $current_lang ) + { + print ''; + print ''; + print ''; + print ''; + } + } print ''; diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 1fd443286bf..15026d64ef3 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -138,6 +138,20 @@ if ($result) while ($i < $num) { $objp = $db->fetch_object($result); + + //Multilangs + if ($conf->global->PRODUIT_MULTILANGS == 1) + { + $sql = "SELECT label FROM ".MAIN_DB_PREFIX."product_det"; + $sql.= " WHERE fk_product=".$objp->rowid." AND lang='". $langs->getDefaultLang() ."'"; + $resultd = $db->query($sql); + if ($resultd) + { + $objtp = $db->fetch_object($resultd); + if ($objtp->label != '') $objp->label = $objtp->label; + } + } + $var=!$var; print ""; print '"; print '"; //print ''; diff --git a/mysql/migration/2.0.0-2.1.0.sql b/mysql/migration/2.0.0-2.1.0.sql index aee61f973dc..32cbcb2fddd 100644 --- a/mysql/migration/2.0.0-2.1.0.sql +++ b/mysql/migration/2.0.0-2.1.0.sql @@ -66,4 +66,14 @@ create table llx_expedition_model_pdf nom varchar(50) PRIMARY KEY, libelle varchar(255), description text +)type=innodb; + +create table llx_product_det +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_product integer DEFAULT 0 NOT NULL, + fk_lang integer DEFAULT 0 NOT NULL, + label varchar(128), + description varchar(255), + note text )type=innodb; \ No newline at end of file diff --git a/mysql/tables/llx_product_det.sql b/mysql/tables/llx_product_det.sql new file mode 100644 index 00000000000..c97e640c779 --- /dev/null +++ b/mysql/tables/llx_product_det.sql @@ -0,0 +1,31 @@ +-- ============================================================================ +-- Copyright (C) 2002-2003 Rodolphe Quiedeville +-- +-- 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 +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +-- +-- $Id$ +-- $Source$ +-- +-- ============================================================================ + +create table llx_product_det +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_product integer DEFAULT 0 NOT NULL, + fk_lang integer DEFAULT 0 NOT NULL, + label varchar(128), + description varchar(255), + note text +)type=innodb;
'.$langs->trans("language").'
'.$value.''.$langs->trans("Label").'
'.$langs->trans("Description").'
'.$langs->trans("Note").'
 '; print '
'; diff --git a/htdocs/product/liste.php b/htdocs/product/liste.php index 9622c5dcea4..e3d8e9a4ae4 100644 --- a/htdocs/product/liste.php +++ b/htdocs/product/liste.php @@ -75,9 +75,9 @@ if (isset($_REQUEST['catid'])) $title=$langs->trans("ProductsAndServices"); -$sql = 'SELECT p.rowid, p.ref, p.label, p.price, p.fk_product_type, '.$db->pdate('p.tms').' as datem,'; +$sql = 'SELECT distinct(p.rowid), p.ref, p.label, p.price, p.fk_product_type, '.$db->pdate('p.tms').' as datem,'; $sql.= ' p.duration, p.envente as statut'; -$sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; +$sql.= ' FROM '.MAIN_DB_PREFIX.'product as p, '.MAIN_DB_PREFIX.'product_det as d'; if ($catid) { @@ -223,6 +223,21 @@ if ($resql) while ($i < min($num,$limit)) { $objp = $db->fetch_object($resql); + + // Multilangs + if ($conf->global->PRODUIT_MULTILANGS == 1) // si l'option est active + { + $sql = "SELECT label FROM ".MAIN_DB_PREFIX."product_det"; + $sql.= " WHERE fk_product=".$objp->rowid." AND lang='". $langs->getDefaultLang() ."'"; + $sql.= " LIMIT 1"; + $result = $db->query($sql); + if ($result) + { + $objtp = $db->fetch_object($result); + if ($objtp->label != '') $objp->label = $objtp->label; + } + } + $var=!$var; print "
"; print "rowid\">"; diff --git a/htdocs/product/popuprop.php b/htdocs/product/popuprop.php index 92d6a229f3c..f04e1b21b5f 100644 --- a/htdocs/product/popuprop.php +++ b/htdocs/product/popuprop.php @@ -83,6 +83,21 @@ if ($result) while ($i < $num) { $objp = $db->fetch_object($result); + + // Multilangs + if ($conf->global->PRODUIT_MULTILANGS == 1) // si l'option est active + { + $sql = "SELECT label FROM ".MAIN_DB_PREFIX."product_det"; + $sql.= " WHERE fk_product=".$objp->rowid." AND lang='". $langs->getDefaultLang() ."'"; + $sql.= " LIMIT 1"; + $result = $db->query($sql); + if ($result) + { + $objtp = $db->fetch_object($result); + if ($objtp->label != '') $objp->label = $objtp->label; + } + } + $var=!$var; print "
'; diff --git a/htdocs/product/stock/fiche.php b/htdocs/product/stock/fiche.php index 7c55aff8b04..a7f3135c2c8 100644 --- a/htdocs/product/stock/fiche.php +++ b/htdocs/product/stock/fiche.php @@ -288,6 +288,22 @@ else while ($i < $num) { $objp = $db->fetch_object($resql); + + // Multilangs + if ($conf->global->PRODUIT_MULTILANGS == 1) // si l'option est active + { + $sql = "SELECT label FROM ".MAIN_DB_PREFIX."product_det"; + $sql.= " WHERE fk_product=".$objp->rowid." AND lang='". $langs->getDefaultLang() ."'"; + $sql.= " LIMIT 1"; + + $result = $db->query($sql); + if ($result) + { + $objtp = $db->fetch_object($result); + if ($objtp->label != '') $objp->produit = $objtp->label; + } + } + $var=!$var; print "
'.dolibarr_print_date($objp->datem).'