From 03d43173020ef87fe0fdd7696ad64d02f755e831 Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Tue, 26 Oct 2021 18:26:36 +0200 Subject: [PATCH] add hook 'menuDropdownQuickaddItems' to manipulate dropdown menu --- htdocs/core/class/hookmanager.class.php | 1 + htdocs/main.inc.php | 319 +++++++++++------------- htdocs/theme/eldy/dropdown.inc.php | 10 +- 3 files changed, 158 insertions(+), 172 deletions(-) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index d1b1e08710e..82772418b36 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -195,6 +195,7 @@ class HookManager 'getFormatedSupplierRef', 'getIdProfUrl', 'getInputIdProf', + 'menuDropdownQuickaddItems', 'menuLeftMenuItems', 'moveUploadedFile', 'moreHtmlStatus', diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index dec6e389156..d15abb78098 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2264,185 +2264,16 @@ function top_menu_user($hideloginname = 0, $urllogout = '') */ function top_menu_quickadd() { - global $langs, $conf, $db, $hookmanager, $user; - global $menumanager; + global $langs; $html = ''; - // Define $dropDownQuickAddHtml - $dropDownQuickAddHtml = ''; - - $dropDownQuickAddHtml .= ''; $html .= ' '; $html .= ' @@ -2477,6 +2308,152 @@ function top_menu_quickadd() return $html; } +/** + * Generate list of quickadd items + * + * @return string HTML output + */ +function printDropdownQuickadd() +{ + global $conf, $user, $langs, $hookmanager; + + $items = array( + 'items' => array( + array( + "url" => "/societe/card.php?action=create", + "title" => "MenuNewThirdParty@companies", + "name" => "ThirdParty@companies", + "picto" => "object_company", + "activation" => !empty($conf->societe->enabled) && $user->rights->societe->creer, // vs hooking + "position" => 10, + ), + array( + "url" => "/contact/card.php?action=create", + "title" => "NewContactAddress@companies", + "name" => "Contact@companies", + "picto" => "object_contact", + "activation" => !empty($conf->societe->enabled) && $user->rights->societe->contact->creer, // vs hooking + "position" => 20, + ), + array( + "url" => "/comm/propal/card.php?action=create", + "title" => "NewPropal@propal", + "name" => "Proposal@propal", + "picto" => "object_propal", + "activation" => !empty($conf->propal->enabled) && $user->rights->propale->creer, // vs hooking + "position" => 30, + ), + + array( + "url" => "/commande/card.php?action=create", + "title" => "NewOrder@orders", + "name" => "Order@orders", + "picto" => "object_order", + "activation" => !empty($conf->commande->enabled) && $user->rights->commande->creer, // vs hooking + "position" => 40, + ), + array( + "url" => "/compta/facture/card.php?action=create", + "title" => "NewBill@bills", + "name" => "Bill@bills", + "picto" => "object_bill", + "activation" => !empty($conf->facture->enabled) && $user->rights->facture->creer, // vs hooking + "position" => 50, + ), + array( + "url" => "/compta/facture/card.php?action=create", + "title" => "NewContractSubscription@contracts", + "name" => "Contract@contracts", + "picto" => "object_contract", + "activation" => !empty($conf->contrat->enabled) && $user->rights->contrat->creer, // vs hooking + "position" => 60, + ), + array( + "url" => "/supplier_proposal/card.php?action=create", + "title" => "SupplierProposalNew@supplier_proposal", + "name" => "SupplierProposal@supplier_proposal", + "picto" => "object_propal", + "activation" => !empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->creer, // vs hooking + "position" => 70, + ), + array( + "url" => "/fourn/commande/card.php?action=create", + "title" => "NewSupplierOrderShort@orders", + "name" => "SupplierOrder@orders", + "picto" => "object_order", + "activation" => (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->creer) || (!empty($conf->supplier_order->enabled) && $user->rights->supplier_order->creer), // vs hooking + "position" => 80, + ), + array( + "url" => "/fourn/facture/card.php?action=create", + "title" => "NewBill@bills", + "name" => "SupplierBill@bills", + "picto" => "object_bill", + "activation" => (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->creer) || (!empty($conf->supplier_invoice->enabled) && $user->rights->supplier_invoice->creer), // vs hooking + "position" => 90, + ), + array( + "url" => "/product/card.php?action=create&type=0", + "title" => "NewProduct@products", + "name" => "Product@products", + "picto" => "object_product", + "activation" => !empty($conf->product->enabled) && $user->rights->produit->creer, // vs hooking + "position" => 100, + ), + array( + "url" => "/product/card.php?action=create&type=1", + "title" => "NewService@products", + "name" => "Service@products", + "picto" => "object_service", + "activation" => !empty($conf->service->enabled) && $user->rights->service->creer, // vs hooking + "position" => 110, + ), + ), + ); + + $dropDownQuickAddHtml = ''; + + // Define $dropDownQuickAddHtml + $dropDownQuickAddHtml .= ''; + + return $dropDownQuickAddHtml; +} + /** * Build the tooltip on top menu bookmark * diff --git a/htdocs/theme/eldy/dropdown.inc.php b/htdocs/theme/eldy/dropdown.inc.php index dcf7ca787b7..41622afc53c 100644 --- a/htdocs/theme/eldy/dropdown.inc.php +++ b/htdocs/theme/eldy/dropdown.inc.php @@ -423,7 +423,15 @@ a.top-menu-dropdown-link { .quickadd-body.dropdown-body { padding: unset; - padding-top: 15px; +} + +.quickadd-item { + padding-top: 6px; + padding-bottom: 6px; +} + +.quickadd-item:before { + content: none; } .quickadd-header {