Hook doAction on statistics pages (#33532)

* Hook doAction on statistics pages

* Hook doAction on statistics pages

* Update index.php

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
Clément 2025-03-19 18:02:28 +01:00 committed by GitHub
parent 36e694e158
commit 9d25e2cd58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 24 additions and 0 deletions

View file

@ -42,6 +42,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$WIDTH = DolGraph::getDefaultGraphSizeForStats('width');
$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
$hookmanager->initHooks(array('expeditionstats', 'globalcard'));
$userid = GETPOSTINT('userid');
$socid = GETPOSTINT('socid');
// Security check
@ -50,6 +52,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 = (int) dol_print_date(dol_now(), "%Y");
$year = GETPOSTINT('year') > 0 ? GETPOSTINT('year') : $nowyear;
$startyear = $year - (!getDolGlobalInt('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, getDolGlobalInt('MAIN_STATS_GRAPHS_SHOW_N_YEARS'))));

View file

@ -44,6 +44,8 @@ $langs->loadLangs(array('trips', 'companies'));
$WIDTH = DolGraph::getDefaultGraphSizeForStats('width');
$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
$hookmanager->initHooks(array('expensereportstats', 'globalcard'));
$mode = GETPOSTISSET("mode") ? GETPOST("mode", 'aZ09') : 'customer';
$object_status = GETPOST('object_status', 'intcomma');
@ -64,6 +66,12 @@ if ($user->socid) {
}
$result = restrictedArea($user, 'expensereport', $id, '');
$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'))));

View file

@ -43,9 +43,17 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$WIDTH = DolGraph::getDefaultGraphSizeForStats('width');
$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
$hookmanager->initHooks(array('receptionstats', 'globalcard'));
$userid = GETPOSTINT('userid');
$socid = GETPOSTINT('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 = (int) dol_print_date(dol_now('gmt'), "%Y", 'gmt');
$year = GETPOSTINT('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'))));