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) »
  • Approval Workflow
Pages: [1]

Author Topic: Approval Workflow  (Read 1576 times)

sussdorff

  • I post occasionally
  • **
  • Posts: 36
  • Karma: 4
  • CiviCRM version: 3.4
  • CMS version: Drupal 6
Approval Workflow
February 04, 2011, 08:49:00 am
Hello,

in the approval workflow (CiviCRM 3.3.2) the Registrant receives an E-Mail after approval which allows him to confirm his participation. Then he is send back to the registration form, with payment options enabled.

Two issues here:

1.) We have custom data fields in a Participant Profile, which the user filled out during registration. When he comes back for confirmation, the data from the fields is not loaded (yet it is in the database and accessible for the admin). So he has to fill this data out again.
2.) The data is actually used to judge the readiness of the participant in the event. So he should not be able to change this data. Additionally, as we have a quota per Country (manually enforced), we don't want the user to change the country (or his address data) after registration. Yet all fields are changeable once he presses the confirmation button and comes back to the registration form for the payment.

Is there a setting, which would only display the fields, plus the payment processor instead of making them editable?

Best wishes
 Malte

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Approval Workflow
February 04, 2011, 10:55:28 am
Hi Malte -
1) This sounds like a bug - all profile data should be prefilled on the registration form when the participant returns to it. Please file an issue on our issue tracker w/ exact steps and if possible please investigate the bug and provide a patch to fix it.

2) You'll need to do this by implementing the buildForm hook. This will require some PHP skills to create a small separate module. If you need info on CiviCRM hooks:

http://en.flossmanuals.net/CiviCRM/DevelopHooks
http://wiki.civicrm.org/confluence/display/CRMDOC33/CiviCRM+hook+specification
Protect your investment in CiviCRM by  becoming a Member!

sussdorff

  • I post occasionally
  • **
  • Posts: 36
  • Karma: 4
  • CiviCRM version: 3.4
  • CMS version: Drupal 6
Re: Approval Workflow
August 11, 2011, 12:43:21 am
Maybe it is the wrong approach to take, but as CiviCRM (at least our installation) does not read the values from custom fields which are in event specific custom groups, we decided to not show the values at all instead of setting the html_quickform elements to freeze. We do this by not executing the buildCustom block.

For this I patched register.php as well as confirm.php, as I can't figure out for the live of it how to do this with a hook. Is there a better way to achieve this / can I do this in a hook?

diff --git a/sites/all/modules/civicrm/CRM/Event/Form/Registration/Confirm.php b/sites/all/modules/civicrm/CRM/Event/Form/Registration/Confirm.php
index 27f2fc1..bf1649e 100644
--- a/sites/all/modules/civicrm/CRM/Event/Form/Registration/Confirm.php
+++ b/sites/all/modules/civicrm/CRM/Event/Form/Registration/Confirm.php
@@ -257,8 +257,12 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration
         $config = CRM_Core_Config::singleton( );
         
         $this->buildCustom( $this->_values['custom_pre_id'] , 'customPre' , true );
-        $this->buildCustom( $this->_values['custom_post_id'], 'customPost', true );
         
+               if ( $this->_params[0]['bypass_custompost'] == '1') {
+                       /*nothing*/
+               } else {
+               $this->buildCustom( $this->_values['custom_post_id'], 'customPost', true );
+        }
         $this->assign( 'lineItem', $this->_lineItem );
         //display additional participants profile.
 
@@ -355,6 +359,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration
                 $fields[$name] = 1;
             }
         }
+
         $fields["billing_state_province-{$this->_bltID}"] =
             $fields["billing_country-{$this->_bltID}"] = $fields["email-{$this->_bltID}"] = 1;
       
diff --git a/sites/all/modules/civicrm/CRM/Event/Form/Registration/Register.php b/sites/all/modules/civicrm/CRM/Event/Form/Registration/Register.php
index e538250..5ef0455 100644
--- a/sites/all/modules/civicrm/CRM/Event/Form/Registration/Register.php
+++ b/sites/all/modules/civicrm/CRM/Event/Form/Registration/Register.php
@@ -359,10 +359,22 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration
         $this->assign( 'requireApprovalMsg', $this->_requireApprovalMsg );
         $this->assign( 'allowGroupOnWaitlist', $allowGroupOnWaitlist );
         $this->assign( 'isAdditionalParticipants', $isAdditionalParticipants );
+               
+               $this->buildCustom( $this->_values['custom_pre_id'] , 'customPre');
+                       
+               /* MSU
+               
+               Fix to hide the custompost when confirming
+               Need to use a bypass variable so the confirm page does not display the values either
+               
+               */
+                if($this->_participantId<1)
+                {
+                   $this->buildCustom( $this->_values['custom_post_id'], 'customPost');
+            } else {   
+               $this->add('hidden','bypass_custompost','1');
+                }
 
-        $this->buildCustom( $this->_values['custom_pre_id'] , 'customPre'  );
-        $this->buildCustom( $this->_values['custom_post_id'], 'customPost' );
-       
         //lets get js on two different qf elements.
         $buildExpressPayBlock = false;
         $showHidePayfieldName = null;

Maybe the proper way would be to debug why the values aren't set as defaults in the first place upon confirmation and modify buildCustom to actually correctly support viewOnly (meaning you can only view the fields and not edit them, which it doesn't).

And please tell me if I post in the wrong place / forum.

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: Approval Workflow
August 11, 2011, 07:50:33 am

ideally we should find the fix the bug, rather than hacking the code to suppress 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

sussdorff

  • I post occasionally
  • **
  • Posts: 36
  • Karma: 4
  • CiviCRM version: 3.4
  • CMS version: Drupal 6
Re: Approval Workflow
August 12, 2011, 05:23:19 am
It took me two hours to find out (among a couple of other things I missed yesterday):

Our custom profile had the participant_role in it. So far so good. Yet the system only loaded the participant_role_id. Hence the form was not setting the value for the participant_role correctly. After I added

+               $this->_defaults['participant_role'] = $this->_defaults['participant_role_id'];

in the setDefaultValues function not only was the Participant Role set correctly, but all the other values showed up as well.

Sadly this brings me back to somewhat 0 as now I need to figure out how to set all the custom values to frozen (mainly, I need to find out in my hook what the custom values are so I can set them to frozen).

sussdorff

  • I post occasionally
  • **
  • Posts: 36
  • Karma: 4
  • CiviCRM version: 3.4
  • CMS version: Drupal 6
Re: Approval Workflow
August 12, 2011, 07:01:58 am
Okay, last post in this  :)

The following is the code which got me going in the custom module of mine to make the custom fields, event_amount and participant_role not editable.

Best wishes
 Malte

       // Make sure to load the values if a participant confirms
       // Actually we should make the fields not editable anymore / hide them altogether
       if($form->getVar('_participantId')>0)
       {
          $event_amount=$form->getElement('amount');
          $event_amount->freeze();
         $participant_role=$form->getElement('participant_role');
         $participant_role->freeze();
         
         $results=civicrm_api("CustomField","getfields", array ('version' =>'3'));
         $fields = array_keys($results['values']);

         foreach($fields as $field) {
           if(isset($form->_elementIndex[$field])) {
               $freeze_field = $form->getElement($field);
               $freeze_field->freeze();
               watchdog(NSG_LOG_LABEL, print_r($field, true));
           }
         }
       }     

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Approval Workflow

This forum was archived on 2017-11-26.