From 8af557dde12e88a9975679b5a4a19427a7325a9d Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Thu, 14 Nov 2024 11:53:23 +0000 Subject: [PATCH] FIX_notification history mismatched --- app/Controllers/Home.php | 2 +- app/Models/HomeModel.php | 42 +++++++++++++++ app/Views/dashboard.php | 112 ++++++++++++++++----------------------- 3 files changed, 88 insertions(+), 68 deletions(-) diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php index a9765430..363075f4 100755 --- a/app/Controllers/Home.php +++ b/app/Controllers/Home.php @@ -27,7 +27,7 @@ class Home extends BaseController $data['invoice'] = $model->invoice_dtls(); // $data['active_category'] = $model->schemes(); $data['active_schemes'] = $model->active_schemes(); - $data['expiring_membership'] = $model->expiring_membership_list(); + $data['expiring_membership'] = $model->expiring_membership_with_notification_list(); $data['notifications'] = $model->expiring_membership_list(); // print_r( $data['expiring_membership']);die; // $data['active_category'] = array_filter($model->schemes(), function ($element) { diff --git a/app/Models/HomeModel.php b/app/Models/HomeModel.php index ad0ebdee..a0abddb6 100755 --- a/app/Models/HomeModel.php +++ b/app/Models/HomeModel.php @@ -175,6 +175,48 @@ class HomeModel extends Model ->get() ->getResultArray(); } + + public function expiring_membership_with_notification_list() { + $now = date('Y-m-d'); + $last30days = date('Y-m-d', strtotime('+30 days')); + + $membershipList = $this->db->table('subscription as S') + ->join('customers as C', 'C.customer_id = S.customer_id', 'left') + ->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('CM.name, CONCAT_WS(" ", C.first_name, C.last_name) as customer_name, + C.email as customer_email, C.mobile_no as customer_mobile, + S.sub_id, S.scheme_id, S.customer_id, S.business_id, + S.to_subscription, S.from_subscription, BK.title, BK.short_code, BK.book_id, + DATEDIFF(S.to_subscription, CURDATE()) as countdays, + DATE_FORMAT(S.to_subscription, "%d/%m/%Y") as to_subscription_date_format, + ( + SELECT MAX(NHP.start_date_time) + FROM notification_campaign as NC + LEFT JOIN notification_history_parents as NHP ON NHP.campaign_id = NC.campaign_id + LEFT JOIN notification_history_children as NHC ON NHC.fkid = NHP.id + WHERE NHC.customer_id = C.customer_id AND NHC.receiving_entity LIKE "%@%" AND NHC.receiving_status = 1 + ) as email_last_notify_on, + ( + SELECT MAX(NHP.start_date_time) + FROM notification_campaign as NC + LEFT JOIN notification_history_parents as NHP ON NHP.campaign_id = NC.campaign_id + LEFT JOIN notification_history_children as NHC ON NHC.fkid = NHP.id + WHERE NHC.customer_id = S.customer_id AND NHC.receiving_entity NOT LIKE "%@%" AND NHC.receiving_status = 1 + AND NHC.receiving_status REGEXP "^[0-9]+$" + ) as whatsapp_last_notify_on') + ->where('S.to_subscription >=', $now) + ->where('S.to_subscription <=', $last30days) + ->where('S.isactive', 1) + ->where('LOWER(CM.name)', strtolower("Membership")) + ->orderBy('S.to_subscription', 'ASC') + ->groupBy('S.sub_id') + ->get() + ->getResultArray(); + return $membershipList; + } + public function book_published_dtls(){ diff --git a/app/Views/dashboard.php b/app/Views/dashboard.php index 511c7ee4..67e55684 100755 --- a/app/Views/dashboard.php +++ b/app/Views/dashboard.php @@ -133,74 +133,52 @@

Expiring Membership List in next 30 days

- - - - - - - - - - - - - - "; - // print_r($expiring_membership); - // echo ""; - if(!empty($expiring_membership)): - foreach ($expiring_membership as $e) : - $daysincount = (int)$e['countdays']; - $daysincountstring = ($daysincount == 0 ? 'Today' : ($daysincount == 1 ? 'Tomorrow' : $daysincount . ' days')); - ?> - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#NameMobile NoEmailScheme NameExpiring InNotification On

- +
#NameMobile NoEmailScheme NameExpiring InNotification On
+ +
+
+ +
No data found
- $notifications = $e['notifications']; - $emailNotifications = array_filter($notifications, function($notification) { - return $notification['mode'] === 'Email'; - }); - - $lastNotification = end($emailNotifications); - $lastStartDateTime = ($lastNotification && isset($lastNotification['start_date_time'])) ? $lastNotification['start_date_time'] : ''; - $startDateTime = $lastStartDateTime ? date('d/m/Y', strtotime($lastStartDateTime)) : ''; - - if(isset($lastNotification['receiving_status'])){ - if ($startDateTime >= $startDate && $startDateTime <= $endDate) { - echo $startDateTime ; - } - } - ?> - - var lastNotification = ; - console.log(lastNotification); - - */ - ?> - - - - - -
No data found
- - - -