Esempio n. 1
0
 public function historyAction()
 {
     $account = new Ot_Account();
     $thisAccount = Zend_Auth::getInstance()->getIdentity();
     $get = Zend_Registry::get('getFilter');
     if (isset($get->accountId)) {
         if ($this->_helper->hasAccess('edit-all-reservations', 'workshop_signup')) {
             $thisAccount = $account->find($get->accountId);
         }
         if (is_null($thisAccount)) {
             throw new Ot_Exception_Data('msg-error-accountNotFound');
         }
     }
     if (is_null($thisAccount)) {
         throw new Ot_Exception_Data('msg-error-notLoggedIn');
     }
     $this->view->acl = array('editAllReservations' => $this->_helper->hasAccess('edit-all-reservations', 'workshop_signup'));
     $form = new Zend_Form();
     $form->setAttrib('id', 'accountForm')->setMethod(Zend_Form::METHOD_GET)->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'filterForm')), 'Form'));
     $accountSelect = $form->createElement('select', 'accountId', array('label' => 'default-index-history:viewReservations'));
     $accountSelect->setRequired(false);
     $account = new Ot_Account();
     $accounts = $account->fetchAll(null, array('lastName', 'firstName'));
     foreach ($accounts as $a) {
         $accountSelect->addMultiOption($a->accountId, $a->firstName . ' ' . $a->lastName . ' (' . $a->username . ')');
     }
     $submit = $form->createElement('submit', 'submitButton', array('label' => 'default-index-history:lookup'));
     $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit'))));
     $form->addElements(array($accountSelect));
     $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit));
     $this->view->form = $form;
     $event = new Event();
     $myEvents = $event->getEventsForUser($thisAccount->accountId);
     $this->view->myEvents = $myEvents['currentEvents'];
     $this->view->myPastEvents = $myEvents['pastEvents'];
     $this->view->account = $thisAccount->toArray();
     $this->view->hideFeature = true;
     $this->_helper->layout->setLayout('my');
     $this->view->messages = $this->_helper->flashMessenger->getMessages();
     $this->view->headScript()->appendFile($this->view->baseUrl() . '/scripts/jquery.autocomplete.js');
     $this->view->headLink()->appendStylesheet($this->view->baseUrl() . '/css/jquery.autocomplete.css');
 }
Esempio n. 2
0
 public function rollForm($values = array())
 {
     if (!isset($values['eventId'])) {
         throw new Ot_Exception_Data('Event ID must be provided');
     }
     $form = new Zend_Form();
     $form->setAttrib('id', 'rollForm')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form')), 'Form'));
     $attendee = new Event_Attendee();
     $attendees = $attendee->getAttendeesForEvent($values['eventId'], 'attending');
     $otAccount = new Ot_Account();
     $attendeeList = array();
     foreach ($attendees as $a) {
         $thisAccount = $otAccount->find($a['accountId']);
         if (!is_null($thisAccount)) {
             $attendeeList[$a['accountId']] = $thisAccount->firstName . ' ' . $thisAccount->lastName . ' (' . $thisAccount->username . ')';
         }
     }
     $attendeeElement = $form->createElement('multiCheckbox', 'attendees');
     $attendeeElement->setMultiOptions($attendeeList)->setValue(isset($values['attendees']) ? $values['attendees'] : '');
     $submit = $form->createElement('submit', 'submitButton', array('label' => 'Submit'));
     $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit'))));
     $cancel = $form->createElement('button', 'cancel', array('label' => 'Cancel'));
     $cancel->setAttrib('id', 'cancel');
     $cancel->setDecorators(array(array('ViewHelper', array('helper' => 'formButton'))));
     $form->addElements(array($attendeeElement));
     $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit, $cancel));
     $eventId = $form->createElement('hidden', 'eventId');
     $eventId->setValue($values['eventId']);
     $eventId->setDecorators(array(array('ViewHelper', array('helper' => 'formHidden'))));
     $form->addElement($eventId);
     return $form;
 }
 /**
  * Allows a user to contact all the people in their event.
  *
  */
 public function contactAction()
 {
     if ($this->_request->isXmlHttpRequest()) {
         $this->_helper->layout->disableLayout();
     } else {
         $this->_helper->pageTitle('workshop-instructor-contact:title');
     }
     $get = Zend_Registry::get('getFilter');
     if (!isset($get->eventId)) {
         throw new Ot_Exception_Input('msg-error-eventIdNotSet');
     }
     $messages = array();
     $event = new Event();
     $eventId = $get->eventId;
     $thisEvent = $event->find($eventId);
     if (is_null($thisEvent)) {
         throw new Ot_Exception_Data('msg-error-noEvent');
     }
     $otAccount = new Ot_Account();
     $thisAccount = $otAccount->find(Zend_Auth::getInstance()->getIdentity()->accountId);
     $status = $event->getStatusOfUserForEvent($thisAccount->accountId, $eventId);
     if ($status != 'instructor' && !$this->_helper->hasAccess('view-all-instructor-pages')) {
         throw new Ot_Exception_Access('msg-error-notInstructor');
     }
     $form = $event->contactForm(array('eventId' => $eventId));
     if ($this->_request->isPost()) {
         if ($form->isValid($_POST)) {
             $recipients = array();
             $attendees = new Event_Attendee();
             $recipients = $attendees->getAttendeesForEvent($thisEvent->eventId, $form->getValue('recipients'));
             if ($form->getValue('emailInstructors')) {
                 $instructor = new Event_Instructor();
                 $instructorList = $instructor->getInstructorsForEvent($thisEvent->eventId);
                 $recipients = array_merge($recipients, $instructorList);
             }
             $this->_checkValidViewer($instructorList);
             $mail = new Zend_Mail();
             $mail->setFrom($thisAccount->emailAddress, $thisAccount->firstName . ' ' . $thisAccount->lastName);
             $mail->setSubject($form->getValue('subject'));
             $mail->setBodyText($form->getValue('message'));
             $mail->addTo($thisAccount->emailAddress);
             foreach ($recipients as $r) {
                 $mail->addBcc($r['emailAddress']);
             }
             $eq = new Ot_Email_Queue();
             $data = array('attributeName' => 'eventId', 'attributeId' => $thisEvent->eventId, 'zendMailObject' => $mail);
             $eq->queueEmail($data);
             //$mail->send();
             $this->_helper->flashMessenger->addMessage('msg-info-emailQueued');
             $this->_redirect('/workshop/instructor/?eventId=' . $thisEvent->eventId);
         } else {
             $messages[] = "msg-error-formSubmitProblem";
         }
     }
     $this->view->messages = $messages;
     $this->view->thisAccount = $thisAccount;
     $this->view->form = $form;
 }
Esempio n. 4
0
 /**
  * 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');
 }