From e9f4b7de9758c6bf70651d10e73b952ba0f89b20 Mon Sep 17 00:00:00 2001 From: Joshua Perry <45966243+jpez-development@users.noreply.github.com> Date: Sun, 5 Feb 2023 15:56:21 +0000 Subject: [PATCH] contact page added --- jobs/Entity/Enquiry.php | 27 +++++++++++++++++++++++++++ jobs/Routes.php | 3 ++- jobs/controllers/Jobs.php | 24 +++++++++++++++++++++++- templates/contact.html.php | 14 ++++++++++++++ templates/layout.html.php | 1 + 5 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 jobs/Entity/Enquiry.php create mode 100644 templates/contact.html.php diff --git a/jobs/Entity/Enquiry.php b/jobs/Entity/Enquiry.php new file mode 100644 index 0000000..10817df --- /dev/null +++ b/jobs/Entity/Enquiry.php @@ -0,0 +1,27 @@ +usersTable = $usersTable; + } + + public function getAdmin() { + if ($completed == 'y') { + return $this->usersTable->find(['id'], ['value0' => $this->admin_id])[0]; + } + else { + return 'N/A'; + } + + } +} +?> \ No newline at end of file diff --git a/jobs/Routes.php b/jobs/Routes.php index c98cf43..7a57f5c 100644 --- a/jobs/Routes.php +++ b/jobs/Routes.php @@ -7,7 +7,7 @@ class Routes extends \CSY2028\Routes { public function __construct() { $this->setDbTables(); $this->controllers = [ - "jobs" => new \jobs\controllers\Jobs($this->databaseTables["jobs"], $this->databaseTables["categories"], $this->databaseTables["applicants"]), + "jobs" => new \jobs\controllers\Jobs($this->databaseTables["jobs"], $this->databaseTables["categories"], $this->databaseTables["applicants"], $this->databaseTables['enquiries']), "portal" => new \jobs\controllers\Portal($this->databaseTables["categories"], $this->databaseTables["jobs"], $this->databaseTables["applicants"], $this->databaseTables['users']), "user" => new \jobs\controllers\User($this->databaseTables["users"], $this->databaseTables["categories"]) ]; @@ -26,6 +26,7 @@ class Routes extends \CSY2028\Routes { $this->databaseTables["applicants"] = new \jobs\JobDatabaseTable('applicants', 'id', '\jobs\Entity\Applicant'); $this->databaseTables["jobs"] = new \jobs\JobDatabaseTable('job', 'id', '\jobs\Entity\Job', [$this->databaseTables["categories"], $this->databaseTables['applicants']]); $this->databaseTables["users"] = new \jobs\JobDatabaseTable('users', 'id', '\jobs\Entity\User'); + $this->databaseTables["enquiries"] = new \jobs\JobDatabaseTable('enquiries', 'id', '\jobs\Entity\Enquiry', [$this->databaseTables['users']]); } } ?> \ No newline at end of file diff --git a/jobs/controllers/Jobs.php b/jobs/controllers/Jobs.php index aee6298..9831c2a 100644 --- a/jobs/controllers/Jobs.php +++ b/jobs/controllers/Jobs.php @@ -4,12 +4,14 @@ class Jobs { private $jobsTable; private $catsTable; private $appsTable; + private $enquiryTable; private $vars = []; - public function __construct(\jobs\JobDatabaseTable $jobsTable, \jobs\JobDatabaseTable $catsTable, \jobs\JobDatabaseTable $appsTable) { + public function __construct(\jobs\JobDatabaseTable $jobsTable, \jobs\JobDatabaseTable $catsTable, \jobs\JobDatabaseTable $appsTable, \jobs\JobDatabaseTable $enquiryTable) { $this->jobsTable = $jobsTable; $this->catsTable = $catsTable; $this->appsTable = $appsTable; + $this->enquiryTable = $enquiryTable; $this->vars['cats'] = $this->catsTable->findAll(); } @@ -56,6 +58,26 @@ class Jobs { ]; } + public function contact() { + return ['template' => 'contact.html.php', + 'title' => 'Jo\'s Jobs- Contact', + 'vars' => $this->vars + ]; + } + + public function contactSubmit() { + $record = [ + 'name' => $_POST['name'], + 'email' => $_POST['email'], + 'telephone' => $_POST['number'], + 'enquiry' => $_POST['enquiry'] + ]; + $this->enquiryTable->save($record); + $this->vars['response'] = 'Enquiry Sent'; + return ['template' => 'response.html.php', + 'title' => 'Jo\'s Jobs- Enquiry Sent', + 'vars' => $this->vars]; + } public function notFound() { $this->vars['response'] = 'The page you have requested has not been found'; diff --git a/templates/contact.html.php b/templates/contact.html.php new file mode 100644 index 0000000..39df2a7 --- /dev/null +++ b/templates/contact.html.php @@ -0,0 +1,14 @@ +
+

Contact Us

+
+ + + + + + + + + +
+
\ No newline at end of file diff --git a/templates/layout.html.php b/templates/layout.html.php index e217bbd..fb821eb 100644 --- a/templates/layout.html.php +++ b/templates/layout.html.php @@ -24,6 +24,7 @@
  • FAQ
  • About Us
  • +
  • Contact