diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 77dfe5ba..fc3ee161 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -215,6 +215,9 @@ $routes->group("/util", ["filter" => "authMVC"], function($routes){ $routes->get("featch-emp-list", "EmployeeController::featchEmpList/$1"); $routes->get("view-success-emp-list", "EmployeeController::viewUploadedEmployeeList/$1"); $routes->get("fetch-policy-for-policy-type", "ClientController::fetchPolicyDataForPolicyType/$1"); + $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"); }); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 0e141e75..2b5354d5 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -610,7 +610,23 @@ class ClientController extends AdminController $policy_terms = $this->clientPolicyModel->where('id', $this->request->getPost('base_policy'))->first(); if ( $this->request->getPost('is_addon') == 2 || $this->request->getPost('is_addon') == 3) { - $data['policy_terms'] = $policy_terms['policy_terms']; + + if ($this->request->getPost('is_addon') == 3) { + $policyTerm = $policy_terms['policy_terms']; + $decoded_policyTerm = json_decode($policyTerm, true); + $decoded_policyTerm['family_floater'] =0; + $decoded_policyTerm['family_floaters']['self'] =0; + $decoded_policyTerm['family_floaters']['spouse'] =0; + $decoded_policyTerm['family_floaters']['childrens'] =0; + $decoded_policyTerm['family_floaters']['parents'] =0; + $decoded_policyTerm['family_floaters']['parents-in-law'] =0; + $decoded_policyTerm['family_floaters']['either-parents-pil'] =0; + + $data['policy_terms'] = json_encode($decoded_policyTerm); + }else{ + $data['policy_terms'] = $policy_terms['policy_terms']; + + } } @@ -679,7 +695,23 @@ class ClientController extends AdminController $policy_terms = $this->clientPolicyModel->where('id', $this->request->getPost('base_policy'))->first(); if ( $this->request->getPost('is_addon') == 2 || $this->request->getPost('is_addon') == 3) { - $data['policy_terms'] = $policy_terms['policy_terms']; + if ($this->request->getPost('is_addon') == 3) { + $policyTerm = $policy_terms['policy_terms']; + $decoded_policyTerm = json_decode($policyTerm, true); + $decoded_policyTerm['family_floater'] =0; + $decoded_policyTerm['family_floaters']['self'] =0; + $decoded_policyTerm['family_floaters']['spouse'] =0; + $decoded_policyTerm['family_floaters']['childrens'] =0; + $decoded_policyTerm['family_floaters']['parents'] =0; + $decoded_policyTerm['family_floaters']['parents-in-law'] =0; + $decoded_policyTerm['family_floaters']['either-parents-pil'] =0; + + $data['policy_terms'] = json_encode($decoded_policyTerm); + } else { + $data['policy_terms'] = $policy_terms['policy_terms']; + } + + } // dd($data); @@ -1259,6 +1291,7 @@ class ClientController extends AdminController ->where("employees.emp_status",'active') ->countAllResults(); + $emp_count_by_policy = $this->employeePolicyModel->where('client_policy_id',$client_policy_id)->where('is_active',1)->countAllResults(); if($emp_count == 0){ $emp_count = true; }else{ @@ -1266,7 +1299,7 @@ class ClientController extends AdminController } if ($record) { - return $this->respond(['Status' => true,'code' => 200,'data' => $record['policy_terms'], 'count' => $emp_count, 'policy_name' => $policy_name], 200); + return $this->respond(['Status' => true,'code' => 200,'data' => $record['policy_terms'], 'count' => $emp_count, 'policy_name' => $policy_name,'policy_addon' => $record['is_addon'], 'emp_count_by_policy'=>$emp_count_by_policy], 200); } else { return $this->respond(['Status' => false,'code' => 200,'message' => 'Record not found.', 'count' => $emp_count, 'policy_name' => $policy_name], 200); } diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index b723e8be..9e0e0517 100644 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -20,7 +20,7 @@ use App\Models\BatchFileModel; use App\Models\EmpEndorsementModel; use App\Models\ClientDepositModel; -use App\Controllers\Jobs ; +use App\Controllers\Jobs; use PhpOffice\PhpSpreadsheet\Spreadsheet; // use PhpOffice\PhpSpreadsheet\Writer\Xlsx; use PhpOffice\PhpSpreadsheet\Reader\Xlsx; @@ -64,381 +64,390 @@ class EmpDataServiceController extends BaseController */ - public function batchFilesAndBatchListEntry($data, $objects) - { + public function batchFilesAndBatchListEntry($data, $objects) + { - $random_number_count = 4; - $data['batch_code'] = generate_random_string($random_number_count); - $data['created_by'] = get_session_userid(); + $random_number_count = 4; + $data['batch_code'] = generate_random_string($random_number_count); + $data['created_by'] = get_session_userid(); - $insert = $this->batchFileModel->insert($data); - $batch_file_batch_code = $this->batchFileModel->where('id', $insert)->first(); + $insert = $this->batchFileModel->insert($data); + $batch_file_batch_code = $this->batchFileModel->where('id', $insert)->first(); - if($insert){ - foreach($objects as $value){ - $batch_list_data['batch_code'] = $batch_file_batch_code['batch_code']; - $batch_list_data['emp_policy_id'] = $value->primaryKey ?? $value->employee_policy_id ?? ''; - $batch_list_data['created_by'] = get_session_userid(); - $this->batchListModel->insert($batch_list_data); - } + if ($insert) { + foreach ($objects as $value) { + $batch_list_data['batch_code'] = $batch_file_batch_code['batch_code']; + $batch_list_data['emp_policy_id'] = $value->primaryKey ?? $value->employee_policy_id ?? ''; + $batch_list_data['created_by'] = get_session_userid(); + $this->batchListModel->insert($batch_list_data); } - - return true; - } - + + return true; + } + /** * Generates an Excel file for Inception_Addititon_DependentAddititon, Correction, SI_Enhancement and Deletion events based on given export data. * * @param array $export_data An array containing export data such as - * client_policy_id, - * insurer_or_tpa, - * event_type, - * actions, - * file_name. + * client_policy_id, + * insurer_or_tpa, + * event_type, + * actions, + * file_name. * @return bool True if the Excel file is successfully generated and exported, otherwise false. */ - public function generateExcelForAdditionandInception($export_data) - { - // Fetch employee data for export from the database - $objects = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($export_data); + public function generateExcelForAdditionandInception($export_data) + { + // Fetch employee data for export from the database + $objects = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($export_data); + + $totals = 0; + foreach ($objects as $key => $value) { - // Log the count of exported data - $count = count($objects); - $export_data['count'] = $count; - $this->myLogger->logme('error', 'Inception export data count : {data}', ['data'=> $count ]); - - // If no data is found for export, return false - if($count == 0){ - return false; - } - - // Log the export file name - $this->myLogger->logme('error', 'Inception export file name : {data}', ['data'=> $export_data['file_name'] ]); - - // Transform retrieved objects to an array suitable for export - $data = transform_objects_to_array_for_inception($objects); - - // Define headers for the Excel file - $headers = [ - 'S.No', - 'NAME OF EMP/DEP', - 'EMP ID', - 'EMP/DEP TYPE', - 'RELATION', - 'DOB', - 'GENDER', - 'PRE EXISTING AILMENTS', - 'BASIC COVER SI', - 'DATE OF COVERAGE', - 'AGE', - 'RELATIONSHIP', - 'REMARKS', - 'POLICY END DATE', - 'NO OF DAYS', - 'TPA ID', - 'UHID', - 'PREMIUM', - 'PR0 RATA PREMIUM', - 'GST', - 'TOTAL' - ]; - - // Generate Excel file - $tempFile = tmpfile(); - $success = generate_excel($headers, $data, $tempFile, 1); - - // If Excel generation is successful - if ($success) { - // Batch files and list entry - $return = $this->batchFilesAndBatchListEntry($export_data, $objects); - - // If batch operation is successful - if ($return) { - // Set headers for Excel file download - header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); - header('Content-Disposition: attachment;filename="' . $export_data['file_name'] . '"'); - header('Cache-Control: max-age=0'); - - // Output file contents - rewind($tempFile); - fpassthru($tempFile); - - // Close and remove temporary file - fclose($tempFile); - - return true; // Excel file successfully generated and exported - } else { - return false; // Batch operation failed - } - } - - return false; // Excel generation failed + $totals += $value->total; } - public function generateExcelForCorrection($export_data) - { - $ids = []; + // Log the count of exported data + $count = count($objects); + $export_data['count'] = $count; + $export_data['amount'] = $totals; - $objects = $this->employeePolicyModel->getCorrectionEmployeesDataForExportExcel($export_data); - foreach ($objects as $obj) { - $ids[] = $obj->id; + $this->myLogger->logme('error', 'Inception export data count : {data}', ['data' => $count]); + + // If no data is found for export, return false + if ($count == 0) { + return false; + } + + // Log the export file name + $this->myLogger->logme('error', 'Inception export file name : {data}', ['data' => $export_data['file_name']]); + + // Transform retrieved objects to an array suitable for export + $data = transform_objects_to_array_for_inception($objects); + + // Define headers for the Excel file + $headers = [ + 'S.No', + 'NAME OF EMP/DEP', + 'EMP ID', + 'EMP/DEP TYPE', + 'RELATION', + 'DOB', + 'GENDER', + 'PRE EXISTING AILMENTS', + 'BASIC COVER SI', + 'DATE OF COVERAGE', + 'AGE', + 'RELATIONSHIP', + 'REMARKS', + 'POLICY END DATE', + 'NO OF DAYS', + 'TPA ID', + 'UHID', + 'PREMIUM', + 'PR0 RATA PREMIUM', + 'GST', + 'TOTAL' + ]; + + // Generate Excel file + $tempFile = tmpfile(); + $success = generate_excel($headers, $data, $tempFile, 1); + + // If Excel generation is successful + if ($success) { + // Batch files and list entry + $return = $this->batchFilesAndBatchListEntry($export_data, $objects); + + // If batch operation is successful + if ($return) { + // Set headers for Excel file download + header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); + header('Content-Disposition: attachment;filename="' . $export_data['file_name'] . '"'); + header('Cache-Control: max-age=0'); + + // Output file contents + rewind($tempFile); + fpassthru($tempFile); + + // Close and remove temporary file + fclose($tempFile); + + return true; // Excel file successfully generated and exported + } else { + return false; // Batch operation failed } - - // echo '
';
- // print_r($objects); die;
+ }
- $count = count($objects);
- $export_data['count'] = $count;
- $this->myLogger->logme('error','Correction export data count : {data}', ['data'=> $count ]);
+ return false; // Excel generation failed
+ }
- if($count == 0){
- return false;
- }
- $this->myLogger->logme('error','Correction export file name : {data}', ['data'=> $export_data['file_name'] ]);
+ public function generateExcelForCorrection($export_data)
+ {
+ $ids = [];
- $correction_data = transform_objects_to_array_for_correction($objects);
+ $objects = $this->employeePolicyModel->getCorrectionEmployeesDataForExportExcel($export_data);
- $headers = [
- 'Emp Code',
- 'RISK ID',
- 'NAME OF EMP/DEP',
- 'EMP/DEP TYPE',
- 'RELATION',
- 'DOB',
- 'GENDER',
- 'Wrong Data',
- 'Correct Data',
- 'Remarks',
- 'Endorsement_Id'
- ];
+ foreach ($objects as $obj) {
+ $ids[] = $obj->id;
+ }
- // Create a temporary file in memory
- $tempFile = tmpfile();
+ // echo '';
+ // print_r($objects); die;
- // Generate Excel file with the temporary file
- $value = generate_excel($headers, $correction_data, $tempFile);
-
- if($value){
- $return = $this->batchFilesAndBatchListEntry($export_data, $objects);
- if($return){
-
- foreach ($ids as $key => $id) {
- $group_key = $this->empEndorsementModel->select('group_key')->where('id', $id)->first();
- if ($group_key) {
- $this->empEndorsementModel->where('group_key', $group_key)->set('status', 'inprogress')->update();
- }
+ $count = count($objects);
+ $export_data['count'] = $count;
+ $this->myLogger->logme('error', 'Correction export data count : {data}', ['data' => $count]);
+
+ if ($count == 0) {
+ return false;
+ }
+
+ $this->myLogger->logme('error', 'Correction export file name : {data}', ['data' => $export_data['file_name']]);
+
+ $correction_data = transform_objects_to_array_for_correction($objects);
+
+ $headers = [
+ 'Emp Code',
+ 'RISK ID',
+ 'NAME OF EMP/DEP',
+ 'EMP/DEP TYPE',
+ 'RELATION',
+ 'DOB',
+ 'GENDER',
+ 'Wrong Data',
+ 'Correct Data',
+ 'Remarks',
+ 'Endorsement_Id'
+ ];
+
+ // Create a temporary file in memory
+ $tempFile = tmpfile();
+
+ // Generate Excel file with the temporary file
+ $value = generate_excel($headers, $correction_data, $tempFile);
+
+ if ($value) {
+ $return = $this->batchFilesAndBatchListEntry($export_data, $objects);
+ if ($return) {
+
+ foreach ($ids as $key => $id) {
+ $group_key = $this->empEndorsementModel->select('group_key')->where('id', $id)->first();
+ if ($group_key) {
+ $this->empEndorsementModel->where('group_key', $group_key)->set('status', 'inprogress')->update();
}
+ }
+
+
+ // Set the appropriate headers for Excel file download
+ header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
+ header('Content-Disposition: attachment;filename="' . $export_data['file_name'] . '"');
+ header('Cache-Control: max-age=0');
+
+ // Rewind the temporary file pointer
+ rewind($tempFile);
+
+ // Output the contents of the temporary file to the browser
+ fpassthru($tempFile);
+
+ // Close and remove the temporary file
+ fclose($tempFile);
+
+ return true;
+ } else {
+
+ return false;
+ }
+ }
+ }
+
+
+ public function generateExcelForSIEnhancement($export_data)
+ {
+ $ids = [];
+ $objects = $this->employeePolicyModel->getSIEnhancementEmployeesDataForExportExcel($export_data);
+
+
+ $totals = 0;
+ foreach ($objects as $obj) {
+ $ids[] = $obj->endorsement_primarykey;
+ $totals += $obj->total;
+ }
+ $rounded_totals = round($totals, 2);
+ // echo '';
+ // print_r($ids); die;
+
+ $count = count($objects);
+ $export_data['count'] = $count;
+ $export_data['amount'] = $rounded_totals;
+
+ $this->myLogger->logme('error', 'SI_Enhancement export data count : {data}', ['data' => $count]);
+
+ if ($count == 0) {
+ return false;
+ }
+
+ $this->myLogger->logme('error', 'SI_Enhancement export file name : {data}', ['data' => $export_data['file_name']]);
+
+ $si_data = transform_objects_to_array_for_si_enhancement($objects);
+
+ $headers = [
+ 'S.No',
+ 'NAME OF EMP/DEP',
+ 'EMP ID',
+ 'EMP/DEP TYPE',
+ 'RELATION',
+ 'DOB',
+ 'GENDER',
+ 'PRE EXISTING AILMENTS',
+ 'BASIC COVER SI',
+ 'Old Sum Insured',
+ 'Date of Coverage',
+ 'Policy End Date',
+ 'No Of Days',
+ 'Old SI Premium',
+ 'New SI premium',
+ 'Difference premium',
+ 'Pro Rata Premium',
+ 'GST',
+ 'Total',
+ 'ENDORSEMENT_ID'
+ ];
+
+
+ // Create a temporary file in memory
+ $tempFile = tmpfile();
+
+ // Generate Excel file with the temporary file
+ $value = generate_excel($headers, $si_data, $tempFile);
+
+ if ($value) {
+ $return = $this->batchFilesAndBatchListEntry($export_data, $objects);
+ if ($return) {
+
+ foreach ($ids as $key => $id) {
+ $group_key = $this->empEndorsementModel->select('group_key')->where('id', $id)->first();
+ if ($group_key) {
+ $this->empEndorsementModel->where('group_key', $group_key)->set('status', 'inprogress')->update();
+ }
+ }
+
+ // Set the appropriate headers for Excel file download
+ header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
+ header('Content-Disposition: attachment;filename="' . $export_data['file_name'] . '"');
+ header('Cache-Control: max-age=0');
+
+ // Rewind the temporary file pointer
+ rewind($tempFile);
+
+ // Output the contents of the temporary file to the browser
+ fpassthru($tempFile);
+
+ // Close and remove the temporary file
+ fclose($tempFile);
+
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
+
+
+ public function generateExcelForDeletion($export_data)
+ {
+ $ids = [];
+
+ $objects = $this->employeePolicyModel->getDeletionEmployeeDataForExportExcel($export_data);
+
+ $totals = 0;
+ foreach ($objects as $obj) {
+ $ids[] = $obj->endorsement_primarykey;
+ $totals += $obj->total;
+ }
+ $rounded_totals = round($totals, 2);
+ // echo '';
+ // print_r($ids);
+ // print_r($objects); die;
+
+ $count = count($objects);
+ $export_data['count'] = $count;
+ $export_data['amount'] = $rounded_totals;
- // Set the appropriate headers for Excel file download
- header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
- header('Content-Disposition: attachment;filename="' . $export_data['file_name'] . '"');
- header('Cache-Control: max-age=0');
-
- // Rewind the temporary file pointer
- rewind($tempFile);
-
- // Output the contents of the temporary file to the browser
- fpassthru($tempFile);
-
- // Close and remove the temporary file
- fclose($tempFile);
-
- return true;
-
- }else{
-
- return false;
- }
- }
+ $this->myLogger->logme('error', 'Deletion export data count : {data}', ['data' => $count]);
+ if ($count == 0) {
+ return false;
}
-
- public function generateExcelForSIEnhancement($export_data)
- {
- $ids = [];
- $objects = $this->employeePolicyModel->getSIEnhancementEmployeesDataForExportExcel($export_data);
-
- foreach ($objects as $obj) {
- $ids[] = $obj->endorsement_primarykey;
- }
+ $this->myLogger->logme('error', 'Deletion export file name : {data}', ['data' => $export_data['file_name']]);
- // echo '';
- // print_r($ids); die;
- // dd($objects);
-
- $count = count($objects);
- $export_data['count'] = $count;
+ $si_data = transform_objects_to_array_for_deletion($objects);
+ // dd($si_data);
+ $headers = [
+ 'S.No',
+ 'EMP ID',
+ 'EMP NAME',
+ 'DOB',
+ 'GENDER',
+ 'RELATIONSHIP',
+ 'SUM INSURED',
+ 'Date of Leaving',
+ 'Policy End Date',
+ 'No Of Days',
+ 'Premium',
+ 'Pro Rata Premium',
+ 'GST',
+ 'Total',
+ 'Claim Status',
+ 'ENDORSEMENT_ID'
+ ];
- $this->myLogger->logme('error','SI_Enhancement export data count : {data}', ['data'=> $count ]);
- if($count == 0){
- return false;
- }
+ // Create a temporary file in memory
+ $tempFile = tmpfile();
- $this->myLogger->logme('error','SI_Enhancement export file name : {data}', ['data'=> $export_data['file_name'] ]);
+ // Generate Excel file with the temporary file
+ $value = generate_excel($headers, $si_data, $tempFile, 2);
- $si_data = transform_objects_to_array_for_si_enhancement($objects);
+ if ($value) {
+ $return = $this->batchFilesAndBatchListEntry($export_data, $objects);
+ if ($return) {
- $headers = [
- 'S.No',
- 'NAME OF EMP/DEP',
- 'EMP ID',
- 'EMP/DEP TYPE',
- 'RELATION',
- 'DOB',
- 'GENDER',
- 'PRE EXISTING AILMENTS',
- 'BASIC COVER SI',
- 'Old Sum Insured',
- 'Date of Coverage',
- 'Policy End Date',
- 'No Of Days',
- 'Old SI Premium',
- 'New SI premium',
- 'Difference premium',
- 'Pro Rata Premium',
- 'GST',
- 'Total',
- 'ENDORSEMENT_ID'
- ];
-
-
- // Create a temporary file in memory
- $tempFile = tmpfile();
-
- // Generate Excel file with the temporary file
- $value = generate_excel($headers, $si_data, $tempFile);
-
- if($value){
- $return = $this->batchFilesAndBatchListEntry($export_data, $objects);
- if($return){
-
- foreach ($ids as $key => $id) {
- $group_key = $this->empEndorsementModel->select('group_key')->where('id', $id)->first();
- if ($group_key) {
- $this->empEndorsementModel->where('group_key', $group_key)->set('status', 'inprogress')->update();
- }
+ foreach ($ids as $key => $id) {
+ $group_key = $this->empEndorsementModel->select('group_key')->where('id', $id)->first();
+ if ($group_key) {
+ $this->empEndorsementModel->where('group_key', $group_key)->set('status', 'inprogress')->update();
}
-
- // Set the appropriate headers for Excel file download
- header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
- header('Content-Disposition: attachment;filename="' . $export_data['file_name'] . '"');
- header('Cache-Control: max-age=0');
-
- // Rewind the temporary file pointer
- rewind($tempFile);
-
- // Output the contents of the temporary file to the browser
- fpassthru($tempFile);
-
- // Close and remove the temporary file
- fclose($tempFile);
-
- return true;
-
- }else{
- return false;
}
- }
- }
+ // Set the appropriate headers for Excel file download
+ header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
+ header('Content-Disposition: attachment;filename="' . $export_data['file_name'] . '"');
+ header('Cache-Control: max-age=0');
+ // Rewind the temporary file pointer
+ rewind($tempFile);
- public function generateExcelForDeletion($export_data)
- {
- $ids = [];
+ // Output the contents of the temporary file to the browser
+ fpassthru($tempFile);
- $objects = $this->employeePolicyModel->getDeletionEmployeeDataForExportExcel($export_data);
+ // Close and remove the temporary file
+ fclose($tempFile);
- foreach ($objects as $obj) {
- $ids[] = $obj->endorsement_primarykey;
- }
-
- // echo '';
- // print_r($ids);
- // print_r($objects); die;
-
- $count = count($objects);
- $export_data['count'] = $count;
-
- $this->myLogger->logme('error','Deletion export data count : {data}', ['data'=> $count ]);
-
- if($count == 0){
+ return true;
+ } else {
return false;
- }
-
- $this->myLogger->logme('error','Deletion export file name : {data}', ['data'=> $export_data['file_name'] ]);
-
- $si_data = transform_objects_to_array_for_deletion($objects);
- // dd($si_data);
- $headers = [
- 'S.No',
- 'EMP ID',
- 'EMP NAME',
- 'DOB',
- 'GENDER',
- 'RELATIONSHIP',
- 'SUM INSURED',
- 'Date of Leaving',
- 'Policy End Date',
- 'No Of Days',
- 'Premium',
- 'Pro Rata Premium',
- 'GST',
- 'Total',
- 'Claim Status',
- 'ENDORSEMENT_ID'
- ];
-
-
- // Create a temporary file in memory
- $tempFile = tmpfile();
-
- // Generate Excel file with the temporary file
- $value = generate_excel($headers, $si_data, $tempFile, 2);
-
- if($value){
- $return = $this->batchFilesAndBatchListEntry($export_data, $objects);
- if( $return){
-
- foreach ($ids as $key => $id) {
- $group_key = $this->empEndorsementModel->select('group_key')->where('id', $id)->first();
- if ($group_key) {
- $this->empEndorsementModel->where('group_key', $group_key)->set('status', 'inprogress')->update();
- }
- }
-
- // Set the appropriate headers for Excel file download
- header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
- header('Content-Disposition: attachment;filename="' . $export_data['file_name'] . '"');
- header('Cache-Control: max-age=0');
-
- // Rewind the temporary file pointer
- rewind($tempFile);
-
- // Output the contents of the temporary file to the browser
- fpassthru($tempFile);
-
- // Close and remove the temporary file
- fclose($tempFile);
-
- return true;
-
- }else{
- return false;
- }
}
-
-
}
+ }
@@ -461,455 +470,458 @@ class EmpDataServiceController extends BaseController
* - 2 if the file does not exist.
* - 0 if the provided data is incomplete or incorrect.
*/
-
- public function importExcelDataForInception($import_data)
- {
- $client_id = $import_data['client_id'];
- $client_policy_id = $import_data['client_policy_id'];
- $file = $import_data['file'];
+ public function importExcelDataForInception($import_data)
+ {
- $data = $this->readExcelToArray($file);
- unset($data[0]);
- array_pop($data);
- $count = count($data);
+ $client_id = $import_data['client_id'];
+ $client_policy_id = $import_data['client_policy_id'];
+ $file = $import_data['file'];
- $missing_id = [];
- $empty_emp_tpa_uh_ids = [];
- foreach ($data as $key => $value) {
+ $data = $this->readExcelToArray($file);
+ unset($data[0]);
+ array_pop($data);
+ $count = count($data);
- try {
+ $missing_id = [];
+ $empty_emp_tpa_uh_ids = [];
+ $totals = 0;
+ foreach ($data as $key => $value) {
- if ($value[15] === null) {
- $missing_id[] = $key + 1;
- }
+ try {
- $emp_code = $value[2];
- $name = $value[1];
+ if ($value[15] === null || $value[16] === null) {
+ $missing_id[] = $key + 1;
+ }
- $db = \Config\Database::connect();
+ $emp_code = $value[2];
+ $name = $value[1];
+ $totals += $value[20];
- // Execute the query
- $query = $db->table('employee_polices')
+ $db = \Config\Database::connect();
+
+ // Execute the query
+ $query = $db->table('employee_polices')
->select('employee_polices.id')
->join('employees', 'employees.id = employee_polices.employee_id')
->where('employee_polices.client_policy_id', $client_policy_id)
- ->where('employees.client_id', $client_id)
- ->where('employees.name', $name)
- ->where('employees.emp_code', $emp_code)
- ->where('(employee_polices.tpa_id IS NULL OR employee_polices.tpa_id = "")')
- ->where('(employee_polices.uhid IS NULL OR employee_polices.uhid = "")')
- ->where('employee_polices.is_active', 1)
- ->limit(1)
- ->get();
+ ->where('employees.client_id', $client_id)
+ ->where('employees.name', $name)
+ ->where('employees.emp_code', $emp_code)
+ ->where('(employee_polices.tpa_id IS NULL OR employee_polices.tpa_id = "")')
+ ->where('(employee_polices.uhid IS NULL OR employee_polices.uhid = "")')
+ ->where('employee_polices.is_active', 1)
+ ->limit(1)
+ ->get();
- // Get the result
- $result = $query->getRowArray();
- if (isset($result['id']) && $result['id'] !== null) {
- $empty_emp_tpa_uh_ids[] = $result['id'];
- }
- } catch (\Exception $e) {
- // Handle the exception here
- return 0;
+ // Get the result
+ $result = $query->getRowArray();
+ if (isset($result['id']) && $result['id'] !== null) {
+ $empty_emp_tpa_uh_ids[] = $result['id'];
}
+ } catch (\Exception $e) {
+ // Handle the exception here
+ return 0;
}
-
- $missing_id_count = count($missing_id);
- $empty_id_count = count($empty_emp_tpa_uh_ids);
-
- // dd($count, $missing_id_count, $empty_id_count, $data, $empty_emp_tpa_uh_ids);
-
- if ($missing_id_count != $count && $missing_id_count != 0) {
-
- return 2;
- }
-
- if ($empty_emp_tpa_uh_ids != $count && $empty_id_count == 0) {
-
- return 3;
- }
-
- // dd($empty_emp_tpa_uh_ids);
-
- $is_moved = $file->move(WRITEPATH . 'uploads/import_excel');
- $filename = $file->getName();
- $this->myLogger->logme('error', 'Inception Import file name : {data}', ['data' => $filename]);
-
- $import_data['count'] = $count;
- $import_data['file_name'] = $filename;
-
-
- $this->insertBatchFileAndBatchListForImportExcel($import_data, $empty_emp_tpa_uh_ids);
-
- // dd($import_data, $empty_emp_tpa_uh_ids);
-
-
- foreach ($data as $key => $value) {
-
- if (!empty($value) && (isset($value[15]) || isset($value[16]))) {
-
- $tpa_id = $value[15] !== null ? $value[15] : '';
- $uhid = $value[16] !== null ? $value[16] : '';
-
- foreach ($empty_emp_tpa_uh_ids as $id) {
- // Update employee policies based on the ID
- $this->employeePolicyModel->where('id', $id)->set(['tpa_id' => $tpa_id, 'uhid' => $uhid])->update();
- }
-
- // $query = $this->employeePolicyModel->getLastQuery();
- // echo $query . "
";
-
- } else {
-
- return 0;
- }
- }
-
-
-
- $policy_name = $this->getPolicyNameUsingClientPolicyId($client_policy_id);
- $depositeData = [
- 'employeeIds'=>$empty_emp_tpa_uh_ids,
- 'client_id'=>$client_id,
- 'client_policy_id'=>$client_policy_id,
- 'count'=>$count,
- 'event'=>$import_data['event_type'],
- 'policy_name'=>$policy_name['policy_name'],
- ];
-
- $this->cashDepositCalculationForInception($depositeData);
- return 1;
-
}
- public function importExcelDataForCorrection($import_data)
- {
+ $missing_id_count = count($missing_id);
+ $empty_id_count = count($empty_emp_tpa_uh_ids);
- $client_id = $import_data['client_id'];
- $client_policy_id = $import_data['client_policy_id'];
- $file = $import_data['file'];
+ // dd($count, $missing_id_count, $empty_id_count, $data, $empty_emp_tpa_uh_ids);
- $data = $this->readExcelToArray($file);
- unset($data[0]);
- $count = count($data);
+ if ($missing_id_count != $count && $missing_id_count != 0) {
- $missing_id = [];
- $empty_emp_tpa_uh_ids = [];
- foreach ($data as $key => $value) {
+ return 2;
+ }
- try {
+ if ($empty_emp_tpa_uh_ids != $count && $empty_id_count == 0) {
- if ($value[10] === null) {
- $missing_id[] = $key + 1;
- }
+ return 3;
+ }
- $emp_code = $value[0];
- $uhid = $value[1];
- $endorsement_id = $value[10] != null ? $value[10] : '';
+ // dd($empty_emp_tpa_uh_ids);
- $db = \Config\Database::connect();
+ $is_moved = $file->move(WRITEPATH . 'uploads/import_excel');
+ $filename = $file->getName();
+ $this->myLogger->logme('error', 'Inception Import file name : {data}', ['data' => $filename]);
- // Execute the query
- $query = $db->table('emp_endorsement')
- ->select('emp_endorsement.id')
- ->join('employees', 'employees.id = emp_endorsement.pk')
- ->join('employee_polices', 'employee_polices.employee_id = employees.id')
- ->where('employee_polices.client_policy_id', $client_policy_id)
- ->where('employees.client_id', $client_id)
- ->where('employee_polices.uhid', $uhid)
- ->where('employees.emp_code', $emp_code)
- ->where('(emp_endorsement.endorsement_id IS NULL OR emp_endorsement.endorsement_id = "")')
- ->groupBy('emp_endorsement.group_key')
- ->limit(1);
-
- // Get the result
- $result = $query->get()->getRowArray();
- if (isset($result['id']) && $result['id'] !== null) {
- $empty_emp_tpa_uh_ids[] = $result['id'];
- }
- } catch (\Exception $e) {
- // Handle the exception here
- return 0;
- }
- }
-
- $missing_id_count = count($missing_id);
- $empty_id_count = count($empty_emp_tpa_uh_ids);
-
- // if($missing_id_count != $count){
-
- // return 2;
- // }
-
- if($missing_id_count != 0 ){
-
- return 2;
- }
-
- // if($empty_emp_tpa_uh_ids != $count){
-
- // return 3;
- // }
-
- if( $empty_id_count == 0){
-
- return 3;
- }
-
- // dd($count, $missing_id, $missing_id_count, $empty_id_count, $data, $empty_emp_tpa_uh_ids);
-
-
- $is_moved = $file->move(WRITEPATH . 'uploads/import_excel');
- $filename = $file->getName();
-
- $this->myLogger->logme('error','Correction Import file name : {data}', ['data'=> $filename ]);
- $random_number_count = 4;
- $batch_code = generate_random_string($random_number_count);
- $this->myLogger->logme('error','Correction Import BATCH CODE : {data}', ['data'=> $batch_code ]);
+ $import_data['count'] = $count;
+ $import_data['file_name'] = $filename;
+ $import_data['amount'] = $totals;
- $import_data['batch_code'] = $batch_code;
- $import_data['created_by'] = get_session_userid();
- $import_data['file_name'] = $filename;
- $insert = $this->batchFileModel->insert($import_data);
- $batch_file_batch_code = $this->batchFileModel->where('id', $insert)->first();
+ $this->insertBatchFileAndBatchListForImportExcel($import_data, $empty_emp_tpa_uh_ids);
- $batch_code_for_batch_list['batch_code'] = $batch_file_batch_code['batch_code'];
- $batch_code_for_batch_list['created_by'] = get_session_userid();
+ // dd($import_data, $empty_emp_tpa_uh_ids);
- $file_name_with_path = WRITEPATH."/uploads/import_excel/".$batch_file_batch_code['file_name'];
- if(!file_exists($file_name_with_path))
- {
- return 2;
+ foreach ($data as $key => $value) {
+
+ if (!empty($value) && (isset($value[15]) || isset($value[16]))) {
+
+ $tpa_id = $value[15] !== null ? $value[15] : '';
+ $uhid = $value[16] !== null ? $value[16] : '';
+
+ foreach ($empty_emp_tpa_uh_ids as $id) {
+ // Update employee policies based on the ID
+ $this->employeePolicyModel->where('id', $id)->set(['tpa_id' => $tpa_id, 'uhid' => $uhid])->update();
}
- $data = read_excel_file_to_array($file_name_with_path);
- unset($data[0]);
- $count = count($data);
- $this->batchFileModel->where('id', $insert)->set('count', $count)->update();
- // dd($data);
- foreach ($data as $key => $value) {
+ // $query = $this->employeePolicyModel->getLastQuery();
+ // echo $query . "
";
- if (!empty($value) && isset($value[10])) {
+ } else {
- $emp_code = $value[0];
- $uhid = $value[1];
- $endorsement_id = $value[10] != null ? $value[10] : '';
-
- $val = $this->employeePolicyModel
- ->select('employees.id')
- ->join('employees', 'employees.id = employee_polices.employee_id')
- ->where('employee_polices.client_policy_id', $client_policy_id)
- ->where('employees.client_id', $client_id)
- ->where('employee_polices.uhid', $uhid)
- ->where('employees.emp_code', $emp_code)
- ->where('employees.is_active', 1)
- ->first();
-
- $batch_code_for_batch_list['emp_policy_id'] = $val['id'];
- $this->batchListModel->insert($batch_code_for_batch_list);
-
- // $this->employeePolicyModel->updateCorrectionData($emp_code, $uhid, $endorsement_id);
-
- $queryData = $this->empEndorsementModel->select('emp_endorsement.*, employees.id as emp_id')
- ->join('employees', 'employees.id = emp_endorsement.pk')
- ->join('employee_polices', 'employee_polices.employee_id = employees.id')
- ->where('employees.emp_code', $emp_code)
- ->where('employees.client_id', $client_id)
- ->where('employee_polices.client_policy_id', $client_policy_id)
- ->where('employee_polices.uhid', $uhid)
- ->get()
- ->getResultArray();
-
- // dd($queryData);
-
- foreach ($queryData as $endorsementData) {
-
- $emp_endoresment_id = $endorsementData['id'];
- $emp_id = $endorsementData['emp_id'];
- $field_name = $endorsementData['field_name'];
- $new_value = $endorsementData['new_value'];
- $endoresment_udate_data = [
- 'endorsement_id' => $endorsement_id,
- 'status' => 'complete',
- ];
- $this->empEndorsementModel->where('id', $emp_endoresment_id)->set($endoresment_udate_data)->update();
- $this->employeeModel->where('id', $emp_id)->set($field_name, $new_value)->update();
- }
-
- // $query = $this->employeePolicyModel->getLastQuery();
- // echo $query . "
";
- }else{
-
- return 0;
- }
-
- }
-
-
- return 1;
-
+ return 0;
+ }
}
- public function importExcelDataForSIEnhancement($import_data)
- {
- $client_id = $import_data['client_id'];
- $client_policy_id = $import_data['client_policy_id'];
- $file = $import_data['file'];
+ $policy_name = $this->getPolicyNameUsingClientPolicyId($client_policy_id);
+ $depositeData = [
+ 'employeeIds' => $empty_emp_tpa_uh_ids,
+ 'client_id' => $client_id,
+ 'client_policy_id' => $client_policy_id,
+ 'count' => $count,
+ 'event' => $import_data['event_type'],
+ 'policy_name' => $policy_name['policy_name'],
+ ];
- $data = $this->readExcelToArray($file);
- unset($data[0]);
- $count = count($data);
+ $this->cashDepositCalculationForInception($depositeData);
+ return 1;
+ }
- $missing_id = [];
- $empty_emp_tpa_uh_ids = [];
- foreach ($data as $key => $value) {
- try {
- if ($value[19] === null) {
- $missing_id[] = $key + 1;
- }
+ public function importExcelDataForCorrection($import_data)
+ {
- $emp_name = $value[1];
- $emp_code = $value[2];
- $endorsement_id = $value[19] != null ? $value[19] : '';
+ $client_id = $import_data['client_id'];
+ $client_policy_id = $import_data['client_policy_id'];
+ $file = $import_data['file'];
- $db = \Config\Database::connect();
+ $data = $this->readExcelToArray($file);
+ unset($data[0]);
+ $count = count($data);
- // Execute the query
- $query = $db->table('emp_endorsement')
+ $missing_id = [];
+ $empty_emp_tpa_uh_ids = [];
+ foreach ($data as $key => $value) {
+
+ try {
+
+ if ($value[10] === null) {
+ $missing_id[] = $key + 1;
+ }
+
+ $emp_code = $value[0];
+ $uhid = $value[1];
+ $endorsement_id = $value[10] != null ? $value[10] : '';
+
+ $db = \Config\Database::connect();
+
+ // Execute the query
+ $query = $db->table('emp_endorsement')
+ ->select('emp_endorsement.id')
+ ->join('employees', 'employees.id = emp_endorsement.pk')
+ ->join('employee_polices', 'employee_polices.employee_id = employees.id')
+ ->where('employee_polices.client_policy_id', $client_policy_id)
+ ->where('employees.client_id', $client_id)
+ ->where('employee_polices.uhid', $uhid)
+ ->where('employees.emp_code', $emp_code)
+ ->where('(emp_endorsement.endorsement_id IS NULL OR emp_endorsement.endorsement_id = "")')
+ ->groupBy('emp_endorsement.group_key')
+ ->limit(1);
+
+ // Get the result
+ $result = $query->get()->getRowArray();
+ if (isset($result['id']) && $result['id'] !== null) {
+ $empty_emp_tpa_uh_ids[] = $result['id'];
+ }
+ } catch (\Exception $e) {
+ // Handle the exception here
+ return 0;
+ }
+ }
+
+ $missing_id_count = count($missing_id);
+ $empty_id_count = count($empty_emp_tpa_uh_ids);
+
+ // if($missing_id_count != $count){
+
+ // return 2;
+ // }
+
+ if ($missing_id_count != 0) {
+
+ return 2;
+ }
+
+ // if($empty_emp_tpa_uh_ids != $count){
+
+ // return 3;
+ // }
+
+ if ($empty_id_count == 0) {
+
+ return 3;
+ }
+
+ // dd($count, $missing_id, $missing_id_count, $empty_id_count, $data, $empty_emp_tpa_uh_ids);
+
+
+ $is_moved = $file->move(WRITEPATH . 'uploads/import_excel');
+ $filename = $file->getName();
+
+ $this->myLogger->logme('error', 'Correction Import file name : {data}', ['data' => $filename]);
+ $random_number_count = 4;
+ $batch_code = generate_random_string($random_number_count);
+ $this->myLogger->logme('error', 'Correction Import BATCH CODE : {data}', ['data' => $batch_code]);
+
+
+ $import_data['batch_code'] = $batch_code;
+ $import_data['created_by'] = get_session_userid();
+ $import_data['file_name'] = $filename;
+ $insert = $this->batchFileModel->insert($import_data);
+ $batch_file_batch_code = $this->batchFileModel->where('id', $insert)->first();
+
+ $batch_code_for_batch_list['batch_code'] = $batch_file_batch_code['batch_code'];
+ $batch_code_for_batch_list['created_by'] = get_session_userid();
+
+ $file_name_with_path = WRITEPATH . "/uploads/import_excel/" . $batch_file_batch_code['file_name'];
+
+ if (!file_exists($file_name_with_path)) {
+ return 2;
+ }
+
+ $data = read_excel_file_to_array($file_name_with_path);
+ unset($data[0]);
+ $count = count($data);
+ $this->batchFileModel->where('id', $insert)->set('count', $count)->update();
+ foreach ($data as $key => $value) {
+
+ if (!empty($value) && isset($value[10])) {
+
+ $emp_code = $value[0];
+ $uhid = $value[1];
+ $endorsement_id = $value[10] != null ? $value[10] : '';
+
+ $val = $this->employeePolicyModel
+ ->select('employees.id')
+ ->join('employees', 'employees.id = employee_polices.employee_id')
+ ->where('employee_polices.client_policy_id', $client_policy_id)
+ ->where('employees.client_id', $client_id)
+ ->where('employee_polices.uhid', $uhid)
+ ->where('employees.emp_code', $emp_code)
+ ->where('employees.is_active', 1)
+ ->first();
+
+ $batch_code_for_batch_list['emp_policy_id'] = $val['id'];
+ $this->batchListModel->insert($batch_code_for_batch_list);
+
+ // $this->employeePolicyModel->updateCorrectionData($emp_code, $uhid, $endorsement_id);
+
+ $queryData = $this->empEndorsementModel->select('emp_endorsement.*, employees.id as emp_id')
+ ->join('employees', 'employees.id = emp_endorsement.pk')
+ ->join('employee_polices', 'employee_polices.employee_id = employees.id')
+ ->where('employees.emp_code', $emp_code)
+ ->where('employees.client_id', $client_id)
+ ->where('employee_polices.client_policy_id', $client_policy_id)
+ ->where('employee_polices.uhid', $uhid)
+ ->get()
+ ->getResultArray();
+
+ // dd($queryData);
+
+ foreach ($queryData as $endorsementData) {
+
+ $emp_endoresment_id = $endorsementData['id'];
+ $emp_id = $endorsementData['emp_id'];
+ $field_name = $endorsementData['field_name'];
+ $new_value = $endorsementData['new_value'];
+ $endoresment_udate_data = [
+ 'endorsement_id' => $endorsement_id,
+ 'status' => 'complete',
+ ];
+ $this->empEndorsementModel->where('id', $emp_endoresment_id)->set($endoresment_udate_data)->update();
+ $this->employeeModel->where('id', $emp_id)->set($field_name, $new_value)->update();
+ }
+
+ // $query = $this->employeePolicyModel->getLastQuery();
+ // echo $query . "
";
+ } else {
+
+ return 0;
+ }
+ }
+
+
+ return 1;
+ }
+
+
+ public function importExcelDataForSIEnhancement($import_data)
+ {
+
+ $client_id = $import_data['client_id'];
+ $client_policy_id = $import_data['client_policy_id'];
+ $file = $import_data['file'];
+
+ $data = $this->readExcelToArray($file);
+ unset($data[0]);
+ $count = count($data);
+
+
+ $missing_id = [];
+ $empty_emp_tpa_uh_ids = [];
+ $totals = 0;
+ foreach ($data as $key => $value) {
+
+ try {
+ if ($value[19] === null) {
+ $missing_id[] = $key + 1;
+ }
+
+ $totals += $value[18];
+
+ $emp_name = $value[1];
+ $emp_code = $value[2];
+ $endorsement_id = $value[19] != null ? $value[19] : '';
+
+ $db = \Config\Database::connect();
+
+ // Execute the query
+ $query = $db->table('emp_endorsement')
->select('emp_endorsement.id')
->join('employee_polices', 'employee_polices.id = emp_endorsement.pk')
->join('employees', 'employees.emp_code = emp_endorsement.emp_code')
->where('employees.emp_code', $emp_code)
- ->where('employees.name', $emp_name)
- ->where('employees.client_id', $client_id)
- ->where('emp_endorsement.actions', 'si')
- ->where('employee_polices.client_policy_id', $client_policy_id)
- ->where('(emp_endorsement.endorsement_id IS NULL OR emp_endorsement.endorsement_id = "")')
- ->groupBy('emp_endorsement.group_key');
+ ->where('employees.name', $emp_name)
+ ->where('employees.client_id', $client_id)
+ ->where('emp_endorsement.actions', 'si')
+ ->where('employee_polices.client_policy_id', $client_policy_id)
+ ->where('(emp_endorsement.endorsement_id IS NULL OR emp_endorsement.endorsement_id = "")')
+ ->groupBy('emp_endorsement.group_key');
- // Get the result
- $result = $query->get()->getRowArray();
- if (isset($result['id']) && $result['id'] !== null) {
- $empty_emp_tpa_uh_ids[] = $result['id'];
- }
- } catch (\Exception $e) {
- // Handle the exception here
- return 0;
+ // Get the result
+ $result = $query->get()->getRowArray();
+ if (isset($result['id']) && $result['id'] !== null) {
+ $empty_emp_tpa_uh_ids[] = $result['id'];
}
+ } catch (\Exception $e) {
+ // Handle the exception here
+ return 0;
}
-
- $missing_id_count = count($missing_id);
- $empty_id_count = count($empty_emp_tpa_uh_ids);
+ }
+ $rounded_totals = round($totals, 2);
- // if($missing_id_count != $count){
+ $missing_id_count = count($missing_id);
+ $empty_id_count = count($empty_emp_tpa_uh_ids);
- // return 2;
- // }
-
- if($missing_id_count != 0 ){
+ // if($missing_id_count != $count){
- return 2;
- }
+ // return 2;
+ // }
- // if($empty_emp_tpa_uh_ids != $count){
+ if ($missing_id_count != 0) {
- // return 3;
- // }
+ return 2;
+ }
- if( $empty_id_count == 0){
+ // if($empty_emp_tpa_uh_ids != $count){
- return 3;
- }
+ // return 3;
+ // }
- // dd($count, $missing_id, $missing_id_count, $empty_id_count, $data, $empty_emp_tpa_uh_ids);
+ if ($empty_id_count == 0) {
- $is_moved = $file->move(WRITEPATH . 'uploads/import_excel');
- $filename = $file->getName();
+ return 3;
+ }
- $this->myLogger->logme('error','SI_Enhancement Import file name : {data}', ['data'=> $filename ]);
- $random_number_count = 4;
- $batch_code = generate_random_string($random_number_count);
- $this->myLogger->logme('error','SI_Enhancement Import BATCH CODE : {data}', ['data'=> $batch_code ]);
+ // dd($count, $missing_id, $missing_id_count, $empty_id_count, $data, $empty_emp_tpa_uh_ids);
+
+ $is_moved = $file->move(WRITEPATH . 'uploads/import_excel');
+ $filename = $file->getName();
+
+ $this->myLogger->logme('error', 'SI_Enhancement Import file name : {data}', ['data' => $filename]);
+ $random_number_count = 4;
+ $batch_code = generate_random_string($random_number_count);
+ $this->myLogger->logme('error', 'SI_Enhancement Import BATCH CODE : {data}', ['data' => $batch_code]);
- $import_data['batch_code'] = $batch_code;
- $import_data['created_by'] = get_session_userid();
- $import_data['file_name'] = $filename;
- $insert = $this->batchFileModel->insert($import_data);
- $batch_file_batch_code = $this->batchFileModel->where('id', $insert)->first();
+ $import_data['batch_code'] = $batch_code;
+ $import_data['created_by'] = get_session_userid();
+ $import_data['file_name'] = $filename;
+ $import_data['amount'] = $rounded_totals;
+ $insert = $this->batchFileModel->insert($import_data);
+ $batch_file_batch_code = $this->batchFileModel->where('id', $insert)->first();
- $batch_code_for_batch_list['batch_code'] = $batch_file_batch_code['batch_code'];
- $batch_code_for_batch_list['created_by'] = get_session_userid();
+ $batch_code_for_batch_list['batch_code'] = $batch_file_batch_code['batch_code'];
+ $batch_code_for_batch_list['created_by'] = get_session_userid();
- $file_name_with_path = WRITEPATH."/uploads/import_excel/".$batch_file_batch_code['file_name'];
+ $file_name_with_path = WRITEPATH . "/uploads/import_excel/" . $batch_file_batch_code['file_name'];
- if(!file_exists($file_name_with_path))
- {
- return 2;
- }
-
- $data = read_excel_file_to_array($file_name_with_path);
- unset($data[0]);
- $count = count($data);
- $this->batchFileModel->where('id', $insert)->set('count', $count)->update();
- // dd($data);
- $employeeIds = [];
- foreach ($data as $key => $value) {
+ if (!file_exists($file_name_with_path)) {
+ return 2;
+ }
- if (!empty($value) && isset($value[19])) {
+ $data = read_excel_file_to_array($file_name_with_path);
+ unset($data[0]);
+ $count = count($data);
+ $this->batchFileModel->where('id', $insert)->set('count', $count)->update();
+ $employeeIds = [];
+ foreach ($data as $key => $value) {
- $emp_name = $value[1];
- $emp_code = $value[2];
- // echo $emp_name .'-'. $emp_code; die;
- $endorsement_id = $value[19] != null ? $value[19] : '';
+ if (!empty($value) && isset($value[19])) {
- $updateData = [
- 'emp_code' =>$emp_code,
- 'client_id' =>$client_id,
- 'client_policy_id' =>$client_policy_id,
- 'emp_name' =>$emp_name,
- 'endorsement_id' =>$endorsement_id,
- ];
+ $emp_name = $value[1];
+ $emp_code = $value[2];
+ // echo $emp_name .'-'. $emp_code; die;
+ $endorsement_id = $value[19] != null ? $value[19] : '';
- $this->employeePolicyModel->updateEndoresmentIdForSIEnhancement($updateData);
+ $updateData = [
+ 'emp_code' => $emp_code,
+ 'client_id' => $client_id,
+ 'client_policy_id' => $client_policy_id,
+ 'emp_name' => $emp_name,
+ 'endorsement_id' => $endorsement_id,
+ ];
- $queryData = $this->employeePolicyModel
- ->select('employee_polices.*')
- ->join('employees', 'employee_polices.employee_id = employees.id')
- ->where('employees.emp_code', $emp_code)
- ->where('employees.name', $emp_name)
- ->where('employees.client_id', $client_id)
- ->where('employee_polices.client_policy_id', $client_policy_id)
- ->where('employee_polices.is_active', 1)
- ->first();
+ $this->employeePolicyModel->updateEndoresmentIdForSIEnhancement($updateData);
- $queryData['is_active'] = 0;
- $this->employeePolicyModel->save($queryData);
+ $queryData = $this->employeePolicyModel
+ ->select('employee_polices.*')
+ ->join('employees', 'employee_polices.employee_id = employees.id')
+ ->where('employees.emp_code', $emp_code)
+ ->where('employees.name', $emp_name)
+ ->where('employees.client_id', $client_id)
+ ->where('employee_polices.client_policy_id', $client_policy_id)
+ ->where('employee_polices.is_active', 1)
+ ->first();
- unset($queryData['id']);
- unset($queryData['created_by']);
- unset($queryData['created_at']);
- unset($queryData['updated_by']);
- unset($queryData['updated_at']);
- unset($queryData['is_active']);
+ $queryData['is_active'] = 0;
+ $this->employeePolicyModel->save($queryData);
- $queryData['basic_cover_si'] = $value[8];
- $queryData['premium'] = $value[14];
- $queryData['si_enhancement_date'] = $value[10];
- $queryData['rata_premimum'] = $value[16];
- $queryData['gst'] = $value[17];
- $queryData['created_by'] = get_session_userid();
+ unset($queryData['id']);
+ unset($queryData['created_by']);
+ unset($queryData['created_at']);
+ unset($queryData['updated_by']);
+ unset($queryData['updated_at']);
+ unset($queryData['is_active']);
- //new insert
- $this->employeePolicyModel->save($queryData);
+ $queryData['basic_cover_si'] = $value[8];
+ $queryData['premium'] = $value[14];
+ $queryData['si_enhancement_date'] = $value[10];
+ $queryData['rata_premimum'] = $value[16];
+ $queryData['gst'] = $value[17];
+ $queryData['created_by'] = get_session_userid();
- $val = $this->employeePolicyModel
+ //new insert
+ $this->employeePolicyModel->save($queryData);
+
+ $val = $this->employeePolicyModel
->select('employee_polices.id')
->join('employees', 'employees.id = employee_polices.employee_id')
->where('employee_polices.client_policy_id', $client_policy_id)
@@ -919,246 +931,245 @@ class EmpDataServiceController extends BaseController
->where('employee_polices.is_active', 1)
->first();
- if ($val !== null) {
- $id = $val['id'];
- $batch_code_for_batch_list['emp_policy_id'] = $id;
- $this->batchListModel->insert($batch_code_for_batch_list);
- array_push($employeeIds, $id);
- }
-
- }else{
-
- return 0;
+ if ($val !== null) {
+ $id = $val['id'];
+ $batch_code_for_batch_list['emp_policy_id'] = $id;
+ $this->batchListModel->insert($batch_code_for_batch_list);
+ array_push($employeeIds, $id);
}
+ } else {
+ return 0;
}
-
- $policy_name = $this->getPolicyNameUsingClientPolicyId($client_policy_id);
- $depositeData = [
- 'employeeIds'=>$employeeIds,
- 'client_id'=>$client_id,
- 'client_policy_id'=>$client_policy_id,
- 'count'=>$count,
- 'event'=>$import_data['event_type'],
- 'policy_name'=>$policy_name['policy_name'],
- ];
-
- // dd($depositeData);
- $this->cashDepositCalculationForSIEnhancement($depositeData);
-
- return 1;
}
+ $policy_name = $this->getPolicyNameUsingClientPolicyId($client_policy_id);
+ $depositeData = [
+ 'employeeIds' => $employeeIds,
+ 'client_id' => $client_id,
+ 'client_policy_id' => $client_policy_id,
+ 'count' => $count,
+ 'event' => $import_data['event_type'],
+ 'policy_name' => $policy_name['policy_name'],
+ ];
- public function importExcelDataForDeletion($import_data)
- {
+ // dd($depositeData);
+ $this->cashDepositCalculationForSIEnhancement($depositeData);
- $client_id = $import_data['client_id'];
- $client_policy_id = $import_data['client_policy_id'];
- $file = $import_data['file'];
+ return 1;
+ }
- $data = $this->readExcelToArray($file);
- unset($data[0]);
- array_pop($data);
- $count = count($data);
+ public function importExcelDataForDeletion($import_data)
+ {
- $missing_id = [];
- $empty_emp_tpa_uh_ids = [];
- foreach ($data as $key => $value) {
+ $client_id = $import_data['client_id'];
+ $client_policy_id = $import_data['client_policy_id'];
+ $file = $import_data['file'];
- try {
- if ($value[15] === null) {
- $missing_id[] = $key + 1;
- }
+ $data = $this->readExcelToArray($file);
+ unset($data[0]);
+ array_pop($data);
+ $count = count($data);
- $emp_name = $value[2]; //employee name
- $emp_code = $value[1]; //employee code
- $date_of_exit = $value[7]; // date of releving
- $endorsement_id = $value[15] != null ? $value[15] : ''; //endorsement id
- $db = \Config\Database::connect();
+ $missing_id = [];
+ $empty_emp_tpa_uh_ids = [];
+ $totals = 0 ;
+ foreach ($data as $key => $value) {
- // Execute the query
- $query = $db->table('emp_endorsement')
- ->select('emp_endorsement.id')
- ->join('employee_polices', 'employee_polices.id = emp_endorsement.pk')
- ->join('employees', 'employees.emp_code = emp_endorsement.emp_code')
- ->where('employees.emp_code', $emp_code)
- ->where('employees.name', $emp_name)
- ->where('employees.client_id', $client_id)
- ->where('emp_endorsement.actions', 'd')
- ->where('employee_polices.client_policy_id', $client_policy_id)
- ->where('(emp_endorsement.endorsement_id IS NULL OR emp_endorsement.endorsement_id = "")')
- ->groupBy('emp_endorsement.group_key');
+ try {
- $result = $query->get()->getRowArray();
- if (isset($result['id']) && $result['id'] !== null) {
- $empty_emp_tpa_uh_ids[] = $result['id'];
- }
- } catch (\Exception $e) {
- // Handle the exception here
- return 0;
- }
- }
-
- $missing_id_count = count($missing_id);
- $empty_id_count = count($empty_emp_tpa_uh_ids);
-
-
- // if($missing_id_count != $count){
-
- // return 2;
- // }
-
- if($missing_id_count != 0 ){
-
- return 2;
- }
-
- // if($empty_emp_tpa_uh_ids != $count){
-
- // return 3;
- // }
-
- if( $empty_id_count == 0){
-
- return 3;
+ if ($value[15] === null) {
+ $missing_id[] = $key + 1;
}
- // dd($count, $missing_id_count, $empty_id_count, $data, $empty_emp_tpa_uh_ids);
+ $totals += $value[13];
- $is_moved = $file->move(WRITEPATH . 'uploads/import_excel');
- $filename = $file->getName();
+ $emp_name = $value[2]; //employee name
+ $emp_code = $value[1]; //employee code
+ $date_of_exit = $value[7]; // date of releving
+ $endorsement_id = $value[15] != null ? $value[15] : ''; //endorsement id
- $this->myLogger->logme('error','Deletion Import file name : {data}', ['data'=> $filename ]);
- $random_number_count = 4;
- $batch_code = generate_random_string($random_number_count);
- $this->myLogger->logme('error','Deletion Import BATCH CODE : {data}', ['data'=> $batch_code ]);
+ $db = \Config\Database::connect();
+
+ // Execute the query
+ $query = $db->table('emp_endorsement')
+ ->select('emp_endorsement.id')
+ ->join('employee_polices', 'employee_polices.id = emp_endorsement.pk')
+ ->join('employees', 'employees.emp_code = emp_endorsement.emp_code')
+ ->where('employees.emp_code', $emp_code)
+ ->where('employees.name', $emp_name)
+ ->where('employees.client_id', $client_id)
+ ->where('emp_endorsement.actions', 'd')
+ ->where('employee_polices.client_policy_id', $client_policy_id)
+ ->where('(emp_endorsement.endorsement_id IS NULL OR emp_endorsement.endorsement_id = "")')
+ ->groupBy('emp_endorsement.group_key');
+
+ $result = $query->get()->getRowArray();
+ if (isset($result['id']) && $result['id'] !== null) {
+ $empty_emp_tpa_uh_ids[] = $result['id'];
+ }
+ } catch (\Exception $e) {
+ // Handle the exception here
+ return 0;
+ }
+ }
+
+ $rounded_totals = round($totals, 2);
+ $missing_id_count = count($missing_id);
+ $empty_id_count = count($empty_emp_tpa_uh_ids);
+
+ // if($missing_id_count != $count){
+
+ // return 2;
+ // }
+
+ if ($missing_id_count != 0) {
+
+ return 2;
+ }
+
+ // if($empty_emp_tpa_uh_ids != $count){
+
+ // return 3;
+ // }
+
+ if ($empty_id_count == 0) {
+
+ return 3;
+ }
+
+ // dd($count, $missing_id_count, $empty_id_count, $data, $empty_emp_tpa_uh_ids);
+
+ $is_moved = $file->move(WRITEPATH . 'uploads/import_excel');
+ $filename = $file->getName();
+
+ $this->myLogger->logme('error', 'Deletion Import file name : {data}', ['data' => $filename]);
+ $random_number_count = 4;
+ $batch_code = generate_random_string($random_number_count);
+ $this->myLogger->logme('error', 'Deletion Import BATCH CODE : {data}', ['data' => $batch_code]);
- $import_data['batch_code'] = $batch_code;
- $import_data['created_by'] = get_session_userid();
- $import_data['file_name'] = $filename;
- $insert = $this->batchFileModel->insert($import_data);
- $batch_file_batch_code = $this->batchFileModel->where('id', $insert)->first();
+ $import_data['batch_code'] = $batch_code;
+ $import_data['created_by'] = get_session_userid();
+ $import_data['file_name'] = $filename;
+ $import_data['amount'] = $rounded_totals;
+ $insert = $this->batchFileModel->insert($import_data);
+ $batch_file_batch_code = $this->batchFileModel->where('id', $insert)->first();
- $batch_code_for_batch_list['batch_code'] = $batch_file_batch_code['batch_code'];
- $batch_code_for_batch_list['created_by'] = get_session_userid();
+ $batch_code_for_batch_list['batch_code'] = $batch_file_batch_code['batch_code'];
+ $batch_code_for_batch_list['created_by'] = get_session_userid();
- $file_name_with_path = WRITEPATH."/uploads/import_excel/".$batch_file_batch_code['file_name'];
+ $file_name_with_path = WRITEPATH . "/uploads/import_excel/" . $batch_file_batch_code['file_name'];
- if(!file_exists($file_name_with_path))
- {
- return 2;
+ if (!file_exists($file_name_with_path)) {
+ return 2;
+ }
+
+ $data = read_excel_file_to_array($file_name_with_path);
+ unset($data[0]);
+ array_pop($data);
+
+ $count = count($data);
+ $this->batchFileModel->where('id', $insert)->set('count', $count)->update();
+
+ $employeeIds = [];
+ foreach ($data as $key => $value) {
+
+ if (!empty($value) && isset($value[15])) {
+
+ $emp_name = $value[2]; //employee name
+ $emp_code = $value[1]; //employee code
+ $date_of_exit = $value[7]; // date of releving
+
+ // echo $emp_name .'-'. $emp_code .'-'. $date_of_exit; die;
+ $endorsement_id = $value[15] != null ? $value[15] : ''; //endorsement id
+
+ $val = $this->employeePolicyModel
+ ->select('employee_polices.id')
+ ->join('employees', 'employees.id = employee_polices.employee_id')
+ ->where('employee_polices.client_policy_id', $client_policy_id)
+ ->where('employees.client_id', $client_id)
+ ->where('employees.name', $emp_name)
+ ->where('employees.emp_code', $emp_code)
+ ->where('employee_polices.is_active', 1)
+ ->first();
+
+
+ if ($val !== null) {
+
+ $id = $val['id'];
+ $batch_code_for_batch_list['emp_policy_id'] = $id;
+ $this->batchListModel->insert($batch_code_for_batch_list);
+ array_push($employeeIds, $id);
}
- $data = read_excel_file_to_array($file_name_with_path);
- unset($data[0]);
- array_pop($data);
+ // $updateData = [
+ // 'emp_code' =>$emp_code,
+ // 'client_id' =>$client_id,
+ // 'client_policy_id' =>$client_policy_id,
+ // 'emp_name' =>$emp_name,
+ // 'endorsement_id' =>$endorsement_id,
+ // ];
- $count = count($data);
- $this->batchFileModel->where('id', $insert)->set('count', $count)->update();
+ // $this->employeePolicyModel->updateEndoresmentIdForDeletion($updateData);
- $employeeIds = [];
- foreach ($data as $key => $value) {
+ $deletionDataForEmployee = $this->empEndorsementModel
+ ->select('emp_endorsement.new_value, emp_endorsement.id as ee_id, employees.id')
+ ->join('employees', 'emp_endorsement.emp_code = employees.emp_code')
+ ->join('employee_polices', 'employee_polices.employee_id = employees.id')
+ ->where('emp_endorsement.emp_code', $emp_code)
+ ->where('employees.client_id', $client_id)
+ ->where('employee_polices.client_policy_id', $client_policy_id)
+ ->where('emp_endorsement.name', $emp_name)
+ ->where('emp_endorsement.field_name', 'emp_status')
+ ->first();
- if (!empty($value) && isset($value[15])) {
+ $deletionDataForEmployee['updated_by'] = get_session_userid();
+ $this->employeeModel->save($deletionDataForEmployee);
- $emp_name = $value[2]; //employee name
- $emp_code = $value[1]; //employee code
- $date_of_exit = $value[7]; // date of releving
+ $e_Data = [
+ 'endorsement_id' => $endorsement_id,
+ 'status' => 'complete',
+ ];
+ $group_key = $this->empEndorsementModel->select('group_key')->where('id', $deletionDataForEmployee['ee_id'])->first();
+ $this->empEndorsementModel->where('group_key', $group_key)->set($e_Data)->update();
- // echo $emp_name .'-'. $emp_code .'-'. $date_of_exit; die;
- $endorsement_id = $value[15] != null ? $value[15] : ''; //endorsement id
-
- $val = $this->employeePolicyModel
- ->select('employee_polices.id')
- ->join('employees', 'employees.id = employee_polices.employee_id')
- ->where('employee_polices.client_policy_id', $client_policy_id)
- ->where('employees.client_id', $client_id)
- ->where('employees.name', $emp_name)
- ->where('employees.emp_code', $emp_code)
- ->where('employee_polices.is_active', 1)
- ->first();
-
-
- if ($val !== null) {
-
- $id = $val['id'];
- $batch_code_for_batch_list['emp_policy_id'] = $id;
- $this->batchListModel->insert($batch_code_for_batch_list);
- array_push($employeeIds, $id);
- }
-
- // $updateData = [
- // 'emp_code' =>$emp_code,
- // 'client_id' =>$client_id,
- // 'client_policy_id' =>$client_policy_id,
- // 'emp_name' =>$emp_name,
- // 'endorsement_id' =>$endorsement_id,
- // ];
-
- // $this->employeePolicyModel->updateEndoresmentIdForDeletion($updateData);
-
- $deletionDataForEmployee = $this->empEndorsementModel
- ->select('emp_endorsement.new_value, emp_endorsement.id as ee_id, employees.id')
- ->join('employees', 'emp_endorsement.emp_code = employees.emp_code')
- ->join('employee_polices', 'employee_polices.employee_id = employees.id')
- ->where('emp_endorsement.emp_code', $emp_code)
- ->where('employees.client_id', $client_id)
- ->where('employee_polices.client_policy_id', $client_policy_id)
- ->where('emp_endorsement.name', $emp_name)
- ->where('emp_endorsement.field_name', 'emp_status')
- ->first();
-
- $deletionDataForEmployee['updated_by'] = get_session_userid();
- $this->employeeModel->save($deletionDataForEmployee);
-
- $e_Data = [
- 'endorsement_id'=> $endorsement_id,
- 'status'=> 'complete',
- ];
- $group_key = $this->empEndorsementModel->select('group_key')->where('id', $deletionDataForEmployee['ee_id'])->first();
- $this->empEndorsementModel->where('group_key', $group_key)->set($e_Data)->update();
-
- $fetchData = [
- 'emp_code'=> $emp_code,
- 'client_policy_id'=> $client_policy_id,
- 'emp_name'=> $emp_name,
- ];
-
- $deletionDataForEmployeePolicy = $this->employeePolicyModel->fetchEmpEndorsementData($fetchData);
- $deletionDataForEmployeePolicy['updated_by'] = get_session_userid();
- $this->employeePolicyModel->save($deletionDataForEmployeePolicy);
-
- // $query = $this->employeePolicyModel->getLastQuery();
- // echo $query . "
";
-
- }else{
-
- return 0;
- }
-
- }
-
- $policy_name = $this->getPolicyNameUsingClientPolicyId($client_policy_id);
- $depositeData = [
- 'employeeIds'=>$employeeIds,
- 'client_id'=>$client_id,
- 'client_policy_id'=>$client_policy_id,
- 'count'=>$count,
- 'event'=>$import_data['event_type'],
- 'policy_name'=>$policy_name['policy_name'],
+ $fetchData = [
+ 'emp_code' => $emp_code,
+ 'client_policy_id' => $client_policy_id,
+ 'emp_name' => $emp_name,
];
- $this->cashDepositCalculationForDeletion($depositeData);
- return 1;
+ $deletionDataForEmployeePolicy = $this->employeePolicyModel->fetchEmpEndorsementData($fetchData);
+ $deletionDataForEmployeePolicy['updated_by'] = get_session_userid();
+ $this->employeePolicyModel->save($deletionDataForEmployeePolicy);
+ // $query = $this->employeePolicyModel->getLastQuery();
+ // echo $query . "
";
+ } else {
+
+ return 0;
+ }
}
+ $policy_name = $this->getPolicyNameUsingClientPolicyId($client_policy_id);
+ $depositeData = [
+ 'employeeIds' => $employeeIds,
+ 'client_id' => $client_id,
+ 'client_policy_id' => $client_policy_id,
+ 'count' => $count,
+ 'event' => $import_data['event_type'],
+ 'policy_name' => $policy_name['policy_name'],
+ ];
+
+ $this->cashDepositCalculationForDeletion($depositeData);
+ return 1;
+ }
+
/**
@@ -1175,88 +1186,86 @@ class EmpDataServiceController extends BaseController
* @return bool Returns true if the operation is successful, otherwise returns 0.
*/
- public function cashDepositCalculationForInception($arrayData)
- {
- if (!empty($arrayData)) {
-
- $amount = $this->employeePolicyModel->query("
+ public function cashDepositCalculationForInception($arrayData)
+ {
+ if (!empty($arrayData)) {
+
+ $amount = $this->employeePolicyModel->query("
SELECT SUM(rata_premimum + gst) AS total_sum
FROM employee_polices
WHERE id IN (" . implode(',', $arrayData['employeeIds']) . ")
")->getRow();
-
- $insurer_id = $this->clientPolicyModel->where('id', $arrayData['client_policy_id'])->first();
- $description = 'The following amount of Rs. ' . $amount->total_sum . '/- has been debited for the ' . $arrayData['count'] . ' employees at ' . remove_underscore_capitalize_first_letter($arrayData['event']) . ' to ' . remove_underscore_capitalize_first_letter($arrayData['policy_name']) . '.';
- $data = [
- 'amount' => $amount->total_sum,
- 'sub_type_id' => 4,
- 'client_id' => $arrayData['client_id'],
- 'insurer_id' => $insurer_id['insurer_id'],
- 'description' => $description,
- 'transaction_type' => 'Debit',
- 'updated_by' => get_session_userid(),
- 'is_active' => 1,
- ];
- $response = DepositHelper::saveDeposit($data, get_session_userid());
- return true;
- // print_r($response);
- // $query = $this->employeePolicyModel->getLastQuery();
- // echo $query . "
";
+ $insurer_id = $this->clientPolicyModel->where('id', $arrayData['client_policy_id'])->first();
+ $description = 'The following amount of Rs. ' . $amount->total_sum . '/- has been debited for the ' . $arrayData['count'] . ' employees at ' . remove_underscore_capitalize_first_letter($arrayData['event']) . ' to ' . remove_underscore_capitalize_first_letter($arrayData['policy_name']) . '.';
- } else {
- return 0;
- }
+ $data = [
+ 'amount' => $amount->total_sum,
+ 'sub_type_id' => 4,
+ 'client_id' => $arrayData['client_id'],
+ 'insurer_id' => $insurer_id['insurer_id'],
+ 'description' => $description,
+ 'transaction_type' => 'Debit',
+ 'updated_by' => get_session_userid(),
+ 'is_active' => 1,
+ ];
+ $response = DepositHelper::saveDeposit($data, get_session_userid());
+ return true;
+ // print_r($response);
+ // $query = $this->employeePolicyModel->getLastQuery();
+ // echo $query . "
";
-
+ } else {
+ return 0;
}
+ }
- public function cashDepositCalculationForSIEnhancement($arrayData)
- {
- if (!empty($arrayData)) {
-
- $amount = $this->employeePolicyModel->query("
+ public function cashDepositCalculationForSIEnhancement($arrayData)
+ {
+ if (!empty($arrayData)) {
+
+ $amount = $this->employeePolicyModel->query("
SELECT
SUM(ROUND((employee_polices.premium * DATEDIFF(employee_polices.policy_end_date, employee_polices.si_enhancement_date)) / 365, 2) +
ROUND(((employee_polices.premium * DATEDIFF(employee_polices.policy_end_date, employee_polices.si_enhancement_date)) / 365) * 0.18, 2)) AS total_sum
FROM employee_polices
WHERE id IN (" . implode(',', $arrayData['employeeIds']) . ")
")->getRow();
- $insurer_id = $this->clientPolicyModel->where('id', $arrayData['client_policy_id'])->first();
- $description = 'The following amount of ' . $amount->total_sum . ' has been credited for the ' . $arrayData['count'] . ' employees at ' . remove_underscore_capitalize_first_letter($arrayData['event']) . ' to ' . remove_underscore_capitalize_first_letter($arrayData['policy_name']) . '.';
+ $insurer_id = $this->clientPolicyModel->where('id', $arrayData['client_policy_id'])->first();
+ $description = 'The following amount of ' . $amount->total_sum . ' has been credited for the ' . $arrayData['count'] . ' employees at ' . remove_underscore_capitalize_first_letter($arrayData['event']) . ' to ' . remove_underscore_capitalize_first_letter($arrayData['policy_name']) . '.';
- $data = [
+ $data = [
- 'amount' => $amount->total_sum,
- 'sub_type_id' => 4,
- 'client_id' => $arrayData['client_id'],
- 'insurer_id' => $insurer_id['insurer_id'],
- 'description' => $description,
- 'transaction_type' => 'Debit',
- 'updated_by' => get_session_userid(),
- 'is_active' => 1,
- ];
- $response = DepositHelper::saveDeposit($data, get_session_userid());
- return true;
- // print_r($response);
- // $query = $this->employeePolicyModel->getLastQuery();
- // echo $query . "
";
+ 'amount' => $amount->total_sum,
+ 'sub_type_id' => 4,
+ 'client_id' => $arrayData['client_id'],
+ 'insurer_id' => $insurer_id['insurer_id'],
+ 'description' => $description,
+ 'transaction_type' => 'Debit',
+ 'updated_by' => get_session_userid(),
+ 'is_active' => 1,
+ ];
+ $response = DepositHelper::saveDeposit($data, get_session_userid());
+ return true;
+ // print_r($response);
+ // $query = $this->employeePolicyModel->getLastQuery();
+ // echo $query . "
";
- } else {
- return 0;
- }
+ } else {
+ return 0;
}
+ }
- public function cashDepositCalculationForDeletion($arrayData)
- {
- // print_r($arrayData);
- if (!empty($arrayData)) {
-
- // echo '';
- // print_r($arrayData); die;
- $amount = $this->employeePolicyModel->query("
+ public function cashDepositCalculationForDeletion($arrayData)
+ {
+ // print_r($arrayData);
+ if (!empty($arrayData)) {
+
+ // echo '';
+ // print_r($arrayData); die;
+ $amount = $this->employeePolicyModel->query("
SELECT
SUM(ROUND((employee_polices.premium * DATEDIFF(employee_polices.policy_end_date, employee_polices.date_of_exit)) / 365, 2) +
ROUND(((employee_polices.premium * DATEDIFF(employee_polices.policy_end_date, employee_polices.date_of_exit)) / 365) * 0.18, 2)) AS total_sum
@@ -1264,203 +1273,199 @@ class EmpDataServiceController extends BaseController
WHERE id IN (" . implode(',', $arrayData['employeeIds']) . ")
")->getRow();
- $insurer_id = $this->clientPolicyModel->where('id', $arrayData['client_policy_id'])->first();
- $description = 'The following amount of ' . $amount->total_sum . ' has been credited for the ' . $arrayData['count'] . ' employees at ' . remove_underscore_capitalize_first_letter($arrayData['event']) . ' to ' . remove_underscore_capitalize_first_letter($arrayData['policy_name']) . '.';
+ $insurer_id = $this->clientPolicyModel->where('id', $arrayData['client_policy_id'])->first();
+ $description = 'The following amount of ' . $amount->total_sum . ' has been credited for the ' . $arrayData['count'] . ' employees at ' . remove_underscore_capitalize_first_letter($arrayData['event']) . ' to ' . remove_underscore_capitalize_first_letter($arrayData['policy_name']) . '.';
- $data = [
+ $data = [
- 'amount' => $amount->total_sum,
- 'sub_type_id' => 3,
- 'client_id' => $arrayData['client_id'],
- 'insurer_id' => $insurer_id['insurer_id'],
- 'description' => $description,
- 'transaction_type' => 'Credit',
- 'updated_by' => get_session_userid(),
- 'is_active' => 1,
- ];
- $response = DepositHelper::saveDeposit($data, get_session_userid());
- return true;
- // print_r($response);
- // $query = $this->employeePolicyModel->getLastQuery();
- // echo $query . "
";
-
- } else {
- return 0;
- }
+ 'amount' => $amount->total_sum,
+ 'sub_type_id' => 3,
+ 'client_id' => $arrayData['client_id'],
+ 'insurer_id' => $insurer_id['insurer_id'],
+ 'description' => $description,
+ 'transaction_type' => 'Credit',
+ 'updated_by' => get_session_userid(),
+ 'is_active' => 1,
+ ];
+ $response = DepositHelper::saveDeposit($data, get_session_userid());
+ return true;
+ // print_r($response);
+ // $query = $this->employeePolicyModel->getLastQuery();
+ // echo $query . "
";
+ } else {
+ return 0;
}
+ }
- /**
- * Below function retrieves the policy name associated with a given client policy ID.
- *
- * @param int $client_policy_id The ID of the client policy.
- * @return mixed Returns the policy name if found, otherwise null.
- */
+ /**
+ * Below function retrieves the policy name associated with a given client policy ID.
+ *
+ * @param int $client_policy_id The ID of the client policy.
+ * @return mixed Returns the policy name if found, otherwise null.
+ */
- public function getPolicyNameUsingClientPolicyId($client_policy_id)
- {
- return $this->clientPolicyModel->select('policies.name as policy_name')
+ public function getPolicyNameUsingClientPolicyId($client_policy_id)
+ {
+ return $this->clientPolicyModel->select('policies.name as policy_name')
->join('policies', 'policies.id = client_policy.policy_id')
->where('client_policy.id', $client_policy_id)
->first();
+ }
+
+
+
+
+ /**
+ * Below function converts row data into column data format for SI enhancement.
+ *
+ * This function takes an array of data containing information about SI enhancement
+ * and calculates additional fields such as pro rata premium, GST, and total.
+ *
+ * @param array $data The array of data containing SI enhancement information.
+ * @return array Returns the converted data in column format.
+ */
+ public function convertRowTColumnForSIEnhancement($data)
+ {
+
+ $result = array();
+
+ foreach ($data as $obj) {
+
+ $pro_rata_premium = round(($obj->difference_premium * $obj->no_of_days / 365), 2);
+ $gst = round(($pro_rata_premium * 18 / 100), 2);
+ $total = round(($pro_rata_premium + $gst), 2);
+
+ $old_total = round(($obj->old_rata + $obj->old_gst), 2);
+
+
+ $result[] = array(
+ "field_name" => 'Basic Cover SI',
+ "old_value" => $obj->old_basic_cover_si,
+ "new_value" => $obj->new_basic_cover_si
+ );
+
+ $result[] = array(
+ "field_name" => 'Premium',
+ "old_value" => $obj->old_si_premium,
+ "new_value" => $obj->new_si_premium
+ );
+
+ $result[] = array(
+ "field_name" => 'SI Enhancement Date',
+ "old_value" => change_date_format($obj->old_date, 'Y-m-d', 'd-M-Y'),
+ "new_value" => change_date_format($obj->date_of_coverage, 'Y-m-d', 'd-M-Y')
+ );
+
+ $result[] = array(
+ "field_name" => 'Difference Premium',
+ "old_value" => ' --- ',
+ "new_value" => $obj->difference_premium
+ );
+
+ $result[] = array(
+ "field_name" => 'No of Days',
+ "old_value" => $obj->old_days,
+ "new_value" => $obj->no_of_days
+ );
+
+ $result[] = array(
+ "field_name" => 'Pro Rata Premium',
+ "old_value" => $obj->old_rata,
+ "new_value" => $pro_rata_premium
+ );
+
+ $result[] = array(
+ "field_name" => 'GST(18%)',
+ "old_value" => $obj->old_gst,
+ "new_value" => $gst
+ );
+
+ $result[] = array(
+ "field_name" => 'Total',
+ "old_value" => $old_total,
+ "new_value" => $total
+ );
}
+ return $result;
+ }
- /**
- * Below function converts row data into column data format for SI enhancement.
- *
- * This function takes an array of data containing information about SI enhancement
- * and calculates additional fields such as pro rata premium, GST, and total.
- *
- * @param array $data The array of data containing SI enhancement information.
- * @return array Returns the converted data in column format.
- */
- public function convertRowTColumnForSIEnhancement($data)
- {
+ /**
+ * Below function converts row data into column data format for deletion records.
+ *
+ * This function takes an array of data containing information about deletion records
+ * and converts it into a column format. It also calculates additional fields such as
+ * period of non-coverage, premium for non-coverage period, GST, total amount, and
+ * claim status based on the exist_reason field.
+ *
+ * @param array $data The array of data containing deletion records information.
+ * @return array Returns the converted data in column format.
+ */
+ public function convertRowTColumnForDeletion($data)
+ {
- $result = array();
+ $result = array();
- foreach ($data as $obj) {
-
- $pro_rata_premium = round(($obj->difference_premium * $obj->no_of_days / 365), 2);
- $gst = round(($pro_rata_premium * 18 / 100), 2);
- $total = round(($pro_rata_premium + $gst), 2);
+ foreach ($data as $obj) {
- $old_total = round(($obj->old_rata + $obj->old_gst), 2);
+ $old_total = round(($obj->old_rata + $obj->old_gst), 2);
+ $result[] = array(
+ "field_name" => 'Policy Period',
+ "data" => change_date_format($obj->start_date, 'Y-m-d', 'd-M-Y') . ' -
' . change_date_format($obj->end_date, 'Y-m-d', 'd-M-Y'),
+ );
+
+ $result[] = array(
+ "field_name" => 'Exit on',
+ "data" => change_date_format($obj->date_of_leaving, 'Y-m-d', 'd-M-Y'),
+ );
+
+ $result[] = array(
+ "field_name" => 'Reason',
+ "data" => $obj->exist_reason,
+ );
+
+
+
+ if ($obj->exist_reason != 'death') {
$result[] = array(
- "field_name" => 'Basic Cover SI',
- "old_value" => $obj->old_basic_cover_si,
- "new_value" => $obj->new_basic_cover_si
+ "field_name" => 'Period of non coverage',
+ "data" => $obj->no_of_days
);
-
+
$result[] = array(
- "field_name" => 'Premium',
- "old_value" => $obj->old_si_premium,
- "new_value" => $obj->new_si_premium
+ "field_name" => 'Premium for non coverage period',
+ "data" => $obj->pro_rata_premium
);
-
- $result[] = array(
- "field_name" => 'SI Enhancement Date',
- "old_value" => change_date_format($obj->old_date, 'Y-m-d', 'd-M-Y'),
- "new_value" => change_date_format($obj->date_of_coverage, 'Y-m-d', 'd-M-Y')
- );
-
- $result[] = array(
- "field_name" => 'Difference Premium',
- "old_value" => ' --- ',
- "new_value" => $obj->difference_premium
- );
-
- $result[] = array(
- "field_name" => 'No of Days',
- "old_value" => $obj->old_days,
- "new_value" => $obj->no_of_days
- );
-
- $result[] = array(
- "field_name" => 'Pro Rata Premium',
- "old_value" => $obj->old_rata,
- "new_value" => $pro_rata_premium
- );
-
+
$result[] = array(
"field_name" => 'GST(18%)',
- "old_value" => $obj->old_gst,
- "new_value" => $gst
+ "data" => $obj->gst
);
-
- $result[] = array(
- "field_name" => 'Total',
- "old_value" => $old_total,
- "new_value" => $total
- );
-
- }
- return $result;
+ $result[] = array(
+ "field_name" => 'Total Amount',
+ "data" => $obj->total
+ );
+
+ $result[] = array(
+ "field_name" => 'Claim',
+ "data" => '---',
+ );
+ }
}
+ return $result;
+ }
- /**
- * Below function converts row data into column data format for deletion records.
- *
- * This function takes an array of data containing information about deletion records
- * and converts it into a column format. It also calculates additional fields such as
- * period of non-coverage, premium for non-coverage period, GST, total amount, and
- * claim status based on the exist_reason field.
- *
- * @param array $data The array of data containing deletion records information.
- * @return array Returns the converted data in column format.
- */
- public function convertRowTColumnForDeletion($data)
- {
-
- $result = array();
-
- foreach ($data as $obj) {
-
- $old_total = round(($obj->old_rata + $obj->old_gst), 2);
-
- $result[] = array(
- "field_name" => 'Policy Period',
- "data" => change_date_format($obj->start_date, 'Y-m-d', 'd-M-Y') . ' -
' . change_date_format($obj->end_date, 'Y-m-d', 'd-M-Y'),
- );
-
- $result[] = array(
- "field_name" => 'Exit on',
- "data" => change_date_format($obj->date_of_leaving, 'Y-m-d', 'd-M-Y'),
- );
-
- $result[] = array(
- "field_name" => 'Reason',
- "data" => $obj->exist_reason,
- );
-
-
-
- if($obj->exist_reason != 'death'){
-
- $result[] = array(
- "field_name" => 'Period of non coverage',
- "data" => $obj->no_of_days
- );
-
- $result[] = array(
- "field_name" => 'Premium for non coverage period',
- "data" => $obj->pro_rata_premium
- );
-
- $result[] = array(
- "field_name" => 'GST(18%)',
- "data" => $obj->gst
- );
-
- $result[] = array(
- "field_name" => 'Total Amount',
- "data" => $obj->total
- );
-
- $result[] = array(
- "field_name" => 'Claim',
- "data" => '---',
- );
-
- }
-
- }
-
- return $result;
- }
-
-
// -----------------------------------------------------------------------------------
@@ -1469,30 +1474,29 @@ class EmpDataServiceController extends BaseController
{
if ($file->isValid() && !$file->hasMoved()) {
- $file = $file;
+ $file = $file;
- $reader = new Xlsx();
- $spreadsheet = $reader->load($file->getPathname());
+ $reader = new Xlsx();
+ $spreadsheet = $reader->load($file->getPathname());
- // Get the active sheet
- $sheet = $spreadsheet->getActiveSheet();
+ // Get the active sheet
+ $sheet = $spreadsheet->getActiveSheet();
- // Iterate through rows to read data
- $data = [];
- foreach ($sheet->getRowIterator() as $row) {
- $rowData = [];
- foreach ($row->getCellIterator() as $cell) {
- $rowData[] = $cell->getValue();
- }
- $data[] = $rowData;
- }
-
- return $data;
+ // Iterate through rows to read data
+ $data = [];
+ foreach ($sheet->getRowIterator() as $row) {
+ $rowData = [];
+ foreach ($row->getCellIterator() as $cell) {
+ $rowData[] = $cell->getValue();
+ }
+ $data[] = $rowData;
+ }
- } else {
+ return $data;
+ } else {
- return false;
- }
+ return false;
+ }
}
@@ -1506,15 +1510,15 @@ class EmpDataServiceController extends BaseController
$insert = $this->batchFileModel->insert($data);
$batch_file_batch_code = $this->batchFileModel->where('id', $insert)->first();
- if($insert){
- foreach($ids as $id){
+ if ($insert) {
+ foreach ($ids as $id) {
$batch_list_data['batch_code'] = $batch_file_batch_code['batch_code'];
$batch_list_data['emp_policy_id'] = $id;
$batch_list_data['created_by'] = get_session_userid();
$this->batchListModel->insert($batch_list_data);
}
}
-
+
return true;
}
}
diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php
index d07567c0..6a3ba065 100644
--- a/app/Controllers/EmployeeController.php
+++ b/app/Controllers/EmployeeController.php
@@ -26,6 +26,8 @@ use App\Controllers\EmpDataServiceController;
use CodeIgniter\API\ResponseTrait;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
+use PhpOffice\PhpSpreadsheet\IOFactory;
+use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
class EmployeeController extends AdminController
{
@@ -77,6 +79,7 @@ class EmployeeController extends AdminController
{
//echo $this->request->isAJAX();die();
$result = $this->clientModel->clientsWithPolicies();
+
// print_r($result);die();
if(!count($result))
{
@@ -247,6 +250,7 @@ class EmployeeController extends AdminController
// Render views and capture output
$result = $empServiceController->getExcelErrorData($file_id);
+ $result['file_id'] = $file_id;
// echo '';
// print_r($result); die;
@@ -557,37 +561,53 @@ class EmployeeController extends AdminController
return $this->respond(['dataStatus' => false, 'code' => 404, 'message' => 'no data found'], 200);
}
}
-
-
// @param int $client_policy_id
// this funciton initiate Inception/adition/DA of employees data only form enrollment app when passing
// client_policy_id pull draft and enrolled status employees and proceed to calculatin and make entry in DB
public function initiateManualEmployeesOnboardProcess($client_policy_id)
- {
- $empServiceController = new EmployeeServiceController();
- $res = $empServiceController->employeesOnboardPreprocess(['client_policy_id' => $client_policy_id]);
- dd($res);
+ {
+ $client_data = $this->clientPolicyModel->select('clients.client_name as client_name, policies.name as policy_name')
+ ->join('clients', 'clients.id = client_policy.client_id')
+ ->join('policies', 'policies.id = client_policy.policy_id')
+ ->where('client_policy.id', $client_policy_id)
+ ->first();
+
+ $empServiceController = new EmployeeServiceController();
+ $res = $empServiceController->employeesOnboardPreprocess(['client_policy_id' => $client_policy_id]);
+ // dd($res);
+
+ $count = count($res);
+ $message = $count . ' Employees are Initiate Onboard Process againts Client '. $client_data['client_name'] . ' and the Policy is ' . $client_data['policy_name'] ;
+ session()->setFlashdata('success1', $message);
+ return redirect()->to(base_url('/employee/upload'));
}
- public function downloadFileList($fileName = null)
+ public function downloadFileList($file_id = null)
{
// $actionType = $this->request->getGet();
+ $file_data = $this->fileModel->where('id', $file_id)->first();
+ $fileName = $file_data['file_name'];
+
+ $error_data = json_decode($file_data['reason']);
+
+ $filePath = WRITEPATH . '/uploads/excel/' . $fileName;
+
try {
- $filePath = WRITEPATH . '/uploads/excel/' . $fileName;
-
+
// Check if the file exists
if (file_exists($filePath)) {
// Set the appropriate MIME type
$mimeType = mime_content_type($filePath);
-
+
// Send the file to the client for download
return $this->response->download($filePath, null, $mimeType);
} else {
- throw new \CodeIgniter\Exceptions\PageNotFoundException();
+ $data['message'] = 'The Physical File Not Found';
+ echo view('errors/404', $data);
}
} catch (\Exception $e) {
// Handle any exceptions
@@ -596,7 +616,6 @@ class EmployeeController extends AdminController
// You can return an error response here
echo $errorMessage;
}
-
}
@@ -641,6 +660,7 @@ class EmployeeController extends AdminController
$emp_data['tbody'] = $excel_data;
$html = view('view_file_upload_emp_list', $emp_data);
+
} else {
$html = 'No Data Found';
@@ -657,5 +677,140 @@ class EmployeeController extends AdminController
}
}
+ public function getEmpCount($id = null){
+
+ $data = $this->employeePolicyModel->select('employee_polices.id')
+ ->where('employee_polices.is_active', 1)
+ ->where('employee_polices.client_policy_id', $id)
+ ->findAll();
+
+ $emp_count = count($data);
+
+ if($data){
+ return $this->respond(['dataStatus' => true, 'code' => 200, 'emp_count' => $emp_count], 200);
+
+ }else{
+
+ return $this->respond(['dataStatus' => false, 'code' => 404], 404);
+
+ }
+
+
+ }
+
+ public function downloadFullExcelErrorFile($file_id = 137, $rowIndex = 1, $colIndex = 1)
+ {
+ // Get file data from the database
+ $file_data = $this->fileModel->find($file_id);
+
+ $error = json_decode($file_data['reason']);
+ // echo '';
+ // print_r($error); die;
+ // dd($error);
+
+ // Check if the file exists
+ if (!$file_data) {
+ $error_message = "File not found";
+ $this->myLogger->logme('error', $error_message . ' for file id ' . $file_id);
+ return $error_message;
+ }
+
+ $fileName = $file_data['file_name'];
+ $filePath = WRITEPATH . '/uploads/excel/' . $fileName;
+
+ // Check if the file exists
+ if (!file_exists($filePath)) {
+ $error_message = "File not found";
+ $this->myLogger->logme('error', $error_message . ' for file id ' . $file_id);
+ return $error_message;
+ }
+
+ // Load the Excel file
+ $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($filePath);
+ $sheet = $spreadsheet->getActiveSheet();
+
+ // echo '';
+
+ foreach ($error->error_data as $index => $error_data) {
+
+ $rowIndex = $index+1;
+
+ if( $error->error_type == 1 ){
+
+ foreach ($error_data as $key => $value) {
+
+ $colIndex = $value->col_idx+1;
+
+ $originalValue = $sheet->getCell([$colIndex, $rowIndex])->getValue();
+
+ $newValue = implode(', ',$value->error);
+ $val = $originalValue . ' ( ' . $newValue . ' )';
+ $sheet->setCellValue([$colIndex, $rowIndex], $val);
+
+ $style = [
+ 'fill' => [
+ 'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
+ 'startColor' => ['rgb' => 'ffad99'] // Red color
+ ]
+ ];
+
+ $sheet->getStyle([$colIndex, $rowIndex])->applyFromArray($style);
+
+ }
+ }else if( $error->error_type == 2){
+
+
+ foreach ($error_data as $key => $value) {
+
+
+ $originalValue = $sheet->getCell([1, $rowIndex])->getValue();
+
+ $newValue = implode(', ',$value->error);
+ $val = $originalValue . ' ( ' . $newValue . ' )';
+ $sheet->setCellValue([$colIndex, $rowIndex], $val);
+
+ $style = [
+ 'fill' => [
+ 'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
+ 'startColor' => ['rgb' => 'ffad99'] // Red color
+ ]
+ ];
+ $sheet->getStyle([$colIndex, $rowIndex])->applyFromArray($style);
+
+ }
+
+ }
+
+ }
+
+
+
+ // Create a new filename for the modified Excel file
+ $newFileName = 'modified_' . $fileName;
+
+ // Save the modified Excel file to a new location
+ $newFilePath = WRITEPATH . '/uploads/excel/' . $newFileName;
+ $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
+ $writer->save($newFilePath);
+
+ // Set headers to force download
+ $response = service('response');
+ $response->setHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
+ $response->setHeader('Content-Disposition', 'attachment;filename="' . $newFileName . '"');
+ $response->setHeader('Cache-Control', 'max-age=0');
+ $response->setHeader('Content-Length', filesize($newFilePath));
+ $response->setBody(file_get_contents($newFilePath));
+
+ // Delete the temporary file
+ unlink($newFilePath);
+
+ // Return the response
+ return $response;
+ }
+
+
+
+
+
}
\ No newline at end of file
diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php
index fcb784fa..d1f7fbde 100644
--- a/app/Controllers/EmployeeRestController.php
+++ b/app/Controllers/EmployeeRestController.php
@@ -1343,6 +1343,7 @@ public function calculatePremium($clientPolicyId = null , $empCode = null)//fami
$slab_details = $this->policesModel->getPolicySlabRatesForEmpOnboard($client_policy_id,$client_id);
$existing_famility_details = $this->employeeModel->getEmpFamilybyEmpCode(client_id: $client_id,client_policy_id: $client_policy_id,emp_code: $emp_code,emp_status:['draft','enrolled'],policy_status:['draft','enrolled']);
+
$file = ['id' => null,'client_id' => $client_id,'policy_id' => $client_policy_id,'action' => 'inception'];
// dd($this->employeeModel->getLastQuery());
// dd($existing_famility_details);die();
diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php
index 6007b717..581d659e 100644
--- a/app/Controllers/EmployeeServiceController.php
+++ b/app/Controllers/EmployeeServiceController.php
@@ -568,7 +568,8 @@ class EmployeeServiceController extends AdminController
$existing_famility_details = $this->employeeModel->getEmpFamilybyEmpCode(client_id: $client_id,client_policy_id: $client_policy_id,emp_status: ['enrolled','draft'],policy_status:['enrolled','draft']);
- $file = ['id' => null,'client_id' => $client_id,'policy_id' => $client_policy_id,'action' => 'inception'];
+ // $file = ['id' => null,'client_id' => $client_id,'policy_id' => $client_policy_id,'action' => 'inception'];
+ $file = ['id' => null,'client_id' => $client_id,'policy_id' => $client_policy_id,'action' => 'inception','created_by' => get_session_userid()];
// dd($this->employeeModel->getLastQuery());
// Kint::dump($existing_famility_details);die();
$employee_data_group_by_family = data_group_by_family($existing_famility_details,$data_source = 'db');
diff --git a/app/Models/BatchFileModel.php b/app/Models/BatchFileModel.php
index 119a73aa..5976d6a2 100644
--- a/app/Models/BatchFileModel.php
+++ b/app/Models/BatchFileModel.php
@@ -21,6 +21,7 @@ class BatchFileModel extends Model
"created_by",
"updated_by",
"is_active",
+ "amount",
];
// Callbacks
diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php
index 084247bf..17f1c3f2 100644
--- a/app/Models/EmployeePolicyModel.php
+++ b/app/Models/EmployeePolicyModel.php
@@ -659,6 +659,7 @@ class EmployeePolicyModel extends Model
->where('employee_polices.client_policy_id',$policy_id);
$result->whereIn('employee_polices.status', ['draft', 'enrolled']);
+ $result->whereIn('emp.emp_status', ['draft', 'enrolled']);
$result = $result->findAll();
return ($result);
}
diff --git a/app/Views/batch_list.php b/app/Views/batch_list.php
index 3f252701..dea70840 100644
--- a/app/Views/batch_list.php
+++ b/app/Views/batch_list.php
@@ -26,6 +26,7 @@
Insurer/TPA
Action
Count
+ Amount
@@ -46,6 +47,7 @@
+
diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php
index d211a9cf..908612fe 100644
--- a/app/Views/client_policy.php
+++ b/app/Views/client_policy.php
@@ -424,10 +424,26 @@ $(document).ready(function() {
// console.log(res)
var OptionsHTML = '';
OptionsHTML += '';
+ $policy_type_value = $('#policy_type').val();
$.each(res.data, function(index, item) {
- OptionsHTML += '';
+
+ if ($policy_type_value == 3) {
+ if (item.policy_type_id == 5 || item.policy_type_id == 3) {
+ OptionsHTML += '';
+ }
+ }else if($policy_type_value == 2){
+ if (item.policy_type_id == 4 ) {
+ OptionsHTML += '';
+ }
+ }else{
+ OptionsHTML += '';
+ }
});
$('#policy').html(OptionsHTML);
@@ -989,6 +1005,10 @@ $('#policy_type').change(function() {
$('#end_date').val('');
$('#base_policy').val('0');
+ if($(this).val() == 3){
+ toastr.warning('Please Change the Policy Terms after Submit the Policy!', 'warning');
+ }
+
if ($(this).val() != '1' && $(this).val() != '0') {
$('#base_policy_id').show();
@@ -1011,7 +1031,6 @@ $('#policy_type').change(function() {
$('#base_policy_id').hide();
$('#base_policy').prop('required', false);
}
-
})
@@ -1074,8 +1093,8 @@ $(document).ready(function(){
const queryString = objectToQueryString(queryParams);
// var uri = '= base_url('util/fetch-policy-for-policy-type')?>?' + queryString
var uri = '= base_url('client/policy/list/')?>' + client_policy_id
- console.log('uri', uri)
- console.log('queryString', queryString)
+ // console.log('uri', uri)
+ // console.log('queryString', queryString)
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
@@ -1102,11 +1121,19 @@ $(document).ready(function(){
var policeOptionHTML = '';
+ $policy_type_value = $('#policy_type').val();
$.each(res.policy, function(index, item) {
- console.log(item)
- policeOptionHTML += '';
+ // }
+ // }
+
});
$('#policy').html(policeOptionHTML);
diff --git a/app/Views/employee_upload.php b/app/Views/employee_upload.php
index c985b877..e6fccef7 100644
--- a/app/Views/employee_upload.php
+++ b/app/Views/employee_upload.php
@@ -1,3 +1,10 @@
+
@@ -124,7 +131,7 @@
@@ -152,6 +159,10 @@
$('#file_upload').hide();
$(document).ready(function() {
+
+ has('success1')): ?>
+ toastr.success('= session()->getFlashdata('success1') ?>', 'success');
+
// Initialize select2
$("#client_id").select2();
$("#policy_id").select2();
@@ -478,7 +489,8 @@ $(document).ready(function() {
$('#client_id').on('change', function() {
var selectedClient = $(this).val();
- console.log(selectedClient);
+
+ console.log('selectedClient', selectedClient);
// $('#selectedOptionInfo').text('Selected option: ' + selectedOption);
// Check if the selected option exists in apiData
@@ -487,6 +499,7 @@ $(document).ready(function() {
});
console.log(foundPolicies.policies);
appendPolicies(foundPolicies.policies);
+
});
});
@@ -573,7 +586,15 @@ document.getElementById('toggleIcon1').addEventListener('click', function() {
icon.classList.toggle('mdi-chevron-up');
});
-$('#fetch_enrolled_data').click(function() {
+
+$('#fetch_enrolled_data').click(function()
+{
+
+ var policy_id = $('#policy_id').val();
+ var uri = '= base_url('util/init-Emp-onboard/') ?>' + policy_id;
+ console.log(policy_id);
+ console.log(uri);
+ $('#fetch_btn').attr('href', uri);
$('#emp_data').empty();
var client_id = $('#client_id').val();
@@ -637,5 +658,76 @@ $('#fetch_enrolled_data').click(function() {
});
})
+
+$(document).ready(function() {
+
+ $('#policy_id').change(function(){
+
+ var selectedpolicy = $(this).val();
+ console.log('selectedpolicy',selectedpolicy)
+
+ var apiURL = '' + 'util/fetch-emp-count/' + selectedpolicy;
+ console.log(apiURL);
+ $.ajax({
+ url: apiURL,
+ method: 'GET',
+ headers: {
+ "Content-Type": "application/json",
+ "X-Requested-With": "XMLHttpRequest"
+ },
+ success: function(response) {
+
+ console.log('responce data emp_count', response);
+
+ if (response.code === 200 && response.dataStatus === true && response.data !== "") {
+ try {
+ console.log(response.emp_count.length)
+ if(response.emp_count > 0){
+
+ var select = document.getElementById("upload-action-type");
+ for (var i = 0; i < select.options.length; i++) {
+ if (select.options[i].value === "inception") {
+ select.options[i].disabled = true;
+ break;
+ }
+ }
+ }else{
+
+ var select = document.getElementById("upload-action-type");
+ for (var i = 0; i < select.options.length; i++) {
+ if (select.options[i].value === "inception") {
+ select.options[i].disabled = false;
+ break;
+ }
+ }
+ }
+
+ } catch (error) {
+ console.error('Error parsing API response data:', error);
+ }
+ } else if (response.code === 404 && response.dataStatus === false) {
+
+ console.error('no data found', response);
+
+ } else {
+ console.error('Something went wrong!');
+ }
+ },
+ error: function(xhr, status, error) {
+ console.error('Error fetching data from API:', error);
+ var select = document.getElementById("upload-action-type");
+ for (var i = 0; i < select.options.length; i++) {
+ if (select.options[i].value === "inception") {
+ select.options[i].disabled = false;
+ break;
+ }
+ }
+ }
+ });
+ })
+
+})
+
+
//--------------------------------------------------------------------------------------
\ No newline at end of file
diff --git a/app/Views/errors/404.php b/app/Views/errors/404.php
new file mode 100644
index 00000000..f271c312
--- /dev/null
+++ b/app/Views/errors/404.php
@@ -0,0 +1,175 @@
+
+
+
+
+
+
+ = isset($page_name) ? $page_name : 'NHance'; ?>
+
+
+
+
+
+
+ /assets/images/Nhance_Favi.svg">
+
+
+
+
+
+
+
+
+
+
+
+ = isset($message) && !empty($message) ? $message : '404 PAGE NOT FOUND' ?>
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/Views/excel_errors.php b/app/Views/excel_errors.php
index 0e8b070e..7c09353c 100644
--- a/app/Views/excel_errors.php
+++ b/app/Views/excel_errors.php
@@ -66,6 +66,7 @@ table.dataTable tbody td {
+
@@ -118,6 +119,12 @@ $(document).ready(function() {
extend: 'excel',
text: 'Excel', // Set the title for the Excel button
title: 'ExcelErrorData', // Set your custom title here
+ },
+ {
+ text: 'Excel Error', // Set the text for the custom button
+ action: function (e, dt, node, config) {
+ window.location.href = '= base_url("util/full-excel-error-file/") . $file_id ?>';
+ }
}
],
paging: false, // Disable pagination
diff --git a/app/Views/policy_gmc_terms.php b/app/Views/policy_gmc_terms.php
index f5b9b5ac..25b16341 100644
--- a/app/Views/policy_gmc_terms.php
+++ b/app/Views/policy_gmc_terms.php
@@ -105,8 +105,8 @@
- Yes
- No
+ Yes
+ No
@@ -159,8 +159,8 @@
- Yes, waived off
- No
+ Yes, waived off
+ No
@@ -206,8 +206,8 @@
- Yes, waived off
- No
+ Yes, waived off
+ No
@@ -224,8 +224,8 @@
- Yes, waived off
- No
+ Yes, waived off
+ No
@@ -235,8 +235,8 @@
- Yes, waived off
- No
+ Yes, waived off
+ No
@@ -254,8 +254,8 @@
- Internal Covered
- No
+ Internal Covered
+ No
@@ -324,8 +324,8 @@
- Yes
- No
+ Yes
+ No
@@ -361,8 +361,8 @@
- Applicable
- Not Applicable
+ Applicable
+ Not Applicable
@@ -370,8 +370,8 @@
- Yes
- No
+ Yes
+ No
@@ -379,8 +379,8 @@
- Yes
- No
+ Yes
+ No
@@ -398,8 +398,8 @@
- Yes
- No
+ Yes
+ No
@@ -640,7 +640,7 @@ var grid_html = '';
var gmc_policy_type_id = $(this).attr('id');
- console.log(gmc_policy_type_id)
+ // console.log(gmc_policy_type_id)
if(gmc_policy_type_id == 'GMC'){
@@ -657,7 +657,9 @@ var grid_html = '';
data: {client_policy_id: client_policy_id},
success: function(response) {
console.log('response',response);
- console.log('count', response.count);
+
+
+ // console.log('count', response.count);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
@@ -684,6 +686,11 @@ var grid_html = '';
if (response) {
+ if ( response.emp_count_by_policy != 0) {
+ $('#btnGridSubmit1').hide();
+
+ $('#myButtonSpecialCondition').hide();
+ }
let jsonObject = JSON.parse(response.data);
Object.keys(jsonObject).forEach(function(key) {
if (key.includes("special_condition_label") || key.includes("special_condition_input")) {
@@ -737,6 +744,53 @@ var grid_html = '';
}
}
+ if(response.policy_addon == '3'){
+
+ $('.jodit-container').prop('disabled', true);
+ $('.waiverofpreexistingdiseases').prop('disabled', true);
+ $('#maternitycoverage').prop('disabled', true);
+ $('#twindelivery').prop('disabled', true);
+ $('#preandpostnatal').prop('disabled', true);
+ $('#babyday1cover').prop('disabled', true);
+ $('.9monthwaitingperiodwaived').prop('disabled', true);
+ $('#coverfromthedateofjoining').prop('disabled', true);
+ $('.waiverof1234thyearexclusions').prop('disabled', true);
+ $('.waiverof30dayswaitingperiod').prop('disabled', true);
+ $('#prehospitalizationcover').prop('disabled', true);
+ $('.congenitaldiseasesinternal').prop('disabled', true);
+ $('#copayzonewisecopay').prop('disabled', true);
+ $('#bioabsorbablestenttoriclensmultifocallens').prop('disabled', true);
+ $('#roomrentlimit').prop('disabled', true);
+ $('#proportionatedeductionclause').prop('disabled', true);
+ $('#nursingallowance').prop('disabled', true);
+ $('.ailmentcapping').prop('disabled', true);
+ $('#ambulancecharges').prop('disabled', true);
+ $('#airambulance').prop('disabled', true);
+ $('#familytransportationbenefit').prop('disabled', true);
+ $('.reasonableandcustomarycharges').prop('disabled', true);
+ $('.daycaretreatment').prop('disabled', true);
+ $('.ayudhtreatmentcover').prop('disabled', true);
+ $('#armdcovered').prop('disabled', true);
+ $('.suminsuredenhancement').prop('disabled', true);
+ $('#automaticsuminsuredreinstatement').prop('disabled', true);
+ $('#lasiksurgery').prop('disabled', true);
+ $('#midterminclusion').prop('disabled', true);
+ $('#capd').prop('disabled', true);
+ $('#organdonorexpenses').prop('disabled', true);
+ $('#moderntreatmentsasperirdai').prop('disabled', true);
+ $('#days_of_discharge').prop('disabled', true);
+ $('#days_from_dod').prop('disabled', true);
+
+ setTimeout(function() {
+ var editor1 = new Jodit('#additionalsicknessbenefit');
+ var editor2 = new Jodit('#Wellness');
+
+ editor1.setReadOnly(true);
+ editor2.setReadOnly(true);
+
+ }, 3000);
+ }
+
}