From 699eb929f1eb10b0dc63b6ccf5048d3aacbfb363 Mon Sep 17 00:00:00 2001 From: Joshua Perry <45966243+jpez-development@users.noreply.github.com> Date: Wed, 25 Jan 2023 16:16:14 +0000 Subject: [PATCH] Added filter to job list in portal --- jobs/controllers/Portal.php | 18 ++++++++++++++---- templates/job_table.html.php | 2 +- todo | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/jobs/controllers/Portal.php b/jobs/controllers/Portal.php index 8b7b2ed..5fca19c 100644 --- a/jobs/controllers/Portal.php +++ b/jobs/controllers/Portal.php @@ -16,11 +16,21 @@ class Portal { public function home() { $this->vars['table'] = 'job_table.html.php'; - if ($_SESSION['userType'] == 'client') { - $this->vars['jobs'] = $this->jobsTable->find('clientId', $_SESSION['loggedin']); - } + if (isset($_GET['filter'])) { + if ($_SESSION['userType'] == 'client') { + $this->vars['jobs'] = $this->jobsTable->find('clientId', $_SESSION['loggedin'], "categoryId", $_GET['filter']); + } + else { + $this->vars['jobs'] = $this->jobsTable->find("categoryId", $_GET['filter']); + } + } else { - $this->vars['jobs'] = $this->jobsTable->findAll(); + if ($_SESSION['userType'] == 'client') { + $this->vars['jobs'] = $this->jobsTable->find('clientId', $_SESSION['loggedin']); + } + else { + $this->vars['jobs'] = $this->jobsTable->findAll(); + } } return ['template' => 'portal.html.php', 'title' => 'Jo\'s Jobs- Jobs', diff --git a/templates/job_table.html.php b/templates/job_table.html.php index 9cf148c..b3feff1 100644 --- a/templates/job_table.html.php +++ b/templates/job_table.html.php @@ -1,6 +1,6 @@

Jobs

Add new job -
+