Skip to content

Commit

Permalink
Merge branch 'dev' into guide_availability
Browse files Browse the repository at this point in the history
  • Loading branch information
Gayandee authored Apr 29, 2024
2 parents a2987c0 + ac1d4f4 commit a9f496e
Show file tree
Hide file tree
Showing 44 changed files with 5,533 additions and 1,877 deletions.
11 changes: 3 additions & 8 deletions app/controllers/API/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -536,9 +536,8 @@ public function allRentalIncome(string $a = '', string $b = '', string $c = ''):
<body>
<h1>Wanderlust</h1><br>
<h2>Income Report</h2>
<h3> Rental Services</h3>
<h3>Income from Rental Services</h3>
<h2><?= $reportDate ?></h2><br>
<!-- <p><strong>Name:</strong> <?= $name ?><br><strong>Address:</strong> <?= $address ?></p> -->
<table>
<thead>
<tr>
Expand All @@ -560,22 +559,18 @@ public function allRentalIncome(string $a = '', string $b = '', string $c = ''):
// $netIncome = $totalIncome - $serviceFee;
?>
<tr>
<td><strong>Total</strong></td>
<td><strong>Total Transactions</strong></td>
<td><strong>Rs.<?= number_format($totalIncome, 2) ?></strong></td>
</tr>
<tr>
<td><strong>Net Income</strong></td>
<td><strong>Rs.<?= number_format($serviceFee, 2) ?></strong></td>
</tr>
<!-- <tr>
<td><strong>Net Income</strong></td>
<td><strong>Rs.<?= number_format($netIncome, 2) ?></strong></td>
</tr> -->

</tbody>
</table>
<div class="footer">
<p>This report was generated by the system on <?= $reportDate ?></p>
<!-- <p>Verify at: <a href="https://<?= $_SERVER['HTTP_HOST'] ?>/reports/income_report_<?= $id ?>.pdf">https://<?= $_SERVER['HTTP_HOST'] ?>/reports/income_report_<?= $id ?>.pdf</a></p> -->
</div>
</body>

Expand Down
24 changes: 19 additions & 5 deletions app/controllers/Admin/Complains.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,27 @@ public function index(string $a = '', string $b = '', string $c = ''): void

public function listComplains(string $a = '', string $b = '', string $c = ''): void
{
$complain = new RentReturnComplaintModel;
$data['complaints'] = $complain->getAdminRentalComplaints($b);
//who complaints
if($a == 'customer'){
$complaint = new RentComplaintModel;
$data['complaints'] = $complaint->getComplaints (['status' => $b]);
$data['view'] = '-customer';

$this->view('admin/components/complainlist', $data);
}
$this->view('admin/components/complainlist', $data);

}else if($a == 'rentalservice'){
$complain = new RentReturnComplaintModel;
$data['complaints'] = $complain->getAdminRentalComplaints($b);
$data['view'] = '';

$this->view('admin/components/complainlist', $data);
}


}


public function viewComplaint(string $a = '', string $b = '', string $c = ''): void
public function viewRentalComplaint(string $a = '', string $b = '', string $c = ''): void
{
$rentreturncomplaint = new RentReturnComplaintModel;
$complaint = $rentreturncomplaint->getComplaint($a);
Expand Down Expand Up @@ -47,4 +59,6 @@ public function viewComplaint(string $a = '', string $b = '', string $c = ''): v

$this->view('admin/components/complaint', ['complaint' => $complaint, 'order' => $order, 'items' => $items]);
}


}
4 changes: 4 additions & 0 deletions app/controllers/Admin/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public function index(string $a = '', string $b = '', string $c = ''): void
$stats = new AdminStatsModel;
$data['orders'] = $stats->getOrdersCount();


$equipment = new EquipmentModel;
$data['equipments'] = $equipment->count([], ['count' => '0']);

$this->view('admin/dashboard', $data);
}
}
3 changes: 3 additions & 0 deletions app/controllers/Admin/Tips.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ public function delete(string $a = '', string $b = '', string $c = ''): void
// show($b);
// show($c);
$tips = new TipsModel();
// show($tips->first(['id' => $a]));

$tips->delete($a, 'id');


redirect('admin/tips');
}
Expand Down
9 changes: 8 additions & 1 deletion app/controllers/MyOrders.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ public function index(string $a = '', string $b = '', string $c = ''):void {


AuthorizationMiddleware::authorize(['customer']);

$tips = new TipsModel();
$data['tips'] = $tips->findAll();

// randomly select 1 tip
$data['tip'] = $data['tips'][array_rand($data['tips'])];
// show($data['tip']);

$this->view('customer/orders');
$this->view('customer/orders', $data);
}

public function list(string $a = '', string $b = '', string $c = ''):void {
Expand Down
8 changes: 8 additions & 0 deletions app/controllers/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,18 @@ public function index(string $a = '', string $b = '', string $c = ''):void {
if ($user['role']== 'customer') {

$rent = new RentModel;
$guideBooking = new GuideBookingsModel;
$complaint = new RentComplaintModel;
$data = [
'rental' => $rent->getUpcomingRentByCustomer(['customer_id' => $user['id']])[0],
'ordersCount' => $rent->count(['customer_id' => $user['id'], 'status' => 'completed']) + $rent->count(['customer_id' => $user['id'], 'status' => 'rented']),
'guideBookingsCount' => $guideBooking->count(['customer_id' => $user['id'], 'status' => 'completed']),
'complaintCount' => sizeof($complaint->getComplaintsByCustomer(['customer_id' => $user['id']]))

];

// show($data);


$this->view('customer/profile', $data);
} else if ($user['role'] == 'guide') {
Expand Down
28 changes: 28 additions & 0 deletions app/core/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,34 @@ public function lastInsertedId():mixed{
}


public function count(array $data = [], array $data_not = []):int{

$keys = array_keys($data);
$query = "select count(*) as count from $this->table where ";
foreach ($keys as $key){
$query .= $key. " = :" . $key . " && ";

}
$keys = array_keys($data_not);
foreach ($keys as $key){
$query .= $key. " != :" . $key . " && ";

}


// show($query);

$query = trim($query, " && ");

$data = array_merge($data, $data_not);

$result = $this->query($query, $data);
if($result)
return $result[0]->count;
return 0;

}


// Extended functions
protected string $q = "";
Expand Down
4 changes: 2 additions & 2 deletions app/models/Rent.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function getItems(array $data, $cart) {

// show($cart);
$q->setTable('equipment');
$q->select('equipment.*, rental_services.name As rental_service_name')
$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')
Expand Down Expand Up @@ -172,4 +172,4 @@ public function getUpcomingRentByRentalService($data) {



}
}
3 changes: 2 additions & 1 deletion app/models/RentalService.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,10 @@ public function getRentalService(int $id): mixed
$q = new QueryBuilder;
$q->setTable('rental_services');
// with user table join
$q->select('rental_services.*,users.email,users.role')
$q->select('rental_services.*,users.email,users.role,locations.latitude,locations.longitude')
// ->from('rental_services')
->join('users', 'rental_services.user_id', 'users.id')
->join('locations', 'rental_services.location_id', 'locations.id')
->where('rental_services.id', $id);
// return $this->query();
// show($id);
Expand Down
31 changes: 24 additions & 7 deletions app/views/admin/complains.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
</button>
<!-- </a> -->
</div>
<div class="flex-d-r mr-5">
<!-- <a href="<?php echo ROOT_DIR ?>/admin/complainsGuides"> -->
<!-- <div class="flex-d-r mr-5">
<a href="<?php echo ROOT_DIR ?>/admin/complainsGuides">
<button type=" submit" class="btn-card" data-id="guide">
Guides
</button>
<!-- </a> -->
</div>
</a>
</div> -->
<div class="flex-d-r mr-5">
<!-- <a href="<?php echo ROOT_DIR ?>/admin/complainsCustomers"> -->
<button type=" submit" class="btn-card" data-id="customer">
Expand Down Expand Up @@ -73,7 +73,7 @@

<div class="section-switch flex-d gap-3 flex-wrap">
<button class="btn-selected" id="pending">Pending</button>
<button class="btn-selected" id="accepted">Accepted</button>
<!-- <button class="btn-selected" id="accepted">Accepted</button> -->
<button class="btn-selected" id="rejected">Rejected</button>
<button class="btn-selected" id="resolved">Resolved</button>

Expand Down Expand Up @@ -149,15 +149,32 @@ function getComplaints(status, user = "customer") {
});


// View Complaint
// View Complaint Rental

$(document).on('click', '#view-button', function() {
var complaintId = $(this).closest('.complaint').attr('data-id');
$.ajax({
headers: {
'Authorization': 'Bearer ' + getCookie('jwt_auth_token')
},
url: '<?= ROOT_DIR ?>/admin/complains/viewComplaint/' + complaintId,
url: '<?= ROOT_DIR ?>/admin/complains/viewRentalComplaint/' + complaintId,
type: 'GET',
success: function(response) {
$('#complaint-data').html(response);
$('#complaint-view-modal').css('display', 'block');
}
});
});

// View Complaint Customer

$(document).on('click', '#view-button-customer', function() {
var complaintId = $(this).closest('.complaint').attr('data-id');
$.ajax({
headers: {
'Authorization': 'Bearer ' + getCookie('jwt_auth_token')
},
url: '<?= ROOT_DIR ?>/admin/complains/viewRentComplaint/' + complaintId,
type: 'GET',
success: function(response) {
$('#complaint-data').html(response);
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/components/complainlist.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</div>

<div class="complaint-actions flex-d gap-3">
<button class="btn-text-green" id="view-button"><i class="fa fa-list" aria-hidden="true"></i> View</button>
<button class="btn-text-green" id="view-button<?php echo $view;?>"><i class="fa fa-list" aria-hidden="true"></i> View</button>
<!-- if status pending set show -->
<?php if ($complaint->status == 'pending') {
?>
Expand Down
Loading

0 comments on commit a9f496e

Please sign in to comment.