diff --git a/app/Controllers/Notifications.php b/app/Controllers/Notifications.php index d00b550d..b74d2919 100755 --- a/app/Controllers/Notifications.php +++ b/app/Controllers/Notifications.php @@ -19,6 +19,7 @@ class Notifications extends BaseController if($records['mode'] == 'Email'){ helper('notification'); $notification = new NotificationHelper(); + $records['description'] = $records['maildescription']; $data = $notification->sendEmail($records); $parents_status = 0; $receiving_status = 0; @@ -67,17 +68,20 @@ class Notifications extends BaseController $params->group_id = $records['group_id']; } else { session()->setFlashdata('error', 'Group Id Missing Please Try again..'); + $data['page_name'] = 'Custom Notifications'; $this->render_page('notifications_form', $data); return; } }else if ($records['categories'] == 'SEND_WAAI_URL') { if ($records['mobile'] == "") { session()->setFlashdata('error', 'Mobile Number Missing Please Try again..'); + $data['page_name'] = 'Custom Notifications'; $this->render_page('notifications_form', $data); return; } } else { session()->setFlashdata('error', 'Please Choose your Category..'); + $data['page_name'] = 'Custom Notifications'; $this->render_page('notifications_form', $data); return; } @@ -89,6 +93,7 @@ class Notifications extends BaseController $params->type = "media"; } else { session()->setFlashdata('error', 'Media Url Missing Please Try again..'); + $data['page_name'] = 'Custom Notifications'; $this->render_page('notifications_form', $data); return; } @@ -98,12 +103,14 @@ class Notifications extends BaseController if (empty($doc_details)) { session()->setFlashdata('error', 'Please select a file to upload.'); + $data['page_name'] = 'Custom Notifications'; $this->render_page('notifications_form', $data); return; } if (!$doc_details->isValid() || $doc_details->getClientMimeType() !== 'image/jpeg') { session()->setFlashdata('error', 'Please upload a valid JPEG image.'); + $data['page_name'] = 'Custom Notifications'; $this->render_page('notifications_form', $data); return; } @@ -113,6 +120,7 @@ class Notifications extends BaseController if ($doc_name === '') { $this->logger->error("Err on upload: name not found"); session()->setFlashdata('error', 'Document name not found. Please try again.'); + $data['page_name'] = 'Custom Notifications'; $this->render_page('notifications_form', $data); return; } @@ -207,22 +215,26 @@ class Notifications extends BaseController session()->setFlashdata("success","Message : Sent Success (". $sended_number_count." / ".$total_number_count." )"); $this->logger->error("Whatsapp : Final ==> ".$sended_number_count." Sended out of ".$total_number_count." ( Not sended numbers count ".$not_sended_number_count." ) "); } + $data['page_name'] = 'Custom Notifications'; $this->render_page('notifications_form', $data); return; }else{ session()->setFlashdata('error', 'Message : Mobile Not Founded'); $this->logger->error('Message : Mobile Not Founded'); + $data['page_name'] = 'Custom Notifications'; $this->render_page('notifications_form', $data); return; } }else{ session()->setFlashdata('error', 'Message : Mobile Field Empty'); - $this->logger->error('Message : Mobile Field Empty'); + $this->logger->error('Message : Mobile Field Empty'); + $data['page_name'] = 'Custom Notifications'; $this->render_page('notifications_form', $data); return; } } } + $data['page_name'] = 'Custom Notifications'; $this->render_page('notifications_form', $data); } @@ -803,7 +815,24 @@ class Notifications extends BaseController { foreach($customer_details as $customer) { - + + $customer['customer_name'] = isset($customer['customer_name']) + ? $customer['customer_name'] + : (isset($customer['first_name']) && isset($customer['last_name']) + ? $customer['first_name'] . ' ' . $customer['last_name'] + : ''); + $customer['scheme_name'] = isset($customer['scheme_name']) ? $customer['scheme_name'] : (isset($customer['title']) ? $customer['title'] : ""); + $formatted_due_date = ""; + + if(isset($customer['to_subscription'])){ + $dateObj = date_create($customer['to_subscription']); + $formatted_due_date = date_format($dateObj, 'd-m-Y'); + }else{ + $formatted_due_date = $customer['formatted_due_date']; + } + $customer['formatted_due_date'] = $formatted_due_date; + + #step 4 replace templates palceholders with data points $notificationContent = $this->replaceTemplateWithDataPoints($template['message'],$customer); $history_child_data = [ @@ -879,15 +908,21 @@ class Notifications extends BaseController function getScheduledNotificationDetails() { $model = new NotificationModel(); - $today = date('Y-m-d'); - $currentTime = date('H:i:s'); - $endTime = date('H:i:s', strtotime('+30 minutes')); - $where = ['scheduled_date' => $today,'isactive' => 1, - 'scheduled_time >=' => $currentTime, - 'scheduled_time <=' => $endTime - ]; + $templateIds = [1, 2]; $model->setTable('notification_campaign'); - $notification_campaign_result = $model->where($where)->findAll(); + $notification_campaign_result = $model->whereIn('template_id', $templateIds)->where('isactive', 1)->findAll(); + + // $today = date('Y-m-d'); + // $currentTime = date('H:i:s'); + // $endTime = date('H:i:s', strtotime('+30 minutes')); + // $where = ['scheduled_date' => $today,'isactive' => 1, + // 'scheduled_time >=' => $currentTime, + // 'scheduled_time <=' => $endTime + // ]; + // $model->setTable('notification_campaign'); + // $notification_campaign_result = $model->where($where)->findAll(); + // echo $model->getLastQuery(); + return $notification_campaign_result; } diff --git a/app/Models/NotificationModel.php b/app/Models/NotificationModel.php index ffccbe8b..2a8569d9 100644 --- a/app/Models/NotificationModel.php +++ b/app/Models/NotificationModel.php @@ -20,6 +20,7 @@ class NotificationModel extends Model // ->findAll(); // } + /** This Function used for due_date_notifications routes */ public function getSubscriptionDueDetail($date){ // $now = date('Y-m-d'); // $lastWeek = date('Y-m-d', strtotime('+7 days')); diff --git a/app/Views/notifications_form.php b/app/Views/notifications_form.php index caa9bc9d..f681784a 100644 --- a/app/Views/notifications_form.php +++ b/app/Views/notifications_form.php @@ -76,7 +76,7 @@