From 0aa067b783ec3ba374380b82612eb876634c78f8 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Thu, 1 Apr 2021 13:27:08 +0300 Subject: Made index.php a router and added the basis of landing view and controller --- src/controllers/LandingController.php | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/controllers/LandingController.php (limited to 'src/controllers') diff --git a/src/controllers/LandingController.php b/src/controllers/LandingController.php new file mode 100644 index 0000000..80e0b5b --- /dev/null +++ b/src/controllers/LandingController.php @@ -0,0 +1,9 @@ + Date: Thu, 1 Apr 2021 13:55:39 +0300 Subject: Implemented base controller --- src/controllers/BaseController.php | 27 +++++++++++++++++++++++++++ src/controllers/LandingController.php | 14 ++++++++++++-- src/index.php | 4 +--- 3 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 src/controllers/BaseController.php (limited to 'src/controllers') diff --git a/src/controllers/BaseController.php b/src/controllers/BaseController.php new file mode 100644 index 0000000..fd4bedd --- /dev/null +++ b/src/controllers/BaseController.php @@ -0,0 +1,27 @@ +invoke(); + LandingController::invoke(); break; default: http_response_code(404); -- cgit v1.3.1-26-gb76a From 61feb28a1e49ea4dd50394d8b971055cd1eb2694 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Thu, 1 Apr 2021 14:00:30 +0300 Subject: Made base controller not abstract --- src/controllers/BaseController.php | 19 ++++++++++++++----- src/controllers/LandingController.php | 9 --------- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src/controllers') diff --git a/src/controllers/BaseController.php b/src/controllers/BaseController.php index fd4bedd..2c2a647 100644 --- a/src/controllers/BaseController.php +++ b/src/controllers/BaseController.php @@ -1,5 +1,5 @@ Date: Sat, 3 Apr 2021 09:05:30 +0300 Subject: Added create (job) offer and view that have demo functionality (basic post request and echo values) --- src/controllers/CreateOfferController.php | 16 ++++++++++++++++ src/index.php | 5 +++++ src/views/create-offer.php | 19 +++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 src/controllers/CreateOfferController.php create mode 100644 src/views/create-offer.php (limited to 'src/controllers') diff --git a/src/controllers/CreateOfferController.php b/src/controllers/CreateOfferController.php new file mode 100644 index 0000000..d510978 --- /dev/null +++ b/src/controllers/CreateOfferController.php @@ -0,0 +1,16 @@ +Works

+ +
+ + +
+ + +
+ + +
+ + +
+ +
-- cgit v1.3.1-26-gb76a From 56a5223e14f798e2c875c4347faecc4e2e9730fc Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 3 Apr 2021 09:31:25 +0300 Subject: Implemented job offer form creating a new job offer in the database; Fixed insertIntoDB method of JobOffer; Added a link to JobOffer page in landing page --- src/controllers/CreateOfferController.php | 15 ++++++++++----- src/models/JobOffer.php | 2 +- src/views/create-offer.php | 6 +++++- src/views/landing.php | 2 ++ 4 files changed, 18 insertions(+), 7 deletions(-) (limited to 'src/controllers') diff --git a/src/controllers/CreateOfferController.php b/src/controllers/CreateOfferController.php index d510978..a223463 100644 --- a/src/controllers/CreateOfferController.php +++ b/src/controllers/CreateOfferController.php @@ -1,16 +1,21 @@ insertValue(self::TABLE_NAME, $jb->title, $jb->description, $jb->company, $jb->salary); + self::$DB->insertValue(self::TABLE_NAME, $jb->title, $jb->description, $jb->companyId, $jb->salary); } /* Read */ diff --git a/src/views/create-offer.php b/src/views/create-offer.php index 2bdeeaf..9162c90 100644 --- a/src/views/create-offer.php +++ b/src/views/create-offer.php @@ -9,7 +9,11 @@

