diff --git a/jobs/controllers/Portal.php b/jobs/controllers/Portal.php index 2a112d3..3af29ba 100644 --- a/jobs/controllers/Portal.php +++ b/jobs/controllers/Portal.php @@ -56,12 +56,6 @@ class Portal { '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() { @@ -86,8 +80,38 @@ class Portal { //TODO: add functions for adding jobs and categories public function addJob() { return ['template' => 'add.html.php', - 'title' => 'Add Job', - 'vars' => $this->vars]; + 'title' => 'Jo\'s Jobs- Add Job', + 'vars' => $this->vars + ]; + } + + public function addCategory() { + if ($_SESSION['userType'] == 'admin') { + return ['template' => 'category_add.html.php', + 'title' => 'Jo\'s Jobs- Add Category', + 'vars' => $this->vars + ]; + } + } + + public function addCategorySubmit() { + if ($_SESSION['userType'] == 'admin') { + + if (count($this->catsTable->find(['name'], ['value0' => $_POST['name']])) > 0) { + $this->vars['response'] = 'This category already exists'; + } + else { + $record = [ + 'name' => $_POST['name'] + ]; + $this->catsTable->save($record); + $this->vars['response'] = 'Category Created'; + } + return ['template' => 'response.html.php', + 'title' => 'Jo\'s Jobs- Add Category', + 'vars' => $this->vars + ]; + } } } ?> \ No newline at end of file diff --git a/templates/category_add.html.php b/templates/category_add.html.php new file mode 100644 index 0000000..e7e3abd --- /dev/null +++ b/templates/category_add.html.php @@ -0,0 +1,7 @@ +
+
+ + + +
+
\ No newline at end of file diff --git a/templates/category_table.html.php b/templates/category_table.html.php index 3362b1e..0d68d56 100644 --- a/templates/category_table.html.php +++ b/templates/category_table.html.php @@ -1,5 +1,5 @@

Categories

-Add new category +Add new category diff --git a/templates/login.html.php b/templates/login.html.php index d1a0f90..1db3f4d 100644 --- a/templates/login.html.php +++ b/templates/login.html.php @@ -8,7 +8,7 @@ - +