From 7363b39c1784207e51fdcd7bb088939fb26ddfa5 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 13 Jan 2012 17:40:52 +0100 Subject: [PATCH] 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(); ?>