Compare commits

...

10 Commits

Author SHA1 Message Date
Joshua Perry 5cbd031279 comments 2023-02-05 23:35:31 +00:00
Joshua Perry dd6c8d1cab finished 2023-02-05 23:04:45 +00:00
Joshua Perry 1f487fe45e added enquiry admin portal 2023-02-05 16:13:36 +00:00
Joshua Perry e9f4b7de97 contact page added 2023-02-05 15:56:21 +00:00
Joshua Perry 86bb50cc47 user creation portal 2023-02-05 15:36:11 +00:00
Joshua Perry 2e21773018 edit category fixed 2023-02-05 15:05:54 +00:00
Joshua Perry 27d8600ea8 better addjob 2023-02-05 14:58:16 +00:00
Joshua Perry 7e29e9c8b4 can relist archived listings 2023-02-05 14:09:02 +00:00
Joshua Perry d8173208da archive instead of delete 2023-02-05 13:50:57 +00:00
Joshua Perry dfc971f9c0 partial implementation of archive of jobs 2023-02-05 13:13:12 +00:00
28 changed files with 485 additions and 135 deletions

View File

@ -20,14 +20,14 @@ class DatabaseTable {
$this->pdo = new \PDO('mysql:dbname='.$this->schema.';host='.$this->server, $this->username, $this->password);
}
private function insert($record) {
private function insert($record) { //Insert record into table
$keys = \array_keys($record);
$columns = \implode(', ', $keys);
$values = \implode(', :', $keys);
$this->pdo->prepare('INSERT INTO '. $this->table . ' (' . $columns . ') VALUES (:' . $values . ')')->execute($record);
}
private function update($record) {
private function update($record) { //Update record in table
$params = [];
foreach ($record as $key => $value) {
$params[] = $key . ' = :' .$key;
@ -36,7 +36,7 @@ class DatabaseTable {
$this->pdo->prepare('UPDATE '. $this->table .' SET '. \implode(', ', $params) .' WHERE '. $this->pk .' = :primaryKey')->execute($record);
}
public function find($columns, $values, $comparators = ['=', '='], $order = "ASC", $orderColumn = "id") {
public function find($columns, $values, $comparators = ['=', '='], $order = "ASC", $orderColumn = "id") { //Find rows in table
$string = 'SELECT * FROM '.$this->table.' WHERE ';
for ($i = 0; $i < count($values); $i++) {
if ($i > 0) {
@ -51,21 +51,21 @@ class DatabaseTable {
return $stmt->fetchAll();
}
public function findAll() {
public function findAll() { //Find all rows in table
$stmt = $this->pdo->prepare('SELECT * FROM ' . $this->table);
$stmt->setFetchMode(\PDO::FETCH_CLASS, $this->entityClass, $this->entityConstructor);
$stmt->execute();
return $stmt->fetchAll();
}
public function delete($column, $value) {
public function delete($column, $value) { //Delete row from table
$values = [
'value' => $value
];
$this->pdo->prepare('DELETE FROM '. $this->table .' WHERE '. $column .' = :value')->execute($values);
}
public function save($record) {
public function save($record) { //Save record to table
if (empty($record[$this->pk])) {
unset($record[$this->pk]);
}

View File

@ -7,14 +7,14 @@ class EntryPoint {
$this->routes = $routes;
}
public function loadTemplate($fileName, $templateData) {
public function loadTemplate($fileName, $templateData) { //Load HTML template
\extract($templateData);
\ob_start();
require $fileName;
return \ob_get_clean();
}
public function run() {
public function run() { //run response
$route = \ltrim(\explode('?', $_SERVER['REQUEST_URI'])[0], '/');

View File

@ -11,7 +11,7 @@ class Routes {
$this->loginControllers = [];
}
public function getController($controllerName, $functionName) {
public function getController($controllerName, $functionName) { //get controller
$this->checkLogin($controllerName);
@ -29,11 +29,11 @@ class Routes {
}
public function getDefaultRoute() {
public function getDefaultRoute() { //Default request route
return 'controller/home';
}
public function checkLogin($name) {
public function checkLogin($name) { //Check if controller requires user to be logged in
$requiresLogin = $this->loginControllers[$name] ?? false;
if ($requiresLogin && !isset($_SESSION['loggedin'])) {
@ -42,7 +42,7 @@ class Routes {
}
}
//404 Page
public function notFound() {
return ['template' => 'response.html.php',
'title' => '404 Not Found',

View File

@ -1,6 +1,6 @@
<?php
namespace jobs\Entity;
class Applicant {
class Applicant { //Represents Applicant Entity from applicants table
public $id;
public $name;
public $email;

View File

@ -1,6 +1,6 @@
<?php
namespace jobs\Entity;
class Category {
class Category { //Represents category Entity from categories table
public $id;
public $name;
}

27
jobs/Entity/Enquiry.php Normal file
View File

@ -0,0 +1,27 @@
<?php
namespace jobs\Entity;
class Enquiry { //Represents enquiry Entity from enquiries table
public $id;
public $name;
public $email;
public $telephone;
public $enquiry;
public $completed;
public $admin_id;
private $usersTable;
public function __construct(\jobs\JobDatabaseTable $usersTable) {
$this->usersTable = $usersTable;
}
public function getAdmin() { //Get the admin that completed the enquiry
if ($this->completed == 'y') {
return $this->usersTable->find(['id'], ['value0' => $this->admin_id])[0];
}
else {
return 'N/A';
}
}
}
?>

View File

@ -1,6 +1,6 @@
<?php
namespace jobs\Entity;
class Job {
class Job { //Represents Job Entity from jobs table
public $id;
public $title;
public $description;
@ -9,6 +9,7 @@ class Job {
public $location;
public $categoryId;
public $clientId;
public $archived;
private $catsTable;
private $appsTable;
@ -17,11 +18,11 @@ class Job {
$this->appsTable = $appsTable;
}
public function getCat() {
public function getCat() { //Get category job is in
return $this->catsTable->find(['id'], ['value0' => $this->categoryId])[0];
}
public function getApps() {
public function getApps() { //Get applicants for job
return $this->appsTable->find(['jobId'], ['value0' => $this->id]);
}
}

View File

@ -1,6 +1,6 @@
<?php
namespace jobs\Entity;
class User {
class User { //Represents User Entity from userss table
public $id;
public $username;
public $password;

View File

@ -1,6 +1,6 @@
<?php
namespace jobs;
class JobDatabaseTable extends \CSY2028\DatabaseTable {
class JobDatabaseTable extends \CSY2028\DatabaseTable { //Represents A table from the schema for this site
protected $server = 'mysql';
protected $username = 'student';
protected $password = 'student';

View File

@ -1,14 +1,14 @@
<?php
namespace jobs;
class Routes extends \CSY2028\Routes {
class Routes extends \CSY2028\Routes { //Represents the routes for this site
public function __construct() {
$this->setDbTables();
$this->controllers = [
"jobs" => new \jobs\controllers\Jobs($this->databaseTables["jobs"], $this->databaseTables["categories"], $this->databaseTables["applicants"]),
"portal" => new \jobs\controllers\Portal($this->databaseTables["categories"], $this->databaseTables["jobs"], $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'], $this->databaseTables['enquiries']),
"user" => new \jobs\controllers\User($this->databaseTables["users"], $this->databaseTables["categories"])
];
$this->loginControllers = [
@ -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']]);
}
}
?>

View File

@ -4,40 +4,43 @@ 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();
}
public function home() {
$this->vars['jobs'] = $this->jobsTable->find(["closingDate"], ['value0' => date('y-m-d')], ['>'], "DESC", "closingDate");
//Homepage
public function home() { //Route: jobs.v.je/jobs/home
$this->vars['jobs'] = $this->jobsTable->find(["closingDate", 'archived'], ['value0' => date('y-m-d'), 'value1' => 'n'], ['>', '='], "DESC", "closingDate");
return ['template' => 'home.html.php',
'title' => 'Jo\'s Jobs- Home',
'vars' => $this->vars
];
}
public function category() {
//Category pages
public function category() { //Route: jobs.v.je/jobs/category
$cat = $this->catsTable->find(['name'], ['value0' => $_GET['page']]);
if ($cat == null) {
return $this->notFound();
}
else {
if (isset($_GET['filter'])) {
$columns = ['categoryId', "location", 'closingDate'];
if (isset($_GET['filter'])) { //location filter for jobs
$columns = ['categoryId', "location", 'closingDate', 'archived'];
$values = ['value0' => $cat[0]->id,
'value1' => $_GET['filter'],
'value2' => date('y-m-d')
'value2' => date('y-m-d'),
'value3' => 'n'
];
$comparators = ["=","=",">"];
$comparators = ["=","=",">",'='];
$this->vars['jobs'] = $this->jobsTable->find($columns, $values, $comparators);
}
else {
$this->vars['jobs'] = $this->jobsTable->find(['categoryId', 'closingDate'], ["value0" => $cat[0]->id, "value1" => date("y-m-d")], ["=", ">"]);
$this->vars['jobs'] = $this->jobsTable->find(['categoryId', 'closingDate', 'archived'], ["value0" => $cat[0]->id, "value1" => date("y-m-d"), 'value2' => 'n'], ["=", ">", '=']);
}
$this->vars['heading'] = $cat[0]->name;
@ -47,32 +50,52 @@ class Jobs {
];
}
}
public function about() {
//About page
public function about() { //Route: jobs.v.je/jobs/about
return ['template' => 'about.html.php',
'title' => 'Jo\'s Jobs- About us',
'vars' => $this->vars
];
}
public function notFound() {
//Contact page
public function contact() { //Route: jobs.v.je/jobs/contact
return ['template' => 'contact.html.php',
'title' => 'Jo\'s Jobs- Contact',
'vars' => $this->vars
];
}
//Contact page POST
public function contactSubmit() { //Route: jobs.v.je/jobs/contact
$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];
}
//404 page
public function notFound() { //Route: jobs.v.je/jobs/notFound
$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() {
//Job Application page
public function apply() { //Route: jobs.v.je/jobs/apply
$this->vars['job'] = $this->jobsTable->find(['id'], ["value0" => $_GET['id']])[0];
return ['template' => 'apply.html.php',
'title' => 'Jo\'s Jobs- Apply',
'vars' => $this->vars];
}
public function applySubmit() {
//Job Application page POST
public function applySubmit() { //Route: jobs.v.je/jobs/apply
if ($_FILES['cv']['error'] == 0) {
$parts = explode('.', $_FILES['cv']['name']);
$extension = end($parts);
@ -102,8 +125,8 @@ class Jobs {
'vars' => $this->vars];
}
public function faq() {
//FAQ Page
public function faq() { //Route: jobs.v.je/jobs/faq
return ['template' => 'construction.html.php',
'title' => 'Jo\'s Jobs- FAQ',
'vars' => $this->vars];

View File

@ -4,17 +4,21 @@ class Portal {
private $catsTable;
private $jobsTable;
private $appsTable;
private $usersTable;
private $enquiryTable;
private $vars;
public function __construct(\jobs\JobDatabaseTable $catsTable, \jobs\JobDatabaseTable $jobsTable, \jobs\JobDatabaseTable $appsTable) {
public function __construct(\jobs\JobDatabaseTable $catsTable, \jobs\JobDatabaseTable $jobsTable, \jobs\JobDatabaseTable $appsTable, \jobs\JobDatabaseTable $usersTable, \jobs\JobDatabaseTable $enquiryTable) {
$this->catsTable = $catsTable;
$this->jobsTable = $jobsTable;
$this->appsTable = $appsTable;
$this->usersTable = $usersTable;
$this->enquiryTable = $enquiryTable;
$this->vars['cats'] = $this->catsTable->findAll();
$this->vars['table'] = 'job_table.html.php';
}
public function home() {
//Portal homepage
public function home() { //Route: jobs.v.je/portal/
$this->vars['table'] = 'job_table.html.php';
if (isset($_GET['filter'])) {
if ($_SESSION['userType'] == 'client') {
@ -36,19 +40,47 @@ class Portal {
'title' => 'Jo\'s Jobs- Jobs',
'vars' => $this->vars];
}
public function homeSubmit() {
if (isset($_POST['job_id'])) {
$this->jobsTable->delete("id", $_POST['job_id']);
//Portal homepage POST
public function homeSubmit() { //Route: jobs.v.je/portal/
if ($_POST['submit'] == "List") { //Relist archived job
$this->vars['job'] = $this->jobsTable->find(['id'], ['value0' => $_POST['job_id']])[0];
$this->vars['archive'] = true;
$this->vars['update'] = true;
return ['template' => 'job_add.html.php',
'title' => 'Jo\'s Jobs- Update Job',
'vars' => $this->vars];
}
else {
if (isset($_POST['job_id'])) { //archive job
$record = [
'id' => $_POST['job_id'],
'archived' => 'y'
];
$this->jobsTable->save($record);
return $this->home();
}
if (isset($_POST['cat_id'])) {
if (isset($_POST['cat_id'])) { //delete category
$this->catsTable->delete("id", $_POST['cat_id']);
$jobs = $this->jobsTable->find(['categoryId'], ['value0' => $_POST['cat_id']]);
foreach ($jobs as $job) {
$this->jobsTable->delete("id", $job->id);
}
return $this->categories();
}
if (isset($_POST['user_id'])) { //delete user
if($_POST['user_type'] == 'client') {
$this->usersTable->delete('id', $_POST['user_id']);
$jobs = $this->jobsTable->find(['clientId'], ['value0' => $_POST['user_id']]);
foreach ($jobs as $job) {
$this->jobsTable->delete('id', $job->id);
}
public function categories() {
return $this->users();
}
}
}
}
//Categories Portal page
public function categories() { //Route: jobs.v.je/portal/categories
if ($_SESSION['userType'] == 'admin') {
$this->vars['table'] = 'category_table.html.php';
$this->vars['cats'] = $this->catsTable->findAll();
@ -57,8 +89,8 @@ class Portal {
'vars' => $this->vars];
}
}
public function applicants() {
//Applicants Portal page
public function applicants() { //Route: jobs.v.je/portal/applicants
$job = $this->jobsTable->find(['id'], ['value0' => $_GET['job_id']])[0];
$this->vars['table'] = 'applicant_table.html.php';
$this->vars['apps'] = $job->getApps();
@ -67,25 +99,98 @@ class Portal {
'title' => 'Jo\'s Jobs- Applicants',
'vars' => $this->vars];
}
public function edit() { //TODO: finish this function
if (isset($_GET['job_id'])) {
$this->vars['job'] = $this->jobsTable->find(["id"], ['value0' => $_GET['jod_id']]);
}
if (isset($_GET['cat_id'])) {
$this->vars['cat'] = $this->catsTable->find(["id"], ['value0' => $_GET['cat_id']]);
}
}
public function addJob() {
return ['template' => 'job_add.html.php',
'title' => 'Jo\'s Jobs- Add Job',
//Users Portal page
public function users() { //Route: jobs.v.je/portal/users
if ($_SESSION['userType'] == 'admin') {
$this->vars['table'] = 'user_table.html.php';
$this->vars['users'] = $this->usersTable->findAll();
return ['template' => 'portal.html.php',
'title' => 'Jo\'s Jobs- Users',
'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) {
}
//Enquiries Portal page
public function enquiries() { //Route: jobs.v.je/portal/enquiries
if ($_SESSION['userType'] == 'admin') {
$this->vars['table'] = 'enquiry_table.html.php';
$this->vars['enqs'] = $this->enquiryTable->findAll();
return ['template' => 'portal.html.php',
'title' => 'Jo\'s Jobs- Enquiries',
'vars' => $this->vars
];
}
}
//Enquiries Portal page POST
public function enquiriesSubmit() { //Route: jobs.v.je/portal/enquiries
$record = [
'id' => $_POST['enq_id'],
'completed' => 'y',
'admin_id' => $_SESSION['loggedin']
];
$this->enquiryTable->save($record);
$this->enquiries();
}
//Edit User Portal page
public function addUser() { //Route: jobs.v.je/portal/addUser
if ($_SESSION['userType'] == 'admin') {
if (isset($_GET['user_id'])) { //Update user
$this->vars['user'] = $this->usersTable->find(['id'], ['value0' => $_GET['user_id']])[0];
$this->vars['update'] = true;
}
else { //Create user
$this->vars['update'] = false;
}
return ['template' => 'user_add.html.php',
'title' => 'Jo\'s Jobs- Edit user',
'vars' => $this->vars
];
}
}
//Edit User Portal page POST
public function addUserSubmit() {
if ($_SESSION['userType'] == 'admin') {
if($_POST['password'] != "") {
$record = [
'username' => $_POST['username'],
'password' => password_hash($_POST['password'], PASSWORD_DEFAULT),
'userType' => $_POST['type']
];
if ($_POST['submit'] == 'Update') {
$record['id'] = $_POST['user_id'];
$this->vars['response'] = 'User Updated Successfully';
}
else {
$this->vars['response'] = 'User Created Successfully';
}
$this->usersTable->save($record);
return [
'template' => 'response.html.php',
'title' => 'Jo\'s Jobs- Edit user',
'vars' => $this->vars
];
}
}
}
//Edit Job Portal page
public function addJob() { //Route: jobs.v.je/portal/addJob
if (isset($_GET['job_id'])) { //Update Job
$this->vars['job'] = $this->jobsTable->find(["id"], ['value0' => $_GET['job_id']])[0];
$this->vars['archive'] = false;
$this->vars['update'] = true;
}
else { //Create Job
$this->vars['archive'] = false;
$this->vars['update'] = false;
}
return ['template' => 'job_add.html.php',
'title' => 'Jo\'s Jobs- Edit Job',
'vars' => $this->vars
];
}
//Edit Job page POST
public function addJobSubmit() { //Route: jobs.v.je/portal/addJob
if ($this->catsTable->find(['name'], ['value0' => $_POST['categoryName']]) != 0) {
$record = [
'title' => $_POST['title'],
'description' => $_POST['description'],
@ -93,33 +198,49 @@ class Portal {
'closingDate' => $_POST['closingDate'],
'categoryId' => $this->catsTable->find(['name'], ['value0' => $_POST['categoryName']])[0]->id,
'location' => $_POST['location'],
'clientId' => $_POST['client_id']
'clientId' => $_POST['client_id'],
'archived' => $_POST['archived']
];
if ($_POST['submit'] == 'Create' && count($this->jobsTable->find(['title', 'clientId'], ['value0' => $_POST['title'], 'value1' => $_POST['client_id']])) == 0) {
$this->jobsTable->save($record);
$this->vars['response'] = 'Job made successfully';
}
else if ($_POST['submit'] == 'Update') {
$record['id'] = $_POST['jobId'];
$this->jobsTable->save($record);
$this->vars['response'] = 'Job updated successfully';
}
}
else {
$this->vars['response'] = 'Some data was incorrect';
}
return ['template' => 'response.html.php',
'title' => 'Jo\'s Jobs- Add Job',
'title' => 'Jo\'s Jobs- Edit Job',
'vars' => $this->vars
];
}
public function addCategory() {
//Edit Category page
public function addCategory() { //Route: jobs.v.je/portal/addCategory
if ($_SESSION['userType'] == 'admin') {
if (isset($_GET['cat_id'])) {
$this->vars['cat'] = $this->catsTable->find(["id"], ['value0' => $_GET['cat_id']])[0];
$this->vars['update'] = true;
}
else {
$this->vars['update'] = false;
}
return ['template' => 'category_add.html.php',
'title' => 'Jo\'s Jobs- Add Category',
'title' => 'Jo\'s Jobs- Edit Category',
'vars' => $this->vars
];
}
}
public function addCategorySubmit() {
//Edit Category page POST
public function addCategorySubmit() { //Route: jobs.v.je/portal/addCategory
if ($_SESSION['userType'] == 'admin') {
if ($_POST['submit'] == 'Create') {
if (count($this->catsTable->find(['name'], ['value0' => $_POST['name']])) > 0) {
$this->vars['response'] = 'This category already exists';
}
@ -130,8 +251,17 @@ class Portal {
$this->catsTable->save($record);
$this->vars['response'] = 'Category Created';
}
}
else {
$record = [
'id' => $_POST['id'],
'name' => $_POST['name']
];
$this->catsTable->save($record);
$this->vars['response'] = 'Category Updated';
}
return ['template' => 'response.html.php',
'title' => 'Jo\'s Jobs- Add Category',
'title' => 'Jo\'s Jobs- Edit Category',
'vars' => $this->vars
];
}

View File

@ -11,14 +11,14 @@ class User {
$this->vars['cats'] = $this->catsTable->findAll();
$this->vars['response'] = '';
}
public function login() {
//Login page
public function login() { //Route: jobs.v.je/user/login
return ['template' => 'login.html.php',
'title' => 'Jo\'s Jobs- Login',
'vars' => $this->vars];
}
public function loginSubmit() {
//Login page POST
public function loginSubmit() { //Route: jobs.v.je/user/login
if ($_POST['username'] != '' && $_POST['password'] != '') {
$user = $this->usersTable->find(["username"], ['value0' => $_POST['username']]);
if (password_verify($_POST['password'], $user[0]->password)) {
@ -49,8 +49,8 @@ class User {
'vars' => $this->vars
];
}
public function logout() {
//Logout page
public function logout() { //Route: jobs.v.je/user/logout
unset($_SESSION['loggedin']);
unset($_SESSION['userType']);
$this->vars['response'] = 'Logged Out Successfully';

8
phpunit.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0"?>
<phpunit>
<testsuites>
<testsuite name="tests">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>

View File

@ -1,7 +1,7 @@
<?php
session_start();
require '../autoload.php';
$routes = new \jobs\Routes();
$entryPoint = new \CSY2028\EntryPoint($routes);
$entryPoint->run();
session_start(); //make sure session is started
require '../autoload.php'; //include autoload
$routes = new \jobs\Routes(); //get routes
$entryPoint = new \CSY2028\EntryPoint($routes); //get entrypoint
$entryPoint->run(); //start entrypoint
?>

View File

@ -1,7 +1,15 @@
<main class="home">
<form method="post" action="/portal/addCategory">
<label>Enter Category Name</label>
<?php if($update) { ?>
<input type="text" name="name" value="<?=$cat->name?>"/>
<input type="hidden" name="id" value="<?=$cat->id?>"/>
<input type="submit" name="submit" value="Update"/>
<?php }
else { ?>
<input type="text" name="name"/>
<input type="submit" name="submit" value="Create"/>
<?php } ?>
</form>
</main>

View File

@ -10,10 +10,10 @@
<?php foreach ($cats as $cat) { ?>
<tr>
<td><?=$cat->name?></td>
<td><a style="float: right" href="/portal/edit?cat_id=<?=$cat->id?>">Edit</a></td>
<td><a style="float: right" href="/portal/addCategory?cat_id=<?=$cat->id?>">Edit</a></td>
<td><form method="post" action="/portal/">
<input type="hidden" name="cat_id" value="<?=$cat->id?>" />
<input type="submit" name="submit" value="Archive" />
<input type="submit" name="submit" value="Delete" />
</form></td>
</tr>
<?php } ?>

View File

@ -0,0 +1,14 @@
<main class="home">
<h2>Contact Us</h2>
<form method="post" action="/jobs/contact">
<label>Name</label>
<input type="text" name="name" />
<label>Email</label>
<input type="email" name="email" />
<label>Telephone Number</label>
<input type="text" name="number" />
<label>Enquiry</label>
<input type="text" name="enquiry" />
<input type="submit" name="submit" value="Send" />
</form>
</main>

View File

@ -0,0 +1,42 @@
<h2>Enquiries</h2>
<table>
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Telephone</th>
<th>Enquiry</th>
<th>Completed</th>
<th>Handled by</th>
<th style="width: 5%">&nbsp;</th>
<th style="width: 5%">&nbsp;</th>
</tr>
<?php foreach ($enqs as $enq) { ?>
<tr>
<td><?=$enq->name?></td>
<td><?=$enq->email?></td>
<td><?=$enq->telephone?></td>
<td><?=$enq->enquiry?></td>
<td><?=$enq->completed?></td>
<td>
<?php
if ($enq->getAdmin() == 'N/A') {
echo 'N/A';
}
else {
echo $enq->getAdmin()->username;
}
?>
</td>
<?php if($enq->completed == 'n') { ?>
<td>
<form method="post" action="/portal/enquiries">
<input type="hidden" name="enq_id" value="<?=$enq->id?>" />
<input type="submit" name="submit" value="Complete" />
</form>
</td>
<?php } ?>
</tr>
<?php } ?>
</thead>
</table>

View File

@ -1,5 +1,28 @@
<main class="home">
<form method="post" action="/portal/addJob">
<?php if ($update) {?>
<input type="hidden" name="archived" value="<?=$job->archived?>"/>
<label>Enter Job Title</label>
<input type="text" name="title" value="<?=$job->title?>"/>
<label>Enter Job Description</label>
<input type="text" name="description" value="<?=$job->description?>"/>
<label>Enter Salary</label>
<input type="text" name="salary" value="<?=$job->salary?>"/>
<label>Enter Closing Date</label>
<input type="date" name="closingDate" value="<?=$job->closingDate?>"/>
<label>Enter Category Name</label>
<input type="text" name="categoryName" value="<?=$job->getCat()->name?>"/>
<label>Enter Location</label>
<input type="text" name="location" value="<?=$job->location?>"/>
<input type="hidden" name="client_id" value="<?=$job->clientId?>" />
<input type="hidden" name="jobId" value="<?=$job->id?>"/>
<input type="submit" name="submit" value="Update"/>
<?php }
else if ($archive) { ?>
<input type="hidden" name="archived" value="n"/>
<?php }
else { ?>
<input type="hidden" name="archived" value="n"/>
<label>Enter Job Title</label>
<input type="text" name="title"/>
<label>Enter Job Description</label>
@ -14,5 +37,6 @@
<input type="text" name="location"/>
<input type="hidden" name="client_id" value="<?=$_SESSION['loggedin']?>" />
<input type="submit" name="submit" value="Create"/>
<?php } ?>
</form>
</main>

View File

@ -15,6 +15,7 @@
<th>Title</th>
<th style="width: 15%">Salary</th>
<th>Category</th>
<th>Archived</th>
<th style="width: 5%">&nbsp;</th>
<th style="width: 15%">&nbsp;</th>
<th style="width: 5%">&nbsp;</th>
@ -25,12 +26,27 @@
<td><?=$job->title?></td>
<td><?=$job->salary?></td>
<td><?=$job->getCat()->name?></td>
<td><a style="float: right" href="portal/edit?job_id=<?=$job->id?>">Edit</a></td>
<td>
<?php if ($job->archived == 'n') {
echo 'no';
}
if ($job->archived == 'y') {
echo 'yes';
} ?>
</td>
<td><a style="float: right" href="portal/addJob?job_id=<?=$job->id?>">Edit</a></td>
<td><a style="float: right" href="portal/applicants?job_id=<?=$job->id?>">View applicants (<?=count($job->getApps())?>)</a></td>
<td><form method="post" action="portal/">
<td>
<form method="post" action="portal">
<input type="hidden" name="job_id" value="<?=$job->id?>" />
<?php if ($job->archived == 'n') { ?>
<input type="submit" name="submit" value="Archive" />
</form></td>
<?php }
else if ($job->archived == 'y') { ?>
<input type="submit" name="submit" value="List" />
<?php } ?>
</form>
</td>
</tr>
<?php } ?>
</thead>

View File

@ -24,6 +24,7 @@
</li>
<li><a href="/jobs/faq">FAQ</a></li>
<li><a href="/jobs/about">About Us</a></li>
<li><a href="/jobs/contact">Contact</a></li>
</ul>
</nav>
<img src="../images/randombanner.php"/>

View File

@ -4,6 +4,8 @@
<li><a href="/portal">Jobs</a></li>
<?php if ($_SESSION['userType'] == 'admin') { ?>
<li><a href="/portal/categories">Categories</a></li>
<li><a href="/portal/enquiries">Enquiries</a></li>
<li><a href="/portal/users">Users</a></li>
<?php } ?>
</ul>
</section>

View File

@ -0,0 +1,23 @@
<main class="home">
<form method="post" action="/portal/addUser">
<?php if ($update) {?>
<label>Enter Username</label>
<input type="username" name="username" value="<?=$user->username?>"/>
<label>Enter Password</label>
<input type="password" name="password" value=""/>
<label>Enter User Type</label>
<input type="text" name="type" value="<?=$user->userType?>"/>
<input type="hidden" name="user_id" value="<?=$user->id?>" />
<input type="submit" name="submit" value="Update"/>
<?php }
else { ?>
<label>Enter Username</label>
<input type="username" name="username" />
<label>Enter Password</label>
<input type="password" name="password" />
<label>Enter User Type</label>
<input type="text" name="type" />
<input type="submit" name="submit" value="Create"/>
<?php } ?>
</form>
</main>

View File

@ -0,0 +1,23 @@
<h2>Users</h2>
<a class="new" href="/portal/addUser">Add new user</a>
<table>
<thead>
<tr>
<th>Username</th>
<th>User Type</th>
<th style="width: 5%">&nbsp;</th>
<th style="width: 5%">&nbsp;</th>
</tr>
<?php foreach ($users as $user) { ?>
<tr>
<td><?=$user->username?></td>
<td><a style="float: right" href="/portal/addUser?user_id=<?=$user->id?>">Edit</a></td>
<td><form method="post" action="/portal/">
<input type="hidden" name="user_id" value="<?=$user->id?>" />
<input type="hidden" name="user_type" value="<?=$user->userType?>" />
<input type="submit" name="submit" value="Delete" />
</form></td>
</tr>
<?php } ?>
</thead>
</table>

6
tests/testTest.php Normal file
View File

@ -0,0 +1,6 @@
<?php
class DatabaseTableTest extends \PHPUnit\Framework\TestCase {
public function testFindColumnsValues() {
}
}
?>

21
todo
View File

@ -12,20 +12,21 @@ Assignment 2:
- Allow customers to filter by location @done
- Move new framework into project @done
- Fix Adding categories @done
- Archive jobs instead of delete
- Add admin user control to admin portal
- User accounts made in admin portal
- Client user accounts
- Archive jobs instead of delete @done
- Relist archived jobs with new closing date @done
- Add admin user control to admin portal @done
- User accounts made in admin portal @done
- Client user accounts @done
- restricted admin panel @done
- add and archive jobs
- add and archive jobs @done
- see who has applied for jobs @done
- Client can only see their jobs @done
- Homepage has 10 jobs that are about to reach closing date @done
- Contact form on contact page
- forms store data in db
- stored enquiries can be accessed from admin panel
- can mark enquieries as Completed once admin has responded
- Keep list of all previous enquieries and which admin dealt with it
- Contact form on contact page @done
- forms store data in db @done
- stored enquiries can be accessed from admin panel @done
- can mark enquieries as Completed once admin has responded @done
- Keep list of all previous enquieries and which admin dealt with it @done
- Create entity classes for database entities (topic 18) @done
- page 37-38 for implementation @done
- Restrict categories by jobs available past current date @done