MERGE_UAT_ENROLMENT_UPLOAD&SEND_MAN_REMINDER

This commit is contained in:
Venba 2024-08-01 06:35:06 +00:00
commit 02c2e909ec
22 changed files with 830 additions and 446 deletions

View File

@ -273,11 +273,15 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->get("get_client_details/(:any)", "ClientController::getClientDetails/$1");
$routes->get("featch_dashboard_data/(:any)", "DashboardController::featch_dashboard_data/$1");
$routes->get("remove_rack_rate/(:any)", "ClientController::removeRackRate/$1");
$routes->get("get_client_policy_list_for_remainder/(:any)", "EmployeeController::get_client_policy_list_for_remainder/$1");
$routes->get("send_manual_remainder/(:any)", "DashboardController::sendManualRemainder/$1");
$routes->get("get_insurer_by_export_templete", "MasterController::getInsurerByExportTemplete");
$routes->get("copy_insurer_templete/(:any)", "MasterController::copyInsurerTemplete/$1");
});
$routes->cli('cli/processjob', 'JobWorker::processJob');
$routes->cli('cli/processjobs', 'JobWorker::processJobs');
$routes->cli('cli/enrollment_status', 'DashboardController::enrollment_status');
$routes->cli('cli/updatePolicyEnrollmentStatus', 'DashboardController::updatePolicyEnrollmentStatus');
$routes->get("processjob", "JobWorker::processJob");

View File

@ -2038,10 +2038,10 @@ class ClientController extends AdminController
if ($record['open_for_enrollment'] == 0) {
$open_for_enrollment_update_value = 1;
$message = 'Enrollment Opened Successfully';
$message = 'Enrolment Opened Successfully';
} else if ($record['open_for_enrollment'] == 1) {
$open_for_enrollment_update_value = 0;
$message = 'Enrollment Closed Successfully';
$message = 'Enrolment Closed Successfully';
}
$data = $this->policesModel->getPolicyPremium($record['policy_id']);
@ -2219,7 +2219,7 @@ class ClientController extends AdminController
CASE
WHEN client_policy.inception_type = 1 THEN "File Upload"
WHEN client_policy.inception_type = 2 THEN "Enrollment"
WHEN client_policy.inception_type = 2 THEN "Enrolment"
ELSE "n/a"
END as inception_type,

View File

@ -27,6 +27,10 @@ class DashboardController extends AdminController
protected $messageModel;
protected $clientModel;
protected $userMessageModel;
protected $clientPolicyModel;
protected $notificationModel;
protected $employeePolicyModel;
protected $myLogger;
public function __construct()
@ -34,32 +38,37 @@ class DashboardController extends AdminController
set_session_context('Dashboard');
$this->messageModel = new MessageModel();
$this->userMessageModel = new UserMessageModel();
$this->clientPolicyModel = new ClientPolicyModel();
$this->notificationModel = new NotificationModel();
$this->employeePolicyModel = new EmployeePolicyModel();
$this->clientModel = new ClientModel();
$this->myLogger = \Config\Services::mylogger();
$this->clientModel = new ClientModel();
}
public function dashboard()
{
$data = [];
$results = $this->clientModel->select('clients.id as client_id, clients.client_name, clients.short_name,
client_branch.id as client_branch_id, client_branch.branch_name,
client_branch.branch_code, employees.id as employee_id,
employees.name as employee_name, employees.relationship,
employees.emp_code, employees.emp_status, auth_history.user_type, client_policy.policy_type_id, client_policy.id as client_policy_id')
->join('client_branch', 'clients.id = client_branch.client_id', 'left')
->join('client_policy', 'client_branch.id = client_policy.client_branch_id', 'left')
->join('employees', 'client_branch.id = employees.client_branch_id', 'left')
->join('auth_history', 'employees.id = auth_history.user_id AND "employee" = auth_history.user_type', 'left')
->findAll();
->join('client_branch', 'clients.id = client_branch.client_id', 'left')
->join('client_policy', 'client_branch.id = client_policy.client_branch_id', 'left')
->join('employees', 'client_branch.id = employees.client_branch_id', 'left')
->join('auth_history', 'employees.id = auth_history.user_id AND "employee" = auth_history.user_type', 'left')
->findAll();
$pendingActionsController = new PendingActionsController;
$pendingActionsData = $pendingActionsController->getPendingActionsForDashBoard();
$groupedData = [];
foreach ($results as $row) {
$clientId = $row['client_id'];
$clientName = $row['client_name'];
@ -70,7 +79,7 @@ class DashboardController extends AdminController
$clientPolicyId = $row['client_policy_id'];
$policyTypeId = $row['policy_type_id'];
$employeeId ='';
$employeeId = '';
if ($employeeId != $row['employee_id']) {
$employeeId = $row['employee_id'];
} else {
@ -104,7 +113,7 @@ class DashboardController extends AdminController
'employees' => []
];
}
// Add the client policy to the branch's policies list if it exists, not already added, and policyTypeId is not equal to 1
if ($clientPolicyId !== null && $policyTypeId != 1 && !in_array(['client_policy_id' => $clientPolicyId, 'policy_type_id' => $policyTypeId], $groupedData[$clientId]['branches'][$branchId]['client_policies'])) {
$groupedData[$clientId]['branches'][$branchId]['client_policies'][] = [
@ -112,8 +121,8 @@ class DashboardController extends AdminController
'policy_type_id' => $policyTypeId
];
}
// Append employee info to the branch's employees list if relationship is 'Self' and not already added
// Append employee error to the branch's employees list if relationship is 'Self' and not already added
$employeeKey = $employeeId . '-' . $employeeName; // unique key to identify an employee
if ($employeeId !== null && $employeeRelationship == 'Self' && !isset($groupedData[$clientId]['branches'][$branchId]['employees'][$employeeKey])) {
$groupedData[$clientId]['branches'][$branchId]['employees'][$employeeKey] = [
@ -142,7 +151,7 @@ class DashboardController extends AdminController
}
$client['branches'] = array_values($client['branches']);
}
$data['client_branch_emp_list'] = $groupedData;
$session = \Config\Services::session();
$session->set('enrollment_data', json_encode($data));
@ -150,15 +159,12 @@ class DashboardController extends AdminController
$data['pendingActionsData'] = $pendingActionsData;
// print_r($data);die;
echo view('layout/header');
echo view('DashBoard', $data);
echo view('layout/footer');
}
public function getDashboardNotifications()
{
@ -187,89 +193,61 @@ class DashboardController extends AdminController
}
public static function enrollment_status() {
public function updatePolicyEnrollmentStatus()
{
$clientModel = new ClientModel();
$clientPolicyModel = new ClientPolicyModel();
$notificationModel = new NotificationModel();
$employeePolicyModel = new EmployeePolicyModel();
$myLogger = \Config\Services::mylogger();
$client_policy_data = $clientPolicyModel->findAll();
// $myLogger->logme('error', 'enrollment_status function called');
$client_policy_data = $clientPolicyModel->getPolicyDetailsForRemainder();
$myLogger->logme('error', 'Fetched client policy data');
// dd($client_policy_data);
$currentDate = date('d');
// $myLogger->logme('error', 'Current date: ' . $currentDate);
// Update policy status based on start and end dates
foreach ($client_policy_data as $client_policy) {
$id = $client_policy['id'];
$openDate = date('d', strtotime($client_policy['open_date']));
$closeDate = date('d', strtotime($client_policy['close_date']));
// $myLogger->logme('error', 'Processing client policy ID: ' . $id);
// $myLogger->logme('error', 'Open date: ' . $openDate . ', Close date: ' . $closeDate);
if ($currentDate == $openDate) {
$clientPolicyModel->update($id, ['open_for_enrollment' => 1]);
}
$myLogger->logme('error', 'Updated policy ID ' . $id . ' to open for enrollment.');
}
if ($closeDate < $currentDate) {
$clientPolicyModel->update($id, ['open_for_enrollment' => 0]);
$myLogger->logme('error', 'Updated policy ID ' . $id . ' to close for enrollment.');
}
}
$reminder_whole_mail = [];
foreach ($client_policy_data as $client_policy) {
// Fetch client data
$client_data = $clientModel->find($client_policy['client_id']);
// Fetch notification settings
$notification_data = $notificationModel->where('client_id', $client_policy['client_id'])
->where('template_name', 'member_reminder_mail')
->first();
// Check if notification should be sent
if ($notification_data && $notification_data['enabled'] == 1 && $currentDate == date('d', strtotime($client_policy['reminder_date'])) ) {
// Fetch all employees related to the client policy
$employees = $employeePolicyModel->select('employees.*')
->join('employees', 'employee_polices.employee_id = employees.id', 'left')
->where('employee_polices.client_policy_id', $client_policy['id'])
->where('employees.emp_status', 'draft')
->where('employee_polices.status', 'draft')
->where('employees.relationship', 'Self')
->findAll();
// Process each employee
foreach ($employees as $employee) {
if($employee['emp_status'] == 'draft' && $employee['relationship'] == 'Self'){
$params['emp_data'] = $employee;
$params['client_data'] = $client_data;
$params['notification_data'] = $notification_data;
// Send the mail notification
$reminder_whole_mail[] = sendMailNotification::sendMailNotification('member_reminder_mail', $params);
}
}
}
}
// Process and queue bulk emails
$temp_whole_data = [];
$count = 0;
foreach ($reminder_whole_mail as $whole_index => $values) {
foreach ($values as $index => $value) {
$temp_whole_data[] = $value;
$count++;
if ($count == 20 || ($whole_index == count($reminder_whole_mail) - 1 && $index == count($values) - 1)) {
if (!empty($temp_whole_data)) {
Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $temp_whole_data]);
$temp_whole_data = [];
$count = 0;
}
}
}
}
if(count($temp_whole_data) > 0){
Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $temp_whole_data]);
// Mail send function
// $myLogger->logme('error', 'Calling sendRemainderMail function');
if( $currentDate == date('d', strtotime($client_policy['reminder_date']))){
$result = $this->sendRemainderMail($client_policy_data);
}else{
$result = false;
}
return json_encode(true);
// $myLogger->logme('error', 'enrollment_status function completed');
if($result){
return json_encode(['status' => true, 'message' => 'Mail send successfully']);
}else{
return json_encode(['status' => false, 'message' => 'There is no data to send']);
}
}
public function featch_dashboard_data($type)
{
@ -308,4 +286,128 @@ class DashboardController extends AdminController
}
public function sendRemainderMail($client_policy_data)
{
// $this->myLogger->logme('error', 'sendRemainderMail function called');
$reminder_whole_mail = [];
foreach ($client_policy_data as $client_policy) {
// Fetch client data
$client_data = $this->clientModel->find($client_policy['client_id']);
// Fetch notification settings
$notification_data = $this->notificationModel
->where('client_id', $client_policy['client_id'])
->where('template_name', 'member_reminder_mail')
->first();
// $this->myLogger->logme('error', 'Notification data fetched: ' . json_encode($notification_data));
// Check if notification should be sent
if ($notification_data && $notification_data['enabled'] == 1 && !empty($notification_data['mail_content'])) {
$this->myLogger->logme('error', 'Notification should be sent for client policy ID: ' . $client_policy['id']);
// Fetch all employees related to the client policy
$employees = $this->employeePolicyModel
->select('employees.*')
->join('employees', 'employee_polices.employee_id = employees.id', 'left')
->where('employee_polices.client_policy_id', $client_policy['id'])
->where('employees.emp_status', 'draft')
->where('employees.is_active', 1)
->where('employee_polices.status', 'draft')
->where('employee_polices.is_active', 1)
->where('employees.relationship', 'Self')
->findAll();
// Process each employee
foreach ($employees as $employee) {
if ($employee['emp_status'] == 'draft' && $employee['relationship'] == 'Self') {
$this->myLogger->logme('error', 'Employee status and relationship check passed for employee ID: ' . $employee['id']);
// Mail params
$params['emp_data'] = $employee;
$params['client_data'] = $client_data;
$params['notification_data'] = $notification_data;
// 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;
}
}
} else {
$this->myLogger->logme('error', 'Notification not sent for client policy ID: ' . $client_policy['id']);
}
}
$this->myLogger->logme('error', 'Whole email, count: ' . $reminder_whole_mail);
// Process and queue bulk emails
$temp_whole_data = [];
$count = 0;
foreach ($reminder_whole_mail as $whole_index => $values) {
foreach ($values as $index => $value) {
$temp_whole_data[] = $value;
$count++;
$this->myLogger->logme('error', 'Queueing email, count: ' . $count);
if ($count == 20 || ($whole_index == count($reminder_whole_mail) - 1 && $index == count($values) - 1)) {
if (!empty($temp_whole_data)) {
Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $temp_whole_data]);
$this->myLogger->logme('error', 'Added bulk mail job: ' . json_encode($temp_whole_data));
$temp_whole_data = [];
$count = 0;
}
}
}
}
if (count($temp_whole_data) > 0) {
Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $temp_whole_data]);
$this->myLogger->logme('error', 'Added final bulk mail job: ' . json_encode($temp_whole_data));
return true;
}
if(count($reminder_whole_mail) > 0){
return true;
}else{
return false;
}
}
public function sendManualRemainder($client_id, $client_branch_id)
{
$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);
// print_r($client_policy_data); die;
// print_r($this->clientPolicyModel->getLastQuery()); die;
// $this->myLogger->logme('error', "Policy details fetched: " . json_encode($client_policy_data));
if ($client_policy_data) {
$result = $this->sendRemainderMail($client_policy_data);
$this->myLogger->logme('error', "Manual Remainder Mail sending result: " . ($result ? 'success' : 'failure'));
if ($result) {
$this->myLogger->logme('error', 'Manual Remainder Mail sent successfully');
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Mail sent successfully'], 200);
} else {
$this->myLogger->logme('error', 'Failed to send manual remainder mail, no data to send');
return $this->respond(['status' => false, 'code' => 200, 'message' => 'There is no data to send','message2' => 'Failed' ], 200);
}
} else {
$this->myLogger->logme('error', 'No policy data found to send');
return $this->respond(['status' => false, 'code' => 200, 'message' => 'There is no data to send', 'message2' => 'No policy data found to send'], 200);
}
}
}

