From c34fa11aab041e40040205243b6afcad4493fe6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Thu, 14 Nov 2024 07:33:35 +0100 Subject: [PATCH 1/8] NEW : Add category feature on Fichinter category update --- htdocs/categories/class/categorie.class.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index f35422605899c..3ba50050af18d 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -9,7 +9,7 @@ * Copyright (C) 2013-2018 Philippe Grand * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Raphaël Doursenaud - * Copyright (C) 2016 Charlie Benke + * Copyright (C) 2016-2024 Charlene Benke * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2023-2024 Benjamin Falière * Copyright (C) 2024 MDW @@ -62,6 +62,7 @@ class Categorie extends CommonObject const TYPE_WEBSITE_PAGE = 'website_page'; const TYPE_TICKET = 'ticket'; const TYPE_KNOWLEDGEMANAGEMENT = 'knowledgemanagement'; + const TYPE_TICKET = 'fichinter'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -86,7 +87,8 @@ class Categorie extends CommonObject 'actioncomm' => 10, 'website_page' => 11, 'ticket' => 12, - 'knowledgemanagement' => 13 + 'knowledgemanagement' => 13, + 'fichinter' => 14 ); /** @@ -108,7 +110,8 @@ class Categorie extends CommonObject 10 => 'actioncomm', 11 => 'website_page', 12 => 'ticket', - 13 => 'knowledgemanagement' + 13 => 'knowledgemanagement', + 14 => 'fichinter' ); /** @@ -153,7 +156,8 @@ class Categorie extends CommonObject 'actioncomm' => 'ActionComm', 'website_page' => 'WebsitePage', 'ticket' => 'Ticket', - 'knowledgemanagement' => 'KnowledgeRecord' + 'knowledgemanagement' => 'KnowledgeRecord', + 'fichinter' => 'Fichinter', ); /** @@ -175,7 +179,8 @@ class Categorie extends CommonObject 'actioncomm' => 'ActioncommCategoriesArea', 'website_page' => 'WebsitePageCategoriesArea', 'ticket' => 'TicketCategoriesArea', - 'knowledgemanagement' => 'KnowledgemanagementCategoriesArea' + 'knowledgemanagement' => 'KnowledgemanagementCategoriesArea', + 'fichinter' => 'FichinterCategoriesArea' ); /** @@ -190,7 +195,8 @@ class Categorie extends CommonObject 'account' => 'bank_account', // old for bank account 'project' => 'projet', 'warehouse' => 'entrepot', - 'knowledgemanagement' => 'knowledgemanagement_knowledgerecord' + 'knowledgemanagement' => 'knowledgemanagement_knowledgerecord', + 'fichinter' => 'fichinter' ); /** @@ -695,6 +701,7 @@ public function delete($user, $notrigger = 0) 'categorie_contact' => 'fk_categorie', 'categorie_fournisseur' => 'fk_categorie', 'categorie_knowledgemanagement' => array('field' => 'fk_categorie', 'enabled' => isModEnabled('knowledgemanagement')), + 'categorie_fichinter' => array('field' => 'fk_categorie', 'enabled' => isModEnabled('ficheinter')), 'categorie_member' => 'fk_categorie', 'categorie_user' => 'fk_categorie', 'categorie_product' => 'fk_categorie', From 0d1098edd429cb75431b230a85021eb7d9957842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Thu, 14 Nov 2024 07:41:32 +0100 Subject: [PATCH 2/8] Update viewcat.php --- htdocs/categories/viewcat.php | 94 +++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 99e8c805056d7..e6cafa1f9360f 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -9,6 +9,7 @@ * Copyright (C) 2024 MDW * Copyright (C) 2024 Frédéric France * Copyright (C) 2024 Alexandre Spangaro + * Copyright (C) 2023-2024 Charlene Benke * * 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 @@ -165,6 +166,11 @@ $tmpobject = new Ticket($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'ticket'; + } elseif ($type == Categorie::TYPE_FICHINTER && $user->hasRight('ficheinter', 'write')) { + require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; + $tmpobject = new Fichinter($db); + $result = $tmpobject->fetch($removeelem); + $elementtype = 'fichinter'; } $result = $object->del_type($tmpobject, $elementtype); @@ -196,6 +202,7 @@ ($type == Categorie::TYPE_MEMBER && $user->hasRight('adherent', 'creer')) || ($type == Categorie::TYPE_CONTACT && $user->hasRight('societe', 'creer')) || ($type == Categorie::TYPE_USER && $user->hasRight('user', 'user', 'creer')) || + ($type == Categorie::TYPE_FICHINTER && $user->hasRight('ficheinter', 'write')) || ($type == Categorie::TYPE_ACCOUNT && $user->hasRight('banque', 'configurer')) ) { $newobject = null; @@ -215,6 +222,10 @@ require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php'; $newobject = new Ticket($db); $elementtype = 'ticket'; + } elseif ($type == Categorie::TYPE_FICHINTER) { + require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; + $newobject = new Fichinter($db); + $elementtype = 'fichinter'; } elseif ($type == Categorie::TYPE_PROJECT) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $newobject = new Project($db); @@ -1322,6 +1333,89 @@ } } +// List of Fichinter +if ($type == Categorie::TYPE_FICHINTER) { + if ($user->hasRight("fichinter", "lire")) { + $permission = ($user->rights->categorie->creer || $user->rights->categorie->creer); + + $fichinters = $object->getObjectsInCateg($type, 0, $limit, $offset); + if ($fichinters < 0) { + dol_print_error($db, $object->error, $object->errors); + } else { + // Form to add record into a category + $showclassifyform = 1; + if ($showclassifyform) { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formintervention.class.php'; + $formfichinter = new FormIntervention($db); + + print '
'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $langs->trans("AddFichinterIntoCategory").'  '; + print $formfichinter->select_interventions('', '', 'elemid'); + print '
'; + print '
'; + } + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'; + $param = '&limit='.$limit.'&id='.$id.'&type='.$type; + $num = count($fichinters); + $nbtotalofrecords = ''; + $newcardbutton = ''; + + print_barre_liste($langs->trans("FichInter"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_intervention', 0, $newcardbutton, '', $limit); + print ''."\n"; + print ''."\n"; + + if (count($fichinters) > 0) { + $i = 0; + foreach ($fichinters as $fichinter) { + $i++; + if ($i > $limit) break; + + print "\t".''."\n"; + print '\n"; + print '\n"; + // Link to delete from category + print ''; + print "\n"; + } + } else { + print ''; + } + print "
'.$langs->trans("Ref").'
'; + print $fichinter->getNomUrl(1); + print "'.$fichinter->description."'; + if ($permission) { + print "id."'>"; + print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); + print ""; + } + print '
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; + print '
'."\n"; + } + } else { + print_barre_liste($langs->trans("FichInter"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'fichinter'); + accessforbidden("NotEnoughPermissions", 0, 0); + } +} + // Note that $action and $object may have been modified by some hooks $parameters = array('type' => $type, 'id' => $id, 'label' => $label); $reshook = $hookmanager->executeHooks('addMoreCategoriesList', $parameters, $object, $action); From 3222fa90d057fe3069d5abbb682c7e01717ed856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Thu, 14 Nov 2024 07:44:36 +0100 Subject: [PATCH 3/8] Update categories.lang --- htdocs/langs/en_US/categories.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index 640e360eebb7e..c7c98b5a56f6e 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -93,6 +93,7 @@ CategorieRecursivHelp=If option is on, when you add an object into a subcategory AddProductServiceIntoCategory=Assign category to the product/service AddCustomerIntoCategory=Assign category to customer AddSupplierIntoCategory=Assign category to supplier +AddFichinterIntoCategory=Assign category to interventional AssignCategoryTo=Assign category to ShowCategory=Show tag/category ByDefaultInList=By default in list From 4c8fcfe4b2259b70e30dc72d768117b4e5465362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Thu, 14 Nov 2024 07:58:14 +0100 Subject: [PATCH 4/8] Update categorie.class.php --- htdocs/categories/class/categorie.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 3ba50050af18d..8e78ed539e950 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -62,7 +62,7 @@ class Categorie extends CommonObject const TYPE_WEBSITE_PAGE = 'website_page'; const TYPE_TICKET = 'ticket'; const TYPE_KNOWLEDGEMANAGEMENT = 'knowledgemanagement'; - const TYPE_TICKET = 'fichinter'; + const TYPE_FICHINTER = 'fichinter'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png From 9140ddcdbcb0ae58c0fc8b74fb3a453e479d7750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Thu, 14 Nov 2024 08:01:07 +0100 Subject: [PATCH 5/8] Update categories.lang --- htdocs/langs/en_US/categories.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index c7c98b5a56f6e..41aaaa3844e41 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -94,6 +94,7 @@ AddProductServiceIntoCategory=Assign category to the product/service AddCustomerIntoCategory=Assign category to customer AddSupplierIntoCategory=Assign category to supplier AddFichinterIntoCategory=Assign category to interventional +Intervention=Intervention AssignCategoryTo=Assign category to ShowCategory=Show tag/category ByDefaultInList=By default in list From ea1e0b2d3c38740cf97a6d9483649a41a86c8b62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Thu, 14 Nov 2024 08:01:44 +0100 Subject: [PATCH 6/8] Update viewcat.php --- 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 e6cafa1f9360f..efa007fd879a1 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -1378,7 +1378,7 @@ $nbtotalofrecords = ''; $newcardbutton = ''; - print_barre_liste($langs->trans("FichInter"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_intervention', 0, $newcardbutton, '', $limit); + print_barre_liste($langs->trans("Intervention"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_intervention', 0, $newcardbutton, '', $limit); print ''."\n"; print ''."\n"; @@ -1411,7 +1411,7 @@ print ''."\n"; } } else { - print_barre_liste($langs->trans("FichInter"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'fichinter'); + print_barre_liste($langs->trans("Intervention"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'fichinter'); accessforbidden("NotEnoughPermissions", 0, 0); } } From cbe4db0f2adcc0831b07501ce975a6b0c5cf1fff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Thu, 14 Nov 2024 08:28:54 +0100 Subject: [PATCH 7/8] Update viewcat.php --- htdocs/categories/viewcat.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index efa007fd879a1..513af4aa6257c 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -1415,7 +1415,7 @@ accessforbidden("NotEnoughPermissions", 0, 0); } } - + // Note that $action and $object may have been modified by some hooks $parameters = array('type' => $type, 'id' => $id, 'label' => $label); $reshook = $hookmanager->executeHooks('addMoreCategoriesList', $parameters, $object, $action); From 91510e144844732aa41bedb8b81db89e12492c8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 16 Nov 2024 15:55:49 +0100 Subject: [PATCH 8/8] Update viewcat.php --- htdocs/categories/viewcat.php | 70 +++++++++++++++++------------------ 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 513af4aa6257c..e9cdd05f703c5 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -555,16 +555,16 @@ // @phan-suppress-next-line PhanPluginSuspiciousParamOrder print_barre_liste($langs->trans("ProductsAndServices"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'products', 0, $newcardbutton, '', $limit); - $showclassifyform = 1; - if ($showclassifyform) { - print '
'.$langs->trans("Ref").'
'; - print ''; - print ''; - print '
'; - print $langs->trans("AddProductServiceIntoCategory").'  '; - $form->select_produits(0, 'elemid', '', 0, 0, -1, 2, '', 1, array(), 0, 1, 0, '', 0, '', null); - print '
'; - } + // $showclassifyform = 1; + // if ($showclassifyform) { + print ''; + print ''; + print ''; + print '
'; + print $langs->trans("AddProductServiceIntoCategory").'  '; + $form->select_produits(0, 'elemid', '', 0, 0, -1, 2, '', 1, array(), 0, 1, 0, '', 0, '', null); + print '
'; + // } print ''."\n"; print ''."\n"; @@ -1336,34 +1336,34 @@ // List of Fichinter if ($type == Categorie::TYPE_FICHINTER) { if ($user->hasRight("fichinter", "lire")) { - $permission = ($user->rights->categorie->creer || $user->rights->categorie->creer); + $permission = $user->hasRight('categorie', 'creer');; $fichinters = $object->getObjectsInCateg($type, 0, $limit, $offset); if ($fichinters < 0) { dol_print_error($db, $object->error, $object->errors); } else { // Form to add record into a category - $showclassifyform = 1; - if ($showclassifyform) { - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formintervention.class.php'; - $formfichinter = new FormIntervention($db); - - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'.$langs->trans("Ref").'
'; - print ''; - print ''; - print '
'; - print $langs->trans("AddFichinterIntoCategory").'  '; - print $formfichinter->select_interventions('', '', 'elemid'); - print '
'; - print ''; - } + // $showclassifyform = 1; + // if ($showclassifyform) { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formintervention.class.php'; + $formfichinter = new FormIntervention($db); + + print '
'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $langs->trans("AddFichinterIntoCategory").'  '; + print $formfichinter->select_interventions('', '', 'elemid'); + print '
'; + print '
'; + // } print '
'; print ''; @@ -1397,8 +1397,8 @@ print ''; if ($permission) { print "id."'>"; - print $langs->trans("DeleteFromCat"); - print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); + //print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft'); print ""; } print ''; @@ -1411,7 +1411,7 @@ print '
'."\n"; } } else { - print_barre_liste($langs->trans("Intervention"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'fichinter'); + print_barre_liste($langs->trans("Intervention"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'fichinter'); accessforbidden("NotEnoughPermissions", 0, 0); } }