diff --git a/jobs/controllers/Portal.php b/jobs/controllers/Portal.php index e69de29..8b7b2ed 100644 --- a/jobs/controllers/Portal.php +++ b/jobs/controllers/Portal.php @@ -0,0 +1,73 @@ +catsTable = $catsTable; + $this->jobsTable = $jobsTable; + $this->appsTable = $appsTable; + $this->vars['cats'] = $this->catsTable->findAll(); + $this->vars['table'] = 'job_table.html.php'; + } + + public function home() { + $this->vars['table'] = 'job_table.html.php'; + 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', + 'vars' => $this->vars]; + } + + public function homeSubmit() { + if (isset($_POST['job_id'])) { + $this->jobsTable->delete("id", $_POST['job_id']); + return $this->home(); + } + if (isset($_POST['cat_id'])) { + $this->catsTable->delete("id", $_POST['cat_id']); + return $this->categories(); + } + } + + public function categories() { + if ($_SESSION['userType'] == 'admin') { + $this->vars['table'] = 'category_table.html.php'; + $this->vars['cats'] = $this->catsTable->findAll(); + return ['template' => 'portal.html.php', + 'title' => 'Jo\'s Jobs- Categories', + 'vars' => $this->vars]; + } + else { + $this->vars['response'] = 'You do not have access to this page'; + return ['template' => 'response.html.php', + 'title' => 'Jo\'s Jobs- Access Denied', + 'vars' => $this->vars]; + } + } + + public function applicants() { + $this->vars['table'] = 'applicant_table.html.php'; + $this->vars['apps'] = $this->appsTable->find('jobId', $_GET['app_id']); + return ['template' => 'portal.html.php', + 'title' => 'Jo\'s Jobs- Applicants', + 'vars' => $this->vars]; + } + + public function edit() { + if (isset($_GET['job_id'])) { + $this->vars['job'] = $this->jobsTable->find("id", $_GET['jod_id']); + } + if (isset($_GET['cat_id'])) { + $this->vars['cat'] = $this->catsTable->find("id", $_GET['cat_id']); + } + } +} \ No newline at end of file