示例#1
0
 public static function updateHoliday($data, $id)
 {
     $holiday = Holiday::find($id);
     $holiday->name = array_get($data, 'name');
     $holiday->date = array_get($data, 'date');
     $holiday->update();
 }
示例#2
0
 public function updateHoliday($id)
 {
     $holiday = Holiday::find($id);
     $holiday->name = Input::get('name');
     $holiday->date = Input::get('date');
     $holiday->save();
     return Redirect::back()->with('message', array('type' => 'success', 'text' => 'Updated Holiday!'));
 }
示例#3
0
 function getAllObjects()
 {
     $holiday = new Holiday();
     $holiday->orderBy('date');
     $holiday->find();
     $list = array();
     while ($holiday->fetch()) {
         $list[$holiday->id] = clone $holiday;
     }
     return $list;
 }
示例#4
0
 public function __get($name)
 {
     if ($name == "holidays") {
         if (!isset($this->holidays) && $this->libraryId) {
             $this->holidays = array();
             $holiday = new Holiday();
             $holiday->libraryId = $this->libraryId;
             $holiday->orderBy('date');
             $holiday->find();
             while ($holiday->fetch()) {
                 $this->holidays[$holiday->id] = clone $holiday;
             }
         }
         return $this->holidays;
     } elseif ($name == "nearbyBookStores") {
         if (!isset($this->nearbyBookStores) && $this->libraryId) {
             $this->nearbyBookStores = array();
             $store = new NearbyBookStore();
             $store->libraryId = $this->libraryId;
             $store->orderBy('weight');
             $store->find();
             while ($store->fetch()) {
                 $this->nearbyBookStores[$store->id] = clone $store;
             }
         }
         return $this->nearbyBookStores;
     } elseif ($name == "moreDetailsOptions") {
         if (!isset($this->moreDetailsOptions) && $this->libraryId) {
             $this->moreDetailsOptions = array();
             $moreDetailsOptions = new LibraryMoreDetails();
             $moreDetailsOptions->libraryId = $this->libraryId;
             $moreDetailsOptions->orderBy('weight');
             $moreDetailsOptions->find();
             while ($moreDetailsOptions->fetch()) {
                 $this->moreDetailsOptions[$moreDetailsOptions->id] = clone $moreDetailsOptions;
             }
         }
         return $this->moreDetailsOptions;
     } elseif ($name == "facets") {
         if (!isset($this->facets) && $this->libraryId) {
             $this->facets = array();
             $facet = new LibraryFacetSetting();
             $facet->libraryId = $this->libraryId;
             $facet->orderBy('weight');
             $facet->find();
             while ($facet->fetch()) {
                 $this->facets[$facet->id] = clone $facet;
             }
         }
         return $this->facets;
     } elseif ($name == 'searchSources') {
         if (!isset($this->searchSources) && $this->libraryId) {
             $this->searchSources = array();
             $searchSource = new LibrarySearchSource();
             $searchSource->libraryId = $this->libraryId;
             $searchSource->orderBy('weight');
             $searchSource->find();
             while ($searchSource->fetch()) {
                 $this->searchSources[$searchSource->id] = clone $searchSource;
             }
         }
         return $this->searchSources;
     } elseif ($name == 'libraryLinks') {
         if (!isset($this->libraryLinks) && $this->libraryId) {
             $this->libraryLinks = array();
             $libraryLink = new LibraryLinks();
             $libraryLink->libraryId = $this->libraryId;
             $libraryLink->orderBy('weight');
             $libraryLink->find();
             while ($libraryLink->fetch()) {
                 $this->libraryLinks[$libraryLink->id] = clone $libraryLink;
             }
         }
         return $this->libraryLinks;
     } elseif ($name == 'libraryTopLinks') {
         if (!isset($this->libraryTopLinks) && $this->libraryId) {
             $this->libraryTopLinks = array();
             $libraryLink = new LibraryTopLinks();
             $libraryLink->libraryId = $this->libraryId;
             $libraryLink->orderBy('weight');
             $libraryLink->find();
             while ($libraryLink->fetch()) {
                 $this->libraryTopLinks[$libraryLink->id] = clone $libraryLink;
             }
         }
         return $this->libraryTopLinks;
     } elseif ($name == 'browseCategories') {
         if (!isset($this->browseCategories) && $this->libraryId) {
             $this->browseCategories = array();
             $browseCategory = new LibraryBrowseCategory();
             $browseCategory->libraryId = $this->libraryId;
             $browseCategory->orderBy('weight');
             $browseCategory->find();
             while ($browseCategory->fetch()) {
                 $this->browseCategories[$browseCategory->id] = clone $browseCategory;
             }
         }
         return $this->browseCategories;
     } else {
         return $this->data[$name];
     }
 }
