Fixes : ps
This commit is contained in:
parent
66f057b1b4
commit
a2522630ed
7
.env
7
.env
@ -146,8 +146,15 @@ APP_TIMEZONE = 'Asia/Kolkata'
|
|||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
# Whatsapp Access Token And Instance ID
|
# Whatsapp Access Token And Instance ID
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
|
# for Live
|
||||||
WAAI_TOKEN = '6568739969f28'
|
WAAI_TOKEN = '6568739969f28'
|
||||||
WAAI_INSTANCE = '656876690A9FD'
|
WAAI_INSTANCE = '656876690A9FD'
|
||||||
|
# for Test
|
||||||
|
# WAAI_TOKEN = '65685e954bcf6'
|
||||||
|
# WAAI_INSTANCE = '656863C54F90C'
|
||||||
|
# for Old Test
|
||||||
|
# WAAI_TOKEN = '652548474f4e4'
|
||||||
|
# WAAI_INSTANCE = '65254894E4A88'
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
# Email Host Name,User,Passcode And Port
|
# Email Host Name,User,Passcode And Port
|
||||||
|
|||||||
@ -115,17 +115,6 @@ define('order_column', ["invoice_id","wp_api_order_id","invoice_child_id"]);
|
|||||||
define('order_child','invoiceitems');
|
define('order_child','invoiceitems');
|
||||||
define('order_child_column', ["invoice_id","wp_api_line_items_id","customer_id"]);
|
define('order_child_column', ["invoice_id","wp_api_line_items_id","customer_id"]);
|
||||||
|
|
||||||
// define('WAAI_TOKEN', '652548474f4e4');
|
|
||||||
// define('WAAI_INSTANCE', '65254894E4A88');
|
|
||||||
|
|
||||||
// UAT - for testing Purpose..
|
|
||||||
// define('WAAI_TOKEN', '65685e954bcf6');
|
|
||||||
// define('WAAI_INSTANCE', '656863C54F90C');
|
|
||||||
|
|
||||||
// LIVE - Vel given.30th Nov.
|
|
||||||
// define('WAAI_TOKEN', '6568739969f28');
|
|
||||||
// define('WAAI_INSTANCE', '656876690A9FD');
|
|
||||||
|
|
||||||
## GET Constant Based on ENV file Starts...
|
## GET Constant Based on ENV file Starts...
|
||||||
define('WAAI_TOKEN', getenv('WAAI_TOKEN'));
|
define('WAAI_TOKEN', getenv('WAAI_TOKEN'));
|
||||||
define('WAAI_INSTANCE', getenv('WAAI_INSTANCE'));
|
define('WAAI_INSTANCE', getenv('WAAI_INSTANCE'));
|
||||||
|
|||||||
@ -39,17 +39,26 @@ class Notifications extends BaseController
|
|||||||
$this->logger->info("Whatsapp : sending message instance id = " . $_ENV['WAAI_INSTANCE'] . " - " . $_ENV['WAAI_TOKEN']);
|
$this->logger->info("Whatsapp : sending message instance id = " . $_ENV['WAAI_INSTANCE'] . " - " . $_ENV['WAAI_TOKEN']);
|
||||||
try {
|
try {
|
||||||
if ($records['categories'] == 'SEND_WAAI_GROUP_URL') {
|
if ($records['categories'] == 'SEND_WAAI_GROUP_URL') {
|
||||||
if($records['group_id'] != ""){ $params->group_id = $records['group_id']; }
|
if ($records['group_id'] != "") {
|
||||||
else{ throw new \Exception("Group Id Missing Please Try again.."); }
|
$params->group_id = $records['group_id'];
|
||||||
|
} else {
|
||||||
|
throw new \Exception("Group Id Missing Please Try again..");
|
||||||
|
}
|
||||||
} else if ($records['categories'] == 'SEND_WAAI_URL') {
|
} else if ($records['categories'] == 'SEND_WAAI_URL') {
|
||||||
if($records['mobile'] != ""){ $params->number = (int)'91' . $records['mobile']; }
|
if ($records['mobile'] != "") {
|
||||||
else{ throw new \Exception("Mobile Number Missing Please Try again.."); }
|
$params->number = (int)'91' . $records['mobile'];
|
||||||
|
} else {
|
||||||
|
throw new \Exception("Mobile Number Missing Please Try again..");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new \Exception("Please Choose your Category");
|
throw new \Exception("Please Choose your Category");
|
||||||
}
|
}
|
||||||
if ($records['type'] == 'media') {
|
if ($records['type'] == 'media') {
|
||||||
if($records['media_url'] != ""){ $params->media_url = $records['media_url']; }
|
if ($records['media_url'] != "") {
|
||||||
else{ throw new \Exception("Media Url Missing Please Try again.."); }
|
$params->media_url = $records['media_url'];
|
||||||
|
} else {
|
||||||
|
throw new \Exception("Media Url Missing Please Try again..");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$url = constant($records['categories']);
|
$url = constant($records['categories']);
|
||||||
@ -104,7 +113,6 @@ class Notifications extends BaseController
|
|||||||
$business_name = $rec['business_name'];
|
$business_name = $rec['business_name'];
|
||||||
$subscription_name = $rec['title'];
|
$subscription_name = $rec['title'];
|
||||||
$to_subscription = $rec['to_subscription'];
|
$to_subscription = $rec['to_subscription'];
|
||||||
|
|
||||||
}
|
}
|
||||||
$records['template_name'] = '';
|
$records['template_name'] = '';
|
||||||
$records['recipient_name'] = $recipient_name;
|
$records['recipient_name'] = $recipient_name;
|
||||||
@ -138,10 +146,10 @@ class Notifications extends BaseController
|
|||||||
$this->logger->info("Notification : Duedate notification Whatsapp Request data = " . json_encode($params));
|
$this->logger->info("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->info("Notification : Duedate notification Whatsapp Response = " . json_encode($whatsapp_result));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function template_creation(){
|
public function template_creation()
|
||||||
|
{
|
||||||
$data['page_name'] = 'Template Details';
|
$data['page_name'] = 'Template Details';
|
||||||
$model = new NotificationModel();
|
$model = new NotificationModel();
|
||||||
$data['template'] = $model->getTemplateDetails();
|
$data['template'] = $model->getTemplateDetails();
|
||||||
@ -149,7 +157,8 @@ class Notifications extends BaseController
|
|||||||
// echo "templates";die;
|
// echo "templates";die;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function template_creation_form($id){
|
public function template_creation_form($id)
|
||||||
|
{
|
||||||
|
|
||||||
$data['group_details'] = $this->get_group_details();
|
$data['group_details'] = $this->get_group_details();
|
||||||
$model = new NotificationModel();
|
$model = new NotificationModel();
|
||||||
@ -169,7 +178,8 @@ class Notifications extends BaseController
|
|||||||
$this->render_page('template_creation_form', $data);
|
$this->render_page('template_creation_form', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function template_creation_delete($id){
|
public function template_creation_delete($id)
|
||||||
|
{
|
||||||
try {
|
try {
|
||||||
helper('session');
|
helper('session');
|
||||||
$session_uid = get_logged_user_id();
|
$session_uid = get_logged_user_id();
|
||||||
@ -196,7 +206,6 @@ class Notifications extends BaseController
|
|||||||
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
|
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
return redirect()->route('template_creation');
|
return redirect()->route('template_creation');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_group_details()
|
public function get_group_details()
|
||||||
@ -208,14 +217,17 @@ class Notifications extends BaseController
|
|||||||
$details = $model->where($where)->orderBy('group_id', 'ASC')->findAll();
|
$details = $model->where($where)->orderBy('group_id', 'ASC')->findAll();
|
||||||
return $details;
|
return $details;
|
||||||
}
|
}
|
||||||
public function get_template_details(){
|
|
||||||
|
public function get_template_details()
|
||||||
|
{
|
||||||
$model = new NotificationModel();
|
$model = new NotificationModel();
|
||||||
$model->setTable('templates');
|
$model->setTable('templates');
|
||||||
$details = $model->where('isactive', 1)->orderBy('template_id', 'ASC')->findAll();
|
$details = $model->where('isactive', 1)->orderBy('template_id', 'ASC')->findAll();
|
||||||
return $details;
|
return $details;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function template_creation_insert(){
|
public function template_creation_insert()
|
||||||
|
{
|
||||||
$this->logger->info("Template: Inserting/Updating Details");
|
$this->logger->info("Template: Inserting/Updating Details");
|
||||||
try {
|
try {
|
||||||
## Declarions
|
## Declarions
|
||||||
@ -252,7 +264,8 @@ class Notifications extends BaseController
|
|||||||
return redirect()->route('template_creation');
|
return redirect()->route('template_creation');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function campaign_creation(){
|
public function campaign_creation()
|
||||||
|
{
|
||||||
$data['page_name'] = 'Campaign Details';
|
$data['page_name'] = 'Campaign Details';
|
||||||
$model = new NotificationModel();
|
$model = new NotificationModel();
|
||||||
$data['campaign'] = $model->getCampaignDetails();
|
$data['campaign'] = $model->getCampaignDetails();
|
||||||
@ -260,7 +273,8 @@ class Notifications extends BaseController
|
|||||||
// echo "templates";die;
|
// echo "templates";die;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function campaign_creation_form($id){
|
public function campaign_creation_form($id)
|
||||||
|
{
|
||||||
|
|
||||||
$data['group_details'] = $this->get_group_details();
|
$data['group_details'] = $this->get_group_details();
|
||||||
$data['template_details'] = $this->get_template_details();
|
$data['template_details'] = $this->get_template_details();
|
||||||
@ -281,12 +295,12 @@ class Notifications extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$data['campaign_details'] = !empty($result[0]) ? $result[0] : [];
|
$data['campaign_details'] = !empty($result[0]) ? $result[0] : [];
|
||||||
|
|
||||||
}
|
}
|
||||||
$this->render_page('campaign_creation_form', $data);
|
$this->render_page('campaign_creation_form', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function campaign_creation_delete($id){
|
public function campaign_creation_delete($id)
|
||||||
|
{
|
||||||
try {
|
try {
|
||||||
helper('session');
|
helper('session');
|
||||||
$session_uid = get_logged_user_id();
|
$session_uid = get_logged_user_id();
|
||||||
@ -313,10 +327,10 @@ class Notifications extends BaseController
|
|||||||
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
|
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
return redirect()->route('campaign_creation');
|
return redirect()->route('campaign_creation');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function campaign_creation_insert(){
|
public function campaign_creation_insert()
|
||||||
|
{
|
||||||
$this->logger->info("Campaign: Inserting/Updating Details");
|
$this->logger->info("Campaign: Inserting/Updating Details");
|
||||||
try {
|
try {
|
||||||
## Declarions
|
## Declarions
|
||||||
@ -363,8 +377,6 @@ class Notifications extends BaseController
|
|||||||
} else {
|
} else {
|
||||||
throw new \Exception("Campaign: Err Occur");
|
throw new \Exception("Campaign: Err Occur");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->logger->error("Campaign: Err Occur =" . $e->getMessage());
|
$this->logger->error("Campaign: Err Occur =" . $e->getMessage());
|
||||||
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
|
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
|
||||||
@ -395,6 +407,7 @@ class Notifications extends BaseController
|
|||||||
}
|
}
|
||||||
$db = \Config\Database::connect();
|
$db = \Config\Database::connect();
|
||||||
$queryResult = $db->query($modifiedQuery)->getResultArray();
|
$queryResult = $db->query($modifiedQuery)->getResultArray();
|
||||||
|
|
||||||
$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->info("There is no customer expiring on date:{$newDate}");
|
||||||
@ -470,280 +483,4 @@ class Notifications extends BaseController
|
|||||||
} // $Whatsapp Template Name
|
} // $Whatsapp Template Name
|
||||||
} // for loop
|
} // for loop
|
||||||
}
|
}
|
||||||
|
|
||||||
public function auto_scheduled_notification()
|
|
||||||
{
|
|
||||||
$this->logger->info("Auto Scheduled Notification Started");
|
|
||||||
$nc_id = "";
|
|
||||||
$model = new NotificationModel();
|
|
||||||
$model->setTable('notification_campaign');
|
|
||||||
$where = ['status'=>0];
|
|
||||||
$notification_campaign_result = $model->where($where)->findAll();
|
|
||||||
$today = date('Y-m-d');
|
|
||||||
$customer_details = array();
|
|
||||||
$customer_details_template = array();
|
|
||||||
if (!empty($notification_campaign_result)) {
|
|
||||||
foreach ($notification_campaign_result as $n => $ncr) {
|
|
||||||
if($today == $ncr['scheduled_date']){
|
|
||||||
// echo "<pre>";print_r($ncr);echo "</pre>";die; //working fine.
|
|
||||||
$nc_id = $ncr['campaign_id'];
|
|
||||||
$this->logger->info("Step 1 : (Campaign) Scheduled Date = " .$ncr['scheduled_date']."/".$ncr['scheduled_time'].", Today = ".$today );
|
|
||||||
$customer_details_template = $this->auto_scheduled_template_details($ncr);
|
|
||||||
}else{
|
|
||||||
$this->logger->info("Step 1 : (Campaign) Scheduled Date = " .$ncr['scheduled_date'].", Today = ".$today );
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if(!empty($customer_details_template)){
|
|
||||||
// echo "<pre>";print_r($customer_details_template);echo "</pre>";die;
|
|
||||||
$customer_details = $this->auto_scheduled_send_message($customer_details_template);
|
|
||||||
if(!empty($customer_details)){
|
|
||||||
$this->auto_scheduled_notification_campaign_status($nc_id);
|
|
||||||
$nc_id = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
$this->logger->info("Step 1 : Campaign details not found ");
|
|
||||||
$this->logger->info("Auto Scheduled Notification End");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function auto_scheduled_template_details($ncr){
|
|
||||||
$this->logger->info("To Retrieved Template for Auto Scheduled");
|
|
||||||
$template_id = $ncr['template_id'];
|
|
||||||
$group_id = $ncr['group_id'];
|
|
||||||
$nc_mode = $ncr['mode'];
|
|
||||||
$model = new NotificationModel();
|
|
||||||
$model->setTable('templates');
|
|
||||||
$where = ['template_id'=>$template_id];
|
|
||||||
$template_result = $model->where($where)->findAll();
|
|
||||||
// echo "<pre>";print_r($template_result);echo "</pre>";die;
|
|
||||||
$flattened_array = array(); // its have customer Details...
|
|
||||||
if (!empty($template_result)) {
|
|
||||||
$group_details = array();
|
|
||||||
foreach ($template_result as $t => $tr) {
|
|
||||||
$this->logger->info("Step 2 : (Template) id = ".$tr['template_id']."/".$tr['template_name']." , Template Mode = ".$tr['mode']." NotifyCampian Mode = ".$nc_mode);
|
|
||||||
$details = $this->auto_scheduled_customer_group_details($tr,$ncr);
|
|
||||||
// echo "<pre>";print_r($details);echo "</pre>";die;
|
|
||||||
|
|
||||||
if(!empty($details)){
|
|
||||||
foreach ($details as $d => $dr) {
|
|
||||||
$group_details[] = $dr['group_query_results'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!empty($group_details)){
|
|
||||||
foreach ($group_details as $sub_array) {
|
|
||||||
foreach ($sub_array as $inner_array) {
|
|
||||||
$flattened_array[] = $inner_array;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// echo "<pre>";print_r($flattened_array);echo "</pre>";die;
|
|
||||||
// Don't Delete It Duplication Check 07-12-2023
|
|
||||||
// // Extract customer IDs using array_column
|
|
||||||
// $customer_ids = array_column($flattened_array, 'customer_id');
|
|
||||||
// // Find unique customer IDs
|
|
||||||
// $unique_customer_ids = array_unique($customer_ids);
|
|
||||||
// // Initialize a new array for unique data
|
|
||||||
// $unique_data = [];
|
|
||||||
// // Iterate through the original data and keep only unique entries
|
|
||||||
// foreach ($flattened_array as $entry) {
|
|
||||||
// if (in_array($entry['customer_id'], $unique_customer_ids)) {
|
|
||||||
// $unique_data[] = $entry;
|
|
||||||
// // Remove the customer ID from the unique array to avoid duplicates
|
|
||||||
// unset($unique_customer_ids[array_search($entry['customer_id'], $unique_customer_ids)]);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// // Now $uniqueData contains entries with unique customer IDs
|
|
||||||
// print_r($unique_data);
|
|
||||||
// echo "<pre>";print_r($flattened_array);echo "</pre>";die;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
$this->logger->info("Step 2 : Template Details details not found");
|
|
||||||
$this->logger->info("Auto Scheduled Notification End");
|
|
||||||
}
|
|
||||||
return $flattened_array;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function auto_scheduled_customer_group_details($tr_object,$ncr_object){
|
|
||||||
|
|
||||||
$this->logger->info("To Retrieved Customer Group Details for Auto Scheduled");
|
|
||||||
$group_id = $ncr_object['group_id'];
|
|
||||||
$nc_mode = $ncr_object['mode'];
|
|
||||||
$group_arr = unserialize($group_id);
|
|
||||||
$t_mode = $tr_object['mode'];
|
|
||||||
$group_details = [];
|
|
||||||
if (!empty($group_arr)) {
|
|
||||||
$this->logger->info("Step 3 : (Customer Group) id = ".implode(", ", $group_arr));
|
|
||||||
$model = new NotificationModel();
|
|
||||||
$model->setTable('customer_groups');
|
|
||||||
$group_arr_result = $model->whereIn('group_id', $group_arr)->findAll();
|
|
||||||
|
|
||||||
if (!empty($group_arr_result)) {
|
|
||||||
foreach ($group_arr_result as $g => $gar) {
|
|
||||||
|
|
||||||
$group_details[$g]['group_query'] = $gar['group_query'];
|
|
||||||
$group_details[$g]['group_id'] = $gar['group_id'];
|
|
||||||
$db = \Config\Database::connect();
|
|
||||||
$sql = (string)$gar['group_query'];
|
|
||||||
if($sql){
|
|
||||||
$query = $db->query($sql);
|
|
||||||
$results = $query->getResultArray();
|
|
||||||
foreach ($results as &$row) {
|
|
||||||
$row['group_id'] = $gar['group_id'];
|
|
||||||
$row['nc_mode'] = $nc_mode; // mode from notification_campaign Table Cross Check purpose
|
|
||||||
$row['t_mode'] = $t_mode; // mode from template Table Cross Check purpose
|
|
||||||
$row['template_message'] = $tr_object['message'];
|
|
||||||
$row['template_subject'] = $tr_object['subject'];
|
|
||||||
$row['campaign_id'] = $ncr_object['campaign_id'];
|
|
||||||
}
|
|
||||||
$group_details[$g]['group_query_results'] = $results;
|
|
||||||
$group_details[$g]['group_query_customer_count'] = count($results);
|
|
||||||
$this->logger->info("Step 3 : Customer Group SQL customer count = ".count($results)." group id = ".$gar['group_id']);
|
|
||||||
|
|
||||||
}else{
|
|
||||||
$this->logger->info("Step 3 : Customer Group SQL not found");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
$this->logger->info("Step 3 : Customer Group details not found");
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
$this->logger->info("Step 3 : Customer Group ID not found");
|
|
||||||
}
|
|
||||||
return $group_details;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function auto_scheduled_send_message($customer_details){
|
|
||||||
$this->logger->info("To Send Message on Customer for Auto Scheduled");
|
|
||||||
$return_statement = array();
|
|
||||||
if (!empty($customer_details)) {
|
|
||||||
foreach($customer_details as $c => $cd) {
|
|
||||||
|
|
||||||
switch($cd['nc_mode']) {
|
|
||||||
case "Whatsapp":
|
|
||||||
$whatsapp = $this->auto_scheduled_whatsapp($cd);
|
|
||||||
array_push($return_statement, $whatsapp);
|
|
||||||
break;
|
|
||||||
case "Email":
|
|
||||||
$email = $this->auto_scheduled_email($cd);
|
|
||||||
array_push($return_statement, $email);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$this->logger->error($cd["customer_name"]." Can't able to identity the mode for Auto Scheduled");
|
|
||||||
array_push($return_statement, $cd["customer_name"]." Can't able to identity the mode for Auto Scheduled");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $return_statement;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function auto_scheduled_email($cd){
|
|
||||||
// // $cd["city"]
|
|
||||||
// // $cd["state"]
|
|
||||||
// // $cd["invoice_date"]
|
|
||||||
// // $cd["customer_id"]
|
|
||||||
// echo $cd["customer_name"];
|
|
||||||
// // $cd["email"]
|
|
||||||
// // $cd["mobile_no"]
|
|
||||||
// // $cd["due_date"]
|
|
||||||
// // $cd["isactive"]
|
|
||||||
// // $cd["invoice_count_raised_by_customer"]
|
|
||||||
// // $cd["scheme_id"]
|
|
||||||
// // $cd["name"]
|
|
||||||
// // $cd["group_id"]
|
|
||||||
// // $cd["nc_mode"]
|
|
||||||
// // $cd["t_mode"]
|
|
||||||
// // $cd["template_message"]
|
|
||||||
// // $cd["campaign_id"]
|
|
||||||
$this->logger->info("Auto Notification : Email Customer Details = " . json_encode($cd));
|
|
||||||
|
|
||||||
if(!empty($cd["template_message"] )){
|
|
||||||
|
|
||||||
$emailContent = $cd["template_message"] ;
|
|
||||||
$emailContent = str_replace("{USER_NAME}", $cd["customer_name"], $emailContent);
|
|
||||||
$emailContent = str_replace("{SCHEME_NAME}", $cd["name"], $emailContent);
|
|
||||||
$emailContent = str_replace("{EXPIRY_DATE}", $cd["formatted_due_date"], $emailContent);
|
|
||||||
|
|
||||||
$emailData = [
|
|
||||||
'template_name' => '',
|
|
||||||
'recipient_email' => $cd["email"],
|
|
||||||
'subject' => $cd["template_subject"] != "" ? $cd["template_subject"] : ucfirst(str_replace('_', ' ', (string)$cd["name"]))." Notification" ,
|
|
||||||
'description' => $emailContent,
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
$notification = new NotificationHelper();
|
|
||||||
// $emailResult = $notification->sendEmail($emailData);
|
|
||||||
$emailResult = array();
|
|
||||||
|
|
||||||
$this->logger->info("Auto Notification : Email Content = " . $emailContent);
|
|
||||||
$this->logger->info("Auto Notification : Email Response = " . json_encode($emailResult));
|
|
||||||
if (isset($emailResult['success'])) {
|
|
||||||
$this->logger->info("Auto Notification : ".$cd["customer_name"]."`s mail sended Mail ID = ".$cd["email"]);
|
|
||||||
return $cd["customer_name"]." mail sended";
|
|
||||||
} else {
|
|
||||||
$this->logger->info("Auto Notification : ".$cd["customer_name"]."`s mail not sended Mail ID = ".$cd["email"]);
|
|
||||||
return $cd["customer_name"]." mail not sended";
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
$this->logger->info('There is no email template found');
|
|
||||||
return $cd["customer_name"]." mail template not found";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public function auto_scheduled_whatsapp($cd){
|
|
||||||
|
|
||||||
if(!empty($cd["template_message"])){
|
|
||||||
if (empty($cd["mobile_no"])) {
|
|
||||||
$this->logger->info('There is no mobile number Founded');
|
|
||||||
return $cd["customer_name"]." mobile number not found";
|
|
||||||
}
|
|
||||||
echo "<pre>";print_r($cd);echo "</pre>";die;
|
|
||||||
$this->logger->info('testing purpose ==> '.$cd["customer_name"]." -- ".$cd["name"]." -- ".$cd["due_date"]);
|
|
||||||
|
|
||||||
$whatsappContent = $cd["template_message"];
|
|
||||||
$whatsappContent = str_replace("{USER_NAME}", $cd["customer_name"], $whatsappContent);
|
|
||||||
$whatsappContent = str_replace("{SCHEME_NAME}", $cd["name"], $whatsappContent);
|
|
||||||
$whatsappContent = str_replace("{EXPIRY_DATE}", $cd["formatted_due_date"], $whatsappContent);
|
|
||||||
|
|
||||||
|
|
||||||
$params = (object) Null;
|
|
||||||
$url = SEND_WAAI_URL;
|
|
||||||
$params->number = (int)'91' . $cd["mobile_no"];
|
|
||||||
$params->type = "text";
|
|
||||||
$params->message = $whatsappContent;
|
|
||||||
$params->instance_id = $_ENV['WAAI_INSTANCE'];
|
|
||||||
$params->access_token = $_ENV['WAAI_TOKEN'];
|
|
||||||
$this->logger->info("Auto Notification : Whatsapp Content = " . $whatsappContent);
|
|
||||||
$this->logger->info($cd["name"]." Whatsapp Request = " . json_encode($params));
|
|
||||||
$this->logger->info($cd["name"]." Whatsapp Request type b4 = " . gettype($params));
|
|
||||||
$notification = new NotificationHelper();
|
|
||||||
// $whatsapp_result = $notification->sendWhatsAppMessage($url, "POST", $params);
|
|
||||||
$whatsapp_result = array();
|
|
||||||
// $this->logger->info($cd["name"]." Whatsapp Reponse = " .$whatsapp_result);
|
|
||||||
|
|
||||||
return $cd["customer_name"]."/".$cd["name"]." whatsapp template found not found";
|
|
||||||
}else{
|
|
||||||
$this->logger->info('There is no Whatsapp template found by the name of '.$cd["name"]);
|
|
||||||
return $cd["customer_name"]."/".$cd["name"]." whatsapp template found not found";
|
|
||||||
}// $Whatsapp Template Name
|
|
||||||
}
|
|
||||||
|
|
||||||
public function auto_scheduled_notification_campaign_status($campaign_id){
|
|
||||||
// echo "<br> have to update...................";
|
|
||||||
$model = new NotificationModel();
|
|
||||||
$model->setTable('notification_campaign');
|
|
||||||
|
|
||||||
$where = ['isactive' => 1, 'status' => 0, 'campaign_id' => (int) $campaign_id];
|
|
||||||
$data = ['status' => 1];
|
|
||||||
|
|
||||||
if ($model->where($where)->update($data)) {
|
|
||||||
// Update successful
|
|
||||||
echo "Update successful!";
|
|
||||||
} else {
|
|
||||||
// Update failed
|
|
||||||
echo "Update failed!";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@ -580,37 +580,14 @@ function restriction(event,temporary_flag) {
|
|||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
document.getElementById('myForm').addEventListener('submit', function(event) {
|
document.getElementById('myForm').addEventListener('submit', function(event) {
|
||||||
var table = document.getElementById("itemTable").getElementsByTagName("tbody")[0];
|
|
||||||
var rows = table.getElementsByTagName("tr");
|
|
||||||
var hasValue = false;
|
|
||||||
var rowCounter = rows.length; // Get the current number of rows
|
|
||||||
|
|
||||||
// Check if any existing fields are empty
|
|
||||||
for (var i = 0; i < rows.length; i++) {
|
|
||||||
var cells = rows[i].getElementsByTagName("td");
|
|
||||||
for (var j = 0; j < cells.length; j++) {
|
|
||||||
var input = cells[j].querySelector('input, select');
|
|
||||||
if (input && input.value.trim() === "") {
|
|
||||||
alert("Field in row " + (i + 1) + " is empty.");
|
|
||||||
$('#scrollable-modal').modal('hide');
|
|
||||||
return; // Exit the loop after the first empty field is found.
|
|
||||||
} else {
|
|
||||||
hasValue = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hasValue) {
|
|
||||||
var form = event.target;
|
var form = event.target;
|
||||||
|
|
||||||
if (form.checkValidity() === false) {
|
if (form.checkValidity() === false) {
|
||||||
|
|
||||||
form.reportValidity(); // Display validation error messages
|
form.reportValidity(); // Display validation error messages
|
||||||
event.preventDefault(); // Prevent form submission if it's not valid
|
event.preventDefault(); // Prevent form submission if it's not valid
|
||||||
$('#save').prop('disabled', false);
|
$('#save').prop('disabled', false);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$('#save').prop('disabled', true);
|
$('#save').prop('disabled', true);
|
||||||
}}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user