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

Guide Booking Adjustments #242

Merged
merged 1 commit into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 17 additions & 1 deletion app/controllers/API/GuideBookings.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,30 @@ public function getAllBookings(): void
{
$response = new JSONResponse;

$GuideBookingsModel = new GuideBookingsModel;
$GuideBookingsModel = new GuideBookingsModel();
$bookings = $GuideBookingsModel->getAllBookings(UserMiddleware::getUser()['id']);
$response->success(true)
->data($bookings)
->message('Bookings fetched successfully')
->statusCode(200)
->send();
}

public function getGuideAllBookings(int $packageId): void{
$response = new JSONResponse;
$GuideBookingsModel = new GuideBookingsModel();
$guide = $GuideBookingsModel->getGuideIdByPackageId($packageId);
$bookings = $GuideBookingsModel->getGuideAllBookings($guide[0]->guide_id);
// show($bookings);

$response->success(true)
->data($bookings)
->message('Bookings fetched successfully')
->statusCode(200)
->send();


}
public function deleteBooking($date): void
{
$response = new JSONResponse;
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/Complaints.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ public function index(){
}elseif (UserMiddleware::getUser()['role']=='customer') {
$this->view('customer/complaints');
}
elseif(UserMiddleware::getUser()['role']=='guide'){
$this->view('guide/complaints');
}

}

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/Guideprofile.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function update(string $a = '', string $b = '', string $c = ''): void {
$data['guide_id'] = UserMiddleware::getUser()['id'];

$guideProfileModel = new GuideprofileModel;
$guideProfileModel->updateGuideProfile($data);
$data = $guideProfileModel->updateGuideProfile($data);

$response
->data($data)
Expand Down
9 changes: 7 additions & 2 deletions app/controllers/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function index(string $a = '', string $b = '', string $c = ''):void {

// show(UserMiddleware::getUser()['role']);

AuthorizationMiddleware::authorize(['rentalservice']);
AuthorizationMiddleware::authorize(['rentalservice','guide','customer']);

if(UserMiddleware::getUser()['role'] == 'rentalservice'){

Expand All @@ -24,7 +24,12 @@ public function index(string $a = '', string $b = '', string $c = ''):void {

$this->view('rental/settings',$data);
// echo "rental service";
}else{
}

else if(UserMiddleware::getUser()['role'] == 'guide'){
$this->view('guide/settings');
}
else{
$this->view('customer/settings');
}

Expand Down
15 changes: 15 additions & 0 deletions app/models/GuideBookings.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,21 @@ public function getAllBookings(int $userId): mixed {
return $this->query($q->getQuery(), $q->getData());
}

public function getGuideIdByPackageId(int $packageId): mixed {
$q = "CALL GetGuideIdByPackageId(:package_id)";
$params = [
'package_id' => $packageId
];
return $this->query($q, $params, true);
}

public function getGuideAllBookings(int $guideId): mixed {
$q = new QueryBuilder();
$q->setTable($this->table);
$q->select('guide_booking.*')->where('guide_id', $guideId);
return $this->query($q->getQuery(), $q->getData());
}

public function deleteBooking(int $guideId, string $date): mixed {

//return $this->delete(['guide_id' => $guideId, 'date' => $date]);
Expand Down
3 changes: 2 additions & 1 deletion app/models/GuideProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class GuideprofileModel {
'certifications',
];

public function updateGuideProfile(array $data): void {
public function updateGuideProfile(array $data) {
$userId = UserMiddleware::getUser()['id'];
$q = new QueryBuilder();
$q->setTable($this->table);
Expand All @@ -22,6 +22,7 @@ public function updateGuideProfile(array $data): void {
'certifications' => $data['certifications'],
]
)->where('guide_id', $userId);
return $this->query($q->getQuery(), $q->getData());
}

public function getGuideProfileByUserId(int $userId) {
Expand Down
21 changes: 21 additions & 0 deletions app/models/GuideSettings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

class GuideSettingsModel{
use Model;

protected $table = 'rental_settings';
protected $allowedColumns = [
'renting_state',
'recovery_period',
];

public function updateSettings($id,$data){
return $this->update($id,$data,'rentalservice_id');




}


}
74 changes: 64 additions & 10 deletions app/views/customer/OneGuide.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,9 @@
</div>
</div>

<div class="info-data mt-5 ml-5 mr-5">
<div class="guide-card-new">
<span class="label">Booking History</span>
<div class="guide-profile-content">
<div class="booking-list" id="booking-list">

<div class="booking-bar .flex-d mt-4 mb-2">
<p>23rd March : Micheal Julius</p>
</div>
<div class="booking-bar .flex-d mt-4 mb-2">
<p>23rd March : Micheal Julius</p>
</div>
</div>
</div>

Expand All @@ -117,6 +110,67 @@
</div> -->


<script>
function bookingList(packageId) {
console.log('booking list');
$.ajax({
headers: {
Authorization: "Bearer " + getCookie('jwt_auth_token')
},
url: '<?= ROOT_DIR ?>/api/guideBookings/getGuideAllBookings/'+ packageId,
type: 'GET',
success: function(data) {
console.log(data);
bookingHTML(data.data);
}

});
}

function bookingHTML(bookingDetails) {
const modalContent = document.getElementById("booking-list");
modalContent.innerHTML = ""; // Clear previous content

const currentDate = new Date();

const recentBookings = [];
const upcomingBookings = [];

// Divide bookings into recent and upcoming based on date
bookingDetails.forEach(booking => {
const bookingDate = new Date(booking.date);
if (bookingDate > currentDate) {
upcomingBookings.push(booking);
} else {
recentBookings.push(booking);
}
});

// Function to generate HTML for booking details
function generateBookingHTML(bookings) {
return bookings.map(booking => `
<div class="booking-bar .flex-d mt-4 mb-2">
<p>${booking.date} : ${booking.location}</p>
</div>
`).join('');
}

const tableHTML = `
<div class="info-data mt-5 ml-5 mr-5 guide-profile-content">
<div class="guide-card-new booking-history">
<span class="label">Recent Bookings</span>
${generateBookingHTML(recentBookings)}
</div>
<div class="guide-card-new booking-history">
<span class="label">Upcoming Bookings</span>
${generateBookingHTML(upcomingBookings)}
</div>
</div>`;
modalContent.innerHTML = tableHTML;
}
Comment on lines +113 to +170
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optimize AJAX request handling in JavaScript.

Refactor the AJAX request handling to use async/await for better readability and error handling.

console.log(<?php echo $package[0]->id ?>);
bookingList(<?= $package[0]->id ?>);
</script>

<script>
function viewBookingPayment() {
Expand Down Expand Up @@ -293,7 +347,7 @@ function fetchGuidePackages(packageId) {
}
});

// Payment gateway
// Payment gateway
function paymentGateWay(data) {
console.log("Payment gateway");
var xhttp = new XMLHttpRequest();
Expand Down
22 changes: 22 additions & 0 deletions app/views/guide/complaints.view.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
require_once('../app/views/layout/header.php');
?>

<?php require_once('../app/views/guide/layout/guide-sidebar.php'); ?>

<div class="dashboard">

<div class="sidebar-flow"></div>

<div class="guide-dash-main flex-d-c">
<h1 class="title mb-2">Complains</h1>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct the typographical error: "Complains" should be "Complaints".

- <h1 class="title mb-2">Complains</h1>
+ <h1 class="title mb-2">Complaints</h1>

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
<h1 class="title mb-2">Complains</h1>
<h1 class="title mb-2">Complaints</h1>

<ul class="breadcrumbs">
<li><a href="<?= ROOT_DIR ?>/home">Home</a></li>
<li class="divider">/</li>
<li><a href="#" class="active">Complains</a></li>
</ul>

<div class="guide-profile-content mt-5 tiny-topic">
<p>Add Complains if there is an issue</p>

</div>
28 changes: 28 additions & 0 deletions app/views/guide/guidebooking.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,4 +457,32 @@ function deleteBooking(bookedDay) {
modal.style.display = "none";
});
}
</script>

<script>
const currentMonthName = currentDate.toLocaleString('en-US', {
month: 'long'
});
const months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var currentMonthIndex = months.indexOf(currentMonthName);

$(document).on('click', '.cal_next', function() {
currentMonthIndex++;
if (currentMonthIndex >= 12) {
currentMonthIndex = 0; // Reset to January if it goes beyond December
currentYear++;
}
console.log(currentMonthIndex);
});

$(document).on('click', '.cal_prev', function() {
currentMonthIndex--;
if (currentMonthIndex < 0) {
currentMonthIndex = 11; // Reset to December if it goes beyond January
currentYear--;
}
});



</script>
1 change: 1 addition & 0 deletions app/views/guide/guideprofile.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ function closeModal() {
data: JSON.stringify(jsonData),
success: function(data) {
console.log(data);
location.reload(); // Reload the page after successful submission
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
Expand Down
55 changes: 3 additions & 52 deletions app/views/guide/layout/guide-sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,55 +108,6 @@
</div>
</li>

<!-- <li class="nav-item">
<a class="nav-link" data-bs-toggle="collapse" href="<?php echo ROOT_DIR ?>/customers" aria-expanded="false" aria-controls="ui-basic">
<i class="ti-palette menu-icon"></i>
<span class="menu-title">Customers</span>
<i class="menu-arrow"></i>
</a>
<div class="collapse" id="ui-basic">
<ul class="nav flex-column sub-menu">
<li class="nav-item"> <a class="nav-link" href="pages/ui-features/buttons.html">Buttons</a></li>
<li class="nav-item"> <a class="nav-link" href="pages/ui-features/typography.html">Typography</a></li>
</ul>
</div>
</li> -->

<li class="nav-item">
<a class="nav-link" href="<?php echo ROOT_DIR ?>/approve-blogs">
<i class="ti-shield menu-icon"></i>
<span class="menu-title">Approve Blogs</span>
</a>
</li>

<!-- <li class="nav-item">
<a class="nav-link" href="<?php echo ROOT_DIR ?>/tips">
<i class="ti-shield menu-icon"></i>
<span class="menu-title">Tips and Know-hows</span>
</a>
</li> -->

<!-- <li class="nav-item">
<a class="nav-link" data-bs-toggle="collapse" href="<?php echo ROOT_DIR ?>/rentalServices/item" aria-expanded="false" aria-controls="ui-basic">
<i class="ti-palette menu-icon"></i>
<span class="menu-title">Items</span>
<i class="menu-arrow"></i>
</a>
<div class="collapse" id="ui-basic">
<ul class="nav flex-column sub-menu">
<li class="nav-item"> <a class="nav-link" href="pages/ui-features/buttons.html">Buttons</a></li>
<li class="nav-item"> <a class="nav-link" href="pages/ui-features/typography.html">Typography</a></li>
</ul>
</div>
</li> -->
<!--
<li class="nav-item">
<a class="nav-link" href="<?php echo ROOT_DIR ?>/blogs">
<i class="ti-shield menu-icon"></i>
<span class="menu-title">Complaints</span>
</a>
</li> -->

<li class="nav-item">
<a class="nav-link" data-bs-toggle="collapse" href="<?php echo ROOT_DIR ?>/guidestatistics" aria-expanded="false" aria-controls="ui-basic">
<i class="ti-palette menu-icon"></i>
Expand All @@ -173,12 +124,12 @@

<div class="guide-dash-prof">
<div class="">
<a href="<?php echo ROOT_DIR ?>/settings" class="ml-7 mr-2">
<i class="fas fa-cog" aria-hidden="true"></i>
</a>
<a href="<?php echo ROOT_DIR ?>/logout"> <button type="submit" class="btn-edit edit-profile">
Logout
</button>
<a href="<?php echo ROOT_DIR ?>/settings">
<i class="fas fa-cog" aria-hidden="true"></i>
</a>
</div>
</div>
</ul>
Expand Down
Loading
Loading