Skip to content

Commit

Permalink
Evarisk#3982 [RiskAssessment] fix: improve filter on risklist not in …
Browse files Browse the repository at this point in the history
…unactive elements on others entity
  • Loading branch information
evarisk-micka committed Jul 11, 2024
1 parent f0f02d8 commit 99af969
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
22 changes: 13 additions & 9 deletions class/riskanalysis/risk.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ public function fetchRisksOrderedByCotation($parent_id, $get_children_data = fal
$objects = $object->getActiveDigiriskElements();

if ($get_shared_data) {
$risk->ismultientitymanaged = 0;
$activeDigiriskElements = $object->getActiveDigiriskElements($get_shared_data);
$risk->ismultientitymanaged = 0;
$riskAssessment->ismultientitymanaged = 0;
}
$riskList = $risk->fetchAll('', '', 0, 0, ['customsql' => 'status = ' . self::STATUS_VALIDATED . $moreParams['filterRisk']]);
Expand Down Expand Up @@ -305,11 +306,12 @@ public function fetchRisksOrderedByCotation($parent_id, $get_children_data = fal
$digiriskElementOfEntity->fetchObjectLinked(null, '', $digiriskElementOfEntity->id, 'digiriskdolibarr_digiriskelement', 'AND', 1, 'sourcetype', 0);
if (!empty($digiriskElementOfEntity->linkedObjectsIds['digiriskdolibarr_risk'])) {
foreach ($digiriskElementOfEntity->linkedObjectsIds['digiriskdolibarr_risk'] as $sharedRiskId) {
$sharedRisk = $riskList[$sharedRiskId];
if (is_object($sharedRisk)) {
$clonedRisk = clone $sharedRisk;
$sharedRisk = $riskList[$sharedRiskId];
$sharedParentActive = array_search($sharedRisk->fk_element, array_column($activeDigiriskElements, 'id'));
if (is_object($sharedRisk) && $sharedParentActive > 0) {
$clonedRisk = clone $sharedRisk;
$clonedRisk->appliedOn = $digiriskElementOfEntity->id;
$risks[] = $clonedRisk;
$risks[] = $clonedRisk;
}
}
}
Expand All @@ -321,10 +323,12 @@ public function fetchRisksOrderedByCotation($parent_id, $get_children_data = fal
$parentElement->fetchObjectLinked(null, '', $parent_id, 'digiriskdolibarr_digiriskelement', 'AND', 1, 'sourcetype', 0);
if (!empty($parentElement->linkedObjectsIds['digiriskdolibarr_risk'])) {
foreach ($parentElement->linkedObjectsIds['digiriskdolibarr_risk'] as $sharedRiskId) {
$sharedRisk = $riskList[$sharedRiskId];
if (is_object($sharedRisk)) {
$sharedRisk->appliedOn = $parent_id;
$risks[] = $sharedRisk;
$sharedRisk = $riskList[$sharedRiskId];
$sharedParentActive = array_search($sharedRisk->fk_element, array_column($activeDigiriskElements, 'id'));
if (is_object($sharedRisk) && $sharedParentActive > 0) {
$clonedRisk = clone $sharedRisk;
$clonedRisk->appliedOn = $parent_id;
$risks[] = $clonedRisk;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
}
$sql .= " AND el.sourcetype = 'digiriskdolibarr_risk'";
$sql .= ' AND r.type = "' . $riskType . '"';
$sql .= ' AND e.rowid IN (' . implode(',', array_keys($alldigiriskelement)) . ')';

foreach ($search as $key => $val) {
if ($key == 'status' && $search[$key] == -1) continue;
Expand Down Expand Up @@ -234,6 +235,7 @@
}
$sql .= " AND el.sourcetype = 'digiriskdolibarr_risk'";
$sql .= ' AND r.type = "' . $riskType . '"';
$sql .= ' AND e.rowid IN (' . implode(',', array_keys($alldigiriskelement)) . ')';

foreach ($search as $key => $val) {
if ($key == 'status' && $search[$key] == -1) continue;
Expand Down

0 comments on commit 99af969

Please sign in to comment.