From 7027d8bdbffb327566a2a48db3034cb7595b5773 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Wed, 4 Dec 2024 12:05:10 +0530 Subject: [PATCH] FEAT_FILTER ADDED IN SEND EXPIRY MESSAGE --- app/Config/Routes.php | 2 +- app/Controllers/Customer.php | 2 +- app/Controllers/Subscription.php | 14 ++++ app/Models/NotificationModel.php | 18 +++++ app/Models/SubscriptionModel.php | 1 + app/Views/invoice_form.php | 12 +-- app/Views/notify_the_expiry_subscribers.php | 89 ++++++++++++++++++--- app/Views/report_book_publish.php | 8 +- 8 files changed, 125 insertions(+), 21 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 30d0c5b2..4e3c4a76 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -98,7 +98,7 @@ $routes->get("subscribers_list/", "Subscription::index"); $routes->get("new_subscription_invoice/(:any)", "Invoice::new_subscription_invoice/$1"); $routes->post("add_subscription/", "Subscription::add_subscription/"); $routes->post('subscription/download_details', 'Subscription::download_details'); -$routes->get("notify_the_expiry_subscribers/", "Subscription::notify_the_expiry_subscribers"); +$routes->match(['get','post'],"notify_the_expiry_subscribers/", "Subscription::notify_the_expiry_subscribers"); diff --git a/app/Controllers/Customer.php b/app/Controllers/Customer.php index a92bbaac..24a27742 100755 --- a/app/Controllers/Customer.php +++ b/app/Controllers/Customer.php @@ -666,7 +666,7 @@ class Customer extends BaseController $result = $model->storeCustomerAddresses($billingData, $shippingData); if (!empty($result['billing_addr_id']) && !empty($result['shipping_addr_id'])) { - $results = ['status' => true, 'message' => 'New addresses saved successfully', 'cus_id' =>$this->request->getPost('customer_id'),"billing_addr_id"=>$result['billing_addr_id'],"shipping_addr_id"=>$result['shipping_addr_id']]; + $results = ['status' => true, 'message' => 'New Address Saved Successfully', 'cus_id' =>$this->request->getPost('customer_id'),"billing_addr_id"=>$result['billing_addr_id'],"shipping_addr_id"=>$result['shipping_addr_id']]; } else { $results = ['status' => false, 'message' => 'Failed to save New addresses']; } diff --git a/app/Controllers/Subscription.php b/app/Controllers/Subscription.php index 68ee6c3e..a23443f5 100755 --- a/app/Controllers/Subscription.php +++ b/app/Controllers/Subscription.php @@ -7,6 +7,7 @@ use App\Models\CustomerModel; use App\Models\SubscriptionModel; use App\Models\SchemeModel; use App\Models\InvoiceModel; +use App\Models\NotificationModel; use Mpdf\Mpdf; class Subscription extends BaseController @@ -298,7 +299,20 @@ public function download_details() } public function notify_the_expiry_subscribers(){ + if ($this->request->is('post')){ + $dateParts = explode(' - ', $this->request->getPost('date')); + $fromDate = $dateParts[0]; + $toDate = $dateParts[1]; + $from_date = \DateTime::createFromFormat('d/m/Y', $fromDate); + $to_date = \DateTime::createFromFormat('d/m/Y', $toDate); + $model = new NotificationModel(); + $response['data'] = $model->get_email_data($from_date->format('Y-m-d'), $to_date->format('Y-m-d')); + // log_message('info','Selected from date is '.$from_date); + $response['selected_data'] = $this->request->getPost('date'); + return $this->response->setJson($response); + } $data['page_name'] = 'Notify the Expiry Subscribers'; + $data['selected_data'] = ''; $this->render_page('notify_the_expiry_subscribers',$data); } diff --git a/app/Models/NotificationModel.php b/app/Models/NotificationModel.php index 4bad4109..12fa33bc 100755 --- a/app/Models/NotificationModel.php +++ b/app/Models/NotificationModel.php @@ -347,6 +347,24 @@ public function getExpDate2(){ ->where('nhc.receiving_status = ',1) ->get()->getResultArray(); } + + public function get_email_data($f_date = null , $t_date = null){ + $builder = $this->db->table('notification_history_parents as nhp'); + $builder->select('nhp.*, nhc.*, nc.*,C.first_name,C.last_name,C.email, S.sub_id,S.membership_id, DATEDIFF(S.to_subscription, CURDATE()) AS countdays'); + $builder->join('notification_history_children as nhc', 'nhc.fkid = nhp.id'); + $builder->join('notification_campaign as nc', 'nc.campaign_id = nhp.campaign_id'); + $builder->join('customers as C', 'C.customer_id = nhc.customer_id'); + $builder->join('subscription as S', 'S.sub_id = nhc.subscription_id'); + $builder->where('nhp.start_date_time >=', $f_date); + $builder->where('nhp.start_date_time <=', $t_date); + $builder->whereIn('nhp.campaign_id', [1, 2]); + $builder->where('nc.isactive', 1); + + $query = $builder->get(); + $results = $query->getResult(); + log_message('info',json_encode($results)); + return $results; + } } diff --git a/app/Models/SubscriptionModel.php b/app/Models/SubscriptionModel.php index 6b9e9758..ba47bc6e 100755 --- a/app/Models/SubscriptionModel.php +++ b/app/Models/SubscriptionModel.php @@ -381,6 +381,7 @@ public function getQueryforSubscriptionDetailsBySchemeName($flag,$condition, $va + } diff --git a/app/Views/invoice_form.php b/app/Views/invoice_form.php index 4ec21c91..d4d8d943 100755 --- a/app/Views/invoice_form.php +++ b/app/Views/invoice_form.php @@ -847,7 +847,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
- + @@ -889,7 +889,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
- + @@ -1401,6 +1401,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d $("#editAddressesCheckbox").on("change", function() { if ($(this).is(":checked")) { + $('#quick_shipping_country').attr('required',true); // $("#storeBillingAddress").prop("readonly", false); $("#storeBillingAddress").prop("readonly", true); @@ -1512,7 +1513,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d console.log("cFAFAFAbbb",cb); $.each(cb, function(k, v) { var state = v.state_name ? v.state_name : v.state; - state = v.postal_code ? state + v.postal_code : state; + state = v.postal_code ? state +' ' + v.postal_code : state; v.address_1 ? customer_billing_addressDetails.push(v.address_1 + " " + v.address_2) : ""; v.city ? customer_billing_addressDetails.push(v.city) : ""; state ? customer_billing_addressDetails.push(state) : ""; @@ -1582,7 +1583,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d if (cs.length > 0) { $.each(cs, function(k, v) { var state = v.state_name ? v.state_name : v.state; - state = v.postal_code ? state + v.postal_code : state; + state = v.postal_code ? state + ' ' + v.postal_code : state; v.address_1 ? customer_shipping_addressDetails.push(v.address_1 + " " + v.address_2) : ""; v.city ? customer_shipping_addressDetails.push(v.city) : ""; state ? customer_shipping_addressDetails.push(state) : ""; @@ -2032,7 +2033,8 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d const formattedShippingAddress = [ saddress1 + " " + (saddress2 || ""), scity, - (sstate ? sstate + szip : ""), + (sstate ? sstate : ""), + szip, scountry ] .filter(Boolean) diff --git a/app/Views/notify_the_expiry_subscribers.php b/app/Views/notify_the_expiry_subscribers.php index a18e815c..253f3f81 100755 --- a/app/Views/notify_the_expiry_subscribers.php +++ b/app/Views/notify_the_expiry_subscribers.php @@ -8,27 +8,54 @@
-
- -
+
+ +
+
+ +

-
+ - - + diff --git a/app/Views/report_book_publish.php b/app/Views/report_book_publish.php index cc3396ea..a55c9214 100755 --- a/app/Views/report_book_publish.php +++ b/app/Views/report_book_publish.php @@ -78,19 +78,19 @@