CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Registering for an event - How to select your Children?
Pages: [1]

Author Topic: Registering for an event - How to select your Children?  (Read 3337 times)

joe.oommen

  • I’m new here
  • *
  • Posts: 2
  • Karma: 0
  • CiviCRM version: 3.3
  • CMS version: Drupal 6
  • MySQL version: 5.1
  • PHP version: 5.3
Registering for an event - How to select your Children?
February 05, 2011, 09:06:21 am
Hello,

I'm new to CiviCRM and I've spent a few days installing it, reading up on it and configuring it. I'm still in the dark regarding this issue mentioned below. Once an event is created, then I need:

1. The parent to login.
2. The must parent have visibility of their children. I attempted this by creating a Contact Reference (with Autocomplete Search), but then I needed to give authenticated users access to CiviCRM. This is not an option for us since the profile contains sensitive custom data.
3. Have the possbility to Register only their children (with custom information such as Guardian/Lodging/Food Preference per child), but yet the parent is the one that is billed/pays for the event registration, and all the children show up as event participants.

The reason why this is important is because many families are large (more than 5) and the guardian will also be a CiviCRM User (i.e. Youth conference where the children need a guardian, since thier parents are not going). To facilitate the registration, then they should be able to select their children from a list (rather than typing in the names). They should also be able to do a Autocomplete search on existing contacts.

I know that CiviCRM has this Parent/Child relationship, but I don't see how this is used in event registration.

1. Can anyone enligten me on the options I have (or addtional modules I could use).
2. Is there a way to use a Contact Reference (Autocomplete Search) from an authenticated user without Giving them (Access CiviCRM Permissions)?

Thanks!
Joe

penguintrax

  • I post frequently
  • ***
  • Posts: 230
  • Karma: 2
  • CiviCRM version: 3.3x and 4.x depending on site
  • CMS version: Joomla 1.5 or 1.7 depending on site
  • MySQL version: 5.0.92-community
  • PHP version: 5.2.17
Re: Registering for an event - How to select your Children?
February 08, 2011, 07:54:23 am
I have a similar issue (I think): When attendees register, they need to add all the members of their household. Is there a way to do this without having the registrants input each person separately? It looks like Custom Data using Multiple Records will not work for this based on some mentions on this Board.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Registering for an event - How to select your Children?
February 08, 2011, 11:13:39 am

for different members of household, cant u use the registration with multiple participants?

for the parent / child case, we've been getting a fair amount of requests for this (maybe because summer camp registrations?). This needs to be custom code and/or a module that extends civicrm by implementing a few hooks. If you/your org is interested in sponsoring this let us know. I suspect its a 40-60 hour project. We could potentially try to get a few more orgs chip in towards the cost

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

penguintrax

  • I post frequently
  • ***
  • Posts: 230
  • Karma: 2
  • CiviCRM version: 3.3x and 4.x depending on site
  • CMS version: Joomla 1.5 or 1.7 depending on site
  • MySQL version: 5.0.92-community
  • PHP version: 5.2.17
Re: Registering for an event - How to select your Children?
February 08, 2011, 11:27:38 am
thanks Lobo - we are trying to replicate functionality in CiviEvent from a non-CiviEvent form. We are trying to sell the client on the benefits of having individual contact records for each attendee, which can then be grouped into a household. 

zesgar

  • I post occasionally
  • **
  • Posts: 107
  • Karma: 2
  • CiviCRM version: 4.3.4
  • CMS version: Joomla 2.5
Re: Registering for an event - How to select your Children?
February 08, 2011, 05:33:32 pm
I would be in for donating some money and time towards this

joe.oommen

  • I’m new here
  • *
  • Posts: 2
  • Karma: 0
  • CiviCRM version: 3.3
  • CMS version: Drupal 6
  • MySQL version: 5.1
  • PHP version: 5.3
Re: Registering for an event - How to select your Children?
February 08, 2011, 09:06:56 pm
Thanks for the reply!

We are able to use registration with Multiple Participants enabled, but then the user has to type the name (i.e. Joe ). This would be fine for us if this entry could be Auto-completed. The issue arises when we would like to enter the name by using an custom field Contact Reference (with Auto-complete). We have to give authenticated users Access CiviCRM permissions. Even when selecting a Guardian, it should be from our Auto-completed list of contact (and not have to be typed completely).

