コード例 #1
0
ファイル: view.html.php プロジェクト: jaanusnurmoja/redjoomla
 function display($tpl = null)
 {
     $mainframe =& JFactory::getApplication();
     //Load pane behavior
     jimport('joomla.html.pane');
     //initialise variables
     $editor =& JFactory::getEditor();
     $document =& JFactory::getDocument();
     $user =& JFactory::getUser();
     $cid = JRequest::getVar('cid');
     $document->setTitle(JText::_('COM_REDEVENT_PAGETITLE_EDITATTENDEE'));
     //add css to document
     $document->addStyleSheet('components/com_redevent/assets/css/redeventbackend.css');
     $row =& $this->get('data');
     //make data safe
     JFilterOutput::objectHTMLSafe($row);
     //create selectlists
     $lists = array();
     //user list
     $lists['user'] = JHTML::_('list.users', 'uid', $row->uid, 1, NULL, 'name', 0);
     $sessionpricegroups = $this->get('Pricegroups');
     $lists['pricegroup_id'] = redEVENTHelper::getRfPricesSelect($sessionpricegroups, $row->pricegroup_id);
     //build toolbar
     if (!empty($cid)) {
         JToolBarHelper::title(JText::_('COM_REDEVENT_EDIT_REGISTRATION'), 'registrations');
         JToolBarHelper::spacer();
     } else {
         JToolBarHelper::title(JText::_('COM_REDEVENT_ADD_REGISTRATION'), 'registrations');
         JToolBarHelper::spacer();
     }
     JToolBarHelper::apply();
     JToolBarHelper::save();
     JToolBarHelper::spacer();
     JToolBarHelper::cancel();
     JToolBarHelper::spacer();
     //JToolBarHelper::help( 'el.registrationedit', true );
     //		echo '<pre>';print_r($row); echo '</pre>';exit;
     $this->assignRef('row', $row);
     $this->assignRef('lists', $lists);
     parent::display($tpl);
 }
