/** * @copyright Copyright (C) 2008 redCOMPONENT.com. All rights reserved. * @license GNU/GPL, see LICENSE.php * redFORM can be downloaded from www.redcomponent.com * redFORM is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License 2 * as published by the Free Software Foundation. * redFORM is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with redFORM; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ defined('_JEXEC') or die('Direct Access to this location is not allowed.'); $rfcore = new redFormCore(); ?> <form action="index.php?option=com_redform&controller=submitters" method="post" name="redform" id="adminForm" enctype="multipart/form-data" onsubmit="return CheckSubmit(this);"> <?php echo $rfcore->getFormFields($this->form_id, array($this->submitter->sid), 1); ?> <input type="hidden" name="task" id="task" value="save" /> <input type="hidden" name="integration" id="integration" value="<?php $this->submitter->integration; ?> " /> </form>
/** * 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; }
</td> </tr> <?php } ?> </table> </fieldset> <fieldset class="adminform editevent"><legend><?php echo JText::_('COM_REDEVENT_Answers'); ?> </legend> <?php $options = array('extrafields' => array(array('label' => JText::_('COM_REDEVENT_REGISTRATION_PRICE'), 'field' => $this->lists['pricegroup_id']))); $rfcore = new redFormCore(); echo $rfcore->getFormFields($this->row->form_id, $this->row->sid ? array($this->row->sid) : null, 1, $options); ?> </fieldset> <?php echo JHTML::_('form.token'); ?> <input type="hidden" name="option" value="com_redevent" /> <input type="hidden" name="controller" value="attendees" /> <input type="hidden" name="view" value="attendee" /> <input type="hidden" name="id" value="<?php echo $this->row->id; ?> " />
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); } }