Skip to content

Commit bdd3527

Browse files
committed
#4112 [Dashboard] fix: moreparam for dashboard request
1 parent 1968cce commit bdd3527

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

class/accident.class.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -661,13 +661,19 @@ public function getNbPresquAccidents(): array
661661
/**
662662
* Get number accident investigations
663663
*
664+
* @param array $moreParam More param (Object/user/etc)
664665
* @return array
665666
* @throws Exception
666667
*/
667-
public function getNbAccidentInvestigations(): array
668+
public function getNbAccidentInvestigations(array $moreParam = []): array
668669
{
669-
$accidentInvestigation = new AccidentInvestigation($this->db);
670-
$accidentInvestigations = $accidentInvestigation->fetchAll('', '', 0, 0, ['customsql' => ' t.status > ' . AccidentInvestigation::STATUS_DRAFT]);
670+
require_once __DIR__ . '/accidentinvestigation.class.php';
671+
672+
$accidentInvestigation = new AccidentInvestigation($this->db);
673+
if (strpos($moreParam['filter'], 't.entity') !== false) {
674+
$accidentInvestigation->ismultientitymanaged = 0;
675+
}
676+
$accidentInvestigations = $accidentInvestigation->fetchAll('', '', 0, 0, ['customsql' => ' t.status > ' . AccidentInvestigation::STATUS_DRAFT . $moreParam['filter']]);
671677
if (!empty($accidentInvestigations) && is_array($accidentInvestigations)) {
672678
$array['nbaccidentinvestigations'] = count($accidentInvestigations);
673679
} else {

class/evaluator.class.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,13 @@ public function load_dashboard(): array
158158
/**
159159
* Get number employees involved.
160160
*
161-
* @return array
161+
* @param array $moreParam More param (Object/user/etc)
162+
* @return array
162163
* @throws Exception
163164
*/
164-
public function getNbEmployeesInvolved() {
165+
public function getNbEmployeesInvolved(array $moreParam = []) {
165166
// Number employees involved
166-
$allevaluators = $this->fetchAll('','', 0, 0, array(), 'AND', 'fk_user');
167+
$allevaluators = $this->fetchAll('','', 0, 0, ['customsql' => $moreParam['filter']], 'AND', 'fk_user');
167168
if (is_array($allevaluators) && !empty($allevaluators)) {
168169
$array['nbemployeesinvolved'] = count($allevaluators);
169170
} else {
@@ -175,17 +176,18 @@ public function getNbEmployeesInvolved() {
175176
/**
176177
* Get number employees
177178
*
179+
* @param array $moreParam More param (Object/user/etc)
178180
* @return array
179181
* @throws Exception
180182
*/
181-
public function getNbEmployees(): array
183+
public function getNbEmployees(array $moreParam = []): array
182184
{
183185
global $user;
184186

185187
if (getDolGlobalInt('DIGIRISKDOLIBARR_NB_EMPLOYEES') > 0 && getDolGlobalInt('DIGIRISKDOLIBARR_MANUAL_INPUT_NB_EMPLOYEES')) {
186188
$array['nbemployees'] = getDolGlobalInt('DIGIRISKDOLIBARR_NB_EMPLOYEES');
187189
} else {
188-
$users = $user->get_full_tree(0, 'u.employee = 1');
190+
$users = $user->get_full_tree(0, 'u.employee = 1' . $moreParam['filter']);
189191
if (!empty($users) && is_array($users)) {
190192
$array['nbemployees'] = count($users);
191193
} else {

class/riskanalysis/risk.class.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -641,11 +641,11 @@ public function load_dashboard(): array
641641
/**
642642
* Get risks by cotation
643643
*
644-
* @param string $filter SQL Filter
644+
* @param array $moreParam More param (Object/user/etc)
645645
* @return array
646646
* @throws Exception
647647
*/
648-
public function getRisksByCotation(string $filter = ''): array
648+
public function getRisksByCotation(array $moreParam = []): array
649649
{
650650
global $conf, $langs;
651651

@@ -667,7 +667,7 @@ public function getRisksByCotation(string $filter = ''): array
667667
$join = ' LEFT JOIN ' . MAIN_DB_PREFIX . $this->table_element . ' as r ON r.rowid = t.fk_risk';
668668
$join .= ' LEFT JOIN ' . MAIN_DB_PREFIX . $digiriskElement->table_element . ' as d ON d.rowid = r.fk_element';
669669

670-
$riskAssessments = saturne_fetch_all_object_type('RiskAssessment', '', '', 0, 0, ['customsql' => 't.status = ' . RiskAssessment::STATUS_VALIDATED . ' AND r.fk_element NOT IN ' . $filter], 'AND', false, true, false, $join);
670+
$riskAssessments = saturne_fetch_all_object_type('RiskAssessment', '', '', 0, 0, ['customsql' => 't.status = ' . RiskAssessment::STATUS_VALIDATED . ' AND r.fk_element NOT IN ' . $moreParam['filter']], 'AND', false, $moreParam['multiEntityManagement'], false, $join);
671671
$array['data'] = $riskAssessment->getRiskAssessmentCategoriesNumber($riskAssessments);
672672

673673
return $array;

0 commit comments

Comments
 (0)