private function getLeaveRule($employee,$leaveType){ $rule = null; $leaveRule = new LeaveRule(); $leaveTypeObj = new LeaveType(); $rules = $leaveRule->Find("employee = ? and leave_type = ?",array($employee->id,$leaveType)); if(count($rules)>0){ return $rules[0]; } $rules = $leaveRule->Find("job_title = ? and employment_status = ? and leave_type = ? and employee is null",array($employee->job_title,$employee->employment_status,$leaveType)); if(count($rules)>0){ return $rules[0]; } $rules = $leaveRule->Find("job_title = ? and employment_status is null and leave_type = ? and employee is null",array($employee->job_title,$leaveType)); if(count($rules)>0){ return $rules[0]; } $rules = $leaveRule->Find("job_title is null and employment_status = ? and leave_type = ? and employee is null",array($employee->employment_status,$leaveType)); if(count($rules)>0){ return $rules[0]; } $rules = $leaveTypeObj->Find("id = ?",array($leaveType)); if(count($rules)>0){ return $rules[0]; } }
private function getLeaveRuleOnly($employee, $leaveType) { $rule = null; $leaveRule = new LeaveRule(); $leaveTypeObj = new LeaveType(); $rules = $leaveRule->Find("employee = ? and leave_type = ?", array($employee->id, $leaveType)); if (count($rules) > 0) { return $rules[0]; } //Check whether this employee has a leave group $leaveGroupId = $this->getEmployeeLeaveGroup($employee->id); if (!empty($leaveGroupId)) { $rules = $leaveRule->Find("leave_group = ? and leave_type = ?", array($leaveGroupId, $leaveType)); if (count($rules) > 0) { return $rules[0]; } $rules = $leaveRule->Find("leave_group = ? and job_title = ? and employment_status = ? and leave_type = ? and employee is null", array($leaveGroupId, $employee->job_title, $employee->employment_status, $leaveType)); if (count($rules) > 0) { return $rules[0]; } $rules = $leaveRule->Find("leave_group = ? and job_title = ? and employment_status is null and leave_type = ? and employee is null", array($leaveGroupId, $employee->job_title, $leaveType)); if (count($rules) > 0) { return $rules[0]; } $rules = $leaveRule->Find("leave_group = ? and job_title is null and employment_status = ? and leave_type = ? and employee is null", array($leaveGroupId, $employee->employment_status, $leaveType)); if (count($rules) > 0) { return $rules[0]; } $rules = $leaveTypeObj->Find("leave_group = ? and id = ?", array($leaveGroupId, $leaveType)); if (count($rules) > 0) { return $rules[0]; } } $rules = $leaveRule->Find("job_title = ? and employment_status = ? and leave_type = ? and employee is null", array($employee->job_title, $employee->employment_status, $leaveType)); if (count($rules) > 0) { return $rules[0]; } $rules = $leaveRule->Find("job_title = ? and employment_status is null and leave_type = ? and employee is null", array($employee->job_title, $leaveType)); if (count($rules) > 0) { return $rules[0]; } $rules = $leaveRule->Find("job_title is null and employment_status = ? and leave_type = ? and employee is null", array($employee->employment_status, $leaveType)); if (count($rules) > 0) { return $rules[0]; } $rules = $leaveTypeObj->Find("id = ?", array($leaveType)); if (count($rules) > 0) { return $rules[0]; } }
Nationality::SetDatabaseAdapter($dbLocal); Employee::SetDatabaseAdapter($dbLocal); User::SetDatabaseAdapter($dbLocal); EmployeeSkill::SetDatabaseAdapter($dbLocal); EmployeeEducation::SetDatabaseAdapter($dbLocal); EmployeeCertification::SetDatabaseAdapter($dbLocal); EmployeeLanguage::SetDatabaseAdapter($dbLocal); EmergencyContact::SetDatabaseAdapter($dbLocal); EmployeeDependent::SetDatabaseAdapter($dbLocal); EmployeeImmigration::SetDatabaseAdapter($dbLocal); EmployeeSalary::SetDatabaseAdapter($dbLocal); LeaveType::SetDatabaseAdapter($dbLocal); LeavePeriod::SetDatabaseAdapter($dbLocal); WorkDay::SetDatabaseAdapter($dbLocal); HoliDay::SetDatabaseAdapter($dbLocal); LeaveRule::SetDatabaseAdapter($dbLocal); EmployeeLeave::SetDatabaseAdapter($dbLocal); EmployeeLeaveDay::SetDatabaseAdapter($dbLocal); File::SetDatabaseAdapter($dbLocal); Client::SetDatabaseAdapter($dbLocal); Project::SetDatabaseAdapter($dbLocal); EmployeeTimeSheet::SetDatabaseAdapter($dbLocal); EmployeeTimeEntry::SetDatabaseAdapter($dbLocal); EmployeeProject::SetDatabaseAdapter($dbLocal); Document::SetDatabaseAdapter($dbLocal); EmployeeDocument::SetDatabaseAdapter($dbLocal); CompanyLoan::SetDatabaseAdapter($dbLocal); EmployeeCompanyLoan::SetDatabaseAdapter($dbLocal); Setting::SetDatabaseAdapter($dbLocal); ChiNhanh::SetDatabaseAdapter($dbLocal); Ca::SetDatabaseAdapter($dbLocal);