Merge branch 'uat'
This commit is contained in:
commit
37dc008a4e
@ -28,17 +28,21 @@ class Email extends BaseConfig
|
||||
/**
|
||||
* SMTP Server Address
|
||||
*/
|
||||
public string $SMTPHost = 'smtp.zoho.in';
|
||||
// public string $SMTPHost = 'smtp.zoho.in';
|
||||
public string $SMTPHost = 'smtp.gmail.com';
|
||||
|
||||
/**
|
||||
* SMTP Username
|
||||
*/
|
||||
public string $SMTPUser = 'web@vijayabharathambooks.com';
|
||||
// public string $SMTPUser = 'web@vijayabharathambooks.com';
|
||||
public string $SMTPUser = 'venbalap08@gmail.com';
|
||||
|
||||
|
||||
/**
|
||||
* SMTP Password
|
||||
*/
|
||||
public string $SMTPPass = 'Sz9VueQ2iLgH';
|
||||
//public string $SMTPPass = 'Sz9VueQ2iLgH';
|
||||
public string $SMTPPass = 'bqhvujeauokgcdxt';
|
||||
|
||||
/**
|
||||
* SMTP Port
|
||||
|
||||
@ -175,7 +175,7 @@ $routes->post("campaign_creation_insert", "Notifications::campaign_creation_inse
|
||||
|
||||
# Auto run process routes
|
||||
$routes->get('process_scheduled_notifications/', 'Notifications::processScheduledNotifications');
|
||||
$routes->get('process_customergroup_notifications/(:any)/(:any)', 'Notifications::customer_group_notification/$1/$2');
|
||||
// $routes->get('process_customergroup_notifications/(:any)/(:any)', 'Notifications::customer_group_notification/$1/$2');
|
||||
$routes->get('acknowlegdement', 'Notifications::noifications_acknowlegdement');
|
||||
$routes->get('subscription_inactive', 'Invoice::subscription_inactive');
|
||||
|
||||
|
||||
@ -324,6 +324,7 @@ class Notifications extends BaseController
|
||||
if ($id === '0') {
|
||||
$this->logger->error("Template Creation: In Add Page");
|
||||
$data['page_name'] = 'Add Template';
|
||||
$data['template_id'] = (int)$id;
|
||||
$data['template_details'] = [];
|
||||
} elseif ($id !== '0') {
|
||||
$this->logger->error("Template Creation: In Edit Page ID =" . $id);
|
||||
@ -331,6 +332,7 @@ class Notifications extends BaseController
|
||||
$model->setTable('templates');
|
||||
$where = ['template_id' => (int)$id];
|
||||
$result = $model->where($where)->findAll();
|
||||
$data['template_id'] = (int)$id;
|
||||
$data['template_details'] = !empty($result[0]) ? $result[0] : [];
|
||||
}
|
||||
// print_r($data['template_details']);die();
|
||||
@ -518,8 +520,8 @@ class Notifications extends BaseController
|
||||
'campaign_id' => $id,
|
||||
'campaign_name' => $this->request->getPost('campaign_name'),
|
||||
'template_id' => $this->request->getPost('template_id'),
|
||||
'scheduled_date' => $this->request->getPost('scheduled_date'),
|
||||
'scheduled_time' => $this->request->getPost('scheduled_time') != "" ? $this->request->getPost('scheduled_time') : NULL,
|
||||
// 'scheduled_date' => $this->request->getPost('scheduled_date'),
|
||||
// 'scheduled_time' => $this->request->getPost('scheduled_time') != "" ? $this->request->getPost('scheduled_time') : NULL,
|
||||
'mode' => $this->request->getPost('mode'),
|
||||
'group_id' => serialize($this->request->getPost('group_id')),
|
||||
'isactive' => $isactive,
|
||||
@ -527,21 +529,27 @@ class Notifications extends BaseController
|
||||
'updated_by' => $session_uid
|
||||
];
|
||||
if ($id != "") {
|
||||
// id has value means updation process.
|
||||
$notify_mod = new NotificationModel();
|
||||
$notify_mod->setTable('notification_campaign');
|
||||
$where = ['campaign_id' => (int)$id];
|
||||
$isactive_check = $notify_mod->where($where)->select('isactive')->first();
|
||||
if ((int)$isactive_check['isactive'] === 0 && $isactive === 0) {
|
||||
$statement['success'] = 'Notification Campaign already In-Active. can`t able to update.';
|
||||
$statement['error'] = "";
|
||||
$statement['success'] = '';
|
||||
$statement['error'] = 'Notification Campaign already In-Active. can`t able to update.';
|
||||
$statement['log'] = "Notification Campaign: already inactive status.Can`t able to update, Notification Campaign Group ID = " . $id;
|
||||
} else {
|
||||
$statement = $model->saveDetails($data, 'campaign_id', 'notification_campaign');
|
||||
}
|
||||
} else {
|
||||
// id has no value means insertion process.
|
||||
$statement = $model->saveDetails($data, 'campaign_id', 'notification_campaign');
|
||||
}
|
||||
|
||||
if ($statement['success']) {
|
||||
$tid = $data['template_id'];
|
||||
$cid = $data['campaign_id'] ? $data['campaign_id'] : $statement['insert_id'];
|
||||
$this->scheduledNotifications($tid,$cid,1);
|
||||
session()->setFlashdata('success', $statement['success']);
|
||||
$this->logger->error($statement['log']);
|
||||
} else if ($statement['error']) {
|
||||
@ -562,7 +570,7 @@ class Notifications extends BaseController
|
||||
################################################################
|
||||
public function getExpCustomerDetail($window_time = null)
|
||||
{
|
||||
echo "hi";
|
||||
echo "Hi, ";
|
||||
# Step 1: add the days to retrive the data//
|
||||
$providedDate = date('Y-m-d');
|
||||
$newDate = date('Y-m-d', strtotime($providedDate . ' + ' . $window_time . ' days'));
|
||||
@ -579,7 +587,7 @@ class Notifications extends BaseController
|
||||
|
||||
# Step 3: Replace the placeholder WINDOW_TIME with the user-provided value
|
||||
$modifiedQuery = str_replace('WINDOW_TIME', $window_time, $ExpCustomerDetail);
|
||||
// print_r($modifiedQuery);die;
|
||||
// print_r($modifiedQuery);die;
|
||||
if (empty($modifiedQuery)) {
|
||||
$this->logger->error('There is no sub query');
|
||||
return;
|
||||
@ -611,6 +619,7 @@ class Notifications extends BaseController
|
||||
if ($status === 'Approved') {
|
||||
# EXPIRAY_NOTIFY_TEMPLATE_EMAIL
|
||||
$emailTemplateName = $NotificationModel->getTempName(EXPIRAY_NOTIFY_TEMPLATE_EMAIL);
|
||||
echo "Person Name :".$fullName." <br>";
|
||||
if (count($emailTemplateName) && !empty($emailTemplateName)) {
|
||||
$campaign_id = 1;
|
||||
# Insertion on History Email Means Campaign ID 1 Hardcoded
|
||||
@ -619,16 +628,29 @@ class Notifications extends BaseController
|
||||
|
||||
# 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);
|
||||
$emailContent = str_replace("{EXPIRY_DATE}", $expirydate, $emailContent);
|
||||
if (isset($fullName)) {
|
||||
$emailContent = str_replace("{USER_NAME}", $fullName, $emailContent);
|
||||
}
|
||||
if (isset($schemename)) {
|
||||
$emailContent = str_replace("{SCHEME_NAME}", $schemename, $emailContent);
|
||||
}
|
||||
if (isset($expirydate)) {
|
||||
$emailContent = str_replace("{EXPIRY_DATE}", $expirydate, $emailContent);
|
||||
}
|
||||
if (isset($customerId)) {
|
||||
$emailContent = str_replace("{RENEWAL_LINK}", base_url() . 'subscription_renewal/' . $customerId, $emailContent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$emailData = [
|
||||
'template_name' => 'EXPIRAY_NOTIFY_TEMPLATE_EMAIL',
|
||||
'recipient_email' => $row['email'],
|
||||
'subject' => 'Your Subscription Expiry Notification',
|
||||
'description' => $emailContent,
|
||||
];
|
||||
|
||||
|
||||
$history_child_data = [ 'fkid' => $history_parent_id,
|
||||
'customer_id' => $customerId,
|
||||
'receiving_entity' => $row['email'],
|
||||
@ -703,10 +725,18 @@ class Notifications extends BaseController
|
||||
|
||||
# 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);
|
||||
|
||||
if (isset($fullName)) {
|
||||
$whatsappContent = str_replace("{USER_NAME}", $fullName, $whatsappContent);
|
||||
}
|
||||
if (isset($schemename)) {
|
||||
$whatsappContent = str_replace("{SCHEME_NAME}", $schemename, $whatsappContent);
|
||||
}
|
||||
if (isset($expirydate)) {
|
||||
$whatsappContent = str_replace("{EXPIRY_DATE}", $expirydate, $whatsappContent);
|
||||
}
|
||||
if (isset($customerId)) {
|
||||
$whatsappContent = str_replace("{RENEWAL_LINK}", base_url() . 'subscription_renewal/' . $customerId, $whatsappContent);
|
||||
}
|
||||
# Step 8: Insertion on History Child for whatsapp
|
||||
$history_child_data = [ 'fkid' => $history_parent_id,
|
||||
'customer_id' => $customerId,
|
||||
@ -779,17 +809,24 @@ class Notifications extends BaseController
|
||||
################################################################
|
||||
## notification campaign details
|
||||
public function processScheduledNotifications(){
|
||||
$this->scheduledNotifications(0,0,0);
|
||||
// parameter are template_id is zero , campaign_id is zero , dummy is zero
|
||||
}
|
||||
|
||||
public function scheduledNotifications($tid,$cid,$dummyvariable){
|
||||
$this->logger->error("Auto Scheduled Notification Started");
|
||||
$model = new NotificationModel();
|
||||
#step 1 get scheduled notification details
|
||||
$notification_campaign_result = $this->getScheduledNotificationDetails(0,0);
|
||||
$notification_campaign_result = $this->getScheduledNotificationDetails($tid,$cid);
|
||||
$this->logger->error("Auto Scheduled Campaign Details Count = ".count($notification_campaign_result));
|
||||
if(!count($notification_campaign_result))
|
||||
{
|
||||
$this->logger->error("No Auto Scheduled Notification in DB,exiting...!");
|
||||
$this->logger->error("Auto Scheduled Notification Ends");
|
||||
echo "No Scheduled Data Founded"."<br>";
|
||||
exit();
|
||||
if($dummyvariable == 0){
|
||||
echo "No Scheduled Data Founded"."<br>";
|
||||
exit();
|
||||
}
|
||||
}
|
||||
// echo "Notification campaign Result Array in count = ".count($notification_campaign_result)."<br>";
|
||||
//looping multiple notification campaign
|
||||
@ -797,7 +834,9 @@ class Notifications extends BaseController
|
||||
{
|
||||
foreach($notification_campaign_result as $index => $single_campaign)
|
||||
{
|
||||
echo "Notification Campaign Name = ".$single_campaign['campaign_name']."<br>";
|
||||
if($dummyvariable == 0){
|
||||
echo "Notification Campaign Name = ".$single_campaign['campaign_name']."<br>";
|
||||
}
|
||||
#step 2 get template details
|
||||
$template = $this->getTemplateDetails($single_campaign['template_id']);
|
||||
$customer_details = $this->getCustomerDetails($single_campaign['group_id']);
|
||||
@ -850,7 +889,7 @@ class Notifications extends BaseController
|
||||
$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));
|
||||
$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->error("Auto Scheduled Email CID = ".$customer['customer_id']." ".$mail_log);
|
||||
@ -888,12 +927,12 @@ class Notifications extends BaseController
|
||||
}
|
||||
// #step 6 update campaign status to 1
|
||||
$statement = $model->update_notification_campaign_status(['status' => 1],$single_campaign['campaign_id']);
|
||||
echo "Final Campaign Status = ".$statement."<br>";
|
||||
if($dummyvariable == 0){ echo "Final Campaign Status = ".$statement."<br>"; }
|
||||
$this->logger->error($statement);
|
||||
|
||||
#step 7 update history parent status to 1
|
||||
$history_parent_statement = $model->update_notification_history_parent_status(['status' => 1],$history_parent_id,$single_campaign['campaign_id']);
|
||||
echo "Final Acknowlegdement = ".$history_parent_statement."<br>";
|
||||
if($dummyvariable == 0){ echo "Final Acknowlegdement = ".$history_parent_statement."<br>"; }
|
||||
$this->logger->error($history_parent_statement);
|
||||
|
||||
}
|
||||
@ -974,10 +1013,18 @@ class Notifications extends BaseController
|
||||
// print_r($dataPointsArray['customer_name']);
|
||||
// echo $originalTemplate;
|
||||
$notificationContent = $originalTemplate;
|
||||
$notificationContent = str_replace("{USER_NAME}", $dataPointsArray["customer_name"], $notificationContent);
|
||||
$notificationContent = str_replace("{SCHEME_NAME}", $dataPointsArray["scheme_name"], $notificationContent);
|
||||
$notificationContent = str_replace("{EXPIRY_DATE}", $dataPointsArray["formatted_due_date"], $notificationContent);
|
||||
$notificationContent = str_replace("{RENEWAL_LINK}", base_url() . 'subscription_renewal/' . $dataPointsArray["customer_id"], $notificationContent);
|
||||
if (isset($dataPointsArray["customer_name"])) {
|
||||
$notificationContent = str_replace("{USER_NAME}", $dataPointsArray["customer_name"], $notificationContent);
|
||||
}
|
||||
if (isset($dataPointsArray["scheme_name"])) {
|
||||
$notificationContent = str_replace("{SCHEME_NAME}", $dataPointsArray["scheme_name"], $notificationContent);
|
||||
}
|
||||
if (isset($dataPointsArray["formatted_due_date"])) {
|
||||
$notificationContent = str_replace("{EXPIRY_DATE}", $dataPointsArray["formatted_due_date"], $notificationContent);
|
||||
}
|
||||
if (isset($dataPointsArray["customer_id"])) {
|
||||
$notificationContent = str_replace("{RENEWAL_LINK}", base_url() . 'subscription_renewal/' . $dataPointsArray["customer_id"], $notificationContent);
|
||||
}
|
||||
return $notificationContent;
|
||||
}
|
||||
############## Auto Scheduled Notification Ends ################
|
||||
@ -993,119 +1040,4 @@ class Notifications extends BaseController
|
||||
$this->render_page('noifications_acknowlegdement', $data);
|
||||
}
|
||||
############## Notification Acknowlegdement Ends ################
|
||||
public function customer_group_notification($tid,$cid){
|
||||
$this->logger->error("Customer Group Notification Started");
|
||||
|
||||
$this->logger->error("Customer Group Notification Ended");
|
||||
$model = new NotificationModel();
|
||||
#step 1 get scheduled notification details
|
||||
$notification_campaign_result = $this->getScheduledNotificationDetails($tid,$cid);
|
||||
// print_r($notification_campaign_result);
|
||||
//looping multiple notification campaign
|
||||
if(count($notification_campaign_result))
|
||||
{
|
||||
foreach($notification_campaign_result as $index => $single_campaign)
|
||||
{
|
||||
echo "Notification Campaign Name = ".$single_campaign['campaign_name']."<br>";
|
||||
#step 2 get template details
|
||||
$template = $this->getTemplateDetails($single_campaign['template_id']);
|
||||
$customer_details = $this->getCustomerDetails($single_campaign['group_id']);
|
||||
if(count($template) && count($customer_details))
|
||||
{
|
||||
#step 3 execute the customer group query and return customer details
|
||||
$sent_customer_details = [];
|
||||
if(count($customer_details))
|
||||
{
|
||||
#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;
|
||||
|
||||
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 = [
|
||||
'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);
|
||||
if(!in_array($customer['customer_id'],$sent_customer_details))
|
||||
{
|
||||
$this->logger->error("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->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_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->error($history_child_statement);
|
||||
|
||||
}
|
||||
if($single_campaign['mode'] == 'Whatsapp')
|
||||
{
|
||||
$params = (object) Null;
|
||||
$url = SEND_WAAI_URL;
|
||||
$params->type = "text";
|
||||
$params->instance_id = $_ENV['WAAI_INSTANCE'];
|
||||
$params->access_token = $_ENV['WAAI_TOKEN'];
|
||||
$params->message = strip_tags(ltrim($notificationContent));
|
||||
$params->number = (int)'91' . $customer['mobile_no'];
|
||||
$whatsapp_reponse = $notification->sendWhatsAppMessage($url, "POST", $params);
|
||||
$whatsapp_reponse_msg = strtolower(gettype($whatsapp_reponse)) == "string" ? $whatsapp_reponse : json_encode($whatsapp_reponse['reponse']);
|
||||
// echo "Whatsapp Response = ".$whatsapp_reponse_msg."<br>";
|
||||
$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_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);
|
||||
$this->logger->error($history_child_statement);
|
||||
|
||||
}
|
||||
|
||||
array_push($sent_customer_details,$customer['customer_id']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
#step 6 update campaign status to 1
|
||||
$statement = $model->update_notification_campaign_status(['status' => 0],$single_campaign['campaign_id']);
|
||||
echo "Final Campaign Status = ".$statement."<br>";
|
||||
$this->logger->error($statement);
|
||||
|
||||
#step 7 update history parent status to 1
|
||||
$history_parent_statement = $model->update_notification_history_parent_status(['status' => 1],$history_parent_id,$single_campaign['campaign_id']);
|
||||
echo "Final Acknowlegdement = ".$history_parent_statement."<br>";
|
||||
$this->logger->error($history_parent_statement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -148,6 +148,66 @@ class NotificationHelper
|
||||
return $final_result;
|
||||
}
|
||||
|
||||
// public function send_whatsapp_message($to , $doc_url)
|
||||
// {
|
||||
// $url = 'https://graph.facebook.com/v20.0/355752820961010/messages';
|
||||
// $headers = [
|
||||
// 'Authorization: Bearer '.$_ENV['whatsAppToken'],
|
||||
// 'Content-Type: application/json'
|
||||
// ];
|
||||
|
||||
// $templateName = 'bbsigndoc';
|
||||
// $languageCode = 'en';
|
||||
// $parsedUrl = parse_url($doc_url, PHP_URL_QUERY);
|
||||
|
||||
// $data = [
|
||||
// 'messaging_product' => 'whatsapp',
|
||||
// 'to' => $to,
|
||||
// 'type' => 'template',
|
||||
// 'template' => [
|
||||
// 'name' => $templateName,
|
||||
// 'language' => [
|
||||
// 'code' => $languageCode
|
||||
// ],
|
||||
// 'components' => [
|
||||
// [
|
||||
// 'type' => 'body',
|
||||
// ],
|
||||
// [
|
||||
// 'type' => 'button',
|
||||
// 'sub_type' => 'url',
|
||||
// 'index' => 0,
|
||||
// 'parameters' => [
|
||||
|
||||
// [
|
||||
// 'type' => 'text',
|
||||
// 'text' => $parsedUrl
|
||||
// ]
|
||||
// ]
|
||||
// ]
|
||||
// ]
|
||||
// ]
|
||||
// ];
|
||||
|
||||
|
||||
// $ch = curl_init();
|
||||
// curl_setopt($ch, CURLOPT_URL, $url);
|
||||
// curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
// curl_setopt($ch, CURLOPT_POST, true);
|
||||
// curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
|
||||
|
||||
// $response = curl_exec($ch);
|
||||
// $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
// curl_close($ch);
|
||||
|
||||
// return [
|
||||
// 'status_code' => $statusCode,
|
||||
// 'response' => json_decode($response, true)
|
||||
// ];
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -43,7 +43,7 @@ class NotificationModel extends Model
|
||||
->join('users as U1', 'U1.user_id = T.created_by', 'left')
|
||||
->join('users as U2', 'U2.user_id = T.updated_by', 'left')
|
||||
->select('T.template_id,T.template_name,T.mode,T.created_on,T.created_by,T.updated_on,T.updated_by,DATE_FORMAT(T.created_on, "%d/%m/%Y %h:%i %p") AS formatted_created_on,CONCAT_WS(" ", U1.first_name, U1.last_name) as created_by_name,CONCAT_WS(" ", U2.first_name, U2.last_name) as updated_by_name,T.isactive')
|
||||
->whereNotIn('T.template_name',array('EXPIRAY_NOTIFY_TEMPLATE_EMAIL','EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP'))
|
||||
// ->whereNotIn('T.template_name',array('EXPIRAY_NOTIFY_TEMPLATE_EMAIL','EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP'))
|
||||
->get()->getResultArray();
|
||||
}
|
||||
|
||||
@ -58,10 +58,13 @@ class NotificationModel extends Model
|
||||
$statement['success'] = $statement_string.' has been updated successfully.';
|
||||
$statement['error'] = "";
|
||||
$statement['log'] = $statement_string.": has been updated successfully. Updated ".$pk_name." = " .$id." Affected Rows = ".$affectedRows;
|
||||
$statement['insert_id'] = $id;
|
||||
|
||||
} else {
|
||||
$statement['success'] = "";
|
||||
$statement['error'] = $statement_string.' update failed. Please try again.';
|
||||
$statement['log'] = $statement_string.": Err Failed to update ID = " .$id ;
|
||||
$statement['insert_id'] = $id;
|
||||
}
|
||||
}else{
|
||||
unset($data['updated_by']);
|
||||
@ -70,10 +73,12 @@ class NotificationModel extends Model
|
||||
$statement['success'] = $statement_string.' has been Inserted successfully.';
|
||||
$statement['error'] = "";
|
||||
$statement['log'] = $statement_string.": has been added successfully. Inserted ID = " .$insertID ;
|
||||
$statement['insert_id'] = $insertID;
|
||||
} else {
|
||||
$statement['success'] = "";
|
||||
$statement['error'] = $statement_string." could not be added. Please try again..";
|
||||
$statement['log'] = $statement_string.": Err could not be added. Please try again.";
|
||||
$statement['insert_id'] = "";
|
||||
}
|
||||
}
|
||||
return $statement;
|
||||
@ -157,7 +162,7 @@ public function customerGroupQueryExecution($queries){
|
||||
{
|
||||
$db = \Config\Database::connect();
|
||||
|
||||
$query = "SELECT * FROM customer_groups WHERE group_name = 'EXPIRYDATE'";
|
||||
$query = "SELECT * FROM customer_groups WHERE group_name = 'EXPIRYDATE' AND isactive = 1";
|
||||
|
||||
$result = $db->query($query)->getResultArray();
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
<th>Template Name</th>
|
||||
<th>Group Name</th>
|
||||
<th>Total Customer</th>
|
||||
<th>Scheduled at</th>
|
||||
<!-- <th>Scheduled at</th> -->
|
||||
<th>Created at</th>
|
||||
<th>Created by</th>
|
||||
<th>Status</th>
|
||||
@ -58,7 +58,7 @@
|
||||
<td data-order="<?= $c['template_name']; ?>"><?= $c['template_name']; ?></td>
|
||||
<td data-order="<?= $c['group_name']; ?>"><?= $c['group_name']; ?></td>
|
||||
<td data-order="<?= $c['customer_group_count']; ?>"><?= $c['customer_group_count']; ?></td>
|
||||
<td><?= $scheduled_date." ".$scheduled_time; ?></td>
|
||||
<!-- <td></td> -->
|
||||
<td data-order="<?= $c['formatted_created_on']; ?>"><?= $c['formatted_created_on']; ?></td>
|
||||
<td data-order="<?= $c['created_by_name']; ?>"><?= $c['created_by_name']; ?></td>
|
||||
<td data-order="<?= $message; ?>"><span class="<?php echo $class; ?>"><?php echo $message; ?></span></td>
|
||||
@ -66,7 +66,7 @@
|
||||
<a href="<?= base_url()."campaign_creation_form/".$c['campaign_id']; ?>" class="edit-button" title="Click to Edit Campaign" ><i class="ri-pencil-line"></i></a>
|
||||
<?php if ($c['isactive']) { ?>
|
||||
<a href="<?= base_url() . "campaign_creation_delete/".$c['campaign_id']; ?>" class="delete-button" title="Click to Delete Campaign" ><i class="ri-delete-bin-line"></i></a>
|
||||
<a href="<?= base_url()."process_customergroup_notifications/".$c['template_id']."/".$c['campaign_id']; ?>" class="send-button" title="Send Now" ><i class="ri-mail-send-fill"></i></a>
|
||||
<!-- <a href="<?= base_url()."process_customergroup_notifications/".$c['template_id']."/".$c['campaign_id']; ?>" class="send-button" title="Send Now" ><i class="ri-mail-send-fill"></i></a> -->
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@ -39,7 +39,7 @@
|
||||
</div>
|
||||
<div class="form-group col-md-8">
|
||||
<!-- <label for="scheduled" class="col-form-label">Scheduled Date/Time<span class="text-danger"> *</span></label> -->
|
||||
<div class="row">
|
||||
<!-- <div class="row">
|
||||
<div class="col-6">
|
||||
<label for="scheduled_date" class="col-form-label">Scheduled Date<span class="text-danger"> *</span></label>
|
||||
<input class="form-control" type="date" name="scheduled_date" id="example-date" value="<?= isset($campaign_details['scheduled_date']) ? $campaign_details['scheduled_date'] : '' ?>" required>
|
||||
@ -50,7 +50,7 @@
|
||||
<input class="form-control" type="time" name="scheduled_time" id="example-time" value="<?= isset($campaign_details['scheduled_time']) ? $campaign_details['scheduled_time'] : '' ?>" required>
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="load_templateid" class="col-form-label">Template<span class="text-danger"> *</span></label>
|
||||
@ -83,7 +83,7 @@
|
||||
<?php } ?>
|
||||
<div class="form-group text-right m-b-0">
|
||||
<button class="btn btn-success waves-effect waves-light mr-1" type="submit" id="submitBtn">
|
||||
Submit
|
||||
Send now
|
||||
</button>
|
||||
<button type="reset" class="btn btn-primary waves-effect mr-1">
|
||||
Reset
|
||||
|
||||
@ -147,7 +147,9 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php $tempinx = 0;
|
||||
// echo "<pre>";
|
||||
// print_r($expiring_membership);
|
||||
// echo "</pre>";
|
||||
if(!empty($expiring_membership)):
|
||||
foreach ($expiring_membership as $e) :
|
||||
$daysincount = (int)$e['countdays'];
|
||||
@ -163,11 +165,23 @@
|
||||
<td><span class="badge badge-success badge-pill"><?= $daysincountstring; ?></span> <span class="font-13"><br><?= $e['to_subscription_date_format']; ?></span></td>
|
||||
<td>
|
||||
<?php
|
||||
$startDate = date('d/m/Y', strtotime($e['from_subscription']));
|
||||
$endDate = date('d/m/Y', strtotime($e['to_subscription']));
|
||||
|
||||
$notifications = $e['notifications'];
|
||||
$lastNotification = end($notifications);
|
||||
$emailNotifications = array_filter($notifications, function($notification) {
|
||||
return $notification['mode'] === 'Email';
|
||||
});
|
||||
|
||||
$lastNotification = end($emailNotifications);
|
||||
$lastStartDateTime = ($lastNotification && isset($lastNotification['start_date_time'])) ? $lastNotification['start_date_time'] : '';
|
||||
$startDateTime = $lastStartDateTime ? $lastStartDateTime : '';
|
||||
echo ($startDateTime) ? date('d/m/Y', strtotime($startDateTime)) : '';
|
||||
$startDateTime = $lastStartDateTime ? date('d/m/Y', strtotime($lastStartDateTime)) : '';
|
||||
|
||||
if($lastNotification['receiving_status']){
|
||||
if ($startDateTime >= $startDate && $startDateTime <= $endDate) {
|
||||
echo $startDateTime ;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
/*
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="templatename" class="col-form-label">Template Name<span class="text-danger"> *</span></label>
|
||||
<input type="text" class="form-control" id="templatename" name="templatename" value="<?= isset($template_details['template_name']) ? $template_details['template_name'] : '' ?>" placeholder="Template Name" required />
|
||||
<input type="text" class="form-control" id="templatename" name="templatename" value="<?= isset($template_details['template_name']) ? $template_details['template_name'] : '' ?>" placeholder="Template Name" <?php echo ($template_id == 1 || $template_id == 2) ? 'readonly' : 'required'; ?> />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user