diff --git a/src/views/landing.php b/src/views/landing.php index 06e32a5..e6477ee 100644 --- a/src/views/landing.php +++ b/src/views/landing.php @@ -5,3 +5,5 @@ echo "{$job->id} {$job->title}
"; } ?> + +Create a new Job Offer -- cgit v1.3.1-26-gb76a From 68808a388a61c7a778494739fe0150651a09ea66 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 3 Apr 2021 09:58:18 +0300 Subject: Implemented a simple login page for (admin) dashboard and skeleton of dashboard controller and view --- src/controllers/DashboardController.php | 8 ++++++++ src/controllers/DashboardLoginController.php | 24 ++++++++++++++++++++++++ src/index.php | 5 +++++ src/views/dashboard-login.php | 12 ++++++++++++ src/views/dashboard.php | 1 + 5 files changed, 50 insertions(+) create mode 100644 src/controllers/DashboardController.php create mode 100644 src/controllers/DashboardLoginController.php create mode 100644 src/views/dashboard-login.php create mode 100644 src/views/dashboard.php (limited to 'src/controllers') diff --git a/src/controllers/DashboardController.php b/src/controllers/DashboardController.php new file mode 100644 index 0000000..84beb14 --- /dev/null +++ b/src/controllers/DashboardController.php @@ -0,0 +1,8 @@ + + + +
+ + +
+ + + diff --git a/src/views/dashboard.php b/src/views/dashboard.php new file mode 100644 index 0000000..86c393a --- /dev/null +++ b/src/views/dashboard.php @@ -0,0 +1 @@ +

Dashboard works!

-- cgit v1.3.1-26-gb76a From 1856de8c22af1a762961547f042891d5b6f9455c Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 3 Apr 2021 10:36:27 +0300 Subject: Added skeleton of edit offer and implemented edit and delete buttons in dashboard offers --- src/controllers/DashboardController.php | 14 ++++++++++++++ src/controllers/DashboardLoginController.php | 8 ++++++-- src/controllers/EditOfferController.php | 5 +++++ src/views/dashboard.php | 17 ++++++++++++++++- src/views/edit-offer.php | 1 + 5 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 src/controllers/EditOfferController.php create mode 100644 src/views/edit-offer.php (limited to 'src/controllers') 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 @@ Dashboard works!

+id} {$job->title} +
+ + id}\"> + +
+
+ + id}\"> + +
+
"; + } +?> 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 @@ +

Works!

-- cgit v1.3.1-26-gb76a From 7677c0edd617c7c6174ec2615febe6599b93cf15 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 3 Apr 2021 11:01:48 +0300 Subject: Fixed dashboard controller redirection to edit offer controller --- src/controllers/DashboardController.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/controllers') diff --git a/src/controllers/DashboardController.php b/src/controllers/DashboardController.php index 7c01efa..5bd26d4 100644 --- a/src/controllers/DashboardController.php +++ b/src/controllers/DashboardController.php @@ -10,13 +10,16 @@ class DashboardController extends BaseController { } 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(); + switch($_POST['_method']) { + case "get": + EditOfferController::get(); + break; + case "put": + EditOfferController::put(); + break; + case "delete": + EditOfferController::delete(); + break; } } } -- cgit v1.3.1-26-gb76a From 6068d95e6d7159f67df7f4a427795ee15eafde98 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 3 Apr 2021 11:02:31 +0300 Subject: Updated dashboard login controller to have a nicer way to redirect to dashboard controller --- src/controllers/DashboardLoginController.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/controllers') diff --git a/src/controllers/DashboardLoginController.php b/src/controllers/DashboardLoginController.php index eb6f323..775b96f 100644 --- a/src/controllers/DashboardLoginController.php +++ b/src/controllers/DashboardLoginController.php @@ -15,10 +15,8 @@ class DashboardLoginController extends BaseController { 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 - DashboardController::invoke(); + DashboardController::get(); } else { self::$message = "Bad credentials!"; -- cgit v1.3.1-26-gb76a From fcab2fc159a64c0c5dc9f6181a7bbca2f331acf6 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 3 Apr 2021 11:04:23 +0300 Subject: Implemented get, put and delete requests for edit offer controller; Implemented edit-offer view --- src/controllers/EditOfferController.php | 25 +++++++++++++++++++++++++ src/views/dashboard.php | 2 +- src/views/edit-offer.php | 25 ++++++++++++++++++++++++- 3 files changed, 50 insertions(+), 2 deletions(-) (limited to 'src/controllers') diff --git a/src/controllers/EditOfferController.php b/src/controllers/EditOfferController.php index 950b6dc..ae49c5b 100644 --- a/src/controllers/EditOfferController.php +++ b/src/controllers/EditOfferController.php @@ -1,5 +1,30 @@ id = $_POST['id']; + JobOffer::updateFromDB($newJobOffer); + + DashboardController::get(); + } + + public static function delete() { + JobOffer::deleteFromDB($_POST['jobId']); + + DashboardController::get(); + } } diff --git a/src/views/dashboard.php b/src/views/dashboard.php index b1b648c..2312419 100644 --- a/src/views/dashboard.php +++ b/src/views/dashboard.php @@ -2,7 +2,7 @@ foreach($jobs as $job) { echo "{$job->id} {$job->title}
- + id}\">
diff --git a/src/views/edit-offer.php b/src/views/edit-offer.php index 957fc3d..b9fb464 100644 --- a/src/views/edit-offer.php +++ b/src/views/edit-offer.php @@ -1 +1,24 @@ -

