From 16d2f066844c24b0ee962f5865768ee1e49e7290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 15 Sep 2022 20:15:40 +0200 Subject: [PATCH 01/12] add badges --- htdocs/core/lib/agenda.lib.php | 11 +++++- htdocs/hrm/lib/hrm.lib.php | 70 ++++++++++++++++++---------------- 2 files changed, 48 insertions(+), 33 deletions(-) diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index cb5a7f41f8f..818cbca264d 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -2,6 +2,7 @@ /* Copyright (C) 2008-2014 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2022 Frédéric France * * 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 @@ -362,7 +363,11 @@ function show_array_last_actions_done($max = 5) */ function agenda_prepare_head() { - global $langs, $conf, $user; + global $langs, $conf, $user, $db; + + $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label('actioncomm'); + $h = 0; $head = array(); @@ -395,6 +400,10 @@ function agenda_prepare_head() $head[$h][0] = DOL_URL_ROOT."/admin/agenda_extrafields.php"; $head[$h][1] = $langs->trans("ExtraFields"); + $nbExtrafields = is_countable($extrafields->attributes['actioncomm']['label']) ? count($extrafields->attributes['actioncomm']['label']) : 0; + if ($nbExtrafields > 0) { + $head[$h][1] .= ' '.$nbExtrafields.''; + } $head[$h][2] = 'attributes'; $h++; diff --git a/htdocs/hrm/lib/hrm.lib.php b/htdocs/hrm/lib/hrm.lib.php index 508cbef22fd..a571231c143 100644 --- a/htdocs/hrm/lib/hrm.lib.php +++ b/htdocs/hrm/lib/hrm.lib.php @@ -4,6 +4,7 @@ * Copyright (C) 2021 Greg Rastklan * Copyright (C) 2021 Jean-Pascal BOUDET * Copyright (C) 2021 Grégory BLEMAND + * Copyright (C) 2022 Frédéric France * * 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 @@ -21,7 +22,7 @@ /** * \file hrm/lib/hrm.lib.php - * \ingroup hr + * \ingroup hrm * \brief Library files with common functions for Workstation */ @@ -32,10 +33,15 @@ */ function hrmAdminPrepareHead() { - global $langs, $conf; + global $langs, $conf, $db; $langs->load("hrm"); + $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label('hrm_evaluation'); + $extrafields->fetch_name_optionals_label('hrm_job'); + $extrafields->fetch_name_optionals_label('hrm_skill'); + $h = 0; $head = array(); $head[$h][0] = DOL_URL_ROOT . "/admin/hrm.php"; @@ -43,37 +49,37 @@ function hrmAdminPrepareHead() $head[$h][2] = 'settings'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/hrm/admin/admin_establishment.php'; - $head[$h][1] = $langs->trans("Establishments"); - $head[$h][2] = 'establishments'; - $h++; - - $head[$h][0] = DOL_URL_ROOT . '/hrm/admin/evaluation_extrafields.php'; - $head[$h][1] = $langs->trans("EvaluationsExtraFields"); - $head[$h][2] = 'evaluationsAttributes'; - $h++; - - $head[$h][0] = DOL_URL_ROOT . '/hrm/admin/job_extrafields.php'; - $head[$h][1] = $langs->trans("JobsExtraFields"); - $head[$h][2] = 'jobsAttributes'; - $h++; - - $head[$h][0] = DOL_URL_ROOT . '/hrm/admin/skill_extrafields.php'; - $head[$h][1] = $langs->trans("SkillsExtraFields"); - $head[$h][2] = 'skillsAttributes'; - $h++; - - /* - $head[$h][0] = dol_buildpath("/workstation/admin/myobject_extrafields.php", 1); - $head[$h][1] = $langs->trans("ExtraFields"); - $head[$h][2] = 'myobject_extrafields'; + $head[$h][0] = DOL_URL_ROOT.'/hrm/admin/admin_establishment.php'; + $head[$h][1] = $langs->trans("Establishments"); + $head[$h][2] = 'establishments'; $h++; - */ - /*$head[$h][0] = require_once "/admin/about.php"; - $head[$h][1] = $langs->trans("About"); - $head[$h][2] = 'about'; - $h++;*/ + $head[$h][0] = DOL_URL_ROOT . '/hrm/admin/evaluation_extrafields.php'; + $head[$h][1] = $langs->trans("EvaluationsExtraFields"); + $nbExtrafields = is_countable($extrafields->attributes['hrm_evaluation']['label']) ? count($extrafields->attributes['hrm_evaluation']['label']) : 0; + if ($nbExtrafields > 0) { + $head[$h][1] .= ' '.$nbExtrafields.''; + } + $head[$h][2] = 'evaluationsAttributes'; + $h++; + + $head[$h][0] = DOL_URL_ROOT . '/hrm/admin/job_extrafields.php'; + $head[$h][1] = $langs->trans("JobsExtraFields"); + $nbExtrafields = is_countable($extrafields->attributes['hrm_job']['label']) ? count($extrafields->attributes['hrm_job']['label']) : 0; + if ($nbExtrafields > 0) { + $head[$h][1] .= ' '.$nbExtrafields.''; + } + $head[$h][2] = 'jobsAttributes'; + $h++; + + $head[$h][0] = DOL_URL_ROOT . '/hrm/admin/skill_extrafields.php'; + $head[$h][1] = $langs->trans("SkillsExtraFields"); + $nbExtrafields = is_countable($extrafields->attributes['hrm_skill']['label']) ? count($extrafields->attributes['hrm_skill']['label']) : 0; + if ($nbExtrafields > 0) { + $head[$h][1] .= ' '.$nbExtrafields.''; + } + $head[$h][2] = 'skillsAttributes'; + $h++; // Show more tabs from modules // Entries must be declared in modules descriptor with line @@ -85,7 +91,7 @@ function hrmAdminPrepareHead() //); // to remove a tab complete_head_from_modules($conf, $langs, null, $head, $h, 'hrm_admin'); - complete_head_from_modules($conf, $langs, null, $head, $h, 'hrm_admin', 'remove'); + complete_head_from_modules($conf, $langs, null, $head, $h, 'hrm_admin', 'remove'); return $head; } From 567c646989c99ecf64c3a3e29032333f875ad17c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 15 Sep 2022 20:23:37 +0200 Subject: [PATCH 02/12] add badges --- htdocs/core/lib/agenda.lib.php | 6 +++--- htdocs/core/lib/asset.lib.php | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index 818cbca264d..d8f3bfbf102 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -20,8 +20,8 @@ */ /** - * \file htdocs/core/lib/agenda.lib.php - * \brief Set of function for the agenda module + * \file htdocs/core/lib/agenda.lib.php + * \brief Set of function for the agenda module */ @@ -314,7 +314,7 @@ function show_array_last_actions_done($max = 5) print ''; $staticaction->type_code = $obj->code; - $staticaction->libelle = $obj->label; + $staticaction->label = $obj->label; $staticaction->id = $obj->id; print ''.$staticaction->getNomUrl(1, 34).''; diff --git a/htdocs/core/lib/asset.lib.php b/htdocs/core/lib/asset.lib.php index 9d71e2b38f1..719091973e3 100644 --- a/htdocs/core/lib/asset.lib.php +++ b/htdocs/core/lib/asset.lib.php @@ -1,5 +1,6 @@ + * Copyright (C) 2022 Frédéric France * * 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 @@ -28,7 +29,11 @@ */ function assetAdminPrepareHead() { - global $langs, $conf; + global $langs, $conf, $db; + + $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label('asset'); + $extrafields->fetch_name_optionals_label('assetmodel'); $langs->load("assets"); @@ -52,11 +57,19 @@ function assetAdminPrepareHead() $head[$h][0] = DOL_URL_ROOT.'/asset/admin/asset_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields"); + $nbExtrafields = is_countable($extrafields->attributes['asset']['label']) ? count($extrafields->attributes['asset']['label']) : 0; + if ($nbExtrafields > 0) { + $head[$h][1] .= ' '.$nbExtrafields.''; + } $head[$h][2] = 'asset_extrafields'; $h++; $head[$h][0] = DOL_URL_ROOT.'/asset/admin/assetmodel_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsAssetModel"); + $nbExtrafields = is_countable($extrafields->attributes['assetmodel']['label']) ? count($extrafields->attributes['assetmodel']['label']) : 0; + if ($nbExtrafields > 0) { + $head[$h][1] .= ' '.$nbExtrafields.''; + } $head[$h][2] = 'assetmodel_extrafields'; $h++; From 79c66ac19e3e73a03d400ef8ec831e3a2711b3cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 15 Sep 2022 20:42:26 +0200 Subject: [PATCH 03/12] add badges --- htdocs/core/lib/contract.lib.php | 14 +++++++++++++- htdocs/core/lib/donation.lib.php | 9 ++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/contract.lib.php b/htdocs/core/lib/contract.lib.php index 2d627532010..52c4267e55d 100644 --- a/htdocs/core/lib/contract.lib.php +++ b/htdocs/core/lib/contract.lib.php @@ -108,7 +108,11 @@ function contract_prepare_head(Contrat $object) */ function contract_admin_prepare_head() { - global $langs, $conf; + global $langs, $conf, $db; + + $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label('contract'); + $extrafields->fetch_name_optionals_label('contractdet'); $h = 0; $head = array(); @@ -126,11 +130,19 @@ function contract_admin_prepare_head() $head[$h][0] = DOL_URL_ROOT.'/contrat/admin/contract_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields"); + $nbExtrafields = is_countable($extrafields->attributes['contract']['label']) ? count($extrafields->attributes['contract']['label']) : 0; + if ($nbExtrafields > 0) { + $head[$h][1] .= ' '.$nbExtrafields.''; + } $head[$h][2] = 'attributes'; $h++; $head[$h][0] = DOL_URL_ROOT.'/contrat/admin/contractdet_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsLines"); + $nbExtrafields = is_countable($extrafields->attributes['contractdet']['label']) ? count($extrafields->attributes['contractdet']['label']) : 0; + if ($nbExtrafields > 0) { + $head[$h][1] .= ' '.$nbExtrafields.''; + } $head[$h][2] = 'attributeslines'; $h++; diff --git a/htdocs/core/lib/donation.lib.php b/htdocs/core/lib/donation.lib.php index e60b7ee3bc6..698932bd469 100644 --- a/htdocs/core/lib/donation.lib.php +++ b/htdocs/core/lib/donation.lib.php @@ -28,7 +28,10 @@ */ function donation_admin_prepare_head() { - global $langs, $conf; + global $langs, $conf, $db; + + $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label('donation'); $h = 0; $head = array(); @@ -46,6 +49,10 @@ function donation_admin_prepare_head() $head[$h][0] = DOL_URL_ROOT.'/don/admin/donation_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields"); + $nbExtrafields = is_countable($extrafields->attributes['donation']['label']) ? count($extrafields->attributes['donation']['label']) : 0; + if ($nbExtrafields > 0) { + $head[$h][1] .= ' '.$nbExtrafields.''; + } $head[$h][2] = 'attributes'; $h++; From 196c1c2c4a0e4158caed7b683fd1e9334aabf3ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 15 Sep 2022 21:43:57 +0200 Subject: [PATCH 04/12] add badges --- htdocs/core/lib/ecm.lib.php | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/ecm.lib.php b/htdocs/core/lib/ecm.lib.php index 97eeffd4337..f10f2ba2917 100644 --- a/htdocs/core/lib/ecm.lib.php +++ b/htdocs/core/lib/ecm.lib.php @@ -1,5 +1,6 @@ + * Copyright (C) 2022 Frédéric France * * 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 @@ -17,9 +18,9 @@ */ /** - * \file htdocs/core/lib/ecm.lib.php - * \brief Ensemble de fonctions de base pour le module ecm - * \ingroup ecm + * \file htdocs/core/lib/ecm.lib.php + * \brief Ensemble de fonctions de base pour le module ecm + * \ingroup ecm */ @@ -160,7 +161,12 @@ function ecm_prepare_head_fm($object) */ function ecm_admin_prepare_head() { - global $langs, $conf; + global $langs, $conf, $db; + + $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label('ecm_files'); + $extrafields->fetch_name_optionals_label('ecm_directories'); + $langs->load("ecm"); $h = 0; @@ -173,11 +179,19 @@ function ecm_admin_prepare_head() $head[$h][0] = DOL_URL_ROOT.'/admin/ecm_files_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsEcmFiles"); + $nbExtrafields = is_countable($extrafields->attributes['ecm_files']['label']) ? count($extrafields->attributes['ecm_files']['label']) : 0; + if ($nbExtrafields > 0) { + $head[$h][1] .= ' '.$nbExtrafields.''; + } $head[$h][2] = 'attributes_ecm_files'; $h++; $head[$h][0] = DOL_URL_ROOT.'/admin/ecm_directories_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsEcmDirectories"); + $nbExtrafields = is_countable($extrafields->attributes['ecm_directories']['label']) ? count($extrafields->attributes['ecm_directories']['label']) : 0; + if ($nbExtrafields > 0) { + $head[$h][1] .= ' '.$nbExtrafields.''; + } $head[$h][2] = 'attributes_ecm_directories'; $h++; From b7208e273dc4fa762ec6515146c4edb9043f59fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 16 Sep 2022 09:13:36 +0200 Subject: [PATCH 05/12] add badges in user admin --- htdocs/core/lib/asset.lib.php | 4 ++-- htdocs/core/lib/contract.lib.php | 8 ++++---- htdocs/core/lib/donation.lib.php | 4 ++-- htdocs/core/lib/usergroups.lib.php | 14 +++++++++++++- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/asset.lib.php b/htdocs/core/lib/asset.lib.php index 719091973e3..4c6f2aea9f3 100644 --- a/htdocs/core/lib/asset.lib.php +++ b/htdocs/core/lib/asset.lib.php @@ -33,7 +33,7 @@ function assetAdminPrepareHead() $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label('asset'); - $extrafields->fetch_name_optionals_label('assetmodel'); + $extrafields->fetch_name_optionals_label('asset_model'); $langs->load("assets"); @@ -66,7 +66,7 @@ function assetAdminPrepareHead() $head[$h][0] = DOL_URL_ROOT.'/asset/admin/assetmodel_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsAssetModel"); - $nbExtrafields = is_countable($extrafields->attributes['assetmodel']['label']) ? count($extrafields->attributes['assetmodel']['label']) : 0; + $nbExtrafields = is_countable($extrafields->attributes['asset_model']['label']) ? count($extrafields->attributes['asset_model']['label']) : 0; if ($nbExtrafields > 0) { $head[$h][1] .= ' '.$nbExtrafields.''; } diff --git a/htdocs/core/lib/contract.lib.php b/htdocs/core/lib/contract.lib.php index 52c4267e55d..41f65be3622 100644 --- a/htdocs/core/lib/contract.lib.php +++ b/htdocs/core/lib/contract.lib.php @@ -111,8 +111,8 @@ function contract_admin_prepare_head() global $langs, $conf, $db; $extrafields = new ExtraFields($db); - $extrafields->fetch_name_optionals_label('contract'); - $extrafields->fetch_name_optionals_label('contractdet'); + $extrafields->fetch_name_optionals_label('contrat'); + $extrafields->fetch_name_optionals_label('contratdet'); $h = 0; $head = array(); @@ -130,7 +130,7 @@ function contract_admin_prepare_head() $head[$h][0] = DOL_URL_ROOT.'/contrat/admin/contract_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields"); - $nbExtrafields = is_countable($extrafields->attributes['contract']['label']) ? count($extrafields->attributes['contract']['label']) : 0; + $nbExtrafields = is_countable($extrafields->attributes['contrat']['label']) ? count($extrafields->attributes['contrat']['label']) : 0; if ($nbExtrafields > 0) { $head[$h][1] .= ' '.$nbExtrafields.''; } @@ -139,7 +139,7 @@ function contract_admin_prepare_head() $head[$h][0] = DOL_URL_ROOT.'/contrat/admin/contractdet_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsLines"); - $nbExtrafields = is_countable($extrafields->attributes['contractdet']['label']) ? count($extrafields->attributes['contractdet']['label']) : 0; + $nbExtrafields = is_countable($extrafields->attributes['contratdet']['label']) ? count($extrafields->attributes['contratdet']['label']) : 0; if ($nbExtrafields > 0) { $head[$h][1] .= ' '.$nbExtrafields.''; } diff --git a/htdocs/core/lib/donation.lib.php b/htdocs/core/lib/donation.lib.php index 698932bd469..06a8fca02d1 100644 --- a/htdocs/core/lib/donation.lib.php +++ b/htdocs/core/lib/donation.lib.php @@ -31,7 +31,7 @@ function donation_admin_prepare_head() global $langs, $conf, $db; $extrafields = new ExtraFields($db); - $extrafields->fetch_name_optionals_label('donation'); + $extrafields->fetch_name_optionals_label('don'); $h = 0; $head = array(); @@ -49,7 +49,7 @@ function donation_admin_prepare_head() $head[$h][0] = DOL_URL_ROOT.'/don/admin/donation_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields"); - $nbExtrafields = is_countable($extrafields->attributes['donation']['label']) ? count($extrafields->attributes['donation']['label']) : 0; + $nbExtrafields = is_countable($extrafields->attributes['don']['label']) ? count($extrafields->attributes['don']['label']) : 0; if ($nbExtrafields > 0) { $head[$h][1] .= ' '.$nbExtrafields.''; } diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 4b524f66b3e..d252606571b 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -250,7 +250,11 @@ function group_prepare_head($object) */ function user_admin_prepare_head() { - global $langs, $conf, $user; + global $langs, $conf, $user, $db; + + $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label('user'); + $extrafields->fetch_name_optionals_label('usergroup'); $langs->load("users"); $h = 0; @@ -268,11 +272,19 @@ function user_admin_prepare_head() $head[$h][0] = DOL_URL_ROOT.'/user/admin/user_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields")." (".$langs->trans("Users").")"; + $nbExtrafields = is_countable($extrafields->attributes['user']['label']) ? count($extrafields->attributes['user']['label']) : 0; + if ($nbExtrafields > 0) { + $head[$h][1] .= ' '.$nbExtrafields.''; + } $head[$h][2] = 'attributes'; $h++; $head[$h][0] = DOL_URL_ROOT.'/user/admin/group_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields")." (".$langs->trans("Groups").")"; + $nbExtrafields = is_countable($extrafields->attributes['usergroup']['label']) ? count($extrafields->attributes['usergroup']['label']) : 0; + if ($nbExtrafields > 0) { + $head[$h][1] .= ' '.$nbExtrafields.''; + } $head[$h][2] = 'attributes_group'; $h++; From d91d02f44ce63b59103122e5365d3ffa0bbc98a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 16 Sep 2022 09:31:02 +0200 Subject: [PATCH 06/12] add badges in user admin --- htdocs/core/class/extrafields.class.php | 3 +++ htdocs/core/lib/usergroups.lib.php | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index a3925c9160a..8a1ea7222ce 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -851,6 +851,7 @@ class ExtraFields $resql = $this->db->query($sql); if ($resql) { + $count = 0; if ($this->db->num_rows($resql)) { while ($tab = $this->db->fetch_object($resql)) { if ($tab->entity != 0 && $tab->entity != $conf->entity) { @@ -890,10 +891,12 @@ class ExtraFields $this->attributes[$tab->elementtype]['csslist'][$tab->name] = $tab->csslist; $this->attributes[$tab->elementtype]['loaded'] = 1; + $count++; } } if ($elementtype) { $this->attributes[$elementtype]['loaded'] = 1; // If nothing found, we also save tag 'loaded' + $this->attributes[$elementtype]['count'] = $count; } } else { $this->error = $this->db->lasterror(); diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index d252606571b..79648eddd87 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -272,7 +272,7 @@ function user_admin_prepare_head() $head[$h][0] = DOL_URL_ROOT.'/user/admin/user_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields")." (".$langs->trans("Users").")"; - $nbExtrafields = is_countable($extrafields->attributes['user']['label']) ? count($extrafields->attributes['user']['label']) : 0; + $nbExtrafields = $extrafields->attributes['user']['count']; if ($nbExtrafields > 0) { $head[$h][1] .= ' '.$nbExtrafields.''; } @@ -281,7 +281,7 @@ function user_admin_prepare_head() $head[$h][0] = DOL_URL_ROOT.'/user/admin/group_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields")." (".$langs->trans("Groups").")"; - $nbExtrafields = is_countable($extrafields->attributes['usergroup']['label']) ? count($extrafields->attributes['usergroup']['label']) : 0; + $nbExtrafields = $extrafields->attributes['usergroup']['count']; if ($nbExtrafields > 0) { $head[$h][1] .= ' '.$nbExtrafields.''; } From 6c844a5bb4ae8294c62954f60e54fd7ec2f28371 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 16 Sep 2022 09:35:28 +0200 Subject: [PATCH 07/12] use count from class --- htdocs/core/lib/agenda.lib.php | 2 +- htdocs/core/lib/asset.lib.php | 4 ++-- htdocs/core/lib/ecm.lib.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index d8f3bfbf102..87755969897 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -400,7 +400,7 @@ function agenda_prepare_head() $head[$h][0] = DOL_URL_ROOT."/admin/agenda_extrafields.php"; $head[$h][1] = $langs->trans("ExtraFields"); - $nbExtrafields = is_countable($extrafields->attributes['actioncomm']['label']) ? count($extrafields->attributes['actioncomm']['label']) : 0; + $nbExtrafields = $extrafields->attributes['actioncomm']['count']; if ($nbExtrafields > 0) { $head[$h][1] .= ' '.$nbExtrafields.''; } diff --git a/htdocs/core/lib/asset.lib.php b/htdocs/core/lib/asset.lib.php index 4c6f2aea9f3..369c351cbaf 100644 --- a/htdocs/core/lib/asset.lib.php +++ b/htdocs/core/lib/asset.lib.php @@ -57,7 +57,7 @@ function assetAdminPrepareHead() $head[$h][0] = DOL_URL_ROOT.'/asset/admin/asset_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields"); - $nbExtrafields = is_countable($extrafields->attributes['asset']['label']) ? count($extrafields->attributes['asset']['label']) : 0; + $nbExtrafields = $extrafields->attributes['asset']['count']); if ($nbExtrafields > 0) { $head[$h][1] .= ' '.$nbExtrafields.''; } @@ -66,7 +66,7 @@ function assetAdminPrepareHead() $head[$h][0] = DOL_URL_ROOT.'/asset/admin/assetmodel_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsAssetModel"); - $nbExtrafields = is_countable($extrafields->attributes['asset_model']['label']) ? count($extrafields->attributes['asset_model']['label']) : 0; + $nbExtrafields = $extrafields->attributes['asset_model']['count']; if ($nbExtrafields > 0) { $head[$h][1] .= ' '.$nbExtrafields.''; } diff --git a/htdocs/core/lib/ecm.lib.php b/htdocs/core/lib/ecm.lib.php index f10f2ba2917..cfcd4972a79 100644 --- a/htdocs/core/lib/ecm.lib.php +++ b/htdocs/core/lib/ecm.lib.php @@ -179,7 +179,7 @@ function ecm_admin_prepare_head() $head[$h][0] = DOL_URL_ROOT.'/admin/ecm_files_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsEcmFiles"); - $nbExtrafields = is_countable($extrafields->attributes['ecm_files']['label']) ? count($extrafields->attributes['ecm_files']['label']) : 0; + $nbExtrafields = $extrafields->attributes['ecm_files']['count']; if ($nbExtrafields > 0) { $head[$h][1] .= ' '.$nbExtrafields.''; } @@ -188,7 +188,7 @@ function ecm_admin_prepare_head() $head[$h][0] = DOL_URL_ROOT.'/admin/ecm_directories_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsEcmDirectories"); - $nbExtrafields = is_countable($extrafields->attributes['ecm_directories']['label']) ? count($extrafields->attributes['ecm_directories']['label']) : 0; + $nbExtrafields = $extrafields->attributes['ecm_directories']['count']; if ($nbExtrafields > 0) { $head[$h][1] .= ' '.$nbExtrafields.''; } From 26720ca11662875a4fa025c57529b8bfa0c6d4e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 16 Sep 2022 09:38:24 +0200 Subject: [PATCH 08/12] use count from class --- htdocs/core/lib/asset.lib.php | 2 +- htdocs/core/lib/contract.lib.php | 4 ++-- htdocs/core/lib/donation.lib.php | 2 +- htdocs/hrm/lib/hrm.lib.php | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/asset.lib.php b/htdocs/core/lib/asset.lib.php index 369c351cbaf..117c564dc95 100644 --- a/htdocs/core/lib/asset.lib.php +++ b/htdocs/core/lib/asset.lib.php @@ -57,7 +57,7 @@ function assetAdminPrepareHead() $head[$h][0] = DOL_URL_ROOT.'/asset/admin/asset_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields"); - $nbExtrafields = $extrafields->attributes['asset']['count']); + $nbExtrafields = $extrafields->attributes['asset']['count']; if ($nbExtrafields > 0) { $head[$h][1] .= ' '.$nbExtrafields.''; } diff --git a/htdocs/core/lib/contract.lib.php b/htdocs/core/lib/contract.lib.php index 41f65be3622..9ccffab8b49 100644 --- a/htdocs/core/lib/contract.lib.php +++ b/htdocs/core/lib/contract.lib.php @@ -130,7 +130,7 @@ function contract_admin_prepare_head() $head[$h][0] = DOL_URL_ROOT.'/contrat/admin/contract_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields"); - $nbExtrafields = is_countable($extrafields->attributes['contrat']['label']) ? count($extrafields->attributes['contrat']['label']) : 0; + $nbExtrafields = $extrafields->attributes['contrat']['count']; if ($nbExtrafields > 0) { $head[$h][1] .= ' '.$nbExtrafields.''; } @@ -139,7 +139,7 @@ function contract_admin_prepare_head() $head[$h][0] = DOL_URL_ROOT.'/contrat/admin/contractdet_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsLines"); - $nbExtrafields = is_countable($extrafields->attributes['contratdet']['label']) ? count($extrafields->attributes['contratdet']['label']) : 0; + $nbExtrafields = $extrafields->attributes['contratdet']['count']; if ($nbExtrafields > 0) { $head[$h][1] .= ' '.$nbExtrafields.''; } diff --git a/htdocs/core/lib/donation.lib.php b/htdocs/core/lib/donation.lib.php index 06a8fca02d1..f951d9b522f 100644 --- a/htdocs/core/lib/donation.lib.php +++ b/htdocs/core/lib/donation.lib.php @@ -49,7 +49,7 @@ function donation_admin_prepare_head() $head[$h][0] = DOL_URL_ROOT.'/don/admin/donation_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields"); - $nbExtrafields = is_countable($extrafields->attributes['don']['label']) ? count($extrafields->attributes['don']['label']) : 0; + $nbExtrafields = $extrafields->attributes['don']['count']; if ($nbExtrafields > 0) { $head[$h][1] .= ' '.$nbExtrafields.''; } diff --git a/htdocs/hrm/lib/hrm.lib.php b/htdocs/hrm/lib/hrm.lib.php index a571231c143..d821c2f5216 100644 --- a/htdocs/hrm/lib/hrm.lib.php +++ b/htdocs/hrm/lib/hrm.lib.php @@ -56,7 +56,7 @@ function hrmAdminPrepareHead() $head[$h][0] = DOL_URL_ROOT . '/hrm/admin/evaluation_extrafields.php'; $head[$h][1] = $langs->trans("EvaluationsExtraFields"); - $nbExtrafields = is_countable($extrafields->attributes['hrm_evaluation']['label']) ? count($extrafields->attributes['hrm_evaluation']['label']) : 0; + $nbExtrafields = $extrafields->attributes['hrm_evaluation']['count']; if ($nbExtrafields > 0) { $head[$h][1] .= ' '.$nbExtrafields.''; } @@ -65,7 +65,7 @@ function hrmAdminPrepareHead() $head[$h][0] = DOL_URL_ROOT . '/hrm/admin/job_extrafields.php'; $head[$h][1] = $langs->trans("JobsExtraFields"); - $nbExtrafields = is_countable($extrafields->attributes['hrm_job']['label']) ? count($extrafields->attributes['hrm_job']['label']) : 0; + $nbExtrafields = $extrafields->attributes['hrm_job']['count']; if ($nbExtrafields > 0) { $head[$h][1] .= ' '.$nbExtrafields.''; } @@ -74,7 +74,7 @@ function hrmAdminPrepareHead() $head[$h][0] = DOL_URL_ROOT . '/hrm/admin/skill_extrafields.php'; $head[$h][1] = $langs->trans("SkillsExtraFields"); - $nbExtrafields = is_countable($extrafields->attributes['hrm_skill']['label']) ? count($extrafields->attributes['hrm_skill']['label']) : 0; + $nbExtrafields = $extrafields->attributes['hrm_skill']['count']; if ($nbExtrafields > 0) { $head[$h][1] .= ' '.$nbExtrafields.''; } From bafadb799120e1b05cfd094e99fba45e882cd0a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Sat, 17 Sep 2022 21:16:02 +0200 Subject: [PATCH 09/12] wip --- htdocs/core/lib/stock.lib.php | 23 ++++++++++++++++++++--- htdocs/core/lib/ticket.lib.php | 15 +++++++++++---- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/stock.lib.php b/htdocs/core/lib/stock.lib.php index afad01ebcff..79844f5aed7 100644 --- a/htdocs/core/lib/stock.lib.php +++ b/htdocs/core/lib/stock.lib.php @@ -17,8 +17,8 @@ */ /** - * \file htdocs/core/lib/stock.lib.php - * \brief Library file with function for stock module + * \file htdocs/core/lib/stock.lib.php + * \brief Library file with function for stock module */ /** @@ -88,7 +88,12 @@ function stock_prepare_head($object) */ function stock_admin_prepare_head() { - global $langs, $conf, $user; + global $langs, $conf, $user, $db; + + $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label('entrepot'); + $extrafields->fetch_name_optionals_label('stock_mouvement'); + $extrafields->fetch_name_optionals_label('inventory'); $h = 0; $head = array(); @@ -106,16 +111,28 @@ function stock_admin_prepare_head() $head[$h][0] = DOL_URL_ROOT.'/product/admin/stock_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields"); + $nbExtrafields = $extrafields->attributes['entrepot']['count']; + if ($nbExtrafields > 0) { + $head[$h][1] .= ' '.$nbExtrafields.''; + } $head[$h][2] = 'attributes'; $h++; $head[$h][0] = DOL_URL_ROOT.'/product/admin/stock_mouvement_extrafields.php'; $head[$h][1] = $langs->trans("StockMouvementExtraFields"); + $nbExtrafields = $extrafields->attributes['stock_mouvement']['count']; + if ($nbExtrafields > 0) { + $head[$h][1] .= ' '.$nbExtrafields.''; + } $head[$h][2] = 'stockMouvementAttributes'; $h++; $head[$h][0] = DOL_URL_ROOT.'/product/admin/inventory_extrafields.php'; $head[$h][1] = $langs->trans("InventoryExtraFields"); + $nbExtrafields = $extrafields->attributes['inventory']['count']; + if ($nbExtrafields > 0) { + $head[$h][1] .= ' '.$nbExtrafields.''; + } $head[$h][2] = 'inventoryAttributes'; $h++; diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index 5fd2682d175..eb814cb1295 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -18,9 +18,9 @@ */ /** - * \file core/lib/ticket.lib.php - * \ingroup ticket - * \brief This file is a library for Ticket module + * \file core/lib/ticket.lib.php + * \ingroup ticket + * \brief This file is a library for Ticket module */ /** @@ -30,7 +30,10 @@ */ function ticketAdminPrepareHead() { - global $langs, $conf; + global $langs, $conf, $db; + + $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label('ticket'); $langs->load("ticket"); @@ -44,6 +47,10 @@ function ticketAdminPrepareHead() $head[$h][0] = DOL_URL_ROOT.'/admin/ticket_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsTicket"); + $nbExtrafields = $extrafields->attributes['ticket']['count']; + if ($nbExtrafields > 0) { + $head[$h][1] .= ' '.$nbExtrafields.''; + } $head[$h][2] = 'attributes'; $h++; From 345864b10db3b5659b7e38104ece62d7a022cf65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Sun, 18 Sep 2022 20:38:14 +0200 Subject: [PATCH 10/12] add badge in propal admin --- htdocs/core/lib/propal.lib.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index 71391f2e499..9a28f2e331f 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -122,7 +122,11 @@ function propal_prepare_head($object) */ function propal_admin_prepare_head() { - global $langs, $conf, $user; + global $langs, $conf, $user, $db; + + $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label('propal'); + $extrafields->fetch_name_optionals_label('propaldet'); $h = 0; $head = array(); @@ -140,11 +144,19 @@ function propal_admin_prepare_head() $head[$h][0] = DOL_URL_ROOT.'/comm/admin/propal_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields"); + $nbExtrafields = $extrafields->attributes['propal']['count']; + if ($nbExtrafields > 0) { + $head[$h][1] .= ' '.$nbExtrafields.''; + } $head[$h][2] = 'attributes'; $h++; $head[$h][0] = DOL_URL_ROOT.'/comm/admin/propaldet_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsLines"); + $nbExtrafields = $extrafields->attributes['propaldet']['count']; + if ($nbExtrafields > 0) { + $head[$h][1] .= ' '.$nbExtrafields.''; + } $head[$h][2] = 'attributeslines'; $h++; From 29bb7505cc91c5ccc86155b36ac6a3a6c6c1050e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Sun, 18 Sep 2022 20:50:15 +0200 Subject: [PATCH 11/12] add badge in product admin --- htdocs/core/lib/product.lib.php | 32 +++++++++++++++++++++++--------- htdocs/core/lib/project.lib.php | 23 +++++++++++++++++------ htdocs/core/lib/propal.lib.php | 6 +++--- 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index b5056c2cce3..393a2f618a0 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -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] .= ' '.$nbExtrafields.''; + } $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] .= ' '.$nbExtrafields.''; + } $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 ''; @@ -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; diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 47fb9b6f186..6c4dbeffd8a 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -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] .= ' '.$nbExtrafields.''; + } $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] .= ' '.$nbExtrafields.''; + } $head[$h][2] = 'attributes_task'; $h++; diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index 9a28f2e331f..06fae0dd81d 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -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 */ /** From 8221e4c4bdd53a3c20e3a2d2656c1ba8e00b6abf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 19 Sep 2022 14:16:23 +0200 Subject: [PATCH 12/12] wip --- htdocs/modulebuilder/template/lib/mymodule.lib.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/modulebuilder/template/lib/mymodule.lib.php b/htdocs/modulebuilder/template/lib/mymodule.lib.php index ab8a647efe4..0ebae6eb74f 100644 --- a/htdocs/modulebuilder/template/lib/mymodule.lib.php +++ b/htdocs/modulebuilder/template/lib/mymodule.lib.php @@ -30,6 +30,10 @@ function mymoduleAdminPrepareHead() { global $langs, $conf; + // global $db; + // $extrafields = new ExtraFields($db); + // $extrafields->fetch_name_optionals_label('myobject'); + $langs->load("mymodule@mymodule"); $h = 0; @@ -43,6 +47,10 @@ function mymoduleAdminPrepareHead() /* $head[$h][0] = dol_buildpath("/mymodule/admin/myobject_extrafields.php", 1); $head[$h][1] = $langs->trans("ExtraFields"); + $nbExtrafields = is_countable($extrafields->attributes['myobject']['label']) ? count($extrafields->attributes['myobject']['label']) : 0; + if ($nbExtrafields > 0) { + $head[$h][1] .= ' ' . $nbExtrafields . ''; + } $head[$h][2] = 'myobject_extrafields'; $h++; */