From d5397f2ff02e62b81d669593f2d9291b884351cc Mon Sep 17 00:00:00 2001 From: Pratik Joshi Date: Wed, 12 Mar 2014 06:59:30 +0530 Subject: [PATCH] CRM-13973-qa : consists of fix for most of the points mentioned in #58122 --- CRM/Contribute/Form/AbstractEditPayment.php | 12 ++++++++++++ CRM/Contribute/Form/AdditionalPayment.php | 4 ++-- CRM/Contribute/Form/Contribution.php | 3 +++ CRM/Event/BAO/Participant.php | 5 +++++ CRM/Event/Form/ParticipantFeeSelection.php | 4 ++-- CRM/Price/BAO/LineItem.php | 7 ++++++- templates/CRM/Event/Form/Participant.tpl | 7 +++++++ templates/CRM/Event/Form/ParticipantFeeSelection.tpl | 8 +++++--- 8 files changed, 42 insertions(+), 8 deletions(-) diff --git a/CRM/Contribute/Form/AbstractEditPayment.php b/CRM/Contribute/Form/AbstractEditPayment.php index 0fa04cdfdd..1f57d47729 100644 --- a/CRM/Contribute/Form/AbstractEditPayment.php +++ b/CRM/Contribute/Form/AbstractEditPayment.php @@ -156,6 +156,18 @@ class CRM_Contribute_Form_AbstractEditPayment extends CRM_Core_Form { protected $_formType; protected $_cdType; + public function showRecordLinkMesssage($id) { + $statusId = CRM_Core_DAO::getFieldValue('CRM_Contribute_BAO_Contribution', $id, 'contribution_status_id'); + if (CRM_Contribute_PseudoConstant::contributionStatus($statusId, 'name') == 'Partially paid') { + if ($pid = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantPayment', $id, 'participant_id', 'contribution_id')) { + $recordPaymentLink = CRM_Utils_System::url('civicrm/payment', + "reset=1&id={$pid}&cid={$this->_contactID}&action=add&component=event" + ); + CRM_Core_Session::setStatus(ts('Please use the Record Payment form if you have received an additional payment for this Partially paid contribution record.', array(1 => $recordPaymentLink)), ts('Notice'), 'alert'); + } + } + } + public function buildValuesAndAssignOnline_Note_Type($id, &$values) { $ids = array(); $params = array('id' => $id); diff --git a/CRM/Contribute/Form/AdditionalPayment.php b/CRM/Contribute/Form/AdditionalPayment.php index d98f4a51d9..c4b20c13ce 100644 --- a/CRM/Contribute/Form/AdditionalPayment.php +++ b/CRM/Contribute/Form/AdditionalPayment.php @@ -112,7 +112,7 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract $this->_fromEmails = CRM_Event_BAO_Event::getFromEmailIds($eventId); $paymentInfo = CRM_Core_BAO_FinancialTrxn::getPartialPaymentWithType($this->_id, $enitityType); - $paymentDetails = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_id, $this->_component); + $paymentDetails = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_id, $this->_component, FALSE, TRUE); $this->_amtPaid = $paymentDetails['paid']; $this->_amtTotal = $paymentDetails['total']; @@ -707,4 +707,4 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract list($mailSent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams); return $mailSent; } -} \ No newline at end of file +} diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index 43dc24e875..983195b03d 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -228,6 +228,9 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $this->preProcessPledge(); } + if ($this->_id) { + $this->showRecordLinkMesssage($this->_id); + } $this->_values = array(); // current contribution id diff --git a/CRM/Event/BAO/Participant.php b/CRM/Event/BAO/Participant.php index 4795ef0a01..cd76f2d218 100644 --- a/CRM/Event/BAO/Participant.php +++ b/CRM/Event/BAO/Participant.php @@ -1835,6 +1835,11 @@ WHERE (li.entity_table = 'civicrm_participant' AND li.entity_id = {$participantI $updatedAmount = $params['amount']; self::recordAdjustedAmt($updatedAmount, $paidAmount, $contributionId); + // update participant fee_amount column + $partUpdateFeeAmt['id'] = $participantId; + $partUpdateFeeAmt['fee_amount'] = $params['amount']; + self::add($partUpdateFeeAmt); + //activity creation self::addActivityForSelection($participantId, 'Change Registration'); } diff --git a/CRM/Event/Form/ParticipantFeeSelection.php b/CRM/Event/Form/ParticipantFeeSelection.php index caa45e16e7..10d9d22d09 100644 --- a/CRM/Event/Form/ParticipantFeeSelection.php +++ b/CRM/Event/Form/ParticipantFeeSelection.php @@ -237,7 +237,7 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form { } function emailReceipt(&$params) { - $updatedLineItem = CRM_Price_BAO_LineItem::getLineItems($this->_participantId, 'participant'); + $updatedLineItem = CRM_Price_BAO_LineItem::getLineItems($this->_participantId, 'participant', NULL, FALSE); $lineItem = array(); if ($updatedLineItem) { $lineItem[] = $updatedLineItem; @@ -346,4 +346,4 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form { list($mailSent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams); return $mailSent; } -} \ No newline at end of file +} diff --git a/CRM/Price/BAO/LineItem.php b/CRM/Price/BAO/LineItem.php index 3b2fe77753..5fa1d3088d 100644 --- a/CRM/Price/BAO/LineItem.php +++ b/CRM/Price/BAO/LineItem.php @@ -111,7 +111,7 @@ AND li.entity_id = {$entityId})"; * * @return array of line items */ - static function getLineItems($entityId, $entity = 'participant', $isQuick = NULL) { + static function getLineItems($entityId, $entity = 'participant', $isQuick = NULL , $isQtyZero = TRUE) { $selectClause = $whereClause = $fromClause = NULL; $selectClause = " SELECT li.id, @@ -141,6 +141,11 @@ AND li.entity_id = {$entityId})"; $fromClause .= " LEFT JOIN civicrm_price_set cps on cps.id = pf.price_set_id "; $whereClause .= " and cps.is_quick_config = 0"; } + + if (!$isQtyZero) { + $whereClause .= " and li.qty != 0"; + } + $lineItems = array(); if (!$entityId || !$entity || !$fromClause) { diff --git a/templates/CRM/Event/Form/Participant.tpl b/templates/CRM/Event/Form/Participant.tpl index 0940a0758f..92d228ef77 100644 --- a/templates/CRM/Event/Form/Participant.tpl +++ b/templates/CRM/Event/Form/Participant.tpl @@ -167,6 +167,7 @@ {/literal} {/if} + {include file="CRM/Event/Form/EventFees.tpl"} {* Ajax callback for custom data snippet *} @@ -406,6 +407,12 @@ {literal} var eventId = $('#event_id').val(); + {/literal}{if $action eq 2}{literal} + if (typeof eventId == 'undefined') { + var eventId = $('[name=event_id]').val(); + } + {/literal}{/if}{literal} + if (eventId) { dataUrl += '&eventId=' + eventId; } diff --git a/templates/CRM/Event/Form/ParticipantFeeSelection.tpl b/templates/CRM/Event/Form/ParticipantFeeSelection.tpl index ad48babf26..12f61d243f 100644 --- a/templates/CRM/Event/Form/ParticipantFeeSelection.tpl +++ b/templates/CRM/Event/Form/ParticipantFeeSelection.tpl @@ -193,13 +193,15 @@ cj(function(){