From 80cdcf4d62b1196f07b520f857b32011abe6b16d Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Sat, 26 Apr 2025 13:16:07 +0200 Subject: [PATCH] WIP Addapage to edit all categories. --- htdocs/categories/class/categorie.class.php | 3 +- htdocs/categories/index.php | 91 +++++++++++++-------- htdocs/core/lib/functions.lib.php | 32 ++++++-- htdocs/langs/en_US/categories.lang | 2 + htdocs/langs/en_US/website.lang | 1 + 5 files changed, 88 insertions(+), 41 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 576f81df118..9684d392b33 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -193,13 +193,14 @@ class Categorie extends CommonObject 'user' => 'Users', 'account' => 'Accounts', // old for bank account 'bank_account' => 'BankAccounts', + 'bank_line' => 'BankTransactions', 'project' => 'Projects', 'warehouse' => 'Warehouse', 'actioncomm' => 'AgendaEvents', 'website_page' => 'WebsitePages', 'ticket' => 'Tickets', 'knowledgemanagement' => 'KnowledgeRecords', - 'fichinter' => 'Fichinters', + 'fichinter' => 'Interventions', 'order' => 'Orders', 'invoice' => 'Invoices', 'supplier_order' => 'SuppliersOrders', diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index 31bc1ca0747..d9cb29746d4 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -45,21 +45,14 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Load translation files required by the page $langs->loadLangs(array("accountancy", "agenda", "banks", "bills", "categories", "contracts", "interventions")); -$langs->loadLangs(array("knowledgemanagement", "members", "orders", "products", "stocks", "suppliers", "tickets")); +$langs->loadLangs(array("knowledgemanagement", "members", "orders", "products", "stocks", "suppliers", "tickets", "website")); $mode = GETPOST('mode', 'aZ09'); if (empty($mode)) { $mode = 'hierarchy'; } -$id = GETPOSTINT('id'); -$type = (GETPOST('type', 'aZ09') ? GETPOST('type', 'aZ09') : Categorie::TYPE_PRODUCT); -$catname = GETPOST('catname', 'alpha'); -$nosearch = GETPOSTINT('nosearch'); $categstatic = new Categorie($db); -if (is_numeric($type)) { - $type = array_search($type, $categstatic->MAP_ID); // For backward compatibility -} // Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('categoryindex')); @@ -75,48 +68,78 @@ if (!$permissiontoread) { accessforbidden(); } -$nbtotalofrecords = 99; - /* * View */ $title = $langs->trans("Categories"); -$title .= ' ('.$langs->trans(empty(Categorie::$MAP_TYPE_TITLE_AREA[$type]) ? ucfirst($type) : Categorie::$MAP_TYPE_TITLE_AREA[$type]).')'; -// Output page -// -------------------------------------------------------------------- - llxHeader('', $title, '', '', 0, 0, '', ''); -print '
'; +print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', '', '', '', -1, 0, $categstatic->picto, 0, '', '', -1, 0, 1, 1); + +print ''; +print $langs->trans("CategorieListOfType").'
'; +print '
'; + +print '
'; + +print '
'; print ''; -print ''; -if ($nbofentries > 0) { - print ''; -} else { +print ''; +print ''; +print ''; +print ''; + +$arrayofcateg = array(); +foreach ($categstatic->MAP_ID as $key => $id) { + $arrayofcateg[$key]['key'] = $key; + $arrayofcateg[$key]['label'] = $langs->transnoentitiesnoconv($categstatic::$MAP_TYPE_TITLE_AREA[$key]); + $arrayofcateg[$key]['labelwithoutaccent'] = dol_string_unaccent($langs->transnoentitiesnoconv($categstatic::$MAP_TYPE_TITLE_AREA[$key])); +} + +$arrayofcateg = dol_sort_array($arrayofcateg, 'labelwithoutaccent', 'asc', 1); + +foreach ($arrayofcateg as $key => $val) { + $tmparray = getElementProperties($key); + + $classname = $tmparray['classname']; + $classpath = $tmparray['classpath']; + $classfile = $tmparray['classfile']; + $module = $tmparray['module']; + $fullpath = DOL_DOCUMENT_ROOT.'/'.$classpath.'/'.$classfile.'.class.php'; + + if (!isModEnabled($module)) { + continue; + } + print ''; - print ''; + print ''; + print ''; print ''; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 3c7a523dabb..30e23087e4e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1870,7 +1870,7 @@ function dol_sanitizeKeyCode($str) /** * Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName * - * @param string $str String to clean + * @param string $str String to clean. Must be an ascii or utf8 string without any htmlentities. * @return string Cleaned string * * @see dol_sanitizeFilename(), dol_string_nospecial() @@ -13711,6 +13711,11 @@ function getElementProperties($elementType) $module = 'bank'; // We need $conf->bank->dir_output and not $conf->banque->dir_output $classfile = 'account'; $classname = 'Account'; + } elseif ($elementType == 'bank_line') { + $classpath = 'compta/bank/class'; + $module = 'bank'; // We need $conf->bank->dir_output and not $conf->banque->dir_output + $classfile = 'account'; + $classname = 'AccountLine'; } elseif ($elementType == 'category') { $classpath = 'categories/class'; $module = 'categorie'; @@ -13730,7 +13735,7 @@ function getElementProperties($elementType) $classpath = 'product/inventory/class'; $table_element = 'inventorydet'; $parent_element = 'inventory'; - } elseif ($elementType == 'stock' || $elementType == 'entrepot') { + } elseif ($elementType == 'stock' || $elementType == 'entrepot' || $elementType == 'warehouse') { $module = 'stock'; $classpath = 'product/stock/class'; $classfile = 'entrepot'; @@ -13884,7 +13889,7 @@ function getElementProperties($elementType) $classpath = 'opensurvey/class'; $module = 'opensurvey'; $subelement = 'opensurveysondage'; - } elseif ($elementType == 'order_supplier' || $elementType == 'commande_fournisseur' || $elementType == 'commandefournisseur') { + } elseif ($elementType == 'order_supplier' || $elementType == 'supplier_order' ||$elementType == 'commande_fournisseur' || $elementType == 'commandefournisseur') { $classpath = 'fourn/class'; $module = 'fournisseur'; $classfile = 'fournisseur.commande'; @@ -13901,7 +13906,7 @@ function getElementProperties($elementType) $classname = 'CommandeFournisseurLigne'; $table_element = 'commande_fournisseurdet'; $parent_element = 'commande_fournisseur'; - } elseif ($elementType == 'invoice_supplier') { + } elseif ($elementType == 'invoice_supplier' || $elementType == 'supplier_invoice') { $classpath = 'fourn/class'; $module = 'fournisseur'; $classfile = 'fournisseur.facture'; @@ -13943,7 +13948,7 @@ function getElementProperties($elementType) $classfile = 'societeaccount'; $classname = 'SocieteAccount'; $module = 'societe'; - } elseif ($elementType == 'websitepage') { + } elseif ($elementType == 'websitepage' || $elementType == 'website_page') { $classpath = 'website/class'; $classfile = 'websitepage'; $classname = 'Websitepage'; @@ -13994,15 +13999,30 @@ function getElementProperties($elementType) $classname = 'Ecmfiles'; $table_element = 'ecmfiles'; $subelement = ''; - } elseif ($elementType == 'knowledgerecord') { + } elseif ($elementType == 'knowledgerecord' || $elementType == 'knowledgemanagement') { $module = ''; $classpath = 'knowledgemanagement/class'; $classfile = 'knowledgerecord'; $classname = 'KnowledgeRecord'; $table_element = 'knowledgemanagement_knowledgerecord'; $subelement = ''; + } elseif ($elementType == 'customer') { + $module = 'thirdparty'; + $classpath = 'societe/class'; + $classfile = 'client'; + $classname = 'Client'; + $table_element = 'societe'; + $subelement = ''; + } elseif ($elementType == 'fournisseur' || $elementType == 'supplier') { + $module = 'thirdparty'; + $classpath = 'fourn/class'; + $classfile = 'fournisseur'; + $classname = 'Fournisseur'; + $table_element = 'societe'; + $subelement = ''; } + if (empty($classfile)) { $classfile = strtolower($subelement); } diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index 44b56551380..3e2e24d7c32 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -100,3 +100,5 @@ ChooseCategory=Choose category UseOrOperatorForCategories=Use 'OR' operator for categories AddObjectIntoCategory=Assign to the category AddTicketIntoCategory=Assign the category to the ticket +CategorieListOfType=Select the type of the categories/tags you want to view or edit +NumberOfCategories=Number of tags/categories diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 58a0a10234e..a90852280ff 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -30,6 +30,7 @@ EditPageMeta=Edit page/container properties EditInLine=Edit inline AddWebsite=Add website WebsitePage=Website page +WebsitePages=Website pages Webpage=Web page/container AddPage=Add page/container PageContainer=Page
'.$langs->trans("Categories").''; -if ($morethan1level && !empty($conf->use_javascript_ajax)) { - print ''; -} -print '
'; - tree_recur($data, $data[0], 0); - print '
'.$langs->trans("Type").''.$langs->trans("NumberOfCategories").'
'; - print ''; - print ''; - print '
'.img_picto_common('', 'treemenu/branchbottom.gif').''; - print $langs->trans("NoCategoryYet"); + print ''; + + $tmpobject = null; + include_once $fullpath; + if (class_exists($classname)) { + $tmpobject = new $classname($db); + } + //print "key=".$key." fullpath=".$fullpath." classname=".$classname." classpath=".$classpath." classfile=".$classfile; + + if ($tmpobject) { + print img_picto('', $tmpobject->picto, 'class="pictofixedwidth"'); + } else { + print img_picto('', 'generic', 'class="pictofixedwidth"'); + } + print dolPrintHTML($arrayofcateg[$key]['label']); print ' 
'; + $nb = 'todo'; + print $nb; + print ''.img_picto('', 'edit').'