/** * Called by the Javascript frontend to get the details about an event * */ public function eventDetailsAction() { $get = Zend_Registry::get('getFilter'); if (!isset($get->eventId)) { throw new Ot_Exception_Input('msg-error-eventIdNotSet'); } $event = new Event(); if (!Zend_Auth::getInstance()->hasIdentity()) { $userEventStatus = false; } else { $userEventStatus = $event->getStatusOfUserForEvent(Zend_Auth::getInstance()->getIdentity()->accountId, $get->eventId); } $i = new Event_Instructor(); $where = $i->getAdapter()->quoteInto('eventId = ?', $get->eventId); $results = $i->fetchAll($where); $currentInstructors = array(); foreach ($results as $r) { $currentInstructors[] = $r->accountId; } $this->view->acl = array('editEvent' => $this->_helper->hasAccess('edit-event'), 'cancelEvent' => $this->_helper->hasAccess('cancel-event'), 'signup' => $this->_helper->hasAccess('signup', 'workshop_signup'), 'viewAllInstructorPages' => $this->_helper->hasAccess('view-all-instructor-pages', 'workshop_instructor'), 'userEventStatus' => $userEventStatus); $this->view->reservationCancelable = $event->isReservationCancelable($get->eventId); // shortened display when an ajax call version) $short = false; if ($this->_request->isXmlHttpRequest()) { $this->_helper->layout->disableLayout(); $short = true; } $this->view->shortDisplay = $short; $workshop = new Workshop(); $location = new Location(); $thisEvent = $event->find($get->eventId); if (is_null($thisEvent)) { throw new Ot_Exception_Data('msg-error-noEvent'); } $i = new Event_Instructor(); $currentInstructors = $i->getInstructorsForEvent($get->eventId); $instructor = array(); foreach ($currentInstructors as $r) { $instructor[] = $r['firstName'] . ' ' . $r['lastName']; } $this->view->instructors = $instructor; $thisEvent = $thisEvent->toArray(); $thisEvent['startTime'] = strftime('%l:%M %p', strtotime($thisEvent['startTime'])); $thisEvent['endTime'] = strftime('%l:%M %p', strtotime($thisEvent['endTime'])); $this->view->location = $location->find($thisEvent['locationId'])->toArray(); $this->view->workshop = $workshop->find($thisEvent['workshopId'])->toArray(); $this->view->event = $thisEvent; }
/** * Allows a user to cancel their reservation for an event. * */ public function cancelAction() { $get = Zend_Registry::get('getFilter'); if (!isset($get->eventId)) { throw new Ot_Exception_Input('msg-error-eventIdNotSet'); } $event = new Event(); $location = new Location(); $workshop = new Workshop(); $instructor = new Event_Instructor(); $attendee = new Event_Attendee(); $thisEvent = $event->find($get->eventId); if (is_null($thisEvent)) { throw new Ot_Exception_Data('msg-error-noEvent'); } $this->view->event = $thisEvent->toArray(); $status = $event->getStatusOfUserForEvent(Zend_Auth::getInstance()->getIdentity()->accountId, $thisEvent->eventId); if ($status != 'waitlist' && $status != 'attending') { throw new Ot_Exception_Data('msg-error-notAttending'); } $this->view->status = $status; $this->view->reservationCancelable = $event->isReservationCancelable($thisEvent->eventId); $thisLocation = $location->find($thisEvent->locationId); if (is_null($thisLocation)) { throw new Ot_Exception_Data('msg-error-noLocation'); } $this->view->location = $thisLocation->toArray(); $thisWorkshop = $workshop->find($thisEvent->workshopId); if (is_null($thisWorkshop)) { throw new Ot_Exception_Data('msg-error-noWorkshop'); } $this->view->workshop = $thisWorkshop->toArray(); $instructors = $instructor->getInstructorsForEvent($thisEvent->eventId); $inst = array(); foreach ($instructors as $i) { $inst[] = $i['firstName'] . ' ' . $i['lastName']; } $this->view->instructors = $inst; $events = $event->getEvents($thisWorkshop->workshopId, null, null, time(), null, 'open')->toArray(); $newEvents = array(); foreach ($events as $e) { if ($e['eventId'] != $thisEvent->eventId) { $e['status'] = $event->getStatusOfUserForEvent(Zend_Auth::getInstance()->getIdentity()->accountId, $e['eventId']); $e['workshop'] = $thisWorkshop->toArray(); $newEvents[] = $e; } } $this->view->events = $newEvents; $form = Ot_Form_Template::delete('cancelReservation', 'workshop-signup-cancel:cancel', 'workshop-signup-cancel:keep'); if ($this->_request->isPost() && $form->isValid($_POST)) { $instructorNames = array(); $instructorEmails = array(); foreach ($instructors as $i) { $instructorNames[] = $i['firstName'] . ' ' . $i['lastName']; $instructorEmails[] = $i['emailAddress']; } $attendee->cancelReservation(Zend_Auth::getInstance()->getIdentity()->accountId, $thisEvent->eventId); $startDt = strtotime($thisEvent->date . ' ' . $thisEvent->startTime); $endDt = strtotime($thisEvent->date . ' ' . $thisEvent->endTime); $data = array('workshopName' => $thisWorkshop->title, 'workshopDate' => date('m/d/Y', $startDt), 'workshopStartTime' => date('g:i a', $startDt), 'workshopEndTime' => date('g:i a', $endDt), 'workshopMinimumEnrollment' => $thisEvent->minSize, 'locationName' => $thisLocation->name, 'locationAddress' => $thisLocation->address, 'instructorNames' => implode(', ', $instructorNames), 'instructorEmails' => implode(', ', $instructorEmails), 'studentEmail' => Zend_Auth::getInstance()->getIdentity()->emailAddress, 'studentName' => Zend_Auth::getInstance()->getIdentity()->firstName . ' ' . Zend_Auth::getInstance()->getIdentity()->lastName, 'studentUsername' => Zend_Auth::getInstance()->getIdentity()->username); $this->_helper->flashMessenger->addMessage($this->view->translate('msg-info-canceled', $thisWorkshop->title)); $trigger = new Ot_Trigger(); $trigger->setVariables($data); $trigger->dispatch('Event_Cancel_Reservation'); $account = new Ot_Account(); if ($status != 'waitlist') { $waiting = $attendee->getAttendeesForEvent($thisEvent->eventId, 'waitlist'); if (count($waiting) != 0) { $newAccount = $account->find($waiting[0]['accountId']); if (!is_null($newAccount)) { $attendee->makeReservation($newAccount->accountId, $thisEvent->eventId); $data['studentEmail'] = $newAccount->emailAddress; $data['studentName'] = $newAccount->firstName . ' ' . $newAccount->lastName; $data['studentUsername'] = $newAccount->username; $trigger = new Ot_Trigger(); $trigger->setVariables($data); $trigger->dispatch('Event_Waitlist_To_Attending'); } } } $this->_redirect('/'); } $this->view->form = $form; $this->view->layout()->setLayout('twocolumn'); $this->view->layout()->rightContent = $this->view->render('signup/right.phtml'); }