Is there a way around that the issue with permissions, or does it require code changes?

If this functionality is missing, we are a non-profit organization but we are willing to contribute (if there are others that are willing to share the expense).

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Registering for an event - How to select your Children?
February 09, 2011, 08:15:39 am

You will need to make some code changes for the below. If you can find a group of folks willing to fund this work that would be great. Hopefully more folks will read this topic and chime in :)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Registering for an event - How to select your Children?
February 25, 2011, 10:37:09 pm

I decided to play around and see what we can do in this case with hooks and see what changes need to be done. This is currently a very developer centric module (no configuration, makes assumption, potential bugs). But basically the workflow is as follows:

1. You send the parent to a profile where you collect all parent information

2. When the profile is submitted, the hook redirects to an event page. The parent enters all the children information here (using additional participants configuration for additional children etc). A parent <-> child relationship is created between the contact created by the profile and each of the participants

3. If the parent already had a record and had existing children, we basically pre-load the children information in the boxes (currently assuming first/last/email, but this can potentially be generalized)

You can download the code here (module: civicrm_event_parent) using git

git clone git@github.com:dlobo/CiviCRM-Experimental-Modules.git

if you make any improvements, please let me know so we can coordinate.

lobo

A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

zesgar

  • I post occasionally
  • **
  • Posts: 107
  • Karma: 2
  • CiviCRM version: 4.3.4
  • CMS version: Joomla 2.5
Re: Registering for an event - How to select your Children?
February 26, 2011, 04:34:36 pm
Thanks so much I will play around with the code and post any modifications I make.

zesgar

  • I post occasionally
  • **
  • Posts: 107
  • Karma: 2
  • CiviCRM version: 4.3.4
  • CMS version: Joomla 2.5
Re: Registering for an event - How to select your Children?
March 01, 2011, 08:19:07 am
What all do I need to change to get this to work with joomla?  So far I have added 'joomla_' to every function and function call.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Registering for an event - How to select your Children?
March 01, 2011, 09:43:34 am

http://wiki.civicrm.org/confluence/display/CRMDOC33/CiviCRM+hook+specification#CiviCRMhookspecification-Proceduresforimplementinghooks%28forJoomla%29

not tried it

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

zesgar

  • I post occasionally
  • **
  • Posts: 107
  • Karma: 2
  • CiviCRM version: 4.3.4
  • CMS version: Joomla 2.5
Re: Registering for an event - How to select your Children?
March 22, 2011, 12:38:20 pm
The code is working on 3.2.1 but on 3.3.5 it is not..

It is not getting the participant ID I have tried and tried but I can't get the participant ID to be pulled .. I played with just grabbing the contact id in the thank you page that is stored in the session.  But no luck there.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Registering for an event - How to select your Children?
March 22, 2011, 12:55:35 pm

can u explain a bit more on what is working in 3.2.1 and not in 3.3.5

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

zesgar

  • I post occasionally
  • **
  • Posts: 107
  • Karma: 2
  • CiviCRM version: 4.3.4
  • CMS version: Joomla 2.5
Re: Registering for an event - How to select your Children?
March 23, 2011, 08:26:22 am
I believe the getVar participantIDs is not returning any value.  Therefore no relationships are created nor is the participant added to a group.
Code: [Select]
        // get the participantIDS
        $participantIDs = $form->getVar( '_participantIDS' );
       
        $pIDString = implode( ',', $participantIDs );

here is the full code...this code works perfectly in 3.2.1 in 3.3.5 no worky.  I am on a joomla cms. I have tried playing around with putting the relationship creating part on the build form hook to the Thank you page. Because their is a contactID or transaction.userID stored in the session. But I couldn't get any of my code to pull those variables.
Code: [Select]
<?php

/*
 +--------------------------------------------------------------------+
 | CiviCRM version 3.3                                                |
 +--------------------------------------------------------------------+
 | Copyright CiviCRM LLC (c) 2004-2010                                |
 +--------------------------------------------------------------------+
 | This file is a part of CiviCRM.                                    |
 |                                                                    |
 | CiviCRM is free software; you can copy, modify, and distribute it  |
 | under the terms of the GNU Affero General Public License           |
 | Version 3, 19 November 2007.                                       |
 |                                                                    |
 | CiviCRM 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 Affero General Public License for more details.        |
 |                                                                    |
 | You should have received a copy of the GNU Affero General Public   |
 | License and the CiviCRM Licensing Exception along                  |
 | with this program; if not, contact CiviCRM LLC                     |
 | at info[AT]civicrm[DOT]org. If you have questions about the        |
 | GNU Affero General Public License or the licensing of CiviCRM,     |
 | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
 +--------------------------------------------------------------------+
*/

