worked on CRM-12463, more cleanup
authorKurund Jalmi <kurund@civicrm.org>
Thu, 2 May 2013 21:57:10 +0000 (14:57 -0700)
committerKurund Jalmi <kurund@civicrm.org>
Thu, 2 May 2013 21:57:10 +0000 (14:57 -0700)
CRM/Contribute/Form/SoftCredit.php

index 2e6e2e2b0e2e8a2b9769a5592c19121263b16455..721cd7d7b11e4cdea3e345cee41db9d42ed93a4a 100644 (file)
@@ -64,7 +64,12 @@ class CRM_Contribute_Form_SoftCredit {
 
     for ($rowNumber = 1; $rowNumber <= $item_count; $rowNumber++) {
       CRM_Contact_Form_NewContact::buildQuickForm($form, $rowNumber, NULL, FALSE, $prefix);
+
       $form->addMoney("{$prefix}amount[{$rowNumber}]", ts('Amount'));
+      if (!empty($form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id'])) {
+        $form->add('hidden', "{$prefix}id[{$rowNumber}]",
+          $form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id']);
+      }
     }
 
     $form->assign('showSoftCreditRow', $showSoftCreditRow);
@@ -82,37 +87,23 @@ class CRM_Contribute_Form_SoftCredit {
    * Function used to set defaults for soft credit block
    */
   static function setDefaultValues(&$defaults, &$form) {
-
-//    crm_core_error::debug('$form->_softCreditInfo', $form->_softCreditInfo);
-//    exit;
-
     if (!empty($form->_softCreditInfo['soft_credit'])) {
       foreach($form->_softCreditInfo['soft_credit'] as $key => $value) {
-        $defaults["soft_credit_amount[$key]"] = $value['soft_credit_amount'];
+        $defaults["soft_credit_amount[$key]"] = $value['amount'];
+        $defaults["soft_credit_contact_select_id[$key]"] = $value['contact_id'];
       }
     }
 
-    /*
-    if (CRM_Utils_Array::value('soft_credit_to', $softCredit)) {
-      $softCredit['sort_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact',
-        $softCredit['soft_credit_to'], 'sort_name'
-      );
-    }
-    $values['soft_credit_to'] = CRM_Utils_Array::value('sort_name', $softCredit);
-    $values['softID'] = CRM_Utils_Array::value('soft_credit_id', $softCredit);
-    $values['soft_contact_id'] = CRM_Utils_Array::value('soft_credit_to', $softCredit);
-    */
-
     if (CRM_Utils_Array::value('pcp_id', $form->_softCreditInfo['pcp'])) {
       $pcpInfo = $form->_softCreditInfo['pcp'];
       $pcpId = CRM_Utils_Array::value('pcp_id', $pcpInfo);
       $pcpTitle = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $pcpId, 'title');
       $contributionPageTitle = CRM_PCP_BAO_PCP::getPcpPageTitle($pcpId, 'contribute');
-      $values['pcp_made_through'] = CRM_Utils_Array::value('sort_name', $pcpInfo) . " :: " . $pcpTitle . " :: " . $contributionPageTitle;
-      $values['pcp_made_through_id'] = CRM_Utils_Array::value('pcp_id', $pcpInfo);
-      $values['pcp_display_in_roll'] = CRM_Utils_Array::value('pcp_display_in_roll', $pcpInfo);
-      $values['pcp_roll_nickname'] = CRM_Utils_Array::value('pcp_roll_nickname', $pcpInfo);
-      $values['pcp_personal_note'] = CRM_Utils_Array::value('pcp_personal_note', $pcpInfo);
+      $defaults['pcp_made_through'] = CRM_Utils_Array::value('sort_name', $pcpInfo) . " :: " . $pcpTitle . " :: " . $contributionPageTitle;
+      $defaults['pcp_made_through_id'] = CRM_Utils_Array::value('pcp_id', $pcpInfo);
+      $defaults['pcp_display_in_roll'] = CRM_Utils_Array::value('pcp_display_in_roll', $pcpInfo);
+      $defaults['pcp_roll_nickname'] = CRM_Utils_Array::value('pcp_roll_nickname', $pcpInfo);
+      $defaults['pcp_personal_note'] = CRM_Utils_Array::value('pcp_personal_note', $pcpInfo);
     }
 
   }