-
-
- Jobs -
- Categories - -
From 05ee8bbeb892ed3fef84518f7ba656604c2a5e9c Mon Sep 17 00:00:00 2001 From: Joshua Perry <45966243+jpez-development@users.noreply.github.com> Date: Mon, 23 Jan 2023 17:50:11 +0000 Subject: [PATCH] Added apply page --- jobs/controllers/Jobs.php | 42 ++++++++++- pages/apply.php | 145 -------------------------------------- templates/apply.html.php | 29 ++++++++ 3 files changed, 69 insertions(+), 147 deletions(-) delete mode 100644 pages/apply.php create mode 100644 templates/apply.html.php diff --git a/jobs/controllers/Jobs.php b/jobs/controllers/Jobs.php index e9d1c74..0f033f0 100644 --- a/jobs/controllers/Jobs.php +++ b/jobs/controllers/Jobs.php @@ -3,11 +3,13 @@ namespace jobs\controllers; class Jobs { private $jobsTable; private $catsTable; + private $appsTable; private $vars = []; - public function __construct(\CSY2028\DatabaseTable $jobsTable, \CSY2028\DatabaseTable $catsTable) { + public function __construct(\CSY2028\DatabaseTable $jobsTable, \CSY2028\DatabaseTable $catsTable, \CSY2028\DatabaseTable $appsTable) { $this->jobsTable = $jobsTable; $this->catsTable = $catsTable; + $this->appsTable = $appsTable; $this->vars['cats'] = $this->catsTable->findAll(); } @@ -40,11 +42,47 @@ class Jobs { ]; } + public function notFound() { - return ['template' => 'notFound.html.php', + $this->vars['response'] = 'The page you have requested has not been found'; + return ['template' => 'response.html.php', 'title' => 'Jo\'s Jobs- 404 Not Found', 'vars' => $this->vars ]; } + + public function apply() { + $this->vars['job'] = $this->jobsTable->find('id', $_GET['id'])[0]; + return ['template' => 'apply.html.php', + 'title' => 'Jo\'s Jobs- Apply', + 'vars' => $this->vars]; + + } + + public function applySubmit() { + if ($_FILES['cv']['error'] == 0) { + $parts = explode('.', $_FILES['cv']['name']); + $extension = end($parts); + $fileName = uniqid() . '.' . $extension; + move_uploaded_file($_FILES['cv']['tmp_name'], 'cvs/' . $fileName); + $record = [ + 'name' => $_POST['name'], + 'email' => $_POST['email'], + 'details' => $_POST['details'], + 'jobId' => $_POST['jobId'], + 'cv' => $fileName + ]; + $this->appsTable->save($record); + $this->vars['response'] = 'Your application is complete. We will contact you after the closing date.'; + } + else { + $this->vars['response'] = 'There was an error uploading your CV'; + } + + return ['template' => 'response.html.php', + 'title' => 'Jo\'s Jobs- Apply', + 'vars' => $this->vars]; + + } } ?> \ No newline at end of file diff --git a/pages/apply.php b/pages/apply.php deleted file mode 100644 index 055e8ac..0000000 --- a/pages/apply.php +++ /dev/null @@ -1,145 +0,0 @@ - - - -
- -