View File

@ -192,6 +192,7 @@ class EmployeeController extends AdminController
// }
if ($this->request->getMethod() == 'post') {
//validate uploaded file
$filename = '';
$validated = $this->validate([
@ -255,7 +256,7 @@ class EmployeeController extends AdminController
//for TPA/insurer upload
$data['events'] = ['inception' => 'Inception (Employee + Dependents)', 'missed_inception' => 'Missed Inception (Employee + Dependents)', 'addition' => 'Addition (Employee + Dependents)', 'dependent_addition' => 'Dependent Addition (Only Dependents)', 'deletion' => 'Deletion', 'correction' => 'Correction', 'si_enhancement' => 'SI Enhancement'];
//for inception upload
$data['actions'] = ['inception' => 'Inception (Employee + Dependents)', 'missed_inception' => 'Missed Inception (Employee + Dependents)', 'addition' => 'Addition (Employee + Dependents)', 'dependent_addtion' => 'Dependent Addition (Only Dependents)', 'deletion' => 'Deletion', 'correction' => 'Correction', 'si_enhancement' => 'SI Enhancement','enrollment' => 'Enrollment'];
$data['actions'] = ['inception' => 'Inception (Employee + Dependents)', 'missed_inception' => 'Missed Inception (Employee + Dependents)', 'addition' => 'Addition (Employee + Dependents)', 'dependent_addtion' => 'Dependent Addition (Only Dependents)', 'deletion' => 'Deletion', 'correction' => 'Correction', 'si_enhancement' => 'SI Enhancement','enrollment' => 'Enrolment'];
$data['import_or_export'] = ['import' => 'Import', 'export' => 'Export'];
$data['insurer_or_tpa'] = ['insurer' => 'Insurer', 'tpa' => 'TPA'];
@ -1563,7 +1564,10 @@ class EmployeeController extends AdminController
foreach($data as $key => $member )
{
// ~dd($member);
$data[$key]['policy_details']['no_of_days'] = $member['policy_details']['date_coverage'] ? (calculate_days_bw_dates($member['policy_details']['date_coverage'],$member['policy_details']['policy_end_date'])->days + 1) : '';
if(is_array($member))
{
$data[$key]['policy_details']['no_of_days'] = $member['policy_details']['date_coverage'] ? (calculate_days_bw_dates($member['policy_details']['date_coverage'],$member['policy_details']['policy_end_date'])->days + 1) : '';
}
}
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $data], 200);
@ -1642,4 +1646,20 @@ class EmployeeController extends AdminController
}
}
public function get_client_policy_list_for_remainder($client_id, $client_branch_id)
{
$policies = $this->clientPolicyModel
->select('client_policy.*, policy_type.policy_type as policy_name')
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
->where('client_policy.client_id', $client_id)
->where('client_policy.client_branch_id', $client_branch_id)
->where('client_policy.is_active', 1)
->where('client_policy.policy_status', 1)
->whereIn('client_policy.policy_type_id', [2, 3])
->findAll();
return $this->respond(['status' => true, 'code' => 200, 'data' => $policies], 200);
}
}

View File

@ -560,7 +560,7 @@ class EmployeeRestController extends AdminController
// Set the header for download
$filename = $empData[0]['policy_name'].'-Enrollment.xlsx';
$filename = $empData[0]['policy_name'].'-Enrolment.xlsx';
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="' . $filename . '"');
header('Cache-Control: max-age=0');

View File

@ -6,6 +6,7 @@ namespace App\Controllers;
use App\Models\JobModel;
use App\Models\FileModel;
class JobWorker extends AdminController
{
const STATUS_DONE = 'done';
@ -287,23 +288,24 @@ class JobWorker extends AdminController
try
{
$response = $jobHandler($payload,$job->id);
$job_status = self::STATUS_DONE;
}
catch(\Exception $e)
{
$job_status = self::STATUS_FAILED;
$runtime = $runtime === null ? microtime(true) - $start : $runtime;
$response = ['file_name' => $e->getFile(),'error' => $e->getMessage(),'line_no' => $e->getLine(),'info' => $e->getTraceAsString()];
$response = ['file_name' => $e->getFile(),'error' => $e->getMessage(),'line_no' => $e->getLine(),'info' => $e->getTraceAsString(),'scope' => 'task failed'];
}
$runtime = microtime(true) - $start;
$job_status = self::STATUS_DONE;
}
catch (\Exception $e)
{
//die();
$job_status = self::STATUS_FAILED;
$runtime = $runtime === null ? microtime(true) - $start : $runtime;
$response = ['file_name' => $e->getFile(),'error' => $e->getMessage(),'line_no' => $e->getLine(),'info' => $e->getTraceAsString()];
$response = ['file_name' => $e->getFile(),'error' => $e->getMessage(),'line_no' => $e->getLine(),'info' => $e->getTraceAsString(),'scope' => 'worker failed'];
}
$db->query("UPDATE jobs SET status=?, run_time=?, response=? WHERE id=? AND uuid=?", [
@ -313,6 +315,21 @@ class JobWorker extends AdminController
$job->id,$job->uuid
]);
//update file status if this job is directly linked with a file id
if($job_status == self::STATUS_FAILED)
{
//get file from job payload
if(array_key_exists('file_id', $payload) && $payload['file_id'] != NULL && $payload['file_id'] != "" && is_numeric($payload['file_id']) && count($payload) == 1)
{
$fileModel = new FileModel();
$fileModel->where('id', $payload['file_id'])
->set(['status' => 'failed','reason' => json_encode(['error_type' => 0,'error_summary' => [0],'error_data' => 'System Error, please contact Admin/Support team']) ])
->update();
}
}
// echo "Job $job->id $job_status. Response - $response \n";
// echo "Job $job->id $job_status \n";
SELF::streamOutput("Job $job->id $job_status \n");

