diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php index b37c0a9..941b7ee 100644 --- a/app/Controllers/DashboardController.php +++ b/app/Controllers/DashboardController.php @@ -18,6 +18,8 @@ class DashboardController extends ResourceController { $manager_id = $this->request->getGet('manager_id'); + $staff_id = $this->request->getGet('staff_id') ?? ''; + $today = date('Y-m-d'); $month = date('m'); $year = date('Y'); @@ -122,8 +124,7 @@ class DashboardController extends ResourceController // ->groupBy('ps.id, ps.name') // ->get()->getResultArray(); - - $staffLevelPendingSummary = $this->db->table('partner_enquiry pe') + $builder = $this->db->table('partner_enquiry pe') ->select(" ps.name AS staff_name, ps.id AS staff_id, @@ -140,11 +141,17 @@ class DashboardController extends ResourceController ->where('pe.is_active', 1) ->where('pe.assigned_to IS NOT NULL') ->where('ps.name IS NOT NULL') - ->where('pe.assigned_to !=', 0) - ->groupBy('pe.assigned_to') - ->orderBy('ps.name', 'ASC') - ->get() - ->getResultArray(); + ->where('pe.assigned_to !=', 0); + + if (!empty($staff_id)) { + $builder->where('ps.id', $staff_id); + } + + $staffLevelPendingSummary = $builder + ->groupBy('pe.assigned_to') + ->orderBy('ps.name', 'ASC') + ->get() + ->getResultArray(); foreach ($staffLevelPendingSummary as &$row) {