diff --git a/app/Controllers/Notifications.php b/app/Controllers/Notifications.php
index 9e77730c..17657f38 100755
--- a/app/Controllers/Notifications.php
+++ b/app/Controllers/Notifications.php
@@ -8,34 +8,57 @@ use App\Models\NotificationModel;
class Notifications extends BaseController
{
- ## Email Section :
+ ################################################################
+ # Custom Email Notification
+ ################################################################
public function mail_custom_notifications()
{
- $request = \Config\Services::request();
- if ($request->is('post')) {
- $records = $request->getVar();
- $records['template_name'] = "";
+ if ($this->request->is('post')) {
+ $records = $this->request->getVar();
helper('notification');
$notification = new NotificationHelper();
$data = $notification->sendEmail($records);
+ $parents_status = 0;
+ $receiving_status = 0;
if (isset($data['error'])) {
session()->setFlashdata('error', 'Message: ' . $data['error']);
+ $history_msg = $data;
}
if (isset($data['success'])) {
session()->setFlashdata('success', 'Message: ' . $data['success']);
+ $parents_status = 1;
+ $receiving_status = 1;
+ $history_msg = 'Email sent successfully';
}
+ $history_msg = (strtolower(gettype($history_msg)) == "string" ? $history_msg : json_encode($history_msg)) ;
+ $NotificationModel = new NotificationModel();
+ $history_parents_data = ['campaign_id' => 0,'status' => $parents_status];
+ $history_parent_id = $NotificationModel->save_notification_history_parents($history_parents_data);
+ $history_child_data = [ 'fkid' => $history_parent_id,
+ 'customer_id' => 0,
+ 'receiving_entity' => $records['recipient_email'],
+ 'receiving_status' => $receiving_status,
+ 'message' => $records['description'],
+ 'result'=>strtolower(gettype($history_msg)) == "string" ? $history_msg : json_encode($history_msg)];
+ $history_child_id = $NotificationModel->save_notification_history_child($history_child_data);
+ $this->logger->info('Custom Notifications Email : historychildid = '.$history_child_id);
}
+ $records = [];
$data['page_name'] = 'Custom Notifications';
$this->render_page('notifications_form', $data);
}
+ # mail custom notifications closed
+ ################################################################
+ # Custom Whatsapp Notification
+ ################################################################
public function whatsapp_custom_notifications()
{
- $request = \Config\Services::request();
- if ($request->is('post')) {
- $records = $request->getVar();
+ if ($this->request->is('post')) {
+ $records = $this->request->getVar();
$params = (object) Null;
-
+ $parents_status = 0;
+ $receiving_status = 0;
$this->logger->info("Whatsapp : sending message instance id = " . $_ENV['WAAI_INSTANCE'] . " - " . $_ENV['WAAI_TOKEN']);
try {
if ($records['categories'] == 'SEND_WAAI_GROUP_URL') {
@@ -44,6 +67,11 @@ class Notifications extends BaseController
} else {
throw new \Exception("Group Id Missing Please Try again..");
}
+ if ($records['mobile'] != "") {
+ $params->number = (int)'91' . $records['mobile'];
+ } else {
+ throw new \Exception("Mobile Number Missing Please Try again..");
+ }
} else if ($records['categories'] == 'SEND_WAAI_URL') {
if ($records['mobile'] != "") {
$params->number = (int)'91' . $records['mobile'];
@@ -71,16 +99,33 @@ class Notifications extends BaseController
helper('notification');
$notification = new NotificationHelper();
$success = $notification->sendWhatsAppMessage($url, "POST", $params);
- session()->setFlashdata('success', 'Message : ' . $success);
- $this->logger->info("Whatsapp : Reponse = " . $success);
+ $receiving_status = $success['receiving_status'];
+ $parents_status = $success['receiving_status'];
+ $history_msg = strtolower(gettype($success)) == "string" ? $success : json_encode($success['reponse']);
+ session()->setFlashdata('success', 'Message : ' . $success['message']);
+ $this->logger->info("Whatsapp : Reponse = " . $success['message']);
} catch (\Exception $e) {
$this->logger->error("Whatsapp : Exception Message = " . $e->getMessage() . "
File: " . $e->getFile() . "
Line: " . $e->getLine() . "
");
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
+ $history_msg = strtolower(gettype($success)) == "string" ? $success : json_encode($success['reponse']);
}
+ $NotificationModel = new NotificationModel();
+ $history_parents_data = ['campaign_id' => 0,'status' => $parents_status];
+ $history_parent_id = $NotificationModel->save_notification_history_parents($history_parents_data);
+ $history_child_data = [ 'fkid' => $history_parent_id,
+ 'customer_id' => 0,
+ 'receiving_entity' => $records['mobile'],
+ 'receiving_status' => $receiving_status,
+ 'message' => $records['description'],
+ 'result'=>$history_msg];
+ $history_child_id = $NotificationModel->save_notification_history_child($history_child_data);
}
+ $records = [];
$data['page_name'] = 'Custom Notifications';
$this->render_page('notifications_form', $data);
+ $this->logger->info('Custom Notifications Whatsapp : historychildid = '.$history_child_id);
}
+ # whatsapp custom notifications closed
public function due_date_notifications()
{
@@ -157,6 +202,9 @@ class Notifications extends BaseController
// echo "templates";die;
}
+ ##################################################################
+ # Template Creation Insertion/updation Process ReferWith : Sanjeev
+ ##################################################################
public function template_creation_form($id)
{
@@ -178,6 +226,9 @@ class Notifications extends BaseController
$this->render_page('template_creation_form', $data);
}
+ ##############################################################################
+ # Template Creation Delection which means inactive Process ReferWith : Sanjeev
+ ##############################################################################
public function template_creation_delete($id)
{
try {
@@ -208,6 +259,7 @@ class Notifications extends BaseController
return redirect()->route('template_creation');
}
+
public function get_group_details()
{
$model = new NotificationModel();
@@ -394,21 +446,26 @@ class Notifications extends BaseController
return redirect()->route('campaign_creation');
}
+ ################################################################
+ # Expiry Notification ReferWith : Hema
+ ################################################################
public function getExpCustomerDetail($window_time = null)
{
- // Step 1: add the days to retrive the data//
+ # Step 1: add the days to retrive the data//
$providedDate = date('Y-m-d');
$newDate = date('Y-m-d', strtotime($providedDate . ' + ' . $window_time . ' days'));
+ $this->logger->info('EXPIRYDATE T-Date = '.$providedDate.', Given ' .$window_time.' Day, Calacuated Date based on Given days = '.$newDate);
- // Step 2 :Get the customer detail//
+ # Step 2 :Get the customer detail//
$NotificationModel = new NotificationModel();
$ExpCustomerDetail = $NotificationModel->getExpDate(); // Retrieve the stored query
+
if (empty($ExpCustomerDetail)) {
$this->logger->info('No customer group found by the name of EXPIRYDATE');
return;
}
- //Step 3: Replace the placeholder WINDOW_TIME with the user-provided value
+ # Step 3: Replace the placeholder WINDOW_TIME with the user-provided value
$modifiedQuery = str_replace('WINDOW_TIME', $window_time, $ExpCustomerDetail);
if (empty($modifiedQuery)) {
@@ -423,6 +480,8 @@ class Notifications extends BaseController
$this->logger->info("There is no customer expiring on date:{$newDate}");
return;
}
+ $emailTemplateName = $NotificationModel->getTempName(EXPIRAY_NOTIFY_TEMPLATE_EMAIL);
+
foreach ($queryResult as $row) {
$userFirstName = $row['first_name'];
$userLastName = $row['last_name'];
@@ -430,14 +489,20 @@ class Notifications extends BaseController
$userMobileNumber = $row['mobile_no'];
$schemename = $row['title'];
$expirydate = $row['to_subscription'];
+ $customerId = $row['customer_id'];
if (empty($fullName)) {
$this->logger->info('There is no subcription Name');
continue;
}
+ # EXPIRAY_NOTIFY_TEMPLATE_EMAIL
$emailTemplateName = $NotificationModel->getTempName(EXPIRAY_NOTIFY_TEMPLATE_EMAIL);
if (!empty($emailTemplateName)) {
- //Step 4: Prepare email content based on the template
+ # Insertion on History Email Means Campaign ID 1 Hardcoded
+ $history_parents_data = ['campaign_id' => 1,'status' => 0];
+ $history_parent_id = $NotificationModel->save_notification_history_parents($history_parents_data);
+
+ # Step 4: Prepare email content based on the template
$emailContent = $emailTemplateName[0]['message'];
$emailContent = str_replace("{USER_NAME}", $fullName, $emailContent);
$emailContent = str_replace("{SCHEME_NAME}", $schemename, $emailContent);
@@ -449,33 +514,64 @@ class Notifications extends BaseController
'subject' => 'Your Subscription Expiry Notification',
'description' => $emailContent,
];
+ $history_child_data = [ 'fkid' => $history_parent_id,
+ 'customer_id' => $customerId,
+ 'receiving_entity' => $row['email'],
+ 'receiving_status' => 0,
+ 'message' => $emailContent];
+ # Step 5: Insertion on History Child
+ $history_child_id = $NotificationModel->save_notification_history_child($history_child_data);
- // Step 5:Send email using NotificationHelper
+ # Step 6:Send email using NotificationHelper
$emailResult = $notification->sendEmail($emailData);
-
- if (isset($emailResult['success'])) {
- echo 'Email sent successfully';
+
+ $this->logger->info("EXPIRAY NOTIFY TEMPLATE EMAIL Email CID = ".$customerId." ".json_encode($emailResult));
+
+ if (isset($emailResult['success'])) {
+ $history_msg = 'Email sent successfully';
+ $receiving_status = 1 ;
+ echo $history_msg;
} else {
+ $history_msg = (strtolower(gettype($emailResult)) == "string" ? $emailResult : json_encode($emailResult)) ;
+ $receiving_status = 0 ;
echo 'Failed to send email';
}
} else {
- $this->logger->info('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 ;
+ $this->logger->info($history_msg);
continue;
- } // $emailTemplateName
+ }
+ # EXPIRAY_NOTIFY_TEMPLATE_EMAIL Closed
+ # EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP
$whatsappTemplateName = $NotificationModel->getTempName(EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP);
if (!empty($whatsappTemplateName)) {
if (empty($userMobileNumber)) {
- $this->logger->info('There is no subscriber mobile number');
+ $history_msg = 'There is no subscriber mobile number';
+ $this->logger->info($history_msg);
continue;
}
- //Step 6: Prepare whatsapp content based on the template
+ # Insertion on History Whatsapp Means Campaign ID 2 Hardcoded
+ $history_parents_data = ['campaign_id' => 2,'status' => 0];
+ $history_parent_id = $NotificationModel->save_notification_history_parents($history_parents_data);
+
+ # Step 7: Prepare whatsapp content based on the template
$whatsappContent = $whatsappTemplateName[0]['message'];
$whatsappContent = str_replace("{USER_NAME}", $fullName, $emailContent);
$whatsappContent = str_replace("{SCHEME_NAME}", $schemename, $emailContent);
$whatsappContent = str_replace("{EXPIRY_DATE}", $expirydate, $emailContent);
- // Step 7: Send email using NotificationHelper
+ # Step 8: Insertion on History Child for whatsapp
+ $history_child_data = [ 'fkid' => $history_parent_id,
+ 'customer_id' => $customerId,
+ 'receiving_entity' => $userMobileNumber,
+ 'receiving_status' => 0,
+ 'message' => $whatsappContent];
+ $history_child_id = $NotificationModel->save_notification_history_child($history_child_data);
+
+
+ # Step 8: Send Whatsapp using NotificationHelper
$params = (object) Null;
$url = SEND_WAAI_URL;
$params->number = (int)'91' . $userMobileNumber;
@@ -486,13 +582,30 @@ class Notifications extends BaseController
$this->logger->info("EXPIRAY NOTIFY TEMPLATE WHATSAPP Request = " . json_encode($params));
$this->logger->info("EXPIRAY NOTIFY TEMPLATE WHATSAPP Request type b4 = " . gettype($params));
$whatsapp_result = $notification->sendWhatsAppMessage($url, "POST", $params);
- $this->logger->info("EXPIRAY NOTIFY TEMPLATE WHATSAPP Reponse = " . $whatsapp_result);
+ $this->logger->info("EXPIRAY NOTIFY TEMPLATE WHATSAPP Reponse = " . $whatsapp_result['message']);
+
+ $receiving_status = $whatsapp_result['receiving_status'];
+ $history_msg = strtolower(gettype($whatsapp_result)) == "string" ? $whatsapp_result : json_encode($whatsapp_result['reponse']);
} else {
- $this->logger->info('There is no Whatsapp template found by the name of EXPIRAY NOTIFY TEMPLATE WHATSAPP ');
+ $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;
- } // $Whatsapp Template Name
- } // for loop
+ }
+ # EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP Closed
+
+ $history_child_where = ['fkid' => $history_parent_id,'id' => (int)$history_child_id];
+ $history_child_updatedata = ['receiving_status'=>$receiving_status,'result'=>$history_msg];
+ $history_child_statement = $NotificationModel->update_notification_history_child($history_child_updatedata,$history_child_where);
+ $this->logger->info($history_child_statement);
+
+ $history_parent_statement = $NotificationModel->update_notification_history_parent_status(['status' => 1],$history_parent_id,$campaign_id);
+ $this->logger->info($history_parent_statement);
+ }
+ # Loop Closed
+
}
+ # getExpCustomerDetail fns Closed
################################################################
# Auto Scheduled Notification
@@ -500,6 +613,7 @@ class Notifications extends BaseController
## notification campaign details
public function processScheduledNotifications(){
$this->logger->info("Auto Scheduled Notification Started");
+ $model = new NotificationModel();
#step 1 get scheduled notification details
$notification_campaign_result = $this->getScheduledNotificationDetails();
$this->logger->info("Auto Scheduled Campaign Details Count = ".count($notification_campaign_result));
@@ -520,7 +634,11 @@ class Notifications extends BaseController
$this->logger->info("Auto Scheduled Template Details TID = ".$single_campaign['template_id']);
if(count($template))
{
-
+ #step 2.1
+ $history_parents_data = ['campaign_id' => $single_campaign['campaign_id'],'status' => 0];
+ $history_parent_id = $model->save_notification_history_parents($history_parents_data);
+ $single_campaign['history_parent_id'] = $history_parent_id;
+
#step 3 execute the customer group query and return customer details
$customer_details = $this->getCustomerDetails($single_campaign['group_id']);
$sent_customer_details = [];
@@ -528,20 +646,34 @@ class Notifications extends BaseController
{
foreach($customer_details as $customer)
{
+
+ #step 4 replace templates palceholders with data points
+ $notificationContent = $this->replaceTemplateWithDataPoints($template['message'],$customer);
+ $history_child_data = [
+ 'fkid' => $single_campaign['history_parent_id'],
+ 'customer_id' => $customer['customer_id'],
+ 'receiving_entity' => $single_campaign['mode'] == 'Email' ? $customer['email'] : $customer['mobile_no'],
+ 'receiving_status' => 0,
+ 'message' => $notificationContent];
+ $history_child_id = $model->save_notification_history_child($history_child_data);
//check wheather if notification send to the current customer already
if(!in_array($customer['customer_id'],$sent_customer_details))
{
- $this->logger->info("Auto Scheduled Customer CID = ".$customer['customer_id'].", CN = ".$customer['customer_name']);
- #step 4 replace templates palceholders with data points
- $notificationContent = $this->replaceTemplateWithDataPoints($template['message'],$customer);
-
+ $this->logger->info("Auto Scheduled Customer CID = ".$customer['customer_id'].", CN = ".$customer['customer_name']);
#step 5 send notification
$notification = new NotificationHelper();
if($single_campaign['mode'] == 'Email')
{
$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';
+ $receiving_status = isset($email_response['success']) ? 1 : 0;
$this->logger->info("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_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);
+ $this->logger->info($history_child_statement);
+
}
else
{
@@ -553,7 +685,13 @@ class Notifications extends BaseController
$params->message = $notificationContent;
$params->number = (int)'91' . $customer['mobile_no'];
$whatsapp_reponse = $notification->sendWhatsAppMessage($url, "POST", $params);
- $this->logger->info("Auto Scheduled Whatsapp CID = ".$customer['customer_id']." ".$whatsapp_reponse);
+ $this->logger->info("Auto Scheduled Whatsapp CID = ".$customer['customer_id']." ".$whatsapp_reponse['message']);
+ $history_child_where = ['fkid' => $single_campaign['history_parent_id'],'id' => (int)$history_child_id];
+
+ $history_child_updatedata = ['receiving_status'=>$whatsapp_reponse['receiving_status'],'result'=>strtolower(gettype($whatsapp_reponse)) == "string" ? $whatsapp_reponse : json_encode($whatsapp_reponse['reponse'])];
+ $history_child_statement = $model->update_notification_history_child($history_child_updatedata,$history_child_where);
+ $this->logger->info($history_child_statement);
+
}
array_push($sent_customer_details,$customer['customer_id']);
@@ -563,10 +701,13 @@ class Notifications extends BaseController
}
#step 6 update campaign status to 1
- $model = new NotificationModel();
- $data = ['status' => 1];
- $statement = $model->notification_campaign_status($data,$single_campaign['campaign_id']);
+ $statement = $model->update_notification_campaign_status(['status' => 1],$single_campaign['campaign_id']);
$this->logger->info($statement);
+
+ #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']);
+ $this->logger->info($history_parent_statement);
+
}
}
@@ -584,6 +725,7 @@ class Notifications extends BaseController
return $notification_campaign_result;
}
+
#step 2 get template details
function getTemplateDetails($template_id)
{
diff --git a/app/Helpers/NotificationHelper.php b/app/Helpers/NotificationHelper.php
index 1a78ebab..da34e98a 100644
--- a/app/Helpers/NotificationHelper.php
+++ b/app/Helpers/NotificationHelper.php
@@ -19,7 +19,7 @@ class NotificationHelper
{
$this->logger->info('Helper : Email Request Data type = '.gettype($records));
- $cc = isset($records['carboncopy']) ? $records['carboncopy'] : 'contact@vijayabharathambooks.com';
+ $cc = isset($records['carboncopy']) ? $records['carboncopy'] : '';
$bcc = isset($records['blindcarboncopy']) ? $records['blindcarboncopy'] : '';
try {
@@ -49,13 +49,13 @@ class NotificationHelper
$ccRecipients = explode(',', trim($cc));
$this->logger->info('Helper : Email carbon copy CC recipient = ' . implode(',', $ccRecipients));
if (!empty($ccRecipients)) {
- if (getenv('CI_ENVIRONMENT') == "production") {
+ if (getenv('CI_ENVIRONMENT') === "production") {
$this->email->setCC('contact@vijayabharathambooks.com');
}
$this->email->setCC($ccRecipients);
}
} else {
- if (getenv('CI_ENVIRONMENT') == "production") {
+ if (getenv('CI_ENVIRONMENT') === "production") {
$this->email->setCC('contact@vijayabharathambooks.com');
}
}
@@ -83,7 +83,7 @@ class NotificationHelper
public function sendWhatsAppMessage($url, $method, $data)
{
- $final_result = ""; // Initialize outside try-catch block
+ $final_result = []; // Initialize outside try-catch block
try {
$this->logger->info('Helper : Whatsapp');
@@ -121,15 +121,18 @@ class NotificationHelper
$result = json_decode($curl_exec);
if ($result->status === "error") {
+ $final_result['message'] = $result->message;
+ $final_result['receiving_status'] = 0 ;
$this->logger->error('Helper : Whatsapp Err occur = ' . $result->message);
throw new \Exception($result->message);
}
if ($result->status === "success") {
- $final_result = isset($result->message) ? (
+ $final_result['message'] = isset($result->message) ? (
(strtolower(gettype($result->message)) === 'string') ?
$result->message : "Sended Success"
) : " Message Not Sent. ";
+ $final_result['receiving_status'] = isset($result->message) ? ((strtolower(gettype($result->message)) === 'string') ? 0 : 1 ) : 0 ;
}
} else {
$curl_errno = curl_errno($curl);
@@ -140,9 +143,10 @@ class NotificationHelper
curl_close($curl);
} catch (\Exception $e) {
$this->logger->error('Helper : Whatsapp Exception Occur = ' . $e->getMessage());
- $final_result = "Exception Errno returned " . $e->getMessage() . "
";
+ $final_result['message'] = "Exception Errno returned " . $e->getMessage() . "
";
+ $final_result['receiving_status'] = 0 ;
}
-
+ $final_result['reponse'] = json_decode($curl_exec);
return $final_result;
}
diff --git a/app/Models/NotificationModel.php b/app/Models/NotificationModel.php
index cb66ae9f..a6b2f793 100644
--- a/app/Models/NotificationModel.php
+++ b/app/Models/NotificationModel.php
@@ -148,6 +148,10 @@ public function customerGroupQueryExecution($queries){
// echo "";
// die;
}
+// $query = "INSERT IGNORE INTO notification_history_children (fkid,customer_id,receiving_entry,message,result,sent_time)
+// VALUES (1, 1, 'somes@gmail2.com','mail msg',NULL,'2023-12-22 14:20:50'),
+// (1, 1, '9638527411','whatapp msg',NULL,'2023-12-22 14:20:50')";
+ // $result = $db->query($query)->getResultArray();
public function getExpDate()
{
$db = \Config\Database::connect();
@@ -183,7 +187,7 @@ public function customerGroupQueryExecution($queries){
}
}
- public function notification_campaign_status($data,$id){
+ public function update_notification_campaign_status($data,$id){
if($id != ''){
$where = ['isactive' => 1, 'status' => 0 ,'campaign_id'=>(int)$id];
if ($this->db->table('notification_campaign')->where($where)->update($data)) {
@@ -198,6 +202,71 @@ public function customerGroupQueryExecution($queries){
}
return $statement;
}
+
+ public function save_notification_history_parents($data){
+
+ $this->db->table('notification_history_parents')->insert($data);
+ $insertID = $this->db->insertID();
+ return $insertID;
+ }
+
+ public function update_notification_history_parent_status($data,$id,$campaign_id){
+ if($id != ''){
+ $where = ['id' => (int)$id, 'status' => 0 ,'campaign_id'=>(int)$campaign_id];
+ if ($this->db->table('notification_history_parents')->where($where)->update($data)) {
+ $affectedRows = $this->db->affectedRows();
+ $statement = $affectedRows > 0 ? 'Notification history parent Status has been updated successfully. Aff Row'.$affectedRows." NHPID = " .$id : 'Notification history parent Status Update failed. Bcoz Already Affected Count = '.$affectedRows.". NHPID = " .$id ;
+ } else {
+ $statement = "Notification history parent Status Update failed. NHPID = " .$id;
+ }
+ }
+ else{
+ $statement = "Notification history parent Status Update failed. Bcoz Not Found NHPID";
+ }
+ return $statement;
+ }
+
+
+ public function save_notification_history_child($data){
+ // $this->db->ignore(true); // Enable "INSERT IGNORE" behavior
+ // $this->db->table('notification_history_children')->insert($data);
+ // $insertID = $this->db->insertID(); // Get the last inserted ID
+ // return $insertID;
+ // $insert_query = $this->db->insert_string('notification_history_children', $data);
+ // $insert_query = str_replace('INSERT INTO', 'INSERT IGNORE INTO', $insert_query);
+ // $this->db->query($insert_query);
+ // $insertID = $this->db->insertID(); // Get the last inserted ID
+ // return $insertID;
+
+ $table = 'notification_history_children';
+ $insert_query = "INSERT IGNORE INTO $table (" . implode(', ', array_keys($data)) . ") VALUES (" . rtrim(str_repeat('?, ', count($data)), ', ') . ")";
+ $this->db->query($insert_query, array_values($data));
+ // print_r($this->db->getLastQuery());die;
+ $insertID = $this->db->insertID();
+ return $insertID;
+ }
+
+ public function update_notification_history_child($data, $where){
+
+ $id = isset($where['id']) ? $where['id'] : "";
+
+ if ($id != '') {
+ $updateResult = $this->db->table('notification_history_children')->where($where)->update($data);
+ // print_r($this->db->getLastQuery());die;
+ if ($updateResult) {
+ $affectedRows = $this->db->affectedRows();
+ $statement = 'Notification history children has been updated successfully. Aff Row ' . $affectedRows . ' NHCID = ' . $id;
+ } else {
+ $statement = 'Notification history children Update failed. NHCID = ' . $id;
+ }
+ } else {
+ $statement = 'Notification history children Update failed. Bcoz Not Found NHCID';
+ }
+
+ return $statement;
+ }
+
+
}
diff --git a/app/Views/notifications_form.php b/app/Views/notifications_form.php
index fa9e5f09..c46ffe93 100644
--- a/app/Views/notifications_form.php
+++ b/app/Views/notifications_form.php
@@ -52,7 +52,9 @@
-
+