From 9ae7c0d90129344fd34d57e893f8f41cff7fe502 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Tue, 26 Nov 2024 13:50:49 +0530 Subject: [PATCH 1/2] FIX_DESIGN ISSUES IN REPORTS --- app/Controllers/Invoice.php | 10 ++---- app/Controllers/Payment.php | 6 +++- app/Models/InvoiceModel.php | 2 +- app/Views/invoice_form.php | 2 +- .../itemwise_report_with_payment_method.php | 10 ++++-- app/Views/received_payments_report.php | 33 ++++++++++--------- app/Views/report_book_publish.php | 17 +++++----- app/Views/report_expired_customers.php | 10 ++++-- app/Views/report_general_invoice.php | 20 +++++------ app/Views/report_itemwise.php | 13 +++++--- app/Views/report_userwise_and_eventwise.php | 10 ++++-- app/Views/subscribers_list.php | 4 +-- 12 files changed, 74 insertions(+), 63 deletions(-) diff --git a/app/Controllers/Invoice.php b/app/Controllers/Invoice.php index 95c21b1c..6ba3a077 100755 --- a/app/Controllers/Invoice.php +++ b/app/Controllers/Invoice.php @@ -1195,14 +1195,8 @@ public function create_or_update_subscription($invoice_id,$invoice_status, $msg_ $data['selected_data'] = $this->request->getVar('date'); $this->logger->info("Itemwise Report "); } - $this->logger->info("'Membership Renewals Report'"); - if (empty($data['selected_data'])){ - //dd($data['selected_data']); - $data['page_name'] = 'Membership Renewals Report (30 days)'; - }else{ - list($fromDate, $toDate) = explode(" - ", $data['selected_data']); - $data['page_name'] = 'Membership Renewals Report -
(From '.$fromDate.' To '.$toDate.')'; - } + + $data['page_name'] = 'Membership Renewals Report (30 days)'; $this->render_page('report_expired_customers', $data); } diff --git a/app/Controllers/Payment.php b/app/Controllers/Payment.php index 1421329d..b26477db 100644 --- a/app/Controllers/Payment.php +++ b/app/Controllers/Payment.php @@ -204,6 +204,7 @@ public function payment_success() { 'billing_address'=> $address['address_1'], 'billing_address_id' => isset($address['customer_address_id']) ? $address['customer_address_id'] : '', 'payment_method' => $payment_method, + 'business_id' =>2 //ask vel ]; $model->save($data); $update_invoice_numbering = [ @@ -260,7 +261,10 @@ public function payment_success() { 'is_renew' => 1, 'business_id'=>2, 'status' =>1, - 'membership_id' =>$membership_id + 'membership_id' =>$membership_id, + 'isactive' =>1, + 'business_id' =>2 //ask vel + ]; $db->table('subscription')->insert($subscriptionData); diff --git a/app/Models/InvoiceModel.php b/app/Models/InvoiceModel.php index 70e3deb3..0219114d 100755 --- a/app/Models/InvoiceModel.php +++ b/app/Models/InvoiceModel.php @@ -147,7 +147,7 @@ public function getJoinedData($where, $orderby = []) // Print the last executed query - // echo $this->db->getLastQuery();die; + //echo $this->db->getLastQuery();die; return $resultArray; } diff --git a/app/Views/invoice_form.php b/app/Views/invoice_form.php index 8a744bb9..58082393 100755 --- a/app/Views/invoice_form.php +++ b/app/Views/invoice_form.php @@ -1559,7 +1559,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d return b.is_renew - a.is_renew; }); if (cm.length > 0) { - text1 = cm[0].is_renew == 1 ? " - Renewal" : ""; + text1 = cm[0].is_renew == 1 ? " - Renewed" : ""; text2 = cm[0].isactive == 0 ? " - Expried" : ""; $(".subscribedetails").show(); // Change this line to use the class selector let message = "Earlier Membership : " + cm[0].title + " ( From: " + cm[0].formatted_from_subscription + " To: " + cm[0].formatted_to_subscription + " )" + text1 + text2; diff --git a/app/Views/itemwise_report_with_payment_method.php b/app/Views/itemwise_report_with_payment_method.php index c7099b3d..2a5d0544 100644 --- a/app/Views/itemwise_report_with_payment_method.php +++ b/app/Views/itemwise_report_with_payment_method.php @@ -1,12 +1,15 @@ -
+
+

-
-
+ + +
+
@@ -21,6 +24,7 @@
+
diff --git a/app/Views/received_payments_report.php b/app/Views/received_payments_report.php index ef94f2d6..d75f036b 100644 --- a/app/Views/received_payments_report.php +++ b/app/Views/received_payments_report.php @@ -35,15 +35,17 @@ -
-
-
-

-
+
+ +
+
+

- -
- +
+ + +
+
@@ -55,8 +57,9 @@
-
-
+
+
+
@@ -64,31 +67,31 @@
  • > - UPI - ₹ + UPI ₹
  • > - CASH - ₹ + CASH ₹
  • > - DEBIT CARD - ₹ + DEBIT CARD ₹
  • > - CREDIT CARD - ₹ + CREDIT CARD ₹
  • > - BANK TRANSFER - ₹ + BANK TRANSFER ₹
  • diff --git a/app/Views/report_book_publish.php b/app/Views/report_book_publish.php index 89624692..f73ad7d4 100755 --- a/app/Views/report_book_publish.php +++ b/app/Views/report_book_publish.php @@ -1,22 +1,20 @@ -
    +
    +

    -
    -
    + + +
    +
    -
    - - -
    - +
    -
    @@ -25,6 +23,7 @@
    +
    diff --git a/app/Views/report_expired_customers.php b/app/Views/report_expired_customers.php index 10d9f56a..97767d38 100755 --- a/app/Views/report_expired_customers.php +++ b/app/Views/report_expired_customers.php @@ -1,11 +1,14 @@ -
    -
    +
    + +

    -
    + + +
    @@ -21,6 +24,7 @@
    +
    diff --git a/app/Views/report_general_invoice.php b/app/Views/report_general_invoice.php index 01a28cda..6ee80ff0 100755 --- a/app/Views/report_general_invoice.php +++ b/app/Views/report_general_invoice.php @@ -1,33 +1,29 @@ -
    +
    +

    -
    - + + +
    +
    -
    - - - -
    - +
    -
    - -
    +
    diff --git a/app/Views/report_itemwise.php b/app/Views/report_itemwise.php index 96a80f5a..1066c98b 100755 --- a/app/Views/report_itemwise.php +++ b/app/Views/report_itemwise.php @@ -24,19 +24,21 @@ -
    +
    +

    -
    -
    - + + +
    +
    - +
    @@ -46,6 +48,7 @@
    +
    diff --git a/app/Views/report_userwise_and_eventwise.php b/app/Views/report_userwise_and_eventwise.php index b56c172a..357fd858 100644 --- a/app/Views/report_userwise_and_eventwise.php +++ b/app/Views/report_userwise_and_eventwise.php @@ -1,12 +1,15 @@ -
    +
    +

    -
    -
    + + +
    +
    @@ -21,6 +24,7 @@
    +
    diff --git a/app/Views/subscribers_list.php b/app/Views/subscribers_list.php index 5a0bf486..7ae018e3 100755 --- a/app/Views/subscribers_list.php +++ b/app/Views/subscribers_list.php @@ -37,8 +37,8 @@ Member's Mobile From Subscription To Subscription - Short-Code Expiring Status + Short-Code Invoice Number Total (₹) Status @@ -96,8 +96,8 @@ - + From b31d922f9a9c4721f2fba778d4f03b20453dce87 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Wed, 27 Nov 2024 11:20:35 +0530 Subject: [PATCH 2/2] CHANGE_MANDATORY FIELDS IN CUSTOMER FORM --- app/Controllers/Invoice.php | 12 +- app/Controllers/Payment.php | 22 +-- app/Models/InvoiceModel.php | 44 +++--- app/Views/customer_form.php | 16 +- app/Views/invoice_form.php | 2 +- app/Views/received_payments_report.php | 205 +++++++++++++------------ app/Views/report_expired_customers.php | 4 +- app/Views/subscription_renewal.php | 18 ++- 8 files changed, 178 insertions(+), 145 deletions(-) diff --git a/app/Controllers/Invoice.php b/app/Controllers/Invoice.php index 6ba3a077..5eb44d6b 100755 --- a/app/Controllers/Invoice.php +++ b/app/Controllers/Invoice.php @@ -497,7 +497,7 @@ public function prepare_invoice_data($invoice_id, $msg_flag_name) 'shipping_label' => ((int)$invoiceType === 1) ? $this->request->getPost('shippingChargesLabel') : NULL, 'order_number' => $this->request->getPost('order_number'), 'payment_method' => $invoice_status !== 'Draft' ? $this->request->getPost('payment_method') : NULL, - 'payment_status' => 'Pending', + 'payment_status' => $invoice_status !== 'Draft'?'Paid':'Pending', 'payment_note' => $this->request->getPost('payment_note'), 'event_id' => (int)$this->request->getPost('event_id'), 'business_id' => (int)get_business_id(), @@ -1196,7 +1196,13 @@ public function create_or_update_subscription($invoice_id,$invoice_status, $msg_ $this->logger->info("Itemwise Report "); } - $data['page_name'] = 'Membership Renewals Report (30 days)'; + if (empty($data['selected_data'])){ + //dd($data['selected_data']); + $data['page_name'] = 'Membership Renewals Report (30 days)'; + }else{ + list($fromDate, $toDate) = explode(" - ", $data['selected_data']); + $data['page_name'] = 'Membership Renewals Report -
    (From '.$fromDate.' To '.$toDate.')'; + } $this->render_page('report_expired_customers', $data); } @@ -1281,7 +1287,7 @@ public function create_or_update_subscription($invoice_id,$invoice_status, $msg_ $data['selected_data'] = $this->request->getVar('date'); } $data['page_name'] = 'Received Payments Report'; - log_message('info',json_encode($data)); + // log_message('info',json_encode($data)); $this->render_page('received_payments_report',$data); } public function itemwise_report_with_payment_method(){ diff --git a/app/Controllers/Payment.php b/app/Controllers/Payment.php index b26477db..4c4e1e51 100644 --- a/app/Controllers/Payment.php +++ b/app/Controllers/Payment.php @@ -75,9 +75,10 @@ class Payment extends BaseController $userAgent = $_SERVER['HTTP_USER_AGENT']; $payment_method = preg_match('/mobile/i', $userAgent) ? "mobile" : 'website'; $data = $_POST; + $membership_id = $this->request->getPost('membership_id'); $paramList = array(); $CUST_ID = (string) $this->request->getPost("CustomerID"); - $ORDER_ID = (string) $this->request->getPost("membership_id"); + $ORDER_ID = (string) uniqid($CUST_ID . "_".$membership_id."_"); $CHANNEL_ID = ($payment_method == "mobile") ? (string) env('Channel_ID_Mobile') : (string) env('Channel_ID_WEB'); $TXN_AMOUNT = (string) $this->request->getPost("amount"); @@ -160,12 +161,12 @@ public function payment_failure(){ public function payment_success() { helper('session'); helper('financial_year_helper'); - - $past_membership_id = $this->request->getVar('ORDERID'); - $payment_method = $this->request->getVar('PAYMENTMODE'); $subModel = new SubscriptionModel(); - $customer = $subModel->select('customer_id')->where('membership_id',$past_membership_id)->first(); - $customer_id = $customer['customer_id']; + $ORDER_ID = $this->request->getVar('ORDERID'); + $parts = explode('_', $ORDER_ID); + $customer_id = (int)$parts[0]; + $past_membership_id = (int)$parts[1]; + $payment_method = $this->request->getVar('PAYMENTMODE'); //dd($past_membership_id); // $parts = explode('_', $ORDER_ID); // $customer_id = (int)$parts[0]; @@ -204,7 +205,7 @@ public function payment_success() { 'billing_address'=> $address['address_1'], 'billing_address_id' => isset($address['customer_address_id']) ? $address['customer_address_id'] : '', 'payment_method' => $payment_method, - 'business_id' =>2 //ask vel + 'business_id' =>2 ]; $model->save($data); $update_invoice_numbering = [ @@ -243,7 +244,6 @@ public function payment_success() { 'to_subscription' =>$tsubscription, ]; - $invoice = new Invoice(); $db->table('invoiceitems')->insert($requestData); $model3 = new SubscriptionModel(); $invoiceController = new Invoice(); @@ -252,18 +252,20 @@ public function payment_success() { // if ($membership_id<=0){ // $membership_id = $invoice->generate_membership_id(6); // } + + $subscription = $subModel->select('sub_id')->where('membersip_id',$past_membership_id)->first(); $subscriptionData = [ 'scheme_id' =>3, 'customer_id' => $customer_id, 'invoice_id' => $invoice_id, 'from_subscription'=>$fsubscription, 'to_subscription'=>$tsubscription, - 'is_renew' => 1, + 'is_renew' => $subscription['sub_id'], 'business_id'=>2, 'status' =>1, 'membership_id' =>$membership_id, 'isactive' =>1, - 'business_id' =>2 //ask vel + 'business_id' =>2 ]; $db->table('subscription')->insert($subscriptionData); diff --git a/app/Models/InvoiceModel.php b/app/Models/InvoiceModel.php index 0219114d..4ed68c15 100755 --- a/app/Models/InvoiceModel.php +++ b/app/Models/InvoiceModel.php @@ -561,28 +561,32 @@ public function getExpiredCustomers($f_date = null, $t_date = null) // Calculate the date 30 days from now $futureDate = date('Y-m-d', strtotime('+30 days')); - // Initialize query builder - $query = $this->db->table('subscription as S'); +$query = $this->db->table('subscription as S'); - // Apply custom date range filter if both $f_date and $t_date are provided - if (!empty($f_date) && !empty($t_date)) { - $query->where('S.to_subscription >=', $f_date) - ->where('S.to_subscription <=', $t_date); - - } else { - $query->where('S.to_subscription >=', date('Y-m-d')) - ->where('S.to_subscription <=', $futureDate); - } +if (!empty($f_date) && !empty($t_date)) { + $query->where('S.to_subscription >=', $f_date) + ->where('S.to_subscription <=', $t_date); +} else { + $query->where('S.to_subscription >=', date('Y-m-d')) + ->where('S.to_subscription <=', $futureDate); +} + +$subquery = $this->db->table('subscription as S2') + ->select('S.sub_id') + ->where('S2.customer_id = S.customer_id') + ->where('S.sub_id = S2.is_renew'); + +$result = $query + ->select('S.customer_id, S.sub_id, S.from_subscription, S.to_subscription, + C.first_name, C.last_name, C.email, C.mobile_no, + S.scheme_id, B.short_code, S.membership_id') + ->join('customers as C', 'C.customer_id = S.customer_id', 'left') + ->join('books as B', 'B.book_id = S.scheme_id', 'left') + ->where('S.isactive', 1) + ->whereNotIn('S.sub_id', $subquery) + ->orderBy('S.to_subscription', 'ASC') + ->get(); - // Build the query - $result = $query - ->select('S.customer_id, S.sub_id, S.from_subscription, S.to_subscription, - C.first_name, C.last_name, C.email, C.mobile_no, - S.scheme_id, B.short_code') - ->join('customers as C', 'C.customer_id = S.customer_id', 'left') - ->join('books as B', 'B.book_id = S.scheme_id', 'left') - ->where('S.isactive', 1) // Only active subscriptions - ->get(); // Debugging: output the generated SQL query // echo $this->db->getLastQuery(); diff --git a/app/Views/customer_form.php b/app/Views/customer_form.php index 9bfafcf4..5d540b14 100755 --- a/app/Views/customer_form.php +++ b/app/Views/customer_form.php @@ -35,13 +35,13 @@
    - - + +
    - - + +
    @@ -110,8 +110,8 @@
    - - + +
    @@ -182,8 +182,8 @@
    - - + +
    diff --git a/app/Views/invoice_form.php b/app/Views/invoice_form.php index 58082393..3a6bab34 100755 --- a/app/Views/invoice_form.php +++ b/app/Views/invoice_form.php @@ -1556,7 +1556,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d success: function(response) { cm = response['data']['customer_membership']; cm.sort(function(a, b) { - return b.is_renew - a.is_renew; + return b.is_renew - a.is_renew;n }); if (cm.length > 0) { text1 = cm[0].is_renew == 1 ? " - Renewed" : ""; diff --git a/app/Views/received_payments_report.php b/app/Views/received_payments_report.php index d75f036b..4a1e553f 100644 --- a/app/Views/received_payments_report.php +++ b/app/Views/received_payments_report.php @@ -1,38 +1,42 @@
    @@ -61,44 +65,22 @@
    -
    +
    - -
    @@ -136,10 +118,17 @@ - + + + + + Total Amount + + +
    @@ -148,48 +137,70 @@
    - - - + + updateTotal(); + }); + + +