diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 1de6f7f5..73940906 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -219,6 +219,9 @@ $routes->group("/util", ["filter" => "authMVC"], function($routes){ $routes->get("fetch-emp-count/(:any)", "EmployeeController::getEmpCount/$1"); $routes->get("init-Emp-onboard/(:any)", "EmployeeController::initiateManualEmployeesOnboardProcess/$1"); $routes->get("full-excel-error-file/(:any)", "EmployeeController::downloadFullExcelErrorFile/$1"); + $routes->get("id-card", "EmployeeController::viewECard/$1"); + $routes->get('digital-id-card/(:segment)/(:segment)', 'EmployeeController::generateIDCardForEmployee/$1/$2'); + }); @@ -268,6 +271,11 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function($routes){ $routes->get("exportDataByClientPolicyId", "EmployeeRestController::exportDataByClientPolicyId"); $routes->get("getCashDepositData", "EmployeeRestController::getCashDepositData"); + $routes->get("exportCashDepositData", "EmployeeRestController::exportCashDepositData"); + + $routes->get("removeEmpAndEmpPolicyData", "EmployeeRestController::removeEmpAndEmpPolicyData"); + + }); $routes->post("sendEmail", "EmployeeRestController::send_email"); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index baca94e2..96815f94 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -1104,7 +1104,7 @@ class ClientController extends AdminController try { foreach ($results as $index => $record) { - if ($self->self == 1 && $self->spouse == 0 && $self->childrens == 0 && $self->parents == 0 && $self->{'parents-in-law'} == 0 && $self->{'either-parents-pil'} == 0) { + if ($self->self == 1 && $self->spouse == 0 && $self->childrens == 0 && $self->parents == 0 && $self->{'parents-in-law'} == 0 && $self->{'either-parents-pil'} == 0 && $family_floater == 0) { if ($index == '0' || $index == '1' || $index == '2') { $resultss[$index] = $record; } diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index a9c2d81a..bfcc61d9 100644 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -29,6 +29,8 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\IOFactory; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; +use Dompdf\Dompdf; + class EmployeeController extends AdminController { @@ -247,19 +249,23 @@ class EmployeeController extends AdminController { $file_id = $this->request->uri->getSegment(3); $empServiceController = new EmployeeServiceController(); - - // Render views and capture output - $result = $empServiceController->getExcelErrorData($file_id); $result['file_id'] = $file_id; - // echo '
';
- // print_r($result); die;
- if($result){
+ // Render views and capture output
+ $result = $empServiceController->getExcelErrorData($file_id);
+
+ if ($result != 0) {
+
echo view('excel_errors', $result);
- }else{
+ } else if ($result == 0) {
+
+ $data['message'] = 'File Not Found Physically';
+ return view('errors/404', $data);
+
+ } else {
+
echo view('errors/html/production');
}
-
}
/**
@@ -673,6 +679,7 @@ class EmployeeController extends AdminController
$highestRowAndColumn = $sheet->getHighestRowAndColumn();
$excel_data = $sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
+ // dd($excel_data);
$emp_data['thead'] = $excel_data[0];
unset($excel_data[0]);
$emp_data['tbody'] = $excel_data;
@@ -684,7 +691,7 @@ class EmployeeController extends AdminController
$html = 'No Data Found';
}
- return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $html, 'file_data' => $file_name], 200);
+ return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $html, 'file_data' => $file_name, 'excel_data' => $excel_data], 200);
} catch (\Exception $e) {
// Handle exception
@@ -826,6 +833,33 @@ class EmployeeController extends AdminController
return $response;
}
+ public function generateIDCardForEmployee($emp_code, $client_policy_id)
+ {
+ $dompdf = new Dompdf();
+
+ $data['data'] = $this->employeePolicyModel->getECardDataUsingMd5($client_policy_id, $emp_code);
+ // $this->loadLayout('id_card_view', $data); exit;
+
+ $html = view('id_card_view', $data);
+ // $html = str_replace('', '', $html);
+
+ $dompdf->loadHtml($html);
+
+ // (Optional) Setup the paper size and orientation
+ $dompdf->setPaper('A4', 'landscape');
+
+ // Render the HTML as PDF
+ $dompdf->render();
+
+ // Output the generated PDF to Browser
+ $dompdf->stream();
+
+ }
+
+ public function viewECard()
+ {
+ $this->loadLayout('id_card_view');
+ }
public function truncateFileData() //truncateFileDataIn DB (de activate rows)
diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php
index 8ce029c1..f25e56cf 100644
--- a/app/Controllers/EmployeeRestController.php
+++ b/app/Controllers/EmployeeRestController.php
@@ -398,7 +398,7 @@ class EmployeeRestController extends AdminController
if(count($empData))
{
- // Define headers and map database fields to Excel fields
+ // Define headers and map database fields to Excel fields
$headers = [
'Employee Code' => 'emp_code',
'Name' => 'name',
@@ -1075,6 +1075,16 @@ public function getEmployeePolicy()
// Generate Notes string based on familyFloates terms
$array->notes = $this->FloterNotesConvertion($familyFloates);
+
+ if($getSlabAndGridData['slab_rates'][0]['premium_type'] == 1)
+ {
+ $array->floter_text_heading = 'Floater Sum Insured';
+ $array->floter_text_description = 'This is a floater sum insured. A floater is a type of sum insured that provides coverage to more than one member ot a family at the same time. Simply put, its a single insurance cover for the entire family.';
+ }else{
+ $array->floter_text_heading = 'Sum Insured';
+ $array->floter_text_description = '';
+ }
+
// Convert familyFloaters terms data to plain array
$floters = $this->FloterConvertion($familyFloates);
@@ -1258,6 +1268,16 @@ public function getAddOnPolicy()
$responce['is_addon'] = $array['is_addon'];
$responce['open_for_enrollment'] = $array['open_for_enrollment'];
$responce['policy_terms'] = $decodedArray;
+
+ if(count($getSlabAndGridData['slab_rates'])){
+ if($getSlabAndGridData['slab_rates'][0]['premium_type'] == 1)
+ {
+ $responce['floter_text_heading'] = 'Floater Sum Insured';
+ }else{
+ $responce['floter_text_heading'] = 'Sum Insured';
+ }
+ }
+
if($array['is_addon'] == 3)
{
@@ -1515,50 +1535,54 @@ public function getCashDepositData()
->findAll();
$result = [];
- foreach ($ClientPolicyData as $key => $value) {
+ if(count($ClientPolicyData))
+ {
+ foreach ($ClientPolicyData as $key => $value) {
- $data['clientId'] = $value['clientId'];
- $data['insurerId'] = $value['insurerId'];
- $data['insurerName'] = $value['insurer_name'];
- $data['depositData'] = $this->clientPolicyModel->getdepositData($value['clientId'],$value['insurerId']);
- $data['balance'] = count($data['depositData']) ? $data['depositData'][0]->balance : 0;
-
- $data['policyDetails'] = [];
- $ClientPolicyData =$this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, policies.id as policy_id,policies.policy_type_id as policy_type_id, policies.name as policy_name , client_policy.is_addon as is_addon')
- ->join('policies', 'client_policy.policy_id = policies.id', 'left')
- ->where('client_policy.insurer_id', $value['insurerId'] )
- ->where('client_policy.client_id', $this->request->getGet('client_id') )
- ->findAll();
- foreach ($ClientPolicyData as $key => $value)
- {
- $getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard( $value['client_policy_id'],$value['client_id']);
- if($value['is_addon'] == "2"){ $value['type'] = 'SI TopUp'; }else if($value['is_addon'] == "3"){ $value['type'] = 'Dependent AddOn'; }else{ $value['type'] = $getSlabAndGridData['grid_master']['policy_type']; }
- $employeeDetails = $this->employeePolicyModel->getEmployeePolicy( client_id:$value['client_id'],policy_id: $value['client_policy_id'],status:0);
- $enrolledCount = 0;
- $draftCount = 0;
- if(count($employeeDetails))
+ $data['clientId'] = $value['clientId'];
+ $data['insurerId'] = $value['insurerId'];
+ $data['insurerName'] = $value['insurer_name'];
+ $data['depositData'] = $this->clientPolicyModel->getdepositData($value['clientId'],$value['insurerId']);
+ $data['balance'] = count($data['depositData']) ? $data['depositData'][0]->balance : 0;
+
+ $data['policyDetails'] = [];
+ $ClientPolicyData =$this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, policies.id as policy_id,policies.policy_type_id as policy_type_id, policies.name as policy_name , client_policy.is_addon as is_addon')
+ ->join('policies', 'client_policy.policy_id = policies.id', 'left')
+ ->where('client_policy.insurer_id', $value['insurerId'] )
+ ->where('client_policy.client_id', $this->request->getGet('client_id') )
+ ->findAll();
+ foreach ($ClientPolicyData as $key => $value)
{
- foreach ($employeeDetails as $item) {
- if ($item['emp_status'] === 'enrolled') {
- $enrolledCount++;
- } elseif ($item['emp_status'] === 'draft') {
- $draftCount++;
+ $getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard( $value['client_policy_id'],$value['client_id']);
+ if($value['is_addon'] == "2"){ $value['type'] = 'SI TopUp'; }else if($value['is_addon'] == "3"){ $value['type'] = 'Dependent AddOn'; }else{ $value['type'] = $getSlabAndGridData['grid_master']['policy_type']; }
+ $employeeDetails = $this->employeePolicyModel->getEmployeePolicy( client_id:$value['client_id'],policy_id: $value['client_policy_id'],status:0);
+ $enrolledCount = 0;
+ $draftCount = 0;
+ if(count($employeeDetails))
+ {
+ foreach ($employeeDetails as $item) {
+ if ($item['emp_status'] === 'enrolled') {
+ $enrolledCount++;
+ } elseif ($item['emp_status'] === 'draft') {
+ $draftCount++;
+ }
}
}
+
+ $value['totalMembersCount'] = count($employeeDetails);
+ $value['membersCountOfEnrolled'] = $enrolledCount;
+ $value['membersCountOfDraft'] = $draftCount;
+
+ array_push($data['policyDetails'],$value);
}
-
- $value['totalMembersCount'] = count($employeeDetails);
- $value['membersCountOfEnrolled'] = $enrolledCount;
- $value['membersCountOfDraft'] = $draftCount;
-
- array_push($data['policyDetails'],$value);
+
+
+ array_push($result,$data);
+
}
-
-
- array_push($result,$data);
-
}
-
+
+
if($result)
{
@@ -1569,4 +1593,140 @@ public function getCashDepositData()
}
+
+
+
+public function exportCashDepositData()
+{
+
+ $CashDepositData = $this->clientPolicyModel->getdepositData($this->request->getGet('client_id'),$this->request->getGet('insurer_id'));
+
+ // echo '';print_r($CashDepositData); echo '
';die;
+
+ if(count($CashDepositData))
+ {
+ // Define headers and map database fields to Excel fields
+ $headers = [
+ 'Date' => 'created_at',
+ 'Type' => 'transaction_type',
+ 'Amount' => 'amount',
+ 'Balance' => 'balance',
+ 'Description' => 'description',
+ 'Insurer Name' => 'insurer_name',
+ 'Client Name' => 'clientname'
+ ];
+
+ // Create a new Spreadsheet object
+ $spreadsheet = new Spreadsheet();
+
+ // Get the active sheet
+ $sheet = $spreadsheet->getActiveSheet();
+
+ // Add headers
+ $column = 'A';
+ foreach ($headers as $header => $dbField) {
+ $sheet->setCellValue($column . '1', $header);
+ $column++;
+ }
+
+ // Add data
+ $row = 2;
+ foreach ($CashDepositData as $Cashvalue) {
+ $column = 'A';
+ foreach ($headers as $dbField) {
+ $sheet->setCellValue($column . $row, $Cashvalue->$dbField);
+ $column++;
+ }
+ $row++;
+ }
+
+
+ // Set the header for download
+ $filename = $CashDepositData[0]->insurer_name.'-CashDeposit.xlsx';
+ header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
+ header('Content-Disposition: attachment;filename="' . $filename . '"');
+ header('Cache-Control: max-age=0');
+
+ // Save the Excel file to output
+ $writer = new Xlsx($spreadsheet);
+ $writer->save('php://output');
+ exit;
+
+ return $this->respond(['status' => 'success', 'code' => 200, 'data' => []], 200);
+
+ }else{
+
+ return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 200);
+ }
+
+}
+
+
+public function removeEmpAndEmpPolicyData()
+{
+ try {
+
+ $clientPolicy = $this->clientPolicyModel->where('id',$this->request->getGet('client_policy_id'))->findAll();
+
+ if(count($clientPolicy))
+ {
+
+
+ if($clientPolicy[0]['is_addon'] == 2)//Topup
+ {
+ $empData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code'))
+ ->where('is_addon_value', 0 )->findAll();
+ if(count($empData))
+ {
+ foreach ($empData as $key => $value) {
+
+ $this->employeePolicyModel->where('client_policy_id',$this->request->getGet('client_policy_id') )
+ ->where('employee_id', $value['id'] )
+ ->set(array('is_active'=> 0 ))
+ ->update();
+
+ }
+ }
+
+ }
+ else if($clientPolicy[0]['is_addon'] == 3)//Dependent addon
+ {
+ $empData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code'))
+ ->where('is_addon_value', 1 )->findAll();
+ if(count($empData))
+ {
+ foreach ($empData as $key => $value) {
+
+ $this->employeePolicyModel->where('client_policy_id',$this->request->getGet('client_policy_id') )
+ ->where('employee_id', $value['id'] )
+ ->set(array('is_active'=> 0 ))
+ ->update();
+
+ }
+
+ $this->employeeModel->where('emp_code', $this->request->getGet('emp_code') )
+ ->where('is_active', 1 )->where('is_addon_value', 1 )
+ ->set(array('is_active'=> 0 ))
+ ->update();
+ }
+
+ }
+
+
+
+ return $this->respond(['status' => 'success','code' => 200,'data' =>[] ], 200);
+
+ }else{
+ return $this->respond(['status' => 'failed','code' => 404,'data' => [] ], 404);
+ }
+
+
+ } catch (\Exception $e) {
+ return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
+ }
+
+}
+
+
+
}
\ No newline at end of file
diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php
index ab05a638..46fb73ee 100644
--- a/app/Controllers/EmployeeServiceController.php
+++ b/app/Controllers/EmployeeServiceController.php
@@ -958,6 +958,7 @@ class EmployeeServiceController extends AdminController
{
$error_message = "File not found";
$this->myLogger->logme('error',($error_message . ' for file id ' . $file_id));
+ return 0;
}
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path);
diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php
index b7e2f19d..3198d873 100644
--- a/app/Models/EmployeePolicyModel.php
+++ b/app/Models/EmployeePolicyModel.php
@@ -79,13 +79,17 @@ class EmployeePolicyModel extends Model
->join('tpa_branch tpab', 'cp.tpa_branch_id = tpab.id') //tpab - tpa brach
->join('clients cm', 'cp.client_id = cm.id') //cm - client master
->where('emp.client_id',$client_id)
- ->where('employee_polices.client_policy_id',$policy_id);
+ ->where('employee_polices.is_active',1)
+ ->where('emp.is_active',1)
+ ->where('employee_polices.client_policy_id',$policy_id)
+ ->orderBy('emp.emp_code','ASC')->orderBy('employee_polices.employee_id','ASC');
+
if($status != 0 && !empty($status)){
$result->where('employee_polices.status', $status);
}
- $result = $result->findAll();
+ $result = $result->findAll();
return ($result);
}
@@ -674,7 +678,8 @@ class EmployeePolicyModel extends Model
}
- public function getViewEmpSuccessList($file_id){
+ public function getViewEmpSuccessList($file_id)
+ {
return $this->db->table('employees emp')
->select(['employee_polices.*','pm.name as policy_name','im.short_name as insurer_short_name','ib.branch_name as insurer_branch_name','ib.branch_code as insurer_branch_code','tpam.name as tpa_name','tpam.short_name as tpa_short_name','tpab.branch_code as tpa_branch_code','cm.client_name','cm.short_name as client_short_name','emp.relationship','emp.relationship_code','emp.change_event','emp.emp_code','emp.name','emp.email_corporate','emp.dob','emp.gender','emp.emp_status','emp.is_active as emp_is_active','emp.mobile as mobile'])
->join('employee_polices', 'employee_polices.employee_id = emp.id')
@@ -689,5 +694,55 @@ class EmployeePolicyModel extends Model
->whereIn('employee_polices.status', ['draft', 'enrolled'])
->get()->getResultArray();
}
+
+ public function getECardDataUsingMd5($client_policy_id, $emp_code){
+
+ $result = $this->db->table('employees e')
+ ->select('e.id,
+ e.name, e.mobile,
+ e.relationship,
+ e.relationship_code,
+ e.emp_code,
+ e.email_personal,
+ e.email_corporate,
+ e.gender,
+ e.dob,
+ e.doj,
+ e.band,
+ TIMESTAMPDIFF(YEAR, e.dob, CURDATE()) AS emp_age,
+
+ ep.tpa_id,
+ ep.uhid,
+ ep.policy_end_date,
+
+ clients.client_name,
+ clients.short_name AS client_short_name,
+
+ policies.name AS policy_name,
+
+ insurers.name AS insurer_name,
+ insurers.short_name AS insurer_short_name,
+
+ tpa.name AS tpa_name,
+ tpa.short_name AS tpa_short_name'
+ )
+
+ ->join('employee_polices ep', 'ep.employee_id = e.id')
+ ->join('client_policy cp', 'cp.id = ep.client_policy_id')
+ ->join('clients', 'clients.id = cp.client_id')
+ ->join('policies', 'policies.id = cp.policy_id')
+ ->join('insurers', 'insurers.id = cp.insurer_id')
+ ->join('tpa', 'tpa.id = cp.tpa_id')
+ ->where('e.emp_status', 'active')
+ ->where('e.is_active', '1')
+ ->where('ep.status', 'active')
+ ->where('ep.is_active', '1')
+ ->where('MD5(e.emp_code)', $emp_code)
+ ->where('MD5(ep.client_policy_id)', $client_policy_id)
+ ->get()
+ ->getResultArray();
+
+ return $result;
+ }
}
\ No newline at end of file
diff --git a/app/Views/id_card_view.php b/app/Views/id_card_view.php
new file mode 100644
index 00000000..b646bb87
--- /dev/null
+++ b/app/Views/id_card_view.php
@@ -0,0 +1,80 @@
+
+
+
+
+
+
+ Driving License ID Card
+
+
+
+
+ | + + + | ++ + + | +