Skip to content

Commit

Permalink
Merge pull request #224 from wanderlust-group-project-1/customer-comp…
Browse files Browse the repository at this point in the history
…laints

Customer complaints
  • Loading branch information
nsavinda authored Apr 24, 2024
2 parents 8336063 + 0147683 commit 880439c
Show file tree
Hide file tree
Showing 13 changed files with 354 additions and 48 deletions.
15 changes: 10 additions & 5 deletions app/controllers/Complaints.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ public function returnComplaintsbyCustomer(string $a = '', string $b = '', strin

$this->view('customer/components/complaintlist', $data);






}

public function returnComplaintbyCustomer(string $a = '', string $b = '', string $c = ''):void {
Expand Down Expand Up @@ -108,4 +103,14 @@ public function returnComplaintbyCustomer(string $a = '', string $b = '', string
$this->view('customer/components/complaint', ['complaint' => $complaint, 'order' => $order, 'items' => $items]);
}

public function rentCompaints(string $a = '', string $b = '', string $c = ''):void {
$rentcomplaint = new RentComplaintModel;
$data = ['customer_id' => UserMiddleware::getUser()['id']];
$data['complaints'] = $rentcomplaint->getComplaintsByCustomer($data);
show ($data['complaints']);

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


}
10 changes: 10 additions & 0 deletions app/models/RentComplaint.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ public function createComplaint($data) {
public function getComplaints(array $data) {
return $this->where($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']);

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

}

Expand Down
13 changes: 6 additions & 7 deletions app/views/customer/complaints.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
require_once('../app/views/navbar/customer-navbar.php');
?>

<div class="container flex-d flex-md-c justify-content-center mt-5">
<div class="cl-lg-12 flex-d-c gap-2 mt-5">
<div class="container flex-d flex-md-c justify-content-center mt-5 bg-color-primary h-100">
<div class="col-lg-10 flex-d-c gap-2 mt-5">
<div class="card card-normal">
<!-- <button class="btn-text-green">hi</button> -->
<h2 class="justufy-content-ceneter flex-d"> Complaints </h2>

<div class="section-switch flex-d gap-3 flex-wrap">
<button class="btn-selected">My complaints</button>
<button class="btn-selected">Add complaints</button>
<button class="btn-selected">Recieved complaints</button>
<button class="btn-selected" id="rentCompaints">My complaints</button>
<button class="btn-selected" id="returnComplaintsbyCustomer">Recieved complaints</button>
</div>

<div class="row gap-2">
Expand All @@ -33,7 +32,7 @@ function getComplaints(status) {
headers:{
'Authorization': 'Bearer' + getCookie('jwt_auth_token')
},
url: '<?= ROOT_DIR ?>/complaints/returnComplaintsbyCustomer/' + status,
url: '<?= ROOT_DIR ?>/complaints/' + status,
type: 'GET',
success: function(response) {
//if complain-list-content in document remove it
Expand All @@ -46,7 +45,7 @@ function getComplaints(status) {
}

$(document).ready(function(){
getComplaints('myComplaints');
getComplaints('returnComplaintsbyCustomer');
$('.section-switch button').click(function() {
$('.section-switch button').removeClass('active');
$(this).addClass('active');
Expand Down
111 changes: 111 additions & 0 deletions app/views/customer/components/customercomplaintlist.view.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@

<div id="complaint-list-content" class=" col-lg-12">


<?php

// oreders list
($complaints) ? : print('<div class="col-lg-12"><h1>No Complaints</h1></div>');

foreach ($complaints as $complaint) {
?>

<div class = "row flex-d col-lg-12 complaint-card-item row-content" id="complaint-card">
<div class="complaint card card-normal3 col-lg-12 flex-md-c miw-200px" data-id="<?= $complaint->id ?>">
<div class="complaint-header">
<div class="complaint-id">Complaint ID: <?= $complaint->complaint_no ?></div>
<div class="complaint-status">Status: <?= $complaint->status ?></div>
</div>

<div class="complaint-body">
<div class="complaint-description"> <?= $complaint->description ?></div>
</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-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 }
?> -->


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



?>


</div>




<!-- View modal -->

<div class="modal" id="complaint-view-modal">
<div class="modal-content">
<span class="close">&times;</span>


<div id="complaint-data"> </div>
</div>
</div>



<!-- Complaint Modals -->

<div id="report-complaint-modal" class="modal">
<div class="modal-content">
<span class="close">&times;</span>

<div id="complaint-form-data">

</div>
</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>
4 changes: 2 additions & 2 deletions app/views/customer/orders.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

?>

<div class="container flex-d flex-md-c justify-content-center mt-5">
<div class=" col-lg-12 flex-d-c gap-2 mt-5 ">
<div class="container flex-d flex-md-c justify-content-center mt-5 bg-color-primary">
<div class=" col-lg-10 flex-d-c gap-2 mt-5 ">

<div class="card card-normal ">

Expand Down
85 changes: 51 additions & 34 deletions app/views/customer/rent.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@



<div class="container flex-d-c justify-content-center gap-2">
<div class="container flex-d-c justify-content-center gap-2 bg-color-primary">

<div class="row gap-2 justify-content-end mt-7">
<!-- Cart -->
Expand All @@ -23,41 +23,57 @@

</div>

<div class="row gap-2">
<!-- Change date -->
<button id="change-date" class="btn" type="button">Change Date</button>

<div class="customer-header w-100 flex-d-c justify-content-center align-items-center">





<div class="col-lg-6 flex-d justify-content-center w-100 p-1 ">
<div class="card-normal mw-100 pl-10 w-100">
<div class="col gap-2">
<!-- Change date -->
<div>
<p class="date-change-phase" id="date-change-phase" ><? echo isset($cart) ? "Selected Date: " . $cart->start_date . " - " . $cart->end_date : "Select Date"; ?></p>
</div>
<div>
<button id="change-date" class="btn-text-green" type="button"><i class="fa fa-calendar"></i> Change Date</button>
</div>
</div>
</div>
</div>



<div class="row">
<div class="col-lg-8 flex-d justify-content-center " >

<div class="col-lg-6 flex-d justify-content-center w-100 p-1">
<div class="card-normal mw-100 pl-10 w-100">
<div class="row">
<div class="col-lg-8 flex-d justify-content-center">
<div class = "search-container col-lg-12">
<form action="<?= ROOT_DIR ?>/search" method="get">
<div class="row gap-2 w-100">
<input type="text" id="search-input" class="form-control-lg" placeholder="Search item by name.." name="search">

<input type="text" class="form-control no-display" id="latitude" name="latitude" hidden/>
<input type="text" class="form-control no-display" id="longitude" name="longitude" hidden/>
<button id="get-location" class="btn-icon" > <i class="fa fa-map-marker"></i></button>
<button id="search-button" class="btn-icon" type="submit"><i class="fa fa-search"></i></button>

<div class = "search-container col-lg-12">
<form action="<?= ROOT_DIR ?>/search" method="get">
<div class="row gap-2">
<input type="text" id="search-input" placeholder="Search.." name="search">
<!-- Select Type of result -->
<select name="type" id="type">
<option value="all">All</option>
<option value="shops">Shops</option>
<option value="items">Items</option>
</select>
<!-- Select location button -->
<input type="text" class="form-control no-display" id="latitude" name="latitude" hidden/>
<input type="text" class="form-control no-display" id="longitude" name="longitude" hidden/>
<button id="get-location" class="btn-icon" > <i class="fa fa-map-marker"></i></button>
<button id="search-button" class="btn-icon" type="submit"><i class="fa fa-search"></i></button>

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

</div>



</div>


<div class="row" id="search-result">
</div>
<div class="row" id="item-list">
Expand All @@ -69,10 +85,11 @@
<div class="modal-content ">
<span class="close">&times;</span>

<div class=" col-lg-12 flex-d-c gap-2 ">

<input id="pac-input" class="controls " type="text" placeholder="Enter Location" />
<div class=" col-lg-12 flex-d-c gap-2 location-container">

<div class="location-form-element">
<input id="pac-input" class="controls " type="text" placeholder="Enter Location" />
</div>
<div id="map-canvas" class="map-canvas"> </div>

<!-- <input type="text" class="form-control" id="latitude" hidden/>
Expand All @@ -81,7 +98,6 @@
<div class="location-button-container">
<button id="confirm-location" class="location-button btn" type="button">Confirm Location</button>
</div>

</div>
</div>

Expand All @@ -97,12 +113,11 @@
<div class="row gap-2">

<div class="date"><label for="start-date">Start Date</label></div>
<div class="date"><input type="date" id="start-date" class="form-control-lg " name="start-date" required value="<?php isset($cart) && print($cart->start_date); ?>"
></div>
<div class="date"><input type="date" id="start-date" class="form-control-lg " name="start-date" required value="<?php isset($cart) && print($cart->start_date); ?>"></div>
<div class="date"><label for="end-date">End Date</label></div>
<div class="date"><input type="date" id="end-date" class="form-control-lg" name="end-date" required value="<?php isset($cart) && print($cart->end_date); ?>"></div>
<div class="date">
<h5>Select days you want to rent camping equipment. If you change the date new cart will be created. Items added to the previous cart will be removed.</h5>
<div class="date-para"><h5>Select days you want to rent camping equipment. If you change the date new cart will be created. Items added to the previous cart will be removed.</h5></div>
</div>
</div>
<div class="row gap-2">
Expand Down Expand Up @@ -475,6 +490,8 @@ function setNewDate(start, end) {

});

$('#date-change-phase').text("Selected Date: " + start + " - " + end);




Expand Down Expand Up @@ -528,9 +545,9 @@ function setNewDate(start, end) {

// function / use jQuery
function disableButton(id) {
var button = $(`[data-id=${id}]`).find('#add-to-cart');
button.text('Added');
button.prop('disabled', true);
// var button = $(`[data-id=${id}]`).find('#add-to-cart');
// button.text('Added');
// button.prop('disabled', true);
}

// get cart count
Expand Down
Loading

0 comments on commit 880439c

Please sign in to comment.