Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/cus tech req #42

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
dbdcc72
admin dashboard
rathinimal Nov 11, 2024
4e94215
re configure missing parts
Abhishke391 Nov 14, 2024
4779c59
making simple confi/creating product model
Abhishke391 Nov 14, 2024
e79577e
resolving conflicts
Abhishke391 Nov 15, 2024
daab5aa
added comments
kasunmendis7 Nov 16, 2024
5e2cbe8
market place landing page/sessions erro
Abhishke391 Nov 17, 2024
991bc03
Merge branch 'fixmetech:develop' into develop
kasunmendis7 Nov 20, 2024
690fd61
commented the code
kasunmendis7 Nov 20, 2024
256c152
commented the code
kasunmendis7 Nov 20, 2024
0bb28bf
Merge pull request #30 from kasunmendis7/develop
kasunmendis7 Nov 20, 2024
c6e1a46
Merge branch 'develop' into feature/service-centre
kasunmendis7 Nov 20, 2024
800691f
Merge pull request #29 from Abhishke391/feature/service-centre
kasunmendis7 Nov 20, 2024
bc8556c
resolved several conflicts
kasunmendis7 Nov 20, 2024
fe5db6d
added admin sign up functionality
kasunmendis7 Nov 20, 2024
4d9f9d0
Merge pull request #31 from kasunmendis7/feature/admin-sign-up
kasunmendis7 Nov 20, 2024
4e1c8d8
Merge pull request #24 from rathinimal/feature/admin-dashboard
kasunmendis7 Nov 20, 2024
a3da490
added admin login
kasunmendis7 Nov 20, 2024
758c319
Merge pull request #32 from kasunmendis7/feature/admin-login
kasunmendis7 Nov 20, 2024
3f393cd
creating admin ui
rathinimal Nov 21, 2024
5898962
added admin retrieve and delete functionality
kasunmendis7 Nov 21, 2024
306ed81
added update profile functionality for admin
kasunmendis7 Nov 21, 2024
49ff8ea
Merge branch 'develop' into feature/admin-new
rathinimal Nov 22, 2024
5300773
Merge pull request #33 from rathinimal/feature/admin-new
kasunmendis7 Nov 22, 2024
48784b6
creating market place create/read components
Abhishke391 Nov 22, 2024
39b37b8
Merge branch 'feature/service-centre' of https://github.com/Abhishke3…
Abhishke391 Nov 22, 2024
b92e51a
Merge branch 'develop' into feature/service-centre
kasunmendis7 Nov 23, 2024
ff4793d
Merge pull request #35 from Abhishke391/feature/service-centre
kasunmendis7 Nov 23, 2024
b8834e8
resolving merge conflicts
kasunmendis7 Nov 23, 2024
b155b54
Merge pull request #36 from kasunmendis7/develop
kasunmendis7 Nov 23, 2024
0e08b0c
promotions tab is added to the navbar
rathinimal Nov 23, 2024
2dcd5ed
promotions php file is created
rathinimal Nov 23, 2024
896a426
path for promotions is added and modifed
rathinimal Nov 23, 2024
ea06e40
added customer delete and retrive functionality to admin
kasunmendis7 Nov 23, 2024
b6d9115
added admin update functionality
kasunmendis7 Nov 23, 2024
bb063d2
users.php file is removed from admin nav bar and modified the sidebar
rathinimal Nov 23, 2024
9f5aa69
modified path
rathinimal Nov 23, 2024
781a93c
retrieved all the technicians in the admin dashboard
kasunmendis7 Nov 23, 2024
3e8380f
deleted files with a ~
kasunmendis7 Nov 23, 2024
e10d6e9
Merge pull request #38 from kasunmendis7/develop
kasunmendis7 Nov 23, 2024
551de1f
deleted setting
rathinimal Nov 23, 2024
a9a70c8
Merge branch 'develop' into feature/admin-updated
rathinimal Nov 23, 2024
802c6c8
completing the crud of service center
Abhishke391 Nov 23, 2024
9593c06
Merge pull request #37 from rathinimal/feature/admin-updated
kasunmendis7 Nov 23, 2024
86b1d34
finishing service center crud
Abhishke391 Nov 23, 2024
8cc823a
Merge branch 'develop' into feature/service-centre
kasunmendis7 Nov 23, 2024
0ae575e
Merge pull request #39 from Abhishke391/feature/service-centre
kasunmendis7 Nov 23, 2024
59146fb
changed the dashboard function to adminDashboard function
kasunmendis7 Nov 23, 2024
c22f732
removed a unnecessary function
kasunmendis7 Nov 24, 2024
7a0788e
resolved some conflicts
kasunmendis7 Nov 24, 2024
8b7a755
added accept and reject functionality
kasunmendis7 Nov 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
DB_DSN = mysql:host=localhost;port=3306;dbname=fixmedb
DB_DSN = mysql:host=127.0.0.1;port=3306;dbname=fixmedb
DB_USER = root
DB_PASSWORD =
143 changes: 143 additions & 0 deletions controllers/AdminController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
<?php

