From 98cadc7f73b423d3c6354b15cae9ef7ca087d759 Mon Sep 17 00:00:00 2001 From: velz Date: Tue, 19 Nov 2024 14:09:25 +0530 Subject: [PATCH 1/4] FIX_LIVE_ISSUES --- app/Controllers/EmployeeController.php | 30 ++++++++++++------- app/Controllers/EmployeeServiceController.php | 9 +++++- app/Models/EmployeePolicyModel.php | 11 ++++--- app/Views/employee_data_list.php | 2 +- 4 files changed, 36 insertions(+), 16 deletions(-) diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 810798af..dd202b3e 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -212,6 +212,7 @@ class EmployeeController extends AdminController //validate uploaded file $filename = ''; + $fileSize = ''; $validated = $this->validate([ 'emplist' => [ 'uploaded[emplist]', @@ -231,6 +232,8 @@ class EmployeeController extends AdminController $is_moved = $avatar->move(WRITEPATH . 'uploads/excel/'); if ($is_moved) { $filename = $avatar->getName(); + $fileSize = $avatar->getSize(); // File size in bytes + $fileSize = $fileSize / (1024 * 1024); // Convert to MB // Handle successful upload, e.g., log success or further processing $this->myLogger->logme("error", 'File move successful'); @@ -258,12 +261,19 @@ class EmployeeController extends AdminController $this->myLogger->logme("error", '{file_id} uploaded success', ['file_id' => $file_id]); //start validation process - - $empServiceController = new EmployeeServiceController(); - $result = $empServiceController->excelFileFormatValidation(['file_id' => $file_id]); - //endof validation process - if (isset($result['error_summary']) && count($result['error_summary'])) { - return $this->respond(['dataStatus' => false, 'code' => 404, 'message' => 'file rejected with errors'], 200); + if($fileSize < 1) // if file size less than 1 + { + $empServiceController = new EmployeeServiceController(); + $result = $empServiceController->excelFileFormatValidation(['file_id' => $file_id]); + //endof validation process + if (isset($result['error_summary']) && count($result['error_summary'])) { + return $this->respond(['dataStatus' => false, 'code' => 404, 'message' => 'file rejected with errors'], 200); + } + } + else //if file size greater than 1 add the file as job + { + $job_details = new Jobs(); + $r = Jobs::addJob(['job_name' => 'excelFileFormatValidation','payload' => ['file_id' => $file_id]]); } return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => 'file upload success'], 200); @@ -825,18 +835,18 @@ class EmployeeController extends AdminController // client_policy_id pull draft and enrolled status employees and proceed to calculatin and make entry in DB public function initiateManualEmployeesOnboardProcess($client_policy_id) { - $client_data = $this->clientPolicyModel->select('clients.client_name as client_name, policies.name as policy_name,client_branch_id') + $client_data = $this->clientPolicyModel->select('clients.client_name as client_name,client_branch_id') ->join('clients', 'clients.id = client_policy.client_id') - ->join('policies', 'policies.id = client_policy.policy_id') + // ->join('policies', 'policies.id = client_policy.policy_id') ->where('client_policy.id', $client_policy_id) ->first(); - + // dd($client_data); $empServiceController = new EmployeeServiceController(); $res = $empServiceController->employeesOnboardPreprocess(['client_policy_id' => $client_policy_id,'client_branch_id' => $client_data['client_branch_id']]); // dd($res); $count = ($res); - $message = $count . ' Employees are Initiate Onboard Process againts Client ' . $client_data['client_name'] . ' and the Policy is ' . $client_data['policy_name']; + $message = $count . ' Employees are Initiate Onboard Process againts Client ' . $client_data['client_name'] . ' and the Policy is ' .$client_policy_id; session()->setFlashdata('success1', $message); return redirect()->to(base_url('/employee/upload')); } diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index c4565c6c..506b33e8 100755 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -1444,7 +1444,14 @@ class EmployeeServiceController extends AdminController $field_value = ($field_name == 'dob' ? change_date_format($row[4],'d-M-Y','Y-m-d') : $row[4] ); - $employee = $this->employeeModel->where('emp_code', $row[1])->where('name',$row[2])->where('client_id',$file['client_id'])->where('client_branch_id',$file['client_branch_id'])->first(); + $employee = $this->employeeModel + ->where('emp_code', $row[1]) + ->where('name',$row[2]) + ->where('client_id',$file['client_id']) + ->where('client_branch_id',$file['client_branch_id']) + ->where('emp_status','active') + ->where('is_active',1) + ->first(); $existing_endorsements = $this->empEndorsementModel->where('actions','c') ->where('table_name','employees') ->where('endorsement_id is null') diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 688b8abf..07a2eb59 100755 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -861,21 +861,24 @@ class EmployeePolicyModel extends Model public function getEmployeePolicyForFileList($client_id, $policy_id) { - $result = $this->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']) + $result = $this->select(['employee_polices.*','pt.policy_type','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('employees emp', 'employee_polices.employee_id = emp.id') ->join('client_policy cp', 'employee_polices.client_policy_id = cp.id') //cp - client policy - ->join('policies pm', 'cp.policy_id = pm.id') //pm - policy master + ->join('policy_type pt', 'cp.policy_type_id = pt.id') //pm - policy master ->join('insurers im', 'cp.insurer_id = im.id') //im - insurar master ->join('insurer_branch ib', 'cp.insurer_branch_id = ib.id') //ib - insurar branch ->join('tpa tpam', 'cp.tpa_id = tpam.id') //tpam - tpa master ->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.client_policy_id',$policy_id) + ->where('employee_polices.is_active',1) + ->where('emp.is_active',1); $result->whereIn('employee_polices.status', ['enrolled']); $result->whereIn('emp.emp_status', ['enrolled']); - $result = $result->findAll(); + $result = $result->findAll(); + // print_r($this->db->getLastQuery()); return ($result); } diff --git a/app/Views/employee_data_list.php b/app/Views/employee_data_list.php index 8ca32f6b..40bc5cd0 100755 --- a/app/Views/employee_data_list.php +++ b/app/Views/employee_data_list.php @@ -142,7 +142,7 @@