Skip to content

Commit

Permalink
Merge pull request #2 from manishmore/QA-fixes
Browse files Browse the repository at this point in the history
CRM-15701 QA-fixes
  • Loading branch information
kurund committed Dec 16, 2014
2 parents 45dff92 + 5542b7c commit a28742b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
12 changes: 7 additions & 5 deletions CRM/Batch/Form/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,12 @@ function buildQuickForm() {
$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);
Expand Down Expand Up @@ -466,7 +468,7 @@ private function processContribution(&$params) {

);
foreach ($fieldTranslations as $formField => $baoField) {
if(isset($value[$formField])) {
if (isset($value[$formField])) {
$value[$baoField] = $value[$formField];
}
unset($value[$formField]);
Expand Down
3 changes: 2 additions & 1 deletion CRM/Pledge/BAO/PledgePayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ static function getOldestPledgePayment($pledgeID, $limit = 1) {
$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}
Expand All @@ -711,6 +711,7 @@ static function getOldestPledgePayment($pledgeID, $limit = 1) {
'amount' => $payment->amount,
'currency' => $payment->currency,
'schedule_date' => $payment->scheduled_date,
'financial_type_id' => $payment->financial_type_id,
'count' => $count,
);
$count++;
Expand Down
14 changes: 9 additions & 5 deletions templates/CRM/Batch/Form/Entry.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,13 @@
{elseif in_array( $fields.$n.html_type, array('Radio', 'CheckBox'))}
<div class="compressed crm-grid-cell">&nbsp;{$form.field.$rowNumber.$n.html}</div>
{elseif $n eq 'total_amount'}
{if $batchType eq 3 }
<div class="compressed crm-grid-cell">{$form.field.$rowNumber.$n.html}
{ts}<span id={$rowNumber} class="pledge-adjust-option"><a href='#'>adjust payment amount</a></span>{/ts}
<span id="adjust-select-{$rowNumber}" class="adjust-selectbox">{$form.option_type.$rowNumber.html}</span></div>
{/if}
<div class="compressed crm-grid-cell">
{$form.field.$rowNumber.$n.html}
{if $batchType eq 3 }
{ts}<span id={$rowNumber} class="pledge-adjust-option"><a href='#'>adjust payment amount</a></span>{/ts}
<span id="adjust-select-{$rowNumber}" class="adjust-selectbox">{$form.option_type.$rowNumber.html}</span>
{/if}
</div>
{else}
<div class="compressed crm-grid-cell">{$form.field.$rowNumber.$n.html}</div>
{/if}
Expand Down Expand Up @@ -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');
}
}
Expand Down

0 comments on commit a28742b

Please sign in to comment.