From 0d853cf73d83af2730c24419dfb588785acaa7fe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Nov 2013 02:49:22 +0100 Subject: [PATCH 1/3] Fix: [ bug #1118 ] Minor problem on print page link --- htdocs/main.inc.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index a8fc47ba413..7d1c9e310de 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1442,8 +1442,9 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a // Link to print main content area if (empty($conf->global->MAIN_PRINT_DISABLELINK) && empty($conf->browser->phone)) { - $qs=$_SERVER["QUERY_STRING"].($_SERVER["QUERY_STRING"]?'&':'').$morequerystring; - $text =''; + $qs=$_SERVER["QUERY_STRING"]; + $qs.=(($qs && $morequerystring)?'&':'').$morequerystring; + $text =''; $text.= img_picto('', 'printer.png', 'class="printer"'); $text.=''; $toprightmenu.=$form->textwithtooltip('',$langs->trans("PrintContentArea"),2,1,$text,'',1); From 00b0031ddfdf7976b11e3ce20531fabb4590ef3e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Nov 2013 16:26:56 +0100 Subject: [PATCH 2/3] Fix: If no permission to edit object, form to change category must be hidden Fix: Adding supplier category was saved into wrong table. --- htdocs/categories/categorie.php | 79 +++++++++++---------- htdocs/categories/class/categorie.class.php | 20 ++++-- 2 files changed, 56 insertions(+), 43 deletions(-) diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php index 4fef3184c20..6aa063a9b4e 100644 --- a/htdocs/categories/categorie.php +++ b/htdocs/categories/categorie.php @@ -118,7 +118,8 @@ if (empty($reshook)) } if ($type==1 && $user->rights->societe->creer) { - $object = new Societe($db); + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; + $object = new Fournisseur($db); $result = $object->fetch($objectid); $elementtype = 'fournisseur'; } @@ -152,7 +153,7 @@ if (empty($reshook)) setEventMessage($cat->errors,'errors'); } } - + // Add object into a category if ($parent > 0) { @@ -165,7 +166,8 @@ if (empty($reshook)) } if ($type==1 && $user->rights->societe->creer) { - $object = new Societe($db); + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; + $object = new Fournisseur($db); $result = $object->fetch($objectid); $elementtype = 'fournisseur'; } @@ -319,11 +321,11 @@ if ($socid) dol_fiche_end(); - if ($soc->client) formCategory($db,$soc,2,$socid); + if ($soc->client) formCategory($db,$soc,2,$socid,$user->rights->societe->creer); if ($soc->client && $soc->fournisseur) print '

'; - if ($soc->fournisseur) formCategory($db,$soc,1,$socid); + if ($soc->fournisseur) formCategory($db,$soc,1,$socid,$user->rights->societe->creer); } else if ($id || $ref) { @@ -377,7 +379,7 @@ else if ($id || $ref) dol_fiche_end(); - formCategory($db,$product,0); + formCategory($db,$product,0,($user->rights->produit->creer || $user->rights->service->creer)); } if ($type == 3) @@ -456,7 +458,7 @@ else if ($id || $ref) dol_fiche_end(); - formCategory($db,$member,3); + formCategory($db,$member,3,0,$user->rights->adherent->creer); } if ($type == 4) { @@ -602,7 +604,7 @@ else if ($id || $ref) dol_fiche_end(); - formCategory($db,$object,4); + formCategory($db,$object,4,$user->rights->societe->creer); } } @@ -610,13 +612,14 @@ else if ($id || $ref) /** * Function to output a form to add object into a category * - * @param DoliDb $db Database handler - * @param Object $object Object we want to see categories it can be classified into - * @param int $typeid Type of category (0, 1, 2, 3) - * @param int $socid Id thirdparty + * @param DoliDb $db Database handler + * @param Object $object Object we want to see categories it can be classified into + * @param int $typeid Type of category (0, 1, 2, 3) + * @param int $socid Id thirdparty + * @param string $showclassifyform 1=Add form to 'Classify', 0=Do not show form to 'Classify' * @return int 0 */ -function formCategory($db,$object,$typeid,$socid=0) +function formCategory($db,$object,$typeid,$socid=0,$showclassifyform=1) { global $user,$langs,$form,$bc; @@ -626,33 +629,37 @@ function formCategory($db,$object,$typeid,$socid=0) if ($typeid == 3) $title = $langs->trans("MembersCategoriesShort"); if ($typeid == 4) $title = $langs->trans("ContactCategoriesShort"); - // Form to add record into a category print '
'; print_fiche_titre($title,'',''); - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if ($user->rights->categorie->creer) + + // Form to add record into a category + if ($showclassifyform) { - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; - print $langs->trans("ClassifyInCategory").'  '; - print $form->select_all_categories($typeid,'auto'); - print ''; - print ''; - print 'id.'&type='.$typeid).'">'; - print $langs->trans("CreateCat").' '; - print img_picto($langs->trans("Create"),'filenew'); - print ""; - print '
'; + print ''; + if ($user->rights->categorie->creer) + { + print ''; + } + print ''; + print '
'; + print $langs->trans("ClassifyInCategory").'  '; + print $form->select_all_categories($typeid,'auto'); + print ''; + print ''; + print 'id.'&type='.$typeid).'">'; + print $langs->trans("CreateCat").' '; + print img_picto($langs->trans("Create"),'filenew'); + print ""; + print '
'; + print '
'; + print '
'; } - print ''; - print ''; - print ''; - print '
'; $c = new Categorie($db); diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index b6d5c622e9c..4ab19b7f915 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -386,7 +386,7 @@ class Categorie * Link an object to the category * * @param Object $obj Object to link to category - * @param string $type Type of category (member, supplier, product, customer, contact) + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') * @return int 1 : OK, -1 : erreur SQL, -2 : id not defined, -3 : Already linked */ function add_type($obj,$type) @@ -397,11 +397,14 @@ class Categorie if ($this->id == -1) return -2; - if ($type == 'company') $type='societe'; - if ($type == 'fournisseur') $type='societe'; + // For backward compatibility + if ($type == 'company') $type='societe'; + if ($type == 'customer') $type='societe'; + if ($type == 'supplier') $type='fournisseur'; $column_name=$type; if ($type=='contact') $column_name='socpeople'; + if ($type=='fournisseur') $column_name='societe'; $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".$type." (fk_categorie, fk_".$column_name.")"; $sql .= " VALUES (".$this->id.", ".$obj->id.")"; @@ -479,7 +482,7 @@ class Categorie * Delete object from category * * @param Object $obj Object - * @param string $type Type + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') * @return int 1 if OK, -1 if KO */ function del_type($obj,$type) @@ -488,12 +491,15 @@ class Categorie $error=0; - if ($type == 'company') $type='societe'; - if ($type == 'fournisseur') $type='societe'; + // For backward compatibility + if ($type == 'company') $type='societe'; + if ($type == 'customer') $type='societe'; + if ($type == 'supplier') $type='fournisseur'; $column_name=$type; if ($type=='contact') $column_name='socpeople'; - + if ($type=='fournisseur') $column_name='societe'; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_".$type; $sql .= " WHERE fk_categorie = ".$this->id; $sql .= " AND fk_".$column_name." = ".$obj->id; From 29e029161f77c92bb488fa00bad45004b7c2a3cb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Nov 2013 18:41:06 +0100 Subject: [PATCH 3/3] Fix: Restore translation lost because entry was not set into en_US lang. --- htdocs/langs/en_US/main.lang | 1 + htdocs/langs/fr_FR/main.lang | 1 + htdocs/langs/fr_FR/orders.lang | 1 - 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 4f5485eb226..6876d0c6b2b 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -656,6 +656,7 @@ Deductible=Deductible from=from toward=toward Access=Access +SetDemandReason=Set source # Week day Monday=Monday diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index dcb72b22cad..f642fe4c9b5 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -654,6 +654,7 @@ Deductible=Déductible from=de toward=vers Access=Accès +SetDemandReason=Définir l'origine # Week day Monday=Lundi diff --git a/htdocs/langs/fr_FR/orders.lang b/htdocs/langs/fr_FR/orders.lang index 045b6223038..f0da79c799d 100644 --- a/htdocs/langs/fr_FR/orders.lang +++ b/htdocs/langs/fr_FR/orders.lang @@ -144,7 +144,6 @@ OrderSource5=Commercial OrderSource6=Magasin QtyOrdered=Qté commandée AddDeliveryCostLine=Ajouter une ligne de frais port indiquant le poids de la commande -SetDemandReason=Définir l'origine de la commande # Document models PDFEinsteinDescription=Modèle de commande complet (logo...)