Merge pull request #22345 from frederic34/adminbadgeextrafields

NEW Add badge in admin extrafields setup
This commit is contained in:
Laurent Destailleur 2022-09-23 18:42:28 +02:00 committed by GitHub
commit 39d7142f2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 14 deletions

View File

@ -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] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
}
$head[$h][2] = 'attributes_categories';
$h++;

View File

@ -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
*/
/**
@ -184,7 +184,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();
@ -207,11 +211,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] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
}
$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] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
}
$head[$h][2] = 'attributes_type';
$h++;

View File

@ -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 .= '<span class="badge marginleftonlyshort">'.($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) {
@ -147,7 +147,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();
@ -161,11 +165,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] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
}
$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] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
}
$head[$h][2] = 'attributeslines';
$h++;
@ -188,7 +200,7 @@ function getCustomerOrderPieChart($socid = 0)
$result = '';
if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) {
if (!isModEnabled('commande') || !$user->hasRight('commande', 'lire')) {
return '';
}
@ -278,7 +290,7 @@ function getCustomerOrderPieChart($socid = 0)
$result .= "</tr>\n";
}
}
if ($conf->use_javascript_ajax) {
if (!empty($conf->use_javascript_ajax)) {
$result .= '<tr class="impair"><td align="center" colspan="2">';
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';