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,12 +16,22 @@ class Portal {
public function home() { public function home() {
$this->vars['table'] = 'job_table.html.php'; $this->vars['table'] = 'job_table.html.php';
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 {
if ($_SESSION['userType'] == 'client') { if ($_SESSION['userType'] == 'client') {
$this->vars['jobs'] = $this->jobsTable->find('clientId', $_SESSION['loggedin']); $this->vars['jobs'] = $this->jobsTable->find('clientId', $_SESSION['loggedin']);
} }
else { else {
$this->vars['jobs'] = $this->jobsTable->findAll(); $this->vars['jobs'] = $this->jobsTable->findAll();
} }
}
return ['template' => 'portal.html.php', return ['template' => 'portal.html.php',
'title' => 'Jo\'s Jobs- Jobs', 'title' => 'Jo\'s Jobs- Jobs',
'vars' => $this->vars]; 'vars' => $this->vars];

View File

@ -1,6 +1,6 @@
<h2>Jobs</h2> <h2>Jobs</h2>
<a class="new" href="addjob.php">Add new job</a> <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> <label for="filter">Filter:</label>
<select name="filter"> <select name="filter">
<?php foreach ($cats as $cat) { ?> <?php foreach ($cats as $cat) { ?>

2
todo
View File

@ -7,7 +7,7 @@ Assignment 2:
- Add cats to Jobs page @done - Add cats to Jobs page @done
- Add cats to nav bar @done - Add cats to nav bar @done
- Job list in admin area lists all jobs - 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 - Add filter to be able to filter by cat
- Allow customers to filter by location - Allow customers to filter by location
- Add admin user control to admin panel - Add admin user control to admin panel