FEAT_SEND_MANUAL_REMAINDER_AND_UPLOAD_ENROLL_FILE : RV

This commit is contained in:
VENKATESHWARAN 2024-07-31 14:51:36 +05:30
parent 78815446c6
commit d26e4fd952
12 changed files with 528 additions and 129 deletions

View File

@ -273,11 +273,13 @@ $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->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

@ -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'];
@ -1642,4 +1643,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

@ -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

@ -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>
@ -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",
@ -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

@ -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 Enrollment 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,7 +261,9 @@
// 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();
@ -291,7 +345,8 @@
});
}
$(document).ready(function() {
$(document).ready(function()
{
function getUrlParameter(name) {
var params = new URLSearchParams(window.location.search);
@ -312,8 +367,6 @@
$('#branch_id').val(branch_id).trigger('change');
if($('#branch_id').val() != 0){
$('#get-emp-list').click().trigger();
}
}, 500);
@ -331,6 +384,7 @@
}, 1000);
$('#clients').select2();
$('#policy_id').select2();
$('#branch_id').select2();
var table = $('#tickets-table').DataTable({
dom: 'fBrtip',
@ -450,7 +504,8 @@
toggleContent();
});
function toggleContent() {
function toggleContent()
{
var content = document.getElementById("statusContent");
var toggleIcon = document.getElementById("toggleIcon");
if (content.style.display === "none") {
@ -463,4 +518,206 @@
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){
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

@ -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>