diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php
index a40ec3e30c3..5f87d81db9d 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 fbcfbe026d7..dc8b49c775f 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -2313,185 +2313,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 .= '';
- $dropDownQuickAddHtml .= '
';
- if (!empty($conf->societe->enabled) && $user->rights->societe->creer) {
- $langs->load("companies");
- $dropDownQuickAddHtml .= '
-
-
- ';
- }
-
- if (!empty($conf->societe->enabled) && $user->rights->societe->contact->creer) {
- $langs->load("companies");
- $dropDownQuickAddHtml .= '
-
-
- ';
- }
-
- if (!empty($conf->propal->enabled) && $user->rights->propale->creer) {
- $langs->load("propal");
- $dropDownQuickAddHtml .= '
-
-
- ';
- }
-
- if (!empty($conf->commande->enabled) && $user->rights->commande->creer) {
- $langs->load("orders");
- $dropDownQuickAddHtml .= '
-
-
- ';
- }
-
- if (!empty($conf->facture->enabled) && $user->rights->facture->creer) {
- $langs->load("bills");
- $dropDownQuickAddHtml .= '
-
-
- ';
- }
-
- if (!empty($conf->contrat->enabled) && $user->rights->contrat->creer) {
- $langs->load("contracts");
- $dropDownQuickAddHtml .= '
-
-
- ';
- }
-
- if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->creer) {
- $langs->load("supplier_proposal");
- $dropDownQuickAddHtml .= '
-
-
- ';
- }
-
- if ((!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)) {
- $langs->load("orders");
- $dropDownQuickAddHtml .= '
-
-
- ';
- }
-
- if ((!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)) {
- $langs->load("bills");
- $dropDownQuickAddHtml .= '
-
-
- ';
- }
-
- if (!empty($conf->product->enabled) && $user->rights->produit->creer) {
- $langs->load("products");
- $dropDownQuickAddHtml .= '
-
-
- ';
- }
-
- if (!empty($conf->service->enabled) && $user->rights->service->creer) {
- $langs->load("products");
- $dropDownQuickAddHtml .= '
-
-
- ';
- }
-
- if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->creer) {
- $langs->load("trips");
- $dropDownQuickAddHtml .= '
-
-
- ';
- }
-
- if (!empty($conf->holiday->enabled) && $user->rights->holiday->write) {
- $langs->load("holiday");
- $dropDownQuickAddHtml .= '
-
-
- ';
- }
-
- // Execute hook printTopRightMenu (hooks should output string like '
')
- $parameters = array();
- $result = $hookmanager->executeHooks('printQuickAddBlock', $parameters); // Note that $action and $object may have been modified by some hooks
- if (is_numeric($result)) {
- if ($result == 0) {
- $dropDownQuickAddHtml .= $hookmanager->resPrint; // add
- } else {
- $dropDownQuickAddHtml = $hookmanager->resPrint; // replace
- }
- } else {
- $dropDownQuickAddHtml .= $result; // For backward compatibility
- }
-
- $dropDownQuickAddHtml .= '
';
- $dropDownQuickAddHtml .= '
';
$html .= '
';
$html .= '
@@ -2526,6 +2357,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 .= '';
+ $dropDownQuickAddHtml .= '
';
+
+ // Allow the $items of the menu to be manipulated by modules
+ $parameters = array();
+ $hook_items = $items;
+ $reshook = $hookmanager->executeHooks('menuDropdownQuickaddItems', $parameters, $hook_items); // Note that $action and $object may have been modified by some hooks
+ if (is_numeric($reshook) && is_array($hookmanager->results)) {
+ if ($reshook == 0) {
+ $items['items'] = array_merge($items['items'], $hookmanager->results); // add
+ } else {
+ $items = $hookmanager->results; // replace
+ }
+
+ // Sort menu items by 'position' value
+ $position = array();
+ foreach ($items['items'] as $key => $row) {
+ $position[$key] = $row['position'];
+ }
+ array_multisort($position, SORT_ASC, $items['items']);
+ }
+
+ foreach ($items['items'] as $item) {
+ if (!$item['activation']) {
+ continue;
+ }
+ $langs->load(explode('@', $item['title'])[1]);
+ $langs->load(explode('@', $item['name'])[1]);
+ $dropDownQuickAddHtml .= '
+
+ '. img_picto('', $item['picto'], 'style="width:18px;"') . ' ' . $langs->trans(explode('@', $item['name'])[0]) . '
+ ';
+ }
+
+ $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 5e0b019a850..242250c8835 100644
--- a/htdocs/theme/eldy/dropdown.inc.php
+++ b/htdocs/theme/eldy/dropdown.inc.php
@@ -433,7 +433,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 {