invoice fixes : ps
This commit is contained in:
parent
a2522630ed
commit
15ac28a3bf
16
.env
16
.env
@ -146,13 +146,19 @@ APP_TIMEZONE = 'Asia/Kolkata'
|
||||
#--------------------------------------------------------------------
|
||||
# Whatsapp Access Token And Instance ID
|
||||
#--------------------------------------------------------------------
|
||||
# for Live
|
||||
WAAI_TOKEN = '6568739969f28'
|
||||
WAAI_INSTANCE = '656876690A9FD'
|
||||
# for Test
|
||||
# for Live Don't delete it
|
||||
# WAAI_TOKEN = '6568739969f28'
|
||||
# WAAI_INSTANCE = '656876690A9FD'
|
||||
|
||||
# Dummy Account by sanjeev created on 14th dec Testing purpose office mail ID (user name - Venba V1 - Krish12345)
|
||||
WAAI_TOKEN = '657af9bf8cad1'
|
||||
WAAI_INSTANCE = '657AFA5A01B21'
|
||||
|
||||
# for Test by sanjeev already created
|
||||
# WAAI_TOKEN = '65685e954bcf6'
|
||||
# WAAI_INSTANCE = '656863C54F90C'
|
||||
# for Old Test
|
||||
|
||||
# for Old Test by krishanan sir
|
||||
# WAAI_TOKEN = '652548474f4e4'
|
||||
# WAAI_INSTANCE = '65254894E4A88'
|
||||
|
||||
|
||||
@ -150,7 +150,7 @@ $routes->get('campaign_creation_delete/(:any)', 'Notifications::campaign_creatio
|
||||
$routes->post("campaign_creation_insert", "Notifications::campaign_creation_insert");
|
||||
|
||||
|
||||
$routes->get('auto_scheduled_notification/', 'Notifications::auto_scheduled_notification');
|
||||
$routes->get('process_scheduled_notifications/', 'Notifications::processScheduledNotifications');
|
||||
|
||||
# Api integration Routes
|
||||
$routes->post('api/(:any)', 'ApiIntegration::api_integration/$1');
|
||||
|
||||
@ -66,9 +66,8 @@ abstract class BaseController extends Controller
|
||||
// echo $requestedRoute;
|
||||
} else {
|
||||
if ($requestedRoute !== '/login' && $requestedRoute !== '/authenticate' && $uri->getSegment(1) != 'getExpCustomerDetail') {
|
||||
|
||||
$this->authData = $this->session_log();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -98,15 +97,15 @@ abstract class BaseController extends Controller
|
||||
$session_uid = get_logged_user_id();
|
||||
$session_uname = get_logged_name();
|
||||
if(!is_session_active()) {
|
||||
|
||||
header("Location: " . base_url("login"));
|
||||
exit();
|
||||
header("Location: " . base_url("login"));
|
||||
exit();
|
||||
}
|
||||
|
||||
$auth_model = new AuthenticationModel();
|
||||
|
||||
$details = $auth_model->getheringDetailsForHeader($session_uid);
|
||||
$data['company_name'] = $details[0]['site_name'];
|
||||
// $data['company_name'] = $details[0]['site_name'];
|
||||
$data['company_name'] = $details[0]['company_name'];
|
||||
$data['company_short_name'] = $details[0]['site_title'];
|
||||
$data['company_address'] = $details[0]['company_address'];
|
||||
$data['company_mobile_no'] = $details[0]['company_mobile_no'];
|
||||
|
||||
@ -417,7 +417,7 @@ class Customer extends BaseController
|
||||
'value' => serialize($request_data['values'])
|
||||
];
|
||||
// Initialize an empty array to store the conditions
|
||||
$conditions = array();
|
||||
$conditionStrings = array();
|
||||
|
||||
// Loop through the elements and build the conditions
|
||||
for ($i = 0; $i < count($request_data['column']); $i++) {
|
||||
@ -469,7 +469,9 @@ class Customer extends BaseController
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($conditionStrings)){
|
||||
throw new \Exception("can't able to save because Field Details Not Founded");
|
||||
}
|
||||
// Join the conditions with 'AND'
|
||||
$whereCondition = implode(' AND ', $conditionStrings);
|
||||
// echo "*************** whereCondition =>>> ";
|
||||
|
||||
685
app/Controllers/Notifications _old.php
Executable file
685
app/Controllers/Notifications _old.php
Executable file
@ -0,0 +1,685 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Helpers\NotificationHelper;
|
||||
use App\Models\NotificationModel;
|
||||
|
||||
class Notifications extends BaseController
|
||||
{
|
||||
|
||||
## Email Section :
|
||||
public function mail_custom_notifications()
|
||||
{
|
||||
$request = \Config\Services::request();
|
||||
if ($request->is('post')) {
|
||||
$records = $request->getVar();
|
||||
$records['template_name'] = "";
|
||||
helper('notification');
|
||||
$notification = new NotificationHelper();
|
||||
$data = $notification->sendEmail($records);
|
||||
if (isset($data['error'])) {
|
||||
session()->setFlashdata('error', 'Message: ' . $data['error']);
|
||||
}
|
||||
if (isset($data['success'])) {
|
||||
session()->setFlashdata('success', 'Message: ' . $data['success']);
|
||||
}
|
||||
}
|
||||
$data['page_name'] = 'Custom Notifications';
|
||||
$this->render_page('notifications_form', $data);
|
||||
}
|
||||
|
||||
public function whatsapp_custom_notifications()
|
||||
{
|
||||
$request = \Config\Services::request();
|
||||
if ($request->is('post')) {
|
||||
$records = $request->getVar();
|
||||
$params = (object) Null;
|
||||
|
||||
$this->logger->info("Whatsapp : sending message instance id = " . $_ENV['WAAI_INSTANCE'] . " - " . $_ENV['WAAI_TOKEN']);
|
||||
try {
|
||||
if ($records['categories'] == 'SEND_WAAI_GROUP_URL') {
|
||||
if ($records['group_id'] != "") {
|
||||
$params->group_id = $records['group_id'];
|
||||
} else {
|
||||
throw new \Exception("Group Id Missing Please Try again..");
|
||||
}
|
||||
} else if ($records['categories'] == 'SEND_WAAI_URL') {
|
||||
if ($records['mobile'] != "") {
|
||||
$params->number = (int)'91' . $records['mobile'];
|
||||
} else {
|
||||
throw new \Exception("Mobile Number Missing Please Try again..");
|
||||
}
|
||||
} else {
|
||||
throw new \Exception("Please Choose your Category");
|
||||
}
|
||||
if ($records['type'] == 'media') {
|
||||
if ($records['media_url'] != "") {
|
||||
$params->media_url = $records['media_url'];
|
||||
} else {
|
||||
throw new \Exception("Media Url Missing Please Try again..");
|
||||
}
|
||||
}
|
||||
|
||||
$url = constant($records['categories']);
|
||||
$params->type = $records['type'] == "" ? "text" : $records['type'];
|
||||
$params->instance_id = $_ENV['WAAI_INSTANCE'];
|
||||
$params->access_token = $_ENV['WAAI_TOKEN'];
|
||||
$params->message = $records['description'];
|
||||
$this->logger->info("Whatsapp : sending message request = " . json_encode($params));
|
||||
$this->logger->info("Whatsapp : sending message request type b4 = " . gettype($params));
|
||||
helper('notification');
|
||||
$notification = new NotificationHelper();
|
||||
$success = $notification->sendWhatsAppMessage($url, "POST", $params);
|
||||
session()->setFlashdata('success', 'Message : ' . $success);
|
||||
$this->logger->info("Whatsapp : Reponse = " . $success);
|
||||
} 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());
|
||||
}
|
||||
}
|
||||
$data['page_name'] = 'Custom Notifications';
|
||||
$this->render_page('notifications_form', $data);
|
||||
}
|
||||
|
||||
public function due_date_notifications()
|
||||
{
|
||||
$date = $this->request->getGet('date');
|
||||
|
||||
$model = new NotificationModel();
|
||||
$details = $model->getSubscriptionDueDetail($date);
|
||||
// echo "<pre>";
|
||||
// print_r($details);
|
||||
// echo "</pre>";
|
||||
// die;
|
||||
$records = [];
|
||||
$recipient_name = "";
|
||||
$recipient_email = "";
|
||||
$recipient_mobile = "";
|
||||
$subscription_name = "";
|
||||
$business_name = "";
|
||||
$to_subscription = "";
|
||||
if (isset($details)) {
|
||||
$this->logger->info("Notification : Duedate notification Request data type = " . gettype($details));
|
||||
}
|
||||
helper('notification');
|
||||
$notification = new NotificationHelper();
|
||||
foreach ($details as $rec) {
|
||||
$recipient_name = $rec['customer_name'];
|
||||
$recipient_email = $rec['customer_email'];
|
||||
$recipient_mobile = $rec['customer_mobile'];
|
||||
// $recipient_email = "sanjeev.p@venbainfotech.com";
|
||||
// $recipient_mobile = 6369084112;
|
||||
$business_name = $rec['business_name'];
|
||||
$subscription_name = $rec['title'];
|
||||
$to_subscription = $rec['to_subscription'];
|
||||
}
|
||||
$records['template_name'] = '';
|
||||
$records['recipient_name'] = $recipient_name;
|
||||
$records['recipient_email'] = $recipient_email ? $recipient_email : "sanjeev.p@venbainfotech.com";
|
||||
$records['subject'] = $business_name . " - Due Date Reminder";
|
||||
$records['description'] = "<!DOCTYPE html>
|
||||
<html>
|
||||
<head><title>Due Date Reminder</title></head>
|
||||
<body>
|
||||
<p>Hello " . $recipient_name . ",</p>
|
||||
<p>This is a reminder that the following subscription is due soon:</p>
|
||||
<p><strong>Subscription Name:</strong>" . $subscription_name . " </p>
|
||||
<p><strong>Due Date:</strong> " . $to_subscription . "</p>
|
||||
<p>Please make sure to complete this subscription on time.</p>
|
||||
<p>Thank you.</p>
|
||||
</body>
|
||||
</html>";
|
||||
|
||||
$template = "Hello " . $recipient_name . ",\r\r\n\nThis is a reminder that the following subscription is due soon:\r\n- Subscription Name: " . $subscription_name . "\r\n Due Date: " . $to_subscription . "\r\n\nPlease make sure to complete this subscription on time.\n Thank you.";
|
||||
|
||||
$params = (object) Null;
|
||||
$params->number = (int)'91' . $recipient_mobile;
|
||||
$params->type = "text";
|
||||
$params->message = $template;
|
||||
$params->instance_id = $_ENV['WAAI_INSTANCE'];
|
||||
$params->access_token = $_ENV['WAAI_TOKEN'];
|
||||
$this->logger->info("Notification : Duedate notification Email Request data = " . json_encode($records));
|
||||
|
||||
$email_result = $notification->sendEmail($records);
|
||||
$this->logger->info("Notification : Duedate notification Email Response = " . json_encode($email_result));
|
||||
$this->logger->info("Notification : Duedate notification Whatsapp Request data = " . json_encode($params));
|
||||
$whatsapp_result = $notification->sendWhatsAppMessage(SEND_WAAI_URL, "POST", $params);
|
||||
$this->logger->info("Notification : Duedate notification Whatsapp Response = " . json_encode($whatsapp_result));
|
||||
}
|
||||
|
||||
public function template_creation()
|
||||
{
|
||||
$data['page_name'] = 'Template Details';
|
||||
$model = new NotificationModel();
|
||||
$data['template'] = $model->getTemplateDetails();
|
||||
$this->render_page('template_creation', $data);
|
||||
// echo "templates";die;
|
||||
}
|
||||
|
||||
public function template_creation_form($id)
|
||||
{
|
||||
|
||||
$data['group_details'] = $this->get_group_details();
|
||||
$model = new NotificationModel();
|
||||
if ($id === '0') {
|
||||
$this->logger->info("Template Creation: In Add Page");
|
||||
$data['page_name'] = 'Add Template';
|
||||
$data['template_details'] = [];
|
||||
} elseif ($id !== '0') {
|
||||
$this->logger->info("Template Creation: In Edit Page ID =" . $id);
|
||||
$data['page_name'] = 'Edit Template';
|
||||
$model->setTable('templates');
|
||||
$where = ['template_id' => (int)$id];
|
||||
$result = $model->where($where)->findAll();
|
||||
$data['template_details'] = !empty($result[0]) ? $result[0] : [];
|
||||
}
|
||||
// print_r($data['template_details']);die();
|
||||
$this->render_page('template_creation_form', $data);
|
||||
}
|
||||
|
||||
public function template_creation_delete($id)
|
||||
{
|
||||
try {
|
||||
helper('session');
|
||||
$session_uid = get_logged_user_id();
|
||||
$model = new NotificationModel();
|
||||
$model->setTable('templates');
|
||||
$where = ['template_id' => (int)$id];
|
||||
$result = $model->where($where)->findAll();
|
||||
if ($result) {
|
||||
$this->logger->Info("Template: Going to Inactive ID = " . $id);
|
||||
$data = ['isactive' => 0, 'updated_by' => $session_uid, 'template_id' => (int)$id];
|
||||
$statement = $model->saveDetails($data, 'template_id', 'templates'); // just updating Inactive status only.
|
||||
if ($statement['success']) {
|
||||
session()->setFlashdata('success', $statement['success'] ? 'Deleted successfully.' : "");
|
||||
$this->logger->info($statement['log']);
|
||||
} else if ($statement['error']) {
|
||||
session()->setFlashdata('error', $statement['error']);
|
||||
$this->logger->error($statement['log']);
|
||||
} else {
|
||||
throw new \Exception("Template: Err Occur on data the Template Inactive");
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->error("Template: Err Occur = " . $e->getMessage() . " File = " . $e->getFile() . " Line = " . $e->getLine());
|
||||
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
|
||||
}
|
||||
return redirect()->route('template_creation');
|
||||
}
|
||||
|
||||
public function get_group_details()
|
||||
{
|
||||
$model = new NotificationModel();
|
||||
$model->setTable('customer_groups');
|
||||
// $details = $model->where('isactive',1)->orderBy('group_id', 'ASC')->findAll();
|
||||
$where = ['isactive' => 1, 'group_name != ' => 'EXPIRYDATE'];
|
||||
$details = $model->where($where)->orderBy('group_id', 'ASC')->findAll();
|
||||
return $details;
|
||||
}
|
||||
|
||||
public function get_template_details()
|
||||
{
|
||||
$model = new NotificationModel();
|
||||
$model->setTable('templates');
|
||||
$details = $model->where('isactive', 1)->orderBy('template_id', 'ASC')->findAll();
|
||||
return $details;
|
||||
}
|
||||
|
||||
public function template_creation_insert()
|
||||
{
|
||||
$this->logger->info("Template: Inserting/Updating Details");
|
||||
try {
|
||||
## Declarions
|
||||
helper('session');
|
||||
$model = new NotificationModel();
|
||||
$session_uid = get_logged_user_id();
|
||||
$id = $this->request->getPost('template_id');
|
||||
$subject = $this->request->getPost('subject') ? $this->request->getPost('subject') : NULL;
|
||||
$isactive = $id != "" ? $this->request->getPost('isactive') : 'on';
|
||||
$data = [
|
||||
'template_id' => $id,
|
||||
'template_name' => $this->request->getPost('templatename'),
|
||||
'subject' => $subject,
|
||||
'message' => $this->request->getPost('templatemessage'),
|
||||
'mode' => $this->request->getPost('mode'),
|
||||
'isactive' => (($isactive == 'on') ? 1 : 0),
|
||||
'created_by' => $session_uid,
|
||||
'updated_by' => $session_uid
|
||||
];
|
||||
$statement = $model->saveDetails($data, 'template_id', 'templates');
|
||||
if ($statement['success']) {
|
||||
session()->setFlashdata('success', $statement['success']);
|
||||
$this->logger->info($statement['log']);
|
||||
} else if ($statement['error']) {
|
||||
session()->setFlashdata('error', $statement['error']);
|
||||
$this->logger->error($statement['log']);
|
||||
} else {
|
||||
throw new \Exception("Template: Err Occur");
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->error("Template: Err Occur =" . $e->getMessage());
|
||||
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
|
||||
}
|
||||
return redirect()->route('template_creation');
|
||||
}
|
||||
|
||||
public function campaign_creation()
|
||||
{
|
||||
$data['page_name'] = 'Campaign Details';
|
||||
$model = new NotificationModel();
|
||||
$data['campaign'] = $model->getCampaignDetails();
|
||||
$this->render_page('campaign_creation', $data);
|
||||
// echo "templates";die;
|
||||
}
|
||||
|
||||
public function campaign_creation_form($id)
|
||||
{
|
||||
|
||||
$data['group_details'] = $this->get_group_details();
|
||||
$data['template_details'] = $this->get_template_details();
|
||||
$model = new NotificationModel();
|
||||
if ($id === '0') {
|
||||
$this->logger->info("Campaign Creation: In Add Page");
|
||||
$data['page_name'] = 'Add Campaign';
|
||||
$data['campaign_details'] = [];
|
||||
} elseif ($id !== '0') {
|
||||
$this->logger->info("Campaign Creation: In Edit Page ID =" . $id);
|
||||
$data['page_name'] = 'Edit Campaign';
|
||||
$model->setTable('notification_campaign');
|
||||
$where = ['campaign_id' => (int)$id];
|
||||
$result = $model->where($where)->findAll();
|
||||
if (!empty($result)) {
|
||||
foreach ($result as $i => $item) {
|
||||
$result[$i]['group_id'] = unserialize($item['group_id']);
|
||||
}
|
||||
}
|
||||
$data['campaign_details'] = !empty($result[0]) ? $result[0] : [];
|
||||
}
|
||||
$this->render_page('campaign_creation_form', $data);
|
||||
}
|
||||
|
||||
public function campaign_creation_delete($id)
|
||||
{
|
||||
try {
|
||||
helper('session');
|
||||
$session_uid = get_logged_user_id();
|
||||
$model = new NotificationModel();
|
||||
$model->setTable('notification_campaign');
|
||||
$where = ['campaign_id' => (int)$id];
|
||||
$result = $model->where($where)->findAll();
|
||||
if ($result) {
|
||||
$this->logger->Info("Campaign: Going to Inactive ID = " . $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.
|
||||
if ($statement['success']) {
|
||||
session()->setFlashdata('success', $statement['success'] ? 'Deleted successfully.' : "");
|
||||
$this->logger->info($statement['log']);
|
||||
} else if ($statement['error']) {
|
||||
session()->setFlashdata('error', $statement['error']);
|
||||
$this->logger->error($statement['log']);
|
||||
} else {
|
||||
throw new \Exception("Campaign: Err Occur on data the Template Inactive");
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->error("Campaign: Err Occur = " . $e->getMessage() . " File = " . $e->getFile() . " Line = " . $e->getLine());
|
||||
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
|
||||
}
|
||||
return redirect()->route('campaign_creation');
|
||||
}
|
||||
|
||||
public function campaign_creation_insert()
|
||||
{
|
||||
$this->logger->info("Campaign: Inserting/Updating Details");
|
||||
try {
|
||||
## Declarions
|
||||
helper('session');
|
||||
$model = new NotificationModel();
|
||||
$session_uid = get_logged_user_id();
|
||||
$id = $this->request->getPost('campaign_id');
|
||||
$request_data = $this->request->getPost();
|
||||
$isactive = $id == "" ? 1 : (isset($request_data['isactive']) && $request_data['isactive'] == 'on' ? 1 : 0);
|
||||
|
||||
$data = [
|
||||
'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'),
|
||||
'mode' => $this->request->getPost('mode'),
|
||||
'group_id' => serialize($this->request->getPost('group_id')),
|
||||
'isactive' => $isactive,
|
||||
'created_by' => $session_uid,
|
||||
'updated_by' => $session_uid
|
||||
];
|
||||
if ($id != "") {
|
||||
$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['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 {
|
||||
$statement = $model->saveDetails($data, 'campaign_id', 'notification_campaign');
|
||||
}
|
||||
if ($statement['success']) {
|
||||
session()->setFlashdata('success', $statement['success']);
|
||||
$this->logger->info($statement['log']);
|
||||
} else if ($statement['error']) {
|
||||
session()->setFlashdata('error', $statement['error']);
|
||||
$this->logger->error($statement['log']);
|
||||
} else {
|
||||
throw new \Exception("Campaign: Err Occur");
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->error("Campaign: Err Occur =" . $e->getMessage());
|
||||
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
|
||||
}
|
||||
return redirect()->route('campaign_creation');
|
||||
}
|
||||
|
||||
public function getExpCustomerDetail($window_time = null)
|
||||
{
|
||||
// Step 1: add the days to retrive the data//
|
||||
$providedDate = date('Y-m-d');
|
||||
$newDate = date('Y-m-d', strtotime($providedDate . ' + ' . $window_time . ' days'));
|
||||
|
||||
// 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
|
||||
$modifiedQuery = str_replace('WINDOW_TIME', $window_time, $ExpCustomerDetail);
|
||||
|
||||
if (empty($modifiedQuery)) {
|
||||
$this->logger->info('There is no sub query');
|
||||
return;
|
||||
}
|
||||
$db = \Config\Database::connect();
|
||||
$queryResult = $db->query($modifiedQuery)->getResultArray();
|
||||
|
||||
$notification = new NotificationHelper();
|
||||
if (empty($queryResult)) {
|
||||
$this->logger->info("There is no customer expiring on date:{$newDate}");
|
||||
return;
|
||||
}
|
||||
foreach ($queryResult as $row) {
|
||||
$userFirstName = $row['first_name'];
|
||||
$userLastName = $row['last_name'];
|
||||
$fullName = $userFirstName . ' ' . $userLastName;
|
||||
$userMobileNumber = $row['mobile_no'];
|
||||
$schemename = $row['title'];
|
||||
$expirydate = $row['to_subscription'];
|
||||
if (empty($fullName)) {
|
||||
$this->logger->info('There is no subcription Name');
|
||||
continue;
|
||||
}
|
||||
|
||||
$emailTemplateName = $NotificationModel->getTempName(EXPIRAY_NOTIFY_TEMPLATE_EMAIL);
|
||||
if (!empty($emailTemplateName)) {
|
||||
//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);
|
||||
|
||||
$emailData = [
|
||||
'template_name' => '',
|
||||
'recipient_email' => $row['email'],
|
||||
'subject' => 'Your Subscription Expiry Notification',
|
||||
'description' => $emailContent,
|
||||
];
|
||||
|
||||
// Step 5:Send email using NotificationHelper
|
||||
$emailResult = $notification->sendEmail($emailData);
|
||||
|
||||
if (isset($emailResult['success'])) {
|
||||
echo 'Email sent successfully';
|
||||
} else {
|
||||
echo 'Failed to send email';
|
||||
}
|
||||
} else {
|
||||
$this->logger->info('There is no email template found by the name of EXPIRAY_NOTIFY_TEMPLATE_EMAIL');
|
||||
continue;
|
||||
} // $emailTemplateName
|
||||
|
||||
$whatsappTemplateName = $NotificationModel->getTempName(EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP);
|
||||
if (!empty($whatsappTemplateName)) {
|
||||
if (empty($userMobileNumber)) {
|
||||
$this->logger->info('There is no subscriber mobile number');
|
||||
continue;
|
||||
}
|
||||
//Step 6: 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
|
||||
$params = (object) Null;
|
||||
$url = SEND_WAAI_URL;
|
||||
$params->number = (int)'91' . $userMobileNumber;
|
||||
$params->type = "text";
|
||||
$params->message = $whatsappContent;
|
||||
$params->instance_id = $_ENV['WAAI_INSTANCE'];
|
||||
$params->access_token = $_ENV['WAAI_TOKEN'];
|
||||
$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);
|
||||
} else {
|
||||
$this->logger->info('There is no Whatsapp template found by the name of EXPIRAY NOTIFY TEMPLATE WHATSAPP ');
|
||||
continue;
|
||||
} // $Whatsapp Template Name
|
||||
} // for loop
|
||||
}
|
||||
|
||||
################################################################
|
||||
# Auto Scheduled Notification
|
||||
################################################################
|
||||
## notification campaign details
|
||||
public function auto_scheduled_notification(){
|
||||
$this->logger->info("Auto Scheduled Notification Started");
|
||||
$model = new NotificationModel();
|
||||
$model->setTable('notification_campaign');
|
||||
$where = ['status'=>0];
|
||||
$notification_campaign_result = $model->where($where)->findAll();
|
||||
$today = date('Y-m-d');
|
||||
$get_notification_campaign_details = [];
|
||||
if (!empty($notification_campaign_result)) {
|
||||
foreach ($notification_campaign_result as $n => $ncr) {
|
||||
if($today == $ncr['scheduled_date']){
|
||||
$this->logger->info("Notification Campaign : Scheduled Date = " .$ncr['scheduled_date']."/".$ncr['scheduled_time'].", Today = ".$today );
|
||||
$get_notification_campaign_details[] = $ncr;
|
||||
}else{
|
||||
$this->logger->info("Notification Campaign : There is no Scheduled, bcoz Date Are Different = " .$ncr['scheduled_date'].", Today = ".$today );
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$this->logger->info("Notification Campaign : Details not found ");
|
||||
echo "Notification Campaign : Details not found" ;
|
||||
return [];
|
||||
}
|
||||
|
||||
if(!empty($get_notification_campaign_details)){
|
||||
$this->logger->info("Notification Campaign : Details founded proceed next Step");
|
||||
$this->get_auto_scheduled_template_details($get_notification_campaign_details);
|
||||
}else{
|
||||
$this->logger->info("Notification Campaign : Details not found ");
|
||||
echo "Notification Campaign : Details not found" ;
|
||||
return [];
|
||||
}
|
||||
}
|
||||
## template_details
|
||||
public function get_auto_scheduled_template_details($nc_dls){
|
||||
$template_result = [];
|
||||
$model = new NotificationModel();
|
||||
if (!empty($nc_dls)) {
|
||||
foreach ($nc_dls as $i => $item) {
|
||||
$group_id = $item['group_id'];
|
||||
$template_id = $item['template_id'];
|
||||
$template_result[$i]['campaign_id'] = $item['campaign_id'];
|
||||
$template_result[$i]['campaign_name'] = $item['campaign_name'];
|
||||
$template_result[$i]['campaign_mode'] = $item['mode'];
|
||||
$template_result[$i]['campaign_status'] = $item['status'];
|
||||
$template_result[$i]['campaign_isactive'] = $item['isactive'];
|
||||
$template_result[$i]['campaign_template_id'] = $template_id;
|
||||
$template_result[$i]['scheduled_date'] = $item['scheduled_date'];
|
||||
$template_result[$i]['scheduled_time'] = $item['scheduled_time'];
|
||||
$template_result[$i]['group_id'] = unserialize($group_id);
|
||||
$model->setTable('templates');
|
||||
$where = ['template_id'=>$template_id];
|
||||
$result = $model->where($where)->findAll();
|
||||
if(!empty($result)){
|
||||
foreach ($result as $s => $sub_array) {
|
||||
$template_result[$i]['template_id'] = $sub_array['template_id'];
|
||||
$template_result[$i]['template_name'] = $sub_array['template_name'];
|
||||
$template_result[$i]['template_mode'] = $sub_array['mode'];
|
||||
$template_result[$i]['template_isactive'] = $sub_array['isactive'];
|
||||
$template_result[$i]['subject'] = $sub_array['subject'];
|
||||
$template_result[$i]['message'] = $sub_array['message'];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->logger->info("Template : Details not found ");
|
||||
echo "Template : Details not found" ;
|
||||
return [];
|
||||
}
|
||||
|
||||
if(!empty($template_result)){
|
||||
// echo "<pre>";
|
||||
$this->logger->info("Template : Details founded proceed next step ");
|
||||
$this->get_auto_scheduled_customer_group_details($template_result);
|
||||
// echo "</pre>";
|
||||
}else{
|
||||
$this->logger->info("Template : Details not found ");
|
||||
echo "Template : Details not found" ;
|
||||
return [];
|
||||
}
|
||||
}
|
||||
#Customer Group Details
|
||||
public function get_auto_scheduled_customer_group_details($t_dls){
|
||||
// echo "<pre>";
|
||||
// print_r($t_dls);
|
||||
// echo "</pre>";
|
||||
// return;
|
||||
$customer_group_result = [];
|
||||
$model = new NotificationModel();
|
||||
if (!empty($t_dls)) {
|
||||
foreach ($t_dls as $i => $item) {
|
||||
$customer_group_result[$i] = $item;
|
||||
$group_id = $item['group_id'];
|
||||
$model->setTable('customer_groups');
|
||||
$group_arr_result = $model->whereIn('group_id', $group_id)->findAll();
|
||||
// echo "<pre>".$i;
|
||||
// print_r($item);
|
||||
// echo "</pre>";
|
||||
if(!empty( $group_arr_result)){
|
||||
foreach ($group_arr_result as $s => $sub_array) {
|
||||
$customer_group_result[$i]['group_name'] = $sub_array['group_name'];
|
||||
$customer_group_result[$i]['group_isactive'] = $sub_array['isactive'];
|
||||
$db = \Config\Database::connect();
|
||||
$sql = (string)$sub_array['group_query'];
|
||||
$customer_group_result[$i]['group_query'] = $sql;
|
||||
if($sql){
|
||||
$query = $db->query($sql);
|
||||
$results = $query->getResultArray();
|
||||
if(!empty($results)){
|
||||
|
||||
$customer_group_result[$i]['group_query_results'] = $results;
|
||||
$customer_group_result[$i]['group_query_customer_count'] = count($results);
|
||||
}else{
|
||||
|
||||
$customer_group_result[$i]['group_query_results'] = [];
|
||||
$customer_group_result[$i]['group_query_customer_count'] = 0;
|
||||
}
|
||||
}else{
|
||||
|
||||
$customer_group_result[$i]['group_query_results'] = [];
|
||||
$customer_group_result[$i]['group_query_customer_count'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->logger->info("Customer Groups : Details not found ");
|
||||
echo "Customer Groups : Details not found" ;
|
||||
return [];
|
||||
}
|
||||
|
||||
if(!empty($customer_group_result)){
|
||||
echo "<pre>";
|
||||
$final = $this->get_auto_scheduled_content_replacement($customer_group_result);
|
||||
print_r($final);
|
||||
echo "</pre>";
|
||||
}else{
|
||||
$this->logger->info("Customer Groups : Details not found ");
|
||||
echo "Customer Groups : Details not found" ;
|
||||
return [];
|
||||
}
|
||||
}
|
||||
# D
|
||||
public function get_auto_scheduled_content_replacement($data){
|
||||
// echo "<pre>";
|
||||
// echo print_r($data);
|
||||
// echo "</pre>";
|
||||
$return_statement = [];
|
||||
if (!empty($data)) {
|
||||
foreach($data as $inx => $item) {
|
||||
$return_statement[$inx] = $item;
|
||||
switch($item['campaign_mode']) {
|
||||
case "Whatsapp":
|
||||
$query_results = $item['group_query_results'];
|
||||
$whatsappContent = $item['message'];
|
||||
foreach($query_results as $q => $qr) {
|
||||
$whatsappContent = str_replace("{USER_NAME}", $qr["customer_name"], $whatsappContent);
|
||||
$whatsappContent = str_replace("{SCHEME_NAME}", $qr["scheme_name"], $whatsappContent);
|
||||
$whatsappContent = str_replace("{EXPIRY_DATE}", $qr["formatted_due_date"], $whatsappContent);
|
||||
$params = (object) Null;
|
||||
$url = SEND_WAAI_URL;
|
||||
$params->number = (int)'91' . $qr["mobile_no"];
|
||||
$params->type = "text";
|
||||
$params->message = $whatsappContent;
|
||||
$params->instance_id = $_ENV['WAAI_INSTANCE'];
|
||||
$params->access_token = $_ENV['WAAI_TOKEN'];
|
||||
$return_statement[$inx]['group_query_results'][$q]['content'] = $params;
|
||||
$return_statement[$inx]['group_query_results'][$q]['mode'] = $item['campaign_mode'];
|
||||
}
|
||||
break;
|
||||
case "Email":
|
||||
$emailContent = $item['message'];
|
||||
$query_results = $item['group_query_results'];
|
||||
foreach($query_results as $q => $qr) {
|
||||
$emailContent = str_replace("{USER_NAME}", $qr["customer_name"], $emailContent);
|
||||
$emailContent = str_replace("{SCHEME_NAME}", $qr["scheme_name"], $emailContent);
|
||||
$emailContent = str_replace("{EXPIRY_DATE}", $qr["formatted_due_date"], $emailContent);
|
||||
$emailData = [
|
||||
'template_name' => '',
|
||||
'recipient_email' => $qr["email"],
|
||||
'subject' => $item['subject'] != "" ? $item['subject'] : ucfirst(str_replace('_', ' ', (string)$qr["scheme_name"]))." Notification" ,
|
||||
'description' => $emailContent,
|
||||
];
|
||||
$return_statement[$inx]['group_query_results'][$q]['content'] = $emailData;
|
||||
$return_statement[$inx]['group_query_results'][$q]['mode'] = $item['campaign_mode'];
|
||||
}
|
||||
break;
|
||||
default:break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $return_statement;
|
||||
}
|
||||
############## Auto Scheduled Notification Ends ################
|
||||
|
||||
}
|
||||
@ -217,12 +217,12 @@ class Notifications extends BaseController
|
||||
$details = $model->where($where)->orderBy('group_id', 'ASC')->findAll();
|
||||
return $details;
|
||||
}
|
||||
|
||||
|
||||
public function get_template_details()
|
||||
{
|
||||
$model = new NotificationModel();
|
||||
$model->setTable('templates');
|
||||
$details = $model->where('isactive', 1)->orderBy('template_id', 'ASC')->findAll();
|
||||
$details = $model->where(['isactive' => 1,'template_name not like "%EXPIRAY_NOTIFY_TEMPLATE%"'])->orderBy('template_id', 'ASC')->findAll();
|
||||
return $details;
|
||||
}
|
||||
|
||||
@ -237,11 +237,18 @@ class Notifications extends BaseController
|
||||
$id = $this->request->getPost('template_id');
|
||||
$subject = $this->request->getPost('subject') ? $this->request->getPost('subject') : NULL;
|
||||
$isactive = $id != "" ? $this->request->getPost('isactive') : 'on';
|
||||
$templatemessage = "";
|
||||
if($this->request->getPost('mode') === "Email"){
|
||||
$templatemessage = $this->request->getPost('templatemessage');
|
||||
}else if($this->request->getPost('mode') === "Whatsapp"){
|
||||
$templatemessage = $this->request->getPost('whatsapptemplatemessage');
|
||||
}
|
||||
|
||||
$data = [
|
||||
'template_id' => $id,
|
||||
'template_name' => $this->request->getPost('templatename'),
|
||||
'subject' => $subject,
|
||||
'message' => $this->request->getPost('templatemessage'),
|
||||
'message' => $templatemessage,
|
||||
'mode' => $this->request->getPost('mode'),
|
||||
'isactive' => (($isactive == 'on') ? 1 : 0),
|
||||
'created_by' => $session_uid,
|
||||
@ -346,7 +353,7 @@ class Notifications extends BaseController
|
||||
'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'),
|
||||
'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,
|
||||
@ -483,4 +490,147 @@ class Notifications extends BaseController
|
||||
} // $Whatsapp Template Name
|
||||
} // for loop
|
||||
}
|
||||
|
||||
################################################################
|
||||
# Auto Scheduled Notification
|
||||
################################################################
|
||||
## notification campaign details
|
||||
public function processScheduledNotifications(){
|
||||
$this->logger->info("Auto Scheduled Notification Started");
|
||||
#step 1 get scheduled notification details
|
||||
$notification_campaign_result = $this->getScheduledNotificationDetails();
|
||||
$this->logger->info("Auto Scheduled Campaign Details Count = ".count($notification_campaign_result));
|
||||
if(!count($notification_campaign_result))
|
||||
{
|
||||
$this->logger->info("No Auto Scheduled Notification in DB,exiting...!");
|
||||
$this->logger->info("Auto Scheduled Notification Ends");
|
||||
exit();
|
||||
}
|
||||
|
||||
//looping multiple notification campaign
|
||||
if(count($notification_campaign_result))
|
||||
{
|
||||
foreach($notification_campaign_result as $index => $single_campaign)
|
||||
{
|
||||
#step 2 get template details
|
||||
$template = $this->getTemplateDetails($single_campaign['template_id']);
|
||||
$this->logger->info("Auto Scheduled Template Details TID = ".$single_campaign['template_id']);
|
||||
if(count($template))
|
||||
{
|
||||
|
||||
#step 3 execute the customer group query and return customer details
|
||||
$customer_details = $this->getCustomerDetails($single_campaign['group_id']);
|
||||
$sent_customer_details = [];
|
||||
if(count($customer_details))
|
||||
{
|
||||
foreach($customer_details as $customer)
|
||||
{
|
||||
//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);
|
||||
|
||||
#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';
|
||||
$this->logger->info("Auto Scheduled Email CID = ".$customer['customer_id']." ".$mail_log);
|
||||
}
|
||||
else
|
||||
{
|
||||
$params = (object) Null;
|
||||
$url = SEND_WAAI_URL;
|
||||
$params->type = "text";
|
||||
$params->instance_id = $_ENV['WAAI_INSTANCE'];
|
||||
$params->access_token = $_ENV['WAAI_TOKEN'];
|
||||
$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);
|
||||
}
|
||||
|
||||
array_push($sent_customer_details,$customer['customer_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#step 6 update campaign status to 1
|
||||
$model = new NotificationModel();
|
||||
$data = ['status' => 1];
|
||||
$statement = $model->notification_campaign_status($data,$single_campaign['campaign_id']);
|
||||
$this->logger->info($statement);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#step 1 get scheduled notification details
|
||||
function getScheduledNotificationDetails()
|
||||
{
|
||||
$model = new NotificationModel();
|
||||
$today = date('Y-m-d');
|
||||
$model->setTable('notification_campaign');
|
||||
$where = ['scheduled_date'=>$today];
|
||||
$notification_campaign_result = $model->where($where)->findAll();
|
||||
return $notification_campaign_result;
|
||||
}
|
||||
|
||||
#step 2 get template details
|
||||
function getTemplateDetails($template_id)
|
||||
{
|
||||
$model = new NotificationModel();
|
||||
$model->setTable('templates');
|
||||
$where = ['template_id'=>$template_id];
|
||||
$result = $model->where($where)->first();
|
||||
return $result;
|
||||
}
|
||||
|
||||
#step 3 execute the customer group query and return customer details
|
||||
function getCustomerDetails($group_ids)
|
||||
{
|
||||
$group_id_arr = unserialize($group_ids);
|
||||
$this->logger->info("Auto Scheduled Customer Group CGID = ".implode(", ", $group_id_arr));
|
||||
$customer_details = [];
|
||||
if(count($group_id_arr))
|
||||
{
|
||||
foreach($group_id_arr as $group_id)
|
||||
{
|
||||
// echo "gid".$group_id;
|
||||
$model = new NotificationModel();
|
||||
$model->setTable('customer_groups');
|
||||
$customer_group_result = $model->where(['group_id'=>$group_id])->findAll();
|
||||
$db = \Config\Database::connect();
|
||||
if(count($customer_group_result))
|
||||
{
|
||||
|
||||
$sql = (string)$customer_group_result[0]['group_query'];
|
||||
$query = $db->query($sql);
|
||||
$sql_group_results = $query->getResultArray();
|
||||
// print_r($sql_group_results);
|
||||
$customer_details = array_merge($customer_details,$sql_group_results);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $customer_details;
|
||||
}
|
||||
|
||||
#step 4
|
||||
function replaceTemplateWithDataPoints($originalTemplate,$dataPointsArray)
|
||||
{
|
||||
// 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);
|
||||
return $notificationContent;
|
||||
}
|
||||
############## Auto Scheduled Notification Ends ################
|
||||
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ class NotificationHelper
|
||||
public function sendEmail($records)
|
||||
{
|
||||
$this->logger->info('Helper : Email Request Data type = '.gettype($records));
|
||||
|
||||
|
||||
$cc = isset($records['carboncopy']) ? $records['carboncopy'] : '';
|
||||
$bcc = isset($records['blindcarboncopy']) ? $records['blindcarboncopy'] : '';
|
||||
|
||||
@ -31,15 +31,17 @@ class NotificationHelper
|
||||
$this->email->setFrom('no-reply@tripapprovaltool.com', isset($records['company'])?$records['company']:"VBP");
|
||||
$this->email->setSubject($records['subject']);
|
||||
$this->logger->info('Helper : Email subject = '.$records['subject']);
|
||||
if($records['template_name'] != ""){
|
||||
$this->logger->info('Helper : Email Template = '.$records['template_name']);
|
||||
$this->logger->info("Helper : Email Request data = ".json_encode($records));
|
||||
$emailContent = view($records['template_name'],$records);
|
||||
$this->email->setMessage($emailContent);
|
||||
}else{
|
||||
$this->logger->info('Helper : Email Dynamic Template');
|
||||
$this->email->setMessage($records['description']);
|
||||
}
|
||||
$this->email->setMessage($records['description']);
|
||||
|
||||
// if($records['template_name'] != ""){
|
||||
// $this->logger->info('Helper : Email Template = '.$records['template_name']);
|
||||
// $this->logger->info("Helper : Email Request data = ".json_encode($records));
|
||||
// $emailContent = view($records['template_name'],$records);
|
||||
// $this->email->setMessage($emailContent);
|
||||
// }else{
|
||||
// $this->logger->info('Helper : Email Dynamic Template');
|
||||
// $this->email->setMessage($records['description']);
|
||||
// }
|
||||
|
||||
|
||||
if (!empty($cc)) {
|
||||
@ -108,8 +110,9 @@ class NotificationHelper
|
||||
if ($result->status === "error") {
|
||||
$this->logger->error('Helper : Whatsapp Err occur = '.$result->message);
|
||||
throw new \Exception($result->message);
|
||||
}else{
|
||||
$final_result = " Sended Success ";
|
||||
}
|
||||
if ($result->status === "success") {
|
||||
$final_result = isset($result->message) ? ((strtolower(gettype($result->message)) === 'string') ? $result->message : "Sended Success") : " Message Not Sent. ";
|
||||
}
|
||||
}else{
|
||||
$curl_errno= curl_errno($curl);
|
||||
|
||||
@ -10,7 +10,7 @@ class AuthenticationModel extends Model
|
||||
public function getheringDetailsForHeader($user_id)
|
||||
{
|
||||
$builder = $this->db->table('users');
|
||||
$builder->select('users.user_id,users.business_id,users.profile_picture,users.role,settings.site_name,settings.site_title,settings.favicon,settings.logo as company_logo_large,business.business_logo as company_logo_small,business.email as company_email,business.address as company_address,business.mobile_no as company_mobile_no,business.title,settings.footer_about');
|
||||
$builder->select('users.user_id,users.business_id,users.profile_picture,users.role,settings.site_name,settings.site_title,settings.favicon,settings.logo as company_logo_large,business.business_logo as company_logo_small,business.email as company_email,business.address as company_address,business.mobile_no as company_mobile_no,business.title as company_name,settings.footer_about');
|
||||
$builder->join('settings', 'settings.business_id = users.business_id', 'left');
|
||||
$builder->join('business', 'business.business_id = users.business_id', 'left');
|
||||
$builder->where('user_id', $user_id);
|
||||
|
||||
@ -82,7 +82,7 @@ public function getCampaignDetails(){
|
||||
->join('users as U1', 'U1.user_id = NC.created_by', 'left')
|
||||
->join('users as U2', 'U2.user_id = NC.updated_by', 'left')
|
||||
->join('templates as T', 'T.template_id = NC.template_id', 'left')
|
||||
->select('NC.campaign_id,NC.campaign_name,T.template_id,T.template_name,NC.mode,NC.created_on,NC.created_by,NC.updated_on,NC.updated_by,DATE_FORMAT(NC.created_on, "%d/%m/%Y %h:%i %p") AS formatted_created_on,concat(U1.first_name," ",U1.last_name) as created_by_name,concat(U2.first_name," ",U2.last_name) as updated_by_name,NC.isactive,NC.group_id,NC.scheduled_date,NC.scheduled_time')
|
||||
->select('NC.campaign_id,NC.campaign_name,T.template_id,T.template_name,NC.mode,NC.created_on,NC.created_by,NC.updated_on,NC.updated_by,DATE_FORMAT(NC.created_on, "%d/%m/%Y %h:%i %p") AS formatted_created_on,concat(U1.first_name," ",U1.last_name) as created_by_name,concat(U2.first_name," ",U2.last_name) as updated_by_name,NC.isactive,NC.group_id,NC.scheduled_date,if(NC.scheduled_time IS NULL ,"",NC.scheduled_time) as scheduled_time')
|
||||
->get()->getResultArray();
|
||||
|
||||
if (!empty($result)) {
|
||||
@ -181,6 +181,21 @@ public function customerGroupQueryExecution($queries){
|
||||
|
||||
}
|
||||
}
|
||||
public function 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)) {
|
||||
$affectedRows = $this->db->affectedRows();
|
||||
$statement = $affectedRows > 0 ? 'Notification Campaign Status has been updated successfully. Aff Row'.$affectedRows." NCID = " .$id : 'Notification Campaign Status Update failed. Bcoz Already Affected Count = '.$affectedRows.". NCID = " .$id ;
|
||||
} else {
|
||||
$statement = "Notification Campaign Status Update failed. NCID = " .$id;
|
||||
}
|
||||
}
|
||||
else{
|
||||
$statement = "Notification Campaign Status Update failed. Bcoz Not Found NCID";
|
||||
}
|
||||
return $statement;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -89,11 +89,12 @@ public function getCustomerAddressesBySchemeName($schemeName)
|
||||
public function getAllCustomerDetailsBySchemeName($schemeName)
|
||||
{
|
||||
$builder = $this->db->table('subscription');
|
||||
$builder->select('customers.customer_id, CONCAT(customers.first_name, " ", customers.last_name) as customer_name,customer_addresses.mobile_no, customer_addresses.address_1,customer_addresses.address_2, customer_addresses.city, customer_addresses.state, customer_addresses.postal_code,business.title,business.address,business.city,business.state,business.postal_code,books.title,from_subscription,to_subscription');
|
||||
$builder->select('customers.customer_id, CONCAT(customers.first_name, " ", customers.last_name) as customer_name,customer_addresses.mobile_no, customer_addresses.address_1,customer_addresses.address_2, customer_addresses.city, customer_addresses.state, customer_addresses.postal_code,business.title as business_name,business.address as business_address,business.city as business_city,business.state as business_state,business.postal_code as business_postal_code,books.title,from_subscription,to_subscription,business.title as business_name,business.mobile_no as business_mobile_no,states.state_name');
|
||||
$builder->join('customers', 'customers.customer_id = subscription.customer_id');
|
||||
$builder->join('customer_addresses', 'customer_addresses.customer_id = customers.customer_id');
|
||||
$builder->join('business', 'business.business_id = subscription.business_id');
|
||||
$builder->join('books', 'books.book_id = subscription.scheme_id');
|
||||
$builder->join('states', 'states.state_short_name = customer_addresses.state');
|
||||
$builder->where('books.title', $schemeName);
|
||||
$builder->where('customer_addresses.address_type', 2); // Filter by address_type 2
|
||||
$builder->orderBy('customers.customer_id', 'ASC'); // Order by customer_id to group by customers
|
||||
@ -122,17 +123,19 @@ public function getAllCustomerDetailsBySchemeName($schemeName)
|
||||
'address_1' => $row['address_1'],
|
||||
'address_2' => $row['address_2'],
|
||||
'mobile_no'=>$row['mobile_no'],
|
||||
|
||||
'city' => $row['city'],
|
||||
'state' => $row['state'],
|
||||
'postal_code' => $row['postal_code'],
|
||||
'address' => $row['address'],
|
||||
'city' => $row['city'],
|
||||
'state' => $row['state'],
|
||||
'state_name' => $row['state_name'] != "" ? $row['state_name'] : $row['state'],
|
||||
'postal_code' => $row['postal_code'],
|
||||
'title' => $row['title'],
|
||||
'to_subscription'=>$row['to_subscription'],
|
||||
'title'=>$row['title'],
|
||||
'company_name'=>$row['business_name'],
|
||||
'company_mobile_no'=>$row['business_mobile_no'],
|
||||
'company_address' => $row['business_address'],
|
||||
'company_city' => $row['business_city'],
|
||||
'company_state' => $row['business_state'],
|
||||
'company_postal_code' => $row['business_postal_code'],
|
||||
|
||||
];
|
||||
|
||||
$currentCustomerID = $customerID;
|
||||
|
||||
@ -50,7 +50,7 @@
|
||||
$message = 'In-Active';
|
||||
}
|
||||
$scheduled_date = $c['scheduled_date'] != "" ? date('d/m/Y', strtotime($c['scheduled_date'])) : "";
|
||||
$scheduled_time = $c['scheduled_time'] != "00:00:00" ? date('h:i A', strtotime($c['scheduled_time'])) : "";
|
||||
$scheduled_time = $c['scheduled_time'] != "" ? date('h:i A', strtotime($c['scheduled_time'])) : "";
|
||||
?>
|
||||
<tr>
|
||||
<td hidden><?= $c['campaign_id']; ?></td>
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
float: left;
|
||||
page-break-inside: avoid;
|
||||
padding-right: 2px !important;
|
||||
border: 4px solid #FFFF00;
|
||||
border: 4px solid #fff;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.header {
|
||||
@ -41,7 +41,7 @@
|
||||
|
||||
.page-container {
|
||||
width: 98%; /* Set the width of the A4 sheet */
|
||||
margin: 1%; /* Add margin for spacing between A4 sheet and labels */
|
||||
margin: 2%; /* Add margin for spacing between A4 sheet and labels */
|
||||
}
|
||||
|
||||
.business-logo {
|
||||
@ -69,21 +69,22 @@
|
||||
<?= $customerDetails[$i]['customer_name'] ?><br>
|
||||
<?= $customerDetails[$i]['address_1'] ?>,<br>
|
||||
<?= $customerDetails[$i]['address_2'] ?>,<br>
|
||||
<?= $customerDetails[$i]['city'] ?>,<br>
|
||||
<?= $customerDetails[$i]['state'] ?> -
|
||||
<?= $customerDetails[$i]['postal_code'] ?>
|
||||
<?php if($customerDetails[$i]['mobile_no'])
|
||||
{
|
||||
echo'Mobile : '.$customerDetails[$i]['mobile_no'];
|
||||
} ?>
|
||||
<?= $customerDetails[$i]['city'] ?>,
|
||||
<?= $customerDetails[$i]['state_name'] ?>
|
||||
<?= $customerDetails[$i]['postal_code'] ? " - ".$customerDetails[$i]['postal_code'] : ""?>
|
||||
<?php if($customerDetails[$i]['mobile_no']) { ?><br>
|
||||
<?php echo'Mobile : '.$customerDetails[$i]['mobile_no']; ?>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div class="header">
|
||||
<!-- <img src="https://vijayabharathambooks.com/wp-content/uploads/2021/09/vijaya-bharatham-logo-8pt.png" alt="Business Logo" class="business-logo"><br> -->
|
||||
<div style="float:left; width:80px;margin-right:10px;"><img src="https://vbp.venbait.in/wp-content/uploads/2023/05/1111.png" alt="Business Logo" class="business-logo"/></div>
|
||||
<div style="text-align:left;font-size:12px;">From<br/>
|
||||
<?= $customerDetails[$i]['address'] ?>
|
||||
<?= $customerDetails[$i]['city'] ?> - <?= $customerDetails[$i]['postal_code'] ?></div>
|
||||
<?= $customerDetails[$i]['company_name']; ?><br>
|
||||
<?= $customerDetails[$i]['company_address']; ?><br>
|
||||
<?= $customerDetails[$i]['company_city'] ?> - <?= $customerDetails[$i]['company_postal_code']; ?>
|
||||
<?= 'Mobile : '.$customerDetails[$i]['company_mobile_no']; ?></div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
@ -105,7 +106,7 @@
|
||||
width: 4in;
|
||||
/* height: 6in; */
|
||||
margin: 20px auto;
|
||||
border: 1px solid #FFFF00;
|
||||
border: 1px solid #fff;
|
||||
padding:15px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
@ -148,16 +149,15 @@
|
||||
|
||||
<div class="bill-details">
|
||||
<!-- <div style="margin-bottom:5px;">To:</div> -->
|
||||
<?= $customerDetails[$i]['customer_name'] ?>
|
||||
<?= $customerDetails[$i]['address_1'] ?>,
|
||||
<?= $customerDetails[$i]['address_2'] ?>,
|
||||
<?= $customerDetails[$i]['city'] ?>,
|
||||
<?= $customerDetails[$i]['state'] ?> -
|
||||
<?= $customerDetails[$i]['postal_code'] ?>
|
||||
<?php if($customerDetails[$i]['mobile_no'])
|
||||
{
|
||||
echo'Mobile : '.$customerDetails[$i]['mobile_no'];
|
||||
} ?>
|
||||
<?= $customerDetails[$i]['customer_name'] ?><br>
|
||||
<?= $customerDetails[$i]['address_1'] ?>,
|
||||
<?= $customerDetails[$i]['address_2'] ?>,<br>
|
||||
<?= $customerDetails[$i]['city'] ?>,
|
||||
<?= $customerDetails[$i]['state_name'] ?>
|
||||
<?= $customerDetails[$i]['postal_code'] ? "-".$customerDetails[$i]['postal_code'] : ""?>
|
||||
<?php if($customerDetails[$i]['mobile_no']) { ?><br>
|
||||
<?php echo'Mobile : '.$customerDetails[$i]['mobile_no']; ?>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div class="header">
|
||||
@ -165,8 +165,11 @@
|
||||
<!-- <div style="float:left; width:80px;margin-right:10px;"><img src="<?= base_url('public/uploads/vijayabharathampdf.png') ?>" alt="Business Logo" class="business-logo"/></div> -->
|
||||
<div style="float:left; width:80px;margin-right:10px;"><img src="https://vbp.venbait.in/wp-content/uploads/2023/05/1111.png" alt="Business Logo" class="business-logo"/></div>
|
||||
<div style="text-align:left;font-size:12px;">From<br/>
|
||||
<?= $customerDetails[$i]['address'] ?>
|
||||
<?= $customerDetails[$i]['city'] ?> - <?= $customerDetails[$i]['postal_code'] ?></div>
|
||||
<?= $customerDetails[$i]['company_name']; ?><br>
|
||||
<?= $customerDetails[$i]['company_address']; ?><br>
|
||||
<?= $customerDetails[$i]['company_city'] ?> - <?= $customerDetails[$i]['company_postal_code']; ?>
|
||||
<?= 'Mobile : '.$customerDetails[$i]['company_mobile_no']; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -30,14 +30,28 @@
|
||||
<input type="text" class="form-control" id="subject" name="subject" value="<?= isset($template_details['subject']) ? $template_details['subject'] : '' ?>" placeholder="Subject" />
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="templatemessage" class="col-form-label">Template Message<span class="text-danger"> *</span></label>
|
||||
<textarea id="summernote-basic" name="templatemessage" class="form-control" rows="7">
|
||||
<?php if(isset($template_details['message'])){ echo $template_details['message']; }else{ ?>
|
||||
<h5>Hello {USER_NAME}, </h5>
|
||||
<p>Please, write text here!</p>
|
||||
<?php } ?>
|
||||
</textarea>
|
||||
<div class="form-group col-md-12" id="emailDescription" style="display: block;">
|
||||
<div>
|
||||
<label for="templatemessage" class="col-form-label">Template Message<span class="text-danger"> *</span></label>
|
||||
<textarea id="summernote-basic" name="templatemessage" class="form-control templatemessage" rows="7">
|
||||
<?php if(isset($template_details['message'])){ echo $template_details['message']; }else{ ?>
|
||||
<h5>Hello {USER_NAME}, </h5>
|
||||
<p>Please, write text here!</p>
|
||||
<?php } ?>
|
||||
</textarea>
|
||||
</div>
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12" id="whatsappDescription" style="display: none;">
|
||||
<div>
|
||||
<label for="whatsapptemplatemessage" class="col-form-label">Template Message<span class="text-danger"> *</span></label>
|
||||
<textarea name="whatsapptemplatemessage" class="form-control whatsapptemplatemessage" rows="7" placeholder="Write something...">
|
||||
<?php if(isset($template_details['message'])){ echo $template_details['message']; }else{ ?>Hello {USER_NAME}, Please, write text here!
|
||||
<?php } ?>
|
||||
</textarea>
|
||||
</div>
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" id="template_id" name="template_id" placeholder="hidden for template id" value="<?= isset($template_details['template_id']) ? $template_details['template_id'] : '' ?>" />
|
||||
@ -70,8 +84,18 @@
|
||||
var selectedValue = $(this).val();
|
||||
if (selectedValue === 'Email') {
|
||||
$('#emailSubject').show();
|
||||
$('#emailDescription').show();
|
||||
$('#whatsappDescription').hide();
|
||||
|
||||
$('.templatemessage').prop('required',true);
|
||||
$('.whatsapptemplatemessage').prop('required',false);
|
||||
} else {
|
||||
$('#emailSubject').hide();
|
||||
$('#emailDescription').hide();
|
||||
$('#whatsappDescription').show();
|
||||
|
||||
$('.templatemessage').prop('required',false);
|
||||
$('.whatsapptemplatemessage').prop('required',true);
|
||||
}
|
||||
});
|
||||
|
||||
@ -83,10 +107,20 @@
|
||||
emailRadio.checked = true;
|
||||
whatsappRadio.checked = false;
|
||||
$('#emailSubject').show();
|
||||
$('#emailDescription').show();
|
||||
$('#whatsappDescription').hide();
|
||||
|
||||
$('.templatemessage').prop('required',true);
|
||||
$('.whatsapptemplatemessage').prop('required',false);
|
||||
}else if(mode == 'Whatsapp'){
|
||||
emailRadio.checked = false;
|
||||
whatsappRadio.checked = true;
|
||||
$('#emailSubject').hide();
|
||||
$('#emailDescription').hide();
|
||||
$('#whatsappDescription').show();
|
||||
|
||||
$('.templatemessage').prop('required',false);
|
||||
$('.whatsapptemplatemessage').prop('required',true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user