示例#5
0
 public static function getLibraryHours($locationId, $timeToCheck)
 {
     $location = new Location();
     $location->locationId = $locationId;
     if ($locationId > 0 && $location->find(true)) {
         // format $timeToCheck according to MySQL default date format
         $todayFormatted = date('Y-m-d', $timeToCheck);
         // check to see if today is a holiday
         require_once ROOT_DIR . '/Drivers/marmot_inc/Holiday.php';
         $holidays = array();
         $holiday = new Holiday();
         $holiday->date = $todayFormatted;
         $holiday->libraryId = $location->libraryId;
         if ($holiday->find(true)) {
             return array('closed' => true, 'closureReason' => $holiday->name);
         }
         // get the day of the week (0=Sunday to 6=Saturday)
         $dayOfWeekToday = strftime('%w', $timeToCheck);
         // find library hours for the above day of the week
         require_once ROOT_DIR . '/Drivers/marmot_inc/LocationHours.php';
         $hours = new LocationHours();
         $hours->locationId = $locationId;
         $hours->day = $dayOfWeekToday;
         if ($hours->find(true)) {
             $hours->fetch();
             return array('open' => ltrim($hours->open, '0'), 'close' => ltrim($hours->close, '0'), 'closed' => $hours->closed ? true : false, 'openFormatted' => $hours->open == '12:00' ? 'Noon' : date("g:i A", strtotime($hours->open)), 'closeFormatted' => $hours->close == '12:00' ? 'Noon' : date("g:i A", strtotime($hours->close)));
         }
     }
     // no hours found
     return null;
 }
 function holiday_list()
 {
     App::uses('Holiday', 'ScheduleManager.Model');
     $holidayModel = new Holiday();
     $holidays = $holidayModel->find('all', array('fields' => array('Holiday.type_holidays_id,Holiday.holidays_date')));
     //debug($holidays);
     $tmp_holidays = array();
     foreach ($holidays as $holiday) {
         if (!array_key_exists($holiday['Holiday']['type_holidays_id'], $tmp_holidays)) {
             $tmp_holidays[$holiday['Holiday']['type_holidays_id']] = array();
         }
         $tmp_holidays[$holiday['Holiday']['type_holidays_id']][$holiday['Holiday']['holidays_date']] = $holiday['Holiday']['holidays_date'];
     }
     return $tmp_holidays;
 }
示例#7
0
 /**
  * Show the form for editing the specified holiday.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $holiday = Holiday::find($id);
     return View::make('holidays.edit', compact('holiday'));
 }
示例#8
0
 public function __get($name)
 {
     if ($name == "holidays") {
         if (!isset($this->holidays) && $this->libraryId) {
             $this->holidays = array();
             $holiday = new Holiday();
             $holiday->libraryId = $this->libraryId;
             $holiday->orderBy('date');
             $holiday->find();
             while ($holiday->fetch()) {
                 $this->holidays[$holiday->id] = clone $holiday;
             }
         }
         return $this->holidays;
     } elseif ($name == "nearbyBookStores") {
         if (!isset($this->nearbyBookStores) && $this->libraryId) {
             $this->nearbyBookStores = array();
             $store = new NearbyBookStore();
             $store->libraryId = $this->libraryId;
             $store->orderBy('weight');
             $store->find();
             while ($store->fetch()) {
                 $this->nearbyBookStores[$store->id] = clone $store;
             }
         }
         return $this->nearbyBookStores;
     } elseif ($name == "facets") {
         if (!isset($this->facets) && $this->libraryId) {
             $this->facets = array();
             $facet = new LibraryFacetSetting();
             $facet->libraryId = $this->libraryId;
             $facet->orderBy('weight');
             $facet->find();
             while ($facet->fetch()) {
                 $this->facets[$facet->id] = clone $facet;
             }
         }
         return $this->facets;
     } elseif ($name == 'searchSources') {
         if (!isset($this->searchSources) && $this->libraryId) {
             $this->searchSources = array();
             $searchSource = new LibrarySearchSource();
             $searchSource->libraryId = $this->libraryId;
             $searchSource->orderBy('weight');
             $searchSource->find();
             while ($searchSource->fetch()) {
                 $this->searchSources[$searchSource->id] = clone $searchSource;
             }
         }
         return $this->searchSources;
     } else {
         return $this->data[$name];
     }
 }