add badge in product admin

This commit is contained in:
Frédéric France 2022-09-18 20:50:15 +02:00
parent 345864b10d
commit 29bb7505cc
3 changed files with 43 additions and 18 deletions

View File

@ -21,9 +21,9 @@
*/
/**
* \file htdocs/core/lib/product.lib.php
* \brief Ensemble de fonctions de base pour le module produit et service
* \ingroup product
* \file htdocs/core/lib/product.lib.php
* \brief Ensemble de fonctions de base pour le module produit et service
* \ingroup product
*/
/**
@ -279,7 +279,11 @@ function productlot_prepare_head($object)
*/
function product_admin_prepare_head()
{
global $langs, $conf, $user;
global $langs, $conf, $user, $db;
$extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label('product');
$extrafields->fetch_name_optionals_label('product_fournisseur_price');
$h = 0;
$head = array();
@ -306,11 +310,19 @@ function product_admin_prepare_head()
$head[$h][0] = DOL_URL_ROOT.'/product/admin/product_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFields");
$nbExtrafields = $extrafields->attributes['product']['count'];
if ($nbExtrafields > 0) {
$head[$h][1] .= ' <span class="badge">'.$nbExtrafields.'</span>';
}
$head[$h][2] = 'attributes';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/product/admin/product_supplier_extrafields.php';
$head[$h][1] = $langs->trans("ProductSupplierExtraFields");
$nbExtrafields = $extrafields->attributes['product_fournisseur_price']['count'];
if ($nbExtrafields > 0) {
$head[$h][1] .= ' <span class="badge">'.$nbExtrafields.'</span>';
}
$head[$h][2] = 'supplierAttributes';
$h++;
@ -322,9 +334,9 @@ function product_admin_prepare_head()
/**
* Return array head with list of tabs to view object informations.
* Return array head with list of tabs to view object informations.
*
* @return array head array with tabs
* @return array head array with tabs
*/
function product_lot_admin_prepare_head()
{
@ -556,11 +568,11 @@ function show_stats_for_company($product, $socid)
}
// MO
if (!empty($conf->mrp->enabled) && $user->rights->mrp->read) {
if (!empty($conf->mrp->enabled) && !empty($user->rights->mrp->read)) {
$nblines++;
$ret = $product->load_stats_mo($socid);
if ($ret < 0) {
setEventMessage($product->error, 'errors');
setEventMessages($product->error, $product->errors, 'errors');
}
$langs->load("mrp");
print '<tr><td>';
@ -585,7 +597,9 @@ function show_stats_for_company($product, $socid)
}
$parameters = array('socid'=>$socid);
$reshook = $hookmanager->executeHooks('addMoreProductStat', $parameters, $product, $nblines); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
print $hookmanager->resPrint;

View File

@ -21,9 +21,9 @@
*/
/**
* \file htdocs/core/lib/project.lib.php
* \brief Functions used by project module
* \ingroup project
* \file htdocs/core/lib/project.lib.php
* \brief Functions used by project module
* \ingroup project
*/
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
@ -487,11 +487,14 @@ function project_timesheet_prepare_head($mode, $fuser = null)
*/
function project_admin_prepare_head()
{
global $langs, $conf, $user;
$h = 0;
$head = array();
global $langs, $conf, $user, $db;
$extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label('projet');
$extrafields->fetch_name_optionals_label('projet_task');
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT."/projet/admin/project.php";
$head[$h][1] = $langs->trans("Projects");
@ -502,11 +505,19 @@ function project_admin_prepare_head()
$head[$h][0] = DOL_URL_ROOT."/projet/admin/project_extrafields.php";
$head[$h][1] = $langs->trans("ExtraFieldsProject");
$nbExtrafields = $extrafields->attributes['projet']['count'];
if ($nbExtrafields > 0) {
$head[$h][1] .= ' <span class="badge">'.$nbExtrafields.'</span>';
}
$head[$h][2] = 'attributes';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/projet/admin/project_task_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFieldsProjectTask");
$nbExtrafields = $extrafields->attributes['projet_task']['count'];
if ($nbExtrafields > 0) {
$head[$h][1] .= ' <span class="badge">'.$nbExtrafields.'</span>';
}
$head[$h][2] = 'attributes_task';
$h++;

View File

@ -18,9 +18,9 @@
*/
/**
* \file htdocs/core/lib/propal.lib.php
* \brief Ensemble de fonctions de base pour le module propal
* \ingroup propal
* \file htdocs/core/lib/propal.lib.php
* \brief Ensemble de fonctions de base pour le module propal
* \ingroup propal
*/
/**