function setRecurringHoliday($id)
 {
     $id = trim($id);
     $rhlf = new RecurringHolidayListFactory();
     if ($id != 0 and $this->Validator->isResultSetWithRows('recurring_holiday', $rhlf->getByID($id), TTi18n::gettext('Selected Recurring Holiday is invalid'))) {
         $this->data['recurring_holiday_id'] = $id;
         return TRUE;
     }
     return FALSE;
 }
コード例 #2
0
 function setRecurringHoliday($ids)
 {
     Debug::text('Setting Recurring Holiday IDs : ', __FILE__, __LINE__, __METHOD__, 10);
     if (is_array($ids) and count($ids) > 0) {
         $tmp_ids = array();
         if (!$this->isNew()) {
             //If needed, delete mappings first.
             $hprhlf = new HolidayPolicyRecurringHolidayListFactory();
             $hprhlf->getByHolidayPolicyId($this->getId());
             foreach ($hprhlf as $obj) {
                 $id = $obj->getRecurringHoliday();
                 Debug::text('Policy ID: ' . $obj->getHolidayPolicy() . ' ID: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
                 //Delete users that are not selected.
                 if (!in_array($id, $ids)) {
                     Debug::text('Deleting: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
                     $obj->Delete();
                 } else {
                     //Save ID's that need to be updated.
                     Debug::text('NOT Deleting : ' . $id, __FILE__, __LINE__, __METHOD__, 10);
                     $tmp_ids[] = $id;
                 }
             }
             unset($id, $obj);
         }
         //Insert new mappings.
         $rhlf = new RecurringHolidayListFactory();
         foreach ($ids as $id) {
             if (isset($ids) and !in_array($id, $tmp_ids) and $id > 0) {
                 $hprhf = new HolidayPolicyRecurringHolidayFactory();
                 $hprhf->setHolidayPolicy($this->getId());
                 $hprhf->setRecurringHoliday($id);
                 $obj = $rhlf->getById($id)->getCurrent();
                 if ($this->Validator->isTrue('recurring_holiday', $hprhf->Validator->isValid(), TTi18n::gettext('Selected Recurring Holiday is invalid') . ' (' . $obj->getName() . ')')) {
                     $hprhf->save();
                 }
             }
         }
         return TRUE;
     }
     Debug::text('No User IDs to set.', __FILE__, __LINE__, __METHOD__, 10);
     return FALSE;
 }
コード例 #3
0
 function getByCompanyIdArray($company_id, $include_blank = TRUE)
 {
     $rhlf = new RecurringHolidayListFactory();
     $rhlf->getByCompanyId($company_id);
     if ($include_blank == TRUE) {
         $list[0] = '--';
     }
     foreach ($rhlf as $rh_obj) {
         $list[$rh_obj->getID()] = $rh_obj->getName();
     }
     if (isset($list)) {
         return $list;
     }
     return FALSE;
 }
コード例 #4
0
        if (isset($id)) {
            BreadCrumb::setCrumb($title);
            $hplf = new HolidayPolicyListFactory();
            $hplf->getByIdAndCompanyID($id, $current_company->getID());
            foreach ($hplf as $hp_obj) {
                //Debug::Arr($station,'Department', __FILE__, __LINE__, __METHOD__,10);
                $data = array('id' => $hp_obj->getId(), 'name' => $hp_obj->getName(), 'type_id' => $hp_obj->getType(), 'default_schedule_status_id' => $hp_obj->getDefaultScheduleStatus(), 'minimum_employed_days' => $hp_obj->getMinimumEmployedDays(), 'minimum_worked_period_days' => $hp_obj->getMinimumWorkedPeriodDays(), 'minimum_worked_days' => $hp_obj->getMinimumWorkedDays(), 'worked_scheduled_days' => $hp_obj->getWorkedScheduledDays(), 'minimum_worked_after_period_days' => $hp_obj->getMinimumWorkedAfterPeriodDays(), 'minimum_worked_after_days' => $hp_obj->getMinimumWorkedAfterDays(), 'worked_after_scheduled_days' => $hp_obj->getWorkedAfterScheduledDays(), 'average_time_days' => $hp_obj->getAverageTimeDays(), 'average_time_worked_days' => $hp_obj->getAverageTimeWorkedDays(), 'force_over_time_policy' => $hp_obj->getForceOverTimePolicy(), 'include_over_time' => $hp_obj->getIncludeOverTime(), 'include_paid_absence_time' => $hp_obj->getIncludePaidAbsenceTime(), 'minimum_time' => $hp_obj->getMinimumTime(), 'maximum_time' => $hp_obj->getMaximumTime(), 'round_interval_policy_id' => $hp_obj->getRoundIntervalPolicyID(), 'absence_policy_id' => $hp_obj->getAbsencePolicyID(), 'recurring_holiday_ids' => $hp_obj->getRecurringHoliday(), 'created_date' => $hp_obj->getCreatedDate(), 'created_by' => $hp_obj->getCreatedBy(), 'updated_date' => $hp_obj->getUpdatedDate(), 'updated_by' => $hp_obj->getUpdatedBy(), 'deleted_date' => $hp_obj->getDeletedDate(), 'deleted_by' => $hp_obj->getDeletedBy());
            }
        } elseif ($action != 'submit') {
            //Defaults
            $data = array('default_schedule_status_id' => 20, 'minimum_employed_days' => 30, 'minimum_worked_period_days' => 30, 'minimum_worked_days' => 15, 'minimum_worked_after_period_days' => 0, 'minimum_worked_after_days' => 0, 'average_time_days' => 30, 'force_over_time_policy' => FALSE, 'include_over_time' => FALSE, 'include_paid_absence_time' => TRUE, 'minimum_time' => 0, 'maximum_time' => 0);
        }
        $aplf = new AbsencePolicyListFactory();
        $absence_options = $aplf->getByCompanyIDArray($current_company->getId(), TRUE);
        $riplf = new RoundIntervalPolicyListFactory();
        $round_interval_options = $riplf->getByCompanyIDArray($current_company->getId(), TRUE);
        $rhlf = new RecurringHolidayListFactory();
        $recurring_holiday_options = $rhlf->getByCompanyIDArray($current_company->getId(), TRUE);
        $sf = new ScheduleFactory();
        //Select box options;
        $data['type_options'] = $hpf->getOptions('type');
        $data['schedule_status_options'] = $sf->getOptions('status');
        $data['scheduled_day_options'] = $hpf->getOptions('scheduled_day');
        $data['absence_options'] = $absence_options;
        $data['round_interval_options'] = $round_interval_options;
        $data['recurring_holiday_options'] = $recurring_holiday_options;
        $smarty->assign_by_ref('data', $data);
        break;
}
$smarty->assign_by_ref('hpf', $hpf);
$smarty->display('policy/EditHolidayPolicy.tpl');
コード例 #5
0
 */
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'global.inc.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'CLI.inc.php';
$offset = 86400 * 60;
//60 days
$hplf = new HolidayPolicyListFactory();
//Get all holiday policies
$hplf->getAll(NULL, NULL, NULL);
$epoch = time();
foreach ($hplf as $hp_obj) {
    //Get all recurring holidays
    $recurring_holiday_ids = $hp_obj->getRecurringHoliday();
    if (is_array($recurring_holiday_ids) and count($recurring_holiday_ids) > 0) {
        Debug::Text('Found Recurring Holidays...', __FILE__, __LINE__, __METHOD__, 10);
        foreach ($recurring_holiday_ids as $recurring_holiday_id) {
            $rhlf = new RecurringHolidayListFactory();
            $rhlf->getById($recurring_holiday_id);
            if ($rhlf->getRecordCount() == 1) {
                $rh_obj = $rhlf->getCurrent();
                Debug::Text('Found Recurring Holiday: ' . $rh_obj->getName(), __FILE__, __LINE__, __METHOD__, 10);
                $next_holiday_date = $rh_obj->getNextDate($epoch);
                Debug::Text('Next Holiday Date: ' . TTDate::getDate('DATE+TIME', $next_holiday_date), __FILE__, __LINE__, __METHOD__, 10);
                if ($next_holiday_date <= $epoch + $offset) {
                    Debug::Text('Next Holiday Date is within Time Period (offset) adding...', __FILE__, __LINE__, __METHOD__, 10);
                    $hf = new HolidayFactory();
                    $hf->setHolidayPolicyId($hp_obj->getId());
                    $hf->setDateStamp($next_holiday_date);
                    $hf->setName($rh_obj->getName());
                    if ($hf->isValid()) {
                        $hf->Save();
                    }
コード例 #6
0
         $delete = FALSE;
     }
     $rhlf = new RecurringHolidayListFactory();
     foreach ($ids as $id) {
         $rhlf->getByIdAndCompanyId($id, $current_company->getId());
         foreach ($rhlf as $rh_obj) {
             $rh_obj->setDeleted($delete);
             if ($rh_obj->isValid()) {
                 $rh_obj->Save();
             }
         }
     }
     Redirect::Page(URLBuilder::getURL(NULL, 'RecurringHolidayList.php'));
     break;
 default:
     $rhlf = new RecurringHolidayListFactory();
     $rhlf->getByCompanyId($current_company->getId(), $current_user_prefs->getItemsPerPage(), $page, NULL, $sort_array);
     $pager = new Pager($rhlf);
     //$type_options = $aplf->getOptions('type');
     foreach ($rhlf as $rh_obj) {
         $rows[] = array('id' => $rh_obj->getId(), 'name' => $rh_obj->getName(), 'next_date' => $rh_obj->getNextDate(time()), 'deleted' => $rh_obj->getDeleted());
     }
     //Special sorting since next_date is calculated outside of the DB.
     if ($sort_column == 'next_date') {
         Debug::Text('Sort By Date!', __FILE__, __LINE__, __METHOD__, 10);
         $rows = Sort::Multisort($rows, $sort_column, NULL, $sort_order);
     }
     $smarty->assign_by_ref('rows', $rows);
     $smarty->assign_by_ref('sort_column', $sort_column);
     $smarty->assign_by_ref('sort_order', $sort_order);
     $smarty->assign_by_ref('paging_data', $pager->getPageVariables());
コード例 #7
0
     if ($data['type_id'] == 20) {
         $rhf->setDayOfWeek($data['day_of_week_20']);
     } elseif ($data['type_id'] == 30) {
         $rhf->setDayOfWeek($data['day_of_week_30']);
     }
     $rhf->setDayOfMonth($data['day_of_month']);
     $rhf->setMonth($data['month']);
     if ($rhf->isValid()) {
         $rhf->Save();
         Redirect::Page(URLBuilder::getURL(NULL, 'RecurringHolidayList.php'));
         break;
     }
 default:
     if (isset($id)) {
         BreadCrumb::setCrumb($title);
         $rhlf = new RecurringHolidayListFactory();
         $rhlf->getByIdAndCompanyID($id, $current_company->getID());
         foreach ($rhlf as $rh_obj) {
             //Debug::Arr($station,'Department', __FILE__, __LINE__, __METHOD__,10);
             $data = array('id' => $rh_obj->getId(), 'name' => $rh_obj->getName(), 'type_id' => $rh_obj->getType(), 'special_day_id' => $rh_obj->getSpecialDay(), 'week_interval' => $rh_obj->getWeekInterval(), 'pivot_day_direction_id' => $rh_obj->getPivotDayDirection(), 'day_of_week' => $rh_obj->getDayOfWeek(), 'day_of_month' => $rh_obj->getDayOfMonth(), 'month' => $rh_obj->getMonth(), 'created_date' => $rh_obj->getCreatedDate(), 'created_by' => $rh_obj->getCreatedBy(), 'updated_date' => $rh_obj->getUpdatedDate(), 'updated_by' => $rh_obj->getUpdatedBy(), 'deleted_date' => $rh_obj->getDeletedDate(), 'deleted_by' => $rh_obj->getDeletedBy());
         }
     }
     //Select box options;
     $data['special_day_options'] = $rhf->getOptions('special_day');
     $data['type_options'] = $rhf->getOptions('type');
     $data['week_interval_options'] = $rhf->getOptions('week_interval');
     $data['pivot_day_direction_options'] = $rhf->getOptions('pivot_day_direction');
     $data['day_of_week_options'] = TTDate::getDayOfWeekArray();
     $data['month_of_year_options'] = TTDate::getMonthOfYearArray();
     $data['day_of_month_options'] = TTDate::getDayOfMonthArray();
     $smarty->assign_by_ref('data', $data);