diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index 3d943692..818fe4b5 100755
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -363,7 +363,8 @@ $routes->cli('cli/processjobs', 'JobWorker::processJobs');
$routes->get("processjob", "JobWorker::processJob");
$routes->cli('cli/new_gmail_token', 'MasterController::generateNewGmailAPIToken');
-$routes->cli('cli/send_mail_cli(/:any)?', 'MasterController::testGmailAPIViaCLI$1');
+$routes->cli('cli/send_mail_cli', 'MasterController::testGmailAPIViaCLI');
+$routes->cli('cli/check_bounce_mail_cli', 'MasterController::testCheckBounceMails');
$routes->cli('cli/app_check_list', 'MasterController::appCheckList');
$routes->cli('cli/new_gdrive_token', 'GoogleDriveController::generateNewGoogleDriveAccessToken');
diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php
index 7c5d3f01..569f1c65 100755
--- a/app/Controllers/EmployeeController.php
+++ b/app/Controllers/EmployeeController.php
@@ -279,7 +279,7 @@ class EmployeeController extends AdminController
$data['fileList'] = $this->fileModel
->select([
- 'files.*',
+ 'files.id','files.file_name','files.created_by','files.created_at','files.is_active','files.status','files.client_id','files.policy_id','files.client_branch_id','files.action','files.uploaded_by',
'up.emp_code',
'up.first_name',
'c.short_name',
@@ -301,9 +301,10 @@ class EmployeeController extends AdminController
->join('client_branch cb', 'files.client_branch_id = cb.id', 'left')
->join('policy_type', 'policy_type.id = cp.policy_type_id')
->join('clients c', 'files.client_id = c.id and files.client_id = cp.client_id', 'left')
- ->where('files.created_by', get_session_userid())
+ // ->where('files.created_by', get_session_userid())
->orderBy('files.created_at', 'desc')
- ->findAll();
+ ->limit(100)
+ ->find();
// dd($data['fileList']);
$data['batch_list'] = $this->batchFileModel->select(
@@ -318,7 +319,8 @@ class EmployeeController extends AdminController
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
->join('clients', 'clients.id = client_policy.client_id')
->orderBy('batch_files.id', 'desc')
- ->findAll();
+ ->limit(100)
+ ->find();
// dd($data['fileList']);die();
@@ -825,7 +827,7 @@ class EmployeeController extends AdminController
$res = $empServiceController->employeesOnboardPreprocess(['client_policy_id' => $client_policy_id,'client_branch_id' => $client_data['client_branch_id']]);
// dd($res);
- $count = count($res);
+ $count = ($res);
$message = $count . ' Employees are Initiate Onboard Process againts Client ' . $client_data['client_name'] . ' and the Policy is ' . $client_data['policy_name'];
session()->setFlashdata('success1', $message);
return redirect()->to(base_url('/employee/upload'));
diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php
index b4359c53..0c43d7cd 100755
--- a/app/Controllers/EmployeeRestController.php
+++ b/app/Controllers/EmployeeRestController.php
@@ -309,6 +309,7 @@ class EmployeeRestController extends AdminController
$data['client_policy_id']= $client_policy_id;
$data['basic_cover_si']= $basic_cover_si;
$data['status']= 'draft';
+ $data['date_coverage'] = $this->getEmployeeCoverageDate($emp_code, $client_policy_id);
$this->employeePolicyModel->insert($data);
@@ -320,10 +321,7 @@ class EmployeeRestController extends AdminController
public function updatePremiumAmount($client_policy_id , $emp_code , $client_branch_id)
{
$response = $this->calculatePremium($client_policy_id , $emp_code , null , $client_branch_id);
- // echo '
';
- // print_r($response);
- // echo '
';
- // die();
+
if(count($response[$emp_code]))
{
@@ -354,6 +352,45 @@ class EmployeeRestController extends AdminController
}
}
+ public function getEmployeeCoverageDate($emp_code, $client_policy_id)
+ {
+ $empData = $this->employeeModel->where('emp_code',$emp_code)->where('relationship', 'self')->where('is_active',1)->first();;
+ if($empData)
+ {
+ $empPolicyData = $this->employeePolicyModel->select('employee_polices.employee_id,employee_polices.client_policy_id,employee_polices.date_coverage,client_policy.policy_type_id,client_policy.base_policy')
+ ->join('client_policy', 'client_policy.id = employee_polices.client_policy_id', 'left')
+ ->where('employee_polices.employee_id' , $empData['id'] )
+ ->where('employee_polices.is_active' , 1 )
+ ->findAll();
+ if(count($empPolicyData))
+ {
+ // find same policy 'self' date of coverage
+ $filterSelfPolicy = array_filter($empPolicyData, function($row) use ($client_policy_id) {
+ return $row['client_policy_id'] == $client_policy_id;
+ });
+ $filterSelfPolicy = array_values($filterSelfPolicy); // Reset the index of the filtered result
+
+ if(count($filterSelfPolicy)){
+ return $filterSelfPolicy[0]['date_coverage'];
+ }else{
+ // find base policy 'self' date of coverage
+ $basePolicy = $this->clientPolicyModel->where('id',$client_policy_id)->get()->getRow()->base_policy;
+
+ $filterSelfBasePolicy = array_filter($empPolicyData, function($row) use ($basePolicy) {
+ return $row['client_policy_id'] == $basePolicy;
+ });
+ $filterSelfBasePolicy = array_values($filterSelfBasePolicy); // Reset the index of the filtered result
+
+ if(count($filterSelfBasePolicy)){
+ return $filterSelfBasePolicy[0]['date_coverage'];
+ }else{ return null; }
+ }
+
+ }else{ return null; }
+
+ }else{ return null; }
+ }
+
public function RelationshipMap($value){
@@ -432,7 +469,6 @@ class EmployeeRestController extends AdminController
}
- // Get the RelationShip list
public function createOrUpdateEmployeePolicySiAmount()
{
@@ -632,11 +668,6 @@ class EmployeeRestController extends AdminController
}
-
-
-
-
-
// Upload the Employee Detail in DB by Sheet Data
public function employeeUpload()
{
@@ -672,7 +703,7 @@ class EmployeeRestController extends AdminController
$file_name_with_path = WRITEPATH."/uploads/excel/".$filename;
//make an entry in DB
- $file_id = $this->fileModel->insert(['file_name' => $filename, 'client_id' => $client_id, 'policy_id' => $policy_id, 'created_by' => $employee_id, 'status' => 'draft', 'action' => 'enrollment', 'client_branch_id' => $client_branch_id]); //here field policy_id have client_policy_id and not policy id from policy master
+ $file_id = $this->fileModel->insert(['file_name' => $filename, 'client_id' => $client_id, 'policy_id' => $policy_id, 'created_by' => $employee_id, 'status' => 'inprogress', 'action' => 'enrollment', 'client_branch_id' => $client_branch_id]); //here field policy_id have client_policy_id and not policy id from policy master
$this->myLogger->logme("error", '{file_id} - client uploaded success', ['file_id' => $file_id]);
$empServiceController = new EmployeeServiceController();
@@ -803,7 +834,8 @@ class EmployeeRestController extends AdminController
'band'=> $extra['10'][$index],
'basic_pay'=> $extra['11'][$index],
'unit'=> isset($extra['12'][$index]) ? $extra['12'][$index] : null,
- 'client_branch_id' => $client_branch_id
+ 'client_branch_id' => $client_branch_id,
+ 'date_coverage' => $extra['13'][$index]
];
$basic_cover_si_value = null;
@@ -840,6 +872,8 @@ class EmployeeRestController extends AdminController
$count = 0;
for ($a=0; $a employeeModel->checkExistingEmployee($dataToInsert[$a],$client_branch_id);
$emp_id =0;
@@ -891,6 +925,7 @@ class EmployeeRestController extends AdminController
'employee_id'=>$emp_id,
'client_policy_id'=>$policy_id,
'status'=> 'draft',
+ 'date_coverage' => $date_coverage,
'basic_cover_si'=>isset($basic_cover_si[$a]) ? $basic_cover_si[$a] : null
];
@@ -932,6 +967,7 @@ class EmployeeRestController extends AdminController
}
}
+ $this->fileModel->where('id', $file_id)->set(['status' => 'success','reason' => '','error_data' => ''])->update();
return $this->respond(['status' => 'success', 'code' => 200, 'message' => "Success" ], 200);
}else{
return $this->respond(['status' => 'failed', 'code' => 404, 'message' => "Client id and Client Policy id is Not Match!" ], 404);
diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php
index ef99ee20..f697a04a 100755
--- a/app/Controllers/EmployeeServiceController.php
+++ b/app/Controllers/EmployeeServiceController.php
@@ -594,6 +594,15 @@ class EmployeeServiceController extends AdminController
'data_type' => 'str',
'format' => null,
'allowed_values' => null
+ ],
+ 'doc' => [
+ 'col_idx' => 13,
+ 'col_cell_name' => 'N',
+ 'col_name' => 'DOC',
+ 'is_mandatory' => false,
+ 'data_type' => 'str',
+ 'format' => 'd-M-Y',
+ 'allowed_values' => null
]
];
@@ -605,7 +614,7 @@ class EmployeeServiceController extends AdminController
4 => 4, // inception: gender (Gender) -> enrollment: gender (Gender)
5 => 5, // inception: relationship (RELATIONSHIP) -> enrollment: relationship (Relation)
6 => 9, // inception: basic_cover_si (BASIC COVER SI) -> enrollment: basic_cover_si (SI)
- 7 => null, // inception: doc (Date of Coverage) -> No match in enrollment
+ 7 => 13, // inception: doc (Date of Coverage)
8 => 3, // inception: doj (DOJ) -> enrollment: doj (DOJ)
9 => 11, // inception: basic_pay (Basic Pay) -> enrollment: basic_pay (Basic Pay)
10 => 10, // inception: band_grade (Band/Grade) -> enrollment: band_grade (Grade)
@@ -1088,7 +1097,7 @@ class EmployeeServiceController extends AdminController
}// end of foreach
}// end of if current action I,DA,A
- // s($result);
+ // return $result;
// die();
if(isset($result['error_summary']) && count($result['error_summary']))
{
@@ -1249,7 +1258,7 @@ class EmployeeServiceController extends AdminController
//get policy slab rates
$slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($client_policy_id,$client_id);
- $existing_famility_details = $this->employeeModel->getEmpFamilybyEmpCode(client_id: $client_id,client_policy_id: $client_policy_id,emp_status: ['enrolled','draft'],policy_status:['enrolled','draft']);
+ $existing_famility_details = $this->employeeModel->getEmpFamilybyEmpCode(client_id: $client_id,client_policy_id: $client_policy_id,emp_status: ['enrolled'],policy_status:['enrolled']);
// $file = ['id' => null,'client_id' => $client_id,'policy_id' => $client_policy_id,'action' => 'inception'];
$file = ['id' => null,'client_id' => $client_id,'policy_id' => $client_policy_id,'action' => 'inception','created_by' => get_session_userid(),'client_branch_id' => $params['client_branch_id']];
@@ -1613,6 +1622,7 @@ class EmployeeServiceController extends AdminController
$value['emp_status'] = 'active';
$value['created_by'] = $file['created_by'];
$value['client_branch_id'] = $file['client_branch_id'];
+ $value['family_floater_key'] = generate_family_floater_key($value['relationship']);
$log_message = 'Insert Employee- '.$value['name'] .'('.$value['emp_code'] .') with PK ';
// $this->myLogger->logme('error',('Insert - ' . $value['emp_code'] .' - '. $value['name']));
// echo 'update emp';
@@ -1983,7 +1993,7 @@ public function employeesEnrollmentInsert($params)
$value['file_id'] = $file_id;
$value['temp']['emp_id'] = null; // dummy value for using exisitng funciton in model
- if (strtolower(trim($value['relationship'])) === 'mother' || strtolower(trim($value['relationship'])) === 'Father') {
+ if (strtolower(trim($value['relationship'])) === 'mother' || strtolower(trim($value['relationship'])) === 'father') {
$relation = 'parent';
} else if(strtolower(trim($value['relationship'])) === 'son' || strtolower(trim($value['relationship'])) === 'daughter'){
$relation = 'child';
@@ -1997,6 +2007,7 @@ public function employeesEnrollmentInsert($params)
$value['family_floater_key'] = $relation;
$policy_data['basic_cover_si'] = $row[9];
+ $policy_data['date_coverage'] = $row[13];
$policy_data['client_policy_id'] = $file['policy_id'];
$employee = $this->employeeModel->checkExistingEmployee($value,$file['client_branch_id']);
diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php
index 691234eb..42f3d660 100755
--- a/app/Controllers/MasterController.php
+++ b/app/Controllers/MasterController.php
@@ -34,6 +34,8 @@ use App\Models\InsurerExcelExportTemplateModel;
use App\Models\SettingsModel;
use App\Models\VehicleModel;
+use CodeIgniter\CLI\CLI;
+
class MasterController extends AdminController
{
use ResponseTrait;
@@ -1605,11 +1607,21 @@ class MasterController extends AdminController
{
// print_r($email_id);die();
// $gmailapi = \Config\Services::gmailapi();
+ $email_id = CLI::getOption('to') ? CLI::getOption('to') : $email_id;
$res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI', 'message' => 'This is sample mail sent via CLI mode']);
print_r($res);
}
-
+ public function testCheckBounceMails()
+ {
+ $gmailapi = \Config\Services::gmailapi();
+ $from_date = CLI::getOption('from') ? CLI::getOption('from') : null;
+ $to_date = CLI::getOption('to') ? CLI::getOption('to') : null;
+ $count = CLI::getOption('count') ? CLI::getOption('count') : null;
+ $page = CLI::getOption('page') ? CLI::getOption('page') : null;
+ $res = $gmailapi->checkBounceStatus(from_date:$from_date,to_date:$to_date,count:$count,page:$page);
+ print_r($res);
+ }
public function appCheckList()
{
@@ -1672,7 +1684,7 @@ class MasterController extends AdminController
echo "Check the following..!\n";
echo "1. Update Gmail Oauth credentials in 'gmail_api_oauth_credentials' field in 'settings' table in JSON format.\n";
echo "2. Call this cli route to generate new access token: 'php public/index.php cli/new_gmail_token' from root of the project.\n";
- echo "3. Call this cli route : 'php public/index.php cli/send_mail_cli someone@gmail.com' to send test mail to testGmailAPIViaCLI ( replace someone@gmail.com with real time mail).\n";
+ echo "3. Call this cli route : 'php public/index.php cli/send_mail_cli --to someone@gmail.com' to send test mail to testGmailAPIViaCLI ( replace someone@gmail.com with real time mail).\n";
}
else
{
diff --git a/app/Helpers/MailHelper.php b/app/Helpers/MailHelper.php
index f94d6419..a65a5b31 100755
--- a/app/Helpers/MailHelper.php
+++ b/app/Helpers/MailHelper.php
@@ -93,7 +93,8 @@ class MailHelper
$emaill = $params['mail'];
$subject = $params['subject'];
$message = $params['message'];
-
+ $attachments = isset($params['attachments']) && count($params['attachments']) ? $params['attachments'] : [];
+
//check BCC mail
if (isset($params['bcc'])) {
$bcc = $params['bcc'];
@@ -118,7 +119,7 @@ class MailHelper
try {
- $res = $gmailapi->sendMessage($emaill, $subject, $message, 'no-reply@nhanceindia.in', $reply_to, $cc, $bcc);
+ $res = $gmailapi->sendMessage($emaill, $subject, $message, 'no-reply@nhanceindia.in', $reply_to, $cc, $bcc,$attachments);
if($res['status'])
{
diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php
index 6de54c74..ab6299ac 100755
--- a/app/Helpers/excel_util_helper.php
+++ b/app/Helpers/excel_util_helper.php
@@ -1646,7 +1646,7 @@ if(!function_exists('get_premium_for_si'))
// dd($slab_details);
foreach ($slab_details as $skey => $slab_value)
{
- if($slab_value['si'] == $si_amount && $slab_value['grade'] == $band && $slab_value['unit'] == $unit && $slab_value['max_si'] == 0)
+ if($slab_value['si'] == $si_amount && $slab_value['grade'] == $band && $slab_value['unit'] == $unit)
{
return $slab_value['premium'];
}
@@ -1800,7 +1800,7 @@ if(!function_exists('transform_enrollment_row_to_inception_row'))
$res[4] = $row[4]; // inception: gender (Gender) -> enrollment: gender (Gender)
$res[5] = $row[5]; // inception: relationship (RELATIONSHIP) -> enrollment: relationship (Relation)
$res[6] = $row[9]; // inception: basic_cover_si (BASIC COVER SI) -> enrollment: basic_cover_si (SI)
- $res[7] = null; // inception: doc (Date of Coverage) -> No match in enrollment
+ $res[7] = $row[13]; // inception: doc (Date of Coverage) -> No match in enrollment
$res[8] = $row[3]; // inception: doj (DOJ) -> enrollment: doj (DOJ)
$res[9] = $row[11]; // inception: basic_pay (Basic Pay) -> enrollment: basic_pay (Basic Pay)
$res[10] = $row[10]; // inception: band_grade (Band/Grade) -> enrollment: band_grade (Grade)
@@ -2119,4 +2119,24 @@ if(!function_exists('group_slab_rates_basedon_name'))
return $temp_slab_rates;
}
+}
+
+
+//this key generating mandantory for display employee info in enrolment app w/o error
+if(!function_exists('generate_family_floater_key'))
+{
+ function generate_family_floater_key($relationship)
+ {
+ if (strtolower(trim($relationship)) === 'mother' || strtolower(trim($relationship)) === 'father') {
+ $relation = 'parent';
+ } else if(strtolower(trim($relationship)) === 'son' || strtolower(trim($relationship)) === 'daughter'){
+ $relation = 'child';
+ }else if(strtolower(trim($relationship)) === 'father in Law' || strtolower(trim($relationship)) === 'mother in Law'){
+ $relation = 'parent_in_law';
+ }else if(strtolower(trim($relationship)) === 'spouse'){
+ $relation = 'spouse';
+ }else{
+ $relation = 'self';
+ }
+ }
}
\ No newline at end of file
diff --git a/app/Libraries/GmailAPI.php b/app/Libraries/GmailAPI.php
index f08a832e..e74101d4 100755
--- a/app/Libraries/GmailAPI.php
+++ b/app/Libraries/GmailAPI.php
@@ -26,18 +26,20 @@ class GmailAPI
'https://www.googleapis.com/auth/gmail.addons.current.message.readonly',
'https://www.googleapis.com/auth/gmail.readonly',
'https://www.googleapis.com/auth/gmail.labels',
- 'https://www.googleapis.com/auth/gmail.send'
+ 'https://www.googleapis.com/auth/gmail.send',
+ 'https://mail.google.com/'
]);
$this->setAuthConfig();
//die();
$this->client->setAccessType('offline');
$this->client->setPrompt('select_account consent');
-
- if (php_sapi_name() !== 'cli' || (uri_string() == 'cli/send_mail_cli' || uri_string() == 'cli/processjob') )
+ // echo uri_string();//die();
+ if (php_sapi_name() !== 'cli' || (uri_string() == 'cli/send_mail_cli' || uri_string() == 'cli/processjob' || uri_string() == 'cli/check_bounce_mail_cli') )
{
+ // echo 'getting token';die();
$this->setTokenFromDB(); // Call only if not in CLI
}
-
+ // die();
$this->service = new Gmail($this->client);
}
@@ -99,44 +101,73 @@ class GmailAPI
$settingsModel->where('id', 1)->set([$this->tokenField => $token])->update();
}
- public function createMessage($to, $subject, $htmlContent, $from, $replyTo, $cc = [], $bcc = [])
- {
- $boundary = uniqid(rand(), true);
+ public function createMessage($to, $subject, $htmlContent, $from, $replyTo, $cc = [], $bcc = [], $attachments = [])
+{
+ // print_r($to);die();
+ $boundary = uniqid(rand(), true); // Unique boundary for separating parts
- $rawMessageString = "From: $from\r\n";
- $rawMessageString .= "To: $to\r\n";
- $rawMessageString .= "Reply-To: $replyTo\r\n";
+ // Initialize raw message headers
+ $rawMessageString = "From: $from\r\n";
+ $rawMessageString .= "To: $to\r\n";
+ $rawMessageString .= "Reply-To: $replyTo\r\n";
- if (!empty($cc)) {
- $rawMessageString .= "Cc: " . implode(',', $cc) . "\r\n";
- }
-
- if (!empty($bcc)) {
- $rawMessageString .= "Bcc: " . implode(',', $bcc) . "\r\n";
- }
-
- $rawMessageString .= "Subject: $subject\r\n";
- $rawMessageString .= "MIME-Version: 1.0\r\n";
- $rawMessageString .= "Content-Type: multipart/alternative; boundary=\"$boundary\"\r\n\r\n";
- $rawMessageString .= "--$boundary\r\n";
- $rawMessageString .= "Content-Type: text/html; charset=UTF-8\r\n";
- $rawMessageString .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
- $rawMessageString .= $htmlContent . "\r\n";
- $rawMessageString .= "--$boundary--";
-
- $rawMessage = base64_encode($rawMessageString);
- $rawMessage = str_replace(['+', '/', '='], ['-', '_', ''], $rawMessage);
-
- $message = new Message();
- $message->setRaw($rawMessage);
-
- return $message;
+ if (!empty($cc)) {
+ $rawMessageString .= "Cc: " . implode(',', $cc) . "\r\n";
}
- public function sendMessage($to, $subject, $htmlContent, $from, $replyTo, $cc = [], $bcc = [])
+ if (!empty($bcc)) {
+ $rawMessageString .= "Bcc: " . implode(',', $bcc) . "\r\n";
+ }
+
+ $rawMessageString .= "Subject: $subject\r\n";
+ $rawMessageString .= "MIME-Version: 1.0\r\n";
+ $rawMessageString .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n\r\n";
+
+ // Add HTML content as an alternative part
+ $rawMessageString .= "--$boundary\r\n";
+ $rawMessageString .= "Content-Type: text/html; charset=UTF-8\r\n";
+ $rawMessageString .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
+ $rawMessageString .= $htmlContent . "\r\n\r\n";
+
+ // Process each attachment
+ foreach ($attachments as $attachment) {
+ $filePath = $attachment['filePath'];
+ $fileName = $attachment['fileName'];
+ $fileData = file_get_contents($filePath);
+
+ if ($fileData === false) {
+ continue; // Skip this attachment if file cannot be read
+ }
+
+ $base64File = base64_encode($fileData);
+
+ // Add each attachment with appropriate headers
+ $rawMessageString .= "--$boundary\r\n";
+ $rawMessageString .= "Content-Type: application/octet-stream; name=\"$fileName\"\r\n";
+ $rawMessageString .= "Content-Disposition: attachment; filename=\"$fileName\"\r\n";
+ $rawMessageString .= "Content-Transfer-Encoding: base64\r\n\r\n";
+ $rawMessageString .= chunk_split($base64File) . "\r\n\r\n";
+ }
+
+ // End boundary to signify the end of the message
+ $rawMessageString .= "--$boundary--";
+
+ // Encode the final raw message in base64 for Gmail API
+ $rawMessage = base64_encode($rawMessageString);
+ $rawMessage = str_replace(['+', '/', '='], ['-', '_', ''], $rawMessage);
+
+ // Create Gmail message object
+ $message = new Message();
+ $message->setRaw($rawMessage);
+
+ return $message;
+}
+
+
+ public function sendMessage($to, $subject, $htmlContent, $from, $replyTo, $cc = [], $bcc = [],$attachments = [])
{
try {
- $message = $this->createMessage($to, $subject, $htmlContent, $from, $replyTo, $cc, $bcc);
+ $message = $this->createMessage($to, $subject, $htmlContent, $from, $replyTo, $cc, $bcc,$attachments);
$res = $this->service->users_messages->send('me', $message);
return array('status' => true, 'data' => $res);
} catch (\Exception $e) {
@@ -177,4 +208,59 @@ class GmailAPI
$this->myLogger->logme('error', 'New token generated and stored in the database.');
print 'New token generated and stored in the database.';
}
+
+
+
+ public function checkBounceStatus( string $userId = 'me',string $from_date = null,string $to_date = null,int $count = null,string $page = null)
+ {
+ $query = 'from:mailer-daemon OR "delivery failed" OR "failure notice"';
+ if($from_date != '' && $to_date != '')
+ {
+ $query .= 'after:' . $from_date . ' before:' . $to_date;
+ }
+ $maxResults = $count ? $count : 20;
+ $pageToken = $page ? $page : null;
+
+ $params = ['q' => $query,'maxResults' => $maxResults];
+ if(isset($pageToken)){ $params['pageToken'] = $pageToken; }
+ $messages = $this->service->users_messages->listUsersMessages($userId, $params);
+
+ $bounceDetails = [];
+ $pageToken = $messages->getNextPageToken();
+ $bounceDetails['pageToken'] = $pageToken;
+ if (count($messages->getMessages()) > 0) {
+ foreach ($messages->getMessages() as $message) {
+ // Get full message details
+ $msg = $this->service->users_messages->get($userId, $message->getId(), ['format' => 'full']);
+
+ // Extract important headers and content
+ $headers = $msg->getPayload()->getHeaders();
+ $subject = null;
+ $date = null;
+ $to = null;
+
+ foreach ($headers as $header) {
+ if ($header->getName() === 'Subject') {
+ $subject = $header->getValue();
+ }
+ if ($header->getName() === 'Date') {
+ $date = $header->getValue();
+ }
+ if ($header->getName() === 'To') {
+ $to = $header->getValue();
+ }
+ }
+
+ $bounceDetails['data'][] = [
+ 'subject' => $subject,
+ 'date' => $date,
+ 'to' => $to,
+ 'snippet' => $msg->getSnippet(),
+ ];
+ }
+ }
+
+ return $bounceDetails;
+ }
+
}
diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php
index 180f810c..18dff3a9 100755
--- a/app/Models/EmployeePolicyModel.php
+++ b/app/Models/EmployeePolicyModel.php
@@ -806,8 +806,8 @@ class EmployeePolicyModel extends Model
->where('emp.client_id',$client_id)
->where('employee_polices.client_policy_id',$policy_id);
- $result->whereIn('employee_polices.status', ['draft', 'enrolled']);
- $result->whereIn('emp.emp_status', ['draft', 'enrolled']);
+ $result->whereIn('employee_polices.status', ['enrolled']);
+ $result->whereIn('emp.emp_status', ['enrolled']);
$result = $result->findAll();
return ($result);
}
diff --git a/app/Views/batch_list.php b/app/Views/batch_list.php
index 00e5b465..a2c371b2 100755
--- a/app/Views/batch_list.php
+++ b/app/Views/batch_list.php
@@ -67,7 +67,7 @@
|
- by
+ by
|
diff --git a/app/Views/employee_data_list.php b/app/Views/employee_data_list.php
index 69ca1f74..2a70d76a 100755
--- a/app/Views/employee_data_list.php
+++ b/app/Views/employee_data_list.php
@@ -67,6 +67,7 @@
| Name |
EMP Code |
Relationship |
+ Gender |
Date of Birth |
Policy name |
Insurer name |
@@ -100,6 +101,7 @@
|
|
|
+ |
|
- |
|
diff --git a/app/Views/file_list.php b/app/Views/file_list.php
index 2cd80976..a504ad5f 100755
--- a/app/Views/file_list.php
+++ b/app/Views/file_list.php
@@ -53,7 +53,7 @@
- |
|
- ' . $file['first_name'] . '' ?>
+ | ' . $file['first_name'] . '' ?>
|
|