namespace app\controllers;

use app\core\Application;
use app\core\Controller;
use app\core\Request;
use app\models\Admin;
use app\models\Customer;
use app\models\Technician;

class AdminController extends Controller
{
public function adminDashboard()
{
$this->setLayout('auth');
return $this->render('/admin/dashboard');
}



public function manageUsers()
{
$this->setLayout('auth');
return $this->render('/admin/users');
}

public function adminSettings()
{
$this->setLayout('auth');
return $this->render('/admin/admin-settings');
}

public function adminProfile()

{
$this->setLayout('auth');
return $this->render('/admin/admin-profile');
}

public function updateAdminProfile(Request $request)
{
$admin = new Admin();
if ($request->isPost()) {
$admin->loadData($request->getBody());
if ($admin->updateValidate()) {
$admin->updateAdmin();
Application::$app->session->setFlash('update-success', 'You have been Updated your account info successfully!');
Application::$app->response->redirect('/admin-profile');
} else {
Application::$app->response->redirect('/admin-profile');
}
}
}

public function viewReports()
{
$this->setLayout('auth');
return $this->render('/admin/reports');
}

public function manageServices()
{
$this->setLayout('auth');
return $this->render('/admin/services');
}

public function adminLogin()
{
$this->setLayout('auth');
return $this->render('/admin/admin-login.php');
}


public function promotions()
{
$this->setLayout('auth');
return $this->render('/admin/admin-promotions');
}



public function customers()
{
// Fetch all customers records
$customers = Admin::findAllCustomers();
// Render the all the customer in the database
$this->setLayout('auth');
return $this->render('/admin/customers', ['customers' => $customers]);

}

public function technicians()
{
// Fetch all technicians records
$technicians = Admin::findAllTechnicians();
// Render the all the customer in the database
$this->setLayout('auth');
return $this->render('/admin/technicians', ['technicians' => $technicians]);

}

public function deleteCustomer(Request $request)
{
$data = $request->getBody(); // Assuming this already returns an array
if (isset($data['cus_id'])) {
$cus_id = $data['cus_id'];

// Call the model function to delete the customer
$result = Admin::deleteCustomerById($cus_id);

if ($result) {
echo json_encode(['status' => 'success']);
} else {
echo json_encode(['status' => 'error', 'message' => 'Failed to delete customer']);
}
} else {
echo json_encode(['status' => 'error', 'message' => 'Invalid customer ID']);
}
}

public function deleteTechnician(Request $request)
{
$data = $request->getBody(); // Assuming this already returns an array
if (isset($data['tech_id'])) {
$tech_id = $data['tech_id'];

// Call the model function to delete the technician
$result = Admin::deleteTechnicianById($tech_id);

if ($result) {
echo json_encode(['status' => 'success']);
} else {
echo json_encode(['status' => 'error', 'message' => 'Failed to delete technician']);
}
} else {
echo json_encode(['status' => 'error', 'message' => 'Invalid technician ID']);
}
}


}

31 changes: 29 additions & 2 deletions controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
use app\core\Controller;
use app\core\Request;
use app\core\Response;
use app\models\Admin;
use app\models\AdminLogin;
use app\models\Customer;
use app\models\CustomerLoginForm;

//use app\core\Response;
use app\models\CustomerRegisterModel;
use app\models\ServiceCenter;
use app\models\ServiceCenterLogin;
use app\models\Technician;
use app\models\ServiceCentre;
Expand Down Expand Up @@ -116,7 +119,7 @@ public function technicianLogOut(Request $request, Response $response)

