CRM-16189, added link on contribution edit form to record payment for pending pay...
authorPradeep Nayak <pradpnayak@gmail.com>
Tue, 20 Sep 2016 10:49:05 +0000 (16:19 +0530)
committerEdsel <edsel.lopez@jmaconsulting.biz>
Mon, 19 Dec 2016 09:28:22 +0000 (14:58 +0530)
----------------------------------------
* CRM-16189: Improve support for Accrual Method bookkeeping
  https://issues.civicrm.org/jira/browse/CRM-16189

Conflicts:
CRM/Contribute/Form/AdditionalPayment.php

17 files changed:
CRM/Contribute/BAO/Contribution.php
CRM/Contribute/BAO/Query.php
CRM/Contribute/Form/AdditionalPayment.php
CRM/Contribute/Form/ContributionView.php
CRM/Contribute/Page/PaymentInfo.php
CRM/Contribute/Selector/Search.php
CRM/Core/BAO/FinancialTrxn.php
CRM/Event/BAO/Participant.php
CRM/Event/Form/EventFees.php
CRM/Event/Form/Participant.php
CRM/Event/Form/ParticipantFeeSelection.php
CRM/Event/Form/ParticipantView.php
templates/CRM/Contribute/Form/AdditionalPayment.tpl
templates/CRM/Contribute/Form/ContributionView.tpl
templates/CRM/Contribute/Page/PaymentInfo.tpl
templates/CRM/Event/Form/Participant.tpl
templates/CRM/Event/Form/ParticipantView.tpl

index 99c909c8e92af504cdbe509e47b33d5f03e547a7..f70b16578dbb64aac801db03777ee325e32bb80c 100644 (file)
@@ -3939,6 +3939,10 @@ WHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']})
         $entityObj = CRM_Event_BAO_Participant::getValues($inputParams, $values, $ids);
         $entityObj = $entityObj[$participantId];
       }
+      else {
+        $entityObj = $contributionDAO;
+        $component = 'contribution';
+      }
       $activityType = ($paymentType == 'refund') ? 'Refund' : 'Payment';
 
       self::addActivityForPayment($entityObj, $financialTrxn, $activityType, $component, $contributionId);
