function isEligible($user_id) { if ($user_id == '') { return FALSE; } //$this->getHolidayPolicyObject(); $ulf = new UserListFactory(); $user_obj = $ulf->getById($user_id)->getCurrent(); $slf = new ScheduleListFactory(); $udtlf = new UserDateTotalListFactory(); //Make sure the employee has been employed long enough according to labor standards //Also make sure that the employee hasn't been terminated on or before the holiday. if ($user_obj->getHireDate() <= $this->getDateStamp() - $this->getHolidayPolicyObject()->getMinimumEmployedDays() * 86400 and ($user_obj->getTerminationDate() == '' or $user_obj->getTerminationDate() != '' and $user_obj->getTerminationDate() > $this->getDateStamp())) { Debug::text('Employee has been employed long enough!', __FILE__, __LINE__, __METHOD__, 10); if ($this->getHolidayPolicyObject()->getType() == 20 or $this->getHolidayPolicyObject()->getType() == 30) { if ($this->getHolidayPolicyObject()->getWorkedScheduledDays() == TRUE and $this->getHolidayPolicyObject()->getMinimumWorkedDays() > 0 and $this->getHolidayPolicyObject()->getMinimumWorkedPeriodDays() > 0) { Debug::text('aUsing scheduled days!', __FILE__, __LINE__, __METHOD__, 10); $slf->getByUserIdAndTypeAndDirectionFromDate($user_obj->getId(), 10, 'before', $this->getDateStamp(), $this->getHolidayPolicyObject()->getMinimumWorkedPeriodDays()); if ($slf->getRecordCount() > 0) { //Get user_date_ids foreach ($slf as $s_obj) { $scheduled_user_date_ids_before[] = $s_obj->getUserDateID(); } //Debug::Arr($scheduled_user_date_ids_before, 'Scheduled UserDateIDs Before: ', __FILE__, __LINE__, __METHOD__,10); } } else { Debug::text('aUsing calendar days, NOT scheduled days!', __FILE__, __LINE__, __METHOD__, 10); } if ($this->getHolidayPolicyObject()->getWorkedAfterScheduledDays() == TRUE and $this->getHolidayPolicyObject()->getMinimumWorkedAfterDays() > 0 and $this->getHolidayPolicyObject()->getMinimumWorkedAfterPeriodDays() > 0) { $slf->getByUserIdAndTypeAndDirectionFromDate($user_obj->getId(), 10, 'after', $this->getDateStamp(), $this->getHolidayPolicyObject()->getMinimumWorkedAfterPeriodDays()); Debug::text('bUsing scheduled days!', __FILE__, __LINE__, __METHOD__, 10); if ($slf->getRecordCount() > 0) { //Get user_date_ids foreach ($slf as $s_obj) { $scheduled_user_date_ids_after[] = $s_obj->getUserDateID(); } //Debug::Arr($scheduled_user_date_ids_after, 'Scheduled UserDateIDs After: ', __FILE__, __LINE__, __METHOD__,10); } } else { Debug::text('bUsing calendar days, NOT scheduled days!', __FILE__, __LINE__, __METHOD__, 10); } $worked_before_days_count = 0; if ($this->getHolidayPolicyObject()->getMinimumWorkedDays() > 0 and $this->getHolidayPolicyObject()->getMinimumWorkedPeriodDays() > 0) { if (isset($scheduled_user_date_ids_before) and $this->getHolidayPolicyObject()->getWorkedScheduledDays() == TRUE) { $worked_before_days_count = $udtlf->getDaysWorkedByUserIDAndUserDateIDs($user_obj->getId(), $scheduled_user_date_ids_before); } else { $worked_before_days_count = $udtlf->getDaysWorkedByUserIDAndStartDateAndEndDate($user_obj->getId(), $this->getDateStamp() - $this->getHolidayPolicyObject()->getMinimumWorkedPeriodDays() * 86400, $this->getDateStamp() - 86400); } } Debug::text('Employee has worked the prior: ' . $worked_before_days_count . ' days (Must be at least: ' . $this->getHolidayPolicyObject()->getMinimumWorkedDays() . ')', __FILE__, __LINE__, __METHOD__, 10); $worked_after_days_count = 0; if ($this->getHolidayPolicyObject()->getMinimumWorkedAfterDays() > 0 and $this->getHolidayPolicyObject()->getMinimumWorkedAfterPeriodDays() > 0) { if (isset($scheduled_user_date_ids_after) and $this->getHolidayPolicyObject()->getWorkedAfterScheduledDays() == TRUE) { $worked_after_days_count = $udtlf->getDaysWorkedByUserIDAndUserDateIDs($user_obj->getId(), $scheduled_user_date_ids_after); } else { $worked_after_days_count = $udtlf->getDaysWorkedByUserIDAndStartDateAndEndDate($user_obj->getId(), $this->getDateStamp() + 86400, $this->getDateStamp() + $this->getHolidayPolicyObject()->getMinimumWorkedAfterPeriodDays() * 86400); } } Debug::text('Employee has worked the following: ' . $worked_after_days_count . ' days (Must be at least: ' . $this->getHolidayPolicyObject()->getMinimumWorkedAfterDays() . ')', __FILE__, __LINE__, __METHOD__, 10); //Make sure employee has worked for a portion of those days. if ($worked_before_days_count >= $this->getHolidayPolicyObject()->getMinimumWorkedDays() and $worked_after_days_count >= $this->getHolidayPolicyObject()->getMinimumWorkedAfterDays()) { Debug::text('Employee has worked enough prior and following days!', __FILE__, __LINE__, __METHOD__, 10); return TRUE; } else { Debug::text('Employee has NOT worked enough days prior or following the holiday!', __FILE__, __LINE__, __METHOD__, 10); } } else { Debug::text('Standard Holiday Policy type, returning TRUE', __FILE__, __LINE__, __METHOD__, 10); return TRUE; } } else { Debug::text('Employee has NOT been employed long enough!', __FILE__, __LINE__, __METHOD__, 10); } return FALSE; }