else {
$setting = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($values['user_dashboard_options'], 1, -1));
$invoiceKey = array_search($setKey, $setting);
- unset($setting[$invoiceKey]);
+ if (!empty($invoiceKey)) {
+ unset($setting[$invoiceKey]);
+ }
$settingName = CRM_Core_DAO::VALUE_SEPARATOR .
implode(CRM_Core_DAO::VALUE_SEPARATOR, array_values($setting)) .
CRM_Core_DAO::VALUE_SEPARATOR;
if ($isPaymentTransaction) {
$contributionParams = array(
+ 'id' => CRM_Utils_Array::value('contribution_id', $paymentParams),
'contact_id' => $contactID,
'line_item' => $lineItems,
'is_test' => $isTest,
// lineItem isn't set until Register postProcess
$this->_lineItem = $this->get('lineItem');
+ $this->_ccid = $this->get('ccid');
$this->_paymentProcessor = $this->get('paymentProcessor');
$this->_params = $this->controller->exportValues('Main');
$this->_params['ip_address'] = CRM_Utils_System::ipAddress();
if (isset($this->_params['payment_processor_id']) && $this->_params['payment_processor_id'] === 0) {
$this->_params['is_pay_later'] = $isPayLater = TRUE;
}
+
+ if (!empty($this->_ccid)) {
+ $this->_params['contribution_id'] = $this->_ccid;
+ }
// add a description field at the very beginning
$this->_params['description'] = ts('Online Contribution') . ': ' . (($this->_pcpInfo['title']) ? $this->_pcpInfo['title'] : $this->_values['title']);
public function preProcess() {
parent::preProcess();
+ $this->_ccid = CRM_Utils_Request::retrieve('ccid', 'Positive', $this);
$this->_paymentProcessors = $this->get('paymentProcessors');
$this->preProcessPaymentOptions();
+ if (!empty($this->_ccid)) {
+ $payment = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_ccid, 'contribution');
+ //bounce if the contribution is not pending.
+ if (empty($payment['balance'])) {
+ CRM_Core_Error::statusBounce(ts("Returning since contribution has already been handled."));
+ }
+ if (!empty($payment['total'])) {
+ $this->_pendingAmount = $payment['total'];
+ $this->assign('pendingAmount', $this->_pendingAmount);
+ }
+ $lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($this->_ccid);
+ foreach (array_keys($lineItems) as $id) {
+ $lineItems[$id]['id'] = $id;
+ }
+ $itemId = key($lineItems);
+ if ($itemId && !empty($lineItems[$itemId]['price_field_id'])) {
+ $this->_priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $lineItems[$itemId]['price_field_id'], 'price_set_id');
+ }
+
+ if (!empty($lineItems[$itemId]['price_field_id'])) {
+ $this->_lineItem[$this->_priceSetId] = $lineItems;
+ }
+ $isQuickConfig = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config');
+ $this->assign('lineItem', $this->_lineItem);
+ $this->assign('is_quick_config', $isQuickConfig);
+ $this->assign('priceSetID', $this->_priceSetId);
+ }
+
// Make the contributionPageID available to the template
$this->assign('contributionPageID', $this->_id);
+ $this->assign('ccid', $this->_ccid);
$this->assign('isShare', CRM_Utils_Array::value('is_share', $this->_values));
$this->assign('isConfirmEnabled', CRM_Utils_Array::value('is_confirm_enabled', $this->_values));
$billingDefaults = $this->getProfileDefaults('Billing', $contactID);
$this->_defaults = array_merge($this->_defaults, $billingDefaults);
}
+ if (!empty($this->_ccid) && !empty($this->_pendingAmount)) {
+ $this->_defaults['total_amount'] = $this->_pendingAmount;
+ }
/*
* hack to simplify credit card entry for testing
}
$this->applyFilter('__ALL__', 'trim');
- $this->add('text', "email-{$this->_bltID}",
- ts('Email Address'),
- array('size' => 30, 'maxlength' => 60, 'class' => 'email'),
- TRUE
- );
- $this->addRule("email-{$this->_bltID}", ts('Email is not valid.'), 'email');
+ $hidePayLater = FALSE;
+ if (empty($this->_ccid)) {
+ $this->add('text', "email-{$this->_bltID}",
+ ts('Email Address'),
+ array('size' => 30, 'maxlength' => 60, 'class' => 'email'),
+ TRUE
+ );
+ $this->addRule("email-{$this->_bltID}", ts('Email is not valid.'), 'email');
+ }
+ else {
+ $this->addElement('hidden', "email-{$this->_bltID}", 1);
+ $this->add('text', 'total_amount', ts('Total Amount'), array('readonly' => TRUE), FALSE);
+ if (!empty($this->_paymentProcessors[0])) {
+ $hidePayLater = TRUE;
+ }
+ }
+ $this->assign('hidePayLater', $hidePayLater);
$pps = array();
//@todo - this should be replaced by a check as to whether billing fields are set
$onlinePaymentProcessorEnabled = FALSE;
//build pledge block.
$this->_useForMember = 0;
//don't build membership block when pledge_id is passed
- if (empty($this->_values['pledge_id'])) {
+ if (empty($this->_values['pledge_id']) && empty($this->_ccid)) {
$this->_separateMembershipPayment = FALSE;
if (in_array('CiviMember', $config->enableComponents)) {
$isTest = 0;
$this->add('hidden', 'priceSetId', $this->_priceSetId);
// build price set form.
$this->set('priceSetId', $this->_priceSetId);
- CRM_Price_BAO_PriceSet::buildPriceSet($this);
+ if (empty($this->_ccid)) {
+ CRM_Price_BAO_PriceSet::buildPriceSet($this);
+ }
if ($this->_values['is_monetary'] &&
$this->_values['is_recur'] && empty($this->_values['pledge_id'])
) {
}
}
- if ($this->_priceSetId) {
+ if ($this->_priceSetId && empty($this->_ccid)) {
$is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config');
if ($is_quick_config) {
$this->_useForMember = 0;
}
//we allow premium for pledge during pledge creation only.
- if (empty($this->_values['pledge_id'])) {
+ if (empty($this->_values['pledge_id']) && empty($this->_ccid)) {
CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, TRUE);
}
//don't build pledge block when mid is passed
- if (!$this->_mid) {
+ if (!$this->_mid && empty($this->_ccid)) {
$config = CRM_Core_Config::singleton();
if (in_array('CiviPledge', $config->enableComponents) && !empty($this->_values['pledge_block_id'])) {
CRM_Pledge_BAO_PledgeBlock::buildPledgeBlock($this);
}
//to create an cms user
- if (!$this->_contactID) {
+ if (!$this->_contactID && empty($this->_ccid)) {
$createCMSUser = FALSE;
if ($this->_values['custom_pre_id']) {
CRM_Core_BAO_CMSUser::buildForm($this, $profileID, TRUE);
}
}
- if ($this->_pcpId) {
+ if ($this->_pcpId && empty($this->_ccid)) {
if ($pcpSupporter = CRM_PCP_BAO_PCP::displayName($this->_pcpId)) {
$pcp_supporter_text = ts('This contribution is being made thanks to the effort of <strong>%1</strong>, who supports our campaign.', array(1 => $pcpSupporter));
// Only tell people that can also create a PCP if the contribution page has a non-empty value in the "Create Personal Campaign Page link" field.
$this->add('textarea', 'pcp_personal_note', ts('Personal Note'), array('style' => 'height: 3em; width: 40em;'));
}
}
- if (empty($this->_values['fee'])) {
+ if (empty($this->_values['fee']) && empty($this->_ccid)) {
CRM_Core_Error::fatal(ts('This page does not have any price fields configured or you may not have permission for them. Please contact the site administrator for more details.'));
}
}
//check for atleast one pricefields should be selected
- if (!empty($fields['priceSetId'])) {
+ if (!empty($fields['priceSetId']) && empty($self->_ccid)) {
$priceField = new CRM_Price_DAO_PriceField();
$priceField->price_set_id = $fields['priceSetId'];
$priceField->orderBy('weight');
$errors["price_{$errorKey}"] = ts('Additional Contribution is required.');
}
}
- if (empty($check)) {
+ if (empty($check) && empty($self->_ccid)) {
if ($self->_useForMember == 1 && $membershipIsActive) {
$errors['_qf_default'] = ts('Select at least one option from Membership Type(s).');
}
}
}
}
- // from here on down, $params['amount'] holds a monetary value (or null) rather than an option ID
- $params['amount'] = self::computeAmount($params, $this->_values);
+
+ if (!empty($this->_ccid) && !empty($this->_pendingAmount)) {
+ $params['amount'] = $this->_pendingAmount;
+ }
+ else {
+ // from here on down, $params['amount'] holds a monetary value (or null) rather than an option ID
+ $params['amount'] = self::computeAmount($params, $this->_values);
+ }
$params['separate_amount'] = $params['amount'];
$memFee = NULL;
$this->set('amount_level', CRM_Utils_Array::value('amount_level', $params));
}
- if ($priceSetId = CRM_Utils_Array::value('priceSetId', $params)) {
+ if ($this->_ccid) {
+ $this->set('lineItem', $this->_lineItem);
+ }
+ elseif ($priceSetId = CRM_Utils_Array::value('priceSetId', $params)) {
$lineItem = array();
$is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config');
if ($is_quick_config) {
public function run() {
$invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
+ $defaultInvoicePage = CRM_Utils_Array::value('default_invoice_page', $invoiceSettings);
$this->assign('invoicing', $invoicing);
+ $this->assign('defaultInvoicePage', $defaultInvoicePage);
parent::preProcess();
$this->listContribution();
}
+--------------------------------------------------------------------+
*}
{* Callback snippet: On-behalf profile *}
-{if $snippet and !empty($isOnBehalfCallback)}
+{if $snippet and !empty($isOnBehalfCallback) and !$ccid}
<div class="crm-public-form-item crm-section">
{include file="CRM/Contribute/Form/Contribution/OnBehalfOf.tpl" context="front-end"}
</div>
<div class="crm-contribution-page-id-{$contributionPageID} crm-block crm-contribution-main-form-block">
- {if $contact_id}
+ {if $contact_id && !$ccid}
<div class="messages status no-popup crm-not-you-message">
{ts 1=$display_name}Welcome %1{/ts}. (<a href="{crmURL p='civicrm/contribute/transact' q="cid=0&reset=1&id=`$contributionPageID`"}" title="{ts}Click here to do this for a different person.{/ts}">{ts 1=$display_name}Not %1, or want to do this for a different person{/ts}</a>?)
</div>
<div class="help">{ts}You have a current Lifetime Membership which does not need to be renewed.{/ts}</div>
{/if}
- {if !empty($useForMember)}
- <div class="crm-public-form-item crm-section">
- {include file="CRM/Contribute/Form/Contribution/MembershipBlock.tpl" context="makeContribution"}
- </div>
+ {if !empty($useForMember) && !$ccid}
+ <div class="crm-public-form-item crm-section">
+ {include file="CRM/Contribute/Form/Contribution/MembershipBlock.tpl" context="makeContribution"}
+ </div>
+ {elseif !empty($ccid)}
+ {if $lineItem && $priceSetID && !$is_quick_config}
+ <div class="header-dark">
+ {ts}Contribution Information{/ts}
+ </div>
+ {assign var="totalAmount" value=$pendingAmount}
+ {include file="CRM/Price/Page/LineItem.tpl" context="Contribution"}
{else}
- <div id="priceset-div">
- {include file="CRM/Price/Form/PriceSet.tpl" extends="Contribution"}
- </div>
+ <div class="display-block">
+ <td class="label">{$form.total_amount.label}</td>
+ <td><span>{$form.total_amount.html|crmMoney}</span></td>
+ </div>
+ {/if}
+ {else}
+ <div id="priceset-div">
+ {include file="CRM/Price/Form/PriceSet.tpl" extends="Contribution"}
+ </div>
{/if}
- {crmRegion name='contribution-main-pledge-block'}
+ {if !$ccid}
+ {crmRegion name='contribution-main-pledge-block'}
{if $pledgeBlock}
{if $is_pledge_payment}
<div class="crm-public-form-item crm-section {$form.pledge_amount.name}-section">
<div class="content">{$form.pledge_amount.html}</div>
<div class="clear"></div>
</div>
- {else}
- <div class="crm-public-form-item crm-section {$form.is_pledge.name}-section">
- <div class="label"> </div>
- <div class="content">
- {$form.is_pledge.html}
- {if $is_pledge_interval}
- {$form.pledge_frequency_interval.html}
+ {else}
+ <div class="crm-public-form-item crm-section {$form.is_pledge.name}-section">
+ <div class="label"> </div>
+ <div class="content">
+ {$form.is_pledge.html}
+ {if $is_pledge_interval}
+ {$form.pledge_frequency_interval.html}
+ {/if}
+ {$form.pledge_frequency_unit.html}<span id="pledge_installments_num"> {ts}for{/ts} {$form.pledge_installments.html} {ts}installments.{/ts}</span>
+ </div>
+ <div class="clear"></div>
+ {if $start_date_editable}
+ {if $is_date}
+ <div class="label">{$form.start_date.label}</div><div class="content">{include file="CRM/common/jcalendar.tpl" elementName=start_date}</div>
+ {else}
+ <div class="label">{$form.start_date.label}</div><div class="content">{$form.start_date.html}</div>
+ {/if}
+ {else}
+ <div class="label">{$form.start_date.label}</div>
+ <div class="content">{$start_date_display|date_format}</div>
{/if}
- {$form.pledge_frequency_unit.html}<span id="pledge_installments_num"> {ts}for{/ts} {$form.pledge_installments.html} {ts}installments.{/ts}</span>
- </div>
- <div class="clear"></div>
- {if $start_date_editable}
- {if $is_date}
- <div class="label">{$form.start_date.label}</div><div class="content">{include file="CRM/common/jcalendar.tpl" elementName=start_date}</div>
- {else}
- <div class="label">{$form.start_date.label}</div><div class="content">{$form.start_date.html}</div>
- {/if}
- {else}
- <div class="label">{$form.start_date.label}</div>
- <div class="content">{$start_date_display|date_format}</div>
- {/if}
<div class="clear"></div>
- </div>
+ </div>
{/if}
{/if}
- {/crmRegion}
-
- {if $form.is_recur}
- <div class="crm-public-form-item crm-section {$form.is_recur.name}-section">
- <div class="label"> </div>
- <div class="content">
- {$form.is_recur.html} {$form.is_recur.label} {ts}every{/ts}
- {if $is_recur_interval}
- {$form.frequency_interval.html}
- {/if}
- {if $one_frequency_unit}
- {$frequency_unit}
- {else}
- {$form.frequency_unit.html}
- {/if}
- {if $is_recur_installments}
- <span id="recur_installments_num">
- {ts}for{/ts} {$form.installments.html} {$form.installments.label}
- </span>
- {/if}
- <div id="recurHelp" class="description">
- {ts}Your recurring contribution will be processed automatically.{/ts}
- {if $is_recur_installments}
- {ts}You can specify the number of installments, or you can leave the number of installments blank if you want to make an open-ended commitment. In either case, you can choose to cancel at any time.{/ts}
+ {/crmRegion}
+
+ {if $form.is_recur}
+ <div class="crm-public-form-item crm-section {$form.is_recur.name}-section">
+ <div class="label"> </div>
+ <div class="content">
+ {$form.is_recur.html} {$form.is_recur.label} {ts}every{/ts}
+ {if $is_recur_interval}
+ {$form.frequency_interval.html}
{/if}
- {if $is_email_receipt}
- {ts}You will receive an email receipt for each recurring contribution.{/ts}
+ {if $one_frequency_unit}
+ {$frequency_unit}
+ {else}
+ {$form.frequency_unit.html}
{/if}
+ {if $is_recur_installments}
+ <span id="recur_installments_num">
+ {ts}for{/ts} {$form.installments.html} {$form.installments.label}
+ </span>
+ {/if}
+ <div id="recurHelp" class="description">
+ {ts}Your recurring contribution will be processed automatically.{/ts}
+ {if $is_recur_installments}
+ {ts}You can specify the number of installments, or you can leave the number of installments blank if you want to make an open-ended commitment. In either case, you can choose to cancel at any time.{/ts}
+ {/if}
+ {if $is_email_receipt}
+ {ts}You will receive an email receipt for each recurring contribution.{/ts}
+ {/if}
+ </div>
</div>
+ <div class="clear"></div>
</div>
- <div class="clear"></div>
- </div>
- {/if}
- {if $pcpSupporterText}
- <div class="crm-public-form-item crm-section pcpSupporterText-section">
- <div class="label"> </div>
- <div class="content">{$pcpSupporterText}</div>
- <div class="clear"></div>
- </div>
- {/if}
- {assign var=n value=email-$bltID}
- <div class="crm-public-form-item crm-section {$form.$n.name}-section">
- <div class="label">{$form.$n.label}</div>
- <div class="content">
- {$form.$n.html}
+ {/if}
+ {if $pcpSupporterText}
+ <div class="crm-public-form-item crm-section pcpSupporterText-section">
+ <div class="label"> </div>
+ <div class="content">{$pcpSupporterText}</div>
+ <div class="clear"></div>
+ </div>
+ {/if}
+ {assign var=n value=email-$bltID}
+ <div class="crm-public-form-item crm-section {$form.$n.name}-section">
+ <div class="label">{$form.$n.label}</div>
+ <div class="content">
+ {$form.$n.html}
+ </div>
+ <div class="clear"></div>
</div>
- <div class="clear"></div>
- </div>
- <div class="crm-public-form-item crm-section">
- {include file="CRM/Contribute/Form/Contribution/OnBehalfOf.tpl"}
- </div>
+ <div class="crm-public-form-item crm-section">
+ {include file="CRM/Contribute/Form/Contribution/OnBehalfOf.tpl"}
+ </div>
- {* User account registration option. Displays if enabled for one of the profiles on this page. *}
- <div class="crm-public-form-item crm-section cms_user-section">
- {include file="CRM/common/CMSUser.tpl"}
- </div>
- <div class="crm-public-form-item crm-section premium_block-section">
- {include file="CRM/Contribute/Form/Contribution/PremiumBlock.tpl" context="makeContribution"}
- </div>
+ {* User account registration option. Displays if enabled for one of the profiles on this page. *}
+ <div class="crm-public-form-item crm-section cms_user-section">
+ {include file="CRM/common/CMSUser.tpl"}
+ </div>
+ <div class="crm-public-form-item crm-section premium_block-section">
+ {include file="CRM/Contribute/Form/Contribution/PremiumBlock.tpl" context="makeContribution"}
+ </div>
- {if $honoreeProfileFields|@count}
- <fieldset class="crm-public-form-item crm-group honor_block-group">
- {crmRegion name="contribution-soft-credit-block"}
- <legend>{$honor_block_title}</legend>
- <div class="crm-public-form-item crm-section honor_block_text-section">
- {$honor_block_text}
- </div>
- {if $form.soft_credit_type_id.html}
- <div class="crm-public-form-item crm-section {$form.soft_credit_type_id.name}-section">
- <div class="content" >
- {$form.soft_credit_type_id.html}
- <div class="description">{ts}Select an option to reveal honoree information fields.{/ts}</div>
- </div>
+ {if $honoreeProfileFields|@count}
+ <fieldset class="crm-public-form-item crm-group honor_block-group">
+ {crmRegion name="contribution-soft-credit-block"}
+ <legend>{$honor_block_title}</legend>
+ <div class="crm-public-form-item crm-section honor_block_text-section">
+ {$honor_block_text}
</div>
- {/if}
- {/crmRegion}
- <div id="honorType" class="honoree-name-email-section">
- {include file="CRM/UF/Form/Block.tpl" fields=$honoreeProfileFields mode=8 prefix='honor'}
- </div>
- </fieldset>
- {/if}
+ {if $form.soft_credit_type_id.html}
+ <div class="crm-public-form-item crm-section {$form.soft_credit_type_id.name}-section">
+ <div class="content" >
+ {$form.soft_credit_type_id.html}
+ <div class="description">{ts}Select an option to reveal honoree information fields.{/ts}</div>
+ </div>
+ </div>
+ {/if}
+ {/crmRegion}
+ <div id="honorType" class="honoree-name-email-section">
+ {include file="CRM/UF/Form/Block.tpl" fields=$honoreeProfileFields mode=8 prefix='honor'}
+ </div>
+ </fieldset>
+ {/if}
- <div class="crm-public-form-item crm-group custom_pre_profile-group">
- {include file="CRM/UF/Form/Block.tpl" fields=$customPre}
- </div>
+ <div class="crm-public-form-item crm-group custom_pre_profile-group">
+ {include file="CRM/UF/Form/Block.tpl" fields=$customPre}
+ </div>
- {if $isHonor}
- <fieldset class="crm-public-form-item crm-group pcp-group">
- <div class="crm-public-form-item crm-section pcp-section">
- <div class="crm-public-form-item crm-section display_in_roll-section">
- <div class="content">
- {$form.pcp_display_in_roll.html}
- {$form.pcp_display_in_roll.label}
+ {if $isHonor}
+ <fieldset class="crm-public-form-item crm-group pcp-group">
+ <div class="crm-public-form-item crm-section pcp-section">
+ <div class="crm-public-form-item crm-section display_in_roll-section">
+ <div class="content">
+ {$form.pcp_display_in_roll.html}
+ {$form.pcp_display_in_roll.label}
+ </div>
+ <div class="clear"></div>
</div>
- <div class="clear"></div>
- </div>
- <div id="nameID" class="crm-public-form-item crm-section is_anonymous-section">
- <div class="content">
- {$form.pcp_is_anonymous.html}
+ <div id="nameID" class="crm-public-form-item crm-section is_anonymous-section">
+ <div class="content">
+ {$form.pcp_is_anonymous.html}
+ </div>
+ <div class="clear"></div>
</div>
- <div class="clear"></div>
- </div>
- <div id="nickID" class="crm-public-form-item crm-section pcp_roll_nickname-section">
- <div class="label">{$form.pcp_roll_nickname.label}</div>
- <div class="content">{$form.pcp_roll_nickname.html}
- <div class="description">{ts}Enter the name you want listed with this contribution. You can use a nick name like 'The Jones Family' or 'Sarah and Sam'.{/ts}</div>
+ <div id="nickID" class="crm-public-form-item crm-section pcp_roll_nickname-section">
+ <div class="label">{$form.pcp_roll_nickname.label}</div>
+ <div class="content">{$form.pcp_roll_nickname.html}
+ <div class="description">{ts}Enter the name you want listed with this contribution. You can use a nick name like 'The Jones Family' or 'Sarah and Sam'.{/ts}</div>
+ </div>
+ <div class="clear"></div>
</div>
- <div class="clear"></div>
- </div>
- <div id="personalNoteID" class="crm-public-form-item crm-section pcp_personal_note-section">
- <div class="label">{$form.pcp_personal_note.label}</div>
- <div class="content">
- {$form.pcp_personal_note.html}
- <div class="description">{ts}Enter a message to accompany this contribution.{/ts}</div>
+ <div id="personalNoteID" class="crm-public-form-item crm-section pcp_personal_note-section">
+ <div class="label">{$form.pcp_personal_note.label}</div>
+ <div class="content">
+ {$form.pcp_personal_note.html}
+ <div class="description">{ts}Enter a message to accompany this contribution.{/ts}</div>
+ </div>
+ <div class="clear"></div>
</div>
- <div class="clear"></div>
</div>
- </div>
- </fieldset>
+ </fieldset>
+ {/if}
+
+ {* end of ccid loop *}
{/if}
{if $form.payment_processor_id.label}
pcpAnonymous();
{/if}
+ {if $hidePayLater}
+ hidePayLater();
+ {/if}
+
{literal}
cj('input[name="soft_credit_type_id"]').on('change', function() {
}
}
+ function hidePayLater() {
+ cj('input:radio[name="payment_processor_id"][value=0]').hide();
+ cj('input:radio[name="payment_processor_id"][value=0]').next('label').hide();
+ }
+
cj('input[id="is_recur"]').on('change', function() {
toggleRecur();
});
<th>{ts}Receipt Sent{/ts}</th>
<th>{ts}Status{/ts}</th>
{if $invoicing && $invoices}
- <th></th>
+ <th></th>
+ {/if}
+ {if $invoicing && $defaultInvoicePage}
+ <th></th>
{/if}
</tr>
{assign var='contact_id' value=$row.contact_id}
{assign var='urlParams' value="reset=1&id=$id&cid=$contact_id"}
{if call_user_func(array('CRM_Core_Permission','check'), 'view my invoices') OR call_user_func(array('CRM_Core_Permission','check'), 'access CiviContribute')}
- <a class="button no-popup "
+ <a class="button no-popup nowrap"
href="{crmURL p='civicrm/contribute/invoice' q=$urlParams}">
<i class="crm-i fa-print"></i>
{if $row.contribution_status != 'Refunded' && $row.contribution_status != 'Cancelled' }
{/if}
</td>
{/if}
+ {if $defaultInvoicePage && $row.contribution_status == 'Pending (Pay Later)'}
+ <td>
+ {assign var='id' value=$row.contribution_id}
+ {capture assign=payNowLink}{crmURL p='civicrm/contribute/transact' q="reset=1&id=`$defaultInvoicePage`&ccid=`$id`"}{/capture}
+ <a class="button" href="{$payNowLink}"><span class='nowrap'>{ts}Pay Now{/ts}</span></a>
+ </td>
+ {/if}
</tr>
{/foreach}
</table>
$this->waitForElementPresent('link=Add Financial Account');
}
+ /**
+ * @param $setTitle
+ * @param $usedFor
+ * @param $setHelp
+ * @param null $financialType
+ */
+ public function _testAddSet($setTitle, $usedFor, $setHelp, $financialType = NULL) {
+ $this->openCiviPage("admin/price", "reset=1&action=add", '_qf_Set_next-bottom');
+
+ // Enter Priceset fields (Title, Used For ...)
+ $this->type('title', $setTitle);
+ if ($usedFor == 'Event') {
+ $this->check('extends_1');
+ }
+ elseif ($usedFor == 'Contribution') {
+ $this->check('extends_2');
+ }
+
+ if ($financialType) {
+ $this->select("financial_type_id", "label={$financialType}");
+ }
+ $this->type('help_pre', $setHelp);
+
+ $this->assertChecked('is_active', 'Verify that Is Active checkbox is set.');
+ $this->clickLink('_qf_Set_next-bottom');
+ }
+
+ /**
+ * @param $fields
+ * @param $validateString
+ * @param $financialType
+ * @param bool $dateSpecificFields
+ */
+ public function _testAddPriceFields(&$fields, &$validateString, $financialType, $dateSpecificFields = FALSE) {
+ $validateStrings[] = $financialType;
+ $sid = $this->urlArg('sid');
+ $this->openCiviPage('admin/price/field', "reset=1&action=add&sid=$sid", 'label');
+ foreach ($fields as $label => $type) {
+ $validateStrings[] = $label;
+
+ $this->type('label', $label);
+ $this->select('html_type', "value={$type}");
+
+ switch ($type) {
+ case 'Text':
+ $validateStrings[] = '525.00';
+ $this->type('price', '525.00');
+ if ($dateSpecificFields == TRUE) {
+ $this->webtestFillDateTime('active_on', '+1 week');
+ }
+ else {
+ $this->check('is_required');
+ }
+ break;
+
+ case 'Select':
+ $options = array(
+ 1 => array(
+ 'label' => 'Chicken',
+ 'amount' => '30.00',
+ ),
+ 2 => array(
+ 'label' => 'Vegetarian',
+ 'amount' => '25.00',
+ ),
+ );
+ $this->addMultipleChoiceOptions($options, $validateStrings);
+ if ($dateSpecificFields == TRUE) {
+ $this->webtestFillDateTime('expire_on', '-1 week');
+ }
+ break;
+
+ case 'Radio':
+ $options = array(
+ 1 => array(
+ 'label' => 'Yes',
+ 'amount' => '50.00',
+ ),
+ 2 => array(
+ 'label' => 'No',
+ 'amount' => '0',
+ ),
+ );
+ $this->addMultipleChoiceOptions($options, $validateStrings);
+ $this->check('is_required');
+ if ($dateSpecificFields == TRUE) {
+ $this->webtestFillDateTime('active_on', '-1 week');
+ }
+ break;
+
+ case 'CheckBox':
+ $options = array(
+ 1 => array(
+ 'label' => 'First Night',
+ 'amount' => '15.00',
+ ),
+ 2 => array(
+ 'label' => 'Second Night',
+ 'amount' => '15.00',
+ ),
+ );
+ $this->addMultipleChoiceOptions($options, $validateStrings);
+ if ($dateSpecificFields == TRUE) {
+ $this->webtestFillDateTime('expire_on', '+1 week');
+ }
+ break;
+
+ default:
+ break;
+ }
+ $this->select('financial_type_id', "label={$financialType}");
+ $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_next-bottom', FALSE);
+ $this->waitForText('crm-notification-container', "Price Field '$label' has been saved.");
+ }
+ }
+
/**
* Delete Financial Account.
* @param $financialAccountTitle
$this->_testVerifyPriceSet($validateStrings, $sid);
}
- /**
- * @param $setTitle
- * @param $usedFor
- * @param $setHelp
- * @param null $financialType
- */
- public function _testAddSet($setTitle, $usedFor, $setHelp, $financialType = NULL) {
- $this->openCiviPage("admin/price", "reset=1&action=add", '_qf_Set_next-bottom');
-
- // Enter Priceset fields (Title, Used For ...)
- $this->type('title', $setTitle);
- if ($usedFor == 'Event') {
- $this->check('extends_1');
- }
- elseif ($usedFor == 'Contribution') {
- $this->check('extends_2');
- }
-
- if ($financialType) {
- $this->select("financial_type_id", "label={$financialType}");
- }
- $this->type('help_pre', $setHelp);
-
- $this->assertChecked('is_active', 'Verify that Is Active checkbox is set.');
- $this->clickLink('_qf_Set_next-bottom');
- }
-
- /**
- * @param $fields
- * @param $validateString
- * @param $financialType
- * @param bool $dateSpecificFields
- */
- public function _testAddPriceFields(&$fields, &$validateString, $financialType, $dateSpecificFields = FALSE) {
- $validateStrings[] = $financialType;
- $sid = $this->urlArg('sid');
- $this->openCiviPage('admin/price/field', "reset=1&action=add&sid=$sid", 'label');
- foreach ($fields as $label => $type) {
- $validateStrings[] = $label;
-
- $this->type('label', $label);
- $this->select('html_type', "value={$type}");
-
- switch ($type) {
- case 'Text':
- $validateStrings[] = '525.00';
- $this->type('price', '525.00');
- if ($dateSpecificFields == TRUE) {
- $this->webtestFillDateTime('active_on', '+1 week');
- }
- else {
- $this->check('is_required');
- }
- break;
-
- case 'Select':
- $options = array(
- 1 => array(
- 'label' => 'Chicken',
- 'amount' => '30.00',
- ),
- 2 => array(
- 'label' => 'Vegetarian',
- 'amount' => '25.00',
- ),
- );
- $this->addMultipleChoiceOptions($options, $validateStrings);
- if ($dateSpecificFields == TRUE) {
- $this->webtestFillDateTime('expire_on', '-1 week');
- }
- break;
-
- case 'Radio':
- $options = array(
- 1 => array(
- 'label' => 'Yes',
- 'amount' => '50.00',
- ),
- 2 => array(
- 'label' => 'No',
- 'amount' => '0',
- ),
- );
- $this->addMultipleChoiceOptions($options, $validateStrings);
- $this->check('is_required');
- if ($dateSpecificFields == TRUE) {
- $this->webtestFillDateTime('active_on', '-1 week');
- }
- break;
-
- case 'CheckBox':
- $options = array(
- 1 => array(
- 'label' => 'First Night',
- 'amount' => '15.00',
- ),
- 2 => array(
- 'label' => 'Second Night',
- 'amount' => '15.00',
- ),
- );
- $this->addMultipleChoiceOptions($options, $validateStrings);
- if ($dateSpecificFields == TRUE) {
- $this->webtestFillDateTime('expire_on', '+1 week');
- }
- break;
-
- default:
- break;
- }
- $this->select('financial_type_id', "label={$financialType}");
- $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_next-bottom', FALSE);
- $this->waitForText('crm-notification-container', "Price Field '$label' has been saved.");
- }
- }
-
/**
* @return string
*/
$this->webtestVerifyTabularData($expected);
}
+ public function testOnlineContributionWithPayNowLink() {
+ $this->webtestLogin();
+ $pageId = 1;
+ $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id=$pageId", 'is_pay_later');
+ $this->check('is_pay_later');
+ $this->type('pay_later_text', "I will send payment by check");
+ $this->fillRichTextField('pay_later_receipt', "I will send payment by check");
+ $this->clickLink("_qf_Amount_upload_done-bottom");
+
+ //add financial type of account type expense
+ $financialType = 'Donation';
+ $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
+ $usedFor = 'Contribution';
+ $setHelp = 'Select your conference options.';
+ $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType);
+ $sid = $this->urlArg('sid');
+
+ $validateStrings = array();
+ $fields = array(
+ 'Full Conference' => 'Text',
+ 'Meal Choice' => 'Select',
+ 'Pre-conference Meetup?' => 'Radio',
+ 'Evening Sessions' => 'CheckBox',
+ );
+
+ $this->_testAddPriceFields($fields, $validateStrings, $financialType);
+
+ //Add profile Details
+ $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
+ $lastName = 'An' . substr(sha1(rand()), 0, 7);
+ $name = $this->_testCreateUser($firstName, $lastName);
+ $this->openCiviPage("admin/synchUser", "reset=1", NULL);
+ $this->clickLink("_qf_CMSUser_next-bottom");
+
+ $this->openCiviPage("admin/setting/preferences/contribute", "reset=1", "deferred_revenue_enabled");
+ $this->check('deferred_revenue_enabled');
+ $this->waitForElementPresent('default_invoice_page');
+ $this->select('default_invoice_page', "value=$pageId");
+ $this->clickLink("_qf_Contribute_next-bottom");
+
+ $this->webtestLogin($name, "Test12345");
+ $this->_testContributeWithPayLater($pageId, $firstName);
+
+ $this->_testContributeWithPayNow($firstName);
+
+ $this->openCiviPage("user", "reset=1");
+ $this->assertFalse($this->isTextPresent("Pay Now"));
+
+ $this->webtestLogin();
+
+ $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id=$pageId", 'price_set_id');
+ $this->select('price_set_id', "value=9");
+ $this->clickLink("_qf_Amount_upload_done-bottom");
+
+ $this->webtestLogin($name, "Test12345");
+
+ $this->_testContributeWithPayLater($pageId, $firstName, TRUE);
+
+ $this->_testContributeWithPayNow($firstName, TRUE);
+
+ $this->openCiviPage("user", "reset=1");
+ $this->assertFalse($this->isTextPresent("Pay Now"));
+
+ // Type search name in autocomplete.
+ $this->webtestLogin();
+ $this->openCiviPage("civicrm/dashboard", "reset=1", 'sort_name_navigation');
+ $this->click('sort_name_navigation');
+ $this->type('css=input#sort_name_navigation', $firstName);
+ $this->typeKeys('css=input#sort_name_navigation', $firstName);
+ $this->waitForElementPresent("css=ul.ui-autocomplete li");
+ $this->clickLink("css=ul.ui-autocomplete li", 'tab_contribute');
+
+ $this->click('css=li#tab_contribute a');
+ $this->waitForElementPresent('link=Record Contribution (Check, Cash, EFT ...)');
+
+ $amountValues = array(
+ 1 => '$ 588.50',
+ 2 => '$ 98.50',
+ );
+ foreach($amountValues as $row => $amount) {
+ $this->clickLink("xpath=//table[@class='selector row-highlight']/tbody/tr[{$row}]/td[8]/span//a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE);
+
+ // View Contribution Record and test for expected values
+ $expected = array(
+ 'From' => "{$firstName} {$lastName}",
+ 'Financial Type' => $financialType,
+ 'Fee Amount' => '$ 1.50',
+ 'Net Amount' => $amount,
+ 'Received Into' => 'Payment Processor Account',
+ 'Payment Method' => 'Credit Card (Test Processor)',
+ 'Contribution Status' => 'Completed',
+ );
+ $this->webtestVerifyTabularData($expected);
+
+ $this->clickAjaxLink("xpath=//span[text()='Done']");
+ }
+ }
+
+ public function _testContributeWithPayNow($firstName, $priceSet = FALSE) {
+ //user dashboard
+ $this->openCiviPage("user", "reset=1");
+ $this->waitForElementPresent("xpath=//a/span[contains(text(), 'Pay Now')]");
+ $this->clickLink("xpath=//a/span[contains(text(), 'Pay Now')]");
+
+ if (empty($priceSet)) {
+ $this->waitForElementPresent("total_amount");
+ $this->assertTrue($this->isElementPresent("xpath=//input[@id='total_amount'][@readonly=1][@value=100]"));
+ }
+ else {
+ $this->assertElementContainsText("xpath=//div[@class='header-dark']", "Contribution Information");
+ $this->assertElementContainsText("xpath=//div[@class='crm-section no-label total_amount-section']", "Contribution Total: $ 590.00");
+ }
+
+ $this->assertFalse($this->isElementPresent("priceset"));
+ $this->assertFalse($this->isElementPresent("xpath=//div[@class='crm-public-form-item crm-section is_pledge-section']"));
+ $this->assertFalse($this->isElementPresent("xpath=//div[@class='crm-public-form-item crm-section premium_block-section']"));
+ $this->assertFalse($this->isElementPresent("xpath=//div[@class='crm-public-form-item crm-group custom_pre_profile-group']"));
+ $this->assertFalse($this->isElementPresent("xpath=//input[@id=email-5]"));
+ $this->assertTrue($this->isElementPresent("xpath=//input[@name='payment_processor_id'][@value=0][@style='display: none;']"));
+ $this->click("xpath=//input[@name='payment_processor_id'][@value=1]");
+ $this->waitForAjaxContent();
+
+ $this->webtestAddCreditCardDetails();
+ $this->webtestAddBillingDetails();
+ $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
+
+ $this->clickLink("_qf_Confirm_next-bottom");
+ $firstName = strtolower($firstName);
+ $emailText = "An email receipt has also been sent to {$firstName}@example.com";
+ $this->waitForTextPresent($emailText);
+
+ }
+
+ public function _testContributeWithPayLater($pageId, $firstName, $priceSet = FALSE) {
+ $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$pageId", NULL);
+ $this->waitForElementPresent("email-5");
+
+ $this->type("email-5", $firstName . "@example.com");
+
+ if (empty($priceSet)) {
+ $this->click("xpath=//div[@class='crm-section other_amount-section']//div[2]/input");
+ $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", 100);
+ $this->typeKeys("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", 100);
+ }
+ else {
+ $this->type("xpath=//input[@class='four crm-form-text required']", "1");
+ $this->click("xpath=//input[@class='crm-form-radio']");
+ $this->click("xpath=//input[@class='crm-form-checkbox']");
+ }
+
+ $this->waitForTextPresent("Payment Method");
+ $payLaterText = "I will send payment by check";
+ $this->click("xpath=//label[text() = '{$payLaterText}']/preceding-sibling::input[1]");
+
+ $this->waitForAjaxContent();
+ $this->clickLink("_qf_Main_upload-bottom");
+ $this->waitForElementPresent("xpath=//div[@class='bold pay_later_receipt-section']");
+
+ $payLaterInstructionsText = "I will send payment by check";
+ $this->assertElementContainsText("xpath=//div[@class='bold pay_later_receipt-section']/p", $payLaterInstructionsText);
+ $this->clickLink("_qf_Confirm_next-bottom");
+
+ $this->waitForElementPresent("xpath=//div[@class='help']/div/p");
+ $this->assertElementContainsText("xpath=//div[@class='help']/div/p", $payLaterInstructionsText);
+ }
+
+ public function _testCreateUser($firstName, $lastName) {
+ $this->open($this->sboxPath . "admin/people/create");
+
+ $this->waitForElementPresent("edit-submit");
+
+ $name = "TestUser" . substr(sha1(rand()), 0, 4);
+ $this->type("edit-name", $name);
+
+ $emailId = substr(sha1(rand()), 0, 7) . '@web.com';
+ $this->type("edit-mail", $emailId);
+ $this->type("edit-pass-pass1", "Test12345");
+ $this->type("edit-pass-pass2", "Test12345");
+
+ $this->type("first_name", $firstName);
+ $this->type("last_name", $lastName);
+
+ //Address Details
+ $this->type("street_address-1", "902C El Camino Way SW");
+ $this->type("city-1", "Dumfries");
+ $this->type("postal_code-1", "1234");
+ $this->select("state_province-1", "value=1019");
+
+ $this->click("edit-submit");
+ $this->waitForPageToLoad($this->getTimeoutMsec());
+ return $name;
+ }
+
}