Auto notification
This commit is contained in:
parent
1b3c9b8520
commit
833cb29734
8
.env
8
.env
@ -152,7 +152,7 @@ WAAI_INSTANCE = '656876690A9FD'
|
||||
#--------------------------------------------------------------------
|
||||
# Email Host Name,User,Passcode And Port
|
||||
#--------------------------------------------------------------------
|
||||
SMTP_Host = 'smtp.sendgrid.net'
|
||||
SMTP_User = 'apikey'
|
||||
SMTP_Pass = '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'
|
||||
SMTP_Port = 587
|
||||
SMTP_HOST = 'smtp.sendgrid.net'
|
||||
SMTP_USER = 'apikey'
|
||||
SMTP_PASS = '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'
|
||||
SMTP_PORT = '587'
|
||||
|
||||
@ -130,11 +130,12 @@ define('order_child_column', ["invoice_id","wp_api_line_items_id","customer_id"]
|
||||
define('WAAI_TOKEN', getenv('WAAI_TOKEN'));
|
||||
define('WAAI_INSTANCE', getenv('WAAI_INSTANCE'));
|
||||
|
||||
define('SMTP_Host', getenv('SMTP_Host'));
|
||||
define('SMTP_User', getenv('SMTP_User'));
|
||||
define('SMTP_Pass', getenv('SMTP_Pass'));
|
||||
define('SMTP_Port', getenv('SMTP_Port'));
|
||||
define('SMTP_HOST', getenv('SMTP_HOST'));
|
||||
define('SMTP_USER', getenv('SMTP_USER'));
|
||||
define('SMTP_PASS', getenv('SMTP_PASS'));
|
||||
define('SMTP_PORT', getenv('SMTP_PORT'));
|
||||
## GET Constant Based on Env File Ends...
|
||||
define('DUMMY_VAR', $_ENV['WAAI_TOKEN']);
|
||||
|
||||
define('SEND_WAAI_URL', 'https://waai.in/api/send');
|
||||
define('SEND_WAAI_GROUP_URL', 'https://waai.in/api/send_group');
|
||||
|
||||
@ -28,22 +28,22 @@ class Email extends BaseConfig
|
||||
/**
|
||||
* SMTP Server Address
|
||||
*/
|
||||
public string $SMTPHost = SMTP_Host;
|
||||
public string $SMTPHost = 'smtp.sendgrid.net';
|
||||
|
||||
/**
|
||||
* SMTP Username
|
||||
*/
|
||||
public string $SMTPUser = SMTP_User;
|
||||
public string $SMTPUser = 'apikey';
|
||||
|
||||
/**
|
||||
* SMTP Password
|
||||
*/
|
||||
public string $SMTPPass = SMTP_Pass;
|
||||
public string $SMTPPass = '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';
|
||||
|
||||
/**
|
||||
* SMTP Port
|
||||
*/
|
||||
public int $SMTPPort = SMTP_Port;
|
||||
public int $SMTPPort = 587;
|
||||
|
||||
/**
|
||||
* SMTP Timeout (in seconds)
|
||||
|
||||
@ -65,7 +65,6 @@ class Customer extends BaseController
|
||||
// Retrieve subscriber data based on the customer ID
|
||||
$subscriberData = $customerModel->getSubscriberDataByCustomerId($id);
|
||||
$data['subscriptionData'] = $subscriberData;
|
||||
|
||||
// Fetch invoice data for the customer
|
||||
$CustomerModel = new CustomerModel();
|
||||
$invoices = $CustomerModel->getInvoicesByCustomerId($id);
|
||||
@ -483,7 +482,7 @@ class Customer extends BaseController
|
||||
// Now you can use $whereCondition in your SQL query
|
||||
$db = \Config\Database::connect();
|
||||
// $sql = "SELECT customer_id,CONCAT(first_name,'',last_name) as customer_name,email,mobile_no FROM customers WHERE ".$whereCondition;
|
||||
$sql = "SELECT CA.city,CA.state,I.invoice_date,C.customer_id,CONCAT(C.first_name,' ',C.last_name) as customer_name,C.email,C.mobile_no ,S.to_subscription as due_date, C.isactive ,count(I.invoice_id) as invoice_count_raised_by_customer, S.scheme_id , CM.name as scheme_name ,CM.name,
|
||||
$sql = "SELECT CA.city,CA.state,I.invoice_date,C.customer_id,CONCAT(C.first_name,' ',C.last_name) as customer_name,C.email,C.mobile_no ,S.to_subscription as due_date, C.isactive ,count(I.invoice_id) as invoice_count_raised_by_customer, S.scheme_id , BK.title as scheme_name ,CM.name as scheme_type_name,
|
||||
DATE_FORMAT(S.to_subscription, '%d/%m/%Y') AS formatted_due_date,
|
||||
DATE_FORMAT(I.invoice_date, '%d/%m/%Y') AS formatted_invoice_date
|
||||
FROM customers as C
|
||||
@ -491,6 +490,7 @@ class Customer extends BaseController
|
||||
LEFT JOIN customer_addresses CA on CA.customer_id = C.customer_id and CA.address_type = 1 and CA.isactive = 1
|
||||
LEFT JOIN subscription S on S.customer_id = C.customer_id
|
||||
LEFT JOIN book_categories BC on BC.book_id = S.scheme_id
|
||||
LEFT JOIN books BK on BK.book_id = S.scheme_id
|
||||
LEFT JOIN category CM on CM.id = BC.category_id
|
||||
WHERE C.isactive = 1 AND ".$whereCondition." GROUP BY C.customer_id";
|
||||
$this->logger->info("Customer Group: SQL = ".$sql);
|
||||
|
||||
@ -21,11 +21,12 @@ class Home extends BaseController
|
||||
} else {
|
||||
$where = [];
|
||||
}
|
||||
$model = new HomeModel();
|
||||
$model = new HomeModel();
|
||||
$data['customer'] = $model->customers($where);
|
||||
$data['customer']['label'] = "Customer";
|
||||
$data['invoice'] = $model->invoice();
|
||||
$data['active_category'] = $model->schemes();
|
||||
// $data['active_category'] = $model->schemes();
|
||||
$data['active_schemes'] = $model->active_schemes();
|
||||
$data['expiring_membership'] = $model->expiring_membership_list();
|
||||
// $data['active_category'] = array_filter($model->schemes(), function ($element) {
|
||||
// return $element['count'] !== '0' ;
|
||||
|
||||
@ -536,8 +536,8 @@ class Invoice extends BaseController
|
||||
$params->number = (int)'91' . $recipient_mobile;
|
||||
$params->type = "text";
|
||||
$params->message = $template;
|
||||
$params->instance_id = WAAI_INSTANCE;
|
||||
$params->access_token = WAAI_TOKEN;
|
||||
$params->instance_id = $_ENV['WAAI_INSTANCE'];
|
||||
$params->access_token = $_ENV['WAAI_TOKEN'];
|
||||
$this->logger->info("Invoice: approve notification Email Request data = ".json_encode($records));
|
||||
$email_result = $notification->sendEmail($records);
|
||||
$this->logger->info("Invoice: approve notification Email Response = " . json_encode($email_result));
|
||||
|
||||
@ -372,104 +372,134 @@ class Notifications extends BaseController
|
||||
return redirect()->route('campaign_creation');
|
||||
}
|
||||
|
||||
public function getExpCustomerDetail($window_time = null)
|
||||
{
|
||||
// Step 1: add the days to retrive th e data//
|
||||
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 custoemr 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');
|
||||
|
||||
// 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);
|
||||
// print_r($modifiedQuery);die;
|
||||
if (empty($modifiedQuery)) {
|
||||
|
||||
$this->logger->info('There is no sub query');
|
||||
|
||||
//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;
|
||||
$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) {
|
||||
$templateName = $NotificationModel->getTempName();
|
||||
if (empty($templateName)) {
|
||||
|
||||
$this->logger->info('There is no template found by the name of EXPIRAY_NOTIFY_TEMPLATE');
|
||||
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;
|
||||
}
|
||||
$userFirstName = $row['first_name'];
|
||||
$userLastName = $row['last_name'];
|
||||
$fullName = $userFirstName . ' ' . $userLastName;
|
||||
|
||||
$schemename = $row['title'];
|
||||
$expirydate = $row['to_subscription'];
|
||||
if (empty($fullName)) {
|
||||
|
||||
$this->logger->info('There is no subcription Name');
|
||||
return;
|
||||
}
|
||||
//Step 4: Prepare email content based on the template
|
||||
$emailContent = $templateName[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,
|
||||
|
||||
];
|
||||
$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);
|
||||
|
||||
// Step 5:Send email using NotificationHelper
|
||||
$emailResult = $notification->sendEmail($emailData);
|
||||
|
||||
|
||||
if (isset($emailResult['success'])) {
|
||||
echo 'Email sent successfully';
|
||||
} else {
|
||||
echo 'Failed to send email';
|
||||
|
||||
}
|
||||
$templateName = $NotificationModel->getTempName();
|
||||
}
|
||||
}
|
||||
$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
|
||||
}
|
||||
|
||||
public function auto_scheduled_notification()
|
||||
{
|
||||
$this->logger->info("Auto Scheduled Notification Started");
|
||||
$nc_id = "";
|
||||
$model = new NotificationModel();
|
||||
$model->setTable('notification_campaign');
|
||||
$where = ['status'=>0];
|
||||
$notification_campaign_result = $model->where($where)->findAll();
|
||||
$today = date('Y-m-d');
|
||||
$customer_details = array();
|
||||
$customer_details_template = array();
|
||||
if (!empty($notification_campaign_result)) {
|
||||
foreach ($notification_campaign_result as $n => $ncr) {
|
||||
if($today == $ncr['scheduled_date']){
|
||||
// echo "<pre>";print_r($ncr);echo "</pre>";die; //working fine.
|
||||
$nc_id = $ncr['campaign_id'];
|
||||
$this->logger->info("Step 1 : (Campaign) Scheduled Date = " .$ncr['scheduled_date']."/".$ncr['scheduled_time'].", Today = ".$today );
|
||||
$customer_details = $this->auto_scheduled_template_details($ncr);
|
||||
$customer_details_template = $this->auto_scheduled_template_details($ncr);
|
||||
}else{
|
||||
$this->logger->info("Step 1 : (Campaign) Scheduled Date = " .$ncr['scheduled_date'].", Today = ".$today );
|
||||
}
|
||||
}
|
||||
if(!empty($customer_details)){
|
||||
$customer_details = $this->auto_scheduled_send_message($customer_details);
|
||||
if(!empty($customer_details_template)){
|
||||
// echo "<pre>";print_r($customer_details_template);echo "</pre>";die;
|
||||
$customer_details = $this->auto_scheduled_send_message($customer_details_template);
|
||||
if(!empty($customer_details)){
|
||||
$this->auto_scheduled_notification_campaign_status($nc_id);
|
||||
$nc_id = "";
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$this->logger->info("Step 1 : Campaign details not found ");
|
||||
@ -486,12 +516,15 @@ class Notifications extends BaseController
|
||||
$model->setTable('templates');
|
||||
$where = ['template_id'=>$template_id];
|
||||
$template_result = $model->where($where)->findAll();
|
||||
// echo "<pre>";print_r($template_result);echo "</pre>";die;
|
||||
$flattened_array = array(); // its have customer Details...
|
||||
if (!empty($template_result)) {
|
||||
$group_details = array();
|
||||
foreach ($template_result as $t => $tr) {
|
||||
$this->logger->info("Step 2 : (Template) id = ".$tr['template_id']."/".$tr['template_name']." , Template Mode = ".$tr['mode']." NotifyCampian Mode = ".$nc_mode);
|
||||
$details = $this->auto_scheduled_customer_group_details($tr,$ncr);
|
||||
// echo "<pre>";print_r($details);echo "</pre>";die;
|
||||
|
||||
if(!empty($details)){
|
||||
foreach ($details as $d => $dr) {
|
||||
$group_details[] = $dr['group_query_results'];
|
||||
@ -504,7 +537,7 @@ class Notifications extends BaseController
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// echo "<pre>";print_r($flattened_array);echo "</pre>";die;
|
||||
// Don't Delete It Duplication Check 07-12-2023
|
||||
// // Extract customer IDs using array_column
|
||||
// $customer_ids = array_column($flattened_array, 'customer_id');
|
||||
@ -522,6 +555,7 @@ class Notifications extends BaseController
|
||||
// }
|
||||
// // Now $uniqueData contains entries with unique customer IDs
|
||||
// print_r($unique_data);
|
||||
// echo "<pre>";print_r($flattened_array);echo "</pre>";die;
|
||||
}
|
||||
}else{
|
||||
$this->logger->info("Step 2 : Template Details details not found");
|
||||
@ -531,6 +565,7 @@ class Notifications extends BaseController
|
||||
}
|
||||
|
||||
public function auto_scheduled_customer_group_details($tr_object,$ncr_object){
|
||||
|
||||
$this->logger->info("To Retrieved Customer Group Details for Auto Scheduled");
|
||||
$group_id = $ncr_object['group_id'];
|
||||
$nc_mode = $ncr_object['mode'];
|
||||
@ -545,6 +580,7 @@ class Notifications extends BaseController
|
||||
|
||||
if (!empty($group_arr_result)) {
|
||||
foreach ($group_arr_result as $g => $gar) {
|
||||
|
||||
$group_details[$g]['group_query'] = $gar['group_query'];
|
||||
$group_details[$g]['group_id'] = $gar['group_id'];
|
||||
$db = \Config\Database::connect();
|
||||
@ -557,6 +593,7 @@ class Notifications extends BaseController
|
||||
$row['nc_mode'] = $nc_mode; // mode from notification_campaign Table Cross Check purpose
|
||||
$row['t_mode'] = $t_mode; // mode from template Table Cross Check purpose
|
||||
$row['template_message'] = $tr_object['message'];
|
||||
$row['template_subject'] = $tr_object['subject'];
|
||||
$row['campaign_id'] = $ncr_object['campaign_id'];
|
||||
}
|
||||
$group_details[$g]['group_query_results'] = $results;
|
||||
@ -578,49 +615,134 @@ class Notifications extends BaseController
|
||||
|
||||
public function auto_scheduled_send_message($customer_details){
|
||||
$this->logger->info("To Send Message on Customer for Auto Scheduled");
|
||||
$return_statement = array();
|
||||
if (!empty($customer_details)) {
|
||||
foreach($customer_details as $c => $cd) {
|
||||
|
||||
switch($cd['nc_mode']) {
|
||||
case "Whatsapp":
|
||||
$this->auto_scheduled_whatsapp($cd);
|
||||
$whatsapp = $this->auto_scheduled_whatsapp($cd);
|
||||
array_push($return_statement, $whatsapp);
|
||||
break;
|
||||
case "Email":
|
||||
$this->auto_scheduled_email($cd);
|
||||
$email = $this->auto_scheduled_email($cd);
|
||||
array_push($return_statement, $email);
|
||||
break;
|
||||
default:
|
||||
$this->logger->error("Can't able to identity the mode for Auto Scheduled");
|
||||
$this->logger->error($cd["customer_name"]." Can't able to identity the mode for Auto Scheduled");
|
||||
array_push($return_statement, $cd["customer_name"]." Can't able to identity the mode for Auto Scheduled");
|
||||
}
|
||||
}
|
||||
}
|
||||
return $return_statement;
|
||||
}
|
||||
|
||||
public function auto_scheduled_whatsapp($cd){
|
||||
// $cd["city"]
|
||||
// $cd["state"]
|
||||
// $cd["invoice_date"]
|
||||
// $cd["customer_id"]
|
||||
echo $cd["customer_name"];
|
||||
// $cd["email"]
|
||||
// $cd["mobile_no"]
|
||||
// $cd["due_date"]
|
||||
// $cd["isactive"]
|
||||
// $cd["invoice_count_raised_by_customer"]
|
||||
// $cd["scheme_id"]
|
||||
// $cd["name"]
|
||||
// $cd["group_id"]
|
||||
// $cd["nc_mode"]
|
||||
// $cd["t_mode"]
|
||||
// $cd["template_message"]
|
||||
// $cd["campaign_id"]
|
||||
echo "<pre>";
|
||||
print_r($cd);
|
||||
echo "</pre>";
|
||||
}
|
||||
public function auto_scheduled_email($cd){
|
||||
echo $cd["customer_name"];
|
||||
echo "<pre>";
|
||||
print_r($cd);
|
||||
echo "</pre>";
|
||||
// // $cd["city"]
|
||||
// // $cd["state"]
|
||||
// // $cd["invoice_date"]
|
||||
// // $cd["customer_id"]
|
||||
// echo $cd["customer_name"];
|
||||
// // $cd["email"]
|
||||
// // $cd["mobile_no"]
|
||||
// // $cd["due_date"]
|
||||
// // $cd["isactive"]
|
||||
// // $cd["invoice_count_raised_by_customer"]
|
||||
// // $cd["scheme_id"]
|
||||
// // $cd["name"]
|
||||
// // $cd["group_id"]
|
||||
// // $cd["nc_mode"]
|
||||
// // $cd["t_mode"]
|
||||
// // $cd["template_message"]
|
||||
// // $cd["campaign_id"]
|
||||
$this->logger->info("Auto Notification : Email Customer Details = " . json_encode($cd));
|
||||
|
||||
if(!empty($cd["template_message"] )){
|
||||
|
||||
$emailContent = $cd["template_message"] ;
|
||||
$emailContent = str_replace("{USER_NAME}", $cd["customer_name"], $emailContent);
|
||||
$emailContent = str_replace("{SCHEME_NAME}", $cd["name"], $emailContent);
|
||||
$emailContent = str_replace("{EXPIRY_DATE}", $cd["formatted_due_date"], $emailContent);
|
||||
|
||||
$emailData = [
|
||||
'template_name' => '',
|
||||
'recipient_email' => $cd["email"],
|
||||
'subject' => $cd["template_subject"] != "" ? $cd["template_subject"] : ucfirst(str_replace('_', ' ', (string)$cd["name"]))." Notification" ,
|
||||
'description' => $emailContent,
|
||||
];
|
||||
|
||||
|
||||
$notification = new NotificationHelper();
|
||||
// $emailResult = $notification->sendEmail($emailData);
|
||||
$emailResult = array();
|
||||
|
||||
$this->logger->info("Auto Notification : Email Content = " . $emailContent);
|
||||
$this->logger->info("Auto Notification : Email Response = " . json_encode($emailResult));
|
||||
if (isset($emailResult['success'])) {
|
||||
$this->logger->info("Auto Notification : ".$cd["customer_name"]."`s mail sended Mail ID = ".$cd["email"]);
|
||||
return $cd["customer_name"]." mail sended";
|
||||
} else {
|
||||
$this->logger->info("Auto Notification : ".$cd["customer_name"]."`s mail not sended Mail ID = ".$cd["email"]);
|
||||
return $cd["customer_name"]." mail not sended";
|
||||
}
|
||||
}else{
|
||||
$this->logger->info('There is no email template found');
|
||||
return $cd["customer_name"]." mail template not found";
|
||||
}
|
||||
}
|
||||
public function auto_scheduled_whatsapp($cd){
|
||||
|
||||
if(!empty($cd["template_message"])){
|
||||
if (empty($cd["mobile_no"])) {
|
||||
$this->logger->info('There is no mobile number Founded');
|
||||
return $cd["customer_name"]." mobile number not found";
|
||||
}
|
||||
echo "<pre>";print_r($cd);echo "</pre>";die;
|
||||
$this->logger->info('testing purpose ==> '.$cd["customer_name"]." -- ".$cd["name"]." -- ".$cd["due_date"]);
|
||||
|
||||
$whatsappContent = $cd["template_message"];
|
||||
$whatsappContent = str_replace("{USER_NAME}", $cd["customer_name"], $whatsappContent);
|
||||
$whatsappContent = str_replace("{SCHEME_NAME}", $cd["name"], $whatsappContent);
|
||||
$whatsappContent = str_replace("{EXPIRY_DATE}", $cd["formatted_due_date"], $whatsappContent);
|
||||
|
||||
|
||||
$params = (object) Null;
|
||||
$url = SEND_WAAI_URL;
|
||||
$params->number = (int)'91' . $cd["mobile_no"];
|
||||
$params->type = "text";
|
||||
$params->message = $whatsappContent;
|
||||
$params->instance_id = $_ENV['WAAI_INSTANCE'];
|
||||
$params->access_token = $_ENV['WAAI_TOKEN'];
|
||||
$this->logger->info("Auto Notification : Whatsapp Content = " . $whatsappContent);
|
||||
$this->logger->info($cd["name"]." Whatsapp Request = " . json_encode($params));
|
||||
$this->logger->info($cd["name"]." Whatsapp Request type b4 = " . gettype($params));
|
||||
$notification = new NotificationHelper();
|
||||
// $whatsapp_result = $notification->sendWhatsAppMessage($url, "POST", $params);
|
||||
$whatsapp_result = array();
|
||||
// $this->logger->info($cd["name"]." Whatsapp Reponse = " .$whatsapp_result);
|
||||
|
||||
return $cd["customer_name"]."/".$cd["name"]." whatsapp template found not found";
|
||||
}else{
|
||||
$this->logger->info('There is no Whatsapp template found by the name of '.$cd["name"]);
|
||||
return $cd["customer_name"]."/".$cd["name"]." whatsapp template found not found";
|
||||
}// $Whatsapp Template Name
|
||||
}
|
||||
|
||||
public function auto_scheduled_notification_campaign_status($campaign_id){
|
||||
// echo "<br> have to update...................";
|
||||
$model = new NotificationModel();
|
||||
$model->setTable('notification_campaign');
|
||||
|
||||
$where = ['isactive' => 1, 'status' => 0, 'campaign_id' => (int) $campaign_id];
|
||||
$data = ['status' => 1];
|
||||
|
||||
if ($model->where($where)->update($data)) {
|
||||
// Update successful
|
||||
echo "Update successful!";
|
||||
} else {
|
||||
// Update failed
|
||||
echo "Update failed!";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -47,12 +47,28 @@ class HomeModel extends Model
|
||||
return $invoice;
|
||||
}
|
||||
|
||||
public function schemes(){
|
||||
$query = $this->db->table('category AS C')
|
||||
->select('C.id,C.name,LEFT(C.name, 1) AS first_letter, COUNT(S.customer_id) AS count')
|
||||
->join('subscription AS S', 'C.id = S.scheme_id', 'left')
|
||||
->where(['C.isactive'=>1,'C.business_id'=>1])
|
||||
->groupBy('C.id, S.scheme_id');
|
||||
// public function schemes(){
|
||||
// $query = $this->db->table('category AS C')
|
||||
// ->select('C.id,C.name,LEFT(C.name, 1) AS first_letter, COUNT(BC.category_id) AS count')
|
||||
// ->join('book_categories AS BC', 'C.id = BC.category_id', 'left')
|
||||
// ->where(['C.isactive'=>1,'C.business_id'=>1])
|
||||
// ->groupBy('C.id');
|
||||
// $results = $query->get()->getResultArray();
|
||||
// return $results;
|
||||
// }
|
||||
|
||||
public function active_schemes()
|
||||
{
|
||||
$query = $this->db->table('subscription AS S')
|
||||
->select('S.business_id,BK.title as name,BK.book_id as id,S.scheme_id,LEFT(BK.title, 1) AS first_letter,COUNT(S.customer_id) AS count,BI.wp_img_url')
|
||||
->join('customers AS C', 'C.customer_id = S.customer_id AND C.isactive = 1', 'left')
|
||||
->join('books AS BK', 'BK.book_id = S.scheme_id', 'left')
|
||||
->join('book_categories AS BC', 'BC.book_id = S.scheme_id AND BC.isactive = 1', 'left')
|
||||
->join('category AS CM', 'CM.id = BC.category_id AND C.isactive = 1', 'left')
|
||||
->join('book_images AS BI', 'BI.book_id = S.scheme_id AND BI.isactive = 1', 'left')
|
||||
->where('LOWER(CM.name)', strtolower("Membership"))
|
||||
->where(['S.business_id' => 1,'BK.isactive' => 1])
|
||||
->groupBy('S.scheme_id');
|
||||
$results = $query->get()->getResultArray();
|
||||
return $results;
|
||||
}
|
||||
|
||||
@ -165,10 +165,10 @@ public function customerGroupQueryExecution($queries){
|
||||
}
|
||||
}
|
||||
|
||||
public function getTempName()
|
||||
public function getTempName($constant)
|
||||
{
|
||||
$db = \Config\Database::connect();
|
||||
$query = "SELECT * FROM templates WHERE template_name = '".EXPIRAY_NOTIFY_TEMPLATE_EMAIL."'";
|
||||
$query = "SELECT * FROM templates WHERE template_name = '".$constant."'";
|
||||
// print_r($query);die;
|
||||
$result = $db->query($query)->getResultArray();
|
||||
if (isset($result)) {
|
||||
|
||||
@ -82,7 +82,7 @@
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="bterms" class="col-form-label">Terms & Condition<span class="text-danger">*</span></label>
|
||||
<textarea class="form-control" id="terms" name="bterms" rows="5" cols="50"><?= $businesses['terms'];?></textarea>
|
||||
<textarea class="form-control" id="terms" name="bterms" rows="5" cols="50"></textarea>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@ -580,6 +580,26 @@ function restriction(event,temporary_flag) {
|
||||
</script>
|
||||
<script>
|
||||
document.getElementById('myForm').addEventListener('submit', function(event) {
|
||||
var table = document.getElementById("itemTable").getElementsByTagName("tbody")[0];
|
||||
var rows = table.getElementsByTagName("tr");
|
||||
var hasValue = false;
|
||||
var rowCounter = rows.length; // Get the current number of rows
|
||||
|
||||
// Check if any existing fields are empty
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
var cells = rows[i].getElementsByTagName("td");
|
||||
for (var j = 0; j < cells.length; j++) {
|
||||
var input = cells[j].querySelector('input, select');
|
||||
if (input && input.value.trim() === "") {
|
||||
alert("Field in row " + (i + 1) + " is empty.");
|
||||
$('#scrollable-modal').modal('hide');
|
||||
return; // Exit the loop after the first empty field is found.
|
||||
} else {
|
||||
hasValue = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasValue) {
|
||||
var form = event.target;
|
||||
|
||||
if (form.checkValidity() === false) {
|
||||
@ -590,7 +610,7 @@ function restriction(event,temporary_flag) {
|
||||
} else {
|
||||
|
||||
$('#save').prop('disabled', true);
|
||||
}
|
||||
}}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@ -151,14 +151,18 @@
|
||||
<div class="card-body">
|
||||
<h4 class="header-title mb-2">Schemes</h4>
|
||||
<div class="conversation-list" data-simplebar style="max-height: 200px !important"> <!-- default 460px -->
|
||||
<?php foreach ($active_category as $a) : ?>
|
||||
|
||||
<?php foreach ($active_schemes as $i => $a) : ?>
|
||||
<div class="media">
|
||||
<?php if (!empty($a['wp_img_url'])) { ?>
|
||||
<img src="<?= $a['wp_img_url']; ?>" alt="table-user"
|
||||
class="mr-3 rounded avatar-md">
|
||||
<?php } else { ?>
|
||||
<div class="avatar-md mr-3">
|
||||
<div class="avatar-title bg-light rounded text-body font-20 font-weight-semibold">
|
||||
<?= $a['first_letter']; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="media-body">
|
||||
<h5 class="my-1"><?= $a['name']; ?></h5>
|
||||
<p class="text-muted mb-0">
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
}
|
||||
.invoice {
|
||||
width: 48%;
|
||||
height: 150px;
|
||||
height: 225px;
|
||||
margin-left: 2px;
|
||||
float: left;
|
||||
page-break-inside: avoid;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user