expriy notify fixes : ps
This commit is contained in:
parent
33b2af9322
commit
714fc37a57
@ -454,7 +454,7 @@ class Notifications extends BaseController
|
|||||||
# Step 1: add the days to retrive the data//
|
# Step 1: add the days to retrive the data//
|
||||||
$providedDate = date('Y-m-d');
|
$providedDate = date('Y-m-d');
|
||||||
$newDate = date('Y-m-d', strtotime($providedDate . ' + ' . $window_time . ' days'));
|
$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//
|
# Step 2 :Get the customer detail//
|
||||||
$NotificationModel = new NotificationModel();
|
$NotificationModel = new NotificationModel();
|
||||||
@ -497,7 +497,7 @@ class Notifications extends BaseController
|
|||||||
|
|
||||||
# EXPIRAY_NOTIFY_TEMPLATE_EMAIL
|
# EXPIRAY_NOTIFY_TEMPLATE_EMAIL
|
||||||
$emailTemplateName = $NotificationModel->getTempName(EXPIRAY_NOTIFY_TEMPLATE_EMAIL);
|
$emailTemplateName = $NotificationModel->getTempName(EXPIRAY_NOTIFY_TEMPLATE_EMAIL);
|
||||||
if (!empty($emailTemplateName)) {
|
if (count($emailTemplateName) && !empty($emailTemplateName)) {
|
||||||
$campaign_id = 1;
|
$campaign_id = 1;
|
||||||
# Insertion on History Email Means Campaign ID 1 Hardcoded
|
# Insertion on History Email Means Campaign ID 1 Hardcoded
|
||||||
$history_parents_data = ['campaign_id' => $campaign_id,'status' => 0];
|
$history_parents_data = ['campaign_id' => $campaign_id,'status' => 0];
|
||||||
@ -510,7 +510,7 @@ class Notifications extends BaseController
|
|||||||
$emailContent = str_replace("{EXPIRY_DATE}", $expirydate, $emailContent);
|
$emailContent = str_replace("{EXPIRY_DATE}", $expirydate, $emailContent);
|
||||||
|
|
||||||
$emailData = [
|
$emailData = [
|
||||||
'template_name' => '',
|
'template_name' => 'EXPIRAY_NOTIFY_TEMPLATE_EMAIL',
|
||||||
'recipient_email' => $row['email'],
|
'recipient_email' => $row['email'],
|
||||||
'subject' => 'Your Subscription Expiry Notification',
|
'subject' => 'Your Subscription Expiry Notification',
|
||||||
'description' => $emailContent,
|
'description' => $emailContent,
|
||||||
@ -530,16 +530,28 @@ class Notifications extends BaseController
|
|||||||
|
|
||||||
if (isset($emailResult['success'])) {
|
if (isset($emailResult['success'])) {
|
||||||
$history_msg = 'Email sent successfully';
|
$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;
|
echo $history_msg;
|
||||||
} else {
|
} else {
|
||||||
$history_msg = (strtolower(gettype($emailResult)) == "string" ? $emailResult : json_encode($emailResult)) ;
|
$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';
|
echo 'Failed to send email';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$history_msg = 'There is no email template found by the name of EXPIRAY_NOTIFY_TEMPLATE_EMAIL';
|
$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);
|
$this->logger->info($history_msg);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -547,10 +559,19 @@ class Notifications extends BaseController
|
|||||||
|
|
||||||
# EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP
|
# EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP
|
||||||
$whatsappTemplateName = $NotificationModel->getTempName(EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP);
|
$whatsappTemplateName = $NotificationModel->getTempName(EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP);
|
||||||
if (!empty($whatsappTemplateName)) {
|
if (count($whatsappTemplateName) && !empty($whatsappTemplateName)) {
|
||||||
$campaign_id = 2;
|
$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)) {
|
if (empty($userMobileNumber)) {
|
||||||
$history_msg = 'There is no subscriber mobile number';
|
$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);
|
$this->logger->info($history_msg);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -586,25 +607,23 @@ class Notifications extends BaseController
|
|||||||
$whatsapp_result = $notification->sendWhatsAppMessage($url, "POST", $params);
|
$whatsapp_result = $notification->sendWhatsAppMessage($url, "POST", $params);
|
||||||
$receiving_status = $whatsapp_result['receiving_status'];
|
$receiving_status = $whatsapp_result['receiving_status'];
|
||||||
$history_msg = strtolower(gettype($whatsapp_result)) == "string" ? $whatsapp_result : json_encode($whatsapp_result['reponse']);
|
$history_msg = strtolower(gettype($whatsapp_result)) == "string" ? $whatsapp_result : json_encode($whatsapp_result['reponse']);
|
||||||
$this->logger->info("EXPIRAY NOTIFY TEMPLATE WHATSAPP Reponse = " . $history_msg);
|
|
||||||
} else {
|
|
||||||
$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_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);
|
$history_child_statement = $NotificationModel->update_notification_history_child($history_child_updatedata,$history_child_where);
|
||||||
$this->logger->info($history_child_statement);
|
$this->logger->info($history_child_statement);
|
||||||
|
|
||||||
$history_parent_statement = $NotificationModel->update_notification_history_parent_status(['status' => 1],$history_parent_id,$campaign_id);
|
$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_parent_statement);
|
||||||
|
$this->logger->info("EXPIRAY NOTIFY TEMPLATE WHATSAPP Reponse = " . $history_msg);
|
||||||
|
} else {
|
||||||
|
// $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
|
||||||
}
|
}
|
||||||
# Loop Closed
|
# Loop Closed
|
||||||
|
|
||||||
}
|
}
|
||||||
# getExpCustomerDetail fns Closed
|
# getExpCustomerDetail fns Closed
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user