display count extrafields in invoice admin

This commit is contained in:
Frédéric FRANCE 2022-10-18 14:26:26 +02:00
parent 60cf6437e0
commit a9031505f1

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2017 Charlie Benke <charlie@patas-monkey.com>
* Copyright (C) 2017 ATM-CONSULTING <contact@atm-consulting.fr>
*
@ -137,7 +137,13 @@ function facture_prepare_head($object)
*/
function invoice_admin_prepare_head()
{
global $langs, $conf, $user;
global $langs, $conf, $user, $db;
$extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label('facture');
$extrafields->fetch_name_optionals_label('facturedet');
$extrafields->fetch_name_optionals_label('facture_rec');
$extrafields->fetch_name_optionals_label('facturedet_rec');
$h = 0;
$head = array();
@ -160,25 +166,41 @@ function invoice_admin_prepare_head()
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facture_cust_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFieldsCustomerInvoices");
$nbExtrafields = $extrafields->attributes['facture']['count'];
if ($nbExtrafields > 0) {
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
}
$head[$h][2] = 'attributes';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facturedet_cust_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFieldsLines");
$nbExtrafields = $extrafields->attributes['facturedet']['count'];
if ($nbExtrafields > 0) {
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
}
$head[$h][2] = 'attributeslines';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facture_rec_cust_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFieldsCustomerInvoicesRec");
$nbExtrafields = $extrafields->attributes['facture_rec']['count'];
if ($nbExtrafields > 0) {
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
}
$head[$h][2] = 'attributesrec';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facturedet_rec_cust_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFieldsLinesRec");
$nbExtrafields = $extrafields->attributes['facturedet_rec']['count'];
if ($nbExtrafields > 0) {
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
}
$head[$h][2] = 'attributeslinesrec';
$h++;
if ($conf->global->INVOICE_USE_SITUATION) { // Warning, implementation is seriously bugged and a new one not compatible is expected to become stable
if (!empty($conf->global->INVOICE_USE_SITUATION)) { // Warning, implementation is seriously bugged and a new one not compatible is expected to become stable
$head[$h][0] = DOL_URL_ROOT.'/admin/facture_situation.php';
$head[$h][1] = $langs->trans("InvoiceSituation");
$head[$h][2] = 'situation';