_messageTemplates[self::MSG_SIGNED] = 'Attendee has been added to Event'; $this->_messageTemplates[static::MSG_SIGNED_MULTI] = 'Attendees have been added to Event'; $this->_pageHeaderTemplates['headerChooseEvent'] = 'Choose %itemName%'; $this->_pageHeaderTemplates['headerNewAttendee'] = 'Add new %itemName% Attendee(s)'; return parent::_init(); } protected function _getChooseEventForm(array $options = array()) { $options['dataObj'] = $this->_getDataObj(); return $this->_getFormInstance('chooseEvent', $options); } protected function _doChooseEvent() { $userId = (int) Qs_Request::getRequestValue('userId'); $obj = $this->_getDataObj(); if ($obj->hasPrimaryKey()) { $eventId = $obj->getPrimaryKey(); Qs_Http::redirect($this->url(array('action' => 'newAttendee', 'userId' => $userId, 'id' => $eventId))); exit; } $form = $this->_getChooseEventForm(array( 'defaults' => array('userId' => $userId) )); $form->setDefaults(); $this->_addFormItem($form); return $this; } protected function _doUseEvent() { $form = $this->_getChooseEventForm(); if ($form->validate()) { $eventId = (int) $form->getValue('eventId'); $userId = (int) $form->getValue('userId'); Qs_Http::redirect($this->url(array('action' => 'newAttendee', 'userId' => $userId, 'id' => $eventId))); $this->_doBack(); } else { $this->_addFormItem($form); } return $this; } protected function _doUseEventAjax() { $form = $this->_getChooseEventForm(); $this->_displayJson($form->validateAjax()); } protected function _getSignupForm(array $options = array()) { $options['dataObj'] = $this->_getDataObj(); $options['userAutocompleteUrl'] = App_User_Admin_View::getAutocompleteNameEmailUrl(); $options['showWaiver'] = $this->_getDataObj()->getShowWaiver(); if (($userId = (int) Qs_Request::getGetValue('userId'))) { $options['userId'] = $userId; } return $this->_getFormInstance('signup', $options); } protected function _doNewAttendee() { if (!$this->_getDataObj()->hasPrimaryKey()) { $userId = (int) Qs_Request::getGetValue('userId'); Qs_Http::redirect($this->url(array('action' => 'chooseEvent', 'userId' => $userId))); exit; } if (false == $this->_getDataObj()->getData('registrationAllowed')) { Qs_Http::redirect($this->url()); exit; } $form = $this->_getSignupForm(); $form->setDefaults(); $this->_addFormItem($form); return $this; } protected function _doInsertAttendee() { $form = $this->_getSignupForm(); if ($form->validate()) { $data = $form->getValues(); $this->_getDataObj()->initFromSignupForm($data); if (false === $this->_getDataObj()->insertAttendee()) { $this->_setBackErrors($this->_getDataObj()->getErrors()); } else { $data = $this->_getDataObj()->getData(); $attendees = $data['attendees']; $this->_postInsertAttendee(); $this->_setBackMessage((1 < count($attendees)) ? static::MSG_SIGNED_MULTI : static::MSG_SIGNED); } $this->_doBack(); } else { $this->_addFormItem($form); } return $this; } protected function _postInsertAttendee() { $this->_sendSignupNotification(); return $this; } protected function _doInsertAttendeeAjax() { $form = $this->_getSignupForm(); $this->_displayJson($form->validateAjax()); } }