Event participant form code cleanup
authorColeman Watts <coleman@civicrm.org>
Thu, 28 Aug 2014 15:19:08 +0000 (16:19 +0100)
committerColeman Watts <coleman@civicrm.org>
Thu, 28 Aug 2014 15:19:08 +0000 (16:19 +0100)
CRM/Event/Form/Participant.php
templates/CRM/Event/Form/EventFees.tpl

index ef44f134932292c7e8f5184d86dc8d2b32f69754..eaacc1b9a5c5dbbe12f3c440fdd9c3fd5bc8a7ad 100644 (file)
@@ -696,39 +696,9 @@ class CRM_Event_Form_Participant extends CRM_Contact_Form_Task {
     }
 
 
-    if ($this->_single) {
-      $urlPath = 'civicrm/contact/view/participant';
-      $urlParams = "reset=1&cid={$this->_contactId}&context=participant";
-      if ($this->_context == 'standalone') {
-        $this->addEntityRef('contact_id', ts('Contact'), array('create' => TRUE), TRUE);
-        $urlParams = 'reset=1&context=standalone';
-        $urlPath = 'civicrm/participant/add';
-      }
-
-      if ($this->_id) {
-        $urlParams .= "&action=update&id={$this->_id}";
-      }
-      else {
-        $urlParams .= "&action=add";
-      }
-
-      if ($this->_mode) {
-        $urlParams .= "&mode={$this->_mode}";
-      }
-
-      $url = CRM_Utils_System::url($urlPath, $urlParams,
-        FALSE, NULL, FALSE
-      );
+    if ($this->_single && $this->_context == 'standalone') {
+      $this->addEntityRef('contact_id', ts('Contact'), array('create' => TRUE, 'api' => array('extra' => array('email'))), TRUE);
     }
-    else {
-      $currentPath = CRM_Utils_System::currentPath();
-
-      $url = CRM_Utils_System::url($currentPath, '_qf_Participant_display=true',
-        FALSE, NULL, FALSE
-      );
-    }
-
-    $this->assign('refreshURL', $url);
 
     $eventFieldParams = array(
       'entity' => 'event',
index afff593cd7fafe85b76a8fbf534ac990eaff64b6..a7cc20029af3f1f959727eabcb7d6fe9086421ff 100644 (file)
 {if $context eq 'standalone' and $outBound_option != 2 }
 <script type="text/javascript">
 {literal}
-CRM.$(function($) {
-    $("#contact_id").change( function( ) {
-        checkEmail( );
-    } );
-    checkEmail( );
-});
-function checkEmail( ) {
-    var contactID =  cj("#contact_id").val();
-    if ( contactID ) {
-        var postUrl = "{/literal}{crmURL p='civicrm/ajax/checkemail' h=0}{literal}";
-        cj.post( postUrl, {contact_id: contactID},
-            function ( response ) {
-                if ( response ) {
-                    cj("#email-receipt").show( );
-                    if ( cj("#send_receipt").is(':checked') ) {
-                        cj("#notice").show( );
-                    }
+  CRM.$(function($) {
+    var $form = $("form.{/literal}{$form.formClass}{literal}");
+    $("#contact_id", $form).change(checkEmail);
+    checkEmail();
 
-                    cj("#email-address").html( response );
-                } else {
-                    cj("#email-receipt").hide( );
-                    cj("#notice").hide( );
-                }
-            }
-        );
+    function checkEmail( ) {
+      var data = $("#contact_id", $form).select2('data');
+      if (data && data.extra && data.extra.email && data.extra.email.length) {
+        $("#email-receipt", $form).show();
+        if ($("#send_receipt", $form).is(':checked')) {
+          $("#notice", $form).show();
+        }
+        $("#email-address", $form).html(data.extra.email);
+      }
+      else {
+        $("#email-receipt, #notice", $form).hide();
+      }
     }
-}
+  });
 {/literal}
 </script>
 {/if}