Beispiel #1
0
 /**
  * Method to store the attendee
  *
  * @access	public
  * @return	boolean	True on success
  * @since	1.5
  */
 function store($data)
 {
     $xref = intval($data['xref']);
     $pricegroup = intval($data['pricegroup_id']);
     $id = JRequest::getInt('id');
     // get price
     $query = ' SELECT pg.price, a.activate ' . ' FROM #__redevent_event_venue_xref AS x ' . ' INNER JOIN #__redevent_events AS a ON a.id =  x.eventid ' . ' LEFT JOIN #__redevent_sessions_pricegroups AS pg ON pg.xref =  x.id AND pg.pricegroup_id = ' . $pricegroup . ' WHERE x.id = ' . $xref;
     $this->_db->setQuery($query);
     $details = $this->_db->loadObject();
     // first save redform data
     $rfcore = new redFormCore();
     $result = $rfcore->saveAnswers('redevent', array('baseprice' => $details->price, 'edit' => 1));
     if (!$result) {
         $msg = JText::_('COM_REDEVENT_REGISTRATION_REDFORM_SAVE_FAILED');
         $this->setError($msg . ' - ' . $rfcore->getError());
         return false;
     }
     // adding to data for register saving
     $data['submit_key'] = $result->submit_key;
     $data['sid'] = $result->posts[0]['sid'];
     if ($details->activate == 0) {
         $data['confirmed'] = 1;
         $data['confirmdate'] = gmdate('Y-m-d H:i:s');
         $data['paymentstart'] = gmdate('Y-m-d H:i:s');
     }
     $row =& JTable::getInstance('redevent_register', '');
     if ($id) {
         $row->load($id);
     }
     //Bind the form fields to the table
     if (!$row->bind($data)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // Make sure the data is valid
     if (!$row->check()) {
         $this->setError($row->getError());
         return false;
     }
     //Store the table to the database
     if (!$row->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     return $row->id;
 }
Beispiel #2
0
 function update()
 {
     $xref = JRequest::getInt('xref');
     $task = JRequest::getVar('task');
     if (JRequest::getVar('cancel', '', 'post')) {
         $msg = JText::_('COM_REDEVENT_Registration_Edit_cancelled');
         if ($task == 'managerupdate') {
             $this->setRedirect(JRoute::_(RedeventHelperRoute::getManageAttendees($xref)), $msg);
         } else {
             $this->setRedirect(JRoute::_(RedeventHelperRoute::getDetailsRoute(null, $xref), false), $msg);
         }
         $this->redirect();
     }
     $xref = JRequest::getInt('xref');
     $pricegroups = JRequest::getVar('pricegroup_id', array(), 'post', 'array');
     JArrayHelper::toInteger($pricegroups);
     $model = $this->getModel('registration');
     $model->setXref(JRequest::getInt('xref'));
     $details = $model->getSessionDetails();
     $submit_key = JRequest::getVar('submit_key');
     $prices = array();
     foreach ($pricegroups as $p) {
         $price = $model->getRegistrationPrice($p);
         if ($price === false) {
             $msg = JText::_('COM_REDEVENT_REGISTRATION_MISSING_PRICE');
             $this->setRedirect('index.php', $msg, 'error');
             return;
         }
         $prices[] = $price;
     }
     if (!$xref) {
         $msg = JText::_('COM_REDEVENT_REGISTRATION_MISSING_XREF');
         $this->setRedirect('index.php', $msg, 'error');
         return;
     }
     // first, ask redform to save it's fields, and return the corresponding sids.
     $options = array('baseprice' => $prices);
     $rfcore = new redFormCore();
     $result = $rfcore->saveAnswers('redevent', $options);
     if (!$result) {
         $msg = JText::_('COM_REDEVENT_REGISTRATION_REDFORM_SAVE_FAILED') . ' - ' . $rfcore->getError();
         if ($task == 'managerupdate') {
             $this->setRedirect(JRoute::_(RedeventHelperRoute::getManageAttendees($xref)), $msg, 'error');
         } else {
             $this->setRedirect(JRoute::_(RedeventHelperRoute::getDetailsRoute(null, $xref)), $msg, 'error');
         }
         return;
     }
     JRequest::setVar('submit_key', $result->submit_key);
     // redform save fine, now save corresponding bookings
     foreach ($result->posts as $rfpost) {
         $k = 0;
         if (!($res = $model->update($rfpost['sid'], $result->submit_key, $pricegroups[$k++]))) {
             $msg = JText::_('COM_REDEVENT_REGISTRATION_REGISTRATION_UPDATE_FAILED');
             if ($task == 'managerupdate') {
                 $this->setRedirect(JRoute::_(RedeventHelperRoute::getManageAttendees($xref)), $msg, 'error');
             } else {
                 $this->setRedirect(JRoute::_(RedeventHelperRoute::getDetailsRoute(null, $xref)), $msg, 'error');
             }
             return;
         }
     }
     //		$mail = $model->sendNotificationEmail();
     //		$mail = $model->notifyManagers();
     $cache = JFactory::getCache('com_redevent');
     $cache->clean();
     $msg = JTEXT::_('COM_REDEVENT_REGISTRATION_UPDATED');
     if ($task == 'managerupdate') {
         $this->setRedirect(RedeventHelperRoute::getManageAttendees($xref), $msg);
     } else {
         $this->setRedirect(RedeventHelperRoute::getDetailsRoute(null, $xref), $msg);
     }
 }