/** * Init view helper function * @param string $name * @param App_Fullcalendar $fc * @param array $attributes * @return string */ public function jqCalendar($name, App_JqCalendar $calendar, $options, $attributes = array()) { $functionName = $name; $jsonOptions = $calendar->options->getConfig(); $canAdd = $calendar->canAdd(); $function = $this->createFunction($functionName, $jsonOptions, $options, $canAdd); $this->view->JQuery()->addOnLoad("{$functionName}();"); $attributes['id'] = $functionName; $attributes['style'] = "overflow-y: visible; border: 1px solid #ccc"; $container = sprintf($this->_container, $this->_parseAttributes($attributes)); return $function . $container; }
public function indexAction() { $user = Zend_Auth::getInstance()->getIdentity()->user; $calendar = new App_JqCalendar(); $calendar->defaultView(); $calendar->currentFirstDay(true); $calendar->canAddAllDay(false); // add reservations only if the user have aircrafts if (count($user->Aircraft->toArray()) > 0) { $calendar->enableAdd(true); } else { $calendar->enableAdd(false); } if (Zend_Auth::getInstance()->getIdentity()->isAdmin) { $this->_addHeadTitle("All reservations"); $reservations = Reservation::findAll(); $this->view->events = Reservation::toEvents($reservations, true); $calendar->loadUrl($this->baseUrl . "/index/index/format/json"); } else { $this->_addHeadTitle("My reservations"); $reservations = Reservation::findByUser($user->id); $this->view->events = Reservation::toEvents($reservations); $calendar->loadUrl($this->baseUrl . "/index/index/format/json"); } $this->view->jqCalendar = $calendar; }