From 5690b7d59543cabe129887b1681827df23334a8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 20 Sep 2022 10:14:11 +0200 Subject: [PATCH 1/7] add badges --- htdocs/core/lib/member.lib.php | 18 +++++++++++++++--- htdocs/core/lib/order.lib.php | 32 ++++++++++++++++++++++---------- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/htdocs/core/lib/member.lib.php b/htdocs/core/lib/member.lib.php index 677d8cfdaef..64c0d429048 100644 --- a/htdocs/core/lib/member.lib.php +++ b/htdocs/core/lib/member.lib.php @@ -20,8 +20,8 @@ */ /** - * \file htdocs/core/lib/member.lib.php - * \brief Functions for module members + * \file htdocs/core/lib/member.lib.php + * \brief Functions for module members */ /** @@ -182,7 +182,11 @@ function member_type_prepare_head(AdherentType $object) */ function member_admin_prepare_head() { - global $langs, $conf, $user; + global $langs, $conf, $user, $db; + + $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label('adherent'); + $extrafields->fetch_name_optionals_label('adherent_type'); $h = 0; $head = array(); @@ -205,11 +209,19 @@ function member_admin_prepare_head() $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/member_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsMember"); + $nbExtrafields = $extrafields->attributes['adherent']['count']; + if ($nbExtrafields > 0) { + $head[$h][1] .= ' '.$nbExtrafields.''; + } $head[$h][2] = 'attributes'; $h++; $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/member_type_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsMemberType"); + $nbExtrafields = $extrafields->attributes['adherent_type']['count']; + if ($nbExtrafields > 0) { + $head[$h][1] .= ' '.$nbExtrafields.''; + } $head[$h][2] = 'attributes_type'; $h++; diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php index 9128be56ea1..174ec36834b 100644 --- a/htdocs/core/lib/order.lib.php +++ b/htdocs/core/lib/order.lib.php @@ -42,7 +42,7 @@ function commande_prepare_head(Commande $object) $h = 0; $head = array(); - if (isModEnabled('commande') && $user->rights->commande->lire) { + if (isModEnabled('commande') && $user->hasRight('commande', 'lire')) { $head[$h][0] = DOL_URL_ROOT.'/commande/card.php?id='.$object->id; $head[$h][1] = $langs->trans("CustomerOrder"); $head[$h][2] = 'order'; @@ -61,27 +61,27 @@ function commande_prepare_head(Commande $object) } if ((isModEnabled('expedition_bon') && $user->hasRight('expedition', 'lire')) - || ($conf->delivery_note->enabled && $user->hasRight('expedition', 'delivery', 'lire'))) { + || (isModEnabled('delivery_note') && $user->hasRight('expedition', 'delivery', 'lire'))) { $nbShipments = $object->getNbOfShipments(); $nbReceiption = 0; $head[$h][0] = DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id; $text = ''; - if ($conf->expedition_bon->enabled) { + if (isModEnabled('expedition_bon')) { $text .= $langs->trans("Shipments"); } - if ($conf->expedition_bon->enabled && $conf->delivery_note->enabled) { + if (isModEnabled('expedition_bon') && isModEnabled('delivery_note')) { $text .= ' - '; } - if ($conf->delivery_note->enabled) { + if (isModEnabled('delivery_note')) { $text .= $langs->trans("Receivings"); } if ($nbShipments > 0 || $nbReceiption > 0) { $text .= ''.($nbShipments ? $nbShipments : 0); } - if ($conf->expedition_bon->enabled && $conf->delivery_note->enabled && ($nbShipments > 0 || $nbReceiption > 0)) { + if (isModEnabled('expedition_bon') && isModEnabled('delivery_note') && ($nbShipments > 0 || $nbReceiption > 0)) { $text .= ' - '; } - if ($conf->expedition_bon->enabled && $conf->delivery_note->enabled && ($nbShipments > 0 || $nbReceiption > 0)) { + if (isModEnabled('expedition_bon') && isModEnabled('delivery_note') && ($nbShipments > 0 || $nbReceiption > 0)) { $text .= ($nbReceiption ? $nbReceiption : 0); } if ($nbShipments > 0 || $nbReceiption > 0) { @@ -145,7 +145,11 @@ function commande_prepare_head(Commande $object) */ function order_admin_prepare_head() { - global $langs, $conf, $user; + global $langs, $conf, $user, $db; + + $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label('commande'); + $extrafields->fetch_name_optionals_label('commandedet'); $h = 0; $head = array(); @@ -159,11 +163,19 @@ function order_admin_prepare_head() $head[$h][0] = DOL_URL_ROOT.'/admin/order_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields"); + $nbExtrafields = $extrafields->attributes['commande']['count']; + if ($nbExtrafields > 0) { + $head[$h][1] .= ' '.$nbExtrafields.''; + } $head[$h][2] = 'attributes'; $h++; $head[$h][0] = DOL_URL_ROOT.'/admin/orderdet_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsLines"); + $nbExtrafields = $extrafields->attributes['commandedet']['count']; + if ($nbExtrafields > 0) { + $head[$h][1] .= ' '.$nbExtrafields.''; + } $head[$h][2] = 'attributeslines'; $h++; @@ -186,7 +198,7 @@ function getCustomerOrderPieChart($socid = 0) $result = ''; - if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) { + if (!isModEnabled('commande') || !$user->hasRight('commande', 'lire')) { return ''; } @@ -276,7 +288,7 @@ function getCustomerOrderPieChart($socid = 0) $result .= "\n"; } } - if ($conf->use_javascript_ajax) { + if (!empty($conf->use_javascript_ajax)) { $result .= ''; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; From ffddce4656100523a26f56220734ef3f3b598d9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 21 Sep 2022 13:49:36 +0200 Subject: [PATCH 2/7] add badges --- htdocs/core/lib/categories.lib.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/categories.lib.php b/htdocs/core/lib/categories.lib.php index 8ff1dbb97ae..7d77b345d61 100644 --- a/htdocs/core/lib/categories.lib.php +++ b/htdocs/core/lib/categories.lib.php @@ -80,7 +80,10 @@ function categories_prepare_head(Categorie $object, $type) */ function categoriesadmin_prepare_head() { - global $langs, $conf, $user; + global $langs, $conf, $user, $db; + + $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label('categorie'); $langs->load("categories"); @@ -94,6 +97,10 @@ function categoriesadmin_prepare_head() $head[$h][0] = DOL_URL_ROOT.'/categories/admin/categorie_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsCategories"); + $nbExtrafields = $extrafields->attributes['categorie']['count']; + if ($nbExtrafields > 0) { + $head[$h][1] .= ' '.$nbExtrafields.''; + } $head[$h][2] = 'attributes_categories'; $h++; From 2fb678523074128231bf4327542265be2b661d59 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Sep 2022 18:39:40 +0200 Subject: [PATCH 3/7] Update member.lib.php --- htdocs/core/lib/member.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/member.lib.php b/htdocs/core/lib/member.lib.php index 64c0d429048..ca307db05ed 100644 --- a/htdocs/core/lib/member.lib.php +++ b/htdocs/core/lib/member.lib.php @@ -211,7 +211,7 @@ function member_admin_prepare_head() $head[$h][1] = $langs->trans("ExtraFieldsMember"); $nbExtrafields = $extrafields->attributes['adherent']['count']; if ($nbExtrafields > 0) { - $head[$h][1] .= ' '.$nbExtrafields.''; + $head[$h][1] .= ''.$nbExtrafields.''; } $head[$h][2] = 'attributes'; $h++; @@ -220,7 +220,7 @@ function member_admin_prepare_head() $head[$h][1] = $langs->trans("ExtraFieldsMemberType"); $nbExtrafields = $extrafields->attributes['adherent_type']['count']; if ($nbExtrafields > 0) { - $head[$h][1] .= ' '.$nbExtrafields.''; + $head[$h][1] .= ''.$nbExtrafields.''; } $head[$h][2] = 'attributes_type'; $h++; From 84e0ab07e9f942d395e66454247ac4f57e65c02a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Sep 2022 18:40:16 +0200 Subject: [PATCH 4/7] Update order.lib.php --- htdocs/core/lib/order.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php index 174ec36834b..c0f852ebf59 100644 --- a/htdocs/core/lib/order.lib.php +++ b/htdocs/core/lib/order.lib.php @@ -165,7 +165,7 @@ function order_admin_prepare_head() $head[$h][1] = $langs->trans("ExtraFields"); $nbExtrafields = $extrafields->attributes['commande']['count']; if ($nbExtrafields > 0) { - $head[$h][1] .= ' '.$nbExtrafields.''; + $head[$h][1] .= ''.$nbExtrafields.''; } $head[$h][2] = 'attributes'; $h++; @@ -174,7 +174,7 @@ function order_admin_prepare_head() $head[$h][1] = $langs->trans("ExtraFieldsLines"); $nbExtrafields = $extrafields->attributes['commandedet']['count']; if ($nbExtrafields > 0) { - $head[$h][1] .= ' '.$nbExtrafields.''; + $head[$h][1] .= ''.$nbExtrafields.''; } $head[$h][2] = 'attributeslines'; $h++; From 21413344230dbb61bf2aab42a1928492516c6935 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Sep 2022 18:40:34 +0200 Subject: [PATCH 5/7] Update order.lib.php --- htdocs/core/lib/order.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php index c0f852ebf59..18c3d7580a2 100644 --- a/htdocs/core/lib/order.lib.php +++ b/htdocs/core/lib/order.lib.php @@ -165,7 +165,7 @@ function order_admin_prepare_head() $head[$h][1] = $langs->trans("ExtraFields"); $nbExtrafields = $extrafields->attributes['commande']['count']; if ($nbExtrafields > 0) { - $head[$h][1] .= ''.$nbExtrafields.''; + $head[$h][1] .= ''.$nbExtrafields.''; } $head[$h][2] = 'attributes'; $h++; @@ -174,7 +174,7 @@ function order_admin_prepare_head() $head[$h][1] = $langs->trans("ExtraFieldsLines"); $nbExtrafields = $extrafields->attributes['commandedet']['count']; if ($nbExtrafields > 0) { - $head[$h][1] .= ''.$nbExtrafields.''; + $head[$h][1] .= ''.$nbExtrafields.''; } $head[$h][2] = 'attributeslines'; $h++; From ce48118bbb22011b0815ed212a579aa2ff59b617 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Sep 2022 18:41:07 +0200 Subject: [PATCH 6/7] Update member.lib.php --- htdocs/core/lib/member.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/member.lib.php b/htdocs/core/lib/member.lib.php index ca307db05ed..baf1012dfea 100644 --- a/htdocs/core/lib/member.lib.php +++ b/htdocs/core/lib/member.lib.php @@ -211,7 +211,7 @@ function member_admin_prepare_head() $head[$h][1] = $langs->trans("ExtraFieldsMember"); $nbExtrafields = $extrafields->attributes['adherent']['count']; if ($nbExtrafields > 0) { - $head[$h][1] .= ''.$nbExtrafields.''; + $head[$h][1] .= ''.$nbExtrafields.''; } $head[$h][2] = 'attributes'; $h++; @@ -220,7 +220,7 @@ function member_admin_prepare_head() $head[$h][1] = $langs->trans("ExtraFieldsMemberType"); $nbExtrafields = $extrafields->attributes['adherent_type']['count']; if ($nbExtrafields > 0) { - $head[$h][1] .= ''.$nbExtrafields.''; + $head[$h][1] .= ''.$nbExtrafields.''; } $head[$h][2] = 'attributes_type'; $h++; From 0c76fe83578f59ede87de3b0fa143571d3b3ccef Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Sep 2022 18:41:47 +0200 Subject: [PATCH 7/7] Update categories.lib.php --- htdocs/core/lib/categories.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/categories.lib.php b/htdocs/core/lib/categories.lib.php index 7d77b345d61..ee69ccf4a87 100644 --- a/htdocs/core/lib/categories.lib.php +++ b/htdocs/core/lib/categories.lib.php @@ -99,7 +99,7 @@ function categoriesadmin_prepare_head() $head[$h][1] = $langs->trans("ExtraFieldsCategories"); $nbExtrafields = $extrafields->attributes['categorie']['count']; if ($nbExtrafields > 0) { - $head[$h][1] .= ' '.$nbExtrafields.''; + $head[$h][1] .= ''.$nbExtrafields.''; } $head[$h][2] = 'attributes_categories'; $h++;