From f6759ed8b6004cc6d9c3dfd59083d0b151cc56d0 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Thu, 28 Nov 2024 17:06:19 +0530 Subject: [PATCH] FIX_ISSUES IN REPORTS --- app/Controllers/Payment.php | 13 ++-- app/Models/HomeModel.php | 3 +- app/Models/InvoiceModel.php | 4 +- app/Models/SubscriptionModel.php | 2 +- app/Views/customer_form.php | 8 ++- app/Views/dashboard.php | 29 ++++---- app/Views/invoice_form.php | 95 ++++++++++++++++++-------- app/Views/received_payments_report.php | 11 +-- app/Views/report_book_publish.php | 2 +- app/Views/subscribers_list.php | 13 ++-- 10 files changed, 115 insertions(+), 65 deletions(-) diff --git a/app/Controllers/Payment.php b/app/Controllers/Payment.php index 513b296a..3d583816 100644 --- a/app/Controllers/Payment.php +++ b/app/Controllers/Payment.php @@ -219,17 +219,20 @@ public function payment_success() { $save_invoice->update_number_formatting($update_invoice_numbering); //get the invoice id to insert into the invoiceitems table $invoice_id = $model->select('invoice_id')->where('invoice_number',$invoice_number)->first(); - //var_dump($invoice_id['invoice_id']);die(); $previous_to_sub = $subModel->select('to_subscription')->where('customer_id',$customer_id)->where('membership_id',$past_membership_id)->first(); $new_subscription_date = $previous_to_sub['to_subscription']; // Create a DateTime object from the existing subscription date $date = new \DateTime($new_subscription_date); + $currentDate = date('Y-m-d'); + if ($currentDate > $new_subscription_date){ + $fsubscription = $currentDate; //if subscription is already expired - // Add one day + }else{ + // Add one day from previous subscrption's to subscription date + $fsubscription = date('Y-m-d', strtotime('+1 day', strtotime($new_subscription_date))); + } + $date->add(new \DateInterval('P1D')); - - // Format the date (optional, if you need it in a specific format) - $fsubscription = $date->format('Y-m-d'); $tsubscription = date('Y-m-d', strtotime('+1 year', strtotime($fsubscription))); $data['item_details'] = 3; $requestData = [ diff --git a/app/Models/HomeModel.php b/app/Models/HomeModel.php index 1af30939..515d6215 100755 --- a/app/Models/HomeModel.php +++ b/app/Models/HomeModel.php @@ -194,7 +194,8 @@ class HomeModel extends Model S.to_subscription, S.from_subscription, BK.title, BK.short_code, BK.book_id, S.membership_id, DATEDIFF(S.to_subscription, CURDATE()) as countdays, DATE_FORMAT(S.to_subscription, "%d/%m/%Y") as to_subscription_date_format, - ( NHC.sent_time ) as email_last_notify_on') + S.is_renew, + ( NHC.sent_time ) as email_last_notify_on,(select is_renew from subscription as sub where S.sub_id = sub.is_renew)as renewed') ->where('S.to_subscription >=', $now) ->where('S.to_subscription <=', $last30days) ->where('S.isactive', 1) diff --git a/app/Models/InvoiceModel.php b/app/Models/InvoiceModel.php index dc9d8b2d..e7053418 100755 --- a/app/Models/InvoiceModel.php +++ b/app/Models/InvoiceModel.php @@ -135,7 +135,7 @@ public function getJoinedData($where, $orderby = []) ->join('business as B', 'B.business_id = I.business_id', 'left') ->join('users as U1', 'U1.user_id = I.created_by', 'left') ->join('users as U2', 'U2.user_id = I.updated_by', 'left') - ->select('I.invoice_id,I.wp_api_order_id,I.invoice_number, I.customer_id,CONCAT_WS(" ", C.first_name, C.last_name) as customer_name ,C.mobile_no, I.invoice_date, I.due_date, I.subtotal, I.tax, I.discount, I.total_amount,I.status, I.payment_status, I.order_number, I.payment_method,I.invoice_type, I.event_id,E.event_name, I.business_id,B.title as business_name,DATE_FORMAT(I.created_on, "%d/%m/%Y") as created_on_format,I.created_on, I.created_by,CONCAT_WS(" ", U1.first_name, U1.last_name) as created_by_name,DATE_FORMAT(I.updated_on, "%d/%m/%Y") as updated_on_format, I.updated_by,CONCAT_WS(" ", U2.first_name, U2.last_name) as updated_by_name, I.isactive,C.email as customer_email,C.mobile_no as customer_mobile,I.shipping_address_id,I.shipping_address,I.billing_address_id,I.billing_address,B.address as business_address,B.city as business_city,B.state as business_state,B.postal_code as business_postal_code,B.email as business_email,B.mobile_no as business_mobile_no,S.from_subscription,S.to_subscription,DATEDIFF(S.to_subscription, S.from_subscription) as subscription_in_days,S.scheme_id') + ->select('I.invoice_id,I.wp_api_order_id,I.invoice_number, I.customer_id,CONCAT_WS(" ", C.first_name, C.last_name) as customer_name ,C.mobile_no, I.invoice_date, I.due_date, I.subtotal, I.tax, I.discount, I.total_amount,I.status, I.payment_status, I.order_number, I.payment_method,I.invoice_type, I.event_id,E.event_name, I.business_id,B.title as business_name,DATE_FORMAT(I.created_on, "%d/%m/%Y") as created_on_format,I.created_on, I.created_by,CONCAT_WS(" ", U1.first_name, U1.last_name) as created_by_name,DATE_FORMAT(I.updated_on, "%d/%m/%Y") as updated_on_format, I.updated_by,CONCAT_WS(" ", U2.first_name, U2.last_name) as updated_by_name, I.isactive,C.email as customer_email,C.mobile_no as customer_mobile,I.shipping_address_id,I.shipping_address,I.billing_address_id,I.billing_address,B.address as business_address,B.city as business_city,B.state as business_state,B.postal_code as business_postal_code,B.email as business_email,B.mobile_no as business_mobile_no,S.from_subscription,S.to_subscription,DATEDIFF(S.to_subscription, S.from_subscription) as subscription_in_days,S.scheme_id,(SELECT is_renew FROM subscription as sub WHERE S.sub_id = sub.is_renew LIMIT 1) as renewed') ->where($where); // if (!empty($orderby)) { // $query->orderBy($orderby[0], $orderby[1]); @@ -293,7 +293,7 @@ public function getJoinedData($where, $orderby = []) ->join('books as BK', 'BK.book_id = S.scheme_id', 'left') ->join('book_categories as BC', 'BC.book_id = S.scheme_id', 'left') ->join('category as CM', 'CM.id = BC.category_id', 'left') - ->select('S.customer_id,BK.short_code,S.membership_id ,CONCAT_WS(" ", C.first_name, C.last_name) as customer_name, S.sub_id, S.scheme_id, DATE_FORMAT(S.from_subscription, "%d/%m/%Y") AS formatted_from_subscription, DATE_FORMAT(S.to_subscription, "%d/%m/%Y") AS formatted_to_subscription, S.from_subscription, S.to_subscription,S.isactive,S.is_renew, S.created_on, CM.name ,BK.title, BK.book_id') + ->select('S.customer_id,BK.short_code,S.membership_id,S.status ,CONCAT_WS(" ", C.first_name, C.last_name) as customer_name, S.sub_id, S.scheme_id, DATE_FORMAT(S.from_subscription, "%d/%m/%Y") AS formatted_from_subscription, DATE_FORMAT(S.to_subscription, "%d/%m/%Y") AS formatted_to_subscription, S.from_subscription, S.to_subscription,S.isactive,S.is_renew, S.created_on, CM.name ,BK.title, BK.book_id') ->where('LOWER(CM.name)', strtolower($category)) ->where('S.customer_id', $id) ->orderBy('S.to_subscription', 'ASC') diff --git a/app/Models/SubscriptionModel.php b/app/Models/SubscriptionModel.php index f1d1f393..6b9e9758 100755 --- a/app/Models/SubscriptionModel.php +++ b/app/Models/SubscriptionModel.php @@ -15,7 +15,7 @@ public function getAllSubscribersWithNames($where) { $builder = $this->db->table('subscription'); - $builder->select('subscription.*, books.title,books.short_code, books.isactive, CONCAT_WS(" ", customers.first_name, customers.last_name) as customer_name'); + $builder->select('subscription.*, books.title,books.short_code, books.isactive, CONCAT_WS(" ", customers.first_name, customers.last_name) as customer_name,(SELECT is_renew FROM subscription as sub WHERE subscription.sub_id = sub.is_renew LIMIT 1)as renewed'); $builder->join('books', 'books.book_id = subscription.scheme_id'); $builder->join('customers', 'customers.customer_id = subscription.customer_id'); $builder->where($where); diff --git a/app/Views/customer_form.php b/app/Views/customer_form.php index 43b3e071..667fd916 100755 --- a/app/Views/customer_form.php +++ b/app/Views/customer_form.php @@ -17,7 +17,7 @@ getFlashdata('error')) : ?> - @@ -411,6 +411,9 @@ $("#szip").val("").prop("readonly", false); $("#scustomer_address_id").val("") // Hidden Field ressetted bcoz Adress history } + var alert = $('#errorAlert').val(); + console.log("The alert message is "+alert); + $('#myForm').parsley().validate(); }); $("#bcountry").on("change", function() { var country = $("#bcountry").val(); @@ -482,7 +485,6 @@ html.find('input#sistate0').attr('id', 'sistate' + j).css("display", "block").val(sarray[i]['state']); html.find('select#sdstate0').attr('id', 'sdstate' + j).css("display", "none").val(''); } - html.find('input#szip').val(sarray[i]['postal_code']); if (i !== 0) { html.find(".shipping-addr-div-change").html("+ Add More Shipping Address - Remove "); diff --git a/app/Views/dashboard.php b/app/Views/dashboard.php index 5eb28e12..bb57989d 100755 --- a/app/Views/dashboard.php +++ b/app/Views/dashboard.php @@ -140,24 +140,25 @@

Expiring Membership List in next 30 days

- - - - - - - - - - - - - +
#NameMobile NoEmailScheme NameExpiring InNotification Onmember id
+ + + + + + + + + + + + @@ -179,7 +180,7 @@ - diff --git a/app/Views/invoice_form.php b/app/Views/invoice_form.php index 0f373bba..11376d99 100755 --- a/app/Views/invoice_form.php +++ b/app/Views/invoice_form.php @@ -96,14 +96,18 @@ input[type=number] { top:35px; } #customerName~.parsley-errors-list{ - position: relative; - top: 70px !important; - z-index: 0; + position: absolute; + color: red; + font-size: 12px; + top: 100%; /* Below the input field */ + left: 0; } #loadShippingDropdown~.parsley-errors-list{ - position: relative; - top: 70px !important; - z-index: 0; + position: absolute; + color: red; + font-size: 12px; + top: 100%; /* Below the input field */ + left: 0; } #fromsubcription~.parsley-errors-list{ position: absolute; @@ -215,7 +219,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
-
@@ -1595,9 +1599,10 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d $(".subscribedetails").show(); // Change this line to use the class selector let messages = "Earlier Membership :
"; for (let i = 0; i < cm.length; i++) { - let text1 = cm[i].is_renew == 1 ? " - Renewal" : ""; - let text2 = cm[i].isactive == 1 ? " - Active" : " - Draft "; - messages += cm[i].title + "
( From: " + cm[i].formatted_from_subscription + " To: " + cm[i].formatted_to_subscription + " )" + text1 + text2 + "
"; + let text1 = cm[i].is_renew > 1 ? " - Renewed" : ""; + let text2 = cm[i].isactive != 1 ? " - Draft" : ""; + let text3 = cm[i].status == 0 ? ' - Expired ': " - Active"; + messages += cm[i].title + "
( From: " + cm[i].formatted_from_subscription + " To: " + cm[i].formatted_to_subscription + " )" + text1 + text2 + text3+ "
"; } // $("#schemeName").text(message); $('#membership_id').empty(); @@ -1607,33 +1612,62 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d membership_id = cm[i].membership_id; console.log(membership_id); - $('#membership_id').append(''); + if (cm[i].is_renew>0){ + $('#membership_id').append(''); + } } $('#membership_id').on('change', function () { var output = $('#membership_id').val();console.log(membership_choice); var membership_choice = output.charAt(output.length-1); var rawDate = cm[membership_choice].formatted_to_subscription; - var dateParts = rawDate.split('/'); - var prev_fsubscription = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]); + var currentDate = new Date(); - prev_fsubscription.setDate(prev_fsubscription.getDate() + 1); - var fsubscription = (prev_fsubscription.getDate()).toString().padStart(2, '0') + '/' + - (prev_fsubscription.getMonth() + 1).toString().padStart(2, '0') + '/' + - prev_fsubscription.getFullYear(); + // Format current date as dd-mm-yy + var formattedDate = ('0' + currentDate.getDate()).slice(-2) + '-' + + ('0' + (currentDate.getMonth() + 1)).slice(-2) + '-' + + currentDate.getFullYear().toString().slice(-2); + // Parse rawDate into a Date object + var rawDateParts = rawDate.split('/'); + var rawDateObj = new Date(rawDateParts[2], rawDateParts[1] - 1, rawDateParts[0]); + + var fsubscription, tsubscription; + + if (currentDate > rawDateObj) { + // Start from current date + fsubscription = ('0' + currentDate.getDate()).slice(-2) + '/' + + ('0' + (currentDate.getMonth() + 1)).slice(-2) + '/' + + currentDate.getFullYear(); + + var tsubscriptionDate = new Date(currentDate); + tsubscriptionDate.setFullYear(tsubscriptionDate.getFullYear() + 1); + tsubscription = ('0' + tsubscriptionDate.getDate()).slice(-2) + '/' + + ('0' + (tsubscriptionDate.getMonth() + 1)).slice(-2) + '/' + + tsubscriptionDate.getFullYear(); + } else { + // Start from rawDate + 1 day + rawDateObj.setDate(rawDateObj.getDate() + 1); + fsubscription = ('0' + rawDateObj.getDate()).slice(-2) + '/' + + ('0' + (rawDateObj.getMonth() + 1)).slice(-2) + '/' + + rawDateObj.getFullYear(); + + rawDateObj.setFullYear(rawDateObj.getFullYear() + 1); + tsubscription = ('0' + rawDateObj.getDate()).slice(-2) + '/' + + ('0' + (rawDateObj.getMonth() + 1)).slice(-2) + '/' + + rawDateObj.getFullYear(); + } + + // Update input fields $('#fromsubcription').val(fsubscription).prop('readonly', true); - - prev_fsubscription.setFullYear(prev_fsubscription.getFullYear() + 1); - var tsubscription = (prev_fsubscription.getDate()).toString().padStart(2, '0') + '/' + - (prev_fsubscription.getMonth() + 1).toString().padStart(2, '0') + '/' + - prev_fsubscription.getFullYear(); - - $('#tosubcription').val(tsubscription).prop('readonly', true); + $('#tosubcription').val(tsubscription).prop('readonly', true); + $('#myForm').parsley().validate(); $('#book0').empty(); $('#book0').append(''); $('#book0').prop('readonly',true); var element = $('#book0')[0]; // Get the actual DOM element (not the value) displayBookTag(element, 0); + $('#myForm').parsley().validate(); + }); showAlert(messages.trim()); } else { @@ -1740,11 +1774,16 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d // When the "Save as Approved" button is clicked document.getElementById('saveApprovedButton').addEventListener('click', function() { // Show the payment modal + const isParsleyValid = $(myForm).parsley().validate(); + + // Check both browser-native validity and Parsley validation + if (isParsleyValid) { + // Show the payment modal if the form is valid $('#paymentModal').modal('show'); - - - // When the "Confirm Payment" button in the modal is clicked - // Get the selected mode of payment + } else { + // Focus on the first invalid field (optional for better UX) + $(myForm).find('.parsley-error').first().focus(); + } var selectedPaymentMode = document.getElementById('paymentMode').value; // You can now use the selected payment mode as needed diff --git a/app/Views/received_payments_report.php b/app/Views/received_payments_report.php index 4a1e553f..4a6ce03d 100644 --- a/app/Views/received_payments_report.php +++ b/app/Views/received_payments_report.php @@ -27,6 +27,8 @@ background-color: transparent; /* Transparent container */ width: 190px; /* Card width */ height: 50px; /* Card height */ + padding-left: 20px; + } .nav { @@ -49,7 +51,7 @@
-
+
@@ -69,11 +71,12 @@
S.NoNameMobile NoEmailScheme Name Expires ByNotification On member id
No data found