Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
6c874beef5
@ -181,7 +181,7 @@ class ClientController extends AdminController
|
||||
print_rr($attachments);
|
||||
}
|
||||
|
||||
public function testingForReviewMail($client_id = 77, $emp_code = 'EMP001-K1', $mail_active = 0) //this function for only tsesting some logics not use for business logic
|
||||
public function testingForReviewMail($client_id = 77, $emp_code = 'EMP001-K1', $mail_active = 1) //this function for only tsesting some logics not use for business logic
|
||||
{
|
||||
|
||||
$client_policy_ids = $this->employeeModel
|
||||
@ -3708,8 +3708,8 @@ class ClientController extends AdminController
|
||||
|
||||
public function sendextraparam(){
|
||||
|
||||
$employeeRestController = new EmployeeServiceController();
|
||||
$employeeRestController->employeesEnrollmentInsert(['file_id' => 683]);
|
||||
// $employeeRestController = new EmployeeServiceController();
|
||||
// $employeeRestController->employeesEnrollmentInsert(['file_id' => 715]);
|
||||
|
||||
// $dashBoardController = new DashboardController();
|
||||
// $client_policy_data = $this->clientPolicyModel->getPolicyDetailsForRemainder($client_id=159, $client_branch_id=126);
|
||||
|
||||
@ -417,8 +417,9 @@ class DashboardController extends AdminController
|
||||
|
||||
// Send the mail notification
|
||||
$mail_result = sendMailNotification::sendMailNotification('member_reminder_mail', $params);
|
||||
// dd($mail_result);
|
||||
// $this->myLogger->logme('error', 'Mail sent result: ' . json_encode($mail_result));
|
||||
$reminder_whole_mail[] = $mail_result;
|
||||
$reminder_whole_mail[] = $mail_result[0];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -483,7 +484,7 @@ class DashboardController extends AdminController
|
||||
// Send the mail notification
|
||||
$mail_result = sendMailNotification::sendMailNotification('member_reminder_mail', $params);
|
||||
// $this->myLogger->logme('error', 'Mail sent result: ' . json_encode($mail_result));
|
||||
$reminder_whole_mail[] = $mail_result;
|
||||
$reminder_whole_mail[] = $mail_result[0];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -496,14 +497,14 @@ class DashboardController extends AdminController
|
||||
}
|
||||
|
||||
// dd($reminder_whole_mail);
|
||||
// print_rr($reminder_whole_mail); die;
|
||||
|
||||
// Process and queue bulk emails
|
||||
if (!empty($reminder_whole_mail) && count($reminder_whole_mail) > 0) {
|
||||
|
||||
$reminder_whole_mail = array_chunk($reminder_whole_mail, 20);
|
||||
|
||||
foreach ($reminder_whole_mail as $key => $value) {
|
||||
$job_details = new Jobs();
|
||||
// $job_details = new Jobs();
|
||||
$r = Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $value]);
|
||||
}
|
||||
}
|
||||
@ -517,6 +518,8 @@ class DashboardController extends AdminController
|
||||
|
||||
public function sendManualReminder($client_id, $client_branch_id)
|
||||
{
|
||||
$this->myLogger->logme('error','Log Works');
|
||||
|
||||
$this->myLogger->logme('error', "sendManualRemainder called with client_id: {$client_id}, client_branch_id: {$client_branch_id}");
|
||||
|
||||
$client_policy_data = $this->clientPolicyModel->getPolicyDetailsForRemainder($client_id, $client_branch_id);
|
||||
@ -526,6 +529,8 @@ class DashboardController extends AdminController
|
||||
|
||||
if ($client_policy_data) {
|
||||
$result = $this->sendRemainderMail($client_policy_data);
|
||||
log_message('error',json_encode($result));
|
||||
$this->myLogger->logme('error',$result);
|
||||
$this->myLogger->logme('error', "Manual Remainder Mail sending result: " . ($result ? 'success' : 'failure'));
|
||||
|
||||
if ($result) {
|
||||
@ -552,6 +557,7 @@ class DashboardController extends AdminController
|
||||
{
|
||||
return $this->respond(['status' => false, 'code' => 400, 'message' => 'No template found','message2' => 'Failed' ], 200);
|
||||
}
|
||||
|
||||
|
||||
$emp_data = $this->employeePolicyModel->getEmployeePolicyForEcard($policy_id);
|
||||
if(count($emp_data) == 0)
|
||||
|
||||
@ -108,7 +108,7 @@ class EmployeeController extends AdminController
|
||||
emp_name : $filterData['emp_name'] ?? null,
|
||||
status : $filterData['status'] ?? [],
|
||||
);
|
||||
|
||||
log_message('error',json_encode($data['employees']));
|
||||
// Set getData in $data array with the processed $filterData
|
||||
$data['getData'] = $filterData;
|
||||
}
|
||||
|
||||
@ -2097,7 +2097,7 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
|
||||
$params['dataToInsert'] = $value; //holds employee master data
|
||||
$params['notification'] = $notification;
|
||||
$params['client_data'] = $client_details;
|
||||
|
||||
$params['common'] = [];
|
||||
//store email and mail content via helper to send notification
|
||||
$emp_emails[] = sendMailNotification::sendMailNotification('member_welcome_mail', $params);
|
||||
}
|
||||
|
||||
@ -30,6 +30,8 @@ use App\Models\StateModel;
|
||||
use App\Models\PolicyTypeModel;
|
||||
use App\Models\CDMasterModel;
|
||||
use App\Models\ClientDepositModel;
|
||||
use App\Models\EmployeePolicyModel;
|
||||
use App\Models\FileModel;
|
||||
use App\Models\InsurerExcelExportTemplateModel;
|
||||
use App\Models\SettingsModel;
|
||||
use App\Models\VehicleModel;
|
||||
@ -1574,7 +1576,7 @@ class MasterController extends AdminController
|
||||
$to = $this->request->getPost('to');
|
||||
$subject = $this->request->getPost('subject');
|
||||
$mail_content = $this->request->getPost('content');
|
||||
|
||||
$common = ['mail_type'=>'test_mail_ui'];
|
||||
/*****CHOOSE ANY ONE AT A TIME, COMMENT ANOTHER ONE******/
|
||||
|
||||
/*****CALLING DIRECLT USING LIB******/
|
||||
@ -1591,7 +1593,7 @@ class MasterController extends AdminController
|
||||
/*****CALLING DIRECLT USING LIB******/
|
||||
|
||||
/*****CALLING VIA MAIL HELPER******/
|
||||
$res = MailHelper::send_email(['mail' => $to, 'subject' => $subject, 'message' => $mail_content]);
|
||||
$res = MailHelper::send_email(['mail' => $to, 'subject' => $subject,'common'=>$common ,'message' => $mail_content]);
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $res],200);
|
||||
/*****CALLING VIA MAIL HELPER******/
|
||||
|
||||
@ -1623,10 +1625,10 @@ class MasterController extends AdminController
|
||||
["filePath" => ROOTPATH."public/sample_excel/sample_inception.xls","fileName" => "sample_inception.xls"],
|
||||
["filePath" => ROOTPATH."public/assets/images/login_bg.jpg","fileName" => "login_bg.jpg"]
|
||||
];
|
||||
|
||||
|
||||
$common = ['mail_type'=>'test_mail_cli'];
|
||||
$email_id = CLI::getOption('to') ? CLI::getOption('to') : $email_id;
|
||||
$res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI', 'message' => $message,'attachments' => $attachments]);
|
||||
$res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI', 'message' => $message,'attachments' => $attachments,'common'=>$common]);
|
||||
echo "Inside the master controller";
|
||||
print_r($res);
|
||||
|
||||
}
|
||||
|
||||
125
app/Helpers/GmailResponseHandler.php
Normal file
125
app/Helpers/GmailResponseHandler.php
Normal file
@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use App\Models\EmployeePolicyModel;
|
||||
use App\Models\GmailSentHistoryModel;
|
||||
use Exception;
|
||||
|
||||
|
||||
class GmailResponseHandler{
|
||||
private $myLogger;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->myLogger = \Config\Services::mylogger();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function receive_and_distribute_param_to_functions($params)
|
||||
{
|
||||
try{
|
||||
|
||||
$this->store_gmail_response_data($params);
|
||||
$this->gmail_response_logger($params);
|
||||
$this->client_id_flag_setter($params);
|
||||
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
|
||||
$error = $e->getMessage();
|
||||
echo "An Error Occured" . $error;
|
||||
log_message('error',$error);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function store_gmail_response_data($params){
|
||||
// foreach ($params as $key => $value){
|
||||
// $prepare_data = [
|
||||
// $key => $value
|
||||
// ];
|
||||
// }
|
||||
// $data = [
|
||||
// 'email' => isset($params['params']['mail']) ? $params['params']['mail'] : null,
|
||||
// 'bcc' => isset($params['params']['bcc']) ? json_encode($params['params']['bcc']) : null,
|
||||
// 'cc' => isset($params['params']['cc']) ? json_encode($params['params']['cc']) : null,
|
||||
// 'message' => isset($params['params']['message']) ? $params['params']['message'] : null,
|
||||
// 'attachments' => isset($params['params']['attachments']) ? json_encode($params['params']['attachments']) : null,
|
||||
// 'client_id' => isset($params['params']['common']['client_id']) ? $params['params']['common']['client_id'] : null,
|
||||
// 'client_branch_id' => isset($params['params']['common']['client_branch_id']) ? $params['params']['common']['client_branch_id'] : null,
|
||||
// 'client_policy_id' => isset($params['params']['common']['client_policy_id']) ? $params['params']['common']['client_policy_id'] : null,
|
||||
// 'employee_policy_id' => isset($params['params']['common']['employee_policy_id']) ? $params['params']['common']['employee_policy_id'] : null,
|
||||
// 'employee_id' => isset($params['params']['common']['employee_id']) ? $params['params']['common']['employee_id'] : null,
|
||||
// 'mail_type' => isset($params['params']['common']['mail_type']) ? $params['params']['common']['mail_type'] : null,
|
||||
// 'gmail_api_status' => isset($params['gmail_api']['status']) ? $params['gmail_api']['status'] : null,
|
||||
// 'gmail_api_id' => isset($params['gmail_api']['data']['id']) ? $params['gmail_api']['data']['id'] : null
|
||||
// ];
|
||||
// Initialize data array
|
||||
$data = [];
|
||||
// print_r($params['params']['common']);die();
|
||||
if (isset($params['params']['common'])) {
|
||||
foreach ($params['params']['common'] as $key => $value) {
|
||||
$data[$key] = isset($value) ? $value : null;
|
||||
}
|
||||
unset($params['params']['common']);
|
||||
}
|
||||
if (isset($params['params'])){
|
||||
foreach($params['params'] as $key => $value){
|
||||
$arr = ['bcc','cc','attachments'];
|
||||
if(in_array($key,$arr)){
|
||||
$data[$key] = isset($value)?json_encode($value):null;
|
||||
}else{
|
||||
$data[$key] = isset($value)?$value:null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($params['gmail_api']['status']) && $params['gmail_api']['status'] == 1 ){
|
||||
$data['gmail_api_status'] = isset($params['gmail_api']['status']) ? $params['gmail_api']['status'] : null;
|
||||
$data['gmail_api_id'] = isset($params['gmail_api']['data']['id']) ? $params['gmail_api']['data']['id'] : null;
|
||||
$data['received_message'] = isset($params['gmail_api']['data']['labelIds']) ? json_encode($params['gmail_api']['data']['labelIds']) : null;
|
||||
|
||||
}
|
||||
elseif(isset($params['gmail_api']['status']) && $params['gmail_api']['status'] == false ){
|
||||
$data['gmail_api_status'] = $params['gmail_api']['status'];
|
||||
if(isset($params['gmail_api']['data'])){
|
||||
$data['received_message'] = json_encode($params['gmail_api']['data']);
|
||||
}
|
||||
}
|
||||
|
||||
$gmailModel = new GmailSentHistoryModel();
|
||||
$save_status = $gmailModel->insert($data);
|
||||
}
|
||||
|
||||
public function gmail_response_logger($params)
|
||||
{
|
||||
$this->myLogger->logme('error',json_encode($params));
|
||||
}
|
||||
|
||||
public function client_id_flag_setter($params)
|
||||
{
|
||||
try{
|
||||
if (isset($params['params']['common']['mail_type'])){
|
||||
if($params['params']['common']['mail_type'] == 'member_ecard_mail'){
|
||||
$employeePolicyModel = new EmployeePolicyModel();
|
||||
$update_status = $employeePolicyModel->where('id',$params['params']['common']['employee_policy_id'])->set('ecard_sent_status',1)->update();
|
||||
if($update_status){
|
||||
$this->myLogger->logme('error',"ecard_sent_status updated for ".$params['params']['common']['employee_policy_id']);
|
||||
}else{
|
||||
$this->myLogger->logme('error','ecard_sent_status failed to update');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch(Exception $e){
|
||||
$error = $e->getMessage();
|
||||
$this->myLogger->logme('error','An Error Occured - '.$error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -11,7 +11,7 @@ use Firebase\JWT\SignatureInvalidException;
|
||||
// use Psr\Http\Message\RequestInterface;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use ReflectionClass;
|
||||
|
||||
use Exception;
|
||||
use App\Models\EmployeeModel;
|
||||
use App\Models\LevelContactModel;
|
||||
|
||||
|
||||
@ -11,7 +11,6 @@ use PHPMailer\PHPMailer\Exception;
|
||||
|
||||
use App\Models\JobModel;
|
||||
|
||||
|
||||
class MailHelper
|
||||
{
|
||||
public static function send_email_smtp($params)
|
||||
@ -94,7 +93,7 @@ class MailHelper
|
||||
$subject = $params['subject'];
|
||||
$message = $params['message'];
|
||||
$attachments = isset($params['attachments']) && count($params['attachments']) ? $params['attachments'] : [];
|
||||
|
||||
$common = isset($params['common'])?$params['common']:'';
|
||||
//check BCC mail
|
||||
if (isset($params['bcc'])) {
|
||||
$bcc = $params['bcc'];
|
||||
@ -118,32 +117,42 @@ class MailHelper
|
||||
if(isset($params['reply_to']) && !empty($params['reply_to'])){
|
||||
$reply_to = $params['reply_to'];
|
||||
}
|
||||
$MailDataHelper = new GmailResponseHandler();
|
||||
|
||||
$res['params'] = $params;
|
||||
try {
|
||||
|
||||
$res = $gmailapi->sendMessage($emaill, $subject, $message, 'no-reply@nhanceindia.in', $reply_to, $cc, $bcc,$attachments);
|
||||
|
||||
if($res['status'])
|
||||
$res['gmail_api'] = $gmailapi->sendMessage($emaill, $subject, $message, 'no-reply@nhanceindia.in', $reply_to, $cc, $bcc,$attachments);
|
||||
if($res['gmail_api']['status'])
|
||||
{
|
||||
$response = $res;
|
||||
$MailDataHelper->receive_and_distribute_param_to_functions($response);
|
||||
return json_encode(['status' => 'success','code' => 200, 'message'=>('Email Sent Successfully...'.$emaill),'data' => $res,],200);
|
||||
}
|
||||
else
|
||||
{
|
||||
$myLogger->logme('error', "mail sent failed - $emaill");
|
||||
$response = $res;
|
||||
$MailDataHelper->receive_and_distribute_param_to_functions($response);
|
||||
return json_encode(['status' => 'failed','code' => 404,'message'=>( 'Email Sent Failed...' . $emaill ),'data' => $res ],404);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
$msg = $e->getMessage();
|
||||
$msg['error'] = $e->getMessage();
|
||||
$msg['params'] = $params;
|
||||
$myLogger->logme('error', "mail sent failed - $msg");
|
||||
$response = $msg;
|
||||
$MailDataHelper->receive_and_distribute_param_to_functions($response);
|
||||
return json_encode(['status' => 'failed','code' => 500,'data' => $msg],500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function bulk_mail(array $mails = [])
|
||||
{
|
||||
// print_r();die;
|
||||
// print_r($mails);die;
|
||||
$model = new JobModel();
|
||||
$start = microtime(true);
|
||||
$runtime= 0;
|
||||
@ -156,7 +165,9 @@ class MailHelper
|
||||
return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...'],200);
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
return json_encode(['status' => 'failed','code' => 500],500);
|
||||
$error = $th->getMessage();
|
||||
log_message('error',$error);
|
||||
return json_encode(['status' => 'failed','code' => 500,'error'=>$error],500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -33,6 +33,7 @@ class EmployeePolicyModel extends Model
|
||||
"rand_string",
|
||||
"is_active",
|
||||
"claim_status",
|
||||
'ecard_sent_status'
|
||||
];
|
||||
|
||||
// Callbacks
|
||||
@ -125,7 +126,6 @@ class EmployeePolicyModel extends Model
|
||||
->join('client_branch', 'emp.client_branch_id = client_branch.id') //cm - client master
|
||||
->orderBy('emp.emp_code', 'ASC')
|
||||
->orderBy('employee_polices.employee_id', 'ASC');
|
||||
|
||||
// Conditionally add where clauses
|
||||
if ($client_id != 0 && !empty($client_id)) {
|
||||
$result->where('emp.client_id', $client_id);
|
||||
@ -194,6 +194,7 @@ class EmployeePolicyModel extends Model
|
||||
$result->where('employee_polices.is_active', 1)
|
||||
->where('employee_polices.status', 'active')
|
||||
->where('employee_polices.tpa_id is not null')
|
||||
->where('employee_polices.ecard_sent_status',0)
|
||||
->where('emp.relationship','Self');
|
||||
|
||||
return $result->findAll();
|
||||
|
||||
11
app/Models/GmailSentHistoryModel.php
Normal file
11
app/Models/GmailSentHistoryModel.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class GmailSentHistoryModel extends Model{
|
||||
protected $table = 'gmail_sent_history';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = ["id", "mail", "bcc", "cc", "message", "attachments", "client_id", "client_branch_id", "client_policy_id", "employee_policy_id", "employee_id", "mail_type", "gmail_api_status", "gmail_api_id", "created_by", "created_at", "updated_by", "updated_at", "isactive","received_message"];
|
||||
}
|
||||
56
phpqueue.sh
Executable file
56
phpqueue.sh
Executable file
@ -0,0 +1,56 @@
|
||||
!/bin/bash
|
||||
while true; do
|
||||
echo "Running job at $(date)"
|
||||
/usr/bin/php /opt/lampp/htdocs/nhance/public/index.php cli/processjob
|
||||
!/bin/bash
|
||||
!/bin/bash
|
||||
|
||||
# Read the Job_Queue variable from the temporary file
|
||||
#!/bin/bash
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
# Define the root directory for the project and PID file path
|
||||
#!/bin/bash
|
||||
|
||||
# Define paths
|
||||
# ROOT_DIR=$(dirname "$(realpath "$0")")
|
||||
# JOB_QUEUE_FILE="$ROOT_DIR/job_queue"
|
||||
# PID_FILE="$ROOT_DIR/phpqueue.pid"
|
||||
|
||||
|
||||
# # Check if the script is already running
|
||||
# if [[ -f "$PID_FILE" ]] && kill -0 "$(cat $PID_FILE)" 2>/dev/null; then
|
||||
# echo "phpqueue.sh is already running. Exiting."
|
||||
# exit 1
|
||||
# fi
|
||||
|
||||
# # Write the current process ID (PID) to the PID file
|
||||
# echo $$ > "$PID_FILE"
|
||||
|
||||
# # Ensure the PID file is removed on script exit
|
||||
# trap "rm -f $PID_FILE" EXIT
|
||||
|
||||
# # Main loop
|
||||
# while true; do
|
||||
# # Check if the Job_Queue file exists
|
||||
# if [[ ! -f "$JOB_QUEUE_FILE" ]]; then
|
||||
# echo "Job Queue file not found."
|
||||
# exit 1
|
||||
# fi
|
||||
|
||||
# # Read the value of Job_Queue from the file
|
||||
# Job_Queue=$(cat "$JOB_QUEUE_FILE")
|
||||
|
||||
# if [[ "$Job_Queue" -eq 1 ]]; then
|
||||
# /usr/bin/php /opt/lampp/htdocs/nhance/public/index.php cli/processjob
|
||||
# else
|
||||
# echo "No job to process."
|
||||
# fi
|
||||
|
||||
# # Sleep for 1 second before the next iteration
|
||||
# sleep 1
|
||||
# done
|
||||
|
||||
Loading…
Reference in New Issue
Block a user