FIX_in getExpCustomerDetail

This commit is contained in:
VE10-Sanjeev 2024-11-07 06:53:40 +00:00
parent 5219d10f5c
commit c5d43763b8
3 changed files with 50 additions and 14 deletions

View File

@ -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." <br>";
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);

View File

@ -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();

View File

@ -147,7 +147,9 @@
</thead>
<tbody>
<?php $tempinx = 0;
// echo "<pre>";
// print_r($expiring_membership);
// echo "</pre>";
if(!empty($expiring_membership)):
foreach ($expiring_membership as $e) :
$daysincount = (int)$e['countdays'];
@ -163,11 +165,23 @@
<td><span class="badge badge-success badge-pill"><?= $daysincountstring; ?></span> <span class="font-13"><br><?= $e['to_subscription_date_format']; ?></span></td>
<td>
<?php
$startDate = date('d/m/Y', strtotime($e['from_subscription']));
$endDate = date('d/m/Y', strtotime($e['to_subscription']));
$notifications = $e['notifications'];
$lastNotification = end($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 ? $lastStartDateTime : '';
echo ($startDateTime) ? date('d/m/Y', strtotime($startDateTime)) : '';
$startDateTime = $lastStartDateTime ? date('d/m/Y', strtotime($lastStartDateTime)) : '';
if($lastNotification['receiving_status']){
if ($startDateTime >= $startDate && $startDateTime <= $endDate) {
echo $startDateTime ;
}
}
?>
<?php
/*