diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 9e8fd8e1..3e79d7a7 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -146,6 +146,7 @@ $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"); }); diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php index b1ed384e..220c7468 100644 --- a/app/Controllers/DashboardController.php +++ b/app/Controllers/DashboardController.php @@ -57,15 +57,6 @@ class DashboardController extends AdminController $pendingActionsController = new PendingActionsController; $pendingActionsData = $pendingActionsController->getPendingActionsForDashBoard(); - $results = $this->clientModel->select('clients.id as client_id, clients.client_name, clients.short_name, - client_branch.id as client_branch_id, client_branch.branch_name, - client_branch.branch_code, employees.id as employee_id, - employees.name as employee_name, employees.relationship, - employees.emp_code, employees.emp_status, auth_history.user_type') - ->join('client_branch', 'clients.id = client_branch.client_id', 'left') - ->join('employees', 'client_branch.id = employees.client_branch_id', 'left') - ->join('auth_history', 'employees.id = auth_history.user_id AND "employee" = auth_history.user_type', 'left') - ->findAll(); $groupedData = []; diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 2e538bf2..82328ba1 100644 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -1495,6 +1495,7 @@ class EmployeeController extends AdminController public function testRackRate() { + helper('excel_util_helper'); if ($this->request->getMethod() == 'get') { $filterData = $this->request->getGet('client_policy_id'); //just load UI only @@ -1545,27 +1546,99 @@ class EmployeeController extends AdminController } // print_r($family_details); - return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $family_details], 200); - //get file array or construnct dummy file array here - $file = ['id' => null,'client_id' => 10,'policy_id' => 10,'action' => 'inception','client_branch_id' => 1,'created_by' => 1]; + // return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $family_details], 200); //get policy details - $policy_details = $this->clientPolicyModel->getPolicyDetails($file['client_id'],$file['policy_id']); - //get rack rates - $slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($file['policy_id'],$file['client_id']); - + $policy_details = $this->clientPolicyModel->getPolicyDetails($client_id,$policy_id); + $policy_details = (array)$policy_details[0]; + // ~dd($policy_details[0]->policy_start_date); + //get rack rates + $slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($policy_id,$client_id); + //get file array or construnct dummy file array here + $file = ['id' => null,'client_id' => $client_id,'policy_id' => $policy_id,'action' => 'inception','client_branch_id' => $branch_id,'created_by' => 1]; + //get existing units in the current branch + $existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $client_id,client_branch_id: $branch_id); //get familiy details in inception file format array from post method - $family_details = [ - [2,'TEST001','John Doe', '01-Jan-1988', 'M', 'Self', '5000000', NULL, '', '', 'G', '', '', '', '', '', '',''], - [1,'TEST001','Jane Doe', '01-Jan-1985', 'F', 'Spouse', 5000000, '01-Jan-2024', '01-Jan-2020', 50000, 'A', 'Manager', '1234567890', 'john.doe@example.com', '0', '', '', ''], - - // [3,'TEST001','Peter Doe', '01-Jan-1955', 'M', 'Father', '', NULL, '', '', '', '', '', '', '', '', '',''], - [4,'TEST001','Mary Doe', '01-Jan-1953', 'F', 'Mother', '', NULL, '', '', '', '', '', '', '', '', '',''], - [5,'TEST001','Grace Doe', '01-Jan-1954', 'F', 'Mother in law', '', NULL, '', '', '', '', '', '', '', '', '',''], - //[6,'TEST001','George Doe', '01-Jan-1948', 'M', 'Father in law', '', NULL, '', '', '', '', '', '', '', '', '',''], - [7,'TEST001','Alice Doe', '01-Jan-1990', 'F', 'Daughter', 5000000, '01-Jan-2024', '01-Jan-2024', 40000, 'B', 'Supervisor', '9876543210', '', '', '', '',''], - [6,'TEST001','Bob Doe', '01-Jan-1993', 'M', 'son', '50000', NULL, '', '', '', '', '', '', '', '', '',''], - ]; - // $data = calculate_premimum_new($family_details,$policy_details,$all_rack_rates,$file); + $data = calculate_premium_new(family_data: $family_details,policy_terms:$policy_details,slab_details:$slab_details,fileArr: $file,existing_units: $existing_units); + + foreach($data as $key => $member ) + { + // ~dd($member); + $data[$key]['policy_details']['no_of_days'] = $member['policy_details']['date_coverage'] ? (calculate_days_bw_dates($member['policy_details']['date_coverage'],$member['policy_details']['policy_end_date'])->days + 1) : ''; + } + + return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $data], 200); + } + } + + + public function testCheckDependentConflict() + { + helper('excel_util_helper'); + if ($this->request->getMethod() == 'get') { + $filterData = $this->request->getGet('client_policy_id'); + //just load UI only + $this->loadLayout('rack_rate_test'); + } + + + if ($this->request->getMethod() == 'post') { + $json = $this->request->getJSON(); + // return $this->respond(['dataStatus' => false, 'code' => 200, 'data' => $data], 200); + // $data = (json_decode(json_encode($data),true)); + $client_id = $json->client_id; + $policy_id = $json->policy_id; + $branch_id = $json->branch_id; + $tabledata = $json->data; + + if(count($tabledata)) + { + $family_details = []; + foreach($tabledata as $key => $row) + { + $row = (array)$row; + if(!$row['column12']) + { + + $temp[0] = $row['column1'];//sno + $temp[1] = $row['column2'];//emp code + $temp[2] = $row['column3'];//name + $temp[3] = $row['column4'];//DOB + $temp[4] = strtoupper($row['column5']);//Gender + $temp[5] = $row['column6'];//relation + $temp[6] = $row['column7'];//SI + $temp[7] = $row['column8'];//DOC + $temp[8] = '';//DOJ + $temp[9] = $row['column9'];//BP + $temp[10] = $row['column10'];//band + $temp[11] = '';//designation + $temp[12] = '';//mobile + $temp[13] = '';//EMail + $temp[14] = '';//CE + $temp[15] = '';//RFE + $temp[16] = '';//DOE + $temp[17] = '';//Unit + $temp[18] = $row['column11'];//unit + $family_details[] = $temp; + } + } + } + + // print_r($family_details); + // return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $family_details], 200); + //get policy details + $policy_details = $this->clientPolicyModel->getPolicyDetails($client_id,$policy_id); + $policy_terms = (array)$policy_details[0]; + // dd($policy_terms); + $policy_terms = json_decode($policy_terms['policy_terms']); + $policy_terms = (array) $policy_terms;// convert obj to array + + //get file array or construnct dummy file array here + $file = ['id' => null,'client_id' => $client_id,'policy_id' => $policy_id,'action' => 'inception','client_branch_id' => $branch_id,'created_by' => 1]; + //get familiy details in inception file format array from post method + $result = check_dependent_conflict($family_details, $policy_terms, $file['action']); + + + return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => ['policy_terms' => $policy_terms['family_floaters'],'result' => $result] ], 200); } } diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index 87eb818d..f31460b2 100644 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -1272,7 +1272,7 @@ class EmployeeServiceController extends AdminController // die(); - return (($employee_data_group_by_family)); + return (count($employee_data_group_by_family)); } diff --git a/app/Controllers/JobWorker.php b/app/Controllers/JobWorker.php index f5b40c04..5c099fe8 100644 --- a/app/Controllers/JobWorker.php +++ b/app/Controllers/JobWorker.php @@ -5,7 +5,7 @@ namespace App\Controllers; - +use App\Models\JobModel; class JobWorker extends AdminController { const STATUS_DONE = 'done'; diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php index a1edcba9..0f3fd7d0 100644 --- a/app/Helpers/excel_util_helper.php +++ b/app/Helpers/excel_util_helper.php @@ -1011,7 +1011,7 @@ if (!function_exists('transform_excel_data_to_db')) // $policy['reason_for_exit'] = $memArr[17]; $policy['client_policy_id'] = $actionArr['policy_id']; - $policy['date_coverage'] = isset($memArr[7]) ? convert_string_to_date($memArr[7],'Y-m-d') : NULL; + $policy['date_coverage'] = isset($memArr[7]) && $memArr[7] != '' ? convert_string_to_date($memArr[7],'Y-m-d') : NULL; $policy['policy_end_date'] = null; $policy['days'] = null; $policy['premium'] = null; diff --git a/app/Models/ClientModel.php b/app/Models/ClientModel.php index a43c1812..b6101356 100644 --- a/app/Models/ClientModel.php +++ b/app/Models/ClientModel.php @@ -82,7 +82,7 @@ class ClientModel extends Model $client['policies'] = $clientPolicies; $clientBranchModel = new ClientBranchModel(); - $clientBranchs = $clientBranchModel->select(['client_branch.id','client_branch.branch_name','client_branch.branch_code', 'client_branch.client_id']) + $clientBranchs = $clientBranchModel->select(['client_branch.id','client_branch.branch_name','client_branch.branch_code', 'client_branch.client_id','client_branch.units']) ->where('client_branch.client_id',$client['id']) ->findAll(); diff --git a/app/Views/enrollment_dash.php b/app/Views/enrollment_dash.php index f0c1fb79..1a5ba2d9 100644 --- a/app/Views/enrollment_dash.php +++ b/app/Views/enrollment_dash.php @@ -9,6 +9,8 @@ + +