public function serviceCentreSignup(Request $request)
{
$registerModel = new ServiceCentre();
$registerModel = new ServiceCenter();
if ($request->isPost()) {
$registerModel->loadData($request->getBody());

Expand Down Expand Up @@ -145,7 +148,7 @@ public function serviceCentreLogin(Request $request, Response $response)
$serviceCenterLogin->loadData($request->getBody());
if ($serviceCenterLogin->validate() && $serviceCenterLogin->loginServiceCenter()) {
$response->redirect('/service-centre-dashboard');
$service_centre = new ServiceCentre();
$service_centre = new ServiceCenter();
$service_centre->serviceCentreAddressGeocoding();
return;
}
Expand All @@ -162,4 +165,28 @@ public function serviceCenterLogout(Request $request, Response $response)
$response->redirect('/service-centre-landing');
}

/* admin login method */
public function adminLogin(Request $request, Response $response)
{
$adminLogin = new AdminLogin();
if ($request->isPost()) {
$adminLogin->loadData($request->getBody());
if ($adminLogin->validate() && $adminLogin->login()) {
$response->redirect('/admin-dashboard'); // later will change this to admin dashboard
return;
}
}
$this->setLayout('auth');
return $this->render('/admin/admin-login', [
'model' => $adminLogin
]);
}

/* admin logout method */
public function adminLogout(Request $request, Response $response)
{
Application::$app->logoutAdmin();
$response->redirect('/');
}

}
24 changes: 16 additions & 8 deletions controllers/CommentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,22 @@ class CommentController extends Controller
// Create a new comment
public function create(Request $request)
{
// Checks if the HTTP request method is POST
if ($request->isPost()) {
// Create a new instance of the Comment model, used to store and handle data of the new comment
$comment = new Comment();
// The loadData method populates the Comment instance with the data from the POST request
$comment->loadData($request->getBody());

// Set the logged-in user's ID as the comment owner
$comment->cus_id = Application::$app->customer->cus_id;

// Validate the data before saving it
if ($comment->validate() && $comment->save()) {
Application::$app->session->setFlash('success', 'Comment posted successfully');
} else {
Application::$app->session->setFlash('error', 'Failed to post comment');
}

// Redirects the user to the fixmecommunity page after attempting to create the comment
Application::$app->response->redirect('/fixme-community');

}
Expand All @@ -35,7 +38,9 @@ public function create(Request $request)
// Edit an existing comment
public function edit(Request $request)
{
// Fetch the comment ID from the request and find the comment
$comment_id = $request->getBody()['comment_id'];
// Retrives the comment from the database
$comment = (new Comment)->findOne(['comment_id' => $comment_id]);

// Ensure the user is the owner of the comment
Expand All @@ -44,10 +49,11 @@ public function edit(Request $request)
$this->response->redirect("/fixme-community");
return;
}

// Checks if the HTTP request is a POST request
if ($request->isPost()) {
// Updates the Comment object with the new values provided by the user.
$comment->loadData($request->getBody());

// Validate the updated data before saving it
if ($comment->validate() && $comment->update()) {
Application::$app->session->setFlash('success', 'Comment updated successfully');
} else {
Expand All @@ -68,17 +74,19 @@ public function delete(Request $request)
{
// Fetch the comment ID from the request
$commentID = $request->getBody()['comment_id'] ?? null;
// Get the logged-in customer's ID
$cusID = Application::$app->customer->cus_id; // Get the logged-in customer ID

// Check if the comment ID or customer ID is not set (invalid request)
if (!$commentID || !$cusID) {
Application::$app->session->setFlash('error', 'Invalid request.');
Application::$app->response->redirect('/fixme-community');
// Stop the execution of the method
return;
}

// Find the comment by ID
// Find the comment using its ID
$comment = (new Comment)->findOne(['comment_id' => $commentID]);

// Check if the comment does not exist
if (!$comment) {
Application::$app->session->setFlash('error', 'Comment not found.');
Application::$app->response->redirect('/fixme-community');
Expand All @@ -98,7 +106,7 @@ public function delete(Request $request)
} else {
Application::$app->session->setFlash('error', 'Failed to delete the comment.');
}

// Redirect the user to the '/fixmecommunity' page after the operation
Application::$app->response->redirect('/fixme-community');
}

Expand Down
Loading