@@ -3957,14 +3961,17 @@ WHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']})
    */
   public static function addActivityForPayment($entityObj, $trxnObj, $activityType, $component, $contributionId) {
     if ($component == 'event') {
-      $date = CRM_Utils_Date::isoToMysql($trxnObj->trxn_date);
-      $paymentAmount = CRM_Utils_Money::format($trxnObj->total_amount, $trxnObj->currency);
-      $eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Event', $entityObj->event_id, 'title');
-      $subject = "{$paymentAmount} - Offline {$activityType} for {$eventTitle}";
-      $targetCid = $entityObj->contact_id;
-      // source record id would be the contribution id
-      $srcRecId = $contributionId;
+      $title = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Event', $entityObj->event_id, 'title');
     }
+    else {
+      $title = ts('Contribution');
+    }
+    $paymentAmount = CRM_Utils_Money::format($trxnObj->total_amount, $trxnObj->currency);
+    $subject = "{$paymentAmount} - Offline {$activityType} for {$title}";
+    $date = CRM_Utils_Date::isoToMysql($trxnObj->trxn_date);
+    $targetCid = $entityObj->contact_id;
+    // source record id would be the contribution id
+    $srcRecId = $contributionId;
 
     // activity params
     $activityParams = array(
@@ -4032,17 +4039,7 @@ WHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']})
       $baseTrxnId = $baseTrxnId['financialTrxnId'];
     }
     if (!CRM_Utils_Array::value('total_amount', $total) || $usingLineTotal) {
-      // for additional participants
-      if ($entityTable == 'civicrm_participant') {
-        $ids = CRM_Event_BAO_Participant::getParticipantIds($contributionId);
-        $total = 0;
-        foreach ($ids as $val) {
-          $total += CRM_Price_BAO_LineItem::getLineTotal($val, $entityTable);
-        }
-      }
-      else {
-        $total = CRM_Price_BAO_LineItem::getLineTotal($id, $entityTable);
-      }
+      $total = CRM_Price_BAO_LineItem::getLineTotal($contributionId);
     }
     else {
       $baseTrxnId = $total['trxn_id'];
index 1cd6eb9277e21da9b5ee9f2709bb64be05f2bd49..b152dedf5cf01c4d1dec1c4f5b6ca7d11aaf460b 100644 (file)
@@ -236,11 +236,6 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query {
       $query->_element['contribution_campaign_title'] = $query->_tables['civicrm_campaign'] = 1;
     }
 
-    if (!empty($query->_returnProperties['contribution_participant_id'])) {
-      $query->_select['contribution_participant_id'] = "civicrm_participant.id as contribution_participant_id";
-      $query->_whereTables['contribution_participant'] = $query->_tables['contribution_participant'] = 1;
-    }
-
     // Adding address_id in a way that is more easily extendable since the above is a bit ... wordy.
     $supportedBasicReturnValues = array('address_id');
     foreach ($supportedBasicReturnValues as $fieldName) {
index 99bea89c7dffe5246b6675a87f08d862f4a7ad6f..da4c596c9260cca18c57cffa599d3e6cc0c13c9a 100644 (file)
@@ -100,12 +100,17 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
     $this->_formType = CRM_Utils_Array::value('formType', $_GET);
 
     $enitityType = NULL;
+    $enitityType = 'contribution';
     if ($this->_component == 'event') {
       $enitityType = 'participant';
       $this->_contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'contribution_id', 'participant_id');
+      $eventId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'event_id', 'id');
+      $this->_fromEmails = CRM_Event_BAO_Event::getFromEmailIds($eventId);
+    }
+    else {
+      $this->_contributionId = $this->_id;
+      $this->_fromEmails['from_email_id'] = CRM_Core_BAO_Email::getFromEmail();
     }
-    $eventId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'event_id', 'id');
-    $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, FALSE, TRUE);
@@ -369,17 +374,27 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
 
   public function postProcess() {
     $participantId = NULL;
+    $childTab = 'contribute';
     if ($this->_component == 'event') {
       $participantId = $this->_id;
+      $childTab = 'participant';
     }
     $submittedValues = $this->controller->exportValues($this->_name);
     $submittedValues['confirm_email_text'] = CRM_Utils_Array::value('receipt_text', $submittedValues);
-
+    $contributionStatuses = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution',
+      'contribution_status_id',
+      array('labelColumn' => 'name')
+    );
+    $contributionStatusID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $this->_contributionId, 'contribution_status_id');
+    if ($contributionStatuses[$contributionStatusID] == 'Pending') {
+      CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_Contribution', $this->_contributionId, 'contribution_status_id', array_search('Partially paid', $contributionStatuses));
+    }
     $submittedValues['trxn_date'] = CRM_Utils_Date::processDate($submittedValues['trxn_date'], $submittedValues['trxn_date_time']);
     if ($this->_mode) {
       // process credit card
       $this->assign('contributeMode', 'direct');
       $this->processCreditCard($submittedValues);
+      $submittedValues = $this->_params;
     }
     else {
       $defaults = array();
@@ -413,7 +428,7 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
 
       $session = CRM_Core_Session::singleton();
       $session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view',
-        "reset=1&cid={$this->_contactId}&selectedChild=participant"
+        "reset=1&cid={$this->_contactId}&selectedChild={$childTab}"
       ));
     }
   }
@@ -602,29 +617,6 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
       );
       $this->_params['source'] = ts('Submit Credit Card Payment by: %1', array(1 => $userSortName));
     }