Works!

+
+ + + +
+ + +
+ + +
+ + +
+ + +
-- cgit v1.3.1-26-gb76a From 9362d6fdfd566f3cc611a02437c6dbdce4f0504b Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 3 Apr 2021 11:07:46 +0300 Subject: Added a link to dashboard in edit offer view and enabled login screen in dashboard --- src/controllers/DashboardLoginController.php | 3 +-- src/views/edit-offer.php | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/controllers') diff --git a/src/controllers/DashboardLoginController.php b/src/controllers/DashboardLoginController.php index 775b96f..fe2009b 100644 --- a/src/controllers/DashboardLoginController.php +++ b/src/controllers/DashboardLoginController.php @@ -6,8 +6,7 @@ class DashboardLoginController extends BaseController { private static $message; public static function get() { - // include "views/dashboard-login.php"; - DashboardController::invoke(); + include "views/dashboard-login.php"; } public static function post() { diff --git a/src/views/edit-offer.php b/src/views/edit-offer.php index b9fb464..a6d699e 100644 --- a/src/views/edit-offer.php +++ b/src/views/edit-offer.php @@ -22,3 +22,4 @@ +< Back to Dashboard -- cgit v1.3.1-26-gb76a From 1180687f951cbb0ebf1b2fd9e22df5b2a20fea9b Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 3 Apr 2021 11:34:24 +0300 Subject: Made job offers show all info --- src/controllers/DashboardController.php | 6 ++++++ src/controllers/LandingController.php | 6 ++++++ src/views/dashboard.php | 2 +- src/views/landing.php | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) (limited to 'src/controllers') diff --git a/src/controllers/DashboardController.php b/src/controllers/DashboardController.php index 5bd26d4..548f60b 100644 --- a/src/controllers/DashboardController.php +++ b/src/controllers/DashboardController.php @@ -1,11 +1,17 @@ id] = $company->name; + } include "views/dashboard.php"; } diff --git a/src/controllers/LandingController.php b/src/controllers/LandingController.php index aa28505..ffa8644 100644 --- a/src/controllers/LandingController.php +++ b/src/controllers/LandingController.php @@ -1,10 +1,16 @@ id] = $company->name; + } include "views/landing.php"; } } diff --git a/src/views/dashboard.php b/src/views/dashboard.php index 2312419..9060317 100644 --- a/src/views/dashboard.php +++ b/src/views/dashboard.php @@ -1,6 +1,6 @@ id} {$job->title} + echo "{$job->id} {$job->title} {$job->description} " . self::$companies[$job->companyId] . " {$job->salary}
id}\"> diff --git a/src/views/landing.php b/src/views/landing.php index d794d93..1bd679c 100644 --- a/src/views/landing.php +++ b/src/views/landing.php @@ -2,7 +2,7 @@ id} {$job->title}
"; + echo "{$job->title} {$job->description} " . self::$companies[$job->companyId] . " {$job->salary}
"; } ?> -- cgit v1.3.1-26-gb76a