Exemple #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;
 }
Exemple #2
0
 /**
  * Get the holidayfiles that are available groups
  */
 protected function actionHolidays($params)
 {
     $available = \GO\Base\Model\Holiday::getAvailableHolidayFiles();
     $store = new \GO\Base\Data\ArrayStore();
     $store->setRecords($available);
     return $store->getData();
 }
<?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');
Exemple #4
0
 protected function beforeSave()
 {
     if ($this->isNew) {
         $holiday = Holiday::localeFromCountry($this->language);
         if ($holiday !== false) {
             $this->holidayset = $holiday;
         }
     }
     if (!$this->isNew && empty($this->holidayset) && ($contact = $this->createContact())) {
         $holiday = Holiday::localeFromCountry($contact->country);
         if ($holiday !== false) {
             $this->holidayset = $holiday;
         }
     }
     if ($this->isModified('password') && !empty($this->password)) {
         $this->_unencryptedPassword = $this->password;
         $this->password = $this->_encryptPassword($this->password);
         $this->password_type = 'crypt';
         $this->digest = md5($this->username . ":" . GO::config()->product_name . ":" . $this->_unencryptedPassword);
     }
     return parent::beforeSave();
 }
Exemple #5
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;
 }