FIX_Notification
This commit is contained in:
parent
c73b186e71
commit
c0010f229b
24
.env
24
.env
@ -147,18 +147,32 @@ APP_TIMEZONE = 'Asia/Kolkata'
|
|||||||
# Whatsapp Access Token And Instance ID
|
# Whatsapp Access Token And Instance ID
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
# for Live Don't delete it
|
# for Live Don't delete it
|
||||||
WAAI_TOKEN = '6582950cb468b'
|
# 1st Account
|
||||||
WAAI_INSTANCE = '6582F04394D59'
|
# WAAI_TOKEN = '6582950cb468b'
|
||||||
|
# WAAI_INSTANCE = '6582F04394D59'
|
||||||
|
# 2nd Account
|
||||||
|
# WAAI_TOKEN = '6568739969f28'
|
||||||
|
# WAAI_INSTANCE = '656876690A9FD'
|
||||||
|
|
||||||
# Dummy Account by sanjeev created on 14th dec Testing purpose office mail ID (user name - Venba V1 - Krish12345)
|
|
||||||
|
# for Testing Purpose
|
||||||
|
# 4th Account - Dummy Account by sanjeev created on 10th april 24 Testing purpose
|
||||||
|
# Dummy Office Mail ID - venba.it.chennai@venbainfotech.com
|
||||||
|
# (UN - venba.it.chennai PWD - venba.it.chennai)
|
||||||
|
WAAI_INSTANCE = '661621B29BDEE'
|
||||||
|
WAAI_TOKEN = '66162101e2f1d'
|
||||||
|
|
||||||
|
# 3rd Account - Dummy Account by sanjeev created on 14th dec Testing purpose
|
||||||
|
# Office Mail ID - sanjeev.p@venbainfotech.com
|
||||||
|
# (UN - Venba V1 PWD - Krish12345)
|
||||||
# WAAI_TOKEN = '657af9bf8cad1'
|
# WAAI_TOKEN = '657af9bf8cad1'
|
||||||
# WAAI_INSTANCE = '657AFA5A01B21'
|
# WAAI_INSTANCE = '657AFA5A01B21'
|
||||||
|
|
||||||
# for Test by sanjeev already created
|
# 2nd Account - Dummy Account by sanjeev
|
||||||
# WAAI_TOKEN = '65685e954bcf6'
|
# WAAI_TOKEN = '65685e954bcf6'
|
||||||
# WAAI_INSTANCE = '656863C54F90C'
|
# WAAI_INSTANCE = '656863C54F90C'
|
||||||
|
|
||||||
# for Old Test by krishanan sir
|
# 1st Account - Dummy Account by krishanan sir
|
||||||
# WAAI_TOKEN = '652548474f4e4'
|
# WAAI_TOKEN = '652548474f4e4'
|
||||||
# WAAI_INSTANCE = '65254894E4A88'
|
# WAAI_INSTANCE = '65254894E4A88'
|
||||||
|
|
||||||
|
|||||||
@ -12,6 +12,7 @@ class Notifications extends BaseController
|
|||||||
# Custom Notification
|
# Custom Notification
|
||||||
################################################################
|
################################################################
|
||||||
public function custom_notifications(){
|
public function custom_notifications(){
|
||||||
|
$data['page_name'] = 'Custom Notifications';
|
||||||
if ($this->request->is('post')) {
|
if ($this->request->is('post')) {
|
||||||
session()->setFlashdata('reset', true);
|
session()->setFlashdata('reset', true);
|
||||||
$records = $this->request->getVar();
|
$records = $this->request->getVar();
|
||||||
@ -42,7 +43,7 @@ class Notifications extends BaseController
|
|||||||
'message' => $records['description'],
|
'message' => $records['description'],
|
||||||
'result'=>strtolower(gettype($history_msg)) == "string" ? $history_msg : json_encode($history_msg)];
|
'result'=>strtolower(gettype($history_msg)) == "string" ? $history_msg : json_encode($history_msg)];
|
||||||
$history_child_id = $NotificationModel->save_notification_history_child($history_child_data);
|
$history_child_id = $NotificationModel->save_notification_history_child($history_child_data);
|
||||||
$this->logger->info('Custom Notifications Email : historychildid = '.$history_child_id);
|
$this->logger->error('Custom Notifications Email : historychildid = '.$history_child_id);
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
$records = $this->request->getVar();
|
$records = $this->request->getVar();
|
||||||
@ -52,133 +53,173 @@ class Notifications extends BaseController
|
|||||||
$receiving_status = 0;
|
$receiving_status = 0;
|
||||||
$doc_path = APPPATH . '../public/uploads/';
|
$doc_path = APPPATH . '../public/uploads/';
|
||||||
$doc_name = '';
|
$doc_name = '';
|
||||||
$this->logger->info("Whatsapp : sending message instance id = " . $_ENV['WAAI_INSTANCE'] . " - " . $_ENV['WAAI_TOKEN']);
|
$errorMessages = [];
|
||||||
|
$this->logger->error("Whatsapp : sending message instance id = " . $_ENV['WAAI_INSTANCE'] . " - " . $_ENV['WAAI_TOKEN']);
|
||||||
if($records['mobile'] != ""){
|
if($records['mobile'] != ""){
|
||||||
$string = $records['mobile'];
|
$string = $records['mobile'];
|
||||||
$mobile_no_arr = explode(',', $string);
|
$mobile_no_arr = explode(',', $string);
|
||||||
$total_number_count = count($mobile_no_arr);
|
$total_number_count = count($mobile_no_arr);
|
||||||
$sended_number_count = 0;
|
$sended_number_count = 0;
|
||||||
$not_sended_number_count = 0;
|
$not_sended_number_count = 0;
|
||||||
if ($records['type'] == 'document') {
|
// Step 1 Categories Check
|
||||||
$doc_name = $doc_details->getName();
|
|
||||||
if($doc_name !== '' && $doc_details->isValid()) {
|
|
||||||
$doc_details->move($doc_path, $doc_name);
|
|
||||||
$this->logger->info("Name After Upload".$doc_name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$NotificationModel = new NotificationModel();
|
|
||||||
$history_parents_data = ['campaign_id' => 0,'status' => 0];
|
|
||||||
$history_parent_id = $NotificationModel->save_notification_history_parents($history_parents_data);
|
|
||||||
// print_r($mobile_no_arr);
|
|
||||||
if(!empty($mobile_no_arr)){
|
|
||||||
try {
|
|
||||||
foreach ($mobile_no_arr as $mobile) {
|
|
||||||
// echo "----$mobile";
|
|
||||||
if (trim(strlen($mobile)) == 10) {
|
|
||||||
if (ctype_digit($mobile)) {
|
|
||||||
// ------------ Step 1
|
|
||||||
if ($records['categories'] == 'SEND_WAAI_GROUP_URL') {
|
if ($records['categories'] == 'SEND_WAAI_GROUP_URL') {
|
||||||
if ($records['group_id'] != "") {
|
if ($records['group_id'] != "") {
|
||||||
$params->group_id = $records['group_id'];
|
$params->group_id = $records['group_id'];
|
||||||
} else {
|
} else {
|
||||||
throw new \Exception("Group Id Missing Please Try again..");
|
session()->setFlashdata('error', 'Group Id Missing Please Try again..');
|
||||||
|
$this->render_page('notifications_form', $data);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}else if ($records['categories'] == 'SEND_WAAI_URL') {
|
}else if ($records['categories'] == 'SEND_WAAI_URL') {
|
||||||
if ($records['mobile'] != "") {
|
if ($records['mobile'] == "") {
|
||||||
$params->number = (int)'91' . $mobile;
|
session()->setFlashdata('error', 'Mobile Number Missing Please Try again..');
|
||||||
|
$this->render_page('notifications_form', $data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
session()->setFlashdata('error', 'Please Choose your Category..');
|
||||||
|
$this->render_page('notifications_form', $data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
// Step 2 Media Check, Document Also Convert into Media Here.
|
||||||
throw new \Exception("Mobile Number Missing Please Try again..");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new \Exception("Please Choose your Category");
|
|
||||||
}
|
|
||||||
// echo "***".$params->number;
|
|
||||||
//---------Step 2
|
|
||||||
if ($records['type'] == 'media') {
|
if ($records['type'] == 'media') {
|
||||||
if ($records['media_url'] != "") {
|
if ($records['media_url'] != "") {
|
||||||
$params->media_url = $records['media_url'];
|
$params->media_url = $records['media_url'];
|
||||||
$params->type = "media";
|
$params->type = "media";
|
||||||
} else {
|
} else {
|
||||||
throw new \Exception("Media Url Missing Please Try again..");
|
session()->setFlashdata('error', 'Media Url Missing Please Try again..');
|
||||||
|
$this->render_page('notifications_form', $data);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}else if ($records['type'] == 'document') {
|
}else if ($records['type'] == 'document') {
|
||||||
|
if (isset($records['media_doc'])) {
|
||||||
|
if ($doc_details->isValid() && $doc_details->getClientMimeType() === 'image/jpeg') {
|
||||||
$doc_name = $doc_details->getName();
|
$doc_name = $doc_details->getName();
|
||||||
if($doc_name == ''){
|
if ($doc_name !== '') {
|
||||||
$this->logger->error("Err on upload name not Founded ".$records['media_doc']);
|
$doc_details->move($doc_path, $doc_name);
|
||||||
throw new \Exception("Media Document Missing Please Try again..");
|
|
||||||
}else{
|
|
||||||
$params->media_url = base_url().'public/uploads/'.$doc_name;
|
$params->media_url = base_url().'public/uploads/'.$doc_name;
|
||||||
$params->type = "media";
|
$params->type = "media";
|
||||||
|
$this->logger->error("Name After Upload: " . $doc_name);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$this->logger->error("Err on upload name not Founded ".$records['media_doc']);
|
||||||
|
session()->setFlashdata('error', 'Media Document Missing Please Try again..');
|
||||||
|
$this->render_page('notifications_form', $data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
session()->setFlashdata('error', 'Please upload a JPEG image.');
|
||||||
|
$this->render_page('notifications_form', $data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
session()->setFlashdata('error', 'Please upload a JPEG image.');
|
||||||
|
$this->render_page('notifications_form', $data);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$params->type = "text" ;
|
$params->type = "text" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$NotificationModel = new NotificationModel();
|
||||||
|
$history_parents_data = ['campaign_id' => 0,'status' => 0,'field_value' =>$records['mobile']];
|
||||||
|
$history_parent_id = $NotificationModel->save_notification_history_parents($history_parents_data);
|
||||||
|
// print_r($mobile_no_arr);
|
||||||
|
if(!empty($mobile_no_arr)){
|
||||||
|
foreach ($mobile_no_arr as $mobile) {
|
||||||
|
// try {
|
||||||
|
$exceptionOccurred = false;
|
||||||
|
// echo "----$mobile";
|
||||||
|
if (trim(strlen($mobile)) == 10) {
|
||||||
|
if (ctype_digit($mobile)) {
|
||||||
|
if ($mobile != "") {
|
||||||
|
$params->number = (int)'91' . $mobile;
|
||||||
$url = constant($records['categories']);
|
$url = constant($records['categories']);
|
||||||
$params->instance_id = $_ENV['WAAI_INSTANCE'];
|
$params->instance_id = $_ENV['WAAI_INSTANCE'];
|
||||||
$params->access_token = $_ENV['WAAI_TOKEN'];
|
$params->access_token = $_ENV['WAAI_TOKEN'];
|
||||||
$params->message = strip_tags(ltrim($records['description']));
|
$params->message = strip_tags(ltrim($records['description']));
|
||||||
$this->logger->info("Whatsapp : sending message request = " . json_encode($params));
|
$this->logger->error("Whatsapp : Request Type ==> Mobile Number = ".$mobile." - " . gettype($params));
|
||||||
$this->logger->info("Whatsapp : sending message request type b4 = " . gettype($params));
|
|
||||||
|
|
||||||
helper('notification');
|
helper('notification');
|
||||||
$notification = new NotificationHelper();
|
$notification = new NotificationHelper();
|
||||||
$success = $notification->sendWhatsAppMessage($url, "POST", $params);
|
$success = $notification->sendWhatsAppMessage($url, "POST", $params);
|
||||||
// echo "<pre>";print_r($success);echo "</pre>";
|
// echo "<pre>";print_r($success);echo "</pre>";
|
||||||
$receiving_status = $success['receiving_status'];
|
$receiving_status = $success['receiving_status'];
|
||||||
$parents_status = $success['receiving_status'];
|
$parents_status = $success['receiving_status'];
|
||||||
$this->logger->info("Whatsapp : Reponse ==> Mobile Number = ".$mobile." Message = ". json_encode($success['reponse']));
|
$this->logger->error("Whatsapp : Reponse ==> Mobile Number = ".$mobile." Waai Reponse = ". json_encode($success['reponse']));
|
||||||
$history_msg = strtolower(gettype($success)) == "string" ? $success : json_encode($success['reponse']);
|
$history_msg = strtolower(gettype($success)) == "string" ? $success : json_encode($success['reponse']);
|
||||||
// $tag = (int)$receiving_status === 1 ? 'success' : 'error' ;
|
// $tag = (int)$receiving_status === 1 ? 'success' : 'error' ;
|
||||||
// session()->setFlashdata($tag, 'Message : ' . $success['message']);
|
// session()->setFlashdata($tag, 'Message : ' . $success['message']);
|
||||||
$this->logger->info("Whatsapp : Reponse = " . $success['message']);
|
|
||||||
(int)$receiving_status === 1 ? $sended_number_count++ : $not_sended_number_count++;
|
(int)$receiving_status === 1 ? $sended_number_count++ : $not_sended_number_count++;
|
||||||
}elseif (ctype_alpha($mobile)) {
|
|
||||||
$history_msg = "Mobile Number = ".$mobile." is a character.";
|
|
||||||
$this->logger->info("Whatsapp : Reponse ==> ".$history_msg);
|
|
||||||
$not_sended_number_count++;
|
|
||||||
throw new \Exception($history_msg);
|
|
||||||
} else {
|
} else {
|
||||||
$history_msg = "Mobile Number = ".$mobile." is a combination of characters and numbers.";
|
$receiving_status = 0;
|
||||||
$this->logger->info("Whatsapp : Reponse ==> ".$history_msg);
|
$parents_status = 0;
|
||||||
|
$history_msg = "Mobile Number = ".$mobile." is invalid.";
|
||||||
|
$this->logger->error("Whatsapp : Reponse ==> ".$history_msg);
|
||||||
$not_sended_number_count++;
|
$not_sended_number_count++;
|
||||||
throw new \Exception($history_msg);
|
$errorMessages[] = $history_msg;
|
||||||
|
}
|
||||||
|
}elseif (ctype_alpha($mobile)) {
|
||||||
|
$receiving_status = 0;
|
||||||
|
$parents_status = 0;
|
||||||
|
$history_msg = "Mobile Number = ".$mobile." is a character.";
|
||||||
|
$this->logger->error("Whatsapp : Reponse ==> ".$history_msg);
|
||||||
|
$not_sended_number_count++;
|
||||||
|
$errorMessages[] = $history_msg;
|
||||||
|
|
||||||
|
}else {
|
||||||
|
$receiving_status = 0;
|
||||||
|
$parents_status = 0;
|
||||||
|
$history_msg = "Mobile Number = ".$mobile." is a combination of characters and numbers.";
|
||||||
|
$this->logger->error("Whatsapp : Reponse ==> ".$history_msg);
|
||||||
|
$not_sended_number_count++;
|
||||||
|
$errorMessages[] = $history_msg;
|
||||||
|
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
$history_msg = "Mobile Number = ".$mobile." does not have 10 digits.";
|
$history_msg = "Mobile Number = ".$mobile." does not have 10 digits.";
|
||||||
$this->logger->info("Whatsapp : Reponse ==> ".$history_msg);
|
$this->logger->error("Whatsapp : Reponse ==> ".$history_msg);
|
||||||
$not_sended_number_count++;
|
$not_sended_number_count++;
|
||||||
throw new \Exception($history_msg);
|
$errorMessages[] = $history_msg;
|
||||||
}
|
}
|
||||||
$NotificationModel = new NotificationModel();
|
|
||||||
$history_parent_statement = $NotificationModel->update_notification_history_parent_status(['status' => 1],$history_parent_id,0);
|
|
||||||
$this->logger->info($history_parent_statement);
|
|
||||||
$history_child_data = [ 'fkid' => $history_parent_id,
|
$history_child_data = [ 'fkid' => $history_parent_id,
|
||||||
'customer_id' => 0,
|
'customer_id' => 0,
|
||||||
'receiving_entity' => $mobile." (original : ".$records['mobile'].")",
|
'receiving_entity' => $mobile,
|
||||||
'receiving_status' => $receiving_status,
|
'receiving_status' => $receiving_status,
|
||||||
'message' => $records['description'],
|
'message' => $records['description'],
|
||||||
'result'=>$history_msg];
|
'result'=>$history_msg];
|
||||||
$history_child_id = $NotificationModel->save_notification_history_child($history_child_data);
|
$NotificationModel = new NotificationModel();
|
||||||
$this->logger->info('Custom Notifications Whatsapp : historychildid = '.$history_child_id);
|
$history_child_id = $NotificationModel->save_custom_notification_history_child($history_child_data);
|
||||||
|
$this->logger->error('Custom Notifications Whatsapp : historychildid = '.$history_child_id);
|
||||||
}
|
}
|
||||||
|
if (!empty($errorMessages)) {
|
||||||
|
$this->logger->error(implode("\n", $errorMessages));
|
||||||
|
session()->setFlashdata('error', implode('<br>', $errorMessages));
|
||||||
|
$errorMessages = [];
|
||||||
|
}
|
||||||
|
if($sended_number_count > 0){
|
||||||
|
$NotificationModel = new NotificationModel();
|
||||||
|
$history_parent_statement = $NotificationModel->update_notification_history_parent_status(['status' => 1],$history_parent_id,0);
|
||||||
|
$this->logger->error($history_parent_statement);
|
||||||
session()->setFlashdata("success","Message : Sent Success (". $sended_number_count." / ".$total_number_count." )");
|
session()->setFlashdata("success","Message : Sent Success (". $sended_number_count." / ".$total_number_count." )");
|
||||||
$this->logger->info("Whatsapp : Final ==> ".$sended_number_count." Sended out of ".$total_number_count." ( Not sended numbers count ".$not_sended_number_count." ) ");
|
$this->logger->error("Whatsapp : Final ==> ".$sended_number_count." Sended out of ".$total_number_count." ( Not sended numbers count ".$not_sended_number_count." ) ");
|
||||||
} catch (\Exception $e) {
|
|
||||||
$this->logger->error("Whatsapp : Exception Message = " . $e->getMessage() . "<br> File: " . $e->getFile() . "<br> Line: " . $e->getLine() . "<br>");
|
|
||||||
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
|
|
||||||
}
|
}
|
||||||
|
$this->render_page('notifications_form', $data);
|
||||||
|
return;
|
||||||
}else{
|
}else{
|
||||||
session()->setFlashdata('error', 'Message : Mobile Not Founded');
|
session()->setFlashdata('error', 'Message : Mobile Not Founded');
|
||||||
|
$this->logger->error('Message : Mobile Not Founded');
|
||||||
|
$this->render_page('notifications_form', $data);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
session()->setFlashdata('error', 'Message : Mobile Field Empty');
|
session()->setFlashdata('error', 'Message : Mobile Field Empty');
|
||||||
|
$this->logger->error('Message : Mobile Field Empty');
|
||||||
|
$this->render_page('notifications_form', $data);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$records = [];
|
|
||||||
$data['page_name'] = 'Custom Notifications';
|
|
||||||
$this->render_page('notifications_form', $data);
|
$this->render_page('notifications_form', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,7 +241,7 @@ class Notifications extends BaseController
|
|||||||
$business_name = "";
|
$business_name = "";
|
||||||
$to_subscription = "";
|
$to_subscription = "";
|
||||||
if (isset($details)) {
|
if (isset($details)) {
|
||||||
$this->logger->info("Notification : Duedate notification Request data type = " . gettype($details));
|
$this->logger->error("Notification : Duedate notification Request data type = " . gettype($details));
|
||||||
}
|
}
|
||||||
helper('notification');
|
helper('notification');
|
||||||
$notification = new NotificationHelper();
|
$notification = new NotificationHelper();
|
||||||
@ -239,13 +280,13 @@ class Notifications extends BaseController
|
|||||||
$params->message = $template;
|
$params->message = $template;
|
||||||
$params->instance_id = $_ENV['WAAI_INSTANCE'];
|
$params->instance_id = $_ENV['WAAI_INSTANCE'];
|
||||||
$params->access_token = $_ENV['WAAI_TOKEN'];
|
$params->access_token = $_ENV['WAAI_TOKEN'];
|
||||||
$this->logger->info("Notification : Duedate notification Email Request data = " . json_encode($records));
|
$this->logger->error("Notification : Duedate notification Email Request data = " . json_encode($records));
|
||||||
|
|
||||||
$email_result = $notification->sendEmail($records);
|
$email_result = $notification->sendEmail($records);
|
||||||
$this->logger->info("Notification : Duedate notification Email Response = " . json_encode($email_result));
|
$this->logger->error("Notification : Duedate notification Email Response = " . json_encode($email_result));
|
||||||
$this->logger->info("Notification : Duedate notification Whatsapp Request data = " . json_encode($params));
|
$this->logger->error("Notification : Duedate notification Whatsapp Request data = " . json_encode($params));
|
||||||
$whatsapp_result = $notification->sendWhatsAppMessage(SEND_WAAI_URL, "POST", $params);
|
$whatsapp_result = $notification->sendWhatsAppMessage(SEND_WAAI_URL, "POST", $params);
|
||||||
$this->logger->info("Notification : Duedate notification Whatsapp Response = " . json_encode($whatsapp_result));
|
$this->logger->error("Notification : Duedate notification Whatsapp Response = " . json_encode($whatsapp_result));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function template_creation()
|
public function template_creation()
|
||||||
@ -266,11 +307,11 @@ class Notifications extends BaseController
|
|||||||
$data['group_details'] = $this->get_group_details();
|
$data['group_details'] = $this->get_group_details();
|
||||||
$model = new NotificationModel();
|
$model = new NotificationModel();
|
||||||
if ($id === '0') {
|
if ($id === '0') {
|
||||||
$this->logger->info("Template Creation: In Add Page");
|
$this->logger->error("Template Creation: In Add Page");
|
||||||
$data['page_name'] = 'Add Template';
|
$data['page_name'] = 'Add Template';
|
||||||
$data['template_details'] = [];
|
$data['template_details'] = [];
|
||||||
} elseif ($id !== '0') {
|
} elseif ($id !== '0') {
|
||||||
$this->logger->info("Template Creation: In Edit Page ID =" . $id);
|
$this->logger->error("Template Creation: In Edit Page ID =" . $id);
|
||||||
$data['page_name'] = 'Edit Template';
|
$data['page_name'] = 'Edit Template';
|
||||||
$model->setTable('templates');
|
$model->setTable('templates');
|
||||||
$where = ['template_id' => (int)$id];
|
$where = ['template_id' => (int)$id];
|
||||||
@ -294,12 +335,12 @@ class Notifications extends BaseController
|
|||||||
$where = ['template_id' => (int)$id];
|
$where = ['template_id' => (int)$id];
|
||||||
$result = $model->where($where)->findAll();
|
$result = $model->where($where)->findAll();
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$this->logger->Info("Template: Going to Inactive ID = " . $id);
|
$this->logger->error("Template: Going to Inactive ID = " . $id);
|
||||||
$data = ['isactive' => 0, 'updated_by' => $session_uid, 'template_id' => (int)$id];
|
$data = ['isactive' => 0, 'updated_by' => $session_uid, 'template_id' => (int)$id];
|
||||||
$statement = $model->saveDetails($data, 'template_id', 'templates'); // just updating Inactive status only.
|
$statement = $model->saveDetails($data, 'template_id', 'templates'); // just updating Inactive status only.
|
||||||
if ($statement['success']) {
|
if ($statement['success']) {
|
||||||
session()->setFlashdata('success', $statement['success'] ? 'Deleted successfully.' : "");
|
session()->setFlashdata('success', $statement['success'] ? 'Deleted successfully.' : "");
|
||||||
$this->logger->info($statement['log']);
|
$this->logger->error($statement['log']);
|
||||||
} else if ($statement['error']) {
|
} else if ($statement['error']) {
|
||||||
session()->setFlashdata('error', $statement['error']);
|
session()->setFlashdata('error', $statement['error']);
|
||||||
$this->logger->error($statement['log']);
|
$this->logger->error($statement['log']);
|
||||||
@ -338,7 +379,7 @@ class Notifications extends BaseController
|
|||||||
|
|
||||||
public function template_creation_insert()
|
public function template_creation_insert()
|
||||||
{
|
{
|
||||||
$this->logger->info("Template: Inserting/Updating Details");
|
$this->logger->error("Template: Inserting/Updating Details");
|
||||||
try {
|
try {
|
||||||
## Declarions
|
## Declarions
|
||||||
helper('session');
|
helper('session');
|
||||||
@ -367,7 +408,7 @@ class Notifications extends BaseController
|
|||||||
$statement = $model->saveDetails($data, 'template_id', 'templates');
|
$statement = $model->saveDetails($data, 'template_id', 'templates');
|
||||||
if ($statement['success']) {
|
if ($statement['success']) {
|
||||||
session()->setFlashdata('success', $statement['success']);
|
session()->setFlashdata('success', $statement['success']);
|
||||||
$this->logger->info($statement['log']);
|
$this->logger->error($statement['log']);
|
||||||
} else if ($statement['error']) {
|
} else if ($statement['error']) {
|
||||||
session()->setFlashdata('error', $statement['error']);
|
session()->setFlashdata('error', $statement['error']);
|
||||||
$this->logger->error($statement['log']);
|
$this->logger->error($statement['log']);
|
||||||
@ -397,11 +438,11 @@ class Notifications extends BaseController
|
|||||||
$data['template_details'] = $this->get_template_details();
|
$data['template_details'] = $this->get_template_details();
|
||||||
$model = new NotificationModel();
|
$model = new NotificationModel();
|
||||||
if ($id === '0') {
|
if ($id === '0') {
|
||||||
$this->logger->info("Campaign Creation: In Add Page");
|
$this->logger->error("Campaign Creation: In Add Page");
|
||||||
$data['page_name'] = 'Add Campaign';
|
$data['page_name'] = 'Add Campaign';
|
||||||
$data['campaign_details'] = [];
|
$data['campaign_details'] = [];
|
||||||
} elseif ($id !== '0') {
|
} elseif ($id !== '0') {
|
||||||
$this->logger->info("Campaign Creation: In Edit Page ID =" . $id);
|
$this->logger->error("Campaign Creation: In Edit Page ID =" . $id);
|
||||||
$data['page_name'] = 'Edit Campaign';
|
$data['page_name'] = 'Edit Campaign';
|
||||||
$model->setTable('notification_campaign');
|
$model->setTable('notification_campaign');
|
||||||
$where = ['campaign_id' => (int)$id];
|
$where = ['campaign_id' => (int)$id];
|
||||||
@ -426,12 +467,12 @@ class Notifications extends BaseController
|
|||||||
$where = ['campaign_id' => (int)$id];
|
$where = ['campaign_id' => (int)$id];
|
||||||
$result = $model->where($where)->findAll();
|
$result = $model->where($where)->findAll();
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$this->logger->Info("Campaign: Going to Inactive ID = " . $id);
|
$this->logger->error("Campaign: Going to Inactive ID = " . $id);
|
||||||
$data = ['isactive' => 0, 'updated_by' => $session_uid, 'campaign_id' => (int)$id];
|
$data = ['isactive' => 0, 'updated_by' => $session_uid, 'campaign_id' => (int)$id];
|
||||||
$statement = $model->saveDetails($data, 'campaign_id', 'notification_campaign'); // just updating Inactive status only.
|
$statement = $model->saveDetails($data, 'campaign_id', 'notification_campaign'); // just updating Inactive status only.
|
||||||
if ($statement['success']) {
|
if ($statement['success']) {
|
||||||
session()->setFlashdata('success', $statement['success'] ? 'Deleted successfully.' : "");
|
session()->setFlashdata('success', $statement['success'] ? 'Deleted successfully.' : "");
|
||||||
$this->logger->info($statement['log']);
|
$this->logger->error($statement['log']);
|
||||||
} else if ($statement['error']) {
|
} else if ($statement['error']) {
|
||||||
session()->setFlashdata('error', $statement['error']);
|
session()->setFlashdata('error', $statement['error']);
|
||||||
$this->logger->error($statement['log']);
|
$this->logger->error($statement['log']);
|
||||||
@ -448,7 +489,7 @@ class Notifications extends BaseController
|
|||||||
|
|
||||||
public function campaign_creation_insert()
|
public function campaign_creation_insert()
|
||||||
{
|
{
|
||||||
$this->logger->info("Campaign: Inserting/Updating Details");
|
$this->logger->error("Campaign: Inserting/Updating Details");
|
||||||
try {
|
try {
|
||||||
## Declarions
|
## Declarions
|
||||||
helper('session');
|
helper('session');
|
||||||
@ -487,7 +528,7 @@ class Notifications extends BaseController
|
|||||||
}
|
}
|
||||||
if ($statement['success']) {
|
if ($statement['success']) {
|
||||||
session()->setFlashdata('success', $statement['success']);
|
session()->setFlashdata('success', $statement['success']);
|
||||||
$this->logger->info($statement['log']);
|
$this->logger->error($statement['log']);
|
||||||
} else if ($statement['error']) {
|
} else if ($statement['error']) {
|
||||||
session()->setFlashdata('error', $statement['error']);
|
session()->setFlashdata('error', $statement['error']);
|
||||||
$this->logger->error($statement['log']);
|
$this->logger->error($statement['log']);
|
||||||
@ -510,14 +551,14 @@ 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 day count = '.$newDate);
|
$this->logger->error('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();
|
||||||
$ExpCustomerDetail = $NotificationModel->getExpDate(); // Retrieve the stored query
|
$ExpCustomerDetail = $NotificationModel->getExpDate(); // Retrieve the stored query
|
||||||
|
|
||||||
if (empty($ExpCustomerDetail)) {
|
if (empty($ExpCustomerDetail)) {
|
||||||
$this->logger->info('No customer group found by the name of EXPIRYDATE');
|
$this->logger->error('No customer group found by the name of EXPIRYDATE');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -525,7 +566,7 @@ class Notifications extends BaseController
|
|||||||
$modifiedQuery = str_replace('WINDOW_TIME', $window_time, $ExpCustomerDetail);
|
$modifiedQuery = str_replace('WINDOW_TIME', $window_time, $ExpCustomerDetail);
|
||||||
// print_r($modifiedQuery);die;
|
// print_r($modifiedQuery);die;
|
||||||
if (empty($modifiedQuery)) {
|
if (empty($modifiedQuery)) {
|
||||||
$this->logger->info('There is no sub query');
|
$this->logger->error('There is no sub query');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$db = \Config\Database::connect();
|
$db = \Config\Database::connect();
|
||||||
@ -533,7 +574,7 @@ class Notifications extends BaseController
|
|||||||
|
|
||||||
$notification = new NotificationHelper();
|
$notification = new NotificationHelper();
|
||||||
if (empty($queryResult)) {
|
if (empty($queryResult)) {
|
||||||
$this->logger->info("There is no customer expiring on date:{$newDate}");
|
$this->logger->error("There is no customer expiring on date:{$newDate}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -549,7 +590,7 @@ class Notifications extends BaseController
|
|||||||
$expirydate = $row['to_subscription'];
|
$expirydate = $row['to_subscription'];
|
||||||
$customerId = $row['customer_id'];
|
$customerId = $row['customer_id'];
|
||||||
if (empty($fullName)) {
|
if (empty($fullName)) {
|
||||||
$this->logger->info('There is no subcription Name');
|
$this->logger->error('There is no subcription Name');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($status === 'Approved') {
|
if ($status === 'Approved') {
|
||||||
@ -584,40 +625,40 @@ class Notifications extends BaseController
|
|||||||
# Step 6:Send email using NotificationHelper
|
# Step 6:Send email using NotificationHelper
|
||||||
$emailResult = $notification->sendEmail($emailData);
|
$emailResult = $notification->sendEmail($emailData);
|
||||||
|
|
||||||
$this->logger->info("EXPIRAY NOTIFY TEMPLATE EMAIL Email CID = ".$customerId." ".json_encode($emailResult));
|
$this->logger->error("EXPIRAY NOTIFY TEMPLATE EMAIL Email CID = ".$customerId." ".json_encode($emailResult));
|
||||||
|
|
||||||
if (isset($emailResult['success'])) {
|
if (isset($emailResult['success'])) {
|
||||||
$history_msg = 'Email sent successfully';
|
$history_msg = 'Email sent successfully';
|
||||||
$history_child_updatedata = ['receiving_status'=>1,'result'=>$history_msg];
|
$history_child_updatedata = ['receiving_status'=>1,'result'=>$history_msg];
|
||||||
$history_child_where = ['fkid' => $history_parent_id,'id' => (int)$history_child_id];
|
$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->error($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->error($history_parent_statement);
|
||||||
echo ($inx+1).") ".$history_msg."<br>";
|
echo ($inx+1).") ".$history_msg."<br>";
|
||||||
} else {
|
} else {
|
||||||
$history_msg = (strtolower(gettype($emailResult)) == "string" ? $emailResult : json_encode($emailResult)) ;
|
$history_msg = (strtolower(gettype($emailResult)) == "string" ? $emailResult : json_encode($emailResult)) ;
|
||||||
$history_child_updatedata = ['receiving_status'=>0,'result'=>$history_msg];
|
$history_child_updatedata = ['receiving_status'=>0,'result'=>$history_msg];
|
||||||
$history_child_where = ['fkid' => $history_parent_id,'id' => (int)$history_child_id];
|
$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->error($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->error($history_parent_statement);
|
||||||
echo ($inx+1).") Failed to send email <br>";
|
echo ($inx+1).") Failed to send email <br>";
|
||||||
}
|
}
|
||||||
} 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->error($history_msg);
|
||||||
echo $history_msg."<br>";
|
echo $history_msg."<br>";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$this->logger->info("status is Draft");
|
$this->logger->error("status is Draft");
|
||||||
}
|
}
|
||||||
# EXPIRAY_NOTIFY_TEMPLATE_EMAIL Closed
|
# EXPIRAY_NOTIFY_TEMPLATE_EMAIL Closed
|
||||||
if ($status === 'Approved') {
|
if ($status === 'Approved') {
|
||||||
@ -633,11 +674,11 @@ class Notifications extends BaseController
|
|||||||
$history_child_updatedata = ['receiving_status'=>0,'result'=>$history_msg];
|
$history_child_updatedata = ['receiving_status'=>0,'result'=>$history_msg];
|
||||||
$history_child_where = ['fkid' => $history_parent_id,'id' => (int)$history_child_id];
|
$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->error($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->error($history_parent_statement);
|
||||||
$this->logger->info($history_msg);
|
$this->logger->error($history_msg);
|
||||||
echo ($inx+1).") ".$history_msg."<br>";
|
echo ($inx+1).") ".$history_msg."<br>";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -668,19 +709,19 @@ class Notifications extends BaseController
|
|||||||
$params->message = strip_tags(ltrim($whatsappContent));
|
$params->message = strip_tags(ltrim($whatsappContent));
|
||||||
$params->instance_id = $_ENV['WAAI_INSTANCE'];
|
$params->instance_id = $_ENV['WAAI_INSTANCE'];
|
||||||
$params->access_token = $_ENV['WAAI_TOKEN'];
|
$params->access_token = $_ENV['WAAI_TOKEN'];
|
||||||
$this->logger->info("EXPIRAY NOTIFY TEMPLATE WHATSAPP Request = " . json_encode($params));
|
$this->logger->error("EXPIRAY NOTIFY TEMPLATE WHATSAPP Request = " . json_encode($params));
|
||||||
$this->logger->info("EXPIRAY NOTIFY TEMPLATE WHATSAPP Request type b4 = " . gettype($params));
|
$this->logger->error("EXPIRAY NOTIFY TEMPLATE WHATSAPP Request type b4 = " . gettype($params));
|
||||||
$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']);
|
||||||
$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_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->error($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->error($history_parent_statement);
|
||||||
$this->logger->info("EXPIRAY NOTIFY TEMPLATE WHATSAPP Reponse = " . $history_msg);
|
$this->logger->error("EXPIRAY NOTIFY TEMPLATE WHATSAPP Reponse = " . $history_msg);
|
||||||
|
|
||||||
if(strtolower(gettype($whatsapp_result)) == "string"){
|
if(strtolower(gettype($whatsapp_result)) == "string"){
|
||||||
echo ($inx+1).") ".$whatsapp_result."<br>";
|
echo ($inx+1).") ".$whatsapp_result."<br>";
|
||||||
@ -690,18 +731,18 @@ class Notifications extends BaseController
|
|||||||
$decodedResult = json_decode($result, true);
|
$decodedResult = json_decode($result, true);
|
||||||
if ($decodedResult && isset($decodedResult['message']['key']['remoteJid'])) {
|
if ($decodedResult && isset($decodedResult['message']['key']['remoteJid'])) {
|
||||||
$remoteJid = $decodedResult['message']['key']['remoteJid'];
|
$remoteJid = $decodedResult['message']['key']['remoteJid'];
|
||||||
$this->logger->info("EXPIRAY NOTIFY TEMPLATE WHATSAPP Remote Jid = " . $remoteJid);
|
$this->logger->error("EXPIRAY NOTIFY TEMPLATE WHATSAPP Remote Jid = " . $remoteJid);
|
||||||
echo ($inx+1).") Whatsapp sent successfully <br>";
|
echo ($inx+1).") Whatsapp sent successfully <br>";
|
||||||
} else {
|
} else {
|
||||||
// echo "Failed to extract remoteJid";
|
// echo "Failed to extract remoteJid";
|
||||||
$this->logger->info("EXPIRAY NOTIFY TEMPLATE WHATSAPP Failed to extract remoteJid ");
|
$this->logger->error("EXPIRAY NOTIFY TEMPLATE WHATSAPP Failed to extract remoteJid ");
|
||||||
echo ($inx+1).") Failed to send Whatsapp <br>";
|
echo ($inx+1).") Failed to send Whatsapp <br>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// $receiving_status = 0;
|
// $receiving_status = 0;
|
||||||
$history_msg = 'There is no Whatsapp template found by the name of EXPIRAY NOTIFY TEMPLATE WHATSAPP ';
|
$history_msg = 'There is no Whatsapp template found by the name of EXPIRAY NOTIFY TEMPLATE WHATSAPP ';
|
||||||
$this->logger->info($history_msg);
|
$this->logger->error($history_msg);
|
||||||
echo "There is no Whatsapp template <br>";
|
echo "There is no Whatsapp template <br>";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -709,7 +750,7 @@ class Notifications extends BaseController
|
|||||||
# EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP Closed
|
# EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP Closed
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$this->logger->info("statsu is draft");
|
$this->logger->error("statsu is draft");
|
||||||
}
|
}
|
||||||
|
|
||||||
# Loop Closed
|
# Loop Closed
|
||||||
@ -723,15 +764,15 @@ class Notifications extends BaseController
|
|||||||
################################################################
|
################################################################
|
||||||
## notification campaign details
|
## notification campaign details
|
||||||
public function processScheduledNotifications(){
|
public function processScheduledNotifications(){
|
||||||
$this->logger->info("Auto Scheduled Notification Started");
|
$this->logger->error("Auto Scheduled Notification Started");
|
||||||
$model = new NotificationModel();
|
$model = new NotificationModel();
|
||||||
#step 1 get scheduled notification details
|
#step 1 get scheduled notification details
|
||||||
$notification_campaign_result = $this->getScheduledNotificationDetails();
|
$notification_campaign_result = $this->getScheduledNotificationDetails();
|
||||||
$this->logger->info("Auto Scheduled Campaign Details Count = ".count($notification_campaign_result));
|
$this->logger->error("Auto Scheduled Campaign Details Count = ".count($notification_campaign_result));
|
||||||
if(!count($notification_campaign_result))
|
if(!count($notification_campaign_result))
|
||||||
{
|
{
|
||||||
$this->logger->info("No Auto Scheduled Notification in DB,exiting...!");
|
$this->logger->error("No Auto Scheduled Notification in DB,exiting...!");
|
||||||
$this->logger->info("Auto Scheduled Notification Ends");
|
$this->logger->error("Auto Scheduled Notification Ends");
|
||||||
echo "No Scheduled Data Founded"."<br>";
|
echo "No Scheduled Data Founded"."<br>";
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
@ -744,7 +785,7 @@ class Notifications extends BaseController
|
|||||||
echo "Notification Campaign Name = ".$single_campaign['campaign_name']."<br>";
|
echo "Notification Campaign Name = ".$single_campaign['campaign_name']."<br>";
|
||||||
#step 2 get template details
|
#step 2 get template details
|
||||||
$template = $this->getTemplateDetails($single_campaign['template_id']);
|
$template = $this->getTemplateDetails($single_campaign['template_id']);
|
||||||
$this->logger->info("Auto Scheduled Template Details TID = ".$single_campaign['template_id']);
|
$this->logger->error("Auto Scheduled Template Details TID = ".$single_campaign['template_id']);
|
||||||
if(count($template))
|
if(count($template))
|
||||||
{
|
{
|
||||||
#step 2.1
|
#step 2.1
|
||||||
@ -772,7 +813,7 @@ class Notifications extends BaseController
|
|||||||
//check wheather if notification send to the current customer already
|
//check wheather if notification send to the current customer already
|
||||||
if(!in_array($customer['customer_id'],$sent_customer_details))
|
if(!in_array($customer['customer_id'],$sent_customer_details))
|
||||||
{
|
{
|
||||||
$this->logger->info("Auto Scheduled Customer CID = ".$customer['customer_id'].", CN = ".$customer['customer_name']);
|
$this->logger->error("Auto Scheduled Customer CID = ".$customer['customer_id'].", CN = ".$customer['customer_name']);
|
||||||
#step 5 send notification
|
#step 5 send notification
|
||||||
$notification = new NotificationHelper();
|
$notification = new NotificationHelper();
|
||||||
if($single_campaign['mode'] == 'Email')
|
if($single_campaign['mode'] == 'Email')
|
||||||
@ -780,12 +821,12 @@ class Notifications extends BaseController
|
|||||||
$email_response = $notification->sendEmail(array('recipient_email' => $customer['email'],'subject' => $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';
|
$mail_log = isset($email_response['success']) ? 'Email sent successfully' : 'Failed to send email';
|
||||||
$receiving_status = isset($email_response['success']) ? 1 : 0;
|
$receiving_status = isset($email_response['success']) ? 1 : 0;
|
||||||
$this->logger->info("Auto Scheduled Email CID = ".$customer['customer_id']." ".$mail_log);
|
$this->logger->error("Auto Scheduled Email CID = ".$customer['customer_id']." ".$mail_log);
|
||||||
|
|
||||||
$history_child_where = ['fkid' => $single_campaign['history_parent_id'],'id' => (int)$history_child_id];
|
$history_child_where = ['fkid' => $single_campaign['history_parent_id'],'id' => (int)$history_child_id];
|
||||||
$history_child_updatedata = ['receiving_status'=>$receiving_status, 'result'=>isset($email_response['success']) ? $mail_log : (strtolower(gettype($email_response)) == "string" ? $email_response : json_encode($email_response)) ];
|
$history_child_updatedata = ['receiving_status'=>$receiving_status, 'result'=>isset($email_response['success']) ? $mail_log : (strtolower(gettype($email_response)) == "string" ? $email_response : json_encode($email_response)) ];
|
||||||
$history_child_statement = $model->update_notification_history_child($history_child_updatedata,$history_child_where);
|
$history_child_statement = $model->update_notification_history_child($history_child_updatedata,$history_child_where);
|
||||||
$this->logger->info($history_child_statement);
|
$this->logger->error($history_child_statement);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -800,12 +841,12 @@ class Notifications extends BaseController
|
|||||||
$whatsapp_reponse = $notification->sendWhatsAppMessage($url, "POST", $params);
|
$whatsapp_reponse = $notification->sendWhatsAppMessage($url, "POST", $params);
|
||||||
$whatsapp_reponse_msg = strtolower(gettype($whatsapp_reponse)) == "string" ? $whatsapp_reponse : json_encode($whatsapp_reponse['reponse']);
|
$whatsapp_reponse_msg = strtolower(gettype($whatsapp_reponse)) == "string" ? $whatsapp_reponse : json_encode($whatsapp_reponse['reponse']);
|
||||||
// echo "Whatsapp Response = ".$whatsapp_reponse_msg."<br>";
|
// echo "Whatsapp Response = ".$whatsapp_reponse_msg."<br>";
|
||||||
$this->logger->info("Auto Scheduled Whatsapp CID = ".$customer['customer_id']." ".$whatsapp_reponse_msg);
|
$this->logger->error("Auto Scheduled Whatsapp CID = ".$customer['customer_id']." ".$whatsapp_reponse_msg);
|
||||||
$history_child_where = ['fkid' => $single_campaign['history_parent_id'],'id' => (int)$history_child_id];
|
$history_child_where = ['fkid' => $single_campaign['history_parent_id'],'id' => (int)$history_child_id];
|
||||||
|
|
||||||
$history_child_updatedata = ['receiving_status'=>$whatsapp_reponse['receiving_status'],'result'=>$whatsapp_reponse_msg];
|
$history_child_updatedata = ['receiving_status'=>$whatsapp_reponse['receiving_status'],'result'=>$whatsapp_reponse_msg];
|
||||||
$history_child_statement = $model->update_notification_history_child($history_child_updatedata,$history_child_where);
|
$history_child_statement = $model->update_notification_history_child($history_child_updatedata,$history_child_where);
|
||||||
$this->logger->info($history_child_statement);
|
$this->logger->error($history_child_statement);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -818,12 +859,12 @@ class Notifications extends BaseController
|
|||||||
#step 6 update campaign status to 1
|
#step 6 update campaign status to 1
|
||||||
$statement = $model->update_notification_campaign_status(['status' => 1],$single_campaign['campaign_id']);
|
$statement = $model->update_notification_campaign_status(['status' => 1],$single_campaign['campaign_id']);
|
||||||
echo "Final Campaign Status = ".$statement."<br>";
|
echo "Final Campaign Status = ".$statement."<br>";
|
||||||
$this->logger->info($statement);
|
$this->logger->error($statement);
|
||||||
|
|
||||||
#step 7 update history parent status to 1
|
#step 7 update history parent status to 1
|
||||||
$history_parent_statement = $model->update_notification_history_parent_status(['status' => 1],$single_campaign['history_parent_id'],$single_campaign['campaign_id']);
|
$history_parent_statement = $model->update_notification_history_parent_status(['status' => 1],$single_campaign['history_parent_id'],$single_campaign['campaign_id']);
|
||||||
echo "Final Acknowlegdement = ".$history_parent_statement."<br>";
|
echo "Final Acknowlegdement = ".$history_parent_statement."<br>";
|
||||||
$this->logger->info($history_parent_statement);
|
$this->logger->error($history_parent_statement);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -862,7 +903,7 @@ class Notifications extends BaseController
|
|||||||
function getCustomerDetails($group_ids)
|
function getCustomerDetails($group_ids)
|
||||||
{
|
{
|
||||||
$group_id_arr = unserialize($group_ids);
|
$group_id_arr = unserialize($group_ids);
|
||||||
$this->logger->info("Auto Scheduled Customer Group CGID = ".implode(", ", $group_id_arr));
|
$this->logger->error("Auto Scheduled Customer Group CGID = ".implode(", ", $group_id_arr));
|
||||||
$customer_details = [];
|
$customer_details = [];
|
||||||
if(count($group_id_arr))
|
if(count($group_id_arr))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -17,7 +17,7 @@ class NotificationHelper
|
|||||||
|
|
||||||
public function sendEmail($records)
|
public function sendEmail($records)
|
||||||
{
|
{
|
||||||
$this->logger->info('Helper : Email Request Data type = '.gettype($records));
|
$this->logger->error('Helper : Email Request Data type = '.gettype($records));
|
||||||
|
|
||||||
$cc = isset($records['carboncopy']) ? $records['carboncopy'] : '';
|
$cc = isset($records['carboncopy']) ? $records['carboncopy'] : '';
|
||||||
$bcc = isset($records['blindcarboncopy']) ? $records['blindcarboncopy'] : '';
|
$bcc = isset($records['blindcarboncopy']) ? $records['blindcarboncopy'] : '';
|
||||||
@ -28,26 +28,26 @@ class NotificationHelper
|
|||||||
throw new \Exception("Email and Subject are Must Please Try again..");
|
throw new \Exception("Email and Subject are Must Please Try again..");
|
||||||
}
|
}
|
||||||
$this->email->setTo($records['recipient_email']);
|
$this->email->setTo($records['recipient_email']);
|
||||||
$this->logger->info('Helper : Email recipient = '.$records['recipient_email']);
|
$this->logger->error('Helper : Email recipient = '.$records['recipient_email']);
|
||||||
$this->email->setFrom('web@vijayabharathambooks.com', isset($records['company'])?$records['company']:"VB");
|
$this->email->setFrom('web@vijayabharathambooks.com', isset($records['company'])?$records['company']:"VB");
|
||||||
$this->email->setSubject($records['subject']);
|
$this->email->setSubject($records['subject']);
|
||||||
$this->logger->info('Helper : Email subject = '.$records['subject']);
|
$this->logger->error('Helper : Email subject = '.$records['subject']);
|
||||||
$this->email->setMessage($records['description']);
|
$this->email->setMessage($records['description']);
|
||||||
|
|
||||||
// if($records['template_name'] != ""){
|
// if($records['template_name'] != ""){
|
||||||
// $this->logger->info('Helper : Email Template = '.$records['template_name']);
|
// $this->logger->error('Helper : Email Template = '.$records['template_name']);
|
||||||
// $this->logger->info("Helper : Email Request data = ".json_encode($records));
|
// $this->logger->error("Helper : Email Request data = ".json_encode($records));
|
||||||
// $emailContent = view($records['template_name'],$records);
|
// $emailContent = view($records['template_name'],$records);
|
||||||
// $this->email->setMessage($emailContent);
|
// $this->email->setMessage($emailContent);
|
||||||
// }else{
|
// }else{
|
||||||
// $this->logger->info('Helper : Email Dynamic Template');
|
// $this->logger->error('Helper : Email Dynamic Template');
|
||||||
// $this->email->setMessage($records['description']);
|
// $this->email->setMessage($records['description']);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
if ($cc !== '') {
|
if ($cc !== '') {
|
||||||
$ccRecipients = explode(',', trim($cc));
|
$ccRecipients = explode(',', trim($cc));
|
||||||
$this->logger->info('Helper : Email carbon copy CC recipient = ' . implode(',', $ccRecipients));
|
$this->logger->error('Helper : Email carbon copy CC recipient = ' . implode(',', $ccRecipients));
|
||||||
if (!empty($ccRecipients)) {
|
if (!empty($ccRecipients)) {
|
||||||
if (getenv('CI_ENVIRONMENT') === "production") {
|
if (getenv('CI_ENVIRONMENT') === "production") {
|
||||||
$this->email->setCC('contact@vijayabharathambooks.com');
|
$this->email->setCC('contact@vijayabharathambooks.com');
|
||||||
@ -62,7 +62,7 @@ class NotificationHelper
|
|||||||
|
|
||||||
if ($bcc !== '') {
|
if ($bcc !== '') {
|
||||||
$bccRecipients = explode(',', trim($bcc));
|
$bccRecipients = explode(',', trim($bcc));
|
||||||
$this->logger->info('Helper : Email blindcarboncopy BCC recipient = ' . implode(',', $bccRecipients));
|
$this->logger->error('Helper : Email blindcarboncopy BCC recipient = ' . implode(',', $bccRecipients));
|
||||||
if(!empty($bccRecipients)) {
|
if(!empty($bccRecipients)) {
|
||||||
$this->email->setBCC($bccRecipients);
|
$this->email->setBCC($bccRecipients);
|
||||||
}
|
}
|
||||||
@ -70,7 +70,7 @@ class NotificationHelper
|
|||||||
|
|
||||||
if ($this->email->send()) {
|
if ($this->email->send()) {
|
||||||
$message['success'] = 'Email sent successfully';
|
$message['success'] = 'Email sent successfully';
|
||||||
$this->logger->info('Helper : Email Status = sent successfully');
|
$this->logger->error('Helper : Email Status = sent successfully');
|
||||||
} else {
|
} else {
|
||||||
throw new \Exception('Email sending failed.');
|
throw new \Exception('Email sending failed.');
|
||||||
}
|
}
|
||||||
@ -86,18 +86,18 @@ class NotificationHelper
|
|||||||
$final_result = []; // Initialize outside try-catch block
|
$final_result = []; // Initialize outside try-catch block
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->logger->info('Helper : Whatsapp');
|
$this->logger->error('Helper : Whatsapp called');
|
||||||
$curl = curl_init();
|
$curl = curl_init();
|
||||||
$headers = array('Content-Type:application/json');
|
$headers = array('Content-Type:application/json');
|
||||||
$jsonencoded = json_encode($data);
|
$jsonencoded = json_encode($data);
|
||||||
curl_setopt($curl, CURLOPT_URL, $url);
|
curl_setopt($curl, CURLOPT_URL, $url);
|
||||||
$this->logger->info('Helper : Whatsapp url = ' . $url);
|
$this->logger->error('Helper : Whatsapp url = ' . $url);
|
||||||
|
|
||||||
switch ($method) {
|
switch ($method) {
|
||||||
case "POST":
|
case "POST":
|
||||||
curl_setopt($curl, CURLOPT_POST, true);
|
curl_setopt($curl, CURLOPT_POST, true);
|
||||||
if ($data) {
|
if ($data) {
|
||||||
$this->logger->info('Helper : Whatsapp jsonencoded = ' . $jsonencoded);
|
$this->logger->error('Helper : Whatsapp Request in jsonencoded Type = ' . $jsonencoded);
|
||||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $jsonencoded);
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $jsonencoded);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -114,7 +114,7 @@ class NotificationHelper
|
|||||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
|
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
|
||||||
$curl_exec = curl_exec($curl);
|
$curl_exec = curl_exec($curl);
|
||||||
$this->logger->info('Helper : Whatsapp Reponse = ' . $curl_exec);
|
$this->logger->error('Helper : Whatsapp Reponse = ' . $curl_exec);
|
||||||
$http_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
$http_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||||
|
|
||||||
if ($http_status === 200) {
|
if ($http_status === 200) {
|
||||||
|
|||||||
@ -246,6 +246,12 @@ public function customerGroupQueryExecution($queries){
|
|||||||
return $insertID;
|
return $insertID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function save_custom_notification_history_child($data){
|
||||||
|
$this->db->table('notification_history_children')->insert($data);
|
||||||
|
$insertID = $this->db->insertID();
|
||||||
|
return $insertID;
|
||||||
|
}
|
||||||
|
|
||||||
public function update_notification_history_child($data, $where){
|
public function update_notification_history_child($data, $where){
|
||||||
|
|
||||||
$id = isset($where['id']) ? $where['id'] : "";
|
$id = isset($where['id']) ? $where['id'] : "";
|
||||||
|
|||||||
@ -159,8 +159,12 @@
|
|||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label for="media_doc" class="col-3 col-form-label">Document</label>
|
<label for="media_doc" class="col-3 col-form-label">Document</label>
|
||||||
<div class="col-9">
|
<div class="col-9">
|
||||||
<input type="file" id="media_doc" name="media_doc" accept="image/*"/>
|
<div>
|
||||||
|
<input type="file" id="media_doc" name="media_doc" accept="image/jpeg"/>
|
||||||
</div>
|
</div>
|
||||||
|
<span class="help-block"><small>Upload JPEG Images Only.</small></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user