From 7e29e9c8b4a05c3165bcab5a6d88c536fd0bba9e Mon Sep 17 00:00:00 2001 From: Joshua Perry <45966243+jpez-development@users.noreply.github.com> Date: Sun, 5 Feb 2023 14:09:02 +0000 Subject: [PATCH] can relist archived listings --- jobs/controllers/Portal.php | 25 ++++++++++++++++++++++--- templates/job_edit.html.php | 12 ++++++++++++ todo | 3 ++- 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 templates/job_edit.html.php diff --git a/jobs/controllers/Portal.php b/jobs/controllers/Portal.php index a17dec8..77b4715 100644 --- a/jobs/controllers/Portal.php +++ b/jobs/controllers/Portal.php @@ -38,8 +38,11 @@ class Portal { } public function homeSubmit() { - if ($_POST['submit'] == "List") { - //TODO: Direct to edit job date + if ($_POST['submit'] == "List") { + $this->vars['job'] = $this->jobsTable->find(['id'], ['value0' => $_POST['job_id']])[0]; + return ['template' => 'job_edit.html.php', + 'title' => 'Jo\'s Jobs- Update Job', + 'vars' => $this->vars]; } else { if (isset($_POST['job_id'])) { @@ -57,6 +60,22 @@ class Portal { } } + public function secondHomeSubmit() { + if(isset($_POST['archived'])) { + $record = [ + 'id' => $_POST['jobId'], + 'closingDate' => $_POST['closingDate'], + 'archived' => $_POST['archived'] + ]; + $this->jobsTable->save($record); + } + $this->vars['response'] = 'Update successful'; + return ['template' => 'response.html.php', + 'title' => 'Jo\'s Jobs- Success', + 'vars' => $this->vars + ]; + } + public function categories() { if ($_SESSION['userType'] == 'admin') { $this->vars['table'] = 'category_table.html.php'; @@ -79,7 +98,7 @@ class Portal { public function edit() { //TODO: finish this function if (isset($_GET['job_id'])) { - $this->vars['job'] = $this->jobsTable->find(["id"], ['value0' => $_GET['jod_id']]); + $this->vars['job'] = $this->jobsTable->find(["id"], ['value0' => $_GET['job_id']]); } if (isset($_GET['cat_id'])) { $this->vars['cat'] = $this->catsTable->find(["id"], ['value0' => $_GET['cat_id']]); diff --git a/templates/job_edit.html.php b/templates/job_edit.html.php new file mode 100644 index 0000000..d1ac4b5 --- /dev/null +++ b/templates/job_edit.html.php @@ -0,0 +1,12 @@ +
+

Update title?>

+
+ archived == 'y') { ?> + + + + + + +
+
\ No newline at end of file diff --git a/todo b/todo index 88e6bf7..9060f64 100644 --- a/todo +++ b/todo @@ -12,7 +12,8 @@ Assignment 2: - Allow customers to filter by location @done - Move new framework into project @done - Fix Adding categories @done - - Archive jobs instead of delete + - Archive jobs instead of delete @done + - Relist archived jobs with new closing date @done - Add admin user control to admin portal - User accounts made in admin portal - Client user accounts