/**
 *
 * @package CRM
 * @copyright CiviCRM LLC (c) 2004-2010
 * $Id$
 *
 */


define( 'PARENT_EVENT_ID'  , 1 );
define( 'PARENT_PROFILE_ID', 1 );

function 
joomla_civicrm_event_parent_get_children_info( $contactID ) {
    
$sql = "
SELECT     c.id as child_id, c.first_name, c.last_name, ce.email,
           p.id as parent_id, pe.email as parent_email
FROM       civicrm_contact c
INNER JOIN civicrm_relationship  r ON c.id = r.contact_id_b
INNER JOIN civicrm_contact       p ON p.id = r.contact_id_a
LEFT  JOIN civicrm_email        ce ON c.id = ce.contact_id AND ce.is_primary = 1
LEFT  JOIN civicrm_email        pe ON p.id = pe.contact_id AND pe.is_primary = 1
WHERE      p.id = %1
AND        r.relationship_type_id = 1
AND        r.is_active = 1
"
;
    
$params = array( 1 => array( $contactID, 'Integer' ) );
    
$dao = CRM_Core_DAO::executeQuery( $sql, $params );

    
$children = array( );
    while ( 
$dao->fetch( ) ) {
        
$children[] = array( 'child_id'     => $dao->child_id  ,
                             
'first_name'   => $dao->first_name,
                             
'last_name'    => $dao->last_name ,
                             
'email'        => $dao->email     ,
                             
'parent_id'    => $dao->parent_id ,
                             
'parent_email' => $dao->parent_email );
    }
    
    return 
$children;
}

function 
joomla_civicrm_buildForm( $formName, &$form ) {
    if ( 
$formName == 'CRM_Event_Form_Registration_Register' ) {
        
joomla_civicrm_event_parent_civicrm_buildForm_regRegister( $formName, $form );
    }

    if ( 
$formName == 'CRM_Event_Form_Registration_AdditionalParticipant' ) {
        
joomla_civicrm_event_parent_civicrm_buildForm_regAdditional( $formName, $form );
    }

}

function 
joomla_civicrm_event_parent_civicrm_buildForm_regRegister( $formName, &$form ) {
   
   require_once 
'CRM/Utils/Request.php';
   if ( 
$form->getVar( '_eventId' ) == PARENT_EVENT_ID ) {
        
$mainID = CRM_Utils_Request::retrieve( 'mainID', 'Integer', $form,
                                               
false, null, $_REQUEST );
        if ( 
$mainID ) {
            
$rTypeID  = CRM_Utils_Request::retrieve( 'rTypeID', 'Integer', $form,
                                                    
false, null, $_REQUEST );
            
$rTypeDir = CRM_Utils_Request::retrieve( 'rTypeDir', 'String', $form,
                                                     
false, 'a_b', $_REQUEST );
            if ( 
$rTypeID ) {
                
$form->set( 'mainID'  , $mainID   );
                
$form->set( 'rTypeID' , $rTypeID  );
                
$form->set( 'rTypeDir', $rTypeDir );
            }

            
// now set the various defaults
            // basically name and email and number of children
            
$children = joomla_civicrm_event_parent_get_children_info( $mainID );
            
$form->set( 'parentChildren', $children );

            if ( ! empty( 
$children ) ) {
                
$defaults = array( );
                
$defaults['additional_participants'] = count( $children ) - 1;
                
$defaults['first_name'] = $children[0]['first_name'];
                
$defaults['last_name' ] = $children[0]['last_name' ];
                
$defaults['email-5'   ] = $children[0]['email'     ];
                
$form->setDefaults( $defaults );
            }
        }
    }
}

