Exemplo n.º 1
0
 function getAllObjects()
 {
     $hours = new LocationHours();
     $hours->orderBy('locationId, day');
     $hours->find();
     $list = array();
     while ($hours->fetch()) {
         $list[$hours->id] = clone $hours;
     }
     return $list;
 }
Exemplo n.º 2
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;
 }