From: Pratik Joshi Date: Tue, 14 Jan 2014 07:02:43 +0000 (+0530) Subject: CRM-13965 : expose 'record payment' link X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=fbc544162de35f3feba894ca45e23dc2c843ddd9;p=civicrm-core.git CRM-13965 : expose 'record payment' link --- diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index 8aa7a382b4..bf7a833219 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -195,6 +195,8 @@ class CRM_Event_Form_Participant extends CRM_Contact_Form_Task { */ public $_participantRoleIds = array(); + + protected $_feePaymenBlock = NULL; /** * Function to set variables up before form is built * @@ -232,13 +234,13 @@ class CRM_Event_Form_Participant extends CRM_Contact_Form_Task { if ($this->_id) { $this->assign('participantId', $this->_id); - $feePaymentBlock = FALSE; + $this->_feePaymenBlock = FALSE; $statusId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $this->_id, 'status_id', 'id'); if (in_array($participantStatuses[$statusId], array('Partially paid', 'Pending refund'))) { - $feePaymentBlock = TRUE; + $this->_feePaymenBlock = TRUE; } - $this->assign('feePaymentBlock', $feePaymentBlock); + $this->assign('feePaymentBlock', $this->_feePaymenBlock); $this->_paymentId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'id', 'participant_id' ); @@ -677,7 +679,7 @@ SELECT civicrm_custom_group.name as name, * @access public */ public function buildQuickForm() { - if ($this->_action == CRM_Core_Action::UPDATE) { + if ($this->_feePaymenBlock) { CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); } if ($this->_showFeeBlock) { @@ -1174,8 +1176,11 @@ loadCampaign( {$this->_eID}, {$eventCampaigns} ); } $this->_params = $params; - $amountOwed = $params['amount']; - unset($params['amount']); + $amountOwed = NULL; + if (isset($params['amount'])) { + $amountOwed = $params['amount']; + unset($params['amount']); + } $params['register_date'] = CRM_Utils_Date::processDate($params['register_date'], $params['register_date_time']); $params['receive_date'] = CRM_Utils_Date::processDate(CRM_Utils_Array::value('receive_date', $params)); $params['contact_id'] = $this->_contactId; diff --git a/CRM/Event/Form/ParticipantView.php b/CRM/Event/Form/ParticipantView.php index f1ebda0e9a..41dda2e3f3 100644 --- a/CRM/Event/Form/ParticipantView.php +++ b/CRM/Event/Form/ParticipantView.php @@ -45,6 +45,7 @@ class CRM_Event_Form_ParticipantView extends CRM_Core_Form { * @return void * @access public */ + protected $_feePaymentBlock = NULL; public function preProcess() { $values = $ids = array(); $participantID = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE); @@ -66,6 +67,16 @@ class CRM_Event_Form_ParticipantView extends CRM_Core_Form { CRM_Event_BAO_Participant::fixEventLevel($values[$participantID]['fee_level']); } + $this->assign('contactId', $contactID); + $this->assign('participantId', $participantID); + $this->_feePaymentBlock = FALSE; + $statusId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $participantID, 'status_id', 'id'); + $participantStatuses = CRM_Event_PseudoConstant::participantStatus(); + if (in_array($participantStatuses[$statusId], array('Partially paid', 'Pending refund'))) { + $this->_feePaymentBlock = TRUE; + } + $this->assign('feePaymentBlock', $this->_feePaymentBlock); + if ($values[$participantID]['is_test']) { $values[$participantID]['status'] .= ' (test) '; } @@ -197,6 +208,9 @@ class CRM_Event_Form_ParticipantView extends CRM_Core_Form { * @access public */ public function buildQuickForm() { + if ($this->_feePaymentBlock) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } $this->addButtons(array( array( 'type' => 'cancel', diff --git a/CRM/Event/Selector/Search.php b/CRM/Event/Selector/Search.php index 4961d18e1b..30f036211d 100644 --- a/CRM/Event/Selector/Search.php +++ b/CRM/Event/Selector/Search.php @@ -360,8 +360,18 @@ class CRM_Event_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co } $row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->participant_id; + $links = self::links($this->_key, $this->_context, $this->_compContext); + + if ($statusTypes[$row['participant_status_id']] == 'Partially paid') { + $links[CRM_Core_Action::ADD] = array( + 'name' => ts('Record Payment'), + 'url' => 'civicrm/payment/add', + 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=add&component=event', + 'title' => ts('Record Payment'), + ); + } - $row['action'] = CRM_Core_Action::formLink(self::links($this->_key, $this->_context, $this->_compContext), + $row['action'] = CRM_Core_Action::formLink($links, $mask, array( 'id' => $result->participant_id, diff --git a/templates/CRM/Event/Form/ParticipantView.tpl b/templates/CRM/Event/Form/ParticipantView.tpl index f663fbdc0b..5b57e56d5e 100644 --- a/templates/CRM/Event/Form/ParticipantView.tpl +++ b/templates/CRM/Event/Form/ParticipantView.tpl @@ -99,6 +99,12 @@ {ts}Event Source{/ts}{$source}  {/if} + {if $participantId and $feePaymentBlock} + + {ts}Fees{/ts} + + + {/if} {if $fee_level} {if $lineItem} @@ -116,6 +122,9 @@ {/if} {/foreach} + {if $participantId and $feePaymentBlock} + {include file="CRM/Contribute/Page/PaymentInfo.tpl" show='event-payment'} + {/if} {include file="CRM/Custom/Page/CustomDataView.tpl"} {if $accessContribution and $rows.0.contribution_id} {include file="CRM/Contribute/Form/Selector.tpl" context="Search"}