-
-    // process the additional payment
-    $participantId = NULL;
-    if ($this->_component == 'event') {
-      $participantId = $this->_id;
-    }
-    $trxnRecord = CRM_Contribute_BAO_Contribution::recordAdditionalPayment($this->_contributionId, $submittedValues, $this->_paymentType, $participantId);
-
-    if ($trxnRecord->id && !empty($this->_params['is_email_receipt'])) {
-      $sendReceipt = $this->emailReceipt($this->_params);
-    }
-
-    if ($trxnRecord->id) {
-      $statusMsg = ts('The payment record has been processed.');
-      if (!empty($this->_params['is_email_receipt']) && $sendReceipt) {
-        $statusMsg .= ' ' . ts('A receipt has been emailed to the contributor.');
-      }
-
-      CRM_Core_Session::setStatus($statusMsg, ts('Complete'), 'success');
-      $session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view',
-        "reset=1&cid={$this->_contactId}&selectedChild=participant"
-      ));
-    }
   }
 
   /**
index 0ef43f4e3abacac6ed8e8a950b29fe26763acc6b..ee75bd0460f1b0da2d747dd4fd4472ba0aa4d2bb 100644 (file)
@@ -219,13 +219,21 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form {
       NULL,
       $recentOther
     );
-
-    $participantID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment',
-      $values['id'], 'participant_id', 'contribution_id'
-    );
-    $this->assign('contactId', $values['contact_id']);
-    $this->assign('hasPayment', $values['id']);
-    $this->assign('participantId', $participantID);
+    $contributionStatus = $status[$values['contribution_status_id']];
+    if (in_array($contributionStatus, array('Partially paid', 'Pending refund'))
+        || ($contributionStatus == 'Pending' && $values['is_pay_later'])
+        ) {
+      if ($contributionStatus == 'Pending refund') {
+        $this->assign('paymentButtonName', ts('Record Refund'));
+      }
+      else {
+        $this->assign('paymentButtonName', ts('Record Payment'));
+      }
+      $this->assign('addRecordPayment', TRUE);
+      $this->assign('contactId', $values['contact_id']);
+      $this->assign('componentId', $id);
+      $this->assign('component', 'contribution');
+    }
   }
 
   /**
index 9975748dc87ee5b898ba05a7e058f87bf9f1eb09..b4a519c581867241a5987efb2f3bad39f702d0a0 100644 (file)
@@ -42,6 +42,9 @@ class CRM_Contribute_Page_PaymentInfo extends CRM_Core_Page {
     $this->assign('id', $this->_id);
     $this->assign('context', $this->_context);
     $this->assign('component', $this->_component);
+    if ($this->_component != 'event') {
+      $this->assign('hideButtonLinks', TRUE);
+    }
   }
 
   public function browse() {
index 79155fd50b1bb0282c5f070548672bd29c59f2dd..efb4b786ced6b13e25c088c4e086af6c0c4c50e8 100644 (file)
@@ -82,7 +82,6 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
     'contribution_soft_credit_contact_id',
     'contribution_soft_credit_amount',
     'contribution_soft_credit_type',
-    'contribution_participant_id',
   );
 
   /**
@@ -185,7 +184,6 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
     // type of selector
     $this->_action = $action;
     $returnProperties = CRM_Contribute_BAO_Query::selectorReturnProperties();
-    $returnProperties['contribution_participant_id'] = 1;
     $this->_includeSoftCredits = CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled($this->_queryParams);
     $this->_query = new CRM_Contact_BAO_Query(
       $this->_queryParams,
@@ -418,7 +416,9 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
         $contributionStatuses
       );
 
+      $isPayLater = FALSE;
       if ($result->is_pay_later && CRM_Utils_Array::value('contribution_status_name', $row) == 'Pending') {
+        $isPayLater = TRUE;
         $row['contribution_status'] .= ' (' . ts('Pay Later') . ')';
         $links[CRM_Core_Action::ADD] = array(
           'name' => ts('Pay with Credit Card'),
@@ -441,26 +441,26 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
         'id' => $result->contribution_id,
         'cid' => $result->contact_id,
         'cxt' => $this->_context,
-        'pid' => $result->contribution_participant_id,
+        'compId' => $result->contribution_id,
+        'comp' => 'contribution',
       );
-      if (!empty($row['contribution_participant_id'])) {
-        if ($row['contribution_status_name'] == 'Partially paid') {
-          $links[CRM_Core_Action::ADD] = array(
-            'name' => ts('Record Payment'),
-            'url' => 'civicrm/payment',
-            'qs' => 'reset=1&id=%%pid%%&cid=%%cid%%&action=add&component=event',
-            'title' => ts('Record Payment'),
-          );
-        }
 
-        if ($row['contribution_status_name'] == 'Pending refund') {
-          $links[CRM_Core_Action::ADD] = array(
-            'name' => ts('Record Refund'),
-            'url' => 'civicrm/payment',
-            'qs' => 'reset=1&id=%%pid%%&cid=%%cid%%&action=add&component=event',
-            'title' => ts('Record Refund'),
-          );
-        }
+      if ($row['contribution_status_name'] == 'Partially paid' || $isPayLater) {
+        $links[CRM_Core_Action::ADD] = array(
+          'name' => ts('Record Payment'),
+          'url' => 'civicrm/payment',
+          'qs' => 'reset=1&id=%%compId%%&cid=%%cid%%&action=add&component=%%comp%%',
+          'title' => ts('Record Payment'),
+        );
+      }
+
+      if ($row['contribution_status_name'] == 'Pending refund') {
+        $links[CRM_Core_Action::ADD] = array(
+          'name' => ts('Record Refund'),
+          'url' => 'civicrm/payment',
+          'qs' => 'reset=1&id=%%pid%%&cid=%%cid%%&action=add&component=event',
+          'title' => ts('Record Refund'),
+        );
       }
 
       $row['action'] = CRM_Core_Action::formLink(
index 0e75bb1d1db4f846063e589f2436a042e8eb2ce9..dc9c8359161508f99e894a9d3aedf716769a8a54 100644 (file)
@@ -469,55 +469,47 @@ WHERE ceft.entity_id = %1";
 
     if ($entityName == 'participant') {
       $contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $entityId, 'contribution_id', 'participant_id');
-      $financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contributionId, 'financial_type_id');
-
-      if ($contributionId && $financialTypeId) {
-        $statusId = CRM_Core_OptionGroup::getValue('contribution_status', 'Completed', 'name');
-        $refundStatusId = CRM_Core_OptionGroup::getValue('contribution_status', 'Refunded', 'name');
-
-        $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
-        $toFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType($financialTypeId, $relationTypeId);
-        $feeRelationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Expense Account is' "));
-        $feeFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType($financialTypeId, $feeRelationTypeId);
-
-        if (empty($lineItemTotal)) {
-          $ids = CRM_Event_BAO_Participant::getParticipantIds($contributionId);
-          if (count($ids) > 1) {
-            $total = 0;
-            foreach ($ids as $val) {
-              $total += CRM_Price_BAO_LineItem::getLineTotal($val, 'civicrm_participant');
-            }
-            $lineItemTotal = $total;
-          }
-          else {
-            $lineItemTotal = CRM_Price_BAO_LineItem::getLineTotal($entityId, 'civicrm_participant');
-          }
-        }
-        $sqlFtTotalAmt = "
+    }
+    else {
+      $contributionId = $entityId;
+    }
+    $financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contributionId, 'financial_type_id');
+
+    if ($contributionId && $financialTypeId) {
+      $statusId = CRM_Core_OptionGroup::getValue('contribution_status', 'Completed', 'name');
+      $refundStatusId = CRM_Core_OptionGroup::getValue('contribution_status', 'Refunded', 'name');
+
+      $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
+      $toFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType($financialTypeId, $relationTypeId);
+      $feeRelationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Expense Account is' "));
+      $feeFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType($financialTypeId, $feeRelationTypeId);
+
+      if (empty($lineItemTotal)) {
+        $lineItemTotal = CRM_Price_BAO_LineItem::getLineTotal($contributionId);
+      }
+      $sqlFtTotalAmt = "
 SELECT SUM(ft.total_amount)
 FROM civicrm_financial_trxn ft
-  LEFT JOIN civicrm_entity_financial_trxn eft ON (ft.id = eft.financial_trxn_id AND eft.entity_table = 'civicrm_contribution')
-  LEFT JOIN civicrm_contribution c ON (eft.entity_id = c.id)
-  LEFT JOIN civicrm_participant_payment pp ON (pp.contribution_id = c.id)
-WHERE pp.participant_id = {$entityId} AND ft.to_financial_account_id != {$toFinancialAccount} AND ft.to_financial_account_id != {$feeFinancialAccount}
+  INNER JOIN civicrm_entity_financial_trxn eft ON (ft.id = eft.financial_trxn_id AND eft.entity_table = 'civicrm_contribution' AND eft.entity_id = {$contributionId})
+WHERE ft.to_financial_account_id != {$toFinancialAccount} AND ft.to_financial_account_id != {$feeFinancialAccount}
   AND ft.status_id IN ({$statusId}, {$refundStatusId})
 ";
-        $ftTotalAmt = CRM_Core_DAO::singleValueQuery($sqlFtTotalAmt);
-        $value = 0;
-        if ($ftTotalAmt) {
-          $value = $paymentVal = $lineItemTotal - $ftTotalAmt;
+      $ftTotalAmt = CRM_Core_DAO::singleValueQuery($sqlFtTotalAmt);
+      $value = 0;
+      if (!$ftTotalAmt) {
+        $ftTotalAmt = 0;
+      }
+      $value = $paymentVal = $lineItemTotal - $ftTotalAmt;
+      if ($returnType) {
+        $value = array();
+        if ($paymentVal < 0) {
+          $value['refund_due'] = $paymentVal;
         }
-        if ($returnType) {
-          $value = array();
-          if ($paymentVal < 0) {
-            $value['refund_due'] = $paymentVal;
-          }
-          elseif ($paymentVal > 0) {
-            $value['amount_owed'] = $paymentVal;
-          }
-          elseif ($lineItemTotal == $ftTotalAmt) {
-            $value['full_paid'] = $ftTotalAmt;
+        elseif ($paymentVal > 0) {
+          $value['amount_owed'] = $paymentVal;
           }
+        elseif ($lineItemTotal == $ftTotalAmt) {
+          $value['full_paid'] = $ftTotalAmt;
         }
       }
     }
index c63041d35f858ffa0e659eb1a78b4737d18b9cd4..0428b1a18e79b60ece5aca2e3f9d629258fd528d 100644 (file)
@@ -2035,11 +2035,7 @@ WHERE (li.entity_table = 'civicrm_participant' AND li.entity_id = {$participantI
     // the recordAdjustedAmt code would execute over here
     $ids = CRM_Event_BAO_Participant::getParticipantIds($contributionId);
     if (count($ids) > 1) {
-      $total = 0;
-      foreach ($ids as $val) {
-        $total += CRM_Price_BAO_LineItem::getLineTotal($val, 'civicrm_participant');
-      }
-      $updatedAmount = $total;
+      $updatedAmount = CRM_Price_BAO_LineItem::getLineTotal($contributionId);
     }
     else {
       $updatedAmount = $params['amount'];
index 2ce9618fcad4a1885949db40ef93bcd9a62a341b..a607057c7bc0be1c0a8865825afdd778c33411cf 100644 (file)
@@ -414,7 +414,7 @@ SELECT  id, html_type
         CRM_Core_Payment_Form::buildPaymentForm($form, $form->_paymentProcessor, FALSE, TRUE);
       }
       elseif (!$form->_mode) {
-        $form->addElement('checkbox', 'record_contribution', ts('Record Invoice?'), NULL,
+        $form->addElement('checkbox', 'record_contribution', ts('Record Payment?'), NULL,
           array('onclick' => "return showHideByValue('record_contribution','','payment_information','table-row','radio',false);")
         );
         // Check permissions for financial type first
index 3a27183ccfc9e9baffbda9bccb6d2c7e495048b1..38b453fa7e729e83bfda7031ca7ec5a6edc4675d 100644 (file)
@@ -244,6 +244,8 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
       );
 
       $this->assign('hasPayment', $this->_paymentId);
+      $this->assign('componentId', $this->_id);
+      $this->assign('component', 'event');
 
       // CRM-12615 - Get payment information from the primary registration
       if ((!$this->_paymentId) && ($this->_action == CRM_Core_Action::UPDATE)) {
index 52c78fd53ae3cce7723ea185dfff15b6e1abdc59..3d9aeb4f70512006c8595a0257ff6c5a7f2e0fcd 100644 (file)
@@ -106,14 +106,9 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form {
 
     $ids = CRM_Event_BAO_Participant::getParticipantIds($this->_contributionId);
     if (count($ids) > 1) {
-      $total = 0;
-      foreach ($ids as $val) {
-        $total += CRM_Price_BAO_LineItem::getLineTotal($val, 'civicrm_participant');
-      }
+      $total = CRM_Price_BAO_LineItem::getLineTotal($this->_contributionId);
       $this->assign('totalLineTotal', $total);
-
-      $lineItemTotal = CRM_Price_BAO_LineItem::getLineTotal($this->_participantId, 'civicrm_participant');
-      $this->assign('lineItemTotal', $lineItemTotal);
+      $this->assign('lineItemTotal', $total);
     }
 
     $title = ts("Change selections for %1", array(1 => $this->_contributorDisplayName));
index ee52b4b3c747bae5647cc70bb83b7772ff6bef10..45ac7a1a6c97a1325d8b86d6a24de614a89650d7 100644 (file)
@@ -74,6 +74,8 @@ class CRM_Event_Form_ParticipantView extends CRM_Core_Form {
       $participantID, 'id', 'participant_id'
     );
     $this->assign('hasPayment', $paymentId);
+    $this->assign('componentId', $participantID);
+    $this->assign('component', 'event');
 
     if ($parentParticipantId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant',
       $participantID, 'registered_by_id'
index 7f210de946fd1cca78d35b440670d07cf8b4a53d..d302860ac70aa52239e1ab58d8f7ddab7443fc51 100644 (file)
   </div>
   <table class="form-layout-compressed">
     <tr>
-      <td class="font-size12pt label"><strong>{ts}Participant{/ts}</strong></td><td class="font-size12pt"><strong>{$displayName}</strong></td>
+      <td class="font-size12pt label"><strong>{if $component eq 'event'}{ts}Participant{/ts}{else}{ts}Contact{/ts}{/if}</strong></td><td class="font-size12pt"><strong>{$displayName}</strong></td>
     </tr>
     {if $contributionMode}
       <tr class="crm-payment-form-block-payment_processor_id"><td class="label nowrap">{$form.payment_processor_id.label}<span class="crm-marker"> * </span></td><td>{$form.payment_processor_id.html}</td></tr>
     {/if}
-    <tr>
-      <td class='label'>{ts}Event{/ts}</td><td>{$eventName}</td>
-    </tr>
+    {if $eventName}
+      <tr>
+        <td class='label'>{ts}Event{/ts}</td><td>{$eventName}</td>
+      </tr>
+    {/if}
     <tr class="crm-payment-form-block-total_amount">
       <td class="label">{$form.total_amount.label}</td>
       <td>
index 175fd5b4ba9b9402a7bc0a5e59bce74d12b4d345..4ebef343e7e2cc4c467f2eef937242cf24ec69d5 100644 (file)
@@ -35,6 +35,9 @@
       <a class="button" href="{crmURL p='civicrm/contact/view/contribution' q=$urlParams}" accesskey="e"><span>
           <i class="crm-i fa-pencil"></i> {ts}Edit{/ts}</span>
       </a>
+      {if $paymentButtonName}
+        <a class="button" href='{crmURL p="civicrm/payment" q="action=add&reset=1&component=`$component`&id=`$id`&cid=`$cid`"}'><i class="crm-i fa-plus-circle"></i> {ts}{$paymentButtonName}{/ts}</a>
+      {/if}
     {/if}
     {if (call_user_func(array('CRM_Core_Permission','check'), 'delete in CiviContribute') && call_user_func(array('CRM_Core_Permission', 'check'), "delete contributions of type $financial_type") && $canDelete)     || (call_user_func(array('CRM_Core_Permission','check'), 'delete in CiviContribute') && $noACL)}
       {assign var='urlParams' value="reset=1&id=$id&cid=$contact_id&action=delete&context=$context"}
       <td>{$thankyou_date|crmDate}</td>
     </tr>
   {/if}
-  {if $participantId and $hasPayment}
+  {if $addRecordPayment}
     <tr>
       <td class='label'>{ts}Fees{/ts}</td>
       <td id='payment-info'></td>
     </div>
   </fieldset>
 {/if}
-{if $participantId and $hasPayment}
-  {include file="CRM/Contribute/Page/PaymentInfo.tpl" show='event-payment'}
+{if $addRecordPayment}
+  {include file="CRM/Contribute/Page/PaymentInfo.tpl" show='payments'}
 {/if}
 
 <div class="crm-submit-buttons">
       {assign var='urlParams' value="reset=1&id=$id&cid=$contact_id&action=update&context=$context&key=$searchKey"}
     {/if}
     <a class="button" href="{crmURL p='civicrm/contact/view/contribution' q=$urlParams}" accesskey="e"><span><i class="crm-i fa-pencil"></i> {ts}Edit{/ts}</span></a>
+    {if $paymentButtonName}
+      <a class="button" href='{crmURL p="civicrm/payment" q="action=add&reset=1&component=`$component`&id=`$id`&cid=`$cid`"}'><i class="crm-i fa-plus-circle"></i> {ts}{$paymentButtonName}{/ts}</a>
+    {/if}
   {/if}
   {if (call_user_func(array('CRM_Core_Permission','check'), 'delete in CiviContribute') && call_user_func(array('CRM_Core_Permission', 'check'), "delete contributions of type $financial_type") && $canDelete)     || (call_user_func(array('CRM_Core_Permission','check'), 'delete in CiviContribute') && $noACL)}
     {assign var='urlParams' value="reset=1&id=$id&cid=$contact_id&action=delete&context=$context"}
index 2080ff0b55ec8a9ed7adbfc05002671aae17d50b..6a0c8019a7f5d840acdde1278d10e590137aeee8 100644 (file)
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
 *}
-{if $show eq 'event-payment'}
+{if $show eq 'payments'}
 {literal}
 <script type='text/javascript'>
 CRM.$(function($) {
   if ($("#payment-info").length) {
-    var dataUrl = {/literal}'{crmURL p="civicrm/payment/view" h=0 q="action=browse&id=$participantId&cid=`$contactId`&component=event&context=payment_info&snippet=4"}'{literal};
+    var dataUrl = {/literal}'{crmURL p="civicrm/payment/view" h=0 q="action=browse&id=$componentId&cid=`$contactId`&component=$component&context=payment_info&snippet=4"}'{literal};
     $.ajax({
       url: dataUrl,
       async: false,
@@ -54,6 +54,8 @@ CRM.$(function($) {
   <tr class="columnheader">
     {if $component eq "event"}
       <th>{ts}Total Fee(s){/ts}</th>
+    {else}
+      <th>{ts}Contribution Amount(s){/ts}</th>
     {/if}
     <th class="right">{ts}Total Paid{/ts}</th>
     <th class="right">{ts}Balance{/ts}</th>
@@ -62,17 +64,20 @@ CRM.$(function($) {
     <td>{$paymentInfo.total|crmMoney}</td>
     <td class='right'>
       {if $paymentInfo.paid > 0}
-        {$paymentInfo.paid|crmMoney}<br/>
-        <a class="crm-hover-button action-item crm-popup medium-popup" href='{crmURL p="civicrm/payment" q="view=transaction&cid=`$cid`&id=`$paymentInfo.id`&component=`$paymentInfo.component`&action=browse"}'>
-          <i class="crm-i fa-list"></i>
-          {ts}view payments{/ts}
-        </a>
+        {$paymentInfo.paid|crmMoney}
+               {if  !$hideButtonLinks}
+          <br/>
+          <a class="crm-hover-button action-item crm-popup medium-popup" href='{crmURL p="civicrm/payment" q="view=transaction&cid=`$cid`&id=`$paymentInfo.id`&component=`$paymentInfo.component`&action=browse"}'>
+            <i class="crm-i fa-list"></i>
+            {ts}view payments{/ts}
+          </a>
+        {/if}
       {/if}
     </td>
     <td class="right" id="payment-info-balance" data-balance="{$paymentInfo.balance}">{$paymentInfo.balance|crmMoney}</td>
   </tr>
 </table>
-{if $paymentInfo.balance and !$paymentInfo.payLater}
+{if $paymentInfo.balance and !$paymentInfo.payLater && !$hideButtonLinks}
   {if $paymentInfo.balance > 0}
      {assign var=paymentButtonName value='Record Payment'}
   {elseif $paymentInfo.balance < 0}
index e4a28c1cbb8fbd8fd41dbf8956e9d4d7bf76085c..5246237f7f706950e8de5783f966e498787cf6bf 100644 (file)
   {* JS block for ADD or UPDATE actions only *}
   {if $action eq 1 or $action eq 2}
     {if $participantId and $hasPayment}
-      {include file="CRM/Contribute/Page/PaymentInfo.tpl" show='event-payment'}
+      {include file="CRM/Contribute/Page/PaymentInfo.tpl" show='payments'}
     {/if}
 
     {*include custom data js file*}
index 190adff70311c630f8a9e32d31d88f37b5ca446b..c7cd459dbcc6388e8711efbc502aae056ef0f4ee 100644 (file)
     {/foreach}
     </table>
     {if $participantId and $hasPayment}
-      {include file="CRM/Contribute/Page/PaymentInfo.tpl" show='event-payment'}
+      {include file="CRM/Contribute/Page/PaymentInfo.tpl" show='payments'}
     {/if}
     {include file="CRM/Custom/Page/CustomDataView.tpl"}
     {if $accessContribution and $rows.0.contribution_id}