From 2bfa92983c3c1cf8fdd9d2cbac2c71e12d346ede Mon Sep 17 00:00:00 2001 From: Zephyriony <142790847+zephyriony@users.noreply.github.com> Date: Sun, 9 Jun 2024 13:39:00 +0200 Subject: [PATCH] NEW : Execute doActions on statistics pages (#29851) * NEW : Execute doActions on statistics pages * Update index.php * Update index.php --------- Co-authored-by: Laurent Destailleur --- htdocs/comm/propal/stats/index.php | 8 ++++++++ htdocs/commande/stats/index.php | 8 ++++++++ htdocs/compta/facture/stats/index.php | 9 +++++++++ 3 files changed, 25 insertions(+) diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php index e9d884cffaa..17e632099d3 100644 --- a/htdocs/comm/propal/stats/index.php +++ b/htdocs/comm/propal/stats/index.php @@ -40,6 +40,8 @@ $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); $mode = GETPOSTISSET("mode") ? GETPOST("mode", 'aZ09') : 'customer'; +$hookmanager->initHooks(array('propalstats', 'globalcard')); + $object_status = GETPOST('object_status', 'intcomma'); $typent_id = GETPOSTINT('typent_id'); $categ_id = GETPOSTINT('categ_id'); @@ -52,6 +54,12 @@ if ($user->socid > 0) { $socid = $user->socid; } +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} + $nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $year = GETPOST('year') > 0 ? GETPOSTINT('year') : $nowyear; $startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS')))); diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 49736a0a802..2243e9bafdc 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -41,6 +41,8 @@ $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); $mode = GETPOSTISSET("mode") ? GETPOST("mode", 'aZ09') : 'customer'; +$hookmanager->initHooks(array('orderstats', 'globalcard')); + $usercanreadcustumerstatistic = $user->hasRight('commande', 'lire'); $usercanreadsupplierstatistic = $user->hasRight('fournisseur', 'commande', 'lire'); if (getDolGlobalInt('MAIN_NEED_EXPORT_PERMISSION_TO_READ_STATISTICS')) { @@ -73,6 +75,12 @@ if ($user->socid > 0) { $socid = $user->socid; } +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} + $nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $year = GETPOST('year') > 0 ? GETPOST('year') : $nowyear; $startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS')))); diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index 9858821f747..b4386092f5f 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -44,6 +44,9 @@ $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); $langs->loadLangs(array('bills', 'companies', 'other')); $mode = GETPOST("mode") ? GETPOST("mode") : 'customer'; + +$hookmanager->initHooks(array('invoicestats', 'globalcard')); + if ($mode == 'customer' && !$user->hasRight('facture', 'lire')) { accessforbidden(); } @@ -64,6 +67,12 @@ if ($user->socid > 0) { $socid = $user->socid; } +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} + $nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $year = GETPOST('year') > 0 ? GETPOSTINT('year') : $nowyear; $startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS'))));