expriy notify fixes : ps

This commit is contained in:
VE10-Sanjeev 2024-01-08 18:14:10 +05:30
parent 33b2af9322
commit 714fc37a57

View File

@ -454,7 +454,7 @@ class Notifications extends BaseController
# Step 1: add the days to retrive the data//
$providedDate = date('Y-m-d');
$newDate = date('Y-m-d', strtotime($providedDate . ' + ' . $window_time . ' days'));
$this->logger->info('EXPIRYDATE T-Date = '.$providedDate.', Given ' .$window_time.' Day, Calacuated Date based on Given days = '.$newDate);
$this->logger->info('EXPIRYDATE T-Date = '.$providedDate.', Given ' .$window_time.' Day, Calacuated Date based on Given day count = '.$newDate);
# Step 2 :Get the customer detail//
$NotificationModel = new NotificationModel();
@ -497,7 +497,7 @@ class Notifications extends BaseController
# EXPIRAY_NOTIFY_TEMPLATE_EMAIL
$emailTemplateName = $NotificationModel->getTempName(EXPIRAY_NOTIFY_TEMPLATE_EMAIL);
if (!empty($emailTemplateName)) {
if (count($emailTemplateName) && !empty($emailTemplateName)) {
$campaign_id = 1;
# Insertion on History Email Means Campaign ID 1 Hardcoded
$history_parents_data = ['campaign_id' => $campaign_id,'status' => 0];
@ -510,7 +510,7 @@ class Notifications extends BaseController
$emailContent = str_replace("{EXPIRY_DATE}", $expirydate, $emailContent);
$emailData = [
'template_name' => '',
'template_name' => 'EXPIRAY_NOTIFY_TEMPLATE_EMAIL',
'recipient_email' => $row['email'],
'subject' => 'Your Subscription Expiry Notification',
'description' => $emailContent,
@ -530,16 +530,28 @@ class Notifications extends BaseController
if (isset($emailResult['success'])) {
$history_msg = 'Email sent successfully';
$receiving_status = 1 ;
$history_child_updatedata = ['receiving_status'=>1,'result'=>$history_msg];
$history_child_where = ['fkid' => $history_parent_id,'id' => (int)$history_child_id];
$history_child_statement = $NotificationModel->update_notification_history_child($history_child_updatedata,$history_child_where);
$this->logger->info($history_child_statement);
$history_parent_statement = $NotificationModel->update_notification_history_parent_status(['status' => 1],$history_parent_id,$campaign_id);
$this->logger->info($history_parent_statement);
echo $history_msg;
} else {
$history_msg = (strtolower(gettype($emailResult)) == "string" ? $emailResult : json_encode($emailResult)) ;
$receiving_status = 0 ;
$history_child_updatedata = ['receiving_status'=>0,'result'=>$history_msg];
$history_child_where = ['fkid' => $history_parent_id,'id' => (int)$history_child_id];
$history_child_statement = $NotificationModel->update_notification_history_child($history_child_updatedata,$history_child_where);
$this->logger->info($history_child_statement);
$history_parent_statement = $NotificationModel->update_notification_history_parent_status(['status' => 1],$history_parent_id,$campaign_id);
$this->logger->info($history_parent_statement);
echo 'Failed to send email';
}
} else {
$history_msg = 'There is no email template found by the name of EXPIRAY_NOTIFY_TEMPLATE_EMAIL';
$receiving_status = 0 ;
// $receiving_status = 0 ;
$this->logger->info($history_msg);
continue;
}
@ -547,10 +559,19 @@ class Notifications extends BaseController
# EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP
$whatsappTemplateName = $NotificationModel->getTempName(EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP);
if (!empty($whatsappTemplateName)) {
if (count($whatsappTemplateName) && !empty($whatsappTemplateName)) {
$campaign_id = 2;
$history_parents_data = ['campaign_id' => $campaign_id,'status' => 0];
$history_parent_id = $NotificationModel->save_notification_history_parents($history_parents_data);
if (empty($userMobileNumber)) {
$history_msg = 'There is no subscriber mobile number';
$history_child_updatedata = ['receiving_status'=>0,'result'=>$history_msg];
$history_child_where = ['fkid' => $history_parent_id,'id' => (int)$history_child_id];
$history_child_statement = $NotificationModel->update_notification_history_child($history_child_updatedata,$history_child_where);
$this->logger->info($history_child_statement);
$history_parent_statement = $NotificationModel->update_notification_history_parent_status(['status' => 1],$history_parent_id,$campaign_id);
$this->logger->info($history_parent_statement);
$this->logger->info($history_msg);
continue;
}
@ -586,25 +607,23 @@ class Notifications extends BaseController
$whatsapp_result = $notification->sendWhatsAppMessage($url, "POST", $params);
$receiving_status = $whatsapp_result['receiving_status'];
$history_msg = strtolower(gettype($whatsapp_result)) == "string" ? $whatsapp_result : json_encode($whatsapp_result['reponse']);
$history_child_updatedata = ['receiving_status'=>$receiving_status,'result'=>$history_msg];
$history_child_where = ['fkid' => $history_parent_id,'id' => (int)$history_child_id];
$history_child_statement = $NotificationModel->update_notification_history_child($history_child_updatedata,$history_child_where);
$this->logger->info($history_child_statement);
$history_parent_statement = $NotificationModel->update_notification_history_parent_status(['status' => 1],$history_parent_id,$campaign_id);
$this->logger->info($history_parent_statement);
$this->logger->info("EXPIRAY NOTIFY TEMPLATE WHATSAPP Reponse = " . $history_msg);
} else {
$receiving_status = 0;
// $receiving_status = 0;
$history_msg = 'There is no Whatsapp template found by the name of EXPIRAY NOTIFY TEMPLATE WHATSAPP ';
$this->logger->info($history_msg);
continue;
}
# EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP Closed
$history_child_where = ['fkid' => $history_parent_id,'id' => (int)$history_child_id];
$history_child_updatedata = ['receiving_status'=>$receiving_status,'result'=>$history_msg];
$history_child_statement = $NotificationModel->update_notification_history_child($history_child_updatedata,$history_child_where);
$this->logger->info($history_child_statement);
$history_parent_statement = $NotificationModel->update_notification_history_parent_status(['status' => 1],$history_parent_id,$campaign_id);
$this->logger->info($history_parent_statement);
}
# Loop Closed
}
# getExpCustomerDetail fns Closed