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

@ -279,7 +279,11 @@ function productlot_prepare_head($object)
*/ */
function product_admin_prepare_head() 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; $h = 0;
$head = array(); $head = array();
@ -306,11 +310,19 @@ function product_admin_prepare_head()
$head[$h][0] = DOL_URL_ROOT.'/product/admin/product_extrafields.php'; $head[$h][0] = DOL_URL_ROOT.'/product/admin/product_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFields"); $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'; $head[$h][2] = 'attributes';
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/product/admin/product_supplier_extrafields.php'; $head[$h][0] = DOL_URL_ROOT.'/product/admin/product_supplier_extrafields.php';
$head[$h][1] = $langs->trans("ProductSupplierExtraFields"); $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'; $head[$h][2] = 'supplierAttributes';
$h++; $h++;
@ -556,11 +568,11 @@ function show_stats_for_company($product, $socid)
} }
// MO // MO
if (!empty($conf->mrp->enabled) && $user->rights->mrp->read) { if (!empty($conf->mrp->enabled) && !empty($user->rights->mrp->read)) {
$nblines++; $nblines++;
$ret = $product->load_stats_mo($socid); $ret = $product->load_stats_mo($socid);
if ($ret < 0) { if ($ret < 0) {
setEventMessage($product->error, 'errors'); setEventMessages($product->error, $product->errors, 'errors');
} }
$langs->load("mrp"); $langs->load("mrp");
print '<tr><td>'; print '<tr><td>';
@ -585,7 +597,9 @@ function show_stats_for_company($product, $socid)
} }
$parameters = array('socid'=>$socid); $parameters = array('socid'=>$socid);
$reshook = $hookmanager->executeHooks('addMoreProductStat', $parameters, $product, $nblines); // Note that $action and $object may have been modified by some hooks $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; print $hookmanager->resPrint;

View File

@ -487,11 +487,14 @@ function project_timesheet_prepare_head($mode, $fuser = null)
*/ */
function project_admin_prepare_head() function project_admin_prepare_head()
{ {
global $langs, $conf, $user; global $langs, $conf, $user, $db;
$h = 0;
$head = array(); $extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label('projet');
$extrafields->fetch_name_optionals_label('projet_task');
$h = 0; $h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT."/projet/admin/project.php"; $head[$h][0] = DOL_URL_ROOT."/projet/admin/project.php";
$head[$h][1] = $langs->trans("Projects"); $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][0] = DOL_URL_ROOT."/projet/admin/project_extrafields.php";
$head[$h][1] = $langs->trans("ExtraFieldsProject"); $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'; $head[$h][2] = 'attributes';
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/projet/admin/project_task_extrafields.php'; $head[$h][0] = DOL_URL_ROOT.'/projet/admin/project_task_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFieldsProjectTask"); $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'; $head[$h][2] = 'attributes_task';
$h++; $h++;