View File

@ -29,6 +29,7 @@ use App\Models\StateModel;
use App\Models\PolicyTypeModel;
use App\Models\CDMasterModel;
use App\Models\ClientDepositModel;
use App\Models\InsurerExcelExportTemplateModel;
class MasterController extends AdminController
{
@ -52,6 +53,7 @@ class MasterController extends AdminController
protected $CDMasterModel;
protected $clientModel;
protected $clientDepositModel;
protected $insurerTemplateModel;
@ -60,7 +62,7 @@ class MasterController extends AdminController
set_session_context('Master');
$this->myLogger = \Config\Services::mylogger();
$this->insurerModel = new ClientModel();
// $this->insurerModel = new ClientModel();
$this->userModel = new UserModel();
// $this->insurerBranchModel = new ClientBranchModel();
$this->insurerKYCDocsModel = new ClientKYCDocsModel();
@ -79,6 +81,7 @@ class MasterController extends AdminController
$this->CDMasterModel = new CDMasterModel();
$this->clientModel = new ClientModel();
$this->clientDepositModel = new ClientDepositModel();
$this->insurerTemplateModel = new InsurerExcelExportTemplateModel();
}
@ -150,6 +153,7 @@ class MasterController extends AdminController
$editData['insurer'] = $this->insurerModel->where(['id' => $id, 'is_active' => 1])->first();
$editData['insuer_branch'] = $this->insurerBranchModel->where(['insurer_id' => $id, 'is_active' => 1])->findAll();
$editData['insurer_templete_count'] = $this->insurerTemplateModel->where(['insurer_id' => $id, 'is_active' => 1])->countAllResults();
// echo "<pre>";
@ -209,7 +213,8 @@ class MasterController extends AdminController
$insert = $this->insurerModel->insert($data);
if($insert){
$insurer_data = $this->insurerModel->where(['id' => $insert, 'is_active' => 1])->first();
echo json_encode(array("status" => true , 'data' => $insurer_data));
$insurer_templete_count = $this->insurerTemplateModel->where(['insurer_id' => $insert, 'is_active' => 1])->countAllResults();
echo json_encode(array("status" => true , 'data' => $insurer_data, 'templete_count' => $insurer_templete_count));
}else{
echo json_encode(array("status" => false));
}
@ -337,6 +342,44 @@ class MasterController extends AdminController
}
}
public function getInsurerByExportTemplete()
{
$insurer_data = $this->insurerModel
->select('insurers.name as insurer_name, insurers.id, insurers.is_multi_event')
->join('insurer_excel_export_template', 'insurer_excel_export_template.insurer_id = insurers.id')
->groupBy('insurers.id')
->findAll();
return $this->respond(['status' => true, 'code' => 200, 'data' => $insurer_data], 200);
}
public function copyInsurerTemplete($existing_insurer_id, $copy_insurer_id)
{
$insurer_templete_data = $this->insurerTemplateModel->where('insurer_id', $existing_insurer_id)->findAll();
$existing_insurer_templete_data = $this->insurerTemplateModel->where('insurer_id', $copy_insurer_id)->delete();
$data_to_insert = [];
foreach ($insurer_templete_data as $value) {
$data_to_insert[] = [
"insurer_id" => $copy_insurer_id,
"policy_type_id" => $value['policy_type_id'],
"event_name" => $value['event_name'],
"type_name" => $value['type_name'],
"jsoncolumns" => $value['jsoncolumns'],
"created_by" => get_session_user(),
"is_active" => 1,
];
}
$insert_result = $this->insurerTemplateModel->insertBatch($data_to_insert);
if($insert_result){
return $this->respond(['status' => true, 'message' => 'Template added successfully', $insurer_templete_data]);
}else{
return $this->respond(['status' => true, 'message' => 'Failed to add template', $insurer_templete_data]);
}
}
// Insurer Ends

View File

@ -388,5 +388,26 @@ public function getCliendDataForExcelFileName($client_policy_id){
}
//for this using in CRONE JOB
public function getPolicyDetailsForRemainder($client_id = null, $branch_id = null)
{
$builder = $this->table('client_policy')
->where('client_policy.is_addon', 1)
->where('client_policy.open_for_enrollment', 1)
->where('client_policy.inception_type', 2)
->where('client_policy.is_active', 1)
->where('client_policy.policy_status', 1)
->whereIn('client_policy.policy_type_id', [2, 3]);
if ($client_id && $branch_id) {
$builder->where('client_policy.client_id', $client_id)
->where('client_policy.client_branch_id', $branch_id);
}
return $builder->get()->getResultArray();
}
}

View File

