From 31ae2f2a21dcc11ae02a9cded197449f76aab63b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josep=20Llu=C3=ADs?= Date: Thu, 22 Oct 2020 16:12:01 +0200 Subject: [PATCH 1/3] NEW form to add customer/supplier into categories Form to add customers and suppliers into categories, as in products --- htdocs/categories/viewcat.php | 68 ++++++++++++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 30b706a4b3a..79799e25aa6 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -5,6 +5,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2020 Tobias Sekan + * Copyright (C) 2020 Josep Lluís Amador * * 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 @@ -160,12 +161,29 @@ if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confi } } -if ($type == Categorie::TYPE_PRODUCT && $elemid && $action == 'addintocategory' && ($user->rights->produit->creer || $user->rights->service->creer)) +if ($elemid && $action == 'addintocategory' && + (($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) || + ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) || + ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) + )) { - require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $newobject = new Product($db); + if ($type == Categorie::TYPE_PRODUCT) + { + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + $newobject = new Product($db); + $elementtype = 'product'; + } elseif ($type == Categorie::TYPE_CUSTOMER) + { + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $newobject = new Societe($db); + $elementtype = 'customer'; + } elseif ($type == Categorie::TYPE_SUPPLIER) + { + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $newobject = new Societe($db); + $elementtype = 'supplier'; + } $result = $newobject->fetch($elemid); - $elementtype = 'product'; // TODO Add into categ $result = $object->add_type($newobject, $elementtype); @@ -513,6 +531,27 @@ if ($type == Categorie::TYPE_SUPPLIER) { dol_print_error($db, $object->error, $object->errors); } else { + // Form to add record into a category + $showclassifyform = 1; + if ($showclassifyform) + { + print '
'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $langs->trans("AddSupplierIntoCategory").'  '; + print $form->select_company('', 'elemid', 's.fournisseur = 1'); + print '
'; + print '
'; + } + print '
'; print ''; print ''; @@ -570,6 +609,27 @@ if ($type == Categorie::TYPE_CUSTOMER) { dol_print_error($db, $object->error, $object->errors); } else { + // Form to add record into a category + $showclassifyform = 1; + if ($showclassifyform) + { + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $langs->trans("AddCustomerIntoCategory").'  '; + print $form->select_company('', 'elemid', 's.client IN (1,3)'); + print '
'; + print '
'; + } + print '
'; print ''; print ''; From b5c2c6b755b2ad748dc7b06efb37f954a1b68d7e Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 22 Oct 2020 14:15:16 +0000 Subject: [PATCH 2/3] Fixing style errors. --- htdocs/categories/viewcat.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 79799e25aa6..4073cc9b689 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -161,7 +161,7 @@ if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confi } } -if ($elemid && $action == 'addintocategory' && +if ($elemid && $action == 'addintocategory' && (($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) || ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) || ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) @@ -177,7 +177,7 @@ if ($elemid && $action == 'addintocategory' && require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; $newobject = new Societe($db); $elementtype = 'customer'; - } elseif ($type == Categorie::TYPE_SUPPLIER) + } elseif ($type == Categorie::TYPE_SUPPLIER) { require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; $newobject = new Societe($db); From 89f00b91140e48cfad76b556d328c0a81ca8ce1a Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Thu, 22 Oct 2020 17:54:33 +0200 Subject: [PATCH 3/3] Fix user list when user module has extrafields --- htdocs/user/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/list.php b/htdocs/user/list.php index d02d647f96d..6da361a0d9d 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -311,7 +311,7 @@ $sql .= " u2.rowid as id2, u2.login as login2, u2.firstname as firstname2, u2.la $sql .= " s.nom as name, s.canvas"; // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key.', ' : ''); + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } // Add fields from hooks $parameters = array();