Beispiel #1
0
 /**
  * Returns true if the time is a holiday or in the weekend
  *
  * @param <type> $time
  * @param <type> $region
  * @return <type> boolean
  */
 public static function is_on_free_day($time, $region = false)
 {
     $weekday = date('w', $time);
     if ($weekday == 6 || $weekday == 0) {
         return true;
     } else {
         $date = date('Y-m-d', $time);
         $region = $region ? $region : \GO::config()->language;
         $year = date('Y', $time);
         if (!isset(self::$holidays[$region][$year])) {
             $hstmt = \GO\Base\Model\Holiday::model()->getHolidaysInPeriod($year . '-01-01', $year . '-12-31', $region);
             foreach ($hstmt as $h) {
                 self::$holidays[$region][$year][$h->date] = $h->name;
             }
         }
         return isset(self::$holidays[$region][$year][$date]);
     }
     return false;
 }
<?php

$stmt = \GO\Base\Model\Holiday::model()->find(\GO\Base\Db\FindParams::newInstance()->criteria(\GO\Base\Db\FindCriteria::newInstance()->addCondition('region', 'nl')->addCondition('date', '2014-01-01', '>=')));
foreach ($stmt as $holidayModel) {
    $holidayModel->delete();
}
\GO\Base\Model\Holiday::model()->generateHolidays('2014', 'nl');
Beispiel #3
0
 /**
  * Fill the response array with the holidays between the start and end time
  * 
  * @param array $response
  * @param \GO\Calendar\Model\Calendar $calendar
  * @param string $startTime
  * @param string $endTime
  * @return array 
  */
 private function _getHolidayResponseForPeriod($response, $calendar, $startTime, $endTime)
 {
     $resultCount = 0;
     if (!$calendar->user && empty($calendar->user->holidayset)) {
         return $response;
     }
     //$holidays = \GO\Base\Model\Holiday::model()->getHolidaysInPeriod($startTime, $endTime, $calendar->user->language);
     $holidays = \GO\Base\Model\Holiday::model()->getHolidaysInPeriod($startTime, $endTime, $calendar->user->holidayset);
     if ($holidays) {
         while ($holiday = $holidays->fetch()) {
             $resultCount++;
             $record = $holiday->getJson();
             $record['calendar_id'] = $calendar->id;
             $record['id'] = $response['count']++;
             $response['results'][$this->_getIndex($response['results'], strtotime($holiday->date))] = $record;
         }
     }
     // Set the count of the holidays
     $response['count_holidays_only'] = $resultCount;
     return $response;
 }