From 81f3d0177a2a7dd6f3699a4710c37037fcec8cab Mon Sep 17 00:00:00 2001 From: Pratik Joshi Date: Tue, 4 Mar 2014 02:38:35 +0530 Subject: [PATCH] CRM-13964-qa : includes 1st QA cycle fixes mentioned in issue comment --- CRM/Contribute/Form/AdditionalPayment.php | 32 +++++++++++++++-- CRM/Contribute/Page/PaymentInfo.php | 4 --- CRM/Contribute/xml/Menu/Contribute.xml | 2 +- CRM/Event/Form/Participant.php | 24 ++++++++++--- CRM/Event/Selector/Search.php | 4 +-- .../civicrm_msg_template.tpl | 1 + .../CRM/Contribute/Form/AdditionalPayment.tpl | 35 ++++++++++++++++++- templates/CRM/Contribute/Page/PaymentInfo.tpl | 34 ++---------------- templates/CRM/Event/Form/Participant.tpl | 15 ++++---- .../event_offline_receipt_html.tpl | 16 ++++++++- .../event_offline_receipt_text.tpl | 8 +++-- 11 files changed, 119 insertions(+), 56 deletions(-) diff --git a/CRM/Contribute/Form/AdditionalPayment.php b/CRM/Contribute/Form/AdditionalPayment.php index 6fb22dfee1..99cd849981 100644 --- a/CRM/Contribute/Form/AdditionalPayment.php +++ b/CRM/Contribute/Form/AdditionalPayment.php @@ -74,11 +74,26 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract protected $_fromEmails = NULL; + protected $_view = NULL; + + public $_action = NULL; + public function preProcess() { $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE); $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE); $this->_component = CRM_Utils_Request::retrieve('component', 'String', $this, TRUE); + $this->_view = CRM_Utils_Request::retrieve('view', 'String', $this, FALSE); + $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE); + $this->assign('component', $this->_component); + $this->assign('id', $this->_id); + if ($this->_view == 'transaction' && ($this->_action & CRM_Core_Action::BROWSE)) { + $paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_id, $this->_component, TRUE); + $transactionRows = $paymentInfo['transaction']; + $this->assign('transaction', TRUE); + $this->assign('rows', $transactionRows); + return; + } $this->_fromEmails = CRM_Core_BAO_Email::getFromEmail(); $this->_formType = CRM_Utils_Array::value('formType', $_GET); @@ -126,8 +141,6 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract $this->assign('contributionMode', $this->_mode); $this->assign('contactId', $this->_contactId); - $this->assign('component', $this->_component); - $this->assign('id', $this->_id); $this->assign('paymentType', $this->_paymentType); $this->assign('paymentAmt', abs($paymentAmt)); @@ -140,6 +153,9 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract } public function setDefaultValues() { + if ($this->_view == 'transaction' && ($this->_action & CRM_Core_Action::BROWSE)) { + return; + } if ($this->_mode) { $defaults = $this->_values; @@ -165,6 +181,18 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract } public function buildQuickForm() { + if ($this->_view == 'transaction' && ($this->_action & CRM_Core_Action::BROWSE)) { + $this->addButtons(array( + array( + 'type' => 'cancel', + 'name' => ts('Done'), + 'spacing' => '         ', + 'isDefault' => TRUE, + ), + ) + ); + return; + } $ccPane = NULL; if ($this->_mode) { if (CRM_Utils_Array::value('payment_type', $this->_processors) & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT diff --git a/CRM/Contribute/Page/PaymentInfo.php b/CRM/Contribute/Page/PaymentInfo.php index ccf502e332..fe8ce148aa 100644 --- a/CRM/Contribute/Page/PaymentInfo.php +++ b/CRM/Contribute/Page/PaymentInfo.php @@ -52,10 +52,6 @@ class CRM_Contribute_Page_PaymentInfo extends CRM_Core_Page { if ($this->_context == 'payment_info') { $this->assign('paymentInfo', $paymentInfo); } - else { - $rows = CRM_Utils_Array::value('transaction', $paymentInfo); - $this->assign('rows', $rows); - } } function run() { diff --git a/CRM/Contribute/xml/Menu/Contribute.xml b/CRM/Contribute/xml/Menu/Contribute.xml index d95d5ad9b4..522f6ca56b 100644 --- a/CRM/Contribute/xml/Menu/Contribute.xml +++ b/CRM/Contribute/xml/Menu/Contribute.xml @@ -122,7 +122,7 @@ 580 - civicrm/payment/add + civicrm/payment New Payment CRM_Contribute_Form_AdditionalPayment action=add diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index d7424165a9..0d474fad71 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -452,7 +452,6 @@ class CRM_Event_Form_Participant extends CRM_Contact_Form_Task { } $this->set('onlinePendingContributionId', $this->_onlinePendingContributionId); $roleIds = CRM_Event_PseudoConstant::participantRole(); - if (!empty($roleIds)) { $query = " SELECT civicrm_custom_group.name as name, @@ -669,7 +668,7 @@ SELECT civicrm_custom_group.name as name, CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); $participantStatuses = CRM_Event_PseudoConstant::participantStatus(); $partiallyPaidStatusId = array_search('Partially paid', $participantStatuses); - CRM_Core_Resources::singleton()->addSetting(array('partiallyPaidStatusId' => $partiallyPaidStatusId)); + $this->assign('partiallyPaidStatusId', $partiallyPaidStatusId); if ($this->_showFeeBlock) { return CRM_Event_Form_EventFees::buildQuickForm($this); @@ -842,7 +841,20 @@ SELECT civicrm_custom_group.name as name, $this->assign('notificationStatusIds', $notificationStatusIds); $this->_participantStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label'); - $this->addSelect('status_id', $checkCancelledJs, TRUE); + $participantStatuses = $this->addSelect('status_id', $checkCancelledJs, TRUE); + $enableCart = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, + 'enable_cart' + ); + $pendingInCartStatusId = CRM_Utils_Array::key( "Pending in cart" , $this->_participantStatuses ); + if (!$enableCart) { + $statusOptions = & $participantStatuses->_options; + foreach($statusOptions as $key =>$option){ + $status_id = $option['attr']['value']; + if ($status_id == $pendingInCartStatusId) { + unset($statusOptions[$key]); + } + } + } $this->addElement('checkbox', 'is_notify', ts('Send Notification'), NULL); @@ -1538,7 +1550,11 @@ SELECT civicrm_custom_group.name as name, } $this->assign('totalAmount', $contributionParams['total_amount']); - + if (isset($contributionParams['partial_payment_total'])) { + // balance amount + $balanceAmount = $contributionParams['partial_payment_total'] - $contributionParams['partial_amount_pay']; + $this->assign('balanceAmount', $balanceAmount ); + } $this->assign('isPrimary', 1); $this->assign('checkNumber', CRM_Utils_Array::value('check_number', $params)); } diff --git a/CRM/Event/Selector/Search.php b/CRM/Event/Selector/Search.php index 5358eec110..b72be682fa 100644 --- a/CRM/Event/Selector/Search.php +++ b/CRM/Event/Selector/Search.php @@ -365,7 +365,7 @@ class CRM_Event_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co if ($statusTypes[$row['participant_status_id']] == 'Partially paid') { $links[CRM_Core_Action::ADD] = array( 'name' => ts('Record Payment'), - 'url' => 'civicrm/payment/add', + 'url' => 'civicrm/payment', 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=add&component=event', 'title' => ts('Record Payment'), ); @@ -374,7 +374,7 @@ class CRM_Event_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co if ($statusTypes[$row['participant_status_id']] == 'Pending refund') { $links[CRM_Core_Action::ADD] = array( 'name' => ts('Record Refund'), - 'url' => 'civicrm/payment/add', + 'url' => 'civicrm/payment', 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=add&component=event', 'title' => ts('Record Refund'), ); diff --git a/CRM/Upgrade/4.5.alpha1.msg_template/civicrm_msg_template.tpl b/CRM/Upgrade/4.5.alpha1.msg_template/civicrm_msg_template.tpl index d46a279aa4..07553db60b 100644 --- a/CRM/Upgrade/4.5.alpha1.msg_template/civicrm_msg_template.tpl +++ b/CRM/Upgrade/4.5.alpha1.msg_template/civicrm_msg_template.tpl @@ -15,6 +15,7 @@ UPDATE civicrm_msg_template SET msg_{$tpl.type} = '{$content|escape:"quotes"}' WHERE workflow_id = @workflow_id AND (is_reserved = 1 OR (is_default = 1 AND msg_{$tpl.type} = @content)); {/foreach} +{php} $ovNames = array( 'contribution' => array( 'payment_or_refund_notification' => ts('Additional Payment Receipt or Refund Notification', array('escape' => 'sql')), diff --git a/templates/CRM/Contribute/Form/AdditionalPayment.tpl b/templates/CRM/Contribute/Form/AdditionalPayment.tpl index d141b9512a..fc97db16c6 100644 --- a/templates/CRM/Contribute/Form/AdditionalPayment.tpl +++ b/templates/CRM/Contribute/Form/AdditionalPayment.tpl @@ -23,7 +23,40 @@ | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ *} -{if $formType} +{if $transaction} +
+ {include file="CRM/common/formButtons.tpl"} +
+ {if !empty($rows)} + + + + + + + + + + {foreach from=$rows item=row} + + + + + + + + + {/foreach} +
{ts}Amount{/ts}{ts}Type{/ts}{ts}Paid By{/ts}{ts}Received{/ts}{ts}Transaction ID{/ts}{ts}Status{/ts}
{$row.total_amount|crmMoney}{$row.financial_type}{$row.payment_instrument}{$row.receive_date|crmDate}{$row.trxn_id}{$row.status}
+ {else} + {if $component eq 'event'} + {assign var='entity' value='participant'} + {else} + {assign var='entity' value=$component} + {/if} + {ts 1=$entity}No additional payments found for this %1 record{/ts} + {/if} +{elseif $formType} {include file="CRM/Contribute/Form/AdditionalInfo/$formType.tpl"} {else} diff --git a/templates/CRM/Contribute/Page/PaymentInfo.tpl b/templates/CRM/Contribute/Page/PaymentInfo.tpl index d770cfe7ce..c388efeab1 100644 --- a/templates/CRM/Contribute/Page/PaymentInfo.tpl +++ b/templates/CRM/Contribute/Page/PaymentInfo.tpl @@ -54,7 +54,7 @@ cj(function($){ @@ -66,36 +66,6 @@ cj(function($){ {elseif $paymentInfo.balance < 0} {assign var=paymentButtonName value='Record Refund'} {/if} -
{ts}{$paymentButtonName}{/ts}
+
{ts}{$paymentButtonName}{/ts}
{/if} -{elseif $context eq 'transaction'} - {if !empty($rows)} -
{$paymentInfo.total|crmMoney} {if $paymentInfo.paid > 0} - {$paymentInfo.paid|crmMoney}
>> view payments
+ {$paymentInfo.paid|crmMoney}
>> view payments
{/if}
{$paymentInfo.balance|crmMoney}
- - - - - - - - - {foreach from=$rows item=row} - - - - - - - - - {/foreach} -
{ts}Amount{/ts}{ts}Type{/ts}{ts}Paid By{/ts}{ts}Received{/ts}{ts}Transaction ID{/ts}{ts}Status{/ts}
{$row.total_amount|crmMoney}{$row.financial_type}{$row.payment_instrument}{$row.receive_date|crmDate}{$row.trxn_id}{$row.status}
- {else} - {if $component eq 'event'} - {assign var='entity' value='participant'} - {else} - {assign var='entity' value=$component} - {/if} - {ts 1=$entity}No additional payments found for this %1 record{/ts} - {/if} {/if} \ No newline at end of file diff --git a/templates/CRM/Event/Form/Participant.tpl b/templates/CRM/Event/Form/Participant.tpl index 743c67c455..0068c32b09 100644 --- a/templates/CRM/Event/Form/Participant.tpl +++ b/templates/CRM/Event/Form/Participant.tpl @@ -132,6 +132,7 @@ // change the status to default 'partially paid' for partial payments var feeAmount, userModifiedAmount; + var partiallyPaidStatusId = {/literal}{$partiallyPaidStatusId}{literal}; cj('#total_amount') .focus( @@ -145,19 +146,20 @@ userModifiedAmount = cj(this).val(); userModifiedAmount = parseInt(userModifiedAmount); if (userModifiedAmount < feeAmount) { - cj('#status_id').val(CRM.partiallyPaidStatusId); + cj('#status_id').select2('val', partiallyPaidStatusId); } } ); - cj('#Participant').submit( + cj('#Participant').on("click",'.validate', function(e) { var userSubmittedStatus = cj('#status_id').val(); var statusLabel = cj('#status_id option:selected').text(); - if (userModifiedAmount < feeAmount && userSubmittedStatus != CRM.partiallyPaidStatusId) { - var result = confirm('Payment amount is less than the amount owed. Expected participant status is \'Partially paid\'. Are you sure you want to set the participant status to ' + statusLabel + '? Click OK to continue, Cancel to change your entries.'); + if (userModifiedAmount < feeAmount && userSubmittedStatus != partiallyPaidStatusId) { + var msg = "{/literal}{ts escape="js" 1="%1"}Payment amount is less than the amount owed. Expected participant status is 'Partially paid'. Are you sure you want to set the participant status to %1? Click OK to continue, Cancel to change your entries.{/ts}{literal}"; + var result = confirm(ts(msg, {1: statusLabel})); if (result == false) { - e.preventDefault(); + return false; } } } @@ -439,14 +441,13 @@ } var roleGroupMapper = {/literal}{$participantRoleIds|@json_encode}{literal}; - function showCustomData( type, subType, subName ) { var dataUrl = {/literal}"{crmURL p=$urlPath h=0 q='snippet=4&type='}"{literal} + type; var roleid = "role_id_"+subType; var loadData = false; if ( document.getElementById( roleid ).checked == true ) { - if ( roleGroupMapper[subType] ) { + if ( typeof roleGroupMapper !== 'undefined' && roleGroupMapper[subType] ) { var splitGroup = roleGroupMapper[subType].split(","); for ( i = 0; i < splitGroup.length; i++ ) { var roleCustomGroupId = splitGroup[i]; diff --git a/xml/templates/message_templates/event_offline_receipt_html.tpl b/xml/templates/message_templates/event_offline_receipt_html.tpl index d26a95bf4c..5dc686c2f4 100644 --- a/xml/templates/message_templates/event_offline_receipt_html.tpl +++ b/xml/templates/message_templates/event_offline_receipt_html.tpl @@ -220,12 +220,26 @@ registration process.{/ts}

{if $isPrimary} + {if $balanceAmount} + + + + + {/if} {if $pricesetFieldsCount }
- {ts}Total Amount{/ts} + {if $balanceAmount} + {ts}Total Paid{/ts} + {else} + {ts}Total Amount{/ts} + {/if} {$totalAmount|crmMoney} {if $hookDiscount.message}({$hookDiscount.message}){/if}
+ {ts}Balance{/ts} + + {$balanceAmount|crmMoney} +
diff --git a/xml/templates/message_templates/event_offline_receipt_text.tpl b/xml/templates/message_templates/event_offline_receipt_text.tpl index 02985ca010..8a51a9e85f 100644 --- a/xml/templates/message_templates/event_offline_receipt_text.tpl +++ b/xml/templates/message_templates/event_offline_receipt_text.tpl @@ -131,9 +131,13 @@ registration process.{/ts} {foreach from=$amount item=amnt key=level}{$amnt.amount|crmMoney} {$amnt.label} {/foreach} {/if} -{if $isPrimary } +{if $isPrimary} + +{if $balanceAmount}{ts}Total Paid{/ts}{else}{ts}Total Amount{/ts}{/if}: {$totalAmount|crmMoney} {if $hookDiscount.message}({$hookDiscount.message}){/if} -{ts}Total Amount{/ts}: {$totalAmount|crmMoney} {if $hookDiscount.message}({$hookDiscount.message}){/if} +{if $balanceAmount} +{ts}Balance{/ts}: {$balanceAmount|crmMoney} +{/if} {if $pricesetFieldsCount } {assign var="count" value= 0} -- 2.25.1