From 5542b7c261fcd18f2df0c5e5a24bdfa91a421cb0 Mon Sep 17 00:00:00 2001 From: moremanish Date: Tue, 16 Dec 2014 18:22:05 +0530 Subject: [PATCH] CRM-15701 QA-fixes --- CRM/Batch/Form/Entry.php | 12 +++++++----- CRM/Pledge/BAO/PledgePayment.php | 3 ++- templates/CRM/Batch/Form/Entry.tpl | 14 +++++++++----- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/CRM/Batch/Form/Entry.php b/CRM/Batch/Form/Entry.php index c2bc6782a5..fd6560ae35 100755 --- a/CRM/Batch/Form/Entry.php +++ b/CRM/Batch/Form/Entry.php @@ -217,10 +217,12 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form { $this->add('select', "option_type[$rowNumber]", NULL, $optionTypes); if (!empty($this->_batchId) && !empty($this->_batchInfo['data']) && !empty($rowNumber)) { $dataValues = json_decode($this->_batchInfo['data'], TRUE); - $PledgeIDs = CRM_Pledge_BAO_Pledge::getContactPledges($dataValues['values']['primary_contact_id'][$rowNumber]); - foreach ($PledgeIDs as $pledgeID) { - $pledgePayment = CRM_Pledge_BAO_PledgePayment::getOldestPledgePayment($pledgeID); - $options += array($pledgeID => CRM_Utils_Date::customFormat($pledgePayment['schedule_date'], '%d/%m/%Y') . ', ' . $pledgePayment['amount'] . ' ' . $pledgePayment['currency']); + if (!empty($dataValues['values']['primary_contact_id'][$rowNumber])) { + $pledgeIDs = CRM_Pledge_BAO_Pledge::getContactPledges($dataValues['values']['primary_contact_id'][$rowNumber]); + foreach ($pledgeIDs as $pledgeID) { + $pledgePayment = CRM_Pledge_BAO_PledgePayment::getOldestPledgePayment($pledgeID); + $options += array($pledgeID => CRM_Utils_Date::customFormat($pledgePayment['schedule_date'], '%d/%m/%Y') . ', ' . $pledgePayment['amount'] . ' ' . $pledgePayment['currency']); + } } } $this->add('select', "open_pledges[$rowNumber]", ts('Open Pledges'), $options); @@ -466,7 +468,7 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form { ); foreach ($fieldTranslations as $formField => $baoField) { - if(isset($value[$formField])) { + if (isset($value[$formField])) { $value[$baoField] = $value[$formField]; } unset($value[$formField]); diff --git a/CRM/Pledge/BAO/PledgePayment.php b/CRM/Pledge/BAO/PledgePayment.php index 5c05e6f868..dc1b2d0f51 100644 --- a/CRM/Pledge/BAO/PledgePayment.php +++ b/CRM/Pledge/BAO/PledgePayment.php @@ -691,7 +691,7 @@ WHERE civicrm_pledge_payment.id = {$paymentId} $statusClause = " IN (" . implode(',', $status) . ")"; $query = " -SELECT civicrm_pledge_payment.id id, civicrm_pledge_payment.scheduled_amount amount, civicrm_pledge_payment.currency, civicrm_pledge_payment.scheduled_date +SELECT civicrm_pledge_payment.id id, civicrm_pledge_payment.scheduled_amount amount, civicrm_pledge_payment.currency, civicrm_pledge_payment.scheduled_date,civicrm_pledge.financial_type_id FROM civicrm_pledge, civicrm_pledge_payment WHERE civicrm_pledge.id = civicrm_pledge_payment.pledge_id AND civicrm_pledge_payment.status_id {$statusClause} @@ -711,6 +711,7 @@ LIMIT 0, %2 'amount' => $payment->amount, 'currency' => $payment->currency, 'schedule_date' => $payment->scheduled_date, + 'financial_type_id' => $payment->financial_type_id, 'count' => $count, ); $count++; diff --git a/templates/CRM/Batch/Form/Entry.tpl b/templates/CRM/Batch/Form/Entry.tpl index 48ba1a568f..abbd5ab8e7 100755 --- a/templates/CRM/Batch/Form/Entry.tpl +++ b/templates/CRM/Batch/Form/Entry.tpl @@ -102,11 +102,13 @@ {elseif in_array( $fields.$n.html_type, array('Radio', 'CheckBox'))}
 {$form.field.$rowNumber.$n.html}
{elseif $n eq 'total_amount'} - {if $batchType eq 3 } -
{$form.field.$rowNumber.$n.html} - {ts}adjust payment amount{/ts} - {$form.option_type.$rowNumber.html}
- {/if} +
+ {$form.field.$rowNumber.$n.html} + {if $batchType eq 3 } + {ts}adjust payment amount{/ts} + {$form.option_type.$rowNumber.html} + {/if} +
{else}
{$form.field.$rowNumber.$n.html}
{/if} @@ -528,12 +530,14 @@ function setPledgeAmount(form, pledgeID) { var dataUrl = CRM.url('civicrm/ajax/pledgeAmount'); if (pledgeID) { cj.post(dataUrl, {pid: pledgeID}, function (data) { + cj('#field_' + rowID + '_financial_type').val(data.financial_type_id).change(); cj('#field_' + rowID + '_total_amount').val(data.amount).change(); cj('#field_' + rowID + '_total_amount').attr('readonly', true); }, 'json'); } else { cj('#field_' + rowID + '_total_amount').val('').change(); + cj('#field_' + rowID + '_financial_type').val('').change(); cj('#field_' + rowID + '_total_amount').removeAttr('readonly'); } } -- 2.25.1