コード例 #2
0
 /**
  * returns form
  * 
  * @return string
  */
 function getForm()
 {
     $app =& JFactory::getApplication();
     $submit_key = JRequest::getVar('submit_key');
     $details = $this->getEvent()->getData();
     $prices = $this->getEvent()->getPrices();
     $options = array('extrafields' => array());
     $user =& JFactory::getUser();
     $rfcore = $this->_getRFCore();
     if (!$rfcore->getFormStatus($this->getEvent()->getData()->redform_id)) {
         $error = $rfcore->getError();
         return '<span class="redform_error">' . $error . '</span>';
     }
     $form = $rfcore->getForm($this->getEvent()->getData()->redform_id);
     $action = JRoute::_(RedeventHelperRoute::getRegistrationRoute($this->getEvent()->getData()->xslug, 'register'));
     // multiple signup ?
     $single = JRequest::getInt('single', 0);
     $max = $this->getEvent()->getData()->max_multi_signup;
     if ($max && !$single && $user->get('id')) {
         $multi = $max;
         // we must deduce current registrations of this user !
         $nbregs = $this->_getCurrentRegs();
         $multi = $max - $nbregs;
         if ($multi < 1) {
             return JText::_('COM_REDEVENT_USER_MAX_REGISTRATION_REACHED');
         }
     } else {
         // single signup
         $multi = 1;
     }
     // multiple pricegroup handling
     $selpg = null;
     if (count($prices)) {
         $currency = current($prices)->currency ? current($prices)->currency : null;
         // is pricegroup already selected ?
         // if a review, we already have pricegroup_id in session
         $pgids = $app->getUserState('pgids' . $submit_key);
         if (!empty($pgids)) {
             $pg = intval($pgids[0]);
         } else {
             $pg = JRequest::getInt('pg');
         }
         if (count($prices) == 1) {
             $selpg = current($prices);
         } else {
             if ($pg) {
                 foreach ($prices as $p) {
                     if ($p->pricegroup_id == $pg) {
                         $selpg = $p;
                         break;
                     }
                 }
             }
         }
         if ($multi > 1 && count($prices) > 1 || !$selpg) {
             $field = array();
             $field['label'] = '<label for="pricegroup_id">' . JText::_('COM_REDEVENT_REGISTRATION_PRICE') . ($currency ? ' <span class="price-currency">(' . $currency . ')</span>' : '') . '</label>';
             $field['field'] = redEVENTHelper::getRfPricesSelect($prices);
             $field['class'] = 'reg-price';
             $options['extrafields'][] = $field;
         } else {
             $field = array();
             $field['label'] = '<label for="pricegroup_id">' . JText::_('COM_REDEVENT_REGISTRATION_PRICE') . '</label>';
             $field['field'] = REOutput::formatprice($selpg->price, $currency) . (count($prices) > 1 ? ' (' . $selpg->name . ')' : '') . '<input type="hidden" name="pricegroup_id[]" class="fixedprice" value="' . $selpg->pricegroup_id . '" price="' . $selpg->price . '" />';
             $field['class'] = 'reg-price pg' . $selpg->id;
             $options['extrafields'][] = $field;
         }
     }
     $details->course_price = null;
     $options['booking'] = $details;
     $html = '<form action="' . $action . '" method="post" name="redform" enctype="multipart/form-data" onsubmit="return CheckSubmit(this);">';
     $html .= $rfcore->getFormFields($this->getEvent()->getData()->redform_id, $submit_key, $multi, $options);
     $html .= '<input type="hidden" name="xref" value="' . $this->_xref . '"/>';
     if ($this->getOption('hasreview')) {
         $html .= '<input type="hidden" name="hasreview" value="1"/>';
     }
     $html .= '<div id="submit_button" style="display: block;" class="submitform' . $form->classname . '">';
     if (empty($submit_key)) {
         $html .= '<input type="submit" id="regularsubmit" name="submit" value="' . JText::_('COM_REDEVENT_Submit') . '" />';
     } else {
         $html .= '<input type="submit" id="redformsubmit" name="submit" value="' . JText::_('COM_REDEVENT_Confirm') . '" />';
         $html .= '<input type="submit" id="redformcancel" name="cancel" value="' . JText::_('COM_REDEVENT_Cancel') . '" />';
     }
     $html .= '</div>';
     $html .= '</form>';
     return $html;
 }
コード例 #3
0
 function _displayEdit($tpl = null)
 {
     $user =& JFactory::getUser();
     $acl = new UserAcl();
     $xref = JRequest::getInt('xref');
     $submitter_id = JRequest::getInt('submitter_id');
     if (!$submitter_id) {
         JError::raise(0, 'Registration id required');
         return false;
     }
     $model = $this->getModel();
     $model->setXref($xref);
     $course = $this->get('SessionDetails');
     $registration = $model->getRegistration($submitter_id);
     if (!$registration) {
         JError::raise(0, $model->getError);
         return false;
     }
     if ($acl->canManageAttendees($registration->xref) && JRequest::getVar('task') == 'manageredit') {
         $action = JRoute::_(RedeventHelperRoute::getRegistrationRoute($xref, 'managerupdate'));
     } else {
         if ($registration->uid == $user->get('id')) {
             $action = JRoute::_(RedeventHelperRoute::getRegistrationRoute($xref, 'update'));
         } else {
             JError::raiseError(403, 'NOT AUTHORIZED');
             return false;
         }
     }
     $rfoptions = array();
     $prices = $this->get('Pricegroups');
     $field = array();
     $field['label'] = '<label for="pricegroup_id">' . JText::_('COM_REDEVENT_REGISTRATION_PRICE') . '</label>';
     $field['field'] = redEVENTHelper::getRfPricesSelect($prices, $registration->pricegroup_id);
     $rfoptions['extrafields'][] = $field;
     $rfcore = new RedformCore();
     $rfields = $rfcore->getFormFields($course->redform_id, array($submitter_id), 1, $rfoptions);
     $this->assign('action', $action);
     $this->assign('rfields', $rfields);
     $this->assign('xref', $xref);
     parent::display($tpl);
 }