add count extrafields in admin dolresource

This commit is contained in:
Frédéric FRANCE 2023-02-07 21:52:33 +01:00 committed by GitHub
parent e671b63a02
commit 39ec233138
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,8 @@
<?php <?php
/* Module to manage locations, buildings, floors and rooms into Dolibarr ERP/CRM /* Module to manage locations, buildings, floors and rooms into Dolibarr ERP/CRM
* Copyright (C) 2013 Jean-François Ferry <jfefe@aternatik.fr> * Copyright (C) 2013 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2016 Gilles Poirier <glgpoirier@gmail.com> * Copyright (C) 2016 Gilles Poirier <gilles.poirier@netlogic.fr>
* Copyright (C) 2023 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -26,7 +27,7 @@
/** /**
* Prepare head for tabs * Prepare head for tabs
* *
* @param Object $object Object * @param Dolresource $object Object
* @return array Array of head entries * @return array Array of head entries
*/ */
function resource_prepare_head($object) function resource_prepare_head($object)
@ -114,7 +115,10 @@ function resource_prepare_head($object)
function resource_admin_prepare_head() function resource_admin_prepare_head()
{ {
global $langs, $conf, $user; global $conf, $db, $langs, $user;
$extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label('resource');
$h = 0; $h = 0;
$head = array(); $head = array();
@ -132,6 +136,10 @@ function resource_admin_prepare_head()
$head[$h][0] = DOL_URL_ROOT.'/admin/resource_extrafields.php'; $head[$h][0] = DOL_URL_ROOT.'/admin/resource_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFields"); $head[$h][1] = $langs->trans("ExtraFields");
$nbExtrafields = $extrafields->attributes['resource']['count'];
if ($nbExtrafields > 0) {
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
}
$head[$h][2] = 'attributes'; $head[$h][2] = 'attributes';
$h++; $h++;