Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into adminstyles
Browse files Browse the repository at this point in the history
  • Loading branch information
nsavinda committed Apr 24, 2024
2 parents 70b8456 + c729a40 commit 842abb7
Show file tree
Hide file tree
Showing 152 changed files with 16,374 additions and 7,461 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public/uploads/
public/uploads/rental_services/


setup.sh

server.env
setup.sql
setup.sql
public/assets/scss/wl/dashboard/index.css
public/assets/scss/wl/dashboard/index.css.map
4 changes: 0 additions & 4 deletions app/controllers/API/Complaints.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,5 @@ public function cancelComplaint(string $a = '', string $b = '', string $c = ''):
$response = new JSONResponse;
$response->statusCode(200)->data(['complaint_id' => $a])->send();





}
}
30 changes: 30 additions & 0 deletions app/controllers/API/Customer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

class Customer {
use Controller;


public function uploadImage(string $a = '', string $b = '', string $c = ''):void {

$request = JSONRequest::createFromFormData();
$response = new JSONResponse();

$customer = new CustomerModel;

$data = [
'image' => $_FILES['image'],

];
$id = UserMiddleware::getUser()['id'];

$image = $customer->uploadImage($data, $id);


if($image){
$response->statusCode(200)->data(['image' => $image['image']])->send();
}else{
$response->statusCode(400)->data(['error' => 'Image upload failed'])->send();
}

}
}
36 changes: 35 additions & 1 deletion app/controllers/API/Equipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,19 @@ public function delete(string $a = '', string $b = '', string $c = ''): void {

$equipmentModel = new EquipmentModel;

$data = $equipmentModel->deleteEquipment($a);
if($equipmentModel->GetCurrentAcceptedRents($a)){
$response->success(false)
->message('Equipment is currently rented out')
->statusCode(422)
->send();

return;
}


$item = new ItemModel;

$data = $item->makeRemovedByEquipment($a);

if (!$data) {
$response->success(true)
Expand Down Expand Up @@ -86,4 +98,26 @@ public function increasecount(string $a = '', string $b = '', string $c = ''): v


}

public function disableEquipment(string $a = '', string $b = '', string $c = ''): void {
$request = new JSONRequest;
$response = new JSONResponse;

$item = new ItemModel;

$data = $item->makeUnavailableByEquipment($a);

if (!$data){
$response->success(true)
->message('Equipment disabled successfully')
->statusCode(200)
->send();
} else {
$response->success(false)
->data(['errors' => $item->errors])
->message('Failed to disable equipment')
->statusCode(422)
->send();
}
}
}
53 changes: 53 additions & 0 deletions app/controllers/API/GuideAvailability.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

class GuideAvailability{
use Controller;
public function index(string $a = '', string $b = '', string $c = ''): void {
$this->view('guide/guideAvailability');
}

public function update(string $a = '', string $b = '', string $c = ''): void {

$request = new JSONRequest;
$response = new JSONResponse;

$id = UserMiddleware::getUser()['id'];

// $request->getAll();
// show($request->getAll());
$data = $request->getAll();
$data['guide_id'] = $id;

$GuideAvailabilityModel = new GuideAvailabilityModel;
$sch = $GuideAvailabilityModel->getScheduleByGuideIdandDate(UserMiddleware::getUser()['id'], $data['date']);

if($sch){
$GuideAvailabilityModel->updateSchedule($data);
}else{
$GuideAvailabilityModel->createSchedule($data);
}


$response->success(true)
->message('Schedule updated successfully')
->statusCode(200)
->send();

}

public function getDays(string $a = '', string $b = '', string $c = ''): void {
$request = new JSONRequest;
$response = new JSONResponse;

$data = $request->getAll();

$GuideAvailabilityModel = new GuideAvailabilityModel;
$schedules = $GuideAvailabilityModel->getDaysByMonth(UserMiddleware::getUser()['id'], $data);

$response->success(true)
->data($schedules)
->message('Schedule fetched successfully')
->statusCode(200)
->send();
}
}
76 changes: 76 additions & 0 deletions app/controllers/API/GuideBookings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php

class GuideBookings{
use Controller;
public function index(string $a = '', string $b = '', string $c = ''): void {
$this->view('guide/guidebooking');
}
public function bookRequest(string $a = '', string $b = '', string $c = ''): void {
$request = new JSONRequest;
$response = new JSONResponse;

$data = $request->getAll();

$GuideBookingsModel = new GuideBookingsModel;
$booking = $GuideBookingsModel->createBooking($data);

if ($booking) {
$response->success(true)
->message('Booking created successfully')
->statusCode(200)
->send();
exit();
} else {
$response->success(false)
->data(['errors' => $GuideBookingsModel->errors])
->message('Validation failed')
->statusCode(422)
->send();
}
}
public function getDays(string $a = '', string $b = '', string $c = ''): void {
$request = new JSONRequest;
$response = new JSONResponse;

$data = $request->getAll();

$GuideBookingsModel = new GuideBookingsModel;
$schedules = $GuideBookingsModel->getDaysByMonth(UserMiddleware::getUser()['id'], $data);

$response->success(true)
->data($schedules)
->message('Schedule fetched successfully')
->statusCode(200)
->send();
}

public function getBookingDetailsByDate($date): void {
$response = new JSONResponse;

// Call your method to retrieve booking details based on the date
$GuideBookingsModel = new GuideBookingsModel();
$bookingDetails = $GuideBookingsModel->getBookingDetailsByDate(UserMiddleware::getUser()['id'],$date);

$response->success(true)
->data($bookingDetails)
->message('Booking details fetched successfully')
->statusCode(200)
->send();

}

public function deleteBooking($date): void {
$response = new JSONResponse;

$GuideBookingsModel = new GuideBookingsModel;

$GuideBookingsModel->deleteBooking(UserMiddleware::getUser()['id'],$date);

$response->success(true)
->message('Booking deleted successfully')
->statusCode(200)
->send();

}

}
12 changes: 10 additions & 2 deletions app/controllers/API/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,19 @@ public function index(): void {
if ($user->authenticate($email, $password)) {
$userData = $user->authenticate($email, $password);
// $_SESSION['USER'] = $userData;

// Check if user is verified
// show($userData);
// die();
if ($userData->is_verified == 0) {
$response->success(false)->message('User not verified, please verify your email')->statusCode(401)->send();
return;
}
// filter user data get id and email array
$userData = array_filter((array) $userData, function ($key) {
$userCookie = array_filter((array) $userData, function ($key) {
return in_array($key, ['id', 'email']);
}, ARRAY_FILTER_USE_KEY);
$this->setcookie($userData);
$this->setcookie($userCookie);
$response->success(true)->data($userData)->send();

} else {
Expand Down
13 changes: 13 additions & 0 deletions app/controllers/API/MyOrders.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,17 @@ public function cancelOrder(string $a = '', string $b = '', string $c = ''):void
$response->statusCode(200)->data(['rent_id' => $a])->send();

}

public function reportOrder(string $a = '', string $b = '', string $c = ''):void {
$request = new JSONRequest();
$response = new JSONResponse();

$data = $request->getAll();
// show($data);
// die();
$report = new RentComplaintModel;
$report->createComplaint($data);

$response->statusCode(200)->message('Complaint added successfully')->send();
}
}
1 change: 1 addition & 0 deletions app/controllers/API/Orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public function submitReturnComplaint(string $a = '', string $b = '', string $c



$response->statusCode(200)->data(['order_id' => $a])->send();


// $rent->updateRentStatus($data);
Expand Down
Loading

0 comments on commit 842abb7

Please sign in to comment.