Skip to content

Commit

Permalink
Merge pull request #260 from wanderlust-group-project-1/guide_availab…
Browse files Browse the repository at this point in the history
…ility

Guide Dashboard
  • Loading branch information
Gayandee authored Apr 29, 2024
2 parents ac1d4f4 + a9f496e commit 9b34db0
Show file tree
Hide file tree
Showing 19 changed files with 270 additions and 111 deletions.
30 changes: 30 additions & 0 deletions app/controllers/API/GuideBookings.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,34 @@ public function completeBooking($date): void
->statusCode(200)
->send();
}

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

$response = new JSONResponse;

$GuideBookingsModel = new GuideBookingsModel;
$userId = UserMiddleware::getUser()['id'];
$bookingDetails = $GuideBookingsModel->GetUserBookingDetails($userId);

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

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

$response = new JSONResponse;

$GuideBookingsModel = new GuideBookingsModel;
$userId = UserMiddleware::getUser()['id'];
$bookingDetails = $GuideBookingsModel->GetMonthlyCompletedBookings($userId);

$response->success(true)
->data($bookingDetails)
->message('Booking details fetched successfully')
->statusCode(200)
->send();
}
}
19 changes: 18 additions & 1 deletion app/models/GuideBookings.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ public function deleteBooking(int $guideId, string $date): mixed {
$q->setTable($this->table);
$q->delete()->where('guide_id', $guideId)->where('date', $date);
return $this->query($q->getQuery(), $q->getData());


}

Expand All @@ -147,4 +146,22 @@ public function completeBooking(int $guideId, string $date): mixed {
$q->update(['status' => 'completed'])->where('guide_id', $guideId)->where('date', $date);
return $this->query($q->getQuery(), $q->getData());
}

public function GetUserBookingDetails(int $userId): mixed {
$q = 'CALL GetUserBookingDetails(:userId)';
$params = [
'userId' => $userId
];

return $this->query($q, $params);
}

public function GetMonthlyCompletedBookings(int $userId): mixed {
$q = 'CALL GetMonthlyCompletedBookings(:userId)';
$params = [
'userId' => $userId
];

return $this->query($q, $params);
}
}
2 changes: 1 addition & 1 deletion app/views/customer/OneGuide.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</ul> -->

<div class="guide-availability" id="guide-availability">
<a class="btn-text-black" href="<?= ROOT_DIR ?>/guideavailability"><i class="fas fa-calendar" aria-hidden="true"></i> Availability</i></a>
<a class="btn-text-black" ><i class="fas fa-calendar" aria-hidden="true"></i> Availability</i></a>
<!-- <button class="btn-text-red" id="cancel-complaint"><i class="fa fa-times" aria-hidden="true"></i> Cancel</button> -->

</div>
Expand Down
58 changes: 54 additions & 4 deletions app/views/customer/myBookings.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<label for="description">Description</label>
<textarea id="report-description" name="description" class="form-control-lg" required=""></textarea>
</div>
<button class="btn-text-green border" id="report-submit" data-id="67">Submit</button>
<button class="btn-text-green border" id="report-submit" data-id="html">Submit</button>
</form>
</div>
</div>
Expand Down Expand Up @@ -111,7 +111,7 @@ function bookingHTML(userDetails, bookingDetails) {
$(document).ready(function() {
// Get the modal
var modal = document.getElementById("report-modal");
var viewModal = document.getElementById("view-modal")
var viewModal = document.getElementById("view-booking-modal")

// When the user clicks the "Complain" button, open the modal
$(document).on('click', '.order-report-button', function() {
Expand All @@ -137,10 +137,60 @@ function bookingHTML(userDetails, bookingDetails) {
}
});
});


$(document).on('click', '#report-submit', function(e) {
e.preventDefault();
var title = $('#report-title').val();
var description = $('#report-description').val();
var orderId = $(this).attr('data-id');
var data = {
title: title,
description: description,
orderId: orderId
};

$.ajax({
headers: {
'Authorization': 'Bearer ' + getCookie('jwt_auth_token')
},
url: '<?= ROOT_DIR ?>/complaints/addComplaint',
method: 'POST',
data: JSON.stringify(data),
success: function(response) {
alert('Complaint submitted successfully');
$('#report-modal').css('display', 'none');
}
});
});
</script>

<?php


<!-- Modal box to view booking details -->
<div class="modal modal view-booking-modal" id="view-booking-modal" style="display: none;">
<div class="modal-content">
<span class="close-button">&times;</span>
<div class="booking-list" id="booking-list">
<h2>Booking Details</h2>

<!-- Booking list will be displayed here -->
</div>
<div class="flex-d gap-2 mt-5">
<button class="btn btn-danger delete-package-button">Cancel Booking</button>
</div>
</div>

<div id="delete-booking-modal" class="delete-booking-modal modal">
<div class="modal-content ">
<span class="close ">&times;</span>
<h2 class="guide-h2-title">Delete Booking</h2>
<p>Are you sure you want to cancel this booking?</p>

</div>
</div>
</div>

<?php
require_once('../app/views/layout/footer.php');
?>
?>
Loading

0 comments on commit 9b34db0

Please sign in to comment.