diff --git a/CSY2028/DatabaseTable.php b/CSY2028/DatabaseTable.php index 292d86d..865360c 100644 --- a/CSY2028/DatabaseTable.php +++ b/CSY2028/DatabaseTable.php @@ -36,12 +36,12 @@ class DatabaseTable { $this->pdo->prepare('UPDATE '. $this->table .' SET '. \implode(', ', $params) .' WHERE '. $this->pk .' = :primaryKey')->execute($record); } - public function find($column, $value, $column2 = "", $value2 = "") { + public function find($column, $value, $comparator = "=", $order = "ASC", $column2 = "", $value2 = "") { if ($column2 == "" && $value2 == "") { $values = [ 'value' => $value ]; - $stmt = $this->pdo->prepare('SELECT * FROM '. $this->table . ' WHERE '. $column . ' = :value'); + $stmt = $this->pdo->prepare('SELECT * FROM '. $this->table . ' WHERE '. $column . ' '. $comparator .' :value ORDER BY '. $column ." ". $order); $stmt->setFetchMode(\PDO::FETCH_CLASS, $this->entityClass, $this->entityConstructor); $stmt->execute($values); return $stmt->fetchAll(); @@ -51,7 +51,7 @@ class DatabaseTable { 'value' => $value, 'value2' => $value2 ]; - $stmt = $this->pdo->prepare('SELECT * FROM '. $this->table . ' WHERE '. $column . ' = :value AND '. $column2 .' = :value2'); + $stmt = $this->pdo->prepare('SELECT * FROM '. $this->table . ' WHERE '. $column . ' '. $comparator .' :value AND '. $column2 .' = :value2'); $stmt->setFetchMode(\PDO::FETCH_CLASS, $this->entityClass, $this->entityConstructor); $stmt->execute($values); return $stmt->fetchAll(); diff --git a/jobs/Routes.php b/jobs/Routes.php index 07fe6c0..dcfbb78 100644 --- a/jobs/Routes.php +++ b/jobs/Routes.php @@ -2,8 +2,10 @@ namespace jobs; class Routes extends \CSY2028\Routes { + + public function __construct() { - setDbTables(); + $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"]), diff --git a/jobs/controllers/Jobs.php b/jobs/controllers/Jobs.php index 1d2f34f..f4a2609 100644 --- a/jobs/controllers/Jobs.php +++ b/jobs/controllers/Jobs.php @@ -14,6 +14,7 @@ class Jobs { } public function home() { + $this->vars['jobs'] = $this->jobsTable->find("closingDate", date("y-m-d"), ">", "DESC"); return ['template' => 'home.html.php', 'title' => 'Jo\'s Jobs- Home', 'vars' => $this->vars diff --git a/jobs/controllers/Portal.php b/jobs/controllers/Portal.php index 8c41182..a3a446c 100644 --- a/jobs/controllers/Portal.php +++ b/jobs/controllers/Portal.php @@ -82,5 +82,10 @@ class Portal { } //TODO: add functions for adding jobs and categories + public function addJob() { + return ['template' => 'add.html.php', + 'title' => 'Add Job', + 'vars' => $this->vars]; + } } ?> \ No newline at end of file diff --git a/templates/about.html.php b/templates/about.html.php index fe7e608..e8a1e41 100644 --- a/templates/about.html.php +++ b/templates/about.html.php @@ -1,8 +1,11 @@ -

Welcome to Jo's Jobs, we're a recruitment agency based in Northampton. We offer a range of different office jobs. Get in touch if you'd like to list a job with us.

Select the type of job you are looking for:

diff --git a/templates/add.html.php b/templates/add.html.php new file mode 100644 index 0000000..6b18410 --- /dev/null +++ b/templates/add.html.php @@ -0,0 +1,6 @@ +
+
+ + +
+
\ No newline at end of file diff --git a/templates/category.html.php b/templates/category.html.php index 3698cfd..678ef59 100644 --- a/templates/category.html.php +++ b/templates/category.html.php @@ -1,8 +1,12 @@
+ +
  • + name?> +
  • + +
    diff --git a/templates/home.html.php b/templates/home.html.php index c7f6c12..9070aef 100644 --- a/templates/home.html.php +++ b/templates/home.html.php @@ -1,7 +1,18 @@

    Welcome to Jo's Jobs, we're a recruitment agency based in Northampton. We offer a range of different office jobs. Get in touch if you'd like to list a job with us.

    -

    Select the type of job you are looking for:

    -
      - -
    +
    +

    Select the type of job you are looking for:

    + +
    +
    +

    Jobs About to close:

    +
      + +
    \ No newline at end of file diff --git a/templates/job_table.html.php b/templates/job_table.html.php index 5144216..63ee4a3 100644 --- a/templates/job_table.html.php +++ b/templates/job_table.html.php @@ -1,5 +1,5 @@

    Jobs

    -Add new job +Add new job