diff options
Added skeleton of edit offer and implemented edit and delete buttons in dashboard offers
5 files changed, 42 insertions, 3 deletions
| -rw-r--r-- | src/controllers/DashboardController.php | 14 | ||||
| -rw-r--r-- | src/controllers/DashboardLoginController.php | 8 | ||||
| -rw-r--r-- | src/controllers/EditOfferController.php | 5 | ||||
| -rw-r--r-- | src/views/dashboard.php | 17 | ||||
| -rw-r--r-- | src/views/edit-offer.php | 1 |
diff --git a/src/controllers/DashboardController.php b/src/controllers/DashboardController.php index 84beb14..7c01efa 100644 --- a/src/controllers/DashboardController.php +++ b/src/controllers/DashboardController.php @@ -1,8 +1,22 @@ <?php include_once('controllers/BaseController.php'); +include_once('models/JobOffer.php'); +include_once('controllers/EditOfferController.php'); class DashboardController extends BaseController { public static function get() { + $jobs = JobOffer::getAllFromDB(); include "views/dashboard.php"; } + + public static function post() { + if ($_POST['_method'] == "put") { + $_SERVER['REQUEST_METHOD'] = "PUT"; + EditOfferController::invoke(); + } + else if ($_POST['_method'] == "delete") { + $_SERVER['REQUEST_METHOD'] = "DELETE"; + EditOfferController::invoke(); + } + } } diff --git a/src/controllers/DashboardLoginController.php b/src/controllers/DashboardLoginController.php index 8c1cc67..eb6f323 100644 --- a/src/controllers/DashboardLoginController.php +++ b/src/controllers/DashboardLoginController.php @@ -6,11 +6,15 @@ class DashboardLoginController extends BaseController { private static $message; public static function get() { - include "views/dashboard-login.php"; + // include "views/dashboard-login.php"; + DashboardController::invoke(); } public static function post() { - if ($_POST['username'] == "admin" && $_POST['password'] == "admin") { + if (isset($_POST['_method'])) { + DashboardController::invoke(); + } + else if ($_POST['username'] == "admin" && $_POST['password'] == "admin") { // Probably a bad practice, but couldn't find if it is $_SERVER['REQUEST_METHOD'] = "GET"; // Load normal dashboard diff --git a/src/controllers/EditOfferController.php b/src/controllers/EditOfferController.php new file mode 100644 index 0000000..950b6dc --- /dev/null +++ b/src/controllers/EditOfferController.php @@ -0,0 +1,5 @@ +<?php +include_once('controllers/BaseController.php'); + +class EditOfferController extends BaseController { +} diff --git a/src/views/dashboard.php b/src/views/dashboard.php index 86c393a..b1b648c 100644 --- a/src/views/dashboard.php +++ b/src/views/dashboard.php @@ -1 +1,16 @@ -<p>Dashboard works!</p> +<?php + foreach($jobs as $job) { + echo "{$job->id} {$job->title} + <form method=\"post\"> + <input type=\"hidden\" name=\"_method\" value=\"put\"> + <input type=\"hidden\" name=\"jobId\" value=\"{$job->id}\"> + <input type=\"submit\" value=\"Edit\"> + </form> + <form method=\"post\"> + <input type=\"hidden\" name=\"_method\" value=\"delete\"> + <input type=\"hidden\" name=\"jobId\" value=\"{$job->id}\"> + <input type=\"submit\" value=\"Delete\"> + </form> + <br>"; + } +?> diff --git a/src/views/edit-offer.php b/src/views/edit-offer.php new file mode 100644 index 0000000..957fc3d --- /dev/null +++ b/src/views/edit-offer.php @@ -0,0 +1 @@ +<p>Works!</p> |
