From 48508fc429f2a661d16dffc2cc413740ac503efc Mon Sep 17 00:00:00 2001 From: Joshua Perry <45966243+jpez-development@users.noreply.github.com> Date: Sun, 5 Feb 2023 12:55:06 +0000 Subject: [PATCH] adding jobs now works --- jobs/controllers/Portal.php | 27 +++++++++++++++++++++++++-- templates/add.html.php | 6 ------ templates/category_table.html.php | 2 +- templates/job_add.html.php | 18 ++++++++++++++++++ templates/job_table.html.php | 2 +- templates/login.html.php | 2 +- todo | 2 +- 7 files changed, 47 insertions(+), 12 deletions(-) delete mode 100644 templates/add.html.php create mode 100644 templates/job_add.html.php diff --git a/jobs/controllers/Portal.php b/jobs/controllers/Portal.php index 3af29ba..9a858ee 100644 --- a/jobs/controllers/Portal.php +++ b/jobs/controllers/Portal.php @@ -77,9 +77,32 @@ class Portal { } } - //TODO: add functions for adding jobs and categories public function addJob() { - return ['template' => 'add.html.php', + return ['template' => 'job_add.html.php', + 'title' => 'Jo\'s Jobs- Add Job', + 'vars' => $this->vars + ]; + } + + public function addJobSubmit() { + if (count($this->jobsTable->find(['title', 'clientId'], ['value0' => $_POST['title'], 'value1' => $_POST['client_id']])) == 0 && $this->catsTable->find(['name'], ['value0' => $_POST['categoryName']]) != 0) { + $record = [ + 'title' => $_POST['title'], + 'description' => $_POST['description'], + 'salary' => $_POST['salary'], + 'closingDate' => $_POST['closingDate'], + 'categoryId' => $this->catsTable->find(['name'], ['value0' => $_POST['categoryName']])[0]->id, + 'location' => $_POST['location'], + 'clientId' => $_POST['client_id'] + ]; + $this->jobsTable->save($record); + $this->vars['response'] = 'Job made successfully'; + } + else { + $this->vars['response'] = 'Some data was incorrect'; + } + + return ['template' => 'response.html.php', 'title' => 'Jo\'s Jobs- Add Job', 'vars' => $this->vars ]; diff --git a/templates/add.html.php b/templates/add.html.php deleted file mode 100644 index 6b18410..0000000 --- a/templates/add.html.php +++ /dev/null @@ -1,6 +0,0 @@ -
-
- - -
-
\ No newline at end of file diff --git a/templates/category_table.html.php b/templates/category_table.html.php index 0d68d56..7a4edde 100644 --- a/templates/category_table.html.php +++ b/templates/category_table.html.php @@ -13,7 +13,7 @@ Edit
- +
diff --git a/templates/job_add.html.php b/templates/job_add.html.php new file mode 100644 index 0000000..f860398 --- /dev/null +++ b/templates/job_add.html.php @@ -0,0 +1,18 @@ +
+
+ + + + + + + + + + + + + + +
+
\ No newline at end of file diff --git a/templates/job_table.html.php b/templates/job_table.html.php index 4be1a25..e2b5fe5 100644 --- a/templates/job_table.html.php +++ b/templates/job_table.html.php @@ -29,7 +29,7 @@ View applicants (getApps())?>)
- +
diff --git a/templates/login.html.php b/templates/login.html.php index 1db3f4d..d1a0f90 100644 --- a/templates/login.html.php +++ b/templates/login.html.php @@ -8,7 +8,7 @@ - +

diff --git a/todo b/todo index bf6518e..342b61f 100644 --- a/todo +++ b/todo @@ -11,7 +11,7 @@ Assignment 2: - Add filter to be able to filter by cat @done - Allow customers to filter by location @done - Move new framework into project @done - - Fix Adding categories + - Fix Adding categories @done - Archive jobs instead of delete - Add admin user control to admin portal - User accounts made in admin portal