Index: CRM/Event/Form/Registration.php
===================================================================
--- CRM/Event/Form/Registration.php (revision 19748)
+++ CRM/Event/Form/Registration.php (working copy)
@@ -634,7 +634,13 @@
// reuse id if one already exists for this one (can happen
// with back button being hit etc)
- if ( $this->_eventId ) {
+ /**
+ * ALTERED BY CHRIS IVENS
+ * We need to re-work this so that we can store the same ID for multiple participants. This is for the placeholder attendees.
+ *
+ * Changed $this->_eventId TO $this->_eventId && !$params['registered_by_id']
+ */
+ if ( $this->_eventId && !$params['registered_by_id']) {
$sql = "
SELECT id
FROM civicrm_participant
Index: CRM/Event/Form/Registration/AdditionalParticipant.php
===================================================================
--- CRM/Event/Form/Registration/AdditionalParticipant.php (revision 19748)
+++ CRM/Event/Form/Registration/AdditionalParticipant.php (working copy)
@@ -97,7 +97,8 @@
{
$config =& CRM_Core_Config::singleton( );
$button = substr( $this->controller->getButtonName(), -4 );
- $required = ( $button == 'skip' ) ? false : true;
+ $required = ( $button == 'skip' || $button == 'temp' ) ? false : true;
+
$this->add( 'text',
"email-{$this->_bltID}",
ts( 'Email Address' ),
@@ -126,6 +127,10 @@
array ( 'type' => 'next',
'name' => ts('Skip Participant >>|'),
'subName' => 'skip' ),
+
+ array ( 'type' => 'next',
+ 'name' => ts('Just reserve place'),
+ 'subName' => 'temp' ),
)
);
@@ -148,7 +153,7 @@
$errors = array( );
//get the button name.
$button = substr( $self->controller->getButtonName(), -4 );
- if ( $button != 'skip' ) {
+ if ( $button != 'skip' && $button != 'temp') {
//Additional Participant can also register for an event only once
require_once 'CRM/Event/Form/Registration/Register.php';
$isRegistered = CRM_Event_Form_Registration_Register::checkRegistration( $fields, $self, true );
@@ -212,6 +217,9 @@
}
} else {
$params = $this->controller->exportValues( $this->_name );
+ if ( $button == 'temp' ) {
+ $params['email-5'] = $this->_params[0]['email-5'];
+ }
if ( $this->_values['event']['is_monetary'] ) {
//added for discount
Index: CRM/Event/Form/UpdateRegister.php
===================================================================
--- CRM/Event/Form/UpdateRegister.php (revision 0)
+++ CRM/Event/Form/UpdateRegister.php (revision 0)
@@ -0,0 +1,382 @@
+_eventId = CRM_Utils_Request::retrieve( 'id' , 'Positive', $this, true );
+ $this->_action = CRM_Utils_Request::retrieve( 'action', 'String' , $this, false );
+
+ // current mode
+ $this->_mode = ( $this->_action == 1024 ) ? 'test' : 'live';
+
+ $this->_values = $this->get( 'values' );
+ $this->_fields = $this->get( 'fields' );
+ $this->_bltID = $this->get( 'bltID' );
+
+ $config =& CRM_Core_Config::singleton( );
+ self::$_session =& CRM_Core_Session::singleton();
+
+ //print_r(self::$_session);
+ if(!$this->_values) {
+ $contactID = self::$_session->get('userID');
+
+ // create redirect URL to send folks back to event info page is registration not available
+ $infoUrl = CRM_Utils_System::url( 'civicrm/event/info',"reset=1&id={$this->_eventId}",
+ true, null, false, true );
+
+ // this is the first time we are hitting this, so check for permissions here
+ if ( ! CRM_Core_Permission::event( CRM_Core_Permission::VIEW,
+ $this->_eventId ) ) {
+ CRM_Core_Error::statusBounce( ts( 'You do not have permission to register for this event' ), $infoUrl );
+ }
+
+ // get all the values from the dao object
+ $this->_values = array( );
+
+ //retrieve event information
+ $params = array( 'id' => $this->_eventId );
+ $ids = array();
+
+ require_once 'CRM/Event/BAO/Participant.php';
+ require_once 'CRM/Event/BAO/Event.php';
+ CRM_Event_BAO_Event::retrieve($params, $this->_values['event']);
+
+ // is the event active (enabled)?
+ if ( ! $this->_values['event']['is_active'] ) {
+ // form is inactive, die a fatal death
+ CRM_Core_Error::statusBounce( ts( 'The event you requested is currently unavailable (contact the site administrator for assistance).' ) );
+ }
+
+ // is online registration is enabled?
+ if ( ! $this->_values['event']['is_online_registration'] ) {
+ CRM_Core_Error::statusBounce( ts( 'Online registration is not currently available for this event (contact the site administrator for assistance).' ), $infoUrl );
+ }
+ $now = time( );
+
+ $startDate = CRM_Utils_Date::unixTime( CRM_Utils_Array::value( 'start_date',
+ $this->_values['event'] ) );
+ if ( $startDate &&
+ $startDate <= $now ) {
+ CRM_Core_Error::statusBounce( ts( 'This event began on %1 you can not alter the participants now', array( 1 => CRM_Utils_Date::customFormat( CRM_Utils_Array::value( 'start_date', $this->_values['event'] ) ) ) ), $infoUrl );
+ }
+
+ // get the location type
+ $locationTypes =& CRM_Core_PseudoConstant::locationType( );
+ $this->_bltID = array_search( 'Billing', $locationTypes );
+ if ( ! $this->_bltID ) {
+ CRM_Core_Error::fatal( ts( 'Please set a location type of %1', array( 1 => 'Billing' ) ) );
+ }
+ $this->set( 'bltID', $this->_bltID );
+
+ $params = array( 'entity_id' => $this->_eventId ,'entity_table' => 'civicrm_event');
+ require_once 'CRM/Core/BAO/Location.php';
+ $location = CRM_Core_BAO_Location::getValues($params, $this->_values, true );
+
+ if ( $this->_mode == 'test' ) {
+ $mode = 1;
+ } else {
+ $mode = 0;
+ }
+
+ /**
+ * We get the registered_by_id id we'll be looking for.
+ */
+ $sql = "
+ SELECT id
+ FROM civicrm_participant
+ WHERE contact_id = $contactID
+ AND event_id = {$this->_eventId}
+ AND is_test = {$mode}
+ ";
+ $rID = CRM_Core_DAO::singleValueQuery( $sql,
+ CRM_Core_DAO::$_nullArray );
+
+ // Check for extra participants for this user.
+ if ( !$rID ) {
+ CRM_Core_Error::statusBounce( ts( 'We don\'t have any additional participants on record for this event.' ), $infoUrl );
+ }
+
+ require_once('CRM/Contact/BAO/Contact/Location.php');
+ // Get all the additional participants
+ $query = "SELECT id, contact_id
+ FROM civicrm_participant
+ WHERE registered_by_id = $rID
+ AND event_id = {$this->_eventId}
+ AND is_test = {$mode}";
+
+ $dao =& CRM_Core_DAO::executeQuery( $query );
+ while ( $dao->fetch( ) ) {
+ $this->_values['participants'][$dao->id] = CRM_Contact_BAO_Contact_Location::getEmailDetails($dao->contact_id);
+ $this->_values['participants'][$dao->id]['contact_id'] = $dao->contact_id;
+ }
+
+ $this->set( 'values', $this->_values );
+ //print_r($this->_values);
+ }
+
+ // setting CMS page title
+ CRM_Utils_System::setTitle('Update Your Registration for ' . $this->_values['event']['title']);
+ $this->assign( 'title', 'Update Your Registration for ' . $this->_values['event']['title'] );
+
+ // we do not want to display recently viewed items on Registration pages
+ $this->assign( 'displayRecent' , false );
+ // Registration page values are cleared from session, so can't use normal Printer Friendly view.
+ // Use Browser Print instead.
+ $this->assign( 'browserPrint', true );
+
+ // assign all event properties so wizard templates can display event info.
+ $this->assign('event', $this->_values['event']);
+ $this->assign('location',$this->_values['location']);
+ $this->assign( 'bltID', $this->_bltID );
+
+ //print_r($this);
+
+
+ }
+
+ /**
+ * This function sets the default values for the form. For edit/view mode
+ * the default values are retrieved from the database
+ *
+ * @access public
+ * @return None
+ */
+ function setDefaultValues( ) {
+ $defaults = array( );
+
+ foreach($this->_values['participants'] as $key => $value) {
+ $defaults['guest_places']['email-'.$this->_bltID.'-'.$key] = $value[1]; // Set the email address in the text boxes.
+ }
+
+ return $defaults;
+ }
+
+ /**
+ * Function to build the form
+ *
+ * @return None
+ * @access public
+ */
+ public function buildQuickForm( ) {
+ $config =& CRM_Core_Config::singleton( );
+
+ // !add free places group
+ $i = 1;
+ foreach($this->_values['participants'] as $key => $value) {
+ $elements[] =& $this->createElement('text', "email-{$this->_bltID}-{$key}",
+ ts('Email Address ' . $i),
+ array( 'size' => 30, 'maxlength' => 60 ),
+ true );
+ $i++;
+ }
+
+ // !todo Add form rules.
+ $this->addGroup( $elements, 'guest_places', ts('Additional Participants'), '
' );
+
+ $this->addGroupRule('guest_places', 'ERROR: Email address format invalid', 'email');
+ $this->addGroupRule('guest_places', 'ERROR: All fields required', 'required');
+
+ //add buttons
+ $this->addButtons(array(
+ array ( 'type' => 'done',
+ 'name' => ts('Submit'),
+ 'isDefault' => true
+ ),
+ )
+ );
+ }
+
+ /**
+ * global form rule
+ *
+ * @param array $fields the input form values
+ * @param array $files the uploaded files if any
+ * @param array $options additional user data
+ *
+ * @return true if no errors, else array of errors
+ * @access public
+ * @static
+ */
+ static function formRule(&$fields, &$files, &$self) {
+ $errors = array( );
+
+ return $errors;
+ }
+
+ /**
+ * Function to process the form
+ *
+ * @access public
+ * @return None
+ */
+ public function postProcess() {
+
+ $params = $this->getSubmitValues();
+
+ foreach($params['guest_places'] as $key => $email) {
+ $matches = explode('-', $key);
+ $idToEdit = $matches[2];
+
+ // Check to see if the contact records for the altered emails exists
+ $values = array(
+ "email-Primary" => $email,
+ "email-{$this->_bltID}" => $email,
+ 'address_name-5' => '',
+ 'contact_type' => "Individual",
+ 'is_primary' => 1,
+ );
+
+ require_once "CRM/Contact/BAO/Contact.php";
+
+ $contact =& CRM_Contact_BAO_Contact::matchContactOnEmail($email);
+ $contactID = $contact->contact_id;
+
+ $fields = array(
+ 'billing_first_name' => 1,
+ 'billing_middle_name' => 1,
+ 'billing_last_name' => 1,
+ 'street_address-5' => 1,
+ 'city-5' => 1,
+ 'state_province_id-5' => 1,
+ 'postal_code-5' => 1,
+ 'country_id-5' => 1,
+ 'credit_card_number' => 1,
+ 'cvv2' => 1,
+ 'credit_card_exp_date' => 1,
+ 'credit_card_type' => 1,
+ 'first_name' => 1,
+ 'middle_name' => 1,
+ 'last_name' => 1,
+ 'address_name-5' => 1,
+ 'email-5' => 1,
+ 'email-Primary' => 1,
+ );
+
+ if(!$contactID) {
+ //$contact =& CRM_Contact_BAO_Contact::create($values);
+ //$contactID = $contact->id;
+ $contactID = CRM_Contact_BAO_Contact::createProfileContact( $values, $fields, $contactID, null, null, 'Individual' );
+ }
+
+ require_once('CRM/Event/Form/Registration/Confirm.php');
+ $contactID =& CRM_Event_Form_Registration_Confirm::updateContactFields( $contactID, $values, $fields );
+
+ $sql = "UPDATE civicrm_participant
+ SET contact_id = $contactID
+ WHERE id = $idToEdit
+ ";
+
+ CRM_Core_DAO::singleValueQuery( $sql, CRM_Core_DAO::$_nullArray );
+ }
+// print_r($params);
+
+ self::$_session->pushUserContext(CRM_Utils_System::url( 'civicrm/event/info', 'reset=1&id='.$this->_eventId ));
+ }
+ /**
+ * Array
+(
+ [qfKey] => c2b08f9b48c8d9d7a796f4fa8d94566d
+ [amount] => 40
+ [amount_level] => Tenor
+ [participant_role_id] => 1
+ [address_name-5] =>
+ [email-Primary] => kevin@test.com
+ [registered_by_id] => 1
+)
+ */
+
+}
+?>
\ No newline at end of file
Property changes on: CRM/Event/Form/UpdateRegister.php
___________________________________________________________________
Name: svn:mime-type
+ text/x-php
Name: svn:keywords
+ "Author Date Id Rev URL"
Name: svn:eol-style
+ native
Index: CRM/Event/Page/EventInfo.php
===================================================================
--- CRM/Event/Page/EventInfo.php (revision 19748)
+++ CRM/Event/Page/EventInfo.php (working copy)
@@ -200,6 +200,62 @@
}
$this->assign('location',$values['location']);
+ /**
+ * To make us able to go to the amend participants pages
+ */
+
+ $session =& CRM_Core_Session::singleton( );
+ $contactID = $session->get( 'userID' );
+
+ //$this->_action = CRM_Utils_Request::retrieve( 'action', 'String' , $this, false );
+
+ // current mode
+ //$this->_mode = ( $this->_action == 1024 ) ? 'test' : 'live';
+
+ require_once 'CRM/Event/BAO/Participant.php';
+ $participant =& new CRM_Event_BAO_Participant();
+ $participant->contact_id = $contactID;
+ $participant->event_id = $this->_id;
+
+ if ($action == CRM_Core_Action::PREVIEW) {
+ $participant->is_test = 1;
+ } else {
+ $participant->is_test = 0;
+ }
+
+ $participant->find( );
+ require_once 'CRM/Event/PseudoConstant.php';
+ $statusTypes = CRM_Event_PseudoConstant::participantStatus( null, "filter = 1" );
+ if ( $participant->fetch( ) ) {
+
+ $query = "SELECT count(id)
+ FROM civicrm_participant
+ WHERE registered_by_id = $participant->id
+ AND event_id = {$this->_id}
+ AND is_test = {$participant->is_test}";
+
+ $result = CRM_Core_DAO::singleValueQuery($query, CRM_Core_DAO::$_nullArray);
+
+ if($result) {
+ // We have finally found out whether we have any additional participants for this mode.
+ $this->assign('display_register_edit', true);
+
+ if ( $action == CRM_Core_Action::PREVIEW ) {
+ $url = CRM_Utils_System::url( 'civicrm/event/updateregister',
+ "id={$this->_id}&reset=1&action=preview",
+ true, null, true,
+ true );
+ } else {
+ $url = CRM_Utils_System::url( 'civicrm/event/updateregister',
+ "id={$this->_id}&reset=1",
+ true, null, true,
+ true );
+ }
+ $this->assign('register_edit_url', $url);
+ }
+
+ }
+
parent::run();
}
Index: templates/CRM/Event/Form/ManageEvent/FreePlaces.tpl
===================================================================
--- templates/CRM/Event/Form/ManageEvent/FreePlaces.tpl (revision 0)
+++ templates/CRM/Event/Form/ManageEvent/FreePlaces.tpl (revision 0)
@@ -0,0 +1,71 @@
+{* Included in ..... - used for fields with multiple choice options. *}
+
+