diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 38329a0..9bab925 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -275,6 +275,7 @@ class EmployeeRestController extends AdminController $item->gender = $this->GenderMap($item->relationship , $item->emp_code); $item->dob = $this->convertDateFormatYMD($item->dob); $item->emp_status = 'draft'; + $item->band = $this->getSelfBand($item->emp_code,$item->client_id,$item->client_branch_id); // dd($item); $employee = $this->employeeModel->insert($item); @@ -312,6 +313,22 @@ class EmployeeRestController extends AdminController } + public function getSelfBand(string $emp_code, int $client_id, int $client_branch_id): ?string + { + $employee = $this->employeeModel + ->where('emp_code', $emp_code) + ->where('client_id', $client_id) + ->where('client_branch_id', $client_branch_id) + ->whereIn('emp_status', ['draft', 'enrolled']) + ->where('is_active', 1) + ->where('relationship','Self') + ->first(); + + return $employee['band'] ?? null; + } + + + public function getEmployeePayableValue($client_policy_id,$relationship) { $terms = $this->clientPolicyModel->where('id',$client_policy_id)->get()->getRow()->policy_terms;