diff --git a/app/Controllers/Notifications.php b/app/Controllers/Notifications.php
index b2502707..15e99906 100755
--- a/app/Controllers/Notifications.php
+++ b/app/Controllers/Notifications.php
@@ -482,8 +482,8 @@ class Notifications extends BaseController
return;
}
$emailTemplateName = $NotificationModel->getTempName(EXPIRAY_NOTIFY_TEMPLATE_EMAIL);
-
- foreach ($queryResult as $row) {
+ echo "Started.
Dated = ".$newDate."
There are ".count($queryResult)." persons
";
+ foreach ($queryResult as $inx => $row) {
$userFirstName = $row['first_name'];
$userLastName = $row['last_name'];
$fullName = $userFirstName . ' ' . $userLastName;
@@ -538,7 +538,7 @@ class Notifications extends BaseController
$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 ($inx+1).") ".$history_msg."
";
} else {
$history_msg = (strtolower(gettype($emailResult)) == "string" ? $emailResult : json_encode($emailResult)) ;
$history_child_updatedata = ['receiving_status'=>0,'result'=>$history_msg];
@@ -548,19 +548,21 @@ class Notifications extends BaseController
$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 ($inx+1).") Failed to send email
";
}
} else {
$history_msg = 'There is no email template found by the name of EXPIRAY_NOTIFY_TEMPLATE_EMAIL';
// $receiving_status = 0 ;
$this->logger->info($history_msg);
+ echo $history_msg."
";
continue;
}
# EXPIRAY_NOTIFY_TEMPLATE_EMAIL Closed
# EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP
$whatsappTemplateName = $NotificationModel->getTempName(EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP);
- if (count($whatsappTemplateName) && !empty($whatsappTemplateName)) {
+ // print_r($whatsappTemplateName);die;
+ if ((count($whatsappTemplateName) > 0) && !empty($whatsappTemplateName)) {
$campaign_id = 2; // hardcoded because static Template.
$history_parents_data = ['campaign_id' => $campaign_id,'status' => 0];
$history_parent_id = $NotificationModel->save_notification_history_parents($history_parents_data);
@@ -574,6 +576,7 @@ class Notifications extends BaseController
$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);
+ echo ($inx+1).") ".$history_msg."
";
continue;
}
# Insertion on History Whatsapp Means Campaign ID 2 Hardcoded
@@ -616,15 +619,34 @@ class Notifications extends BaseController
$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);
+
+ if(strtolower(gettype($whatsapp_result)) == "string"){
+ echo ($inx+1).") ".$whatsapp_result."
";
+ }
+ else{
+ $result = json_encode($whatsapp_result['reponse']);
+ $decodedResult = json_decode($result, true);
+ if ($decodedResult && isset($decodedResult['message']['key']['remoteJid'])) {
+ $remoteJid = $decodedResult['message']['key']['remoteJid'];
+ $this->logger->info("EXPIRAY NOTIFY TEMPLATE WHATSAPP Remote Jid = " . $remoteJid);
+ echo ($inx+1).") Whatsapp sent successfully
";
+ } else {
+ // echo "Failed to extract remoteJid";
+ $this->logger->info("EXPIRAY NOTIFY TEMPLATE WHATSAPP Failed to extract remoteJid ");
+ echo ($inx+1).") Failed to send Whatsapp
";
+ }
+ }
} 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);
+ echo "There is no Whatsapp template
";
continue;
}
# EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP Closed
}
# Loop Closed
+ echo "Process Completed
";
}
# getExpCustomerDetail fns Closed