diff --git a/app/controllers/API/Pay.php b/app/controllers/API/Pay.php
index 5b7a78e..dd75d1c 100644
--- a/app/controllers/API/Pay.php
+++ b/app/controllers/API/Pay.php
@@ -135,6 +135,43 @@ public function fullPay(string $a = '', string $b = '', string $c = ''):void {
+ }
+
+ public function unpaid(string $a = '', string $b = '', string $c = ''):void {
+ AuthorizationMiddleware::authorize(['customer']);
+
+ $request = new JSONRequest();
+ $response = new JSONResponse();
+
+ $payment = new PaymentModel;
+
+ $data['payments'] = $payment->first($request->getAll());
+
+ $merchant_id = MERCHANT_ID;
+ $merchant_secret = MERCHANT_SECRET;
+
+ $hash = strtoupper(
+ md5(
+ $merchant_id .
+ $data['payments']->reference_number .
+ // number_format($order->totalAmount, 2, '.', '') .
+ $data['payments']->amount .
+ 'LKR' .
+ strtoupper(md5($merchant_secret))
+ )
+ );
+
+ $data['hash'] = $hash;
+ $data['merchant_id'] = $merchant_id;
+ $data['orderId'] = $data['payments']->reference_number;
+ $data['amount'] = $data['payments']->amount;
+
+ $response->data($data)->statusCode(200)->send();
+
+
+
+
+
}
}
diff --git a/app/views/customer/components/items.view.php b/app/views/customer/components/items.view.php
index dd056ef..46f6867 100644
--- a/app/views/customer/components/items.view.php
+++ b/app/views/customer/components/items.view.php
@@ -24,7 +24,7 @@
-->
-
+
diff --git a/app/views/customer/components/orderlist.view.php b/app/views/customer/components/orderlist.view.php
index 983d2ee..425df3d 100644
--- a/app/views/customer/components/orderlist.view.php
+++ b/app/views/customer/components/orderlist.view.php
@@ -3,7 +3,8 @@
No Orders
');
foreach ($orders as $order) {
@@ -31,7 +32,8 @@
payment_status == 'pending') { ?>
-
+
rent_status == 'rented') { ?>
diff --git a/app/views/customer/orders.view.php b/app/views/customer/orders.view.php
index 849a861..66d0907 100644
--- a/app/views/customer/orders.view.php
+++ b/app/views/customer/orders.view.php
@@ -342,6 +342,37 @@ function loadOrders(status = 'all') {
});
+ // Pay button for unpaid
+ $(document).on('click','.order-pay-button', function() {
+ var referenceNo = $(this).closest('button').attr('data-id');
+ console.log(referenceNo);
+ showLoader();
+ // open pay modal
+ $.ajax({
+ url: '= ROOT_DIR ?>/api/pay/unpaid',
+ headers: {
+ 'Authorization': 'Bearer ' + getCookie('jwt_auth_token')
+ },
+ type: 'POST',
+ data: JSON.stringify({
+ reference_number: referenceNo
+ }),
+ contentType: 'application/json',
+ success: function(data) {
+ paymentGateWay(data.data);
+
+ },
+ error: function(data) {
+ console.log(data);
+ alertmsg('Error loading payment details', 'error');
+ hideLoader();
+ }
+
+ });
+
+ });
+
+
function paymentGateWay(data) {
console.log("Payment gateway");
diff --git a/app/views/rental/components/equipment.view.php b/app/views/rental/components/equipment.view.php
index 9adc32a..a327abe 100644
--- a/app/views/rental/components/equipment.view.php
+++ b/app/views/rental/components/equipment.view.php
@@ -273,7 +273,7 @@
-
+
diff --git a/app/views/rental/equipments.view.php b/app/views/rental/equipments.view.php
index 0adf16e..b7f5def 100644
--- a/app/views/rental/equipments.view.php
+++ b/app/views/rental/equipments.view.php
@@ -216,7 +216,7 @@
Upload Equipment Images
@@ -236,6 +236,15 @@
var imgContainer = $('', { 'class': 'img-preview-item' });
var img = $('', { 'class': 'image-preview' }).appendTo(imgContainer);
+ // validate file type
+ var fileType = file['type'];
+ var validImageTypes = ['image/jpeg', 'image/png', 'image/jpg', 'image/gif', 'image/webp'];
+ if (!validImageTypes.includes(fileType)) {
+ alertmsg('Invalid file type. Please select an image file' , 'error');
+ // clear
+ $('#equipment-image-input').val('');
+ return;
+ }
var removeButton = $('', {
@@ -803,9 +812,22 @@ function filterEquipment() {
formData.append('json', JSON.stringify(jsonData));
+
+
+
+
+
if (formData.get('equipment_image') != '') {
var image = formData.get('equipment_image');
+ // validate file type
+ var fileType = image['type'];
+ var validImageTypes = ['image/jpeg', 'image/png', 'image/jpg', 'image/gif', 'image/webp'];
+ if (!validImageTypes.includes(fileType)) {
+ alertmsg('Invalid file type. Please select an image file' , 'error');
+ return;
+ }
+
formData.append('image', image);
diff --git a/app/views/rental/layout/sidebar.php b/app/views/rental/layout/sidebar.php
index a2269c5..d2ccd90 100755
--- a/app/views/rental/layout/sidebar.php
+++ b/app/views/rental/layout/sidebar.php
@@ -228,7 +228,7 @@ function toggleSidebar() {
-->