From b17ee3eee6a3b28c343db42c65a44c8a507ffa6c Mon Sep 17 00:00:00 2001 From: Pratik Joshi Date: Fri, 17 Jan 2014 10:27:53 +0530 Subject: [PATCH] CRM-13973 : client side behavior improvement --- CRM/Event/Form/ParticipantFeeSelection.php | 4 ++ .../Event/Form/ParticipantFeeSelection.tpl | 70 +++++++++++++------ 2 files changed, 51 insertions(+), 23 deletions(-) diff --git a/CRM/Event/Form/ParticipantFeeSelection.php b/CRM/Event/Form/ParticipantFeeSelection.php index 467bcdd3d4..4928b7e6f7 100644 --- a/CRM/Event/Form/ParticipantFeeSelection.php +++ b/CRM/Event/Form/ParticipantFeeSelection.php @@ -60,6 +60,8 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form { public $_participantId = NULL; + protected $_participantStatus = NULL; + public function preProcess() { $this->_participantId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE); $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE); @@ -76,6 +78,7 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form { $this->assign('displayName', $this->_contributorDisplayName); $this->assign('email', $this->_contributorEmail); + $this->_participantStatus = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $this->_participantId, 'status_id'); //set the payment mode - _mode property is defined in parent class $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this); @@ -121,6 +124,7 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form { CRM_Core_Resources::singleton()->addSetting(array( 'partiallyPaid' => array_search('Partially paid', $statuses), 'pendingRefund' => array_search('Pending refund', $statuses), + 'participantStatus' => $this->_participantStatus )); $config = CRM_Core_Config::singleton(); diff --git a/templates/CRM/Event/Form/ParticipantFeeSelection.tpl b/templates/CRM/Event/Form/ParticipantFeeSelection.tpl index 8e13facf3d..97ca631c9a 100644 --- a/templates/CRM/Event/Form/ParticipantFeeSelection.tpl +++ b/templates/CRM/Event/Form/ParticipantFeeSelection.tpl @@ -32,25 +32,49 @@ function display(totalfee) { totalfee = Math.round(totalfee*100)/100; // note : some variables used used here are global variables defined inside Calculate.tpl var totalEventFee = formatMoney( totalfee, 2, seperator, thousandMarker); - document.getElementById('pricevalue').innerHTML = ""+symbol+" "+totalEventFee; + cj('#pricevalue').html(""+symbol+" "+totalEventFee); scriptfee = totalfee; scriptarray = price; - cj('#total_amount').val( totalfee ); + cj('#total_amount').val(totalfee); ( totalfee < 0 ) ? cj('table#pricelabel').addClass('disabled') : cj('table#pricelabel').removeClass('disabled'); // populate the balance amount div - populatebalanceFee(); + // change the status selections according to updated selections + populatebalanceFee(totalEventFee); } -function populatebalanceFee() { +function populatebalanceFee(updatedAmt) { // calculate the balance amount using total paid and updated amount - var updatedFeeUnFormatted = cj('#pricevalue').text(); - var updatedAmt = parseFloat(updatedFeeUnFormatted.replace(/[^0-9-.]/g, '')); var balanceAmt = updatedAmt - CRM.feePaid; + // change the status selections according to updated selections + if (balanceAmt > 0) { + cj('#status_id').val(CRM.partiallyPaid); + } + else if(balanceAmt < 0) { + cj('#status_id').val(CRM.pendingRefund); + } + else if(balanceAmt == 0) { + cj('#status_id').val(CRM.participantStatus); + } + balanceAmt = formatMoney(balanceAmt, 2, seperator, thousandMarker); cj('#balance-fee').text(symbol+" "+balanceAmt); } +cj(function(){ + var updatedFeeUnFormatted = cj('#pricevalue').text(); + var updatedAmt = parseFloat(updatedFeeUnFormatted.replace(/[^0-9-.]/g, '')); + var balanceAmt = updatedAmt - CRM.feePaid; + + // change the status selections according to updated selections + if (balanceAmt > 0) { + cj('#status_id').val(CRM.partiallyPaid); + } + else if(balanceAmt < 0) { + cj('#status_id').val(CRM.pendingRefund); + } +}); + {/literal}

Change Registration Selections

@@ -157,26 +181,26 @@ function populatebalanceFee() { {/literal} \ No newline at end of file -- 2.25.1