function 
joomla_civicrm_event_parent_civicrm_buildForm_regAdditional( $formName, &$form ) {
    if ( 
$form->getVar( '_eventId' ) == PARENT_EVENT_ID ) {
        
$children = $form->get( 'parentChildren' );
        if ( ! empty( 
$children ) ) {
            
$childNum = substr( $form->getVar( '_name' ), 12 );

            
$defaults = array( );
            
$defaults['first_name'] = $children[$childNum]['first_name'];
            
$defaults['last_name' ] = $children[$childNum]['last_name' ];
            
$defaults['email-5'   ] = $children[$childNum]['email'     ];
            
$form->setDefaults( $defaults );
        }
    }
}

function 
joomla_civicrm_postProcess( $class, &$form ) {
    if ( 
is_a( $form, 'CRM_Event_Form_Registration_Confirm' ) ) {
    
return joomla_civicrm_event_parent_civicrm_postProcess_regConfirm( $class, $form );

    }

    if ( 
is_a( $form, 'CRM_Profile_Form_Edit' ) ) {
        return 
joomla_civicrm_event_parent_civicrm_postProcess_profileEdit( $class, $form );
    }
}

function 
joomla_civicrm_event_parent_civicrm_postProcess_regConfirm( $class, &$form ) {
  
   if ( 
$form->getVar( '_eventId' ) == PARENT_EVENT_ID &&
         
$form->get( 'mainID' ) ) {
        
$mainID   = $form->get( 'mainID'   );
        
$rTypeID  = $form->get( 'rTypeID'  );
        
$rTypeDir = $form->get( 'rTypeDir' );

        
// get the participantIDS
        
$participantIDs = $form->getVar( '_participantIDS' );
        
        
$pIDString = implode( ',', $participantIDs );

        
// get all the contactIDs for these participants
        
$sql = "
SELECT contact_id
FROM   civicrm_participant
WHERE  id IN ( 
$pIDString )
"
;

        if ( 
$rTypeDir == 'a_b' ) {
            
$mainLabel  = 'a';
            
$otherLabel = 'b';
        } else {
            
$mainLabel  = 'b';
            
$otherLabel = 'a';
        }

require_once 'CRM/Core/DAO.php';
        
$dao = CRM_Core_DAO::executeQuery( $sql );
        require_once 
'api/v2/Relationship.php';
        while ( 
$dao->fetch( ) ) {
            
// create the relationship
            
$params = array( "contact_id_{$mainLabel}"  => $mainID,
                             
"contact_id_{$otherLabel}" => $dao->contact_id,
                             
'relationship_type_id'     => $rTypeID,
                             
'is_active'                => 1,
                             );
            
civicrm_relationship_create( $params );

        }
    }
}

function 
joomla_civicrm_event_parent_civicrm_postProcess_profileEdit( $class, &$form ) {
    
require_once 'CRM/Utils/System.php';
if ( $form->getVar( '_gid' ) == PARENT_PROFILE_ID ) {
        
// get the contactID of the newly created contact (or existing one)
        // and redirect to event registration page
        
$mainID = $form->getVar( '_id' );

        if ( 
$mainID ) {
            
$url = CRM_Utils_System::url( 'civicrm/event/register',
                                          
"reset=1&id=1&cid=0&mainID={$mainID}&rTypeID=1&rTypeDir=b_a" );
            
CRM_Utils_System::redirect( $url );
        }
    }
}
?>

jimyhuang

  • I post occasionally
  • **
  • Posts: 35
  • Karma: 3
Re: Registering for an event - How to select your Children?
April 26, 2011, 11:06:22 am
I just quick added an interface for that by Drupal way.

Attachment is the modified version, and still need to change theme for display option when manage event. Code like this:

Code: [Select]
--- a/templates/CRM/Event/Form/ManageEvent/Registration.tpl
+++ b/templates/CRM/Event/Form/ManageEvent/Registration.tpl
@@ -106,6 +106,10 @@
             <td>{$form.footer_text.html}
             <div class="description">{ts}Optional footer text for registration screen.{/ts}</div></td>
          </tr>
+         <tr class="crm-event-manage-registration-form-block-parent_gid">
+            <td scope="row" class="label" width="20%">{$form.parent_gid.label}</td>
+            <td>{$form.parent_gid.html}</td>
+        </tr>
          <tr class="crm-event-manage-registration-form-block-custom_pre_id">
             <td scope="row" class="label" width="20%">{$form.custom_pre_id.label}</td>
             <td>{$form.custom_pre_id.html}<br />

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Registering for an event - How to select your Children?

This forum was archived on 2017-11-26.