@ -59,7 +59,7 @@ body {
<li class="nav-item">
<a href="#enrollment-dash-tab" data-toggle="tab" aria-expanded="true" class="nav-link px-3 py-2" id="enrollemnt_tab">
<span class="mr-1"><i class="fa fa-file"></i></span>
<span class="d-none d-sm-inline-block">Enrollment</span>
<span class="d-none d-sm-inline-block">Enrolment</span>
</a>
</li>
</ul>

View File

@ -129,7 +129,7 @@
<th class="font-weight-medium"><label> Insurer </label></th>
<th class="font-weight-medium"><label> TPA </label></th>
<th class="font-weight-medium"><label> Policy Validity </label></th>
<th class="font-weight-medium"><label> Enrollment Status </label></th>
<th class="font-weight-medium"><label> Enrolment Status </label></th>
<th class="font-weight-medium"><label> Policy Status </label></th>
</tr>
</thead>

View File

@ -58,7 +58,7 @@ table.dataTable thead th {
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="<?= base_url("client/list/"); ?><?= $row->id;?>"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a class="dropdown-item" href="<?= base_url("client/deposit/{$row->id}"); ?>"><i class="mdi mdi-cash mr-2 text-muted font-18 vertical-middle"></i>CD Tranctions</a>
<a class="dropdown-item" href="<?= base_url("client/deposit/{$row->id}"); ?>"><i class="mdi mdi-cash mr-2 text-muted font-18 vertical-middle"></i>CD Transactions</a>
<?php if(get_role_id() != 3 && get_role_id() != 4) { ?>
<a class="dropdown-item" data-id="<?= $row->id;?>" onclick="removeClient(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
<?php } ?>

View File

@ -15,7 +15,7 @@
<th>Client Branch</th>
<th>TPA</th>
<th>Date</th>
<th>Enrollment Status</th>
<th>Enrolment Status</th>
<th>Status</th>
<th>Action</th>
</tr>
@ -312,13 +312,13 @@
if (item.open_for_enrollment == 1) {
enrollmentStatus = '<a href="#" data-id="' + item.id + '" id="' + item.policy_id +
'" class="btnOpenEnroll" data-toggle="tooltip" data-placement="left" title="Click To Close Enrollment">Open</a>'
'" class="btnOpenEnroll" data-toggle="tooltip" data-placement="left" title="Click To Close Enrolment">Open</a>'
} else if (item.open_for_enrollment == 0) {
enrollmentStatus =
'<a href="#" data-toggle="tooltip" data-placement="top" title="Click To Open Enrollment" data-id="' +
'<a href="#" data-toggle="tooltip" data-placement="top" title="Click To Open Enrolment" data-id="' +
item.id + '" id="' + item.policy_id + '" class="btnOpenEnroll">Closed</a>'
}
@ -551,7 +551,7 @@
if (item.open_for_enrollment == 1) {
enrollmentStatus =
'<a data-toggle="tooltip" data-placement="top" title="Click To Close Enrollment" href="#" data-id="' +
'<a data-toggle="tooltip" data-placement="top" title="Click To Close Enrolment" href="#" data-id="' +
item.id + '" id="' + item.policy_id +
'" class="btnOpenEnroll">Open</a>'
@ -559,7 +559,7 @@
} else if (item.open_for_enrollment == 0) {
enrollmentStatus =
'<a data-toggle="tooltip" data-placement="top" title="Click To Open Enrollment" href="#" data-id="' +
'<a data-toggle="tooltip" data-placement="top" title="Click To Open Enrolment" href="#" data-id="' +
item.id + '" id="' + item.policy_id +
'" class="btnOpenEnroll">Closed</a>'
@ -944,7 +944,7 @@
Swal.fire({
title: "Are you sure?",
text: "You need to approve this!",
text: "Do you want to approve this!",
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",
@ -982,7 +982,7 @@
$('.btnOpenEnroll').each(function(index, element) {
if ($(element).data('id') == client_policy_id) {
$(element).html(
'<a data-toggle="tooltip" data-placement="top" title="Click To Close Enrollment" href="#" data-id="' +
'<a data-toggle="tooltip" data-placement="top" title="Click To Close Enrolment" href="#" data-id="' +
res.client_policy_data.id +
'" id="' + res.client_policy_data
.policy_id +
@ -995,7 +995,7 @@
$('.btnOpenEnroll').each(function(index, element) {
if ($(element).data('id') == client_policy_id) {
$(element).html(
'<a data-toggle="tooltip" data-placement="top" title="Click To Open Enrollment" href="#" data-id="' +
'<a data-toggle="tooltip" data-placement="top" title="Click To Open Enrolment" href="#" data-id="' +
res.client_policy_data.id +
'" id="' + res.client_policy_data
.policy_id +
@ -1661,7 +1661,7 @@
Swal.fire({
title: "Are you sure?",
text: "You need to remove this Policy.",
text: "Do you want to remove this Policy.",
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",

View File

@ -55,7 +55,7 @@
<th class="font-weight-medium">Policy name</th>
<th class="font-weight-medium">Insurer <br> name</th>
<th class="font-weight-medium">TPA ID</th>
<th class="font-weight-medium">UHID</th>
<th class="font-weight-medium">Risk ID</th>
<th class="font-weight-medium">Policy <br> status</th>
<th class="font-weight-medium">()Sum Insured</th>
<th class="font-weight-medium">()Premium</th>

View File

@ -476,6 +476,10 @@ function fetchFileError(file_id) {
var err_id = parseInt(key);
var err_count = file_error_data['error_summary'][key];
switch (err_id) {
case 0:
file_error_html +=
"<strong>"+file_error_data['error_data']+"</strong>";
break;
case 1:
file_error_html +=
"<strong>Mandatory values missing</strong> <span class='badge badge-danger float-right'>" +
@ -562,7 +566,7 @@ function fetchFileError(file_id) {
// console.log('file_error_html_2', file_error_html)
}
if (err_id != 5 && err_id != 6) {
if (err_id != 5 && err_id != 6 && err_id != 0) {
file_error_html += (file_error_html != "" ?
"<a href ='<?php echo base_url()?>" +
"employee/excel_error/" + file_id +

View File

@ -107,9 +107,9 @@
height: 100%;
}
.carousel-control-prev-icon, .carousel-control-next-icon {
/* background-color: rgba(0,0,0,0.5); Change color as needed */
}
/* .carousel-control-prev-icon, .carousel-control-next-icon {
background-color: rgba(0,0,0,0.5);
} */
.carousel-control-prev-icon {
background-image: url('data:image/svg+xml;charset=utf8,%3Csvg xmlns%3D"http://www.w3.org/2000/svg" fill%3D"%23000000" viewBox%3D"0 0 8 8"%3E%3Cpath d%3D"M2.5 0L4 1.5 1.5 4 4 6.5 2.5 8 0 4 2.5 0z"/%3E%3C/svg%3E');
@ -148,8 +148,8 @@
<div class="row">
<div class="col-3">
<select class="form-control" name="" id="enrollment_status_open_close">
<option value="open">Open Enrollment</option>
<option value="close">Closed Enrollment</option>
<option value="open">Open Enrolment</option>
<option value="close">Closed Enrolment</option>
</select>
</div>
<div class="col-5"></div>

View File

@ -46,7 +46,7 @@
<div class="col-12">
<div class="card">
<div class="card-header">
<div class="row">
<div class="row" style="margin-bottom: -22px;">
<div class="col-3">
<div id="categoryFilter" style="display: flex;">
<select class="form-control" id="clients" onchange="populateBranches()">
@ -64,24 +64,35 @@
</select>
</div>
</div>
<div class="col-3">
<div class="col-1">
<div id="categoryFilter_11">
<a href="#" class="btn btn-primary waves-effect waves-light" id="get-emp-list" onclick="fetchEmpolyeeList(event);">Search</a>
</div>
</div>
<div class="col-3 text-right view-status-btn">
<button type="button" class="btn btn-link visa_status_button" onclick="toggleContent()">
<div class="col-2">
<div id="categoryFilter_12">
<a href="#" class="btn btn-primary waves-effect waves-light" onclick="sendManualReminder(this)">Send Reminder</a>
</div>
</div>
<div class="col-2">
<div id="categoryFilter_13">
<a class="btn btn-primary waves-effect waves-light" onclick="uploadEnrollmentFile(this)" >Upload File</a>
</div>
</div>
<div class="col-1 text-right view-status-btn" style="position: relative;bottom: 7px;">
<button type="button" class="btn btn-link visa_status_button" onclick="toggleContent()" style="color: #000;">
Status <i id="toggleIcon" class="fas fa-minus"></i>
</button>
</div>
</div>
</div>
<div class="card-body status-option" id="statusContent" style="padding: 0.5rem !important;background-color: darkgrey;">
<div class="card-body status-option" id="statusContent" style="padding: 1.5rem !important;background-color: darkgrey;">
<div class="text-center">
<div class="row" style="margin-right: -261px;margin-left: 5px;">
<div class="col-xl-2 col-md-3">
<div class="card">
<div class="row" style="margin-left: 125px; margin-bottom: -11px;">
<div class="col-xl-2 col-md-2">
<div class="card cardWidth">
<div class="card-body" id="emp_count_view_click">
<div class="d-flex justify-content-between" style="justify-content: center !important;">
<div>
@ -93,12 +104,12 @@
</div>
</div>
</div><!-- end col -->
<div class="col-xl-2 col-md-3">
<div class="col-xl-2 col-md-2">
<div class="card">
<div class="card-body" id="emp_enrolled_view_click">
<div class="d-flex justify-content-between" style="justify-content: center !important;">
<div>
<h5 class="text-muted font-weight-normal mt-0 text-truncate" title="Enrolled">Enrolled</h5>
<h5 class="text-muted font-weight-normal mt-0 text-truncate" title="Enrolled">Enroled</h5>
<h3 class="my-2 py-1"><span data-plugin="counterup" id="emp_enrolled_view">0</span></h3>
</div>
@ -106,12 +117,12 @@
</div>
</div>
</div><!-- end col -->
<div class="col-xl-2 col-md-3">
<div class="col-xl-2 col-md-2">
<div class="card">
<div class="card-body" id="emp_not_enrolled_view_click">
<div class="d-flex justify-content-between" style="justify-content: center !important;">
<div>
<h5 class="text-muted font-weight-normal mt-0 text-truncate" title="Not Enrolled">Not Enrolled</h5>
<h5 class="text-muted font-weight-normal mt-0 text-truncate" title="Not Enrolled">Not Enroled</h5>
<h3 class="my-2 py-1"><span data-plugin="counterup" id="emp_not_enrolled_view">0</span></h3>
</div>
@ -119,7 +130,7 @@
</div>
</div>
</div><!-- end col -->
<div class="col-xl-2 col-md-3">
<div class="col-xl-2 col-md-2">
<div class="card">
<div class="card-body" id="emp_logged_in_view_click">
<div class="d-flex justify-content-between" style="justify-content: center !important;">
@ -132,7 +143,7 @@
</div>
</div>
</div><!-- end col -->
<div class="col-xl-2 col-md-3">
<div class="col-xl-2 col-md-2">
<div class="card">
<div class="card-body" id="emp_not_logged_in_view_click">
<div class="d-flex justify-content-between" style="justify-content: center !important;">
@ -146,7 +157,9 @@
</div>
</div><!-- end col -->
</div>
</div>
</div>
</div>
</div>
@ -154,7 +167,7 @@
<div class="row" id="client_list">
<div class="col-12">
<div class="card" style="">
<div class="card">
<div class="card-body">
<table class="table table-hover m-0 table-centered dt-responsive w-100" cellspacing="0" id="tickets-table">
<thead class="bg-light">
@ -162,7 +175,7 @@
<th class="font-weight-medium">SNO</th>
<th class="font-weight-medium">Name</th>
<th class="font-weight-medium">Emp Code</th>
<th class="font-weight-medium">Enrolled</th>
<th class="font-weight-medium">Enroled</th>
<th class="font-weight-medium">Logged-In</th>
</tr>
</thead>
@ -175,10 +188,48 @@
</div>
</div>
<!-- Center modal content omitted for brevity -->
<!-- Center modal content -->
<div class="modal fade" id="upload_enrollment_model" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="false">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myCenterModalLabel">Upload Enrolment File</h4>
<button type="button" id="close_btn" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<form class="parsley-examples" method="post" id="uploadForm" action="<?php echo base_url().'employee/upload'?>" enctype="multipart/form-data">
<input type="hidden" id="file_client_id" name="client_id">
<input type="hidden" id="file_branch_id" name="branch_id">
<input type="hidden" id="file_upload_actions" name="upload-action-type" value="enrollment">
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-12">
<label for="policy_id">Client Policy<span class="text-danger">*</span></label>
<select class="form-control" id="policy_id" name="policy_id" required>
<option selected >Select Client Policy</option>
</select>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="file">File<span class="text-danger">*</span></label>
<input type="file" id="fileInput" name="emplist" required
accept=" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet">
</div>
</div>
</div>
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1">Upload</button>
</div>
</form>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script>
function populateBranches() {
function populateBranches()
{
var clientId = document.getElementById('clients').value;
var branchDropdown = document.getElementById('branch_id');
@ -200,7 +251,8 @@
});
}
function filterTable(columnIndex, filterValue) {
function filterTable(columnIndex, filterValue)
{
var table = $('#tickets-table').DataTable();
// Reset the search filter for all columns
@ -209,14 +261,20 @@
// Apply the filter to the specified column
table.column(columnIndex).search(filterValue).draw();
}
function fetchEmpolyeeList(event) {
function fetchEmpolyeeList(event)
{
event.preventDefault();
var client_id = $('#clients').val();
var branch_id = $('#branch_id').val();
if (client_id == '0' || branch_id == '0') {
alert('Please select values in both dropdowns.');
return;
Swal.fire({
title: "warning!",
text: 'Please select the Client and Client Branch.',
icon: "warning"
});
return false;
}
$.ajax({
@ -226,7 +284,15 @@
"Content-Type": "application/json",
"X-Requested-With": "XMLHttpRequest"
},
beforeSend: function() {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
},
success: function(response) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
var data = JSON.parse(response);
console.log(data);
var table = $('#tickets-table').DataTable();
@ -286,12 +352,16 @@
},
error: function(xhr, status, error) {
console.error('Error fetching data from API:', error);
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}
});
}
$(document).ready(function() {
$(document).ready(function()
{
function getUrlParameter(name) {
var params = new URLSearchParams(window.location.search);
@ -312,8 +382,6 @@
$('#branch_id').val(branch_id).trigger('change');
if($('#branch_id').val() != 0){
$('#get-emp-list').click().trigger();
}
}, 500);
@ -331,6 +399,7 @@
}, 1000);
$('#clients').select2();
$('#policy_id').select2();
$('#branch_id').select2();
var table = $('#tickets-table').DataTable({
dom: 'fBrtip',
@ -339,25 +408,25 @@
extend: 'copy',
text: '<i class="fa fa-copy"></i>',
titleAttr: 'Copy',
filename: 'Enrollment List'
filename: 'Enrolment List'
},
{
extend: 'print',
text: '<i class="fa fa-print"></i>',
titleAttr: 'Print',
filename: 'Enrollment List'
filename: 'Enrolment List'
},
{
extend: 'pdf',
text: '<i class="fa fa-file-pdf"></i>',
titleAttr: 'PDF',
filename: 'Enrollment List'
filename: 'Enrolment List'
},
{
extend: 'csv',
text: '<i class="fa fa-file-csv"></i>',
titleAttr: 'CSV',
filename: 'Enrollment List'
filename: 'Enrolment List'
}
],
initComplete: function() {
@ -450,7 +519,8 @@
toggleContent();
});
function toggleContent() {
function toggleContent()
{
var content = document.getElementById("statusContent");
var toggleIcon = document.getElementById("toggleIcon");
if (content.style.display === "none") {
@ -463,4 +533,211 @@
toggleIcon.classList.add("fa-plus");
}
}
//----------------------------------------------------------------------------------------------------
function uploadEnrollmentFile(input)
{
console.log('uploadEnrollmentFile called');
var client_id = $('#clients').val()
var client_branch_id = $('#branch_id').val()
console.log('input', input);
console.log('client_id', client_id);
console.log('client_branch_id', client_branch_id);
if(client_id == 0 && client_branch_id == 0){
Swal.fire({
title: "warning!",
text: 'Please select the Client and Client Branch.',
icon: "warning"
});
return false
}
// $('#upload_enrollment_model').modal('show');
var myModal = new bootstrap.Modal(document.getElementById('upload_enrollment_model'));
myModal.show();
$('#file_client_id').val(client_id);
$('#file_branch_id').val(client_branch_id);
$.ajax({
url: '<?= base_url("util/get_client_policy_list_for_remainder/") ?>' + client_id + '/' + client_branch_id,
type: "GET",
dataType: 'json',
success: function(res) {
console.log('uploadEnrollmentFile policy list', res)
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if (res.status === false) {
toastr.error(res.status);
return;
}
appendpolicy(res.data)
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}
});
}
function appendpolicy(data)
{
$('#policy_id').empty();
$('#policy_id').append($('<option>', {
value: '',
text: 'Select',
selected: true
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text:`${item.policy_name ?? ''} - ${item.policy_no ?? ''}`
});
$('#policy_id').append(option);
});
}
$(document).ready(function() {
$("#uploadForm").submit(function(event) {
event.preventDefault(); // Prevent the default form submission
var client_id = $('#clients').val()
var client_branch_id = $('#branch_id').val()
var isValid = $('#uploadForm').parsley().validate();
if (!isValid) {
console.log('Form is Empty', 'Warning');
return;
}
if(client_id == 0 && client_branch_id == 0){
toastr.warning('Select Client and Client Branch');
return false;
}
var formData = new FormData($(this)[0]);
$.ajax({
url: $(this).attr("action"),
type: 'POST',
data: formData,
processData: false, // Prevent jQuery from automatically processing the data
contentType: false, // Let jQuery handle the content type
headers: {
"X-Requested-With": "XMLHttpRequest"
},
beforeSend: function() {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
},
success: function(response) {
// Request successful, handle response
console.log('Enrollment list:', response);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
toastr.success('File upload success, Data validation is in-progress', 'success');
setTimeout(function() {
window.location.href = '<?= base_url("employee/upload/") ?>';
}, 600);
} else if (response.code === 404 && response.dataStatus === false) {
console.error('No data found', response);
toastr.error(response.message, 'error');
setTimeout(function() {
window.location.href = '<?= base_url("employee/upload/") ?>';
}, 600);
} else {
console.error('Something went wrong!');
// toastr.error('Something went wrong! Try later', 'Error');
setTimeout(function() {
window.location.href = '<?= base_url("employee/upload/") ?>';
}, 600);
}
},
error: function(xhr, status, error) {
// Request failed, handle error
console.error("Request failed:", status, error);
console.error('Response:', xhr.responseText);
// toastr.error('Something went wrong! Try later', 'Error');
setTimeout(function() {
window.location.href = '<?= base_url("employee/upload/") ?>';
}, 1000);
},
complete: function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}
});
});
});
function sendManualReminder(input)
{
console.log('sendManualReminder function called');
var client_id = $('#clients').val()
var client_branch_id = $('#branch_id').val()
console.log('input', input);
console.log('client_id', client_id);
console.log('client_branch_id', client_branch_id);
if(client_id == 0 && client_branch_id == 0)
{
Swal.fire({
title: "warning!",
text: 'Please select the Client and Client Branch.',
icon: "warning"
});
return false
}
$.ajax({
url: '<?= base_url("util/send_manual_remainder/") ?>' + client_id + '/' + client_branch_id,
type: "GET",
dataType: 'json',
success: function(res) {
console.log('send_manual_remainder', res)
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if(res.status == false){
toastr.info(res.message, 'INFO');
}else{
toastr.success(res.message, 'SUCCESS');
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}
});
}
</script>

View File

@ -150,16 +150,12 @@ input:checked + .slider:before {
$("#insurer_general_form").submit(function(events) {
events.preventDefault();
// var isValid = validateForm();
var isValid = true;
jQuery.each(events.target, function(index, event) {
if (event.validity.valid) {
} else {
isValid = false;
}
});
var isValid = $('#insurer_General_PrimaryKey').parsley().validate();
if (!isValid) {
console.log('Form is Empty', 'Warning');
return ;
}
var PrimaryKey = $('#insurer_General_PrimaryKey').val();
var form_action = '';
@ -193,29 +189,25 @@ input:checked + .slider:before {
$('#insurer_id').val(res.data.id);
$('#insurer_General_PrimaryKey').val(res.data.id);
$('#insurer_id_branch').val(res.data.id);
$('#insurer_branch_contacts_id').click();
// $('#insurer_branch_contacts_id').click();
$('#btnBranchAdd').show();
var message = "Insurer General Info";
toastr.success(message, 'Success');
// $.toast({
// text: 'Insurer General Info',
// heading: "Submitted Sucessfully",
// position: 'top-right',
// icon: 'success',
// bgColor: !1,
// });
if (PrimaryKey === '') {
setTimeout(function(){
window.location.href = '<?= base_url('master/insurer/list/')?>' + res.data.id
}, 100)
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log('Something Wrong!', 'warning'); }, 1000);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log('Something Wrong!', 'warning');
}
});
}
@ -252,7 +244,8 @@ input:checked + .slider:before {
});
function PreviewImage() {
function PreviewImage()
{
var oFReader = new FileReader();
oFReader.readAsDataURL(document.getElementById("insurer_logo").files[0]);
@ -260,4 +253,9 @@ input:checked + .slider:before {
document.getElementById("uploadPreview").src = oFREvent.target.result;
};
};
//-----------------------------------------------------------------------------------------------------
</script>

View File

@ -0,0 +1,152 @@
<div class="tab-pane fade" id="template-tab">
<input type="hidden" id="insurer_templete_count" value="<?= isset($insurer_templete_count) ? $insurer_templete_count : ''?>">
<div class="row">
<div class="form-group col-md-4">
<label for="email">Existing Insurer Export<span class="text-danger">*</span></label>
<select class="form-control" id="insurer" name="insurer" required>
<option value="">Select Insurer</option>
</select>
</div>
<div class="form-group col-md-3" style="position: relative;top: 28px;">
<label for="email"><span class="text-danger"></span></label>
<a href="#" class="btn btn-primary waves-effect waves-light" onclick="checkInsurerTemplete(this)">Copy</a>
</div>
</div>
</div>
<script>
$(document).ready(function(){
$('#insurer').select2();
featchInsurerList()
})
function featchInsurerList()
{
$.ajax({
url: '<?= base_url("util/get_insurer_by_export_templete") ?>',
type: "GET",
dataType: 'json',
success: function(res) {
console.log('featchInsurerList list', res)
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
appendInsurer(res.data)
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}
});
}
function appendInsurer(data)
{
$('#insurer').empty();
$('#insurer').append($('<option>', {
value: '',
text: 'Select',
selected: true
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.insurer_name
});
$('#insurer').append(option);
});
}
function checkInsurerTemplete(input)
{
var existing_insurer_id = $('#insurer').val();
var copy_insurer_id = $('#insurer_General_PrimaryKey').val()
var insurer_templete_count = $('#insurer_templete_count').val()
if(existing_insurer_id == '')
{
Swal.fire({
title: "warning!",
text: 'Please select the Insurer',
icon: "warning"
});
return false;
}
console.log('existing_insurer_id', existing_insurer_id)
console.log('copy_insurer_id', copy_insurer_id)
console.log('insurer_templete_count', insurer_templete_count)
$('#insurer').val('').change();
if(insurer_templete_count == 0){
copyTemplateAJAX(existing_insurer_id, copy_insurer_id)
}else{
Swal.fire({
title: "The insurer already have export template?",
text: "If you want to approve this the existing template will be deleted!",
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#3085d6",
confirmButtonText: "Yes",
}).then((result) => {
if (result.isConfirmed) {
copyTemplateAJAX(existing_insurer_id, copy_insurer_id)
}
});
}
}
function copyTemplateAJAX(existing_insurer_id, copy_insurer_id)
{
$.ajax({
url: '<?= base_url("util/copy_insurer_templete/") ?>' + existing_insurer_id + '/' + copy_insurer_id,
type: "GET",
dataType: 'json',
success: function(res) {
console.log('checkInsurerTemplete response', res)
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if(res.status == false){
toastr.error(res.message, 'ERROR');
}else{
toastr.success(res.message, 'SUCCESS');
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}
});
}
</script>

View File

@ -1,35 +1,3 @@
<style>
body {
.multiselect-native-select {
position: relative;
/* bottom: 32px; */
select {
border: 0 !important;
clip: rect(0 0 0 0) !important;
height: 1px !important;
margin: -1px -1px -1px -3px !important;
overflow: hidden !important;
padding: 0 !important;
position: absolute !important;
width: 1px !important;
left: 50%;
top: 30px;
}
}
.multiselect-container{
width: 100% !important;
}
.multiselect-selected-text{
float: left !important;
}
}
</style>
<div class="row" id="insurer_add">
<div class="col-12">
<div class="card">
@ -59,10 +27,24 @@ body {
<span class="d-none d-sm-inline-block">Branch & Contacts</span>
</a>
</li>
<?php if(isset($insurer['id'])){ ?>
<li class="nav-item">
<a href="#template-tab" data-toggle="tab" aria-expanded="false" class="nav-link px-3 py-2" id="insurer_export_templete">
<span class="mr-1"><i class="mdi mdi-file-export font-16"></i></span>
<span class="d-none d-sm-inline-block">Insurer Export Templete</span>
</a>
</li>
<?php } ?>
</ul>
<div class="tab-content">
<?php include('insurer_basic_info.php'); ?>
<?php include('insurer_branch.php'); ?>
<?php include('insurer_export_templete.php'); ?>
</div>
</div>
</div>

View File

@ -572,7 +572,7 @@
<a href="<?= base_url('/employee/endorsement-list') ?>">View Endorsement</a>
</li>
<li>
<a href="<?= base_url('/employee/enrollment-list') ?>">View Enrollment</a>
<a href="<?= base_url('/employee/enrollment-list') ?>">View Enrolment</a>
</li>
</ul>
</div>

View File

@ -2698,14 +2698,14 @@ function createCheckboxes(obj, additional_relationship = [], unique_id = null, p
<input class="form-check-input" type="radio" name="childrens" id="children-1" value="1" ${childrensValue === '1' ? 'checked' : ''}>
<label class="form-check-label radioalign" for="children-1">1</label>
</div>
<div class="form-check col-lg-1">
<input class="form-check-input" type="radio" name="childrens" id="children-any" value="any" ${childrensValue === 'any' ? 'checked' : ''}>
<label class="form-check-label radioalign" for="children-any">Any</label>
</div>
<div class="form-check col-lg-1">
<input class="form-check-input" type="radio" name="childrens" id="children-no" value="0" ${childrensValue === '0' ? 'checked' : ''}>
<label class="form-check-label radioalign" for="children-unset">No</label>
</div>
<div class="form-check col-lg-1">
<input class="form-check-input" type="radio" name="childrens" id="children-any" value="any" ${childrensValue === 'any' ? 'checked' : ''}>
<label class="form-check-label radioalign" for="children-any">Any</label>
</div>
<div class="form-check col-lg-1">
<input class="form-check-input" type="radio" name="childrens" id="children-unset" value="NA" ${childrensValue === 'NA' ? 'checked' : ''}>
<label class="form-check-label radioalign" for="children-unset">NA</label>
@ -2727,14 +2727,14 @@ function createCheckboxes(obj, additional_relationship = [], unique_id = null, p
<input class="form-check-input" type="radio" name="parents" id="parents-double" value="2" ${parentsValue === '2' ? 'checked' : ''}>
<label class="form-check-label radioalign" for="parents-double">2</label>
</div>
<div class="form-check col-lg-1">
<input class="form-check-input" type="radio" name="parents" id="parents-any" value="any" ${parentsValue === 'any' ? 'checked' : ''}>
<label class="form-check-label radioalign" for="parents-any">Any</label>
</div>
<div class="form-check col-lg-1">
<input class="form-check-input" type="radio" name="parents" id="parents-no" value="0" ${parentsValue === '0' ? 'checked' : ''}>
<label class="form-check-label radioalign" for="parents-no">No</label>
</div>
<div class="form-check col-lg-1">
<input class="form-check-input" type="radio" name="parents" id="parents-any" value="any" ${parentsValue === 'any' ? 'checked' : ''}>
<label class="form-check-label radioalign" for="parents-any">Any</label>
</div>
<div class="form-check col-lg-1">
<input class="form-check-input" type="radio" name="parents" id="parents-unset" value="NA" ${parentsValue === 'NA' ? 'checked' : ''}>
<label class="form-check-label radioalign" for="parents-unset">NA</label>
@ -2755,14 +2755,14 @@ function createCheckboxes(obj, additional_relationship = [], unique_id = null, p
<input class="form-check-input" type="radio" name="parents-in-law" id="parents-in-law-double" value="2" ${parentsInLawValue === '2' ? 'checked' : ''}>
<label class="form-check-label radioalign" for="parents-in-law-double">2</label>
</div>
<div class="form-check col-lg-1">
<input class="form-check-input" type="radio" name="parents-in-law" id="parents-in-law-any" value="any" ${parentsInLawValue === 'any' ? 'checked' : ''}>
<label class="form-check-label radioalign" for="parents-in-law-any">Any</label>
</div>
<div class="form-check col-lg-1">
<input class="form-check-input" type="radio" name="parents-in-law" id="parents-in-law-no" value="0" ${parentsInLawValue === '0' ? 'checked' : ''}>
<label class="form-check-label radioalign" for="parents-in-law-no">No</label>
</div>
<div class="form-check col-lg-1">
<input class="form-check-input" type="radio" name="parents-in-law" id="parents-in-law-any" value="any" ${parentsInLawValue === 'any' ? 'checked' : ''}>
<label class="form-check-label radioalign" for="parents-in-law-any">Any</label>
</div>
<div class="form-check col-lg-1">
<input class="form-check-input" type="radio" name="parents-in-law" id="parents-in-law-unset" value="NA" ${parentsInLawValue === 'NA' ? 'checked' : ''}>
<label class="form-check-label radioalign" for="parents-in-law-unset">NA</label>

View File

@ -1,236 +0,0 @@
<?php
namespace App\Tests;
use CodeIgniter\Test\CIUnitTestCase;
use Config\App;
use Config\Services;
use Tests\Support\Libraries\ConfigReader;
use App\Controllers\EmployeeServiceController;
use CodeIgniter\Test\DatabaseTestTrait;
use Kint\Kint;
class PremiumCalculationTestNew extends CIUnitTestCase
{
use DatabaseTestTrait;
protected $migrate = false;
//primary, single parent, double parent, and double parent in law
public function testPremiumCalculation($MY_PARAM = 'default')
{
helper('excel_util_helper');
$param = getenv('MY_PARAM');
// echo isset($param) && $param != NULL ? $param : $MY_PARAM;
//first slab
$primary_relationship = '{"self":1,"spouse":"any","childrens":"any","parents":"NA","parents-in-law":"NA","either-parents-pil":0}';
$primary_grid_id = 7;
$primary_unit = 'unit1';
$primary_grid_type = 2;
$primary_max_si = 35000000;
$primary_grid_name = 'dependent + age + SI';
$primary_grid_master = ['id' => 4,'policy_type' => 'GMC','ui_type' => $primary_grid_id,'policy_grid_type' => $primary_grid_name,'is_dependent_allowed' => 1,'max_dependent_age' => 0,'max_dependent_count' => 1,'basicpay' => 0,'emp_band' => 0];
$primary_slabs = [
[ 'id' => 322, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $primary_grid_id, 'age_from' => 0, 'age_to' => 18, 'grade' => 'A', 'si' => 5000000, 'premium' => 500, 'max_si' => $primary_max_si,'premium_type' => $primary_grid_type, 'relationship' => null,'additional_relationship' => $primary_relationship,'unit' => $primary_unit],
[ 'id' => 323, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $primary_grid_id, 'age_from' => 19, 'age_to' => 25, 'grade' => 'B', 'si' => 5000000, 'premium' => 1500, 'max_si' => $primary_max_si, 'premium_type' => $primary_grid_type, 'relationship' => null,'additional_relationship' => $primary_relationship,'unit' => $primary_unit],
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $primary_grid_id, 'age_from' => 26, 'age_to' => 35, 'grade' => 'C', 'si' => 5000000, 'premium' => 2000, 'max_si' => $primary_max_si, 'premium_type' => $primary_grid_type, 'relationship' => null,'additional_relationship' => $primary_relationship,'unit' => $primary_unit],
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $primary_grid_id, 'age_from' => 36, 'age_to' => 45, 'grade' => 'D', 'si' => 5000000, 'premium' => 2500, 'max_si' => $primary_max_si, 'premium_type' => $primary_grid_type, 'relationship' => null,'additional_relationship' => $primary_relationship,'unit' => $primary_unit],
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $primary_grid_id, 'age_from' => 46, 'age_to' => 55, 'grade' => 'E', 'si' => 5000000, 'premium' => 3000, 'max_si' => $primary_max_si, 'premium_type' => $primary_grid_type, 'relationship' => null,'additional_relationship' => $primary_relationship,'unit' => $primary_unit],
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $primary_grid_id, 'age_from' => 56, 'age_to' => 75, 'grade' => 'F', 'si' => 5000000, 'premium' => 3500, 'max_si' => $primary_max_si, 'premium_type' => $primary_grid_type, 'relationship' => null,'additional_relationship' => $primary_relationship,'unit' => $primary_unit],
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $primary_grid_id, 'age_from' => 76, 'age_to' => 85, 'grade' => 'G', 'si' => 5000000, 'premium' => 4000, 'max_si' => $primary_max_si, 'premium_type' => $primary_grid_type, 'relationship' => null,'additional_relationship' => $primary_relationship,'unit' => $primary_unit],
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $primary_grid_id, 'age_from' => 86, 'age_to' => 100, 'grade' => 'G', 'si' => 5000000, 'premium' => 4500, 'max_si' => $primary_max_si, 'premium_type' => $primary_grid_type, 'relationship' => null,'additional_relationship' => $primary_relationship,'unit' => $primary_unit],
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $primary_grid_id, 'age_from' => 86, 'age_to' => 100, 'grade' => 'G', 'si' => $primary_max_si, 'premium' => 15000, 'max_si' => 0, 'premium_type' => $primary_grid_type, 'relationship' => null,'additional_relationship' => $primary_relationship,'unit' => $primary_unit],
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $primary_grid_id, 'age_from' => 86, 'age_to' => 100, 'grade' => 'G', 'si' => 30000000, 'premium' => 30000, 'max_si' => 0, 'premium_type' => $primary_grid_type, 'relationship' => null,'additional_relationship' => $primary_relationship,'unit' => $primary_unit]
];
//second slab
$second_relationship = '{"self":"NA","spouse":"NA","childrens":"NA","parents":"any","parents-in-law":"NA","either-parents-pil":0}';
$second_grid_id = 10;
$second_unit = 'unit1';
$second_grid_type = 1;
$second_max_si = 35000000;
$second_grid_name = 'max age';
$second_grid_master = ['id' => 4,'policy_type' => 'GMC','ui_type' => $second_grid_id,'policy_grid_type' => $second_grid_name,'is_dependent_allowed' => 1,'max_dependent_age' => 0,'max_dependent_count' => 1,'basicpay' => 0,'emp_band' => 0];
$second_slabs = [
[ 'id' => 322, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $second_grid_id, 'age_from' => 0, 'age_to' => 18, 'grade' => 'A', 'si' => 5000000, 'premium' => 700, 'max_si' => 2500000,'premium_type' => $second_grid_type, 'relationship' => null,'additional_relationship' => $second_relationship,'unit' => $second_unit ],
[ 'id' => 323, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $second_grid_id, 'age_from' => 19, 'age_to' => 25, 'grade' => 'B', 'si' => 5000000, 'premium' => 1400, 'max_si' => 2000000, 'premium_type' => $second_grid_type, 'relationship' => null,'additional_relationship' => $second_relationship,'unit' => $second_unit],
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $second_grid_id, 'age_from' => 26, 'age_to' => 35, 'grade' => 'C', 'si' => 5000000, 'premium' => 2300, 'max_si' => 1800000, 'premium_type' => $second_grid_type, 'relationship' => null,'additional_relationship' => $second_relationship,'unit' => $second_unit],
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $second_grid_id, 'age_from' => 36, 'age_to' => 45, 'grade' => 'D', 'si' => 5000000, 'premium' => 2750, 'max_si' => 150000, 'premium_type' => $second_grid_type, 'relationship' => null,'additional_relationship' => $second_relationship,'unit' => $second_unit],
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $second_grid_id, 'age_from' => 46, 'age_to' => 55, 'grade' => 'E', 'si' => 5000000, 'premium' => 3500, 'max_si' => 130000, 'premium_type' => $second_grid_type, 'relationship' => null,'additional_relationship' => $second_relationship,'unit' => $second_unit],
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $second_grid_id, 'age_from' => 56, 'age_to' => 75, 'grade' => 'F', 'si' => 5000000, 'premium' => 4250, 'max_si' => 10, 'premium_type' => $second_grid_type, 'relationship' => null,'additional_relationship' => $second_relationship,'unit' => $second_unit],
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $second_grid_id, 'age_from' => 76, 'age_to' => 85, 'grade' => 'G', 'si' => 5000000, 'premium' => 4950, 'max_si' => 5, 'premium_type' => $second_grid_type, 'relationship' => null,'additional_relationship' => $second_relationship,'unit' => $second_unit],
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $second_grid_id, 'age_from' => 86, 'age_to' => 100, 'grade' => 'G', 'si' => 5000000, 'premium' => 5500, 'max_si' => 5, 'premium_type' => $second_grid_type, 'relationship' => null,'additional_relationship' => $second_relationship,'unit' => $second_unit]
];
// third slab
$third_relationship = '{"self":"NA","spouse":"NA","childrens":"NA","parents":1,"parents-in-law":"NA","either-parents-pil":0}';
$third_grid_id = 7;
$third_unit = 'unit1';
$third_grid_type = 1;
$third_max_si = 35000000;
$third_grid_name = 'age band';
$third_grid_master = ['id' => 4,'policy_type' => 'GMC','ui_type' => $third_grid_id,'policy_grid_type' => $third_grid_name,'is_dependent_allowed' => 1,'max_dependent_age' => 0,'max_dependent_count' => 1,'basicpay' => 0,'emp_band' => 0];
$third_slabs = [
[ 'id' => 322, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $third_grid_id, 'age_from' => 0, 'age_to' => 18, 'grade' => 'A', 'si' => 5000000, 'premium' => 701, 'max_si' => 2500000,'premium_type' => $third_grid_type, 'relationship' => null,'additional_relationship' => $third_relationship,'unit' => $third_unit ],
[ 'id' => 323, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $third_grid_id, 'age_from' => 19, 'age_to' => 25, 'grade' => 'B', 'si' => 5000000, 'premium' => 1401, 'max_si' => 2000000, 'premium_type' => $third_grid_type, 'relationship' => null,'additional_relationship' => $third_relationship,'unit' => $third_unit],
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $third_grid_id, 'age_from' => 26, 'age_to' => 35, 'grade' => 'C', 'si' => 5000000, 'premium' => 2301, 'max_si' => 1800000, 'premium_type' => $third_grid_type, 'relationship' => null,'additional_relationship' => $third_relationship,'unit' => $third_unit],
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $third_grid_id, 'age_from' => 36, 'age_to' => 45, 'grade' => 'D', 'si' => 5000000, 'premium' => 2751, 'max_si' => 150000, 'premium_type' => $third_grid_type, 'relationship' => null,'additional_relationship' => $third_relationship,'unit' => $third_unit],
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $third_grid_id, 'age_from' => 46, 'age_to' => 55, 'grade' => 'E', 'si' => 5000000, 'premium' => 3501, 'max_si' => 130000, 'premium_type' => $third_grid_type, 'relationship' => null,'additional_relationship' => $third_relationship,'unit' => $third_unit],
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $third_grid_id, 'age_from' => 56, 'age_to' => 75, 'grade' => 'F', 'si' => 5000000, 'premium' => 4251, 'max_si' => 10, 'premium_type' => $third_grid_type, 'relationship' => null,'additional_relationship' => $third_relationship,'unit' => $third_unit],
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $third_grid_id, 'age_from' => 76, 'age_to' => 85, 'grade' => 'G', 'si' => 5000000, 'premium' => 4951, 'max_si' => 5, 'premium_type' => $third_grid_type, 'relationship' => null,'additional_relationship' => $third_relationship,'unit' => $third_unit],
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $third_grid_id, 'age_from' => 86, 'age_to' => 100, 'grade' => 'G', 'si' => 5000000, 'premium' => 5501, 'max_si' => 5, 'premium_type' => $third_grid_type, 'relationship' => null,'additional_relationship' => $third_relationship,'unit' => $third_unit]
];
// fourth slab
$fourth_relationship = '{"self":"NA","spouse":"NA","childrens":"NA","parents":"NA","parents-in-law":2,"either-parents-pil":0}';
$fourth_grid_id = 11;
$fourth_unit = 'unit1';
$fourth_grid_type = 2;
$fourth_max_si = 8000000;
$fourth_grid_name = 'age band';
$fourth_grid_master = ['id' => 4,'policy_type' => 'GMC','ui_type' => $fourth_grid_id,'policy_grid_type' => $fourth_grid_name,'is_dependent_allowed' => 1,'max_dependent_age' => 0,'max_dependent_count' => 1,'basicpay' => 0,'emp_band' => 0];
$fourth_slabs = [
[ 'id' => 322, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $fourth_grid_id, 'age_from' => 0, 'age_to' => 18, 'grade' => 'A', 'si' => 5000000, 'premium' => 1111, 'max_si' => $fourth_max_si,'premium_type' => $fourth_grid_type, 'relationship' => null,'additional_relationship' => $fourth_relationship,'unit' => $fourth_unit ],
[ 'id' => 323, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $fourth_grid_id, 'age_from' => 19, 'age_to' => 25, 'grade' => 'B', 'si' => 5000000, 'premium' => 2222, 'max_si' => $fourth_max_si, 'premium_type' => $fourth_grid_type, 'relationship' => null,'additional_relationship' => $fourth_relationship,'unit' => $fourth_unit],
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $fourth_grid_id, 'age_from' => 26, 'age_to' => 35, 'grade' => 'C', 'si' => 5000000, 'premium' => 3333, 'max_si' => $fourth_max_si, 'premium_type' => $fourth_grid_type, 'relationship' => null,'additional_relationship' => $fourth_relationship,'unit' => $fourth_unit],
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $fourth_grid_id, 'age_from' => 36, 'age_to' => 45, 'grade' => 'D', 'si' => 5000000, 'premium' => 4444, 'max_si' => $fourth_max_si, 'premium_type' => $fourth_grid_type, 'relationship' => null,'additional_relationship' => $fourth_relationship,'unit' => $fourth_unit],
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $fourth_grid_id, 'age_from' => 46, 'age_to' => 55, 'grade' => 'E', 'si' => 5000000, 'premium' => 5555, 'max_si' => $fourth_max_si, 'premium_type' => $fourth_grid_type, 'relationship' => null,'additional_relationship' => $fourth_relationship,'unit' => $fourth_unit],
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $fourth_grid_id, 'age_from' => 56, 'age_to' => 75, 'grade' => 'F', 'si' => 5000000, 'premium' => 6666, 'max_si' => $fourth_max_si, 'premium_type' => $fourth_grid_type, 'relationship' => null,'additional_relationship' => $fourth_relationship,'unit' => $fourth_unit],
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $fourth_grid_id, 'age_from' => 76, 'age_to' => 85, 'grade' => 'G', 'si' => 5000000, 'premium' => 7777, 'max_si' => $fourth_max_si, 'premium_type' => $fourth_grid_type, 'relationship' => null,'additional_relationship' => $fourth_relationship,'unit' => $fourth_unit],
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $fourth_grid_id, 'age_from' => 86, 'age_to' => 100, 'grade' => 'G', 'si' => 5000000, 'premium' => 8888, 'max_si' => $fourth_max_si, 'premium_type' => $fourth_grid_type, 'relationship' => null,'additional_relationship' => $fourth_relationship,'unit' => $fourth_unit],
[ 'id' => 324, 'client_id' => 61, 'client_policy_id' => 63, 'policy_grid_id' => $fourth_grid_id, 'age_from' => 86, 'age_to' => 100, 'grade' => 'G', 'si' => 8000000, 'premium' => 9999, 'max_si' => 0, 'premium_type' => $fourth_grid_type, 'relationship' => null,'additional_relationship' => $fourth_relationship,'unit' => $fourth_unit]
];
//overall rack rate
$over_all_rack_details = [ 'primary' => [ "slab_rates" => $primary_slabs,'grid_master' => $primary_grid_master],
'two parent' => ["slab_rates" => $second_slabs,'grid_master' => $second_grid_master],
'single parent' => ["slab_rates" => $third_slabs,'grid_master' => $third_grid_master],
'double_parent_in_law' => ["slab_rates" => $fourth_slabs,'grid_master' => $fourth_grid_master]
];
// Sample family data
$family_details = [
[2,'TEST001','John Doe', '01-Jan-1988', 'M', 'Self', '5000000', NULL, '', '', 'G', '', '', '', '', '', '','','unit1'],
[1,'TEST001','Jane Doe', '01-Jan-1985', 'F', 'Spouse', 5000000, '01-Jan-2024', '01-Jan-2020', 50000, 'A', 'Manager', '1234567890', 'john.doe@example.com', '0', '', '', '',''],
// [3,'TEST001','Peter Doe', '01-Jan-1955', 'M', 'Father', '', NULL, '', '', '', '', '', '', '', '', '','',''],
[4,'TEST001','Mary Doe', '01-Jan-1953', 'F', 'Mother', '', NULL, '', '', '', '', '', '', '', '', '','',''],
[5,'TEST001','Grace Doe', '01-Jan-1954', 'F', 'Mother in law', '', NULL, '', '', '', '', '', '', '', '', '','',''],
//[6,'TEST001','George Doe', '01-Jan-1948', 'M', 'Father in law', '', NULL, '', '', '', '', '', '', '', '', '','',''],
[7,'TEST001','Alice Doe', '01-Jan-1990', 'F', 'Daughter', 5000000, '01-Jan-2024', '01-Jan-2024', 40000, 'B', 'Supervisor', '9876543210', '', '', '', '','',''],
[6,'TEST001','Bob Doe', '01-Jan-1993', 'M', 'son', '50000', NULL, '', '', '', '', '', '', '', '', '','',''],
];
// Sample policy terms
$policy_terms = [
'family_floater' => true,
'family_floaters' => [
'self' => 1,
'spouse' => 1,
'childrens' => 2,
'either-parents-pil' => 0,
'parents' => 2,
'parents-in-law' => 2,
],
];
//re organize over_all_rack_details
$all_rack_rates = [];
foreach ($over_all_rack_details as $key => $value) {
foreach ($value['slab_rates'] as $skey => $svalue) {
$svalue['rack_rate_name'] = $key;
$svalue['grid_master'] = $value['grid_master'];
$all_rack_rates['slab_rates'][] = $svalue;
}
// dd($value['slab_rates']);
}
// dd($all_rack_rates);
$policy_details = ['base_policy' => null,"policy_start_date" => "2023-02-02","policy_end_date" => "2024-02-02","policy_terms" => json_encode($policy_terms),'gst' => 5];
$file = ['id' => null,'client_id' => 10,'policy_id' => 10,'action' => 'inception','client_branch_id' => 1,'created_by' => 1];
$existing_units = ['unit1'];
$data = calculate_premium_new(family_data:$family_details,policy_terms: $policy_details,slab_details : $all_rack_rates,fileArr: $file, existing_units:$existing_units);
//****************************onboard process*******************
// $empServiceController = new EmployeeServiceController();
// $empServiceController->employeesOnboardProcess(['familiy_data' => $data,'file' => $file]);
// dd();
//******************************** onboard process****************
$policy_created_count = 0;
echo "\n";
$result_to_display = [];
foreach ($data as $key => $value)
{
if(is_array($value))
{
$result_to_display[$key]['emp_code'] = $value['emp_code'];
$result_to_display[$key]['name'] = $value['name'].'('.calculate_days_bw_dates($value['dob'])->y.')';
$result_to_display[$key]['relation'] = $value['relationship'];
$temp_grid = ($value['temp']['grid_name']);
$temp_grid_type = ($value['temp']['premium_type']);
$temp_grid_type = ($temp_grid_type == 1 ? 'S' : 'I');
$result_to_display[$key]['premium_type'] = $temp_grid.'#'.$value['temp']['grid_id'].'#'.
($value['temp']['acting_self'] == true ? 'Self' : 'No' ) .'#'. ($temp_grid_type) ;
$result_to_display[$key]['si'] = $value['policy_details']['basic_cover_si'];
$result_to_display[$key]['premium'] = $value['policy_details']['premium'];
$result_to_display[$key]['policy days'] = (calculate_days_bw_dates($policy_details['policy_start_date'],$policy_details['policy_end_date'])->days + 1);
$result_to_display[$key]['no of days'] = $value['policy_details']['days'];
$result_to_display[$key]['rata_premimum'] = $value['policy_details']['rata_premimum'];
$result_to_display[$key]['gst'] = $value['policy_details']['gst'];
if(!empty($value['policy_details']['premium'])){ $policy_created_count = $policy_created_count + 1; }
}
}
TableDisplay::displayTable($result_to_display);
$this->assertTrue(($policy_created_count >= 1 || $policy_created_count = 0));
}
}
class TableDisplay
{
public static function displayTable(array $data)
{
if (empty($data)) {
echo "No data to display.\n";
return;
}
// Calculate column widths
$columns = array_keys($data[0]);
$widths = array_map(function ($col) use ($data) {
$maxWidth = strlen($col);
foreach ($data as $row) {
$maxWidth = max($maxWidth, strlen($row[$col]));
}
return $maxWidth;
}, $columns);
// Print header
echo str_repeat('-', array_sum($widths) + count($columns) * 3) . PHP_EOL;
foreach ($columns as $i => $col) {
echo str_pad($col, $widths[$i]) . " | ";
}
echo PHP_EOL;
echo str_repeat('-', array_sum($widths) + count($columns) * 3) . PHP_EOL;
// Print rows
foreach ($data as $row) {
foreach ($columns as $i => $col) {
echo str_pad($row[$col], $widths[$i]) . " | ";
}
echo PHP_EOL;
}
echo str_repeat('-', array_sum($widths) + count($columns) * 3) . PHP_EOL;
}
}