private static function loadHolidaysSettings() { global $AppUI; if (is_null(self::$holiday_manual)) { // Query database for settings $q = new w2p_Database_Query(); $q->addTable("holiday_settings"); $q->addQuery("holiday_manual, holiday_auto, holiday_driver, holiday_filter"); $settings = $q->loadHash(); self::$holiday_manual = $settings['holiday_manual']; self::$holiday_auto = $settings['holiday_auto']; self::$holiday_driver = $settings['holiday_driver']; self::$holiday_filter = $settings['holiday_filter']; } if (self::$holiday_auto && self::$holiday_filter >= 0 && is_null(self::$holiday_filter_instance)) { $filters_alloc = Date_Holidays::getInstalledFilters(); require_once dirname(__FILE__) . "/PEAR/Holidays/Filter/" . str_replace("_", "/", $filters_alloc[self::$holiday_filter]['title']) . ".php"; $filterclass = "Date_Holidays_Filter_" . $filters_alloc[self::$holiday_filter]['title']; self::$holiday_filter_instance = new $filterclass(); } if (self::$holiday_auto && self::$holiday_driver >= 0 && is_null(self::$holiday_driver_instance)) { $drivers_alloc = Date_Holidays::getInstalledDrivers(); self::$holiday_driver_instance = Date_Holidays::factory($drivers_alloc[self::$holiday_driver]['title'], null, $AppUI->user_locale); } }
public function isWorkingDay() { global $AppUI; if ($AppUI->isActiveModule('holiday')) { // Holiday module, check the holiday database require_once W2P_BASE_DIR . "/modules/holiday/holiday_functions.class.php"; if (HolidayFunctions::isHoliday($this)) { return false; } } $working_days = w2PgetConfig('cal_working_days'); $working_days = is_null($working_days) ? array('1', '2', '3', '4', '5') : explode(',', $working_days); return in_array($this->getDayOfWeek(), $working_days); }
public function hook_calendar($userId) { $date = new w2p_Utilities_Date(w2PgetParam($_GET, 'date', null)); $date->setTime(0, 0, 0); $start = $date->duplicate(); $end = $date->duplicate(); $view = w2PgetParam($_GET, 'a', 'month_view'); switch ($view) { case 'day_view': break; case 'week_view': $end->addDays(6); break; case 'index': case 'month_view': $start->setDay(1); $end->setDay($date->getDaysInMonth()); break; case 'year_view': $start->setMonth(1); $start->setDay(1); $end->setMonth(12); $end->setDay(31); break; } $end->setTime(23, 59, 59); $holidays = HolidayFunctions::getHolidaysForDatespan($start, $end, $userId); $itemsList = array(); foreach ($holidays as $i => $holiday) { $date = $holiday['startDate']; $end = $holiday['endDate']; while (!$date->after(clone $end)) { $itemsList[] = array('id' => $holiday['id'], 'name' => $holiday['name'], 'startDate' => $date->format(FMT_TIMESTAMP_DATE), 'endDate' => $date->format(FMT_TIMESTAMP_DATE), 'description' => $holiday['description']); $date = $date->getNextDay(); } } return $itemsList; }
$newworkdaysranges = HolidayFunctions::makeHolidaysRecords($workdays, 0, HOLIDAY_TYPE_COMPANY_WORKDAY); HolidayFunctions::storeRecords($newworkdaysranges, 0, HOLIDAY_TYPE_COMPANY_WORKDAY); $AppUI->setMsg("Public Holidays updated"); } if ($target == "user") { $user_id = w2PgetParam($_POST, 'user_id', $AppUI->user_id); $description = w2PgetParam($_POST, 'holiday_description', ""); $newholidays = w2PgetParam($_POST, 'newholidays', ""); $newholidays = $newholidays ? explode(",", $newholidays) : array(); $holidays = array(); foreach ($newholidays as $newholiday) { list($id, $date, $name) = explode("-", $newholiday); $holidays[] = $date; // put the date in whitelist } $newholidaysranges = HolidayFunctions::makeHolidaysRecords($holidays, $user_id, HOLIDAY_TYPE_USER_HOLIDAY, 0, $description); HolidayFunctions::storeRecords($newholidaysranges, $user_id, HOLIDAY_TYPE_USER_HOLIDAY, 0, $description); $newworkdays = w2PgetParam($_POST, 'newworkdays', ""); $newworkdays = $newworkdays ? explode(",", $newworkdays) : array(); foreach ($newworkdays as $newworkday) { list($id, $date, $name) = explode("-", $newworkday); if ($id > 0) { // this holidays is in whitelist of the user $holiday = new CHoliday(); $holiday->loadFull($AppUI, $id); $holiday->remove($AppUI, new w2p_Utilities_Date($date)); } } $AppUI->setMsg("User Holidays updated"); } $AppUI->redirect();
} $holidaysList = HolidayFunctions::getBlacklistForDatespan($start, $end); foreach ($holidaysList as $holiday) { $id = $holiday['id']; $type = $holiday['type']; $description = $holiday['description'] ? $holiday['description'] : ""; $odate = $holiday['startDate']; $oend = $holiday['endDate']; $cdate = clone $odate; while (!$cdate->after(clone $oend)) { $holidays[$odate->format(FMT_TIMESTAMP_DATE)] = array($id, $type, $description, ""); $odate = $odate->getNextDay(); $cdate = clone $odate; } } $holidaysList = HolidayFunctions::getWhitelistForDatespan($start, $end, $user_id); foreach ($holidaysList as $holiday) { $id = $holiday['id']; $type = $holiday['type']; $description = $holiday['description'] ? $holiday['description'] : ""; $odate = $holiday['startDate']; $oend = $holiday['endDate']; $cdate = clone $odate; while (!$cdate->after(clone $oend)) { $holidays[$odate->format(FMT_TIMESTAMP_DATE)] = array($id, $type, $description, ""); $odate = $odate->getNextDay(); $cdate = clone $odate; } } $cal_working_days = explode(",", w2PgetConfig("cal_working_days")); $user_holiday_types = w2PgetSysVal('UserHolidayType');
} $holidaysList = HolidayFunctions::getWhitelistForDatespan($start, $end); foreach ($holidaysList as $holiday) { $id = $holiday['id']; $type = $holiday['type']; $description = $holiday['description'] ? $holiday['description'] : ""; $odate = $holiday['startDate']; $oend = $holiday['endDate']; $cdate = clone $odate; while (!$cdate->after(clone $oend)) { $holidays[$odate->format(FMT_TIMESTAMP_DATE)] = array($id, $type, $description, ""); $odate = $odate->getNextDay(); $cdate = clone $odate; } } $holidaysList = HolidayFunctions::getBlacklistForDatespan($start, $end); foreach ($holidaysList as $holiday) { $id = $holiday['id']; $type = $holiday['type']; $description = $holiday['description'] ? $holiday['description'] : ""; $odate = $holiday['startDate']; $oend = $holiday['endDate']; $cdate = clone $odate; while (!$cdate->after(clone $oend)) { $holidays[$odate->format(FMT_TIMESTAMP_DATE)] = array($id, $type, $description, ""); $odate = $odate->getNextDay(); $cdate = clone $odate; } } $cal_working_days = explode(",", w2PgetConfig("cal_working_days")); setlocale(LC_ALL, 'C');