$this->assign('lineItem', empty($this->_lineItems) ? FALSE : $this->_lineItems);
// Set title
- if ($this->_mode) {
+ if ($this->_mode && $this->_id) {
+ $this->setPageTitle(ts('Contribution (Pay Now)'));
+ }
+ elseif ($this->_mode) {
$this->setPageTitle($this->_ppID ? ts('Credit Card Pledge Payment') : ts('Credit Card Contribution'));
}
else {
unset($status[CRM_Utils_Array::key('Chargeback', $statusName)]);
}
- $this->add('select', 'contribution_status_id',
+ $statusElement = $this->add('select', 'contribution_status_id',
ts('Contribution Status'),
$status,
FALSE
);
+ $currencyFreeze = FALSE;
+ if ($this->_mode && $this->_id && ($this->_action & CRM_Core_Action::UPDATE)) {
+ $statusElement->freeze();
+ $currencyFreeze = TRUE;
+ $attributes['total_amount']['readonly'] = TRUE;
+ }
+
// CRM-16189, add Revenue Recognition Date
if (CRM_Contribute_BAO_Contribution::checkContributeSettings('deferred_revenue_enabled')) {
$this->add('date', 'revenue_recognition_date', ts('Revenue Recognition Date'), CRM_Core_SelectValues::date(NULL, 'M Y', NULL, 5));
}
}
$this->assign('hasPriceSets', $hasPriceSets);
- $currencyFreeze = FALSE;
if (!($this->_action & CRM_Core_Action::UPDATE)) {
if ($this->_online || $this->_ppID) {
$attributes['total_amount'] = array_merge($attributes['total_amount'], array(
$this->set('is_deductible', TRUE);
}
$contributionParams = array(
+ 'id' => CRM_Utils_Array::value('contribution_id', $this->_params),
'contact_id' => $contactID,
'line_item' => $lineItem,
'is_test' => $isTest,
$pId = $contributionDetails['participant'];
}
}
+ $this->_params['contribution_id'] = $this->_id;
}
if (!$priceSetId && !empty($submittedValues['total_amount']) && $this->_id) {
{if $contributionMode}
<div class="help">
{if $contactId}
- {ts 1=$displayName 2=$contributionMode|upper}Use this form to submit a new contribution on behalf of %1. <strong>A
+ {ts 1=$displayName 2=$contributionMode|upper}Use this form to {if $contribID} edit {else} submit a new {/if} contribution on behalf of %1. <strong>A
%2 transaction will be submitted</strong> using the selected payment processor.{/ts}
{else}
{ts 1=$displayName 2=$contributionMode|upper}Use this form to submit a new contribution. <strong>A %2 transaction will be submitted</strong> using the selected payment processor.{/ts}
{ts}(test){/ts}
{/if} {help id="id-financial_type"}
</td>
+ <td>
+ {if $contactId && $contribID && $contributionMode EQ null && $contribution_status_id eq 2}
+ {capture assign=payNowLink}{crmURL p='civicrm/contact/view/contribution' q="reset=1&action=update&id=`$contribID`&cid=`$contactId`&context=`$context`&mode=live"}{/capture}
+ <a class="open-inline-noreturn action-item crm-hover-button" href="{$payNowLink}">» {ts}Pay Now{/ts}</a>
+ {/if}
+ </td>
</tr>
{if $action eq 2 and $lineItem and !$defaultContribution}
<tr>
</td>
</tr>
- {if $buildRecurBlock}
+ {if $buildRecurBlock && !$contribID}
<tr id='recurringPaymentBlock' class='hiddenElement'>
<td></td>
<td>
{* CRM-7362 --add campaign to contributions *}
{include file="CRM/Campaign/Form/addCampaignToComponent.tpl" campaignTrClass="crm-contribution-form-block-campaign_id"}
- {if $contributionMode}
+ {if $contributionMode && !$contribID}
{if $email and $outBound_option != 2}
<tr class="crm-contribution-form-block-is_email_receipt">
<td class="label">{$form.is_email_receipt.label}</td>
</td>
</tr>
{/if}
- {if !$contributionMode}
+ {if !$contributionMode || $contribID}
<tr class="crm-contribution-form-block-contribution_status_id">
<td class="label">{$form.contribution_status_id.label}</td>
<td>{$form.contribution_status_id.html}
{if $contribution_status_id eq 2}{if $is_pay_later }: {ts}Pay Later{/ts} {else}: {ts}Incomplete Transaction{/ts}{/if}{/if}
</td>
</tr>
+ {/if}
+ {if !$contributionMode}
{* Cancellation / Refunded fields are hidden unless contribution status is set to Cancelled or Refunded*}
<tr id="cancelInfo" class="crm-contribution-form-block-cancelInfo">
<td> </td>
</td>
</tr>
{/if}
- {if $form.revenue_recognition_date}
+ {if $form.revenue_recognition_date && !$contribID}
<tr class="crm-contribution-form-block-revenue_recognition_date">
<td class="label">{$form.revenue_recognition_date.label}</td>
<td>{$form.revenue_recognition_date.html}</td>
parent::setUp();
}
+ public function testPayNowLink() {
+ $this->webtestLogin();
+
+ //Offline Pay Later Contribution
+ $contact = $this->_testOfflineContribution();
+ $this->openCiviPage("contact/view", "reset=1&cid={$contact['id']}", "css=li#tab_contribute a");
+ $this->click("css=li#tab_contribute a");
+ $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']/tbody//tr/td[8]/span/a");
+
+ $this->clickPopupLink("xpath=//table[@class='selector row-highlight']/tbody//tr/td[8]/span/a[@title='Edit Contribution']");
+ $this->waitForElementPresent('financial_type_id');
+
+ $this->clickPopupLink("xpath=//a[contains(text(), 'Pay Now')]");
+ $this->assertElementContainsText("xpath=//span[@class='ui-dialog-title']", "Edit Contribution (Pay Now)");
+ $this->assertElementNotPresent("xpath=//select[@id='currency']");
+ $this->assertNotEditable('total_amount');
+ $this->assertElementNotPresent("xpath=//select[@id='contribution_status_id']");
+
+ $this->webtestAddCreditCardDetails();
+ $this->webtestAddBillingDetails();
+
+ $this->clickAjaxLink('_qf_Contribution_upload-bottom');
+ $this->waitForText('crm-notification-container', "The contribution record has been saved.");
+
+ $this->clickPopupLink("xpath=//table[@class='selector row-highlight']/tbody//tr/td[8]/span/a[@title='View Contribution']");
+
+ // View Contribution Record and test for expected values
+ $expected = array(
+ 'From' => $contact['display_name'],
+ 'Financial Type' => 'Donation',
+ 'Total Amount' => '$ 100.00',
+ 'Payment Method' => 'Credit Card (Test Processor)',
+ 'Contribution Status' => 'Completed',
+ 'Received Into' => 'Payment Processor Account',
+ 'Net Amount' => '$ 98.50',
+ 'Fee Amount' => '$ 1.50',
+ );
+ $this->webtestVerifyTabularData($expected);
+ }
+
public function testUpdatePendingContribution() {
$this->webtestLogin();
$this->type("note", "This is a test note.");
$this->type("non_deductible_amount", "10");
- $this->type("fee_amount", "0");
- $this->type("net_amount", "0");
$this->type("invoice_id", time());
$this->webtestFillDate('thankyou_date');
// View Contribution Record and test for expected values
$expected = array(
'Financial Type' => 'Donation',
- 'Total Amount' => '100.00',
+ 'Total Amount' => '$ 100.00',
'Contribution Status' => 'Pending',
'Payment Method' => 'Check',
'Check Number' => 'check #1041',
// verify soft credit details
$expected = array(
4 => 'Donation',
- 2 => '100.00',
+ 2 => '$ 100.00',
6 => 'Pending',
1 => $contact['display_name'],
);