diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 1252386c..a1ad29d4 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -17,6 +17,8 @@ $routes->get('/logout', 'LoginController::logout'); $routes->get('/oauth2callback', 'LoginController::receiveGoogleOAuthResponse'); $routes->get('/auth/google', 'LoginController::initiateGoogleOAuth'); $routes->get('/update-emp-policy-status', 'ClientController::updateEmpAndPolicyStatus'); +$routes->get('download-e-card/(:segment)/(:segment)', 'EmployeeController::generateIDCardForEmployee/$1/$2'); + $routes->group("/user", ["filter" => "authMVC"], function($routes){ @@ -114,6 +116,7 @@ $routes->group("/employee", ["filter" => "authMVC"], function($routes){ $routes->post("upload", "EmployeeController::employeesUplodWithEvents"); $routes->get("excel_error/(:any)", "EmployeeController::getExcelFileErrors/$1"); $routes->get("endorsement-list", "EmployeeController::endorsementList"); + $routes->get("truncate/(:any)", "EmployeeController::truncateFileData/$1"); }); @@ -218,7 +221,7 @@ $routes->group("/util", ["filter" => "authMVC"], function($routes){ $routes->get("fetch-emp-count/(:any)", "EmployeeController::getEmpCount/$1"); $routes->get("init-Emp-onboard/(:any)", "EmployeeController::initiateManualEmployeesOnboardProcess/$1"); $routes->get("full-excel-error-file/(:any)", "EmployeeController::downloadFullExcelErrorFile/$1"); - + $routes->get("id-card", "EmployeeController::viewECard/$1"); }); $routes->cli('cli/processjob', 'JobWorker::processJob'); @@ -267,6 +270,11 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function($routes){ $routes->get("exportDataByClientPolicyId", "EmployeeRestController::exportDataByClientPolicyId"); $routes->get("getCashDepositData", "EmployeeRestController::getCashDepositData"); + $routes->get("exportCashDepositData", "EmployeeRestController::exportCashDepositData"); + + $routes->get("removeEmpAndEmpPolicyData", "EmployeeRestController::removeEmpAndEmpPolicyData"); + + }); $routes->post("sendEmail", "EmployeeRestController::send_email"); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index baca94e2..6c76b45b 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -1104,12 +1104,12 @@ class ClientController extends AdminController try { foreach ($results as $index => $record) { - if ($self->self == 1 && $self->spouse == 0 && $self->childrens == 0 && $self->parents == 0 && $self->{'parents-in-law'} == 0 && $self->{'either-parents-pil'} == 0) { + if ($self->self == 1 && $self->spouse == 0 && $self->childrens == 0 && $self->parents == 0 && $self->{'parents-in-law'} == 0 && $self->{'either-parents-pil'} == 0 && $family_floater == 0) { if ($index == '0' || $index == '1' || $index == '2') { $resultss[$index] = $record; } } else { - if ($index == '0' || $index == '1' || $index == '2' || $index == '3' || $index == '4' || $index == '5' || $index == '6' || $index == '8' || $index == '7' || $index == '9' || $index == '10') { + if ($index == '3' || $index == '4' || $index == '5' || $index == '6' || $index == '8' || $index == '7' || $index == '9' || $index == '10') { $resultss[$index] = $record; } } diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index a3953889..bfcc61d9 100644 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -29,6 +29,8 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\IOFactory; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; +use Dompdf\Dompdf; + class EmployeeController extends AdminController { @@ -129,9 +131,9 @@ class EmployeeController extends AdminController // print_r($this->request->getPost('policies')); // print_r($this->request->getPost('upload-action-type')); // die(); - $empServiceController = new EmployeeServiceController(); - $res = $empServiceController->excelFileFormatValidation(['file_id' => '42']); - dd($res); + // $empServiceController = new EmployeeServiceController(); + // $res = $empServiceController->excelFileFormatValidation(['file_id' => '42']); + // dd($res); // $empServiceController = new EmployeeServiceController(); // $res = $empServiceController->excelFileDataValidation(['file_id' => '38']); @@ -247,19 +249,23 @@ class EmployeeController extends AdminController { $file_id = $this->request->uri->getSegment(3); $empServiceController = new EmployeeServiceController(); - - // Render views and capture output - $result = $empServiceController->getExcelErrorData($file_id); $result['file_id'] = $file_id; - // echo '
';
-        // print_r($result); die;
-        if($result){
+        // Render views and capture output
+        $result = $empServiceController->getExcelErrorData($file_id);
+
+        if ($result != 0) {
+
             echo view('excel_errors', $result);
-        }else{
+        } else if ($result == 0) {
+
+            $data['message'] = 'File Not Found Physically';
+            return view('errors/404', $data);
+
+        } else {
+
             echo view('errors/html/production');
         }
-    
     }
 
     /**
@@ -673,6 +679,7 @@ class EmployeeController extends AdminController
             
                 $highestRowAndColumn = $sheet->getHighestRowAndColumn();
                 $excel_data = $sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
+                // dd($excel_data);
                 $emp_data['thead'] = $excel_data[0];
                 unset($excel_data[0]);
                 $emp_data['tbody'] = $excel_data;
@@ -684,7 +691,7 @@ class EmployeeController extends AdminController
                 $html = '
No Data Found
'; } - return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $html, 'file_data' => $file_name], 200); + return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $html, 'file_data' => $file_name, 'excel_data' => $excel_data], 200); } catch (\Exception $e) { // Handle exception @@ -826,7 +833,96 @@ class EmployeeController extends AdminController return $response; } + public function generateIDCardForEmployee($emp_code, $client_policy_id) + { + $dompdf = new Dompdf(); + + $data['data'] = $this->employeePolicyModel->getECardDataUsingMd5($client_policy_id, $emp_code); + // $this->loadLayout('id_card_view', $data); exit; + + $html = view('id_card_view', $data); + // $html = str_replace('', '', $html); + + $dompdf->loadHtml($html); + + // (Optional) Setup the paper size and orientation + $dompdf->setPaper('A4', 'landscape'); + + // Render the HTML as PDF + $dompdf->render(); + + // Output the generated PDF to Browser + $dompdf->stream(); + + } + + public function viewECard() + { + $this->loadLayout('id_card_view'); + } + + public function truncateFileData() //truncateFileDataIn DB (de activate rows) + { + $file_id = $this->request->uri->getSegment(3); + // $file_id = 112; + $file = $this->fileModel->find($file_id); + // $file['action'] = 'si_enhancement'; + // $result = []; + // !dd($file); + if($file['action'] == 'inception' || $file['action'] == 'dependent_addition' || $file['action'] == 'addition') + { + $result = $this->employeeModel->getEmpListByFileId(file_id: $file_id,emp_status: ['active'],policy_status:['active']); + // ~dd($result); + if(count($result)) + { + return $this->respond(['dataStatus' => false,'code' => 404,'message' => 'File data already processed'], 200); + } + else + { + + //update emp and emp plocies + $db = db_connect(); + $query = "UPDATE employees JOIN employee_polices ON employees.id = employee_polices.employee_id and employees.file_id = $file_id SET employees.emp_status = 'truncated', employee_polices.status = 'truncated', employees.is_active = 0,employee_polices.is_active = 0 WHERE employees.file_id = $file_id"; + $db->query($query); + $affectedRows = $db->affectedRows(); + // $affectedRows = 10; + + //update file status + $this->fileModel->where('id', $file_id)->set(['status' => 'truncated'])->update(); + + return $this->respond(['dataStatus' => true,'code' => 200,'data' => round($affectedRows/2)], 200); + } + } + else if($file['action'] == 'si_enhancement' || $file['action'] == 'correction' || $file['action'] == 'deletion') + { + $res = $this->empEndorsementModel->select(['count(id) as count']) + ->where('emp_endorsement.file_id',$file_id) + ->groupStart() + ->where('emp_endorsement.endorsement_id is not null') + ->orwhereIn('emp_endorsement.status',['complete']) + ->groupEnd() + ->get() + ->getResult(); + // print_r($this->empEndorsementModel->getLastQuery()); + // echo $res[0]->count;die(); + if($res[0]->count == 0) + { + //update truncated status to db + $this->empEndorsementModel->where('file_id',$file_id) + ->set(['status' => 'truncated']) + ->update(); + //update file status + $this->fileModel->where('id', $file_id)->set(['status' => 'truncated'])->update(); + return $this->respond(['dataStatus' => true,'code' => 200,'data' => 'success'], 200); + } + else + { + return $this->respond(['dataStatus' => false,'code' => 404,'message' => 'File data already processed'], 200); + } + } + + } diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 8ce029c1..f25e56cf 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -398,7 +398,7 @@ class EmployeeRestController extends AdminController if(count($empData)) { - // Define headers and map database fields to Excel fields + // Define headers and map database fields to Excel fields $headers = [ 'Employee Code' => 'emp_code', 'Name' => 'name', @@ -1075,6 +1075,16 @@ public function getEmployeePolicy() // Generate Notes string based on familyFloates terms $array->notes = $this->FloterNotesConvertion($familyFloates); + + if($getSlabAndGridData['slab_rates'][0]['premium_type'] == 1) + { + $array->floter_text_heading = 'Floater Sum Insured'; + $array->floter_text_description = 'This is a floater sum insured. A floater is a type of sum insured that provides coverage to more than one member ot a family at the same time. Simply put, its a single insurance cover for the entire family.'; + }else{ + $array->floter_text_heading = 'Sum Insured'; + $array->floter_text_description = ''; + } + // Convert familyFloaters terms data to plain array $floters = $this->FloterConvertion($familyFloates); @@ -1258,6 +1268,16 @@ public function getAddOnPolicy() $responce['is_addon'] = $array['is_addon']; $responce['open_for_enrollment'] = $array['open_for_enrollment']; $responce['policy_terms'] = $decodedArray; + + if(count($getSlabAndGridData['slab_rates'])){ + if($getSlabAndGridData['slab_rates'][0]['premium_type'] == 1) + { + $responce['floter_text_heading'] = 'Floater Sum Insured'; + }else{ + $responce['floter_text_heading'] = 'Sum Insured'; + } + } + if($array['is_addon'] == 3) { @@ -1515,50 +1535,54 @@ public function getCashDepositData() ->findAll(); $result = []; - foreach ($ClientPolicyData as $key => $value) { + if(count($ClientPolicyData)) + { + foreach ($ClientPolicyData as $key => $value) { - $data['clientId'] = $value['clientId']; - $data['insurerId'] = $value['insurerId']; - $data['insurerName'] = $value['insurer_name']; - $data['depositData'] = $this->clientPolicyModel->getdepositData($value['clientId'],$value['insurerId']); - $data['balance'] = count($data['depositData']) ? $data['depositData'][0]->balance : 0; - - $data['policyDetails'] = []; - $ClientPolicyData =$this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, policies.id as policy_id,policies.policy_type_id as policy_type_id, policies.name as policy_name , client_policy.is_addon as is_addon') - ->join('policies', 'client_policy.policy_id = policies.id', 'left') - ->where('client_policy.insurer_id', $value['insurerId'] ) - ->where('client_policy.client_id', $this->request->getGet('client_id') ) - ->findAll(); - foreach ($ClientPolicyData as $key => $value) - { - $getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard( $value['client_policy_id'],$value['client_id']); - if($value['is_addon'] == "2"){ $value['type'] = 'SI TopUp'; }else if($value['is_addon'] == "3"){ $value['type'] = 'Dependent AddOn'; }else{ $value['type'] = $getSlabAndGridData['grid_master']['policy_type']; } - $employeeDetails = $this->employeePolicyModel->getEmployeePolicy( client_id:$value['client_id'],policy_id: $value['client_policy_id'],status:0); - $enrolledCount = 0; - $draftCount = 0; - if(count($employeeDetails)) + $data['clientId'] = $value['clientId']; + $data['insurerId'] = $value['insurerId']; + $data['insurerName'] = $value['insurer_name']; + $data['depositData'] = $this->clientPolicyModel->getdepositData($value['clientId'],$value['insurerId']); + $data['balance'] = count($data['depositData']) ? $data['depositData'][0]->balance : 0; + + $data['policyDetails'] = []; + $ClientPolicyData =$this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, policies.id as policy_id,policies.policy_type_id as policy_type_id, policies.name as policy_name , client_policy.is_addon as is_addon') + ->join('policies', 'client_policy.policy_id = policies.id', 'left') + ->where('client_policy.insurer_id', $value['insurerId'] ) + ->where('client_policy.client_id', $this->request->getGet('client_id') ) + ->findAll(); + foreach ($ClientPolicyData as $key => $value) { - foreach ($employeeDetails as $item) { - if ($item['emp_status'] === 'enrolled') { - $enrolledCount++; - } elseif ($item['emp_status'] === 'draft') { - $draftCount++; + $getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard( $value['client_policy_id'],$value['client_id']); + if($value['is_addon'] == "2"){ $value['type'] = 'SI TopUp'; }else if($value['is_addon'] == "3"){ $value['type'] = 'Dependent AddOn'; }else{ $value['type'] = $getSlabAndGridData['grid_master']['policy_type']; } + $employeeDetails = $this->employeePolicyModel->getEmployeePolicy( client_id:$value['client_id'],policy_id: $value['client_policy_id'],status:0); + $enrolledCount = 0; + $draftCount = 0; + if(count($employeeDetails)) + { + foreach ($employeeDetails as $item) { + if ($item['emp_status'] === 'enrolled') { + $enrolledCount++; + } elseif ($item['emp_status'] === 'draft') { + $draftCount++; + } } } + + $value['totalMembersCount'] = count($employeeDetails); + $value['membersCountOfEnrolled'] = $enrolledCount; + $value['membersCountOfDraft'] = $draftCount; + + array_push($data['policyDetails'],$value); } - - $value['totalMembersCount'] = count($employeeDetails); - $value['membersCountOfEnrolled'] = $enrolledCount; - $value['membersCountOfDraft'] = $draftCount; - - array_push($data['policyDetails'],$value); + + + array_push($result,$data); + } - - - array_push($result,$data); - } - + + if($result) { @@ -1569,4 +1593,140 @@ public function getCashDepositData() } + + + +public function exportCashDepositData() +{ + + $CashDepositData = $this->clientPolicyModel->getdepositData($this->request->getGet('client_id'),$this->request->getGet('insurer_id')); + + // echo '
';print_r($CashDepositData); echo '
';die; + + if(count($CashDepositData)) + { + // Define headers and map database fields to Excel fields + $headers = [ + 'Date' => 'created_at', + 'Type' => 'transaction_type', + 'Amount' => 'amount', + 'Balance' => 'balance', + 'Description' => 'description', + 'Insurer Name' => 'insurer_name', + 'Client Name' => 'clientname' + ]; + + // Create a new Spreadsheet object + $spreadsheet = new Spreadsheet(); + + // Get the active sheet + $sheet = $spreadsheet->getActiveSheet(); + + // Add headers + $column = 'A'; + foreach ($headers as $header => $dbField) { + $sheet->setCellValue($column . '1', $header); + $column++; + } + + // Add data + $row = 2; + foreach ($CashDepositData as $Cashvalue) { + $column = 'A'; + foreach ($headers as $dbField) { + $sheet->setCellValue($column . $row, $Cashvalue->$dbField); + $column++; + } + $row++; + } + + + // Set the header for download + $filename = $CashDepositData[0]->insurer_name.'-CashDeposit.xlsx'; + header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); + header('Content-Disposition: attachment;filename="' . $filename . '"'); + header('Cache-Control: max-age=0'); + + // Save the Excel file to output + $writer = new Xlsx($spreadsheet); + $writer->save('php://output'); + exit; + + return $this->respond(['status' => 'success', 'code' => 200, 'data' => []], 200); + + }else{ + + return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 200); + } + +} + + +public function removeEmpAndEmpPolicyData() +{ + try { + + $clientPolicy = $this->clientPolicyModel->where('id',$this->request->getGet('client_policy_id'))->findAll(); + + if(count($clientPolicy)) + { + + + if($clientPolicy[0]['is_addon'] == 2)//Topup + { + $empData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code')) + ->where('is_addon_value', 0 )->findAll(); + if(count($empData)) + { + foreach ($empData as $key => $value) { + + $this->employeePolicyModel->where('client_policy_id',$this->request->getGet('client_policy_id') ) + ->where('employee_id', $value['id'] ) + ->set(array('is_active'=> 0 )) + ->update(); + + } + } + + } + else if($clientPolicy[0]['is_addon'] == 3)//Dependent addon + { + $empData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code')) + ->where('is_addon_value', 1 )->findAll(); + if(count($empData)) + { + foreach ($empData as $key => $value) { + + $this->employeePolicyModel->where('client_policy_id',$this->request->getGet('client_policy_id') ) + ->where('employee_id', $value['id'] ) + ->set(array('is_active'=> 0 )) + ->update(); + + } + + $this->employeeModel->where('emp_code', $this->request->getGet('emp_code') ) + ->where('is_active', 1 )->where('is_addon_value', 1 ) + ->set(array('is_active'=> 0 )) + ->update(); + } + + } + + + + return $this->respond(['status' => 'success','code' => 200,'data' =>[] ], 200); + + }else{ + return $this->respond(['status' => 'failed','code' => 404,'data' => [] ], 404); + } + + + } catch (\Exception $e) { + return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500); + } + +} + + + } \ No newline at end of file diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index ac2b2c86..46fb73ee 100644 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -145,7 +145,7 @@ class EmployeeServiceController extends AdminController $policy_terms = json_decode($policy_terms[0]->policy_terms); $policy_terms = (array) $policy_terms;// convert obj to array // - dd($policy_terms); + // dd($policy_terms); //get policy slab rates $slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($file['policy_id'],$file['client_id']); @@ -621,14 +621,14 @@ class EmployeeServiceController extends AdminController $group_key = rand(100000, 999999); //for emp table - $this->empEndorsementModel->save(['pk' => (int)$data['emp_id'],'emp_code' => $data['emp_code'],'table_name' => 'employees','actions' => 'd','name' => $data['name'],'field_name' => 'emp_status','old_value' => $data['emp_status'],'new_value' => 'deactivate','created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key]); + $this->empEndorsementModel->save(['pk' => (int)$data['emp_id'],'emp_code' => $data['emp_code'],'table_name' => 'employees','actions' => 'd','name' => $data['name'],'field_name' => 'emp_status','old_value' => $data['emp_status'],'new_value' => 'deactivate','created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id']]); // dd( $this->empEndorsementModel->getLastQuery()); // $this->empEndorsementModel->save(['pk' => (int)$data['emp_id'],'emp_code' => $data['emp_code'],'table_name' => 'employees','actions' => 'd','name' => $data['name'],'field_name' => 'change_event','old_value' => $data['change_event'],'new_value' => 'deletion','created_by' => $file['created_by'],'remarks' => 'general deletion']); // for employee policy table - $this->empEndorsementModel->save(['pk' => (int)$data['emp_policy_id'],'emp_code' => $data['emp_code'],'table_name' => 'employee_polices','actions' => 'd','name' => $data['name'],'field_name' => 'date_of_exit','old_value' => $data['date_of_exit'],'new_value' => change_date_format($row[4],'d-M-Y','Y-m-d'),'created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key]); - $this->empEndorsementModel->save(['pk' => (int)$data['emp_policy_id'],'emp_code' => $data['emp_code'],'table_name' => 'employee_polices','actions' => 'd','name' => $data['name'],'field_name' => 'reason_for_exit','old_value' => $data['reason_for_exit'],'new_value' => $row[5],'created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key]); - $this->empEndorsementModel->save(['pk' => (int)$data['emp_policy_id'],'emp_code' => $data['emp_code'],'table_name' => 'employee_polices','actions' => 'd','name' => $data['name'],'field_name' => 'status','old_value' => $data['status'],'new_value' => 'deactivate','created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key]); + $this->empEndorsementModel->save(['pk' => (int)$data['emp_policy_id'],'emp_code' => $data['emp_code'],'table_name' => 'employee_polices','actions' => 'd','name' => $data['name'],'field_name' => 'date_of_exit','old_value' => $data['date_of_exit'],'new_value' => change_date_format($row[4],'d-M-Y','Y-m-d'),'created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id']]); + $this->empEndorsementModel->save(['pk' => (int)$data['emp_policy_id'],'emp_code' => $data['emp_code'],'table_name' => 'employee_polices','actions' => 'd','name' => $data['name'],'field_name' => 'reason_for_exit','old_value' => $data['reason_for_exit'],'new_value' => $row[5],'created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id']]); + $this->empEndorsementModel->save(['pk' => (int)$data['emp_policy_id'],'emp_code' => $data['emp_code'],'table_name' => 'employee_polices','actions' => 'd','name' => $data['name'],'field_name' => 'status','old_value' => $data['status'],'new_value' => 'deactivate','created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id']]); }; //iterate each row foreach ($excel_data as $col_key => $row) @@ -738,7 +738,7 @@ class EmployeeServiceController extends AdminController if(!count($existing_endorsements)) { $group_key = rand(100000, 999999); - $this->empEndorsementModel->save(['pk' => (int)$employee['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employees','actions' => 'c','name' => $employee['name'],'field_name' => $field_name,'old_value' => $employee[ $field_name ],'new_value' => $field_value,'created_by' => $file['created_by'],'remarks' => $row[7],'date_of_correction' => change_date_format($row[5],'d-M-Y','Y-m-d'),'group_key' => $group_key]); + $this->empEndorsementModel->save(['pk' => (int)$employee['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employees','actions' => 'c','name' => $employee['name'],'field_name' => $field_name,'old_value' => $employee[ $field_name ],'new_value' => $field_value,'created_by' => $file['created_by'],'remarks' => $row[7],'date_of_correction' => change_date_format($row[5],'d-M-Y','Y-m-d'),'group_key' => $group_key,'file_id' => $file['id']]); } @@ -803,9 +803,9 @@ class EmployeeServiceController extends AdminController if($slab_value['si'] == $row[3]) { $group_key = rand(100000, 999999); - $this->empEndorsementModel->save(['pk' => (int)$employee['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employee_polices','actions' => 'si','name' => $employee['name'],'field_name' => 'basic_cover_si','old_value' => $employee_policy['basic_cover_si'],'new_value' => $row[3],'created_by' => $file['created_by'],'remarks' => 'general si enhancement','group_key' => $group_key]); - $this->empEndorsementModel->save(['pk' => (int)$employee['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employee_polices','actions' => 'si','name' => $employee['name'],'field_name' => 'premium','old_value' => $employee_policy['premium'],'new_value' => $slab_value['premium'],'created_by' => $file['created_by'],'remarks' => 'general si enhancement','group_key' => $group_key]); - $this->empEndorsementModel->save(['pk' => (int)$employee['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employee_polices','actions' => 'si','name' => $employee['name'],'field_name' => 'si_enhancement_date','old_value' => null,'new_value' => change_date_format($row[4],'d-M-Y','Y-m-d'),'created_by' => $file['created_by'],'remarks' => 'general si enhancement','group_key' => $group_key]); + $this->empEndorsementModel->save(['pk' => (int)$employee['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employee_polices','actions' => 'si','name' => $employee['name'],'field_name' => 'basic_cover_si','old_value' => $employee_policy['basic_cover_si'],'new_value' => $row[3],'created_by' => $file['created_by'],'remarks' => 'general si enhancement','group_key' => $group_key,'file_id' => $file['id']]); + $this->empEndorsementModel->save(['pk' => (int)$employee['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employee_polices','actions' => 'si','name' => $employee['name'],'field_name' => 'premium','old_value' => $employee_policy['premium'],'new_value' => $slab_value['premium'],'created_by' => $file['created_by'],'remarks' => 'general si enhancement','group_key' => $group_key,'file_id' => $file['id']]); + $this->empEndorsementModel->save(['pk' => (int)$employee['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employee_polices','actions' => 'si','name' => $employee['name'],'field_name' => 'si_enhancement_date','old_value' => null,'new_value' => change_date_format($row[4],'d-M-Y','Y-m-d'),'created_by' => $file['created_by'],'remarks' => 'general si enhancement','group_key' => $group_key,'file_id' => $file['id']]); break; } } @@ -958,6 +958,7 @@ class EmployeeServiceController extends AdminController { $error_message = "File not found"; $this->myLogger->logme('error',($error_message . ' for file id ' . $file_id)); + return 0; } $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path); diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php index 6ed64b27..84ed0c24 100644 --- a/app/Helpers/excel_util_helper.php +++ b/app/Helpers/excel_util_helper.php @@ -247,22 +247,33 @@ if (!function_exists('data_group_by_family')) function data_group_by_family($emp_data,$data_source = 'excel') { $result = []; + // dd($emp_data); foreach ($emp_data as $rkey => $row) { if($data_source == 'excel') { if(!check_row_is_empty_or_null($row)) { - $result[$row[1]][] = $row; + if(strtolower($row[5]) == 'self' && isset($result[$row[1]])) + { + array_unshift($result[$row[1]],$row); + }else + { + $result[$row[1]][] = $row; + } } - }else if($data_source = 'db') { - $result[$row['emp_code']][] = $row; + if(strtolower($row['relationship']) == 'self' && isset($result[$row['emp_code']])) + { + array_unshift($result[$row['emp_code']],$row); + }else + { + $result[$row['emp_code']][] = $row; + } } } - return $result; } } @@ -844,7 +855,7 @@ if (!function_exists('premium_calculation_manager')) $emp_data['policy_details']['policy_end_date'] = $policy_terms['policy_end_date']; $emp_data['policy_details']['days'] = calculate_days_bw_dates($policy_terms['policy_start_date'],$policy_terms['policy_end_date'])->days; $emp_data['policy_details']['premium'] = $slab_value['premium']; - $emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']; + $emp_data['policy_details']['rata_premimum'] = calculate_pro_rata_premimum($slab_value['premium'],$emp_data['policy_details']['days']); $emp_data['policy_details']['gst'] = ((float) number_format(($emp_data['policy_details']['rata_premimum'] * (18/100)),2,'.','')); break; diff --git a/app/Models/EmpEndorsementModel.php b/app/Models/EmpEndorsementModel.php index 8be6c38c..ab20b712 100644 --- a/app/Models/EmpEndorsementModel.php +++ b/app/Models/EmpEndorsementModel.php @@ -25,7 +25,8 @@ class EmpEndorsementModel extends Model "created_by", "updated_by", "is_active", - "remarks" + "remarks", + "file_id" ]; // Callbacks diff --git a/app/Models/EmployeeModel.php b/app/Models/EmployeeModel.php index 50b0eadf..fe534ebf 100644 --- a/app/Models/EmployeeModel.php +++ b/app/Models/EmployeeModel.php @@ -139,4 +139,30 @@ class EmployeeModel extends Model return $this->where('emp_code',$arr['emp_code'])->where('name',$arr['name'])->where('client_id', $arr['client_id'])->first(); } + + public function getEmpListByFileId(int $file_id,array $emp_status = [],array $policy_status = []) + { + $result = $this->select(['employees.id as emp_id', 'employees.client_id', 'employees.relationship', 'employees.relationship_code', 'employees.change_event', 'employees.emp_code', 'employees.name', 'employees.email_personal', 'employees.email_corporate', 'employees.mobile', 'employees.gender', 'employees.dob', 'employees.doj', 'employees.basic_pay', 'employees.band', 'employees.designation', 'employees.emp_status','employee_polices.id as emp_policy_id', 'employee_polices.employee_id', 'employee_polices.client_policy_id', 'employee_polices.tpa_id', 'employee_polices.uhid', 'employee_polices.batch_code', 'employee_polices.status', 'employee_polices.pre_existing_alignments', 'employee_polices.basic_cover_si', 'employee_polices.date_coverage', 'employee_polices.policy_end_date', 'employee_polices.days', 'employee_polices.premium', 'employee_polices.rata_premimum', 'employee_polices.gst', 'employee_polices.date_of_exit', 'employee_polices.reason_for_exit']) + ->join('employee_polices', 'employee_polices.employee_id = employees.id') + ->where('employees.is_active',1) + ->where('employees.file_id',$file_id) + ->where('employee_polices.is_active',1) + // ->where('employee_polices.uhid is not null') + // ->where('employee_polices.tpa_id is not null') + ->groupStart() + ->orWhere('employee_polices.uhid is not null') + ->orWhere('employee_polices.tpa_id is not null') + ->groupEnd() + ->when(count($emp_status), function($query) use ($emp_status){ + return $query->whereIn('employees.emp_status', $emp_status); + }) + ->when(count($policy_status), function($query) use ($policy_status){ + return $query->whereIn('employee_polices.status', $policy_status); + }) + ->findAll(); + // ~dd($this->db->getLastQuery()); + + return ($result); + } + } diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index b7e2f19d..3198d873 100644 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -79,13 +79,17 @@ class EmployeePolicyModel extends Model ->join('tpa_branch tpab', 'cp.tpa_branch_id = tpab.id') //tpab - tpa brach ->join('clients cm', 'cp.client_id = cm.id') //cm - client master ->where('emp.client_id',$client_id) - ->where('employee_polices.client_policy_id',$policy_id); + ->where('employee_polices.is_active',1) + ->where('emp.is_active',1) + ->where('employee_polices.client_policy_id',$policy_id) + ->orderBy('emp.emp_code','ASC')->orderBy('employee_polices.employee_id','ASC'); + if($status != 0 && !empty($status)){ $result->where('employee_polices.status', $status); } - $result = $result->findAll(); + $result = $result->findAll(); return ($result); } @@ -674,7 +678,8 @@ class EmployeePolicyModel extends Model } - public function getViewEmpSuccessList($file_id){ + public function getViewEmpSuccessList($file_id) + { return $this->db->table('employees emp') ->select(['employee_polices.*','pm.name as policy_name','im.short_name as insurer_short_name','ib.branch_name as insurer_branch_name','ib.branch_code as insurer_branch_code','tpam.name as tpa_name','tpam.short_name as tpa_short_name','tpab.branch_code as tpa_branch_code','cm.client_name','cm.short_name as client_short_name','emp.relationship','emp.relationship_code','emp.change_event','emp.emp_code','emp.name','emp.email_corporate','emp.dob','emp.gender','emp.emp_status','emp.is_active as emp_is_active','emp.mobile as mobile']) ->join('employee_polices', 'employee_polices.employee_id = emp.id') @@ -689,5 +694,55 @@ class EmployeePolicyModel extends Model ->whereIn('employee_polices.status', ['draft', 'enrolled']) ->get()->getResultArray(); } + + public function getECardDataUsingMd5($client_policy_id, $emp_code){ + + $result = $this->db->table('employees e') + ->select('e.id, + e.name, e.mobile, + e.relationship, + e.relationship_code, + e.emp_code, + e.email_personal, + e.email_corporate, + e.gender, + e.dob, + e.doj, + e.band, + TIMESTAMPDIFF(YEAR, e.dob, CURDATE()) AS emp_age, + + ep.tpa_id, + ep.uhid, + ep.policy_end_date, + + clients.client_name, + clients.short_name AS client_short_name, + + policies.name AS policy_name, + + insurers.name AS insurer_name, + insurers.short_name AS insurer_short_name, + + tpa.name AS tpa_name, + tpa.short_name AS tpa_short_name' + ) + + ->join('employee_polices ep', 'ep.employee_id = e.id') + ->join('client_policy cp', 'cp.id = ep.client_policy_id') + ->join('clients', 'clients.id = cp.client_id') + ->join('policies', 'policies.id = cp.policy_id') + ->join('insurers', 'insurers.id = cp.insurer_id') + ->join('tpa', 'tpa.id = cp.tpa_id') + ->where('e.emp_status', 'active') + ->where('e.is_active', '1') + ->where('ep.status', 'active') + ->where('ep.is_active', '1') + ->where('MD5(e.emp_code)', $emp_code) + ->where('MD5(ep.client_policy_id)', $client_policy_id) + ->get() + ->getResultArray(); + + return $result; + } } \ No newline at end of file diff --git a/app/Views/file_list.php b/app/Views/file_list.php index 0eb25a30..a3bf934f 100644 --- a/app/Views/file_list.php +++ b/app/Views/file_list.php @@ -86,6 +86,11 @@ data-target="#full-width-modal-emp-list" class="dropdown-item view_emp_list" href="#">View + + Truncate + @@ -225,6 +230,80 @@ $('body').on('click', '.upload_button', function() { $('#file_upload_actions').val(fileId.action) }) +$('body').on('click', '.truncate', function() { + event.preventDefault(); + // console.log(event); + var fileId = JSON.parse(this.getAttribute('data-id')); + // alert('Hi' + fileId); + + Swal.fire({ + title: "Do you want to truncate data from uploaded file?", + showCancelButton: true, + confirmButtonText: "Delete", + confirmButtonColor: "#ff3333", + }).then((result) => { + + console.log(result); + if (result.isConfirmed) { + $('.loader').fadeIn(); + $('.loader-mask').fadeIn(); + var apiURL = '' + 'employee/truncate/' + fileId; + $.ajax({ + url: apiURL, + method: 'GET', + headers: { + // "Content-Type": "application/json", + "X-Requested-With": "XMLHttpRequest" + }, + success: function(response) { + // console.log(response.code); + // console.log(response.dataStatus); + // console.log(response.data); + setTimeout(function() { + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + }, 1000); + + + if (response.code === 200 && response.dataStatus === true && response.data !== "") { + Swal.fire({ + title: "Deleted!", + // text: "Data from truncated", + icon: "success" + }); + } else if (response.code === 404 && response.dataStatus === false) { + console.error('no data found', response); + Swal.fire({ + title: "Failed!", + text: response.message, + icon: "error" + }); + } else { + + Swal.fire({ + title: "Failed!", + text: 'Something went wrong! Try later', + icon: "error" + }); + } + }, + error: function(xhr, status, error) { + setTimeout(function() { + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + }, 1000); + + console.error('Error fetching data from API:', error); + toastr.error('Something went wrong! Try later', 'Error'); + } + }); + + } + }); + + +}) + $('#uploadForm').submit(function() { diff --git a/app/Views/id_card_view.php b/app/Views/id_card_view.php new file mode 100644 index 00000000..b646bb87 --- /dev/null +++ b/app/Views/id_card_view.php @@ -0,0 +1,80 @@ + + + + + + + Driving License ID Card + + + + + + + $value) { ?> + + + + + + +
+ +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ +
+
+
+

Terms and Conditions

+

This card is non-transferable and is valid at network hospitals only.

+
    +
  • will enable Card Holder to avail cashless hospitalization only on the basis of +
  • +
  • In the case of photoless identity cards issued to beneficiaries, acceptable + proof
  • +
  • Notify the authorities in case of any changes to your personal information.
  • +
  • The mentioned covers are add-ons by paying additional premium and available only if opted by the policyholders.
  • +
+
+
+
+
+ + + button + + + + + \ No newline at end of file diff --git a/app/Views/policy_grid.php b/app/Views/policy_grid.php index 372e5279..289392f5 100644 --- a/app/Views/policy_grid.php +++ b/app/Views/policy_grid.php @@ -27,17 +27,17 @@ -
@@ -487,6 +487,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
- + @@ -695,8 +696,10 @@ $('body').on('click', '.btnPolicyModel', function() { if(res.family_floater == 1){ $('#premium_type').show(); + $('#individual').prop('checked', true) }else{ $('#premium_type').hide(); + $('#individual').prop('checked', false) } setTimeout(function() { @@ -827,8 +830,8 @@ $('body').on('click', '.btnPolicyModel', function() { $('#grid').empty(); $('#nameOfThePolicy').html(''); $('#GridForm').hide(); - $('#no_data').html('The policy has no Policy Rac Rate'); - toastr.warning("The policy has no Policy Rac Rate", "Warning") + $('#no_data').html('The policy has no Policy Rack Rate'); + toastr.warning("The policy has no Policy Rack Rate", "Warning") } @@ -1208,7 +1211,7 @@ function appendGridtHtml(ui_type = false, data = false, ) {
-
+