diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 3ca47517..80babc57 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -49,7 +49,7 @@ $routes->group("/user", ["filter" => "authMVC"], function ($routes) { $routes->group("/dashboard", ["filter" => "authMVC"], function ($routes) { - $routes->match(['get','post'],'view','DashboardController::dashboard'); + $routes->get("view", "DashboardController::dashboard"); $routes->get('get-notification', 'DashboardController::getDashboardNotifications'); $routes->get('acknowledge-notification/(:segment)', 'DashboardController::acknowledgeMessage/$1'); $routes->get('get-pending-action', 'PendingActionsController::getPendingActions'); @@ -146,7 +146,6 @@ $routes->group("/employee", ["filter" => "authMVC"], function ($routes) { $routes->get("truncate/(:any)", "EmployeeController::truncateFileData/$1"); $routes->get("test-rack-rate", "EmployeeController::testRackRate"); $routes->post("test-rack-rate", "EmployeeController::testRackRate"); - $routes->post("test-dependent", "EmployeeController::testCheckDependentConflict"); }); @@ -272,16 +271,11 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->get("get_policy_type_for_base_policy/(:any)", "ClientController::getPolicyTypeForBasePolicy/$1"); $routes->get("get_client_details/(:any)", "ClientController::getClientDetails/$1"); $routes->get("featch_dashboard_data/(:any)", "DashboardController::featch_dashboard_data/$1"); - $routes->get("remove_rack_rate/(:any)", "ClientController::removeRackRate/$1"); - $routes->get("get_client_policy_list_for_remainder/(:any)", "EmployeeController::get_client_policy_list_for_remainder/$1"); - $routes->get("send_manual_remainder/(:any)", "DashboardController::sendManualRemainder/$1"); - $routes->get("get_insurer_by_export_templete", "MasterController::getInsurerByExportTemplete"); - $routes->get("copy_insurer_templete/(:any)", "MasterController::copyInsurerTemplete/$1"); }); $routes->cli('cli/processjob', 'JobWorker::processJob'); $routes->cli('cli/processjobs', 'JobWorker::processJobs'); -$routes->cli('cli/updatePolicyEnrollmentStatus', 'DashboardController::updatePolicyEnrollmentStatus'); +$routes->cli('cli/enrollment_status', 'JobWorker::enrollment_status'); $routes->get("processjob", "JobWorker::processJob"); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 2c6111af..b2a638f7 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -1034,7 +1034,7 @@ class ClientController extends AdminController 'parents-in-law'=> $this->request->getPost('parents-in-law'), ]; - if ($policy_grid_id == 1 || $policy_grid_id == 2 || $policy_grid_id == 6 || $policy_grid_id == 7) { + if ($policy_grid_id == 1 || $policy_grid_id == 2 ) { $relation_data = [ 'self' => 1, 'spouse' => 'NA', @@ -1220,7 +1220,6 @@ class ClientController extends AdminController $age_from = $this->request->getPost('5_age_from[]'); $age_to = $this->request->getPost('5_age_to[]'); $unit = $this->request->getPost('5_unit[]'); - for ($i = 0; $i < count($premium); $i++) { $data['premium'] = str_replace(',', '', $premium[$i]); $data['si'] = str_replace(',', '', $sum_insure[$i]); @@ -1427,7 +1426,7 @@ class ClientController extends AdminController } } catch (\Exception $e) { - echo 'Error: ' . $e->getMessage(); + echo 'Error: ' . $e->getMessage(). ' at line no ' . $e->getLine(); } } @@ -2038,10 +2037,10 @@ class ClientController extends AdminController if ($record['open_for_enrollment'] == 0) { $open_for_enrollment_update_value = 1; - $message = 'Enrollment Opened Successfully'; + $message = 'Enrolment Opened Successfully'; } else if ($record['open_for_enrollment'] == 1) { $open_for_enrollment_update_value = 0; - $message = 'Enrollment Closed Successfully'; + $message = 'Enrolment Closed Successfully'; } $data = $this->policesModel->getPolicyPremium($record['policy_id']); @@ -2219,7 +2218,7 @@ class ClientController extends AdminController CASE WHEN client_policy.inception_type = 1 THEN "File Upload" - WHEN client_policy.inception_type = 2 THEN "Enrollment" + WHEN client_policy.inception_type = 2 THEN "Enrolment" ELSE "n/a" END as inception_type, diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index c5556e9a..b0eb77de 100644 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -1511,8 +1511,11 @@ class EmployeeController extends AdminController $client_id = $json->client_id; $policy_id = $json->policy_id; $branch_id = $json->branch_id; + $unit_id = $json->unit_id; + $action = $json->action; + $family_code = $json->emp_code; $tabledata = $json->data; - + $existing_famility_details = []; if(count($tabledata)) { $family_details = []; @@ -1523,7 +1526,7 @@ class EmployeeController extends AdminController { $temp[0] = $row['column1'];//sno - $temp[1] = $row['column2'];//emp code + $temp[1] = $family_code != "" ? $family_code : $row['column2'];//emp code $temp[2] = $row['column3'];//name $temp[3] = $row['column4'];//DOB $temp[4] = strtoupper($row['column5']);//Gender @@ -1540,14 +1543,29 @@ class EmployeeController extends AdminController $temp[15] = '';//RFE $temp[16] = '';//DOE $temp[17] = '';//Unit - $temp[18] = $row['column11'];//unit + $temp[18] = $unit_id;//unit $family_details[] = $temp; } } } - // print_r($family_details); - // return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $family_details], 200); + if($action == 'dependent_addition') + { + $existing_famility_details = $this->employeeModel->getEmpFamilybyEmpCode(emp_code: $family_code,client_id: $client_id,client_policy_id: $policy_id,emp_status: ['active'],policy_status:['active'],client_branch_id: [ $branch_id ]); + // ~dd($this->employeeModel->getLastQuery()); + + if(!count($existing_famility_details)) + { + return $this->respond(['dataStatus' => false, 'code' => 404, 'data' => [],'messgae' => "No Data found for emp code $family_code"], 200); + } + //transsform familiy details from db columns to exxcel row with column indexs for checking remaining functionalitites + $existing_famility_details = transform_db_data_to_excel($existing_famility_details,[]); + // Kint::dump($existing_famility_details); + $family_details = array_merge($family_details,$existing_famility_details); + $family_details = data_group_by_family($family_details)[ $family_code ];// reason to call this again is bring self to first index of the array + // dd($family); + } + //get policy details $policy_details = $this->clientPolicyModel->getPolicyDetails($client_id,$policy_id); $policy_details = (array)$policy_details[0]; @@ -1570,7 +1588,7 @@ class EmployeeController extends AdminController } } - return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $data], 200); + return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => ['new' => $data,'old' => $existing_famility_details], 200]); } } diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 01735912..af9c2f07 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -560,7 +560,7 @@ class EmployeeRestController extends AdminController // Set the header for download - $filename = $empData[0]['policy_name'].'-Enrollment.xlsx'; + $filename = $empData[0]['policy_name'].'-Enrolment.xlsx'; header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment;filename="' . $filename . '"'); header('Cache-Control: max-age=0'); @@ -1015,6 +1015,17 @@ class EmployeeRestController extends AdminController $self['data']['basic_cover_si'] = $employee_policy->basic_cover_si; $array->mapped_family_floaters = $self; + + + + $res = []; + array_push($res,$array); + $EDLIPolicy = $this->getAdditionalGPAPolicy($employeeData,6,$emp_code,$client_id,$client_branch_id); + if($EDLIPolicy){ array_push($res,$EDLIPolicy); } + $GTLIPolicy = $this->getAdditionalGPAPolicy($employeeData,7,$emp_code,$client_id,$client_branch_id); + if($GTLIPolicy){ array_push($res,$GTLIPolicy); } + return $this->respond(['status' => 'success','code' => 200,'data' => $res ], 200); + // Return result if($this->request->getGet('policy') == 'GPA') @@ -1133,8 +1144,8 @@ class EmployeeRestController extends AdminController $array->mapped_family_floaters = $data; $array->type = "Group Medical Coverage"; - $checkGmcParentsPolicyExist = $this->clientPolicyModel->select('client_policy.id as ClientPolicyId , client_policy.client_id as ClientId, policies.id as PolicyId , client_policy.policy_type_id as policy_type_id, policies.name as Policy_Name , client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type , client_policy.policy_terms as Policy_Terms') - ->join('policies', 'client_policy.policy_id = policies.id', 'left') + $checkGmcParentsPolicyExist = $this->clientPolicyModel->select('client_policy.id as ClientPolicyId , client_policy.client_id as ClientId, client_policy.policy_type_id as policy_type_id, policy_type.long_name as Policy_Name , client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type , client_policy.policy_terms as Policy_Terms') + ->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left') ->where('client_policy.policy_type_id', 3 ) ->where('client_policy.is_addon', 1 ) ->where('client_policy.client_id', $this->request->getGet('client_id') ) @@ -1328,6 +1339,70 @@ class EmployeeRestController extends AdminController } + + public function getAdditionalGPAPolicy($empData,$policy_type,$emp_code,$client_id,$client_branch_id) + { + $checkPolicyExist = $this->clientPolicyModel->select('client_policy.id as ClientPolicyId , client_policy.client_id as ClientId, client_policy.policy_type_id as policy_type_id, client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type , client_policy.policy_terms as Policy_Terms , client_policy.enrolment_visibility') + ->where('client_policy.policy_type_id', $policy_type ) + ->where('client_policy.is_addon', 1 ) + ->where('client_policy.client_id', $client_id ) + ->where('client_policy.client_branch_id', $client_branch_id ) + ->where('client_policy.is_active', 1 ) + ->get() + ->getResult(); + + if($checkPolicyExist){ + + foreach ($checkPolicyExist as $key => $array) { + + $decodedArray = json_decode($array->Policy_Terms); + $array->Policy_Terms = $decodedArray; + + + // Filter employee data where the family_floater_key is 'self' + $selfData = array_filter($empData, fn($arr) => trim(strtolower($arr['family_floater_key'])) === 'self'); + $employee_policy = $this->employeePolicyModel->where('employee_id',$selfData[0]['id'])->where('client_policy_id',$array->ClientPolicyId)->where('is_active', 1 )->get()->getRow(); + $policyTypeData = $this->policyTypeModel->where('id',$policy_type)->get()->getRow(); + $array->type = $policyTypeData->policy_type; + $array->Policy_Name = $policyTypeData->long_name; + if($employee_policy){ + + if($employee_policy->tpa_id != null){ + $array->eCardDownload = base_url('download-e-card/') . $employee_policy->rand_string; + }else{ $array->eCardDownload = null; } + + $self['is_value_exist'] = true; + $self['data']['family_floater_key'] = 'self'; + $self['data']['employee_id'] = $selfData[0]['id']; + $self['data']['relationship'] = 'Self'; + $self['data']['name'] = $selfData[0]['name']; + $self['data']['dob'] = $this->convertDateFormatDMY($selfData[0]['dob']); + $self['data']['mobile'] = $selfData[0]['mobile']; + $self['data']['client_policy_id'] = $array->ClientPolicyId; + $self['data']['basic_cover_si'] = $employee_policy->basic_cover_si; + $array->mapped_family_floaters = $self; + + if($array->enrolment_visibility == 1) + return $array; + else + return false; + + }else{ + return false; + } + + + + } + + } + } + + public function getGTLIPolicy($empData,$emp_code,$client_id,$client_branch_id) + { + + } + public function FloterConvertion($array){ $result = []; @@ -1473,8 +1548,9 @@ class EmployeeRestController extends AdminController } - - $responce['policy_name'] = $this->policesModel->where('id',$array['policy_id'])->get()->getRow()->name; + $policyTypeData = $this->policyTypeModel->where('id',$array['policy_type_id'])->get()->getRow(); + $responce['policy_name'] = $policyTypeData->long_name; + $responce['type'] = $policyTypeData->policy_type; $responce['SlabRates'] = $uniqueData; $responce['GridMaster'] = $getSlabAndGridData['grid_master']; $responce['client_id'] = $array['client_id']; @@ -1934,8 +2010,8 @@ class EmployeeRestController extends AdminController $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 , client_policy.policy_type_id as policy_type_id, policies.name as policy_name , client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type ') - ->join('policies', 'client_policy.policy_id = policies.id', 'left') + $ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, client_policy.policy_type_id as policy_type_id, client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type ') + ->where('client_policy.insurer_id', $value['insurerId'] ) ->where('client_policy.client_id', $this->request->getGet('client_id') ) ->where('client_policy.client_branch_id', $this->request->getGet('client_branch_id') ) @@ -1945,8 +2021,9 @@ class EmployeeRestController extends AdminController // dd( $ClientPolicyData); foreach ($ClientPolicyData as $key => $value) { - - $value['type'] = $this->policyTypeModel->where('id',$value['policy_type_id'])->get()->getRow()->policy_type; + $policyTypeData = $this->policyTypeModel->where('id',$value['policy_type_id'])->get()->getRow(); + $value['type'] = $policyTypeData->policy_type; + $value['policy_name'] = $policyTypeData->long_name; $employeeDetails = $this->employeePolicyModel->getEmployeePolicy( client_id:$value['client_id'],policy_id: $value['client_policy_id'],status:0,branch_id:$this->request->getGet('client_branch_id')); $enrolledCount = 0; $draftCount = 0; diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index f31460b2..264a8aa4 100644 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -1654,6 +1654,10 @@ class EmployeeServiceController extends AdminController }// if end }// is array check end + else + { + $this->myLogger->logme('error','######Incoming value is not an array'); + } }// for end }//function end diff --git a/app/Controllers/JobWorker.php b/app/Controllers/JobWorker.php index 5c099fe8..a0d5f694 100644 --- a/app/Controllers/JobWorker.php +++ b/app/Controllers/JobWorker.php @@ -6,6 +6,7 @@ namespace App\Controllers; use App\Models\JobModel; +use App\Models\FileModel; class JobWorker extends AdminController { const STATUS_DONE = 'done'; @@ -287,23 +288,24 @@ class JobWorker extends AdminController try { $response = $jobHandler($payload,$job->id); + $job_status = self::STATUS_DONE; } catch(\Exception $e) { $job_status = self::STATUS_FAILED; $runtime = $runtime === null ? microtime(true) - $start : $runtime; - $response = ['file_name' => $e->getFile(),'error' => $e->getMessage(),'line_no' => $e->getLine(),'info' => $e->getTraceAsString()]; + $response = ['file_name' => $e->getFile(),'error' => $e->getMessage(),'line_no' => $e->getLine(),'info' => $e->getTraceAsString(),'scope' => 'task failed']; } $runtime = microtime(true) - $start; - $job_status = self::STATUS_DONE; + } catch (\Exception $e) { //die(); $job_status = self::STATUS_FAILED; $runtime = $runtime === null ? microtime(true) - $start : $runtime; - $response = ['file_name' => $e->getFile(),'error' => $e->getMessage(),'line_no' => $e->getLine(),'info' => $e->getTraceAsString()]; + $response = ['file_name' => $e->getFile(),'error' => $e->getMessage(),'line_no' => $e->getLine(),'info' => $e->getTraceAsString(),'scope' => 'worker failed']; } $db->query("UPDATE jobs SET status=?, run_time=?, response=? WHERE id=? AND uuid=?", [ @@ -313,6 +315,21 @@ class JobWorker extends AdminController $job->id,$job->uuid ]); + //update file status if this job is directly linked with a file id + + if($job_status == self::STATUS_FAILED) + { + //get file from job payload + if(array_key_exists('file_id', $payload) && $payload['file_id'] != NULL && $payload['file_id'] != "" && is_numeric($payload['file_id']) && count($payload) == 1) + { + $fileModel = new FileModel(); + $fileModel->where('id', $payload['file_id']) + ->set(['status' => 'failed','reason' => json_encode(['error_type' => 0,'error_summary' => [0],'error_data' => 'System Error, please contact Admin/Support team']) ]) + ->update(); + } + + } + // echo "Job $job->id $job_status. Response - $response \n"; // echo "Job $job->id $job_status \n"; SELF::streamOutput("Job $job->id $job_status \n"); diff --git a/app/Models/EmployeeModel.php b/app/Models/EmployeeModel.php index e0e29c14..e64a4d63 100644 --- a/app/Models/EmployeeModel.php +++ b/app/Models/EmployeeModel.php @@ -149,9 +149,9 @@ class EmployeeModel extends Model { return $this->db->table('employee_polices') - ->select(' policies.name as Policy_Name , client_policy.policy_terms as Policy_Terms, client_policy.client_id as ClientId, client_policy.policy_id as PolicyId,client_policy.id as ClientPolicyId, client_policy.open_for_enrollment as OpenForEnrollment , employee_polices.tpa_id as tpa_id , employee_polices.rand_string as rand_string') // Select all columns from both tables + ->select(' policy_type.long_name as Policy_Name , client_policy.policy_terms as Policy_Terms, client_policy.client_id as ClientId, client_policy.policy_id as PolicyId,client_policy.id as ClientPolicyId, client_policy.open_for_enrollment as OpenForEnrollment , employee_polices.tpa_id as tpa_id , employee_polices.rand_string as rand_string') // Select all columns from both tables ->join('client_policy', 'client_policy.id = employee_polices.client_policy_id') - ->join('policies', 'policies.id = client_policy.policy_id') + ->join('policy_type', 'policy_type.id = client_policy.policy_type_id') ->where('client_policy.policy_status', 1) ->where('employee_polices.employee_id', $id) ->get() diff --git a/app/Views/cd_master_list.php b/app/Views/cd_master_list.php index 04a52784..cf0f19e8 100644 --- a/app/Views/cd_master_list.php +++ b/app/Views/cd_master_list.php @@ -241,6 +241,10 @@ table.dataTable thead th { $('#opening_bal').val(''); $('#CDMasterForm')[0].reset(); $('#CDMasterForm').parsley().reset(); + $('#client_id').prop("disabled", false); + $('#insurer_id').prop("disabled", false); + $('#cd_ac_no').prop("disabled", false); + }) @@ -261,9 +265,12 @@ table.dataTable thead th { $('#CDMasterForm').attr('action', ''); $('#CD_Master_ID').val(res.data.id); $('#client_id').val(res.data.client_id).change(); + $('#client_id').prop("disabled", true); $('#insurer_id').val(res.data.insurer_id).change(); + $('#insurer_id').prop("disabled", true); $('#opening_date').val(res.data.opening_date); $('#cd_ac_no').val(res.data.cd_ac_no); + $('#cd_ac_no').prop("disabled", true); $('#opening_bal').val(res.data.opening_bal); $('#btnSubmit').html('Update'); @@ -279,6 +286,10 @@ table.dataTable thead th { $('#cd_ac_no').change(function(){ var cd_ac_no = $(this).val(); + console.log(cd_ac_no +'-'+cd_ac_no.length); + cd_ac_no = cd_ac_no.trim(); + console.log(cd_ac_no +'-'+cd_ac_no.length); + $.ajax({ url: ''+cd_ac_no, diff --git a/app/Views/client_info.php b/app/Views/client_info.php index 879eceea..485684dc 100644 --- a/app/Views/client_info.php +++ b/app/Views/client_info.php @@ -129,7 +129,7 @@