Added filter to job list in portal

This commit is contained in:
Joshua Perry 2023-01-25 16:16:14 +00:00
parent 69da9ef69b
commit 699eb929f1
3 changed files with 16 additions and 6 deletions

View File

@ -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',

View File

@ -1,6 +1,6 @@
<h2>Jobs</h2>
<a class="new" href="addjob.php">Add new job</a>
<form method="post" action="portal/">
<form method="get" action="/portal">
<label for="filter">Filter:</label>
<select name="filter">
<?php foreach ($cats as $cat) { ?>

2
todo
View File

@ -7,7 +7,7 @@ Assignment 2:
- Add cats to Jobs page @done
- Add cats to nav bar @done
- Job list in admin area lists all jobs
- Add cat name as new column in table
- Add cat name as new column in table @done
- Add filter to be able to filter by cat
- Allow customers to filter by location
- Add admin user control to admin panel