From c5d43763b8155b7b78f354885d92186eb483363a Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Thu, 7 Nov 2024 06:53:40 +0000 Subject: [PATCH] FIX_in getExpCustomerDetail --- app/Controllers/Notifications.php | 42 +++++++++++++++++++++++-------- app/Models/NotificationModel.php | 2 +- app/Views/dashboard.php | 20 ++++++++++++--- 3 files changed, 50 insertions(+), 14 deletions(-) diff --git a/app/Controllers/Notifications.php b/app/Controllers/Notifications.php index 8fb56f73..b1860ebe 100755 --- a/app/Controllers/Notifications.php +++ b/app/Controllers/Notifications.php @@ -570,7 +570,7 @@ class Notifications extends BaseController ################################################################ public function getExpCustomerDetail($window_time = null) { - echo "hi"; + echo "Hi, "; # Step 1: add the days to retrive the data// $providedDate = date('Y-m-d'); $newDate = date('Y-m-d', strtotime($providedDate . ' + ' . $window_time . ' days')); @@ -587,7 +587,7 @@ class Notifications extends BaseController # Step 3: Replace the placeholder WINDOW_TIME with the user-provided value $modifiedQuery = str_replace('WINDOW_TIME', $window_time, $ExpCustomerDetail); -// print_r($modifiedQuery);die; + // print_r($modifiedQuery);die; if (empty($modifiedQuery)) { $this->logger->error('There is no sub query'); return; @@ -619,6 +619,7 @@ class Notifications extends BaseController if ($status === 'Approved') { # EXPIRAY_NOTIFY_TEMPLATE_EMAIL $emailTemplateName = $NotificationModel->getTempName(EXPIRAY_NOTIFY_TEMPLATE_EMAIL); + echo "Person Name :".$fullName."
"; if (count($emailTemplateName) && !empty($emailTemplateName)) { $campaign_id = 1; # Insertion on History Email Means Campaign ID 1 Hardcoded @@ -627,16 +628,29 @@ class Notifications extends BaseController # Step 4: Prepare email content based on the template $emailContent = $emailTemplateName[0]['message']; - $emailContent = str_replace("{USER_NAME}", $fullName, $emailContent); - $emailContent = str_replace("{SCHEME_NAME}", $schemename, $emailContent); - $emailContent = str_replace("{EXPIRY_DATE}", $expirydate, $emailContent); + if (isset($fullName)) { + $emailContent = str_replace("{USER_NAME}", $fullName, $emailContent); + } + if (isset($schemename)) { + $emailContent = str_replace("{SCHEME_NAME}", $schemename, $emailContent); + } + if (isset($expirydate)) { + $emailContent = str_replace("{EXPIRY_DATE}", $expirydate, $emailContent); + } + if (isset($customerId)) { + $emailContent = str_replace("{RENEWAL_LINK}", base_url() . 'subscription_renewal/' . $customerId, $emailContent); + } + + $emailData = [ 'template_name' => 'EXPIRAY_NOTIFY_TEMPLATE_EMAIL', 'recipient_email' => $row['email'], 'subject' => 'Your Subscription Expiry Notification', 'description' => $emailContent, ]; + + $history_child_data = [ 'fkid' => $history_parent_id, 'customer_id' => $customerId, 'receiving_entity' => $row['email'], @@ -711,10 +725,18 @@ class Notifications extends BaseController # Step 7: Prepare whatsapp content based on the template $whatsappContent = $whatsappTemplateName[0]['message']; - $whatsappContent = str_replace("{USER_NAME}", $fullName, $emailContent); - $whatsappContent = str_replace("{SCHEME_NAME}", $schemename, $emailContent); - $whatsappContent = str_replace("{EXPIRY_DATE}", $expirydate, $emailContent); - + if (isset($fullName)) { + $whatsappContent = str_replace("{USER_NAME}", $fullName, $whatsappContent); + } + if (isset($schemename)) { + $whatsappContent = str_replace("{SCHEME_NAME}", $schemename, $whatsappContent); + } + if (isset($expirydate)) { + $whatsappContent = str_replace("{EXPIRY_DATE}", $expirydate, $whatsappContent); + } + if (isset($customerId)) { + $whatsappContent = str_replace("{RENEWAL_LINK}", base_url() . 'subscription_renewal/' . $customerId, $whatsappContent); + } # Step 8: Insertion on History Child for whatsapp $history_child_data = [ 'fkid' => $history_parent_id, 'customer_id' => $customerId, @@ -867,7 +889,7 @@ class Notifications extends BaseController $notification = new NotificationHelper(); if($single_campaign['mode'] == 'Email') { - $email_response = $notification->sendEmail(array('recipient_email' => $customer['email'],'subject' => "ttt ".$template['subject'],'template_name' => $template['template_name'],'description' => $notificationContent)); + $email_response = $notification->sendEmail(array('recipient_email' => $customer['email'],'subject' => $template['subject'],'template_name' => $template['template_name'],'description' => $notificationContent)); $mail_log = isset($email_response['success']) ? 'Email sent successfully' : 'Failed to send email'; $receiving_status = isset($email_response['success']) ? 1 : 0; $this->logger->error("Auto Scheduled Email CID = ".$customer['customer_id']." ".$mail_log); diff --git a/app/Models/NotificationModel.php b/app/Models/NotificationModel.php index a2bc4634..359307ec 100755 --- a/app/Models/NotificationModel.php +++ b/app/Models/NotificationModel.php @@ -162,7 +162,7 @@ public function customerGroupQueryExecution($queries){ { $db = \Config\Database::connect(); - $query = "SELECT * FROM customer_groups WHERE group_name = 'EXPIRYDATE'"; + $query = "SELECT * FROM customer_groups WHERE group_name = 'EXPIRYDATE' AND isactive = 1"; $result = $db->query($query)->getResultArray(); diff --git a/app/Views/dashboard.php b/app/Views/dashboard.php index f235620a..d447447d 100755 --- a/app/Views/dashboard.php +++ b/app/Views/dashboard.php @@ -147,7 +147,9 @@ "; // print_r($expiring_membership); + // echo ""; if(!empty($expiring_membership)): foreach ($expiring_membership as $e) : $daysincount = (int)$e['countdays']; @@ -163,11 +165,23 @@
= $startDate && $startDateTime <= $endDate) { + echo $startDateTime ; + } + } ?>