CRM-13965 : expose 'record payment' link
authorPratik Joshi <pratik.joshi@webaccess.co.in>
Tue, 14 Jan 2014 07:02:43 +0000 (12:32 +0530)
committerPratik Joshi <pratik.joshi@webaccess.co.in>
Thu, 16 Jan 2014 01:43:17 +0000 (07:13 +0530)
CRM/Event/Form/Participant.php
CRM/Event/Form/ParticipantView.php
CRM/Event/Selector/Search.php
templates/CRM/Event/Form/ParticipantView.tpl

index 8aa7a382b4047744adc5aada92e0390b4e371846..bf7a833219e15af331ca5329738949e7e3d7d9a6 100644 (file)
@@ -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;
index f1ebda0e9aa6703bfc043849e6b91a40e7fa0924..41dda2e3f3066b302027ecd1dd021cb1fb7c7ecb 100644 (file)
@@ -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',
index 4961d18e1b4a3acd9f59644cefa5ec8ac3e62207..30f036211d962eef340cbfb9c3d391b0ae805081 100644 (file)
@@ -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,
index f663fbdc0bfe2093f479085942df74328b669303..5b57e56d5e79f8fbe9e8438137d8b8e961ff3702 100644 (file)
         <td class="label">{ts}Event Source{/ts}</td><td>{$source}&nbsp;</td>
       </tr>
     {/if}
+    {if $participantId and $feePaymentBlock}
+      <tr>
+        <td class='label'>{ts}Fees{/ts}</td>
+        <td id='payment-info'></td>
+      </tr>
+    {/if}
     {if $fee_level}
         <tr class="crm-event-participantview-form-block-fee_amount">
             {if $lineItem}
       {/if}
     {/foreach}
     </table>
+    {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"}