Skip to content

Commit

Permalink
Merge branch 'dev' into buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
nsavinda authored Apr 28, 2024
2 parents 5255221 + e54b3eb commit cbf24cc
Show file tree
Hide file tree
Showing 38 changed files with 1,134 additions and 852 deletions.
17 changes: 17 additions & 0 deletions app/controllers/API/GuideBookings.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,23 @@ public function getGuideAllBookings(int $packageId): void{


}

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

$GuideBookingsModel = new GuideBookingsModel();
$bookingDetails = $GuideBookingsModel->getAllMyBookings(UserMiddleware::getUser()['id']);
$guideDetails = $GuideBookingsModel->getGuideDetailsByBookingID($bookingDetails[0]->id);
$response->success(true)
->data([
'bookingDetails' => $bookingDetails,
'guideDetails' => $guideDetails
])
->message('Booking details fetched successfully')
->statusCode(200)
->send();
}
public function deleteBooking($date): void
{
$response = new JSONResponse;
Expand Down
5 changes: 4 additions & 1 deletion app/controllers/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ public function viewCart(string $a = '', string $b = '', string $c = ''):void {




// if($data['items']){


foreach ($data['items'] as $equipment) {
$equipment->total = $equipment->e_standard_fee + $equipment->e_fee * (strtotime($data['cart']->end_date) - strtotime($data['cart']->start_date)) / (60 * 60 * 24);
}
Expand All @@ -42,6 +44,7 @@ public function viewCart(string $a = '', string $b = '', string $c = ''):void {
$data['total'] += $item->total;
}

// }


$this->view('customer/components/cart', $data);
Expand Down
37 changes: 0 additions & 37 deletions app/controllers/GuideProfile.php

This file was deleted.

4 changes: 2 additions & 2 deletions app/controllers/Rent.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function items(string $a = '', string $b = '', string $c = ''):void {
$data['cart'] = $cart;
$data['request'] = $request->getAll();

$data['equipments'] = $rent->getItems($request->getAll());
$data['equipments'] = $rent->getItems($request->getAll(),$data['cart']);

// show($data['equipments']);

Expand All @@ -79,7 +79,7 @@ public function items(string $a = '', string $b = '', string $c = ''):void {
// show($data['equipments']);



// show($data['equipments']);

// show($data['equipments']);

Expand Down
16 changes: 16 additions & 0 deletions app/models/GuideBookings.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ public function getCustomerDetailsByBookingID(int $bookingId): mixed {
return $this->query($q->getQuery(), $q->getData())[0];
}

public function getGuideDetailsByBookingID(int $bookingId): mixed {
$q = new QueryBuilder();
$q->setTable('guides');
$q->select('guides.*')->join('guide_booking', 'guides.id', 'guide_booking.guide_id')->where('guide_booking.id', $bookingId);
return $this->query($q->getQuery(), $q->getData())[0];
}

public function getAllBookings(int $userId): mixed {

$userId = $_SESSION['USER']->id;
Expand All @@ -99,6 +106,15 @@ public function getAllBookings(int $userId): mixed {
return $this->query($q->getQuery(), $q->getData());
}

public function getAllMyBookings(int $userId): mixed {

$userId = $_SESSION['USER']->id;
$q = new QueryBuilder();
$q->setTable($this->table);
$q->select('guide_booking.*')->where('customer_id', $userId);
return $this->query($q->getQuery(), $q->getData());
}

public function getGuideIdByPackageId(int $packageId): mixed {
$q = "CALL GetGuideIdByPackageId(:package_id)";
$params = [
Expand Down
1 change: 1 addition & 0 deletions app/models/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class PackageModel

protected string $table = 'package';
protected array $allowedColumns = [
'name',
'guide_id',
'price',
'max_group_size',
Expand Down
33 changes: 31 additions & 2 deletions app/models/Rent.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,17 @@ public function validateRent(array $data) {
}


public function getItems(array $data) {
public function getItems(array $data, $cart) {

$q = new QueryBuilder();

// show($cart);
$q->setTable('equipment');
$q->select('equipment.*, rental_services.name As rental_service_name')
->join('rental_services', 'equipment.rentalservice_id', 'rental_services.id')
->join('rental_settings', 'equipment.rentalservice_id', 'rental_settings.rentalservice_id')
->join('locations', 'rental_services.location_id', 'locations.id')

->where('rental_settings.renting_status', 1)

// if $data['search']
Expand All @@ -76,8 +78,35 @@ public function getItems(array $data) {



// show($q->getQuery());
$equipments = $this->query($q->getQuery(), $q->getData());
// show($equipments);
if (is_array($equipments)) {
$equipments = array_map(function ($equipment) use ($cart) {
$item = new ItemModel;
$items = $item->getAvailableItems([
'equipment_id' => $equipment->id,
'start_date' => $cart->start_date,
'end_date' => $cart->end_date
]);
// only return equipment that has available items (item status = available)

if (count($items) > 0) {
// $equipment->items = $items;
return $equipment;
}


}, $equipments);
} else {
// Handle the case where $equipments is not an array
$equipments = [];
}
// remove null values
$equipments = array_filter($equipments);


// show($equipments);
return $equipments;

return $this->query($q->getQuery(),$q->getData());

Expand Down
7 changes: 3 additions & 4 deletions app/models/RentComplaint.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ public function cancelComplaint($id){
}


// public function getComplaints(array $data)
// {
// return $this->where($data);
// }



}
4 changes: 2 additions & 2 deletions app/models/RentalService.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ public function getRentalServiceStat(int $id): mixed
$q->setTable('rental_services');
// group by rental service id and count orders
$q->select('count(distinct(rent.id)) as orders_count , count(distinct(equipment.id)) as equipments_count')
->join('equipment', 'rental_services.id', 'equipment.rentalservice_id')
->join('rent', 'rental_services.id', 'rent.rentalservice_id')
->leftJoin('equipment', 'rental_services.id', 'equipment.rentalservice_id')
->leftJoin('rent', 'rental_services.id', 'rent.rentalservice_id')
->where('rental_services.id', $id)
->groupBy('rental_services.id');

Expand Down
21 changes: 21 additions & 0 deletions app/views/admin/customer.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
</ul>


<div class="flex-d-r mt-5 ml-3">
<div class="search-container">
<input type="text" placeholder="Search.." name="search" class="form-control-lg" id="search">
<!-- <button class="btn-text-green border" type="submit"><i class="fa fa-search"></i></button> -->
</div>
</div>


<div class="table-container">
<table class="data-table table-custom">
<thead>
Expand Down Expand Up @@ -120,6 +128,19 @@ function openModal(id) {
</script>


<script>
$(document).ready(function() {
$("#search").on("keyup", function() {
var value = $(this).val().toLowerCase();
$(".data-table tbody tr").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
});


</script>



<?php
Expand Down
4 changes: 2 additions & 2 deletions app/views/admin/customer/user.view.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class=" col profile-info m-5">
<div class="row">
<img src="<?php echo ROOT_DIR ?>/assets/images/dp.jpg" alt="Profile Image" class="mw-200px px-4 p-6">
<img src="<?php echo OSURL?>images/customer/<?= $customer->image ?>" alt="Profile Image" class="mw-200px px-4 p-6">
<div>
<h2 id="profile-name"> <?php echo $customer->name ?> </h2>
<p id="profile-email"><i class="fas fa-envelope m-2"></i><?php echo $customer->email ?></p>
Expand All @@ -9,7 +9,7 @@
<p id="profile-address"><i class="fa fa-location-arrow m-2"></i><?php echo $customer->address ?></p>
<!-- <p id="profile-status" class="status <?php echo $customer->status; ?>"><?php echo ucfirst($customer->status); ?></p> -->
<div class="row">
<button type="" class="btn-danger m-2 d-flex justify-content-end p-2 " id="see-more">
<button type="" class="btn-text-red border " id="see-more">
Remove User
</button>
</div>
Expand Down
20 changes: 10 additions & 10 deletions app/views/admin/dashboard.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<div class="flex-d-c">
<div class="flex-d-r justify-content-end">
<a href="<?php echo ROOT_DIR ?>/admin/rentalServices">
<button type=" submit" class="btn-success" id="see-more">
<button type=" submit" class="btn-text-green border " id="see-more">
See More >>
</button>
</a>
Expand Down Expand Up @@ -75,7 +75,7 @@
<div class="flex-d-c">
<div class="flex-d-r justify-content-end">
<a href="<?php echo ROOT_DIR ?>/admin/guides">
<button type=" submit" class="btn-success" id="see-more">
<button type=" submit" class="btn-text-green border " id="see-more">
See More >>
</button>
</a>
Expand Down Expand Up @@ -108,7 +108,7 @@
<div class="flex-d-c">
<div class="flex-d-r justify-content-end">
<a href="<?php echo ROOT_DIR ?>/admin/customers">
<button type=" submit" class="btn-success" id="see-more">
<button type=" submit" class="btn-text-green border " id="see-more">
See More >>
</button>
</a>
Expand Down Expand Up @@ -143,7 +143,7 @@
<div class="flex-d-c">
<div class="flex-d-r justify-content-end">
<a href="<?php echo ROOT_DIR ?>/admin/charts">
<button type=" submit" class="btn-success" id="see-more">
<button type=" submit" class="btn-text-green border " id="see-more">
See More >>
</button>
</a>
Expand Down Expand Up @@ -175,7 +175,7 @@
<div class="flex-d-c">
<div class="flex-d-r justify-content-end">
<a href="<?php echo ROOT_DIR ?>/admin/complains">
<button type=" submit" class="btn-success" id="see-more">
<button type=" submit" class="btn-text-green border " id="see-more">
See More >>
</button>
</a>
Expand Down Expand Up @@ -207,7 +207,7 @@
<div class="flex-d-c">
<div class="flex-d-r justify-content-end">
<a href="<?php echo ROOT_DIR ?>/admin/tips">
<button type=" submit" class="btn-success" id="see-more">
<button type=" submit" class="btn-text-green border " id="see-more">
See More >>
</button>
</a>
Expand All @@ -231,7 +231,7 @@
<div class="flex-d-c">
<!-- <div class="flex-d-r justify-content-end">
<a href="<?php echo ROOT_DIR ?>/admin/charts">
<button type=" submit" class="btn-success" id="see-more">
<button type=" submit" class="btn-text-green border " id="see-more">
See More >>
</button>
</a>
Expand Down Expand Up @@ -330,7 +330,7 @@
<div class="flex-d-c">
<div class="flex-d-r justify-content-end">
<a href="<?php echo ROOT_DIR ?>/admin/charts">
<button type=" submit" class="btn-success" id="see-more">
<button type=" submit" class="btn-text-green border " id="see-more">
See More >>
</button>
</a>
Expand Down Expand Up @@ -433,7 +433,7 @@

</div>
<div class="col-lg-4">
<button class="btn-success" id="income-report">Generate</button>
<button class="btn-text-green border " id="income-report">Generate</button>
</div>


Expand Down Expand Up @@ -471,7 +471,7 @@

</div>
<div class="col-lg-4">
<button class="btn-success" id="income-report">Generate</button>
<button class="btn-text-green border " id="income-report">Generate</button>
</div>


Expand Down
22 changes: 22 additions & 0 deletions app/views/admin/guides.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
</ul>


<div class="flex-d-r mt-5 ml-3">
<div class="search-container">
<input type="text" placeholder="Search.." name="search" class="form-control-lg" id="search">
<!-- <button class="btn-text-green border" type="submit"><i class="fa fa-search"></i></button> -->
</div>
</div>


<div class="table-container">
<table class="data-table table-custom">
<thead>
Expand Down Expand Up @@ -119,6 +127,20 @@ function openModal(id) {
</script>


<script>
$(document).ready(function() {
$("#search").on("keyup", function() {
var value = $(this).val().toLowerCase();
$(".data-table tbody tr").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
});


</script>




<?php
Expand Down
Loading

0 comments on commit cbf24cc

Please sign in to comment.