$cs->find();
if ($cs->N > 0) {
+ $count = 1;
while ($cs->fetch()) {
if ($all) {
foreach ($pcpFields as $val) {
$softContribution['pcp'][$val] = $cs->$val;
}
}
- $softContribution['soft_credit'][$cs->id]['soft_credit_to'] = $cs->contact_id;
- $softContribution['soft_credit'][$cs->id]['soft_credit_id'] = $cs->id;
- $softContribution['soft_credit'][$cs->id]['soft_credit_amount'] = $cs->amount;
+
+ $softContribution['soft_credit'][$count] = array(
+ 'soft_credit_to' => $cs->contact_id,
+ 'soft_credit_id' => $cs->id,
+ 'soft_credit_amount' => $cs->amount,
+ );
+ $count++;
}
}
return $softContribution;
// by default generate 5 blocks
$item_count = 6;
+ $showSoftCreditRow = 2;
+ $showCreateNew = true;
if ($form->_action & CRM_Core_Action::UPDATE) {
$csParams = array('contribution_id' => $form->_id);
$form->_softCreditInfo = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($csParams, TRUE);
- $showSoftCreditRow = count($form->_softCreditInfo['soft_credit']);
- $showSoftCreditRow++;
- }
- else {
- $showSoftCreditRow = 2;
+ if (!empty($form->_softCreditInfo['soft_credit'])) {
+ $showSoftCreditRow = count($form->_softCreditInfo['soft_credit']);
+ $showSoftCreditRow++;
+ $showCreateNew = false;
+ }
}
for ($rowNumber = 1; $rowNumber <= $item_count; $rowNumber++) {
$form->assign('showSoftCreditRow', $showSoftCreditRow);
$form->assign('rowCount', $item_count);
+ $form->assign('showCreateNew', $showCreateNew);
// Tell tpl to hide soft credit field if contribution is linked directly to a PCP Page
if (CRM_Utils_Array::value('pcp_made_through_id', $form->_values)) {
*/
static function setDefaultValues(&$defaults, &$form) {
- //crm_core_error::debug('$form->_softCreditInfo', $form->_softCreditInfo);
- //exit;
+// 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'];
+ }
+ }
/*
if (CRM_Utils_Array::value('soft_credit_to', $softCredit)) {
<tr id="soft-credit-row-{$rowNumber}" class="crm-contribution-form-block-soft_credit_to {if $rowNumber gte $showSoftCreditRow}hiddenElement{/if}">
<td class="label">{ts}Soft Credit To{/ts}</td>
<td>
+ {assign var='createNewStatus' value=true}
+ {if !$showCreateNew and $rowNumber lt $showSoftCreditRow}
+ {assign var='createNewStatus' value=false}
+ {/if}
{include file="CRM/Contact/Form/NewContact.tpl" noLabel=true skipBreak=true blockNo=$rowNumber
- prefix="soft_credit_"}
+ prefix="soft_credit_" showNewSelect=$createNewStatus}
</td>
<td>
{$form.soft_credit_amount.$rowNumber.label} {$form.soft_credit_amount.$rowNumber.html|crmAddClass:eight}