CRM_Core_Form::validateMandatoryFields($self->_fields, $fields, $errors);
- // validate supplied payment instrument values (e.g. credit card number and cvv)
- $payment_processor_id = $self->_params[0]['payment_processor'];
- CRM_Core_Payment_Form::validatePaymentInstrument($payment_processor_id, $self->_params[0], $errors, (!$self->_isBillingAddressRequiredForPayLater ? NULL : 'billing'));
-
+ if (isset($self->_params[0]['payment_processor'])) {
+ // validate supplied payment instrument values (e.g. credit card number and cvv)
+ $payment_processor_id = $self->_params[0]['payment_processor'];
+ CRM_Core_Payment_Form::validatePaymentInstrument($payment_processor_id, $self->_params[0], $errors, (!$self->_isBillingAddressRequiredForPayLater ? NULL : 'billing'));
+ }
if (!empty($errors)) {
return FALSE;
}
*/
public function setDefaultValues() {
$this->_defaults = array();
+ if (!$this->_allowConfirmation && $this->_requireApproval) {
+ $this->_defaults['bypass_payment'] = 1;
+ }
$contactID = $this->getContactID();
CRM_Core_Payment_Form::setDefaultValues($this, $contactID);
}
}
+ if (!$this->_allowConfirmation) {
+ $bypassPayment = TRUE;
+ }
+
//hack to allow group to register w/ waiting
if ((!empty($this->_values['event']['is_multiple_registrations']) ||
$this->_priceSetId
$this->assign('allowGroupOnWaitlist', $allowGroupOnWaitlist);
$this->assign('isAdditionalParticipants', $isAdditionalParticipants);
- //lets get js on two different qf elements.
- $showHidePayfieldName = NULL;
- $showHidePaymentInformation = FALSE;
if ($this->_values['event']['is_monetary']) {
self::buildAmount($this);
}
}
}
- //lets add some qf element to bypass payment validations, CRM-4320
- if ($bypassPayment) {
- $this->addElement('hidden', 'bypass_payment', NULL, array('id' => 'bypass_payment'));
- }
+ $this->addElement('hidden', 'bypass_payment', NULL, array('id' => 'bypass_payment'));
+
$this->assign('bypassPayment', $bypassPayment);
- $this->assign('showHidePaymentInformation', $showHidePaymentInformation);
$userID = $this->getContactID();
}
//don't allow to register w/ waiting if enough spaces available.
- if (!empty($fields['bypass_payment'])) {
+ if (!empty($fields['bypass_payment']) && $self->_allowConfirmation) {
if (!is_numeric($self->_availableRegistrations) ||
(empty($fields['priceSetId']) && CRM_Utils_Array::value('additional_participants', $fields) < $self->_availableRegistrations)
) {
}
}
- {/literal}
- {if $form.is_pay_later and $paymentProcessor.payment_processor_type EQ 'PayPal_Express'}
- showHidePayPalExpressOption();
- {/if}
- {literal}
-
CRM.$(function($) {
enableHonorType();
showRecurHelp();
skipPaymentMethod();
});
- function showHidePayPalExpressOption() {
- if (cj('input[name="is_pay_later"]').is(':checked')) {
- cj("#crm-submit-buttons").show();
- cj("#paypalExpress").hide();
- }
- else {
- cj("#paypalExpress").show();
- cj("#crm-submit-buttons").hide();
- }
- }
-
- function showHidePayment(flag) {
- var payment_options = cj(".payment_options-group");
- var payment_processor = cj("div.payment_processor-section");
- var payment_information = cj("div#payment_information");
- if (flag) {
- payment_options.hide();
- payment_processor.hide();
- payment_information.hide();
- }
- else {
- payment_options.show();
- payment_processor.show();
- payment_information.show();
- }
- }
-
- function skipPaymentMethod() {
- var flag = false;
- cj('.price-set-option-content input[data-amount]').each( function(){
- currentTotal = cj(this).attr('data-amount').replace(/[^\/\d]/g,'');
- if( cj(this).is(':checked') && currentTotal == 0 ) {
- flag = true;
- }
- });
-
- cj('.price-set-option-content input[data-amount]').change( function () {
- if (cj(this).attr('data-amount').replace(/[^\/\d]/g,'') == 0 ) {
- flag = true;
- } else {
- flag = false;
- }
- showHidePayment(flag);
- });
- showHidePayment(flag);
- }
-
CRM.$(function($) {
// highlight price sets
function updatePriceSetHighlight() {
$('#priceset input[type="radio"]').change(updatePriceSetHighlight);
updatePriceSetHighlight();
- function toggleBillingBlockIfFree(){
- var total_amount_tmp = $(this).data('raw-total');
- // Hide billing questions if this is free
- if (total_amount_tmp == 0){
- $("#billing-payment-block").hide();
- $(".payment_options-group").hide();
- }
- else {
- $("#billing-payment-block").show();
- $(".payment_options-group").show();
- }
- }
-
- $('#pricevalue').each(toggleBillingBlockIfFree).on('change', toggleBillingBlockIfFree);
-
// Update pledge contribution amount when pledge checkboxes change
$("input[name^='pledge_amount']").on('change', function() {
var total = 0;
</fieldset>
{/if}
- <div id="billing-payment-block">
- {* If we have a payment processor, load it - otherwise it happens via ajax *}
- {if $paymentProcessorID or $isBillingAddressRequiredForPayLater}
- {include file="CRM/Financial/Form/Payment.tpl" snippet=4}
- {/if}
- </div>
- {include file="CRM/common/paymentBlock.tpl"}
+ {include file='CRM/Core/BillingBlockWrapper.tpl'}
<div class="crm-public-form-item crm-section custom_pre-section">
{include file="CRM/UF/Form/Block.tpl" fields=$customPost}
skipPaymentMethod();
});
- CRM.$(function($) {
- skipPaymentMethod();
- });
-
- // Hides billing and payment options block - but only if a price set is used.
- // Called from display() in Calculate.tpl, depends on display() having been called.
- function skipPaymentMethod() {
- // If we're in quick-config price set, we do not have the pricevalue hidden element, so just return.
- if (cj('#pricevalue').length == 0) {
- return;
- }
- // CRM-15433 Remove currency symbol, decimal separator so we can check for zero numeric total regardless of localization.
- currentTotal = cj('#pricevalue').text().replace(/[^\/\d]/g,'');
- var isMultiple = '{/literal}{$event.is_multiple_registrations}{literal}';
-
- var flag = 1;
- var payment_options = cj(".payment_options-group");
- var payment_processor = cj("div.payment_processor-section");
- var payment_information = cj("div#payment_information");
-
- // Do not hide billing and payment blocks if user is registering additional participants, since we do not know total owing.
- if (isMultiple && cj("#additional_participants").val() && currentTotal == 0) {
- flag = 0;
- }
-
- if (currentTotal == 0 && flag) {
- payment_options.hide();
- payment_processor.hide();
- payment_information.hide();
- // also unset selected payment methods
- cj('input[name="payment_processor_id"]').removeProp('checked');
- }
- else {
- payment_options.show();
- payment_processor.show();
- payment_information.show();
- }
- }
-
- {/literal}
- </script>
-
-{literal}
-<script type="text/javascript">
- {/literal}{if $pcp && $is_honor_roll }pcpAnonymous();
- {/if}{literal}
+ {/literal}
+ {if $pcp && $is_honor_roll }
+ pcpAnonymous();
+ {/if}
+ {literal}
function allowParticipant() {
{/literal}{if $allowGroupOnWaitlist}{literal}
{/literal}{/if}{literal}
}
- {/literal}{if ($bypassPayment) and $paymentProcessor.payment_processor_type EQ 'PayPal_Express'}
- {literal}
- showHidePayPalExpressOption();
- {/literal}{/if}{literal}
-
- function showHidePayPalExpressOption() {
- if (( cj("#bypass_payment").val() == 1 )) {
- cj("#crm-submit-buttons").show();
- cj("#paypalExpress").hide();
- }
- else {
- cj("#paypalExpress").show();
- cj("#crm-submit-buttons").hide();
- }
- }
-
- {/literal}{if ($bypassPayment and $showHidePaymentInformation)}{literal}
- showHidePaymentInfo();
- {/literal} {/if}{literal}
-
- function showHidePaymentInfo() {
- if (( cj("#bypass_payment").val() == 1 )) {
- cj('#billing-payment-block').hide();
- }
- else {
- cj('#billing-payment-block').show();
- }
- }
-
{/literal}{if $allowGroupOnWaitlist}{literal}
allowGroupOnWaitlist(0, 0);
{/literal}{/if}{literal}
if (isrequireApproval) {
cj("#id-waitlist-approval-msg").show();
cj("#id-waitlist-msg").hide();
+ cj("#bypass_payment").val(1);
}
else {
cj("#id-waitlist-approval-msg").hide();
+ cj("#bypass_payment").val(0);
}
//reset value since user don't want or not eligible for waitlist
- cj("#bypass_payment").val(0);
+ skipPaymentMethod();
}
-
- //now call showhide payment info.
- {/literal}
- {if ($bypassPayment) and $paymentProcessor.payment_processor_type EQ 'PayPal_Express'}{literal}
- showHidePayPalExpressOption();
- {/literal}{/if}
- {literal}
-
- {/literal}{if ($bypassPayment) and $showHidePaymentInformation}{literal}
- showHidePaymentInfo();
- {/literal}{/if}{literal}
}
{/literal}
var separator = '{/literal}{$config->monetaryDecimalPoint}{literal}';
var symbol = '{/literal}{$currencySymbol}{literal}';
var optionSep = '|';
-var priceSet = price = Array();
+
cj("#priceset [price]").each(function () {
var elementType = cj(this).attr('type');
totalfee = Math.round(totalfee*100)/100;
var totalEventFee = formatMoney( totalfee, 2, separator, thousandMarker);
document.getElementById('pricevalue').innerHTML = "<b>"+symbol+"</b> "+totalEventFee;
- scriptfee = totalfee;
cj('#total_amount').val( totalfee );
cj('#pricevalue').data('raw-total', totalfee).trigger('change');
( totalfee < 0 ) ? cj('table#pricelabel').addClass('disabled') : cj('table#pricelabel').removeClass('disabled');
if (typeof skipPaymentMethod == 'function') {
+ // Advice to anyone who, like me, feels hatred towards this if construct ... if you remove the if you
+ // get an error on participant 2 of a event that requires approval & permits multiple registrants.
skipPaymentMethod();
}
}
*}
{literal}
<script type="text/javascript">
+ /**
+ * Show or hide payment options.
+ *
+ * @param bool $isHide
+ * Should the block be hidden.
+ */
+ function showHidePayment(isHide) {
+ var payment_options = cj(".payment_options-group");
+ var payment_processor = cj("div.payment_processor-section");
+ var payment_information = cj("div#payment_information");
+ // I've added a hide for billing block. But, actually the issue
+ // might be that the unselecting of the processor should cause it
+ // to be hidden (or removed) in which case it can go from this function.
+ var billing_block = cj("div#billing-payment-block");
+ if (isHide) {
+ payment_options.hide();
+ payment_processor.hide();
+ payment_information.hide();
+ billing_block.hide();
+ // also unset selected payment methods
+ cj('input[name="payment_processor_id"]').removeProp('checked');
+ }
+ else {
+ payment_options.show();
+ payment_processor.show();
+ payment_information.show();
+ billing_block.show();
+ }
+ }
+
+ /**
+ * Hides or shows billing and payment options block depending on whether payment is required.
+ *
+ * In general incomplete orders or $0 orders do not require a payment block.
+ */
+ function skipPaymentMethod() {
+ var isHide = false;
+ var isMultiple = '{/literal}{$event.is_multiple_registrations}{literal}';
+ var alwaysShowFlag = (isMultiple && cj("#additional_participants").val());
+ var alwaysHideFlag = (cj("#bypass_payment").val() == 1);
+ var total_amount_tmp = cj('#pricevalue').data('raw-total');
+ // Hide billing questions if this is free
+ if (!alwaysShowFlag && total_amount_tmp == 0){
+ isHide = true;
+ }
+ else {
+ isHide = false;
+ }
+ if (alwaysHideFlag) {
+ isHide = true;
+ }
+ showHidePayment(isHide);
+ }
+ skipPaymentMethod();
CRM.$(function($) {
function buildPaymentBlock(type) {