From 8ccc7acf285bbcf4937e1f8287d56aa43a1842eb Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 13 Jan 2012 11:25:48 +0100 Subject: [PATCH 1/6] Fix: add all phones if create user from contact --- htdocs/user/class/user.class.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index bcb7bdd1913..b1caeaba781 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -853,12 +853,15 @@ class User extends CommonObject $error=0; // Positionne parametres - $this->admin = 0; - $this->nom = $contact->nom; // TODO deprecated - $this->prenom = $contact->prenom; // TODO deprecated - $this->lastname = $contact->nom; - $this->firstname = $contact->prenom; - $this->email = $contact->email; + $this->admin = 0; + $this->nom = $contact->nom; // TODO deprecated + $this->prenom = $contact->prenom; // TODO deprecated + $this->lastname = $contact->nom; + $this->firstname = $contact->prenom; + $this->email = $contact->email; + $this->office_phone = $contact->phone_pro; + $this->office_fax = $contact->fax; + $this->user_mobile = $contact->phone_mobile; if (empty($login)) $login=strtolower(substr($contact->prenom, 0, 4)) . strtolower(substr($contact->nom, 0, 4)); $this->login = $login; @@ -871,6 +874,9 @@ class User extends CommonObject { $sql = "UPDATE ".MAIN_DB_PREFIX."user"; $sql.= " SET fk_socpeople=".$contact->id; + $sql.= ", office_phone = '".$this->db->escape($this->office_phone)."'"; + $sql.= ", office_fax = '".$this->db->escape($this->office_fax)."'"; + $sql.= ", user_mobile = '".$this->db->escape($this->user_mobile)."'"; if ($contact->socid) $sql.=", fk_societe=".$contact->socid; $sql.= " WHERE rowid=".$this->id; $resql=$this->db->query($sql); From 66bfaf8530d3b222047c74cb93d67a1f8866cc49 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 13 Jan 2012 12:17:41 +0100 Subject: [PATCH 2/6] Fix: custom language file was not loaded --- htdocs/core/class/translate.class.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 321debc5644..7e924f8ffae 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -81,7 +81,7 @@ class Translate { $newdir=$dir.$conf->global->MAIN_FORCELANGDIR; if (! in_array($newdir,$this->dir)) { - $more['module_'.$i]=$newdir; $i++; + $more['module_'.$i]=$newdir; $i++; // TODO a quoi ça sert ?? } } $this->dir=array_merge($more,$this->dir); @@ -193,7 +193,6 @@ class Translate { if ($alt < 1 && strtolower($langarray[0]) == strtolower($langarray[1])) $alt=1; if ($alt < 2 && (strtolower($langofdir) == 'en_us' || strtolower($langofdir) == 'fr_fr' || strtolower($langofdir) == 'es_es')) $alt=2; - foreach($this->dir as $keydir => $searchdir) { // Directory of translation files @@ -250,7 +249,7 @@ class Translate { $tab=explode('=',$line,2); $key=trim($tab[0]); //print "Domain=$domain, found a string for $tab[0] with value $tab[1]
"; - if (empty($this->tab_translate[$key]) && isset($tab[1])) + if ((! empty($conf->global->MAIN_FORCELANGDIR) || empty($this->tab_translate[$key])) && isset($tab[1])) { $value=trim(preg_replace('/\\n/',"\n",$tab[1])); From 69c9edbeb387e9e56a219b5b32a77c7aaabbe917 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 13 Jan 2012 16:53:28 +0100 Subject: [PATCH 3/6] =?UTF-8?q?ajoute=20la=20possibilit=C3=A9=20de=20visua?= =?UTF-8?q?liser=20la=20description=20des=20produits=20dans=20la=20langue?= =?UTF-8?q?=20du=20client=20lors=20de=20l'jout=20de=20lignes=20dans=20les?= =?UTF-8?q?=20commandes/propales/factures?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/comm/propal.php | 20 ++++++++++++++++++-- htdocs/commande/fiche.php | 20 ++++++++++++++++++-- htdocs/compta/facture.php | 20 ++++++++++++++++++-- htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/fr_FR/admin.lang | 1 + htdocs/product/admin/produit.php | 21 +++++++++++++++++++++ 6 files changed, 77 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 42236b90473..c6a9cfd6bc4 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -747,8 +747,24 @@ if ($_POST['action'] == "addline" && $user->rights->propale->creer) } } - $desc = $prod->description; - $desc.= ($prod->description && $_POST['np_desc']) ? ((dol_textishtml($prod->description) || dol_textishtml($_POST['np_desc']))?"
\n":"\n") : ""; + // Define output language + if ($conf->global->PRODUIT_DESC_IN_CLIENT_LANGUAGE) { + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + $desc = (! empty($prod->multilangs[$outputlangs->defaultlang]["description"]))?$prod->multilangs[$outputlangs->defaultlang]["description"]:$prod->description; + } + else + $desc = $prod->description; + + $desc.= ($desc && $_POST['np_desc']) ? ((dol_textishtml($desc) || dol_textishtml($_POST['np_desc']))?"
\n":"\n") : ""; $desc.= $_POST['np_desc']; $type = $prod->type; } diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 408e1005069..536c8672ecc 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -552,8 +552,24 @@ if ($action == 'addline' && $user->rights->commande->creer) } } - $desc = $prod->description; - $desc.= ($prod->description && $_POST['np_desc']) ? ((dol_textishtml($prod->description) || dol_textishtml($_POST['np_desc']))?"
\n":"\n") : ""; + // Define output language + if ($conf->global->PRODUIT_DESC_IN_CLIENT_LANGUAGE) { + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + $desc = (! empty($prod->multilangs[$outputlangs->defaultlang]["description"]))?$prod->multilangs[$outputlangs->defaultlang]["description"]:$prod->description; + } + else + $desc = $prod->description; + + $desc.= ($desc && $_POST['np_desc']) ? ((dol_textishtml($desc) || dol_textishtml($_POST['np_desc']))?"
\n":"\n") : ""; $desc.= $_POST['np_desc']; $type = $prod->type; } diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 0659b33058f..0f8cee517dd 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -996,8 +996,24 @@ if (($action == 'addline' || $action == 'addline_predef') && $user->rights->fact } } - $desc = $prod->description; - $desc.= ($prod->description && $_POST['np_desc']) ? ((dol_textishtml($prod->description) || dol_textishtml($_POST['np_desc']))?"
\n":"\n") : ""; + // Define output language + if ($conf->global->PRODUIT_DESC_IN_CLIENT_LANGUAGE) { + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + $desc = (! empty($prod->multilangs[$outputlangs->defaultlang]["description"]))?$prod->multilangs[$outputlangs->defaultlang]["description"]:$prod->description; + } + else + $desc = $prod->description; + + $desc.= ($desc && $_POST['np_desc']) ? ((dol_textishtml($desc) || dol_textishtml($_POST['np_desc']))?"
\n":"\n") : ""; $desc.= $_POST['np_desc']; if (! empty($prod->customcode) || ! empty($prod->country_code)) { diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index c19cfbb7712..9fc7f0e4ee6 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1111,6 +1111,7 @@ NumberOfProductShowInSelect=Max number of products in combos select lists (0=no ConfirmDeleteProductLineAbility=Confirmation when removing product lines in forms ModifyProductDescAbility=Personalization of product descriptions in forms ViewProductDescInFormAbility=Visualization of product descriptions in the forms (otherwise as popup tooltip) +ViewProductDescInClientLanguageAbility=Visualization of product descriptions in the customer language UseSearchToSelectProduct=Use a search form to choose a product (instead of using a list box).
Also if you have a large number of product (> 100 000), you can increase speed by setting constant PRODUCT_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string. UseEcoTaxeAbility=Support Eco-Taxe (WEEE) SetDefaultBarcodeTypeProducts=Default barcode type to use for products diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 1cb634c03e4..950e1362240 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -1119,6 +1119,7 @@ NumberOfProductShowInSelect= Nombre de produits max dans les listes déroulantes ConfirmDeleteProductLineAbility= Confirmation de suppression d'une ligne produit dans les formulaires ModifyProductDescAbility= Personnalisation des descriptions produits dans les formulaires ViewProductDescInFormAbility= Visualisation des descriptions produits dans les formulaires (sinon en tant que tooltip) +ViewProductDescInClientLanguageAbility= Visualisation des descriptions produits dans la langue du client UseSearchToSelectProduct= Utiliser un formulaire de recherche pour le choix d'un produit (plutôt qu'une liste déroulante).
Notez que si vous avez un nombre important de produits ou services (> 100 000), vous pouvez améliorer les performances en définissant la constante PRODUCT_DONOTSEARCH_ANYWHERE à 1 dans Configuration->Divers. La recherche sera alors limitée au début de la chaine. UseEcoTaxeAbility= Prise en charge des éco-taxes (DEEE) SetDefaultBarcodeTypeProducts= Type de code-barres utilisé par défaut pour les produits diff --git a/htdocs/product/admin/produit.php b/htdocs/product/admin/produit.php index dd911ae0bc0..45d672e0247 100644 --- a/htdocs/product/admin/produit.php +++ b/htdocs/product/admin/produit.php @@ -69,6 +69,11 @@ 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 == 'viewProdDescInClientLanguage') +{ + $view = GETPOST("activate_viewProdDescInClientLanguage"); + $res = dolibarr_set_const($db, "PRODUIT_DESC_IN_CLIENT_LANGUAGE", $view,'chaine',0,'',$conf->entity); +} else if ($action == 'usesearchtoselectproduct') { $usesearch = GETPOST("activate_usesearchtoselectproduct"); @@ -249,6 +254,22 @@ print ''; print ''; print ''; +// Visualiser description produit dans la langue du client +$var=!$var; +print '
'; +print ''; +print ''; +print ''; +print ''.$langs->trans("ViewProductDescInClientLanguageAbility").''; +print ''; +print $form->selectyesno("activate_viewProdDescInClientLanguage",$conf->global->PRODUIT_DESC_IN_CLIENT_LANGUAGE,1); +print ''; +print ''; +print ''; +print ''; +print '
'; + + if ($conf->global->PRODUCT_CANVAS_ABILITY) { // Add canvas feature From 7363b39c1784207e51fdcd7bb088939fb26ddfa5 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 13 Jan 2012 17:40:52 +0100 Subject: [PATCH 4/6] Fix: uniform code --- htdocs/comm/propal.php | 136 ++++++++++++++----------------- htdocs/commande/fiche.php | 35 ++++---- htdocs/compta/facture.php | 35 ++++---- htdocs/langs/en_US/admin.lang | 2 +- htdocs/langs/fr_FR/admin.lang | 2 +- htdocs/product/admin/produit.php | 42 +++++----- 6 files changed, 125 insertions(+), 127 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index c6a9cfd6bc4..9cda8958adf 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005 Marc Barilley / Ocebo - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010-2011 Juanjo Menent * Copyright (C) 2010-2011 Philippe Grand @@ -45,12 +45,12 @@ $langs->load('bills'); $langs->load('orders'); $langs->load('products'); -$id=GETPOST('id'); -$ref=GETPOST('ref'); -$socid=GETPOST('socid'); -$action=GETPOST('action'); -$confirm=GETPOST('confirm'); -$lineid=GETPOST('lineid'); +$id=GETPOST('id','int'); +$ref=GETPOST('ref','alpha'); +$socid=GETPOST('socid','int'); +$action=GETPOST('action','alpha'); +$confirm=GETPOST('confirm','alpha'); +$lineid=GETPOST('lineid','int'); $search_ref=GETPOST('sf_ref')?GETPOST('sf_ref','alpha'):GETPOST('search_ref','alpha'); $search_societe=GETPOST('search_societe','alpha'); @@ -124,7 +124,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes') } // Suppression de la propale -if ($action == 'confirm_delete' && $confirm == 'yes') +else if ($action == 'confirm_delete' && $confirm == 'yes') { if ($user->rights->propale->supprimer) { @@ -148,7 +148,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') } // Remove line -if ($action == 'confirm_deleteline' && $confirm == 'yes') +else if ($action == 'confirm_deleteline' && $confirm == 'yes') { if ($user->rights->propale->creer) { @@ -184,7 +184,7 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes') } // Validation -if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->propale->valider) +else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->propale->valider) { $object->fetch($id); $object->fetch_thirdparty(); @@ -214,7 +214,7 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->propale } } -if ($_POST['action'] == 'setdate') +else if ($action == 'setdate') { $datep=dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); @@ -231,20 +231,20 @@ if ($_POST['action'] == 'setdate') if ($result < 0) dol_print_error($db,$object->error); } } -if ($_POST['action'] == 'setecheance') +else if ($action == 'setecheance') { $object->fetch($id); $result=$object->set_echeance($user,dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear'])); if ($result < 0) dol_print_error($db,$object->error); } -if ($_POST['action'] == 'setdate_livraison') +else if ($action == 'setdate_livraison') { $object->fetch($id); $result=$object->set_date_livraison($user,dol_mktime(12, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year'])); if ($result < 0) dol_print_error($db,$object->error); } -if ($_POST['action'] == 'setaddress' && $user->rights->propale->creer) +else if ($actione == 'setaddress' && $user->rights->propale->creer) { $object->fetch($id); $result=$object->set_adresse_livraison($user,$_POST['fk_address']); @@ -252,14 +252,14 @@ if ($_POST['action'] == 'setaddress' && $user->rights->propale->creer) } // Positionne ref client -if ($_POST['action'] == 'set_ref_client' && $user->rights->propale->creer) +else if ($action == 'set_ref_client' && $user->rights->propale->creer) { $object->fetch($id); $object->set_ref_client($user, $_POST['ref_client']); } // Create proposal -if ($_POST['action'] == 'add' && $user->rights->propale->creer) +else if ($action == 'add' && $user->rights->propale->creer) { $object->socid=$socid; $object->fetch_thirdparty(); @@ -400,14 +400,14 @@ if ($_POST['action'] == 'add' && $user->rights->propale->creer) } // Classify billed -if ($action == 'classifybilled') +else if ($action == 'classifybilled') { $object->fetch($id); $object->cloture($user, 4, ''); } // Reopen proposal -if ($action == 'confirm_reopen' && $user->rights->propale->cloturer) +else if ($action == 'confirm_reopen' && $user->rights->propale->cloturer) { if (! $_POST['cancel']) { @@ -421,7 +421,7 @@ if ($action == 'confirm_reopen' && $user->rights->propale->cloturer) } // Close proposal -if ($action == 'setstatut' && $user->rights->propale->cloturer) +else if ($action == 'setstatut' && $user->rights->propale->cloturer) { if (! $_POST['cancel']) { @@ -481,7 +481,7 @@ if (! empty($_POST['removedfile'])) /* * Send mail */ -if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel']) +if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel']) { $langs->load('mails'); @@ -653,7 +653,7 @@ if ($action == 'modif' && $user->rights->propale->creer) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager); } -if ($_POST['action'] == "setabsolutediscount" && $user->rights->propale->creer) +else if ($action == "setabsolutediscount" && $user->rights->propale->creer) { if ($_POST["remise_id"]) { @@ -674,10 +674,8 @@ if ($_POST['action'] == "setabsolutediscount" && $user->rights->propale->creer) } } -/* - * Ajout d'une ligne produit dans la propale - */ -if ($_POST['action'] == "addline" && $user->rights->propale->creer) +//Ajout d'une ligne produit dans la propale +else if ($action == "addline" && $user->rights->propale->creer) { $result=0; @@ -746,23 +744,26 @@ if ($_POST['action'] == "addline" && $user->rights->propale->creer) $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); } } - - // Define output language - if ($conf->global->PRODUIT_DESC_IN_CLIENT_LANGUAGE) { - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - - $desc = (! empty($prod->multilangs[$outputlangs->defaultlang]["description"]))?$prod->multilangs[$outputlangs->defaultlang]["description"]:$prod->description; - } - else - $desc = $prod->description; + + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_DESC_IN_THIRDPARTY_LANGUAGE)) + { + $outputlangs = $langs; + $newlang=''; + if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); + if (empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + $desc = (! empty($prod->multilangs[$outputlangs->defaultlang]["description"])) ? $prod->multilangs[$outputlangs->defaultlang]["description"] : $prod->description; + } + else + { + $desc = $prod->description; + } $desc.= ($desc && $_POST['np_desc']) ? ((dol_textishtml($desc) || dol_textishtml($_POST['np_desc']))?"
\n":"\n") : ""; $desc.= $_POST['np_desc']; @@ -840,10 +841,8 @@ if ($_POST['action'] == "addline" && $user->rights->propale->creer) } } -/* - * Mise a jour d'une ligne dans la propale - */ -if ($_POST['action'] == 'updateligne' && $user->rights->propale->creer && $_POST["save"] == $langs->trans("Save")) +// Mise a jour d'une ligne dans la propale +if ($action == 'updateligne' && $user->rights->propale->creer && $_POST["save"] == $langs->trans("Save")) { if (! $object->fetch($_POST["id"]) > 0) { @@ -915,10 +914,8 @@ if ($_POST['action'] == 'updateligne' && $user->rights->propale->creer && $_POST } } -/* - * Generation doc (depuis lien ou depuis cartouche doc) - */ -if ($action == 'builddoc' && $user->rights->propale->creer) +// Generation doc (depuis lien ou depuis cartouche doc) +else if ($action == 'builddoc' && $user->rights->propale->creer) { $object->fetch($id); $object->fetch_thirdparty(); @@ -952,63 +949,57 @@ if ($action == 'builddoc' && $user->rights->propale->creer) } // Set project -if ($_POST['action'] == 'classin') +else if ($action == 'classin') { $object->fetch($id); $object->setProject($_POST['projectid']); } // Delai de livraison -if ($_POST["action"] == 'setavailability') +else if ($action == 'setavailability') { - $object->fetch($_REQUEST['id']); + $object->fetch($id); $result = $object->availability($_POST['availability_id']); - $id=$_REQUEST['id']; } // Origine de la propale -if ($_POST["action"] == 'setdemandreason') +else if ($action == 'setdemandreason') { - $object->fetch($_REQUEST['id']); + $object->fetch($id); $result = $object->demand_reason($_POST['demand_reason_id']); - $id=$_REQUEST['id']; } // Conditions de reglement -if ($_POST["action"] == 'setconditions') +else if ($action == 'setconditions') { - $object->fetch($_REQUEST['id']); + $object->fetch($id); $result = $object->cond_reglement($_POST['cond_reglement_id']); - $id=$_REQUEST['id']; } -if ($action == 'setremisepercent' && $user->rights->propale->creer) +else if ($action == 'setremisepercent' && $user->rights->propale->creer) { - $object->fetch($_REQUEST["id"]); + $object->fetch($id); $result = $object->set_remise_percent($user, $_POST['remise_percent']); - $id=$_REQUEST["id"]; } -if ($action == 'setremiseabsolue' && $user->rights->propale->creer) +else if ($action == 'setremiseabsolue' && $user->rights->propale->creer) { - $object->fetch($_REQUEST["id"]); + $object->fetch($id); $result = $object->set_remise_absolue($user, $_POST['remise_absolue']); - $id=$_REQUEST["id"]; } // Mode de reglement -if ($_POST["action"] == 'setmode') +else if ($action == 'setmode') { - $object->fetch($_REQUEST["id"]); + $object->fetch($id); $result = $object->mode_reglement($_POST['mode_reglement_id']); - $id=$_REQUEST["id"]; } /* * Ordonnancement des lignes */ -if ($action == 'up' && $user->rights->propale->creer) +else if ($action == 'up' && $user->rights->propale->creer) { $object->fetch($id); $object->fetch_thirdparty(); @@ -1030,7 +1021,7 @@ if ($action == 'up' && $user->rights->propale->creer) exit; } -if ($action == 'down' && $user->rights->propale->creer) +else if ($action == 'down' && $user->rights->propale->creer) { $object->fetch($id); $object->fetch_thirdparty(); @@ -1066,9 +1057,6 @@ $companystatic=new Societe($db); $now=dol_now(); -$id = GETPOST('id'); -$ref= GETPOST('ref'); - if ($id > 0 || ! empty($ref)) { /* diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 536c8672ecc..9f5e6f3a917 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -551,23 +551,26 @@ if ($action == 'addline' && $user->rights->commande->creer) $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); } } - + // Define output language - if ($conf->global->PRODUIT_DESC_IN_CLIENT_LANGUAGE) { - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - - $desc = (! empty($prod->multilangs[$outputlangs->defaultlang]["description"]))?$prod->multilangs[$outputlangs->defaultlang]["description"]:$prod->description; - } - else - $desc = $prod->description; + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_DESC_IN_THIRDPARTY_LANGUAGE)) + { + $outputlangs = $langs; + $newlang=''; + if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); + if (empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + $desc = (! empty($prod->multilangs[$outputlangs->defaultlang]["description"])) ? $prod->multilangs[$outputlangs->defaultlang]["description"] : $prod->description; + } + else + { + $desc = $prod->description; + } $desc.= ($desc && $_POST['np_desc']) ? ((dol_textishtml($desc) || dol_textishtml($_POST['np_desc']))?"
\n":"\n") : ""; $desc.= $_POST['np_desc']; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 0f8cee517dd..1a1f1ab0830 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -995,23 +995,26 @@ if (($action == 'addline' || $action == 'addline_predef') && $user->rights->fact $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); } } - + // Define output language - if ($conf->global->PRODUIT_DESC_IN_CLIENT_LANGUAGE) { - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - - $desc = (! empty($prod->multilangs[$outputlangs->defaultlang]["description"]))?$prod->multilangs[$outputlangs->defaultlang]["description"]:$prod->description; - } - else - $desc = $prod->description; + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_DESC_IN_THIRDPARTY_LANGUAGE)) + { + $outputlangs = $langs; + $newlang=''; + if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); + if (empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + $desc = (! empty($prod->multilangs[$outputlangs->defaultlang]["description"])) ? $prod->multilangs[$outputlangs->defaultlang]["description"] : $prod->description; + } + else + { + $desc = $prod->description; + } $desc.= ($desc && $_POST['np_desc']) ? ((dol_textishtml($desc) || dol_textishtml($_POST['np_desc']))?"
\n":"\n") : ""; $desc.= $_POST['np_desc']; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 9fc7f0e4ee6..55bfaef9806 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1111,7 +1111,7 @@ NumberOfProductShowInSelect=Max number of products in combos select lists (0=no ConfirmDeleteProductLineAbility=Confirmation when removing product lines in forms ModifyProductDescAbility=Personalization of product descriptions in forms ViewProductDescInFormAbility=Visualization of product descriptions in the forms (otherwise as popup tooltip) -ViewProductDescInClientLanguageAbility=Visualization of product descriptions in the customer language +ViewProductDescInThirdpartyLanguageAbility=Visualization of products descriptions in the thirdparty language UseSearchToSelectProduct=Use a search form to choose a product (instead of using a list box).
Also if you have a large number of product (> 100 000), you can increase speed by setting constant PRODUCT_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string. UseEcoTaxeAbility=Support Eco-Taxe (WEEE) SetDefaultBarcodeTypeProducts=Default barcode type to use for products diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 950e1362240..2b56e6e1968 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -1119,7 +1119,7 @@ NumberOfProductShowInSelect= Nombre de produits max dans les listes déroulantes ConfirmDeleteProductLineAbility= Confirmation de suppression d'une ligne produit dans les formulaires ModifyProductDescAbility= Personnalisation des descriptions produits dans les formulaires ViewProductDescInFormAbility= Visualisation des descriptions produits dans les formulaires (sinon en tant que tooltip) -ViewProductDescInClientLanguageAbility= Visualisation des descriptions produits dans la langue du client +ViewProductDescInThirdpartyLanguageAbility= Visualisation des descriptions produits dans la langue du tiers UseSearchToSelectProduct= Utiliser un formulaire de recherche pour le choix d'un produit (plutôt qu'une liste déroulante).
Notez que si vous avez un nombre important de produits ou services (> 100 000), vous pouvez améliorer les performances en définissant la constante PRODUCT_DONOTSEARCH_ANYWHERE à 1 dans Configuration->Divers. La recherche sera alors limitée au début de la chaine. UseEcoTaxeAbility= Prise en charge des éco-taxes (DEEE) SetDefaultBarcodeTypeProducts= Type de code-barres utilisé par défaut pour les produits diff --git a/htdocs/product/admin/produit.php b/htdocs/product/admin/produit.php index 45d672e0247..50c5e757a9e 100644 --- a/htdocs/product/admin/produit.php +++ b/htdocs/product/admin/produit.php @@ -3,7 +3,7 @@ * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2006-2007 Rodolphe Quiedeville * Copyright (C) 2007 Auguria SARL - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2011 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -69,10 +69,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 == 'viewProdDescInClientLanguage') +else if ($action == 'viewProdDescInThirdpartyLanguage') { - $view = GETPOST("activate_viewProdDescInClientLanguage"); - $res = dolibarr_set_const($db, "PRODUIT_DESC_IN_CLIENT_LANGUAGE", $view,'chaine',0,'',$conf->entity); + $view = GETPOST("activate_viewProdDescInThirdpartyLanguage"); + $res = dolibarr_set_const($db, "PRODUIT_DESC_IN_THIRDPARTY_LANGUAGE", $view,'chaine',0,'',$conf->entity); } else if ($action == 'usesearchtoselectproduct') { @@ -254,20 +254,23 @@ print ''; print ''; print ''; -// Visualiser description produit dans la langue du client -$var=!$var; -print '
'; -print ''; -print ''; -print ''; -print ''.$langs->trans("ViewProductDescInClientLanguageAbility").''; -print ''; -print $form->selectyesno("activate_viewProdDescInClientLanguage",$conf->global->PRODUIT_DESC_IN_CLIENT_LANGUAGE,1); -print ''; -print ''; -print ''; -print ''; -print '
'; +// View product description in thirdparty language +if (! empty($conf->global->MAIN_MULTILANGS)) +{ + $var=!$var; + print '
'; + print ''; + print ''; + print ''; + print ''.$langs->trans("ViewProductDescInThirdpartyLanguageAbility").''; + print ''; + print $form->selectyesno("activate_viewProdDescInThirdpartyLanguage",$conf->global->PRODUIT_DESC_IN_THIRDPARTY_LANGUAGE,1); + print ''; + print ''; + print ''; + print ''; + print '
'; +} if ($conf->global->PRODUCT_CANVAS_ABILITY) @@ -340,7 +343,8 @@ if ($conf->global->PRODUCT_CANVAS_ABILITY) dol_htmloutput_mesg($mesg); +llxFooter(); + $db->close(); -llxFooter(); ?> From 9fe45c4f4ff8c41734c36bc92604bb71a1559c65 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 13 Jan 2012 17:46:15 +0100 Subject: [PATCH 5/6] Fix: uniform code --- htdocs/comm/propal.php | 136 ++++++++++++++----------------- htdocs/commande/fiche.php | 35 ++++---- htdocs/compta/facture.php | 35 ++++---- htdocs/langs/en_US/admin.lang | 2 +- htdocs/langs/fr_FR/admin.lang | 2 +- htdocs/product/admin/produit.php | 42 +++++----- 6 files changed, 125 insertions(+), 127 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index c6a9cfd6bc4..10c897d8c84 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005 Marc Barilley / Ocebo - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010-2011 Juanjo Menent * Copyright (C) 2010-2011 Philippe Grand @@ -45,12 +45,12 @@ $langs->load('bills'); $langs->load('orders'); $langs->load('products'); -$id=GETPOST('id'); -$ref=GETPOST('ref'); -$socid=GETPOST('socid'); -$action=GETPOST('action'); -$confirm=GETPOST('confirm'); -$lineid=GETPOST('lineid'); +$id=GETPOST('id','int'); +$ref=GETPOST('ref','alpha'); +$socid=GETPOST('socid','int'); +$action=GETPOST('action','alpha'); +$confirm=GETPOST('confirm','alpha'); +$lineid=GETPOST('lineid','int'); $search_ref=GETPOST('sf_ref')?GETPOST('sf_ref','alpha'):GETPOST('search_ref','alpha'); $search_societe=GETPOST('search_societe','alpha'); @@ -124,7 +124,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes') } // Suppression de la propale -if ($action == 'confirm_delete' && $confirm == 'yes') +else if ($action == 'confirm_delete' && $confirm == 'yes') { if ($user->rights->propale->supprimer) { @@ -148,7 +148,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') } // Remove line -if ($action == 'confirm_deleteline' && $confirm == 'yes') +else if ($action == 'confirm_deleteline' && $confirm == 'yes') { if ($user->rights->propale->creer) { @@ -184,7 +184,7 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes') } // Validation -if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->propale->valider) +else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->propale->valider) { $object->fetch($id); $object->fetch_thirdparty(); @@ -214,7 +214,7 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->propale } } -if ($_POST['action'] == 'setdate') +else if ($action == 'setdate') { $datep=dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); @@ -231,20 +231,20 @@ if ($_POST['action'] == 'setdate') if ($result < 0) dol_print_error($db,$object->error); } } -if ($_POST['action'] == 'setecheance') +else if ($action == 'setecheance') { $object->fetch($id); $result=$object->set_echeance($user,dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear'])); if ($result < 0) dol_print_error($db,$object->error); } -if ($_POST['action'] == 'setdate_livraison') +else if ($action == 'setdate_livraison') { $object->fetch($id); $result=$object->set_date_livraison($user,dol_mktime(12, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year'])); if ($result < 0) dol_print_error($db,$object->error); } -if ($_POST['action'] == 'setaddress' && $user->rights->propale->creer) +else if ($action == 'setaddress' && $user->rights->propale->creer) { $object->fetch($id); $result=$object->set_adresse_livraison($user,$_POST['fk_address']); @@ -252,14 +252,14 @@ if ($_POST['action'] == 'setaddress' && $user->rights->propale->creer) } // Positionne ref client -if ($_POST['action'] == 'set_ref_client' && $user->rights->propale->creer) +else if ($action == 'set_ref_client' && $user->rights->propale->creer) { $object->fetch($id); $object->set_ref_client($user, $_POST['ref_client']); } // Create proposal -if ($_POST['action'] == 'add' && $user->rights->propale->creer) +else if ($action == 'add' && $user->rights->propale->creer) { $object->socid=$socid; $object->fetch_thirdparty(); @@ -400,14 +400,14 @@ if ($_POST['action'] == 'add' && $user->rights->propale->creer) } // Classify billed -if ($action == 'classifybilled') +else if ($action == 'classifybilled') { $object->fetch($id); $object->cloture($user, 4, ''); } // Reopen proposal -if ($action == 'confirm_reopen' && $user->rights->propale->cloturer) +else if ($action == 'confirm_reopen' && $user->rights->propale->cloturer) { if (! $_POST['cancel']) { @@ -421,7 +421,7 @@ if ($action == 'confirm_reopen' && $user->rights->propale->cloturer) } // Close proposal -if ($action == 'setstatut' && $user->rights->propale->cloturer) +else if ($action == 'setstatut' && $user->rights->propale->cloturer) { if (! $_POST['cancel']) { @@ -481,7 +481,7 @@ if (! empty($_POST['removedfile'])) /* * Send mail */ -if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel']) +if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel']) { $langs->load('mails'); @@ -653,7 +653,7 @@ if ($action == 'modif' && $user->rights->propale->creer) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager); } -if ($_POST['action'] == "setabsolutediscount" && $user->rights->propale->creer) +else if ($action == "setabsolutediscount" && $user->rights->propale->creer) { if ($_POST["remise_id"]) { @@ -674,10 +674,8 @@ if ($_POST['action'] == "setabsolutediscount" && $user->rights->propale->creer) } } -/* - * Ajout d'une ligne produit dans la propale - */ -if ($_POST['action'] == "addline" && $user->rights->propale->creer) +//Ajout d'une ligne produit dans la propale +else if ($action == "addline" && $user->rights->propale->creer) { $result=0; @@ -746,23 +744,26 @@ if ($_POST['action'] == "addline" && $user->rights->propale->creer) $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); } } - - // Define output language - if ($conf->global->PRODUIT_DESC_IN_CLIENT_LANGUAGE) { - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - - $desc = (! empty($prod->multilangs[$outputlangs->defaultlang]["description"]))?$prod->multilangs[$outputlangs->defaultlang]["description"]:$prod->description; - } - else - $desc = $prod->description; + + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_DESC_IN_THIRDPARTY_LANGUAGE)) + { + $outputlangs = $langs; + $newlang=''; + if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); + if (empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + $desc = (! empty($prod->multilangs[$outputlangs->defaultlang]["description"])) ? $prod->multilangs[$outputlangs->defaultlang]["description"] : $prod->description; + } + else + { + $desc = $prod->description; + } $desc.= ($desc && $_POST['np_desc']) ? ((dol_textishtml($desc) || dol_textishtml($_POST['np_desc']))?"
\n":"\n") : ""; $desc.= $_POST['np_desc']; @@ -840,10 +841,8 @@ if ($_POST['action'] == "addline" && $user->rights->propale->creer) } } -/* - * Mise a jour d'une ligne dans la propale - */ -if ($_POST['action'] == 'updateligne' && $user->rights->propale->creer && $_POST["save"] == $langs->trans("Save")) +// Mise a jour d'une ligne dans la propale +if ($action == 'updateligne' && $user->rights->propale->creer && $_POST["save"] == $langs->trans("Save")) { if (! $object->fetch($_POST["id"]) > 0) { @@ -915,10 +914,8 @@ if ($_POST['action'] == 'updateligne' && $user->rights->propale->creer && $_POST } } -/* - * Generation doc (depuis lien ou depuis cartouche doc) - */ -if ($action == 'builddoc' && $user->rights->propale->creer) +// Generation doc (depuis lien ou depuis cartouche doc) +else if ($action == 'builddoc' && $user->rights->propale->creer) { $object->fetch($id); $object->fetch_thirdparty(); @@ -952,63 +949,57 @@ if ($action == 'builddoc' && $user->rights->propale->creer) } // Set project -if ($_POST['action'] == 'classin') +else if ($action == 'classin') { $object->fetch($id); $object->setProject($_POST['projectid']); } // Delai de livraison -if ($_POST["action"] == 'setavailability') +else if ($action == 'setavailability') { - $object->fetch($_REQUEST['id']); + $object->fetch($id); $result = $object->availability($_POST['availability_id']); - $id=$_REQUEST['id']; } // Origine de la propale -if ($_POST["action"] == 'setdemandreason') +else if ($action == 'setdemandreason') { - $object->fetch($_REQUEST['id']); + $object->fetch($id); $result = $object->demand_reason($_POST['demand_reason_id']); - $id=$_REQUEST['id']; } // Conditions de reglement -if ($_POST["action"] == 'setconditions') +else if ($action == 'setconditions') { - $object->fetch($_REQUEST['id']); + $object->fetch($id); $result = $object->cond_reglement($_POST['cond_reglement_id']); - $id=$_REQUEST['id']; } -if ($action == 'setremisepercent' && $user->rights->propale->creer) +else if ($action == 'setremisepercent' && $user->rights->propale->creer) { - $object->fetch($_REQUEST["id"]); + $object->fetch($id); $result = $object->set_remise_percent($user, $_POST['remise_percent']); - $id=$_REQUEST["id"]; } -if ($action == 'setremiseabsolue' && $user->rights->propale->creer) +else if ($action == 'setremiseabsolue' && $user->rights->propale->creer) { - $object->fetch($_REQUEST["id"]); + $object->fetch($id); $result = $object->set_remise_absolue($user, $_POST['remise_absolue']); - $id=$_REQUEST["id"]; } // Mode de reglement -if ($_POST["action"] == 'setmode') +else if ($action == 'setmode') { - $object->fetch($_REQUEST["id"]); + $object->fetch($id); $result = $object->mode_reglement($_POST['mode_reglement_id']); - $id=$_REQUEST["id"]; } /* * Ordonnancement des lignes */ -if ($action == 'up' && $user->rights->propale->creer) +else if ($action == 'up' && $user->rights->propale->creer) { $object->fetch($id); $object->fetch_thirdparty(); @@ -1030,7 +1021,7 @@ if ($action == 'up' && $user->rights->propale->creer) exit; } -if ($action == 'down' && $user->rights->propale->creer) +else if ($action == 'down' && $user->rights->propale->creer) { $object->fetch($id); $object->fetch_thirdparty(); @@ -1066,9 +1057,6 @@ $companystatic=new Societe($db); $now=dol_now(); -$id = GETPOST('id'); -$ref= GETPOST('ref'); - if ($id > 0 || ! empty($ref)) { /* diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 536c8672ecc..9f5e6f3a917 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -551,23 +551,26 @@ if ($action == 'addline' && $user->rights->commande->creer) $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); } } - + // Define output language - if ($conf->global->PRODUIT_DESC_IN_CLIENT_LANGUAGE) { - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - - $desc = (! empty($prod->multilangs[$outputlangs->defaultlang]["description"]))?$prod->multilangs[$outputlangs->defaultlang]["description"]:$prod->description; - } - else - $desc = $prod->description; + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_DESC_IN_THIRDPARTY_LANGUAGE)) + { + $outputlangs = $langs; + $newlang=''; + if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); + if (empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + $desc = (! empty($prod->multilangs[$outputlangs->defaultlang]["description"])) ? $prod->multilangs[$outputlangs->defaultlang]["description"] : $prod->description; + } + else + { + $desc = $prod->description; + } $desc.= ($desc && $_POST['np_desc']) ? ((dol_textishtml($desc) || dol_textishtml($_POST['np_desc']))?"
\n":"\n") : ""; $desc.= $_POST['np_desc']; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 0f8cee517dd..1a1f1ab0830 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -995,23 +995,26 @@ if (($action == 'addline' || $action == 'addline_predef') && $user->rights->fact $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); } } - + // Define output language - if ($conf->global->PRODUIT_DESC_IN_CLIENT_LANGUAGE) { - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - - $desc = (! empty($prod->multilangs[$outputlangs->defaultlang]["description"]))?$prod->multilangs[$outputlangs->defaultlang]["description"]:$prod->description; - } - else - $desc = $prod->description; + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_DESC_IN_THIRDPARTY_LANGUAGE)) + { + $outputlangs = $langs; + $newlang=''; + if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); + if (empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + $desc = (! empty($prod->multilangs[$outputlangs->defaultlang]["description"])) ? $prod->multilangs[$outputlangs->defaultlang]["description"] : $prod->description; + } + else + { + $desc = $prod->description; + } $desc.= ($desc && $_POST['np_desc']) ? ((dol_textishtml($desc) || dol_textishtml($_POST['np_desc']))?"
\n":"\n") : ""; $desc.= $_POST['np_desc']; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 9fc7f0e4ee6..55bfaef9806 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1111,7 +1111,7 @@ NumberOfProductShowInSelect=Max number of products in combos select lists (0=no ConfirmDeleteProductLineAbility=Confirmation when removing product lines in forms ModifyProductDescAbility=Personalization of product descriptions in forms ViewProductDescInFormAbility=Visualization of product descriptions in the forms (otherwise as popup tooltip) -ViewProductDescInClientLanguageAbility=Visualization of product descriptions in the customer language +ViewProductDescInThirdpartyLanguageAbility=Visualization of products descriptions in the thirdparty language UseSearchToSelectProduct=Use a search form to choose a product (instead of using a list box).
Also if you have a large number of product (> 100 000), you can increase speed by setting constant PRODUCT_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string. UseEcoTaxeAbility=Support Eco-Taxe (WEEE) SetDefaultBarcodeTypeProducts=Default barcode type to use for products diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 950e1362240..2b56e6e1968 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -1119,7 +1119,7 @@ NumberOfProductShowInSelect= Nombre de produits max dans les listes déroulantes ConfirmDeleteProductLineAbility= Confirmation de suppression d'une ligne produit dans les formulaires ModifyProductDescAbility= Personnalisation des descriptions produits dans les formulaires ViewProductDescInFormAbility= Visualisation des descriptions produits dans les formulaires (sinon en tant que tooltip) -ViewProductDescInClientLanguageAbility= Visualisation des descriptions produits dans la langue du client +ViewProductDescInThirdpartyLanguageAbility= Visualisation des descriptions produits dans la langue du tiers UseSearchToSelectProduct= Utiliser un formulaire de recherche pour le choix d'un produit (plutôt qu'une liste déroulante).
Notez que si vous avez un nombre important de produits ou services (> 100 000), vous pouvez améliorer les performances en définissant la constante PRODUCT_DONOTSEARCH_ANYWHERE à 1 dans Configuration->Divers. La recherche sera alors limitée au début de la chaine. UseEcoTaxeAbility= Prise en charge des éco-taxes (DEEE) SetDefaultBarcodeTypeProducts= Type de code-barres utilisé par défaut pour les produits diff --git a/htdocs/product/admin/produit.php b/htdocs/product/admin/produit.php index 45d672e0247..50c5e757a9e 100644 --- a/htdocs/product/admin/produit.php +++ b/htdocs/product/admin/produit.php @@ -3,7 +3,7 @@ * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2006-2007 Rodolphe Quiedeville * Copyright (C) 2007 Auguria SARL - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2011 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -69,10 +69,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 == 'viewProdDescInClientLanguage') +else if ($action == 'viewProdDescInThirdpartyLanguage') { - $view = GETPOST("activate_viewProdDescInClientLanguage"); - $res = dolibarr_set_const($db, "PRODUIT_DESC_IN_CLIENT_LANGUAGE", $view,'chaine',0,'',$conf->entity); + $view = GETPOST("activate_viewProdDescInThirdpartyLanguage"); + $res = dolibarr_set_const($db, "PRODUIT_DESC_IN_THIRDPARTY_LANGUAGE", $view,'chaine',0,'',$conf->entity); } else if ($action == 'usesearchtoselectproduct') { @@ -254,20 +254,23 @@ print ''; print ''; print ''; -// Visualiser description produit dans la langue du client -$var=!$var; -print '
'; -print ''; -print ''; -print ''; -print ''.$langs->trans("ViewProductDescInClientLanguageAbility").''; -print ''; -print $form->selectyesno("activate_viewProdDescInClientLanguage",$conf->global->PRODUIT_DESC_IN_CLIENT_LANGUAGE,1); -print ''; -print ''; -print ''; -print ''; -print '
'; +// View product description in thirdparty language +if (! empty($conf->global->MAIN_MULTILANGS)) +{ + $var=!$var; + print '
'; + print ''; + print ''; + print ''; + print ''.$langs->trans("ViewProductDescInThirdpartyLanguageAbility").''; + print ''; + print $form->selectyesno("activate_viewProdDescInThirdpartyLanguage",$conf->global->PRODUIT_DESC_IN_THIRDPARTY_LANGUAGE,1); + print ''; + print ''; + print ''; + print ''; + print '
'; +} if ($conf->global->PRODUCT_CANVAS_ABILITY) @@ -340,7 +343,8 @@ if ($conf->global->PRODUCT_CANVAS_ABILITY) dol_htmloutput_mesg($mesg); +llxFooter(); + $db->close(); -llxFooter(); ?> From 94ea9f3c555b9ccb86fbd086019714efebafbbb4 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 13 Jan 2012 18:24:25 +0100 Subject: [PATCH 6/6] Fix: uniform code --- htdocs/user/class/user.class.php | 8 +++----- htdocs/user/group/fiche.php | 27 +++++++++++++-------------- htdocs/user/group/ldap.php | 14 ++++---------- 3 files changed, 20 insertions(+), 29 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index b1caeaba781..6fac46f76ea 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -95,11 +95,11 @@ class User extends CommonObject /** * Constructor de la classe * - * @param DoliDb $DB Database handler + * @param DoliDb $db Database handler */ - function User($DB) + function __construct($db) { - $this->db = $DB; + $this->db = $db; // Preference utilisateur $this->liste_limit = 0; @@ -107,8 +107,6 @@ class User extends CommonObject $this->all_permissions_are_loaded = 0; $this->admin=0; - - return 1; } /** diff --git a/htdocs/user/group/fiche.php b/htdocs/user/group/fiche.php index 9bf6c38b66b..9c26e7be32c 100644 --- a/htdocs/user/group/fiche.php +++ b/htdocs/user/group/fiche.php @@ -43,10 +43,10 @@ if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $langs->load("users"); $langs->load("other"); -$id=GETPOST("id"); -$action=GETPOST("action"); -$confirm=GETPOST("confirm"); -$userid=GETPOST("user","int"); +$id=GETPOST('id', 'int'); +$action=GETPOST('action', 'alpha'); +$confirm=GETPOST('confirm', 'alpha'); +$userid=GETPOST('user', 'int'); // Security check $result = restrictedArea($user, 'user', $id, 'usergroup&usergroup', 'user'); @@ -66,7 +66,7 @@ if ($action == 'confirm_delete' && $confirm == "yes") { if ($caneditperms) { - $object->fetch($_GET["id"]); + $object->fetch($id); $object->delete(); Header("Location: index.php"); exit; @@ -95,11 +95,10 @@ if ($action == 'add') if (! $message) { $object->nom = trim($_POST["nom"]); - if($conf->multicompany->enabled && !empty($conf->multicompany->transverse_mode)) - $object->entity = 0; - else - $object->entity = $_POST["entity"]; $object->note = trim($_POST["note"]); + + if($conf->multicompany->enabled && ! empty($conf->multicompany->transverse_mode)) $object->entity = 0; + else $object->entity = $_POST["entity"]; $db->begin(); @@ -176,11 +175,10 @@ if ($action == 'update') $object->oldcopy=dol_clone($object); $object->nom = trim($_POST["group"]); - if($conf->multicompany->enabled && !empty($conf->multicompany->transverse_mode)) - $object->entity = 0; - else - $object->entity = $_POST["entity"]; $object->note = dol_htmlcleanlastbr($_POST["note"]); + + if($conf->multicompany->enabled && !empty($conf->multicompany->transverse_mode)) $object->entity = 0; + else $object->entity = $_POST["entity"]; $ret=$object->update(); @@ -507,5 +505,6 @@ else llxFooter(); -if (is_object($db)) $db->close(); +$db->close(); + ?> diff --git a/htdocs/user/group/ldap.php b/htdocs/user/group/ldap.php index 4275fc08a79..69d21031574 100644 --- a/htdocs/user/group/ldap.php +++ b/htdocs/user/group/ldap.php @@ -40,12 +40,10 @@ if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS)) } $id = GETPOST('id', 'int'); +$action = GETPOST('action', 'alpha'); $socid=0; -if ($user->societe_id > 0) -{ - $socid = $user->societe_id; -} +if ($user->societe_id > 0) $socid = $user->societe_id; $fgroup = new Usergroup($db); $fgroup->fetch($id); @@ -56,7 +54,7 @@ $fgroup->getrights(); * Actions */ -if ($_GET["action"] == 'dolibarr2ldap') +if ($action == 'dolibarr2ldap') { $message=""; @@ -84,8 +82,6 @@ if ($_GET["action"] == 'dolibarr2ldap') } - - /* * View */ @@ -208,10 +204,8 @@ else print ''; - - +llxFooter(); $db->close(); -llxFooter(); ?>