Skip to content

Commit

Permalink
[bvl_feedback][dashboard] Add project/site specs to widget
Browse files Browse the repository at this point in the history
  • Loading branch information
CamilleBeau committed Dec 6, 2022
1 parent 6eb61c5 commit 3b17859
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions modules/bvl_feedback/php/module.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,31 @@ class Module extends \Module

$last_login = $user->getLastLogin($DB);

$bvl_feedback = $DB->pselect(
"SELECT fbt.Name, fbe.Testdate, fbe.Comment, fbth.FieldName,
// Base query
$query = "SELECT fbt.Name, fbe.Testdate, fbe.Comment, fbth.FieldName,
fbth.CommentID, fbth.SessionID, fbth.CandID, fbth.Feedback_level
FROM feedback_bvl_entry fbe
JOIN feedback_bvl_thread fbth USING (FeedbackID)
JOIN feedback_bvl_type fbt USING (Feedback_type)
WHERE fbth.Status='opened' AND fbth.Active='Y'
ORDER BY Testdate DESC LIMIT 4",
[]
JOIN session s ON s.ID=fbth.SessionID
WHERE fbth.Status='opened' AND fbth.Active='Y'";

// Add centerID restriction if needed
if (!$user->hasPermission('access_all_profiles')) {
$site_arr = implode(",",$user->getCenterIDs());
$query .= " AND s.CenterID IN ({$site_arr}) ";
}

// Add project restriction & order BY
$project_arr = implode(",",$user->getProjectIDs());
$query .= " AND s.ProjectID IN ({$project_arr})
ORDER BY Testdate DESC LIMIT 4";

$bvl_feedback = $DB->pselect(
$query,
array()
);

$frontend_feedback = [];
foreach ($bvl_feedback as $row) {
if (new \DateTime($row['Testdate']) > $last_login) {
Expand Down

0 comments on commit 3b17859

Please # to comment.