Skip to content

Commit

Permalink
Merge pull request #10680 from JMAConsulting/CRM-20889
Browse files Browse the repository at this point in the history
CRM-20889 : Toggle check_number field on backoffice form as payment form fields
  • Loading branch information
eileenmcnaughton authored Sep 13, 2017
2 parents 848bd73 + b3453b5 commit db3a540
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 75 deletions.
2 changes: 1 addition & 1 deletion CRM/Contribute/Form/AbstractEditPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ protected function assignPaymentRelatedVariables() {
}
$this->assignProcessors();
$this->assignBillingType();
CRM_Core_Payment_Form::setPaymentFieldsByProcessor($this, $this->_paymentProcessor, FALSE, TRUE, CRM_Utils_Request::retrieve('payment_instrument_id', 'Integer'));
CRM_Core_Payment_Form::setPaymentFieldsByProcessor($this, $this->_paymentProcessor, FALSE, TRUE, CRM_Utils_Request::retrieve('payment_instrument_id', 'Integer', $this));
}
catch (CRM_Core_Exception $e) {
CRM_Core_Error::statusBounce($e->getMessage());
Expand Down
7 changes: 2 additions & 5 deletions CRM/Contribute/Form/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@ public function preProcess() {
return;
}

$this->assign('showCheckNumber', TRUE);

$this->_fromEmails = CRM_Core_BAO_Email::getFromEmail();

if (in_array('CiviPledge', CRM_Core_Config::singleton()->enableComponents) && !$this->_formType) {
Expand Down Expand Up @@ -552,7 +550,8 @@ public function buildQuickForm() {
$paneNames[ts('Premium Information')] = 'Premium';
}

if (CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, TRUE, $this->getDefaultPaymentInstrumentId()) == TRUE) {
$this->payment_instrument_id = CRM_Utils_Array::value('payment_instrument_id', $defaults, $this->getDefaultPaymentInstrumentId());
if (CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, TRUE, $this->payment_instrument_id) == TRUE) {
if (!empty($this->_recurPaymentProcessors)) {
$buildRecurBlock = TRUE;
if ($this->_ppID) {
Expand Down Expand Up @@ -704,7 +703,6 @@ public function buildQuickForm() {
if ($this->_online) {
$this->assign('hideCalender', TRUE);
}
$checkNumber = $this->add('text', 'check_number', ts('Check Number'), $attributes['contribution_check_number']);

$this->addDateTime('receipt_date', ts('Receipt Date'), FALSE, array('formatType' => 'activityDateTime'));
$this->addDateTime('cancel_date', ts('Cancelled / Refunded Date'), FALSE, array('formatType' => 'activityDateTime'));
Expand Down Expand Up @@ -839,7 +837,6 @@ public function buildQuickForm() {
if ($totalAmount) {
$totalAmount->freeze();
}
$checkNumber->freeze();
$paymentInstrument->freeze();
$trxnId->freeze();
$financialType->freeze();
Expand Down
3 changes: 1 addition & 2 deletions CRM/Core/Payment/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ public static function getPaymentTypeName($paymentProcessor) {
* @return string
*/
public static function getPaymentTypeLabel($paymentProcessor) {
$paymentProcessorObject = Civi\Payment\System::singleton()->getByProcessor($paymentProcessor);
return ts(($paymentProcessorObject->getPaymentTypeLabel()) . ' Information');
return ts(($paymentProcessor['object']->getPaymentTypeLabel()) . ' Information');
}

/**
Expand Down
5 changes: 1 addition & 4 deletions CRM/Core/Payment/Manual.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,7 @@ public function getPaymentFormFields() {
return array('credit_card_type', 'pan_truncation');
}
elseif ($paymentInstrument === 'Check') {
// Really we should render check_number here, but we need to review how we edit
// check_numebr since we expose it as editable on the contribution form,
// even though it should only be editable from a transation specific form.
return array();
return array('check_number');
}
return array();
}
Expand Down
16 changes: 0 additions & 16 deletions templates/CRM/Contribute/Form/AdditionalPayment.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,6 @@
<td >{$form.payment_instrument_id.html} {help id="payment_instrument_id"}</td>
</td>
</tr>
{if $showCheckNumber || !$isOnline}
<tr id="checkNumber" class="crm-payment-form-block-check_number">
<td class="label">{$form.check_number.label}</td>
<td>{$form.check_number.html}</td>
</tr>
{/if}
<tr class="crm-payment-form-block-trxn_id">
<td class="label">{$form.trxn_id.label}</td>
<td>{$form.trxn_id.html} {help id="id-trans_id"}</td>
Expand Down Expand Up @@ -174,14 +168,4 @@

</script>
{/literal}
{if !$contributionMode}
{include file="CRM/common/showHideByFieldValue.tpl"
trigger_field_id ="payment_instrument_id"
trigger_value = '4'
target_element_id ="checkNumber"
target_element_type ="table-row"
field_type ="select"
invert = 0
}
{/if}
{/if}
17 changes: 0 additions & 17 deletions templates/CRM/Contribute/Form/Contribution.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,6 @@
<td {$valueStyle}>{$form.payment_instrument_id.html} {help id="payment_instrument_id"}</td>
</td>
</tr>
{if $showCheckNumber || !$isOnline}
<tr id="checkNumber" class="crm-contribution-form-block-check_number">
<td class="label">{$form.check_number.label}</td>
<td>{$form.check_number.html}</td>
</tr>
{/if}
<tr class="crm-contribution-form-block-trxn_id">
<td class="label">{$form.trxn_id.label}</td>
<td {$valueStyle}>{$form.trxn_id.html} {help id="id-trans_id"}</td>
Expand Down Expand Up @@ -497,17 +491,6 @@
{/literal}{/if}
});
</script>
{if !$contributionMode}
{crmAPI var="checkVal" entity="OptionValue" action="getvalue" version="3" option_group_id="payment_instrument" name="Check" return="value"}
{include file="CRM/common/showHideByFieldValue.tpl"
trigger_field_id ="payment_instrument_id"
trigger_value = $checkVal
target_element_id ="checkNumber"
target_element_type ="table-row"
field_type ="select"
invert = 0
}
{/if}
{/if} {* not delete mode if*}
{/if} {* closing of main custom data if *}
Expand Down
16 changes: 3 additions & 13 deletions templates/CRM/Event/Form/EventFees.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
<td>{include file="CRM/common/jcalendar.tpl" elementName=receive_date}</td>
</tr>
<tr class="crm-event-eventfees-form-block-payment_instrument_id"><td class="label">{$form.payment_instrument_id.label}<span class="crm-marker"> *</span></td><td>{$form.payment_instrument_id.html} {help id="payment_instrument_id" file="CRM/Contribute/Page/Tab.hlp"}</td></tr>
<tr id="checkNumber" class="crm-event-eventfees-form-block-check_number"><td class="label">{$form.check_number.label}</td><td>{$form.check_number.html|crmAddClass:six}</td></tr>
{if $showTransactionId }
<tr class="crm-event-eventfees-form-block-trxn_id"><td class="label">{$form.trxn_id.label}</td><td>{$form.trxn_id.html}</td></tr>
{/if}
Expand All @@ -102,7 +101,9 @@

{/if}

{include file='CRM/Core/BillingBlockWrapper.tpl'}
{if $action neq 2}
{include file='CRM/Core/BillingBlockWrapper.tpl'}
{/if}

{if ($email OR $batchEmail) and $outBound_option != 2}
<fieldset id="send_confirmation_receipt"><legend>{if $paid}{ts}Registration Confirmation and Receipt{/ts}{else}{ts}Registration Confirmation{/ts}{/if}</legend>
Expand Down Expand Up @@ -177,17 +178,6 @@
}
{/if}

{if $paid and ($action eq 1 or ( $action eq 2 and !$hasPayment) ) and !$participantMode}
{include file="CRM/common/showHideByFieldValue.tpl"
trigger_field_id ="payment_instrument_id"
trigger_value = '4'
target_element_id ="checkNumber"
target_element_type ="table-row"
field_type ="select"
invert = 0
}
{/if}

{if $context eq 'standalone' and $outBound_option != 2 }
<script type="text/javascript">
{literal}
Expand Down
15 changes: 6 additions & 9 deletions templates/CRM/Member/Form/MembershipCommon.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@
<td class="label">{$form.payment_instrument_id.label}<span class='marker'>*</span></td>
<td>{$form.payment_instrument_id.html} {help id="payment_instrument_id" file="CRM/Contribute/Page/Tab.hlp"}</td>
</tr>
<tr id="checkNumber" class="crm-{$formClass}-form-block-check_number">
<td class="label">{$form.check_number.label}</td>
<td>{$form.check_number.html|crmAddClass:six}</td>
</tr>

{if $action neq 2 }
<tr class="crm-{$formClass}-form-block-trxn_id">
Expand All @@ -55,6 +51,12 @@
<td class="label">{$form.contribution_status_id.label}</td>
<td>{$form.contribution_status_id.html}</td>
</tr>

<tr class="crm-membership-form-block-billing">
<td colspan="2">
{include file='CRM/Core/BillingBlockWrapper.tpl'}
</td>
</tr>
</table>
</fieldset></td></tr>
{/if}
Expand Down Expand Up @@ -106,8 +108,3 @@
<td>{$form.payment_processor_id.html}</td>
</tr>
{/if}
<tr class="crm-membership-form-block-billing">
<td colspan="2">
{include file='CRM/Core/BillingBlockWrapper.tpl'}
</td>
</tr>
8 changes: 0 additions & 8 deletions templates/CRM/Member/Form/MembershipRenewal.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,6 @@
{/if}

{if !$membershipMode}
{include file="CRM/common/showHideByFieldValue.tpl"
trigger_field_id ="payment_instrument_id"
trigger_value = '4'
target_element_id ="checkNumber"
target_element_type ="table-row"
field_type ="select"
invert = 0
}
{include file="CRM/common/showHideByFieldValue.tpl"
trigger_field_id ="send_receipt"
trigger_value =""
Expand Down

0 comments on commit db3a540

Please sign in to comment.