CRM-15182 - on behalf of: preloaded org is not preserved
authoratif-shaikh <shaikh388@gmail.com>
Thu, 4 Sep 2014 12:12:38 +0000 (17:42 +0530)
committeratif-shaikh <shaikh388@gmail.com>
Thu, 4 Sep 2014 12:12:38 +0000 (17:42 +0530)
https://issues.civicrm.org/jira/browse/CRM-15182

CRM/Contribute/Form/Contribution/Confirm.php
CRM/Contribute/Form/Contribution/OnBehalfOf.php

index 8728e808afdedc5e5e574eda5a60365fcdb08d34..45b6b878fd31fc8abeaf81e9f6a7e95479d6e9fd 100644 (file)
@@ -268,10 +268,14 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
     }
     // if onbehalf-of-organization
     if (!empty($this->_params['hidden_onbehalf_profile'])) {
-      if (!empty($this->_params['org_option']) && !empty($this->_params['organization_id'])) {
+      // CRM-15182
+      if (empty($this->_params['org_option']) && empty($this->_params['organization_id'])) {
         if (!empty($this->_params['onbehalfof_id'])) {
           $this->_params['organization_id'] = $this->_params['onbehalfof_id'];
         }
+        else {
+          $this->_params['organization_id'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_params['onbehalf']['organization_name'], 'id', 'display_name');
+        }
       }
 
       $this->_params['organization_name'] = $this->_params['onbehalf']['organization_name'];
index ea2d992564e7ffe36e8586382bf93b1c8669ce3a..e2c62f1b678e806804f46629bcac52c2dd0e0eb1 100644 (file)
@@ -97,7 +97,9 @@ class CRM_Contribute_Form_Contribution_OnBehalfOf {
         $form->assign('locDataURL', $locDataURL);
 
         if (!empty($form->_submitValues['onbehalf'])) {
-          $form->assign('submittedOnBehalf', $form->_submitValues['onbehalfof_id']);
+          if (!empty($form->_submitValues['onbehalfof_id'])) {
+            $form->assign('submittedOnBehalf', $form->_submitValues['onbehalfof_id']);
+          }
           $form->assign('submittedOnBehalfInfo', json_encode($form->_submitValues['onbehalf']));
         }
       }