From 6a90298af00a3242ecdd6982d7d0007dbd7df4df Mon Sep 17 00:00:00 2001 From: Christophe Battarel <christophe.battarel@altairis.fr> Date: Mon, 16 Jan 2012 17:12:29 +0100 Subject: [PATCH] =?UTF-8?q?affiche=20libell=C3=A9=20produit=20dans=20la=20?= =?UTF-8?q?langue=20du=20client=20en=20plus=20de=20la=20description=20(var?= =?UTF-8?q?iable=20de=20conf=20renomm=C3=A9e=20en=20PRODUIT=5FTEXTS=5FIN?= =?UTF-8?q?=5FTHIRDPARTY=5FLANGUAGE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/comm/propal.php | 2 +- htdocs/commande/fiche.php | 2 +- htdocs/compta/facture.php | 2 +- htdocs/core/class/commonobject.class.php | 35 ++++++++++++++++++++---- htdocs/product/admin/produit.php | 10 +++---- 5 files changed, 37 insertions(+), 14 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index b29a8138759..a9f088dd77b 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -747,7 +747,7 @@ else if ($action == "addline" && $user->rights->propale->creer) } // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_DESC_IN_THIRDPARTY_LANGUAGE)) + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; $newlang=''; diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index d0bd5f9e1f8..69ed314b433 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -554,7 +554,7 @@ if ($action == 'addline' && $user->rights->commande->creer) } // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_DESC_IN_THIRDPARTY_LANGUAGE)) + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; $newlang=''; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index eddc66d47b5..e19cc5deaed 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -998,7 +998,7 @@ if (($action == 'addline' || $action == 'addline_predef') && $user->rights->fact } // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_DESC_IN_THIRDPARTY_LANGUAGE)) + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; $newlang=''; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 4168a97166f..076cd861ddb 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> * * 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 @@ -2096,12 +2097,34 @@ abstract class CommonObject { $product_static = new Product($this->db); - $product_static->type=$line->fk_product_type; - $product_static->id=$line->fk_product; - $product_static->ref=$line->ref; - $product_static->libelle=$line->product_label; - $text=$product_static->getNomUrl(1); - $text.= ' - '.$line->product_label; + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) + { + $this->fetch_thirdparty(); + $prod = new Product($this->db, $line->fk_product); + + $outputlangs = $langs; + $newlang=''; + if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); + if (empty($newlang)) $newlang=$this->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["libelle"])) ? $prod->multilangs[$outputlangs->defaultlang]["libelle"] : $line->product_label; + } + else { + $label = $line->product_label; + } + + $product_static->type=$line->fk_product_type; + $product_static->id=$line->fk_product; + $product_static->ref=$line->ref; + $product_static->libelle=$label; + $text=$product_static->getNomUrl(1); + $text.= ' - '.$label; $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->description)); // Use global variables + $seller and $buyer diff --git a/htdocs/product/admin/produit.php b/htdocs/product/admin/produit.php index 108b9ce87b7..24de62f5e99 100644 --- a/htdocs/product/admin/produit.php +++ b/htdocs/product/admin/produit.php @@ -70,10 +70,10 @@ else if ($action == 'viewProdDescInForm') $view = GETPOST("activate_viewProdDescInForm"); $res = dolibarr_set_const($db, "PRODUIT_DESC_IN_FORM", $view,'chaine',0,'',$conf->entity); } -else if ($action == 'viewProdDescInThirdpartyLanguage') +else if ($action == 'viewProdTextsInThirdpartyLanguage') { - $view = GETPOST("activate_viewProdDescInThirdpartyLanguage"); - $res = dolibarr_set_const($db, "PRODUIT_DESC_IN_THIRDPARTY_LANGUAGE", $view,'chaine',0,'',$conf->entity); + $view = GETPOST("activate_viewProdTextsInThirdpartyLanguage"); + $res = dolibarr_set_const($db, "PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE", $view,'chaine',0,'',$conf->entity); } else if ($action == 'usesearchtoselectproduct') { @@ -261,11 +261,11 @@ if (! empty($conf->global->MAIN_MULTILANGS)) $var=!$var; print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; - print '<input type="hidden" name="action" value="viewProdDescInThirdpartyLanguage">'; + print '<input type="hidden" name="action" value="viewProdTextsInThirdpartyLanguage">'; print '<tr '.$bc[$var].'>'; print '<td>'.$langs->trans("ViewProductDescInThirdpartyLanguageAbility").'</td>'; print '<td width="60" align="right">'; - print $form->selectyesno("activate_viewProdDescInThirdpartyLanguage",$conf->global->PRODUIT_DESC_IN_THIRDPARTY_LANGUAGE,1); + print $form->selectyesno("activate_viewProdTextsInThirdpartyLanguage",$conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE,1); print '</td><td align="right">'; print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">'; print '</td>'; -- GitLab