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 @@