public function execute($lastRunDt = null)
 {
     $config = Zend_Registry::get('config');
     $checkDtStart = new Zend_Date($this->_lastRunDt);
     $checkDtStart->subHour($config->user->numHoursEvaluationReminder->val);
     $checkDtEnd = new Zend_Date();
     $checkDtEnd->subHour($config->user->numHoursEvaluationReminder->val);
     $event = new Event();
     $events = $event->getEvents(null, null, null, $checkDtStart->getTimestamp(), $checkDtEnd->getTimestamp(), 'open');
     $location = new Location();
     $workshop = new Workshop();
     $instructor = new Event_Instructor();
     $attendee = new Event_Attendee();
     $eu = new Evaluation_User();
     foreach ($events as $e) {
         $startDt = strtotime($e->date . ' ' . $e->startTime);
         $endDt = strtotime($e->date . ' ' . $e->endTime);
         if ($checkDtStart->getTimestamp() < $endDt && $checkDtEnd->getTimestamp() >= $endDt) {
             $evalAvailableDt = new Zend_Date($endDt);
             $evalAvailableDt->addHour($config->user->numHoursEvaluationAvailability->val);
             if ($evalAvailableDt->getTimestamp() > time()) {
                 $taken = $eu->getCompleted($e->eventId);
                 $thisLocation = $location->find($e->locationId);
                 if (is_null($thisLocation)) {
                     throw new Ot_Exception_Data('msg-error-noLocation');
                 }
                 $thisWorkshop = $workshop->find($e->workshopId);
                 if (is_null($thisWorkshop)) {
                     throw new Ot_Exception_Data('msg-error-noWorkshop');
                 }
                 $instructors = $instructor->getInstructorsForEvent($e->eventId);
                 $instructorNames = array();
                 $instructorEmails = array();
                 foreach ($instructors as $i) {
                     $instructorNames[] = $i['firstName'] . ' ' . $i['lastName'];
                     $instructorEmails[] = $i['emailAddress'];
                 }
                 $data = array('workshopName' => $thisWorkshop->title, 'workshopDate' => date('m/d/Y', $startDt), 'workshopStartTime' => date('g:i a', $startDt), 'workshopEndTime' => date('g:i a', $endDt), 'workshopMinimumEnrollment' => $e->minSize, 'workshopCurrentEnrollment' => $e->roleSize, 'locationName' => $thisLocation->name, 'locationAddress' => $thisLocation->address, 'instructorNames' => implode(', ', $instructorNames), 'instructorEmails' => implode(', ', $instructorEmails));
                 $attending = $attendee->getAttendeesForEvent($e->eventId, 'attending');
                 foreach ($attending as $a) {
                     if ($a['attended'] == 1 && !in_array($a['accountId'], $taken)) {
                         $trigger = new Ot_Trigger();
                         $trigger->setVariables($data);
                         $trigger->accountId = $a['accountId'];
                         $trigger->studentEmail = $a['emailAddress'];
                         $trigger->studentName = $a['firstName'] . ' ' . $a['lastName'];
                         $trigger->studentUsername = $a['username'];
                         $trigger->dispatch('Event_Evaluation_Reminder');
                     }
                 }
             }
         }
     }
 }
 public function execute($lastRunDt = null)
 {
     $config = Zend_Registry::get('config');
     $event = new Event();
     $events = $event->getEvents(null, null, null, time(), null, 'open');
     $location = new Location();
     $workshop = new Workshop();
     $instructor = new Event_Instructor();
     $checkDt = new Zend_Date($this->_lastRunDt);
     $checkDt->addHour($config->user->numHoursLowAttendanceNotification->val);
     foreach ($events as $e) {
         if ($e->roleSize < $e->minSize) {
             $startDt = strtotime($e->date . ' ' . $e->startTime);
             $endDt = strtotime($e->date . ' ' . $e->endTime);
             if ($checkDt->getTimestamp() > $startDt && $this->_lastRunDt < $startDt) {
                 $thisLocation = $location->find($e->locationId);
                 if (is_null($thisLocation)) {
                     throw new Ot_Exception_Data('msg-error-noLocation');
                 }
                 $thisWorkshop = $workshop->find($e->workshopId);
                 if (is_null($thisWorkshop)) {
                     throw new Ot_Exception_Data('msg-error-noWorkshop');
                 }
                 $instructors = $instructor->getInstructorsForEvent($e->eventId);
                 $instructorNames = array();
                 $instructorEmails = array();
                 foreach ($instructors as $i) {
                     $instructorNames[] = $i['firstName'] . ' ' . $i['lastName'];
                     $instructorEmails[] = $i['emailAddress'];
                 }
                 $data = array('workshopName' => $thisWorkshop->title, 'workshopDate' => date('m/d/Y', $startDt), 'workshopStartTime' => date('g:i a', $startDt), 'workshopEndTime' => date('g:i a', $endDt), 'workshopMinimumEnrollment' => $e->minSize, 'workshopCurrentEnrollment' => $e->roleSize, 'locationName' => $thisLocation->name, 'locationAddress' => $thisLocation->address, 'instructorNames' => implode(', ', $instructorNames), 'instructorEmails' => implode(', ', $instructorEmails));
                 $trigger = new Ot_Trigger();
                 $trigger->setVariables($data);
                 $trigger->dispatch('Event_LowAttendance');
             }
         }
     }
 }
 /**
  * Allows a user to edit a location type
  *
  */
 public function editAction()
 {
     $messages = array();
     $get = Zend_Registry::get('getFilter');
     if (!isset($get->typeId)) {
         throw new Ot_Exception_Input('msg-error-typeIdNotSet');
     }
     $locationType = new LocationType();
     $thisLocationType = $locationType->find($get->typeId);
     if (is_null($thisLocationType)) {
         throw new Ot_Exception_Data('msg-error-noLocationType');
     }
     $form = $locationType->form($thisLocationType->toArray());
     if ($this->_request->isPost()) {
         if ($form->isValid($_POST)) {
             $data = array('typeId' => $form->getValue('typeId'), 'name' => $form->getValue('name'), 'description' => $form->getValue('description'));
             $locationType->update($data, null);
             $trigger = new Ot_Trigger();
             $data['accountId'] = Zend_Auth::getInstance()->getIdentity()->accountId;
             $trigger->setVariables($data);
             $trigger->dispatch('LocationType_Edit');
             $this->_helper->flashMessenger->addMessage('msg-info-locationTypeModified');
             $this->_helper->redirector->gotoUrl('/workshop/locationType/details/?typeId=' . $form->getValue('typeId'));
         } else {
             $messages[] = "msg-error-formSubmitProblem";
         }
     }
     $this->view->messages = $messages;
     $this->view->form = $form;
     $this->view->headScript()->appendFile($this->view->baseUrl() . '/scripts/workshop/location-type/edit.js');
     $this->view->headScript()->appendFile($this->view->baseUrl() . '/scripts/jquery.wysiwyg.js');
     $this->view->headLink()->appendStylesheet($this->view->baseUrl() . '/css/jquery.wysiwyg.css');
     $this->_helper->pageTitle('workshop-location-edit:title');
 }
 public function execute($lastRunDt = null)
 {
     $config = Zend_Registry::get('config');
     $event = new Event();
     $events = $event->getEvents(null, null, null, time(), null, 'open');
     $location = new Location();
     $workshop = new Workshop();
     $instructor = new Event_Instructor();
     $attendees = new Event_Attendee();
     $lastRunDt = new Zend_Date($this->_lastRunDt);
     $currentDt = new Zend_Date();
     foreach ($events as $e) {
         $startDt = strtotime($e->date . ' ' . $e->startTime);
         $endDt = strtotime($e->date . ' ' . $e->endTime);
         $firstDt = new Zend_Date($startDt);
         $firstDt->subHour($config->user->numHoursFirstReminder->val);
         $finalDt = new Zend_Date($startDt);
         $finalDt->subHour($config->user->numHoursFinalReminder->val);
         $notification = null;
         if ($firstDt->getTimestamp() > $lastRunDt->getTimestamp() && $firstDt->getTimestamp() < $currentDt->getTimestamp()) {
             $notification = 'first';
         }
         if ($finalDt->getTimestamp() > $lastRunDt->getTimestamp() && $finalDt->getTimestamp() < $currentDt->getTimestamp()) {
             $notification = 'final';
         }
         if (!is_null($notification)) {
             $thisLocation = $location->find($e->locationId);
             if (is_null($thisLocation)) {
                 throw new Ot_Exception_Data('msg-error-noLocation');
             }
             $thisWorkshop = $workshop->find($e->workshopId);
             if (is_null($thisWorkshop)) {
                 throw new Ot_Exception_Data('msg-error-noWorkshop');
             }
             $instructors = $instructor->getInstructorsForEvent($e->eventId);
             $instructorNames = array();
             $instructorEmails = array();
             foreach ($instructors as $i) {
                 $instructorNames[] = $i['firstName'] . ' ' . $i['lastName'];
                 $instructorEmails[] = $i['emailAddress'];
             }
             $data = array('workshopName' => $thisWorkshop->title, 'workshopDate' => date('m/d/Y', $startDt), 'workshopStartTime' => date('g:i a', $startDt), 'workshopEndTime' => date('g:i a', $endDt), 'workshopMinimumEnrollment' => $e->minSize, 'workshopCurrentEnrollment' => $e->roleSize, 'locationName' => $thisLocation->name, 'locationAddress' => $thisLocation->address, 'instructorNames' => implode(', ', $instructorNames), 'instructorEmails' => implode(', ', $instructorEmails));
             $attending = $attendees->getAttendeesForEvent($e->eventId, 'attending');
             foreach ($attending as $a) {
                 $trigger = new Ot_Trigger();
                 $trigger->setVariables($data);
                 $trigger->accountId = $a['accountId'];
                 $trigger->studentEmail = $a['emailAddress'];
                 $trigger->studentName = $a['firstName'] . ' ' . $a['lastName'];
                 if ($notification == 'final') {
                     $trigger->dispatch('Event_Attendee_Final_Reminder');
                 } else {
                     $trigger->dispatch('Event_Attendee_First_Reminder');
                 }
             }
             $trigger = new Ot_Trigger();
             $trigger->setVariables($data);
             if ($notification == 'final') {
                 $trigger->dispatch('Event_Instructor_Final_Reminder');
             } else {
                 $trigger->dispatch('Event_Instructor_First_Reminder');
             }
         }
     }
 }
 /**
  * Allows a user to delete an attendee from an event.
  *
  */
 public function removeAttendeeAction()
 {
     $get = Zend_Registry::get('getFilter');
     if (!isset($get->eventId)) {
         throw new Ot_Exception_Input('msg-error-eventIdNotSet');
     }
     // lookup the event
     $event = new Event();
     $thisEvent = $event->find($get->eventId);
     if (is_null($thisEvent)) {
         throw new Ot_Exception_Data('msg-error-noEvent');
     }
     $workshop = new Workshop();
     $thisWorkshop = $workshop->find($thisEvent->workshopId);
     if (is_null($thisWorkshop)) {
         throw new Ot_Exception_Data('msg-error-noWorkshop');
     }
     $location = new Location();
     $thisLocation = $location->find($thisEvent->locationId);
     if (is_null($thisLocation)) {
         throw new Ot_Exception_Data('msg-error-noLocation');
     }
     $otAccount = new Ot_Account();
     $up = $otAccount->find($get->accountId);
     if (is_null($up)) {
         throw new Ot_Exception_Input('msg-error-noAccount');
     }
     $instructor = new Event_Instructor();
     $instructors = $instructor->getInstructorsForEvent($thisEvent->eventId);
     $this->_checkValidViewer($instructors);
     $instructorNames = array();
     $instructorEmails = array();
     foreach ($instructors as $i) {
         $instructorNames[] = $i['firstName'] . ' ' . $i['lastName'];
         $instructorEmails[] = $i['emailAddress'];
     }
     $attendee = new Event_Attendee();
     $attendee->cancelReservation($get->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, 'studentAcountId' => $get->accountId, 'instructorNames' => implode(', ', $instructorNames), 'instructorEmails' => implode(', ', $instructorEmails), 'studentEmail' => $up->emailAddress, 'studentFirstName' => $up->firstName, 'studentLastName' => $up->lastName, 'studentUsername' => $up->username, 'studentAccountId' => $up->accountId);
     $trigger = new Ot_Trigger();
     $trigger->setVariables($data);
     $trigger->dispatch('Instructor_Cancels_Users_Reservation');
     $waiting = $attendee->getAttendeesForEvent($thisEvent->eventId, 'waitlist');
     if (count($waiting) != 0) {
         $up = $otAccount->find($waiting[0]['accountId']);
         if (!is_null($up)) {
             $attendee->makeReservation($up->accountId, $thisEvent->eventId);
             $data['studentEmail'] = $up->emailAddress;
             $data['studentFirstName'] = $up->firstName;
             $data['studentLastName'] = $up->lastName;
             $data['username'] = $up->username;
             $data['studentAccountId'] = $up->accountId;
             $trigger = new Ot_Trigger();
             $trigger->setVariables($data);
             $trigger->dispatch('User_Automatically_Moved_From_Waitlist_To_Attending');
         }
     }
     $this->_helper->flashMessenger->addMessage('msg-info-userRemoved');
     $this->_redirect('/workshop/instructor/?eventId=' . $thisEvent->eventId);
 }
示例#6
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');
 }