Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
0bbab27c2f
@ -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,21 @@ 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]);
|
||||
$this->myLogger->logme("error", '{file_id} is less than 1MB, validating on the fly', ['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]]);
|
||||
$this->myLogger->logme("error", '{file_id} is greather than 1MB, validating with job queue', ['file_id' => $file_id]);
|
||||
}
|
||||
|
||||
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => 'file upload success'], 200);
|
||||
@ -825,18 +837,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'));
|
||||
}
|
||||
|
||||
@ -1320,10 +1320,10 @@ class EmployeeServiceController extends AdminController
|
||||
$row[4] = change_date_format($row[4],'d-M-Y','Y-m-d');// date of exit from excel
|
||||
// Kint::dump($row[4]);
|
||||
// check if insurer configured with add one day for deletion
|
||||
if($insurer['deletion_add_day'] == true)
|
||||
{
|
||||
$row[4] = (new \DateTime($row[4]))->modify('+1 day')->format('Y-m-d');
|
||||
}
|
||||
// if($insurer['deletion_add_day'] == true)
|
||||
// {
|
||||
// $row[4] = (new \DateTime($row[4]))->modify('+1 day')->format('Y-m-d');
|
||||
// }
|
||||
// dd($row[4]);
|
||||
//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,'file_id' => $file['id'],'status' => 'pending']);
|
||||
@ -1355,6 +1355,7 @@ class EmployeeServiceController extends AdminController
|
||||
->where('emp_code',$employee['emp_code'])
|
||||
->where('name',$employee['name'])
|
||||
->where('field_name','emp_status')
|
||||
->where('status !=','truncated')
|
||||
->findAll();
|
||||
|
||||
// dd($existing_endorsements);
|
||||
@ -1444,7 +1445,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')
|
||||
@ -1959,7 +1967,8 @@ public function employeesEnrollmentInsert($params)
|
||||
$allowedHighestColumn = end($columns_to_check);
|
||||
$excel_data = $sheet->rangeToArray('A1:' . $allowedHighestColumn['col_cell_name'] . $highestRowAndColumn['row']);
|
||||
// print_r($keys);die();
|
||||
|
||||
//get existing units in the current branch
|
||||
$existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $file['client_id'],client_branch_id: $file['client_branch_id']);
|
||||
//remove header
|
||||
unset($excel_data[0]);
|
||||
// dd($excel_data);
|
||||
@ -1975,6 +1984,11 @@ public function employeesEnrollmentInsert($params)
|
||||
// dd($key.'-'.count($excel_data));
|
||||
$value = [];
|
||||
$policy_data = [];
|
||||
$temp_unit = '';
|
||||
if(empty($row[12]))
|
||||
{
|
||||
$temp_unit = $existing_units[0];
|
||||
}
|
||||
|
||||
$value['emp_code'] = $row[1];
|
||||
$value['name'] = $row[2];
|
||||
@ -1986,7 +2000,7 @@ public function employeesEnrollmentInsert($params)
|
||||
$value['mobile'] = $row[8];
|
||||
$value['band'] = $row[10];
|
||||
$value['basic_pay'] = $row[11];
|
||||
$value['unit'] = $row[12];
|
||||
$value['unit'] = $temp_unit;
|
||||
$value['family_floater_key'] = null;
|
||||
$value['client_id'] = $file['client_id'];
|
||||
$value['client_branch_id'] = $file['client_branch_id'];
|
||||
|
||||
@ -511,10 +511,10 @@ if (!function_exists('name_and_empid_check_in_db'))
|
||||
->where("ep.is_active",1)
|
||||
->where("ep.status",'active')
|
||||
// ->where("ep.client_id",$client_id)
|
||||
->where('name',$row[2])->where('emp_code',$row[1])
|
||||
->where('name',trim($row[2]))->where('emp_code',trim($row[1]))
|
||||
->findAll();
|
||||
|
||||
// dd($employeeModel->getLastQuery());
|
||||
// kint::dump($employeeModel->getLastQuery()->getQuery());
|
||||
|
||||
|
||||
if(($current_action == 'deletion' || $current_action == 'correction' || $current_action == 'si_enhancement') && !count($res))
|
||||
@ -2021,6 +2021,12 @@ if(!function_exists('check_unit'))
|
||||
{
|
||||
return array('status' => true);
|
||||
}
|
||||
else if($temp != $existing_units[0])
|
||||
{
|
||||
return array('status' => false,'error' => 'wrong unit name');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(strtolower($row[5]) == 'self')
|
||||
|
||||
@ -631,19 +631,19 @@ class EmployeePolicyModel extends Model
|
||||
|
||||
LEFT JOIN(
|
||||
|
||||
select aa.emp_code, aa.new_value as 'empstatus', bb.new_value as 'changeevent', cc.new_value as 'dateofexit', dd.new_value as 'reasonforexit', ee.new_value as 'status' from
|
||||
select aa.emp_code, aa.new_value as 'empstatus', bb.new_value as 'changeevent', cc.new_value as 'dateofexit', dd.new_value as 'reasonforexit', ee.new_value as 'status' from
|
||||
|
||||
( SELECT a1.emp_code, a1.field_name, a1.new_value from emp_endorsement as a1 where a1.field_name = 'emp_status') aa
|
||||
( SELECT a1.emp_code, a1.field_name, a1.new_value from emp_endorsement as a1 where a1.field_name = 'emp_status' and a1.status != 'truncated') aa
|
||||
left join
|
||||
( SELECT b1.emp_code, b1.field_name, b1.new_value from emp_endorsement as b1 where b1.field_name = 'change_event') bb on aa.emp_code = bb.emp_code
|
||||
( SELECT b1.emp_code, b1.field_name, b1.new_value from emp_endorsement as b1 where b1.field_name = 'change_event' and b1.status != 'truncated') bb on aa.emp_code = bb.emp_code
|
||||
left join
|
||||
( SELECT c1.emp_code, c1.field_name, c1.new_value from emp_endorsement as c1 where c1.field_name = 'date_of_exit') cc on aa.emp_code = cc.emp_code
|
||||
( SELECT c1.emp_code, c1.field_name, c1.new_value from emp_endorsement as c1 where c1.field_name = 'date_of_exit' and c1.status != 'truncated') cc on aa.emp_code = cc.emp_code
|
||||
left join
|
||||
( SELECT d1.emp_code, d1.field_name, d1.new_value from emp_endorsement as d1 where d1.field_name = 'reason_for_exit') dd on aa.emp_code = dd.emp_code
|
||||
( SELECT d1.emp_code, d1.field_name, d1.new_value from emp_endorsement as d1 where d1.field_name = 'reason_for_exit' and d1.status != 'truncated') dd on aa.emp_code = dd.emp_code
|
||||
left JOIN
|
||||
( SELECT e1.emp_code, e1.field_name, e1.new_value from emp_endorsement as e1 where e1.field_name = 'status') ee on aa.emp_code = ee.emp_code
|
||||
( SELECT e1.emp_code, e1.field_name, e1.new_value from emp_endorsement as e1 where e1.field_name = 'status' and e1.status != 'truncated') ee on aa.emp_code = ee.emp_code
|
||||
|
||||
) as deletiondata on a.emp_code = deletiondata.emp_code
|
||||
) as deletiondata on a.emp_code = deletiondata.emp_code and a.status != 'truncated'
|
||||
|
||||
LEFT JOIN
|
||||
(
|
||||
@ -665,6 +665,7 @@ class EmployeePolicyModel extends Model
|
||||
AND employees.client_branch_id = {$client_branch_id}
|
||||
$endorsement_condition
|
||||
AND a.actions = 'd'
|
||||
AND a.status != 'truncated'
|
||||
AND employee_polices.is_active = 1
|
||||
AND employees.is_active = 1
|
||||
AND $status_condition
|
||||
@ -864,21 +865,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);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user