CRM-14701 fixes - Form data not retained subsequent to contribution page on behalf...
authormonishdeb <monish.deb@webaccessglobal.com>
Sat, 28 Jun 2014 19:30:04 +0000 (01:00 +0530)
committermonishdeb <monish.deb@webaccessglobal.com>
Sat, 28 Jun 2014 19:30:04 +0000 (01:00 +0530)
https://issues.civicrm.org/jira/browse/CRM-14701

CRM/Contribute/Form/Contribution/OnBehalfOf.php
templates/CRM/Contribute/Form/Contribution/OnBehalfOf.tpl

index 38bd4653e6e8a6a7e0adb3d857e55c5029d4d582..abc6331eacbafa008a09208d458da2c6bc7a28a6 100644 (file)
@@ -73,7 +73,7 @@ class CRM_Contribute_Form_Contribution_OnBehalfOf {
       if (!empty($form->_membershipContactID) && $contactID != $form->_membershipContactID) {
         // renewal case - membership being renewed may or may not be for organization
         if (!empty($form->_employers) && array_key_exists($form->_membershipContactID, $form->_employers)) {
-          // if _membershipContactID belongs to employers list, we can say: 
+          // if _membershipContactID belongs to employers list, we can say:
           $form->_relatedOrganizationFound = TRUE;
         }
       } else if (!empty($form->_employers)) {
@@ -93,6 +93,11 @@ class CRM_Contribute_Form_Contribution_OnBehalfOf {
         }
         $locDataURL = CRM_Utils_System::url('civicrm/ajax/permlocation', $args, FALSE, NULL, FALSE);
         $form->assign('locDataURL', $locDataURL);
+
+        if (!empty($form->_submitValues['onbehalf'])) {
+          $form->assign('submittedOnBehalf', $form->_submitValues['onbehalfof_id']);
+          $form->assign('submittedOnBehalfInfo', json_encode($form->_submitValues['onbehalf']));
+        }
       }
 
       if ($form->_values['is_for_organization'] != 2) {
@@ -192,4 +197,3 @@ class CRM_Contribute_Form_Contribution_OnBehalfOf {
     $form->addElement('hidden', 'hidden_onbehalf_profile', 1);
   }
 }
-
index cc4d7711287230c6c3ec78bb85cb4f306293f59a..fbd78867b26b9e3e3889fed9ec39d47c0a5b6843 100644 (file)
@@ -193,7 +193,17 @@ function setOrgName( ) {
 }
 
 
-function setLocationDetails(contactID) {
+function setLocationDetails(contactID , reset) {
+  var submittedCID = {/literal}"{$submittedOnBehalf}"{literal};
+  var submittedOnBehalfInfo = {/literal}'{$submittedOnBehalfInfo}'{literal};
+  submittedOnBehalfInfo = cj.parseJSON(submittedOnBehalfInfo);
+  if (submittedCID == contactID) {
+    cj.each(submittedOnBehalfInfo, function(key, value) {
+      cj('#onbehalf_' + key ).val(value);
+    });
+    return;
+  }
+
   resetValues();
   var locationUrl = {/literal}"{$locDataURL}"{literal} + contactID + "&ufId=" + {/literal}"{$profileId}"{literal};
   cj.ajax({