Skip to content

Commit

Permalink
Merge pull request #251 from wanderlust-group-project-1/buttons
Browse files Browse the repository at this point in the history
Buttons
  • Loading branch information
Zaras00 authored Apr 28, 2024
2 parents e54b3eb + cbf24cc commit a6542ca
Show file tree
Hide file tree
Showing 23 changed files with 224 additions and 207 deletions.
12 changes: 12 additions & 0 deletions app/controllers/API/Complaints.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,16 @@ public function resolveComplaint(string $a = ''): void
$response = new JSONResponse;
$response->statusCode(200)->success(true)->data(['complaint_id' => $a])->send();
}

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

$complaint = new RentComplaintModel;
$complaint->cancelComplaint($a);

$response = new JSONResponse;
$response->statusCode(200)->data(['complaint_id' => $a])->send();
}


}
4 changes: 2 additions & 2 deletions app/controllers/Complaints.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function rentComplaints(string $a = '', string $b = '', string $c = ''):v
$rentcomplaint = new RentComplaintModel;
$data = ['customer_id' => UserMiddleware::getUser()['id']];
$data['complaints'] = $rentcomplaint->getComplaintsByCustomer($data);
show ($data['complaints']);
// show ($data['complaints']);

$this->view('customer/components/customercomplaintlist', $data);
}
Expand All @@ -122,7 +122,7 @@ public function rentComplaint(string $a = '', string $b = '', string $c = ''):vo

$rent = new RentModel;
$data['rentitems'] = $rent->getItemListbyRentId($data['complaint']->rent_id);
show($data);
// show($data);

$this->view('customer/components/customercomplaints', $data);
}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/_404.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class _404{
public function index(){
http_response_code(404);

echo "Controller not found";
$this->view('404');
}
}

Expand Down
42 changes: 26 additions & 16 deletions app/models/RentComplaint.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ class RentComplaintModel
{
use Model;

protected string $table = 'rent_return_complaints';
protected string $table = 'rent_complaint';

protected array $allowedColumns = [
'rent_id',
'complaint_no',
'title',
'description',
'created_at',
'status'
];

Expand All @@ -30,36 +32,44 @@ public function resolveComplaint($id)
//$table
$this->update($id, ['status' => 'resolved']);
}
public function getComplaints(array $data)
{
public function getComplaints(array $data) {
return $this->where($data);
}

public function getComplaintsByCustomer(array $data)
{
public function getComplaintsByCustomer(array $data) {
$q = new QueryBuilder;
$q->setTable('rent_complaint');
$q->select('rent.customer_id as customer_id, rent.id as rent_id, complaint_no as complaint_no, rent_complaint.status as status, rent_complaint.description as description, rent_complaint.created_at as created_at')
->join('rent', 'rent_complaint.rent_id', 'rent.id')
->where('rent.customer_id', $data['customer_id']);
->join('rent', 'rent_complaint.rent_id','rent.id')
->where('rent.customer_id', $data['customer_id'])
->orderBy('rent_complaint.created_at', 'DESC');

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

public function getRentComplaint($id)
{

public function getRentComplaint($id) {
$q = new QueryBuilder;
$q->setTable('rent_complaint');
$q->select('rent_complaint.complaint_no as complaint_no, rent.id as rent_id,rent.created_at as rent_date, rent.customer_id as customer_id, rent.paid_amount as paid_amount, rent.created_at as paid_date, rent.start_date as start_date, rent.end_date as end_date,
rent.status as rent_status, rent.total as total_amount,rental_services.id as rental_id, rental_services.name as rental_name, rental_services.mobile as rental_mobile,
rent_complaint.title as title, rent_complaint.description as description, rent_complaint.created_at as created_at, rent_complaint.status as status')
->join('rent', 'rent_complaint.rent_id', 'rent.id')
->join('rental_services', 'rent.rentalservice_id', 'rental_services.id')
->where('rent_complaint.complaint_no', $id);

rent.status as rent_status, rent.total as total_amount,rental_services.id as rental_id, rental_services.name as rental_name, rental_services.mobile as rental_mobile,
rent_complaint.title as title, rent_complaint.description as description, rent_complaint.created_at as created_at, rent_complaint.status as status')
->join('rent','rent_complaint.rent_id', 'rent.id')
->join('rental_services', 'rent.rentalservice_id','rental_services.id')
->where('rent_complaint.complaint_no', $id);
return $this->query($q->getQuery(), $q->getData());
}

public function cancelComplaint($id){
// show($id);
// return $this->update($id, ['status' => 'cancelled'], 'complaint_no');
$q = new QueryBuilder;
$q->setTable('rent_complaint');
$q->update(['status' => 'cancelled'])->where('complaint_no', $id);
return $this->query($q->getQuery(), $q->getData());
}





}
15 changes: 12 additions & 3 deletions app/views/404.view.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<div class="modal-content">
<h1>Page not found</h1>
<!-- <img src="</php echo ROOT_DIR?>/assets/images/404.jpg" alt="404.jpg" class="404-image"> -->
<?php
require_once('../app/views/layout/header.php');
// require_once('../app/views/components/navbar-auth.php');
?>

<div class="profile col-lg-12 align-items-center">
<div class="customer-bg-image">
<img src="<?php echo ROOT_DIR?>/assets/images/customerbg.jpg" alt="customer-bg-image" class="customer-bg-image">
</div>
<div class="error-container p-6 mt-6">
<img src="<?php echo ROOT_DIR?>/assets/images/404-error.png" alt="customer-bg-image" class="error-img mt-10">
</div>
</div>

89 changes: 55 additions & 34 deletions app/views/customer/complaints.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<div class="customer-bg-image">
<img src="<?php echo ROOT_DIR?>/assets/images/customerbg.jpg" alt="customer-bg-image" class="customer-bg-image">
</div>
<div class="cl-lg-12 flex-d-c gap-2 mt-5">
<div class="cl-lg-7 flex-d-c gap-2 mt-9">
<div class="card card-normal-glass">
<!-- <button class="btn-text-green">hi</button> -->
<h2 class="justufy-content-ceneter flex-d"> Complaints </h2>
<h2 class="justufy-content-ceneter flex-d ml-3"> Complaints </h2>

<div class="section-switch flex-d gap-3 flex-wrap">
<button class="btn-selected" id="rentComplaints">My complaints</button>
Expand All @@ -29,6 +29,20 @@

</div>

<!-- complaint cancel -->

<div id="cancel-complaint-modal" class="modal">
<div class="modal-content">
<span class="close">&times;</span>
<h2>Cancel Complaint</h2>
<p>Are you sure you want to cancel this complaint?</p>
<div class="flex-d gap-3 mt-3">
<button class="btn btn-primary" id="cancel-complaint-confirm">Yes</button>
<button class="btn btn-danger modal-close" id="cancel-complaint-cancel">No</button>
</div>
</div>
</div>

<script>

function getComplaints(status) {
Expand Down Expand Up @@ -71,38 +85,6 @@ function getComplaints(status) {
}
});
});

$(document).on('click', '#cancel-complaint', function() {
var complaintId = $(this).closest('.complaint').attr('data-id');
$('#cancel-complaint-confirm').attr('data-id', complaintId);
$('#cancel-complaint-modal').css('display', 'block');
});

$(document).on('click', '#cancel-complaint-confirm', function() {
var complaintId = $(this).attr('data-id');
$.ajax({
headers:{
'Authorization': 'Bearer ' + getCookie('jwt_auth_token')
},
url: '<?= ROOT_DIR ?>/api/complaints/cancelComplaint/' + complaintId,
type: 'GET',
success: function(response) {
console.log(response);
var id = response.data.complaint_id;
$('#complaint-card[data-id="' + id + '"]').remove();
$('#cancel-complaint-modal').css('display', 'none');

getComplaints('myComplaints');




},
error: function(err) {
console.log(err);
}
});
});

</script>

Expand Down Expand Up @@ -137,4 +119,43 @@ function getComplaints(status) {
}
});
});
</script>

<!-- cancel complaint -->
<script>
$(document).on('click', '#cancel-complaint', function() {
var complaintId = $(this).closest('.complaint').attr('data-id');
$('#cancel-complaint-confirm').attr('data-id', complaintId);
$('#cancel-complaint-modal').css('display', 'block');
});




$(document).on('click', '#cancel-complaint-confirm', function() {
var complaintId = $(this).attr('data-id');
$.ajax({
headers:{
'Authorization': 'Bearer ' + getCookie('jwt_auth_token')
},
url: '<?= ROOT_DIR ?>/api/complaints/cancelCustomerComplaint/' + complaintId,
type: 'GET',
success: function(response) {
console.log(response);
var id = response.data.complaint_id;
$('#complaint-card[data-id="' + id + '"]').remove();
$('#cancel-complaint-modal').css('display', 'none');

// getComplaints('pending');
alertmsg ("Complaint cancelled successfully", 'success');



},
error: function(err) {
console.log(err);
}
});
});

</script>
4 changes: 2 additions & 2 deletions app/views/customer/components/cart.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<h2 class="justify-content-center flex-d">Cart</h2>

<div class="row gap-2">
<h3> <?php echo htmlspecialchars($cart->start_date); ?> - <?php echo htmlspecialchars($cart->end_date); ?> </h3>
<h6 class="rent-item-view-price"> <?php echo htmlspecialchars($cart->start_date); ?> - <?php echo htmlspecialchars($cart->end_date); ?> </h6>
</div>
<div class="row gap-2 ">
<!-- scrollable cart items -->
Expand Down Expand Up @@ -36,7 +36,7 @@
<!-- <div class="item-count">
</div> -->
<div class="cart-item-price">
<h4>Rs. <?php echo htmlspecialchars($item->total); ?></h4>
<h4 class="rent-item-view-price py-1">Rs. <?php echo htmlspecialchars($item->total); ?></h4>
<!-- <input class="form-control-lg" type="number" name="count" id="item-count" value="1" min="1" max="48"> -->
</div>
</div>
Expand Down
20 changes: 4 additions & 16 deletions app/views/customer/components/complaint.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@
<!-- item list -->

<div class="col-lg-12 col-md-12">
<h3>Equipment List</h3>
<div class="row">
<h3>Equipment List</h3>
</div>
<div class="table-container">
<table class="table-custom">
<thead>
Expand All @@ -119,20 +121,6 @@
</div>

</div>







</div>




</div>



</div>
</div>
4 changes: 2 additions & 2 deletions app/views/customer/components/complaintlist.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@

<!-- complaint cancel -->

<div id="cancel-complaint-modal" class="modal">
<!-- <div id="cancel-complaint-modal" class="modal">
<div class="modal-content">
<span class="close">&times;</span>
<h2>Cancel Complaint</h2>
Expand All @@ -103,7 +103,7 @@
<button class="btn btn-danger modal-close" id="cancel-complaint-cancel">No</button>
</div>
</div>
</div>
</div> -->

<style>

Expand Down
48 changes: 6 additions & 42 deletions app/views/customer/components/customercomplaintlist.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,41 +23,20 @@

<div class="complaint-actions flex-d gap-3">
<button class="btn-text-green" id="mycom-view-button"><i class="fa fa-list" aria-hidden="true"></i> View</button>
<button class="btn-text-red" id="cancel-complaint"><i class="fa fa-times" aria-hidden="true"></i> Cancel</button>

<!-- if status pending set show -->
<!-- <?php if ($complaint->status == 'myComplaints') {





?>
<div class="flex-d-c">
<button class="btn-text-red" id="cancel-complaint"><i class="fa fa-times" aria-hidden="true"></i> Cancel</button>


<button class="btn-text-red" id="cancel-rented" hidden>Cancel</button>
</div>
<?php
}
elseif ($complaint->status == 'rented') { ?>
<button class="btn btn-primary" id="mark-as-returned">Mark as Returned</button>
<?php }
elseif ($complaint->status == 'pending') { ?>
<button class="btn-text-orange" id="accept-complaint"><i class="fa fa-check" aria-hidden="true"></i> Accept</button>
<button class="btn-text-red" id="cancel-complaint"><i class="fa fa-times" aria-hidden="true"></i> Cancel</button>
<?php }
?> -->
if ($complaint->status == 'pending') { ?>
<button class="btn-text-red" id="cancel-complaint"><i class="fa fa-times" aria-hidden="true"></i> Cancel</button>
<?php }?>



</div>
</div>
</div>
<?php
<?php
}



?>


Expand All @@ -77,21 +56,6 @@
</div>
</div>


<!-- complaint cancel -->

<div id="cancel-complaint-modal" class="modal">
<div class="modal-content">
<span class="close">&times;</span>
<h2>Cancel Complaint</h2>
<p>Are you sure you want to cancel this complaint?</p>
<div class="flex-d gap-3 mt-3">
<button class="btn btn-primary" id="cancel-complaint-confirm">Yes</button>
<button class="btn btn-danger modal-close" id="cancel-complaint-cancel">No</button>
</div>
</div>
</div>

<style>

</style>
Loading

0 comments on commit a6542ca

Please sign in to comment.