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/2] 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/2] 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);