예제 #1
0
     $hplf = new HolidayPolicyListFactory();
     foreach ($ids as $id) {
         $hplf->getByIdAndCompanyId($id, $current_company->getId());
         foreach ($hplf as $hp_obj) {
             $hp_obj->setDeleted($delete);
             if ($hp_obj->isValid()) {
                 $hp_obj->Save();
             }
         }
     }
     Redirect::Page(URLBuilder::getURL(NULL, 'HolidayPolicyList.php'));
     break;
 default:
     BreadCrumb::setCrumb($title);
     $hplf = new HolidayPolicyListFactory();
     $hplf->getByCompanyId($current_company->getId());
     $pager = new Pager($hplf);
     $type_options = $hplf->getOptions('type');
     $show_no_policy_group_notice = FALSE;
     foreach ($hplf as $hp_obj) {
         if ((int) $hp_obj->getColumn('assigned_policy_groups') == 0) {
             $show_no_policy_group_notice = TRUE;
         }
         $policies[] = array('id' => $hp_obj->getId(), 'name' => $hp_obj->getName(), 'type_id' => $hp_obj->getType(), 'type' => $type_options[$hp_obj->getType()], 'assigned_policy_groups' => (int) $hp_obj->getColumn('assigned_policy_groups'), 'deleted' => $hp_obj->getDeleted());
     }
     $smarty->assign_by_ref('policies', $policies);
     $smarty->assign_by_ref('show_no_policy_group_notice', $show_no_policy_group_notice);
     $smarty->assign_by_ref('sort_column', $sort_column);
     $smarty->assign_by_ref('sort_order', $sort_order);
     $smarty->assign_by_ref('paging_data', $pager->getPageVariables());
     break;
 function getByCompanyIdArray($company_id, $include_blank = TRUE)
 {
     $hplf = new HolidayPolicyListFactory();
     $hplf->getByCompanyId($company_id);
     if ($include_blank == TRUE) {
         $list[0] = '--';
     }
     foreach ($hplf as $hp_obj) {
         $list[$hp_obj->getID()] = $hp_obj->getName();
     }
     if (isset($list)) {
         return $list;
     }
     return FALSE;
 }
 function getHolidayUserDateIDs()
 {
     Debug::text('reCalculating Holiday...', __FILE__, __LINE__, __METHOD__, 10);
     //Get Holiday policies and determine how many days we need to look ahead/behind in order
     //to recalculate the holiday eligilibility/time.
     $holiday_before_days = 0;
     $holiday_after_days = 0;
     $hplf = new HolidayPolicyListFactory();
     $hplf->getByCompanyId($this->getUserDateObject()->getUserObject()->getCompany());
     if ($hplf->getRecordCount() > 0) {
         foreach ($hplf as $hp_obj) {
             if ($hp_obj->getMinimumWorkedPeriodDays() > $holiday_before_days) {
                 $holiday_before_days = $hp_obj->getMinimumWorkedPeriodDays();
             }
             if ($hp_obj->getAverageTimeDays() > $holiday_before_days) {
                 $holiday_before_days = $hp_obj->getAverageTimeDays();
             }
             if ($hp_obj->getMinimumWorkedAfterPeriodDays() > $holiday_after_days) {
                 $holiday_after_days = $hp_obj->getMinimumWorkedAfterPeriodDays();
             }
         }
     }
     Debug::text('Holiday Before Days: ' . $holiday_before_days . ' Holiday After Days: ' . $holiday_after_days, __FILE__, __LINE__, __METHOD__, 10);
     if ($holiday_before_days > 0 or $holiday_after_days > 0) {
         $retarr = array();
         $search_start_date = TTDate::getBeginWeekEpoch($this->getUserDateObject()->getDateStamp() - $holiday_after_days * 86400);
         $search_end_date = TTDate::getEndWeekEpoch(TTDate::getEndDayEpoch($this->getUserDateObject()->getDateStamp()) + $holiday_before_days * 86400 + 3601);
         Debug::text('Holiday search start date: ' . TTDate::getDate('DATE', $search_start_date) . ' End date: ' . TTDate::getDate('DATE', $search_end_date) . ' Current Date: ' . TTDate::getDate('DATE', $this->getUserDateObject()->getDateStamp()), __FILE__, __LINE__, __METHOD__, 10);
         $hlf = new HolidayListFactory();
         //$hlf->getByPolicyGroupUserIdAndStartDateAndEndDate( $this->getUserDateObject()->getUser(), TTDate::getEndWeekEpoch( $this->getUserDateObject()->getDateStamp() )+86400, TTDate::getEndDayEpoch()+($max_average_time_days*86400)+3601 );
         $hlf->getByPolicyGroupUserIdAndStartDateAndEndDate($this->getUserDateObject()->getUser(), $search_start_date, $search_end_date);
         if ($hlf->getRecordCount() > 0) {
             Debug::text('Found Holidays within range: ' . $hlf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
             $udlf = new UserDateListFactory();
             foreach ($hlf as $h_obj) {
                 Debug::text('ReCalculating Day due to Holiday: ' . TTDate::getDate('DATE', $h_obj->getDateStamp()), __FILE__, __LINE__, __METHOD__, 10);
                 $user_date_ids = $udlf->getArrayByListFactory($udlf->getByUserIdAndDate($this->getUserDateObject()->getUser(), $h_obj->getDateStamp()));
                 if (is_array($user_date_ids)) {
                     $retarr = array_merge($retarr, $user_date_ids);
                 }
                 unset($user_date_ids);
             }
         }
     }
     if (isset($retarr) and is_array($retarr) and count($retarr) > 0) {
         //Debug::Arr($retarr, 'Holiday UserDateIDs: ', __FILE__, __LINE__, __METHOD__, 10);
         return $retarr;
     }
     Debug::text('No Holidays within range...', __FILE__, __LINE__, __METHOD__, 10);
     return FALSE;
 }