CRM-13973 - work on the UI implementation, CRM-13965 - improvements to BAOs
authorPratik Joshi <pratik.joshi@webaccess.co.in>
Thu, 16 Jan 2014 01:45:01 +0000 (07:15 +0530)
committerPratik Joshi <pratik.joshi@webaccess.co.in>
Thu, 16 Jan 2014 01:45:01 +0000 (07:15 +0530)
13 files changed:
CRM/Contribute/BAO/Contribution.php
CRM/Contribute/Page/PaymentInfo.php
CRM/Core/BAO/FinancialTrxn.php
CRM/Event/Form/Participant.php
CRM/Event/Form/ParticipantFeeSelection.php [new file with mode: 0644]
CRM/Event/Form/ParticipantView.php
CRM/Event/xml/Menu/Event.xml
CRM/Price/BAO/LineItem.php
templates/CRM/Contribute/Page/PaymentInfo.tpl
templates/CRM/Event/Form/Participant.tpl
templates/CRM/Event/Form/ParticipantFeeSelection.tpl [new file with mode: 0644]
templates/CRM/Event/Form/ParticipantView.tpl
templates/CRM/Price/Form/Calculate.tpl

index 20a1fe547937674b225c0431dae99c47a92c9387..6f2477672e40add218961bf09a949c4e0d5cd3be 100644 (file)
@@ -3148,17 +3148,23 @@ WHERE eft.financial_trxn_id = {$trxnId}
       $contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantPayment', $id, 'contribution_id', 'participant_id');
     }
     $total = CRM_Core_BAO_FinancialTrxn::getBalanceTrxnAmt($contributionId);
-    $baseTrxnId = $total['trxn_id'];
-    $total = $total['total_amount'];
-    $paymentBalance = CRM_Core_BAO_FinancialTrxn::getPartialPaymentWithType($id, $entity, FALSE);
+    $baseTrxnId = NULL;
+    if (empty($total)) {
+      $total = CRM_Price_BAO_LineItem::getLineTotal($id, 'civicrm_participant');
+    }
+    else {
+      $baseTrxnId = $total['trxn_id'];
+      $total = $total['total_amount'];
+    }
+    $paymentBalance = CRM_Core_BAO_FinancialTrxn::getPartialPaymentWithType($id, $entity, FALSE, $total);
 
     $info['total'] = $total;
     $info['paid'] = $total - $paymentBalance;
     $info['balance'] = $paymentBalance;
     $info['id'] = $id;
     $info['component'] = $component;
-
-    if ($getTrxnInfo) {
+    $rows = array();
+    if ($getTrxnInfo && $baseTrxnId) {
       $sql = "
 SELECT ft.total_amount, con.financial_type_id, ft.payment_instrument_id, ft.trxn_date, ft.trxn_id, ft.status_id
 FROM civicrm_contribution con
@@ -3168,7 +3174,6 @@ WHERE ft.id != {$baseTrxnId} AND con.id = {$contributionId}
 ";
       $resultDAO = CRM_Core_DAO::executeQuery($sql);
 
-      $rows = array();
       while($resultDAO->fetch()) {
         $paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
         $statuses = CRM_Contribute_PseudoConstant::contributionStatus();
index 1bc1f662e46067bdcd282e8b5068e71f5af9c91a..ccf502e332f32a0400c3b7bdf810c72ef10d09c6 100644 (file)
@@ -53,7 +53,7 @@ class CRM_Contribute_Page_PaymentInfo extends CRM_Core_Page {
       $this->assign('paymentInfo', $paymentInfo);
     }
     else {
-      $rows = $paymentInfo['transaction'];
+      $rows = CRM_Utils_Array::value('transaction', $paymentInfo);
       $this->assign('rows', $rows);
     }
   }
index e0b2100fcf10d84c87c6506c0831fc5963e45e3b..f8c46ce15cc0857dcec09dbf1732f962d3099f57 100644 (file)
@@ -398,48 +398,38 @@ WHERE ceft.entity_id = %1";
    * return @array : payment type => amount
    * payment type  : 'amount_owed' or 'refund_due'
    */
-  static function getPartialPaymentWithType($entityId, $entityName = 'pariticpant', $returnType = TRUE) {
+  static function getPartialPaymentWithType($entityId, $entityName = 'participant', $returnType = TRUE, $lineItemTotal = NULL) {
     $value = NULL;
     if (empty($entityName)) {
       return $value;
     }
 
     if ($entityName == 'participant') {
-      $partialPaymentStatusId = CRM_Core_OptionGroup::getValue('contribution_status', 'Partially paid', 'name');
-      $sql = "SELECT pp.contribution_id, con.financial_type_id FROM civicrm_participant_payment pp
-INNER JOIN civicrm_contribution con ON con.id = pp.contribution_id
-WHERE pp.participant_id = %1 AND con.contribution_status_id = %2
-";
-      $qParams[1] = array($entityId, 'Integer');
-      $qParams[2] = array($partialPaymentStatusId, 'Integer');
-      $dao = CRM_Core_DAO::executeQuery($sql, $qParams);
-      if ($dao->fetch()) {
-        $contributionId  = $dao->contribution_id;
-        $financialTypeId = $dao->financial_type_id;
-      }
+      $contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $entityId, 'contribution_id', 'participant_id');
+      $financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $entityId, 'financial_type_id');
 
       if ($contributionId && $financialTypeId) {
         $statusId = CRM_Core_OptionGroup::getValue('contribution_status', 'Completed', '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);
 
-        $sqlLineItemTotal = "SELECT SUM(li.line_total)
-FROM civicrm_line_item li
-INNER JOIN civicrm_participant_payment pp ON ( li.entity_id = pp.participant_id
-AND li.entity_table = 'civicrm_participant'
-AND li.entity_id = {$entityId})";
-        $lineItemTotal = CRM_Core_DAO::singleValueQuery($sqlLineItemTotal);
-
-        $sqlFtTotalAmt = "SELECT SUM(ft.total_amount)
+        if (empty($lineItemTotal)) {
+          $lineItemTotal = CRM_Price_BAO_LineItem::getLineTotal($entityId, 'civicrm_participant');
+        }
+        $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.status_id = {$statusId}
+  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.from_financial_account_id = {$toFinancialAccount} AND ft.status_id = {$statusId}
 ";
         $ftTotalAmt = CRM_Core_DAO::singleValueQuery($sqlFtTotalAmt);
-
-        $value = $paymentVal = $lineItemTotal - $ftTotalAmt;
+        $value = 0;
+        if ($ftTotalAmt) {
+          $value = $paymentVal = $lineItemTotal - $ftTotalAmt;
+        }
         if ($returnType) {
           $value = array();
           if ($paymentVal < 0) {
@@ -448,6 +438,9 @@ WHERE pp.participant_id = {$entityId} AND ft.to_financial_account_id != {$toFina
           elseif ($paymentVal > 0) {
             $value['amount_owed'] = $paymentVal;
           }
+          elseif ($lineItemTotal == $ftTotalAmt) {
+            $value['full_paid'] = $ftTotalAmt;
+          }
         }
       }
     }
index bf7a833219e15af331ca5329738949e7e3d7d9a6..bbf750ca2c689876ee0acfd255f2684dfc8792e6 100644 (file)
@@ -195,8 +195,6 @@ 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
    *
@@ -234,13 +232,8 @@ class CRM_Event_Form_Participant extends CRM_Contact_Form_Task {
 
     if ($this->_id) {
       $this->assign('participantId', $this->_id);
-      $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'))) {
-        $this->_feePaymenBlock = TRUE;
-      }
-      $this->assign('feePaymentBlock', $this->_feePaymenBlock);
       $this->_paymentId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment',
         $this->_id, 'id', 'participant_id'
       );
@@ -679,9 +672,7 @@ SELECT civicrm_custom_group.name as name,
    * @access public
    */
   public function buildQuickForm() {
-    if ($this->_feePaymenBlock) {
-      CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
-    }
+    CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
     if ($this->_showFeeBlock) {
       return CRM_Event_Form_EventFees::buildQuickForm($this);
     }
diff --git a/CRM/Event/Form/ParticipantFeeSelection.php b/CRM/Event/Form/ParticipantFeeSelection.php
new file mode 100644 (file)
index 0000000..b87e850
--- /dev/null
@@ -0,0 +1,178 @@
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.4                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2013                                |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM.                                    |
+ |                                                                    |
+ | CiviCRM is free software; you can copy, modify, and distribute it  |
+ | under the terms of the GNU Affero General Public License           |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
+ |                                                                    |
+ | CiviCRM is distributed in the hope that it will be usefusul, but   |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
+ | See the GNU Affero General Public License for more details.        |
+ |                                                                    |
+ | You should have received a copy of the GNU Affero General Public   |
+ | License and the CiviCRM Licensing Exception along                  |
+ | with this program; if not, contact CiviCRM LLC                     |
+ | at info[AT]civicrm[DOT]org. If you have questions about the        |
+ | GNU Affero General Public License or the licensing of CiviCRM,     |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+ +--------------------------------------------------------------------+
+*/
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2013
+ * $Id$
+ *
+ */
+
+/**
+ * This form records additional payments needed when
+ * event/contribution is partially paid
+ *
+ */
+class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form {
+  /**
+   * related component whose financial payment is being processed
+   *
+   * @var string
+   * @public
+   */
+  protected $_component = NULL;
+
+  protected $_contactId = NULL;
+
+  protected $_contributorDisplayName = NULL;
+
+  protected $_contributorEmail = NULL;
+
+  protected $_toDoNotEmail = NULL;
+
+  protected $_contributionId = NULL;
+
+  protected $fromEmailId = NULL;
+
+  protected $_eventId = NULL;
+
+  public $_action = NULL;
+
+  public $_values = NULL;
+
+  public $_isPaidEvent = NULL;
+
+  public $_participantId = NULL;
+
+  public function preProcess() {
+    $this->_participantId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
+    $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
+    $this->_fromEmails = CRM_Core_BAO_Email::getFromEmail();
+    $this->_eventId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_participantId, 'event_id');
+    $this->_contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_participantId, 'contribution_id', 'participant_id');
+    if ($this->_contributionId) {
+      $this->_isPaidEvent = TRUE;
+    }
+    $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, TRUE);
+
+    list($this->_contributorDisplayName, $this->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactId);
+    $this->assign('displayName', $this->_contributorDisplayName);
+    //set the payment mode - _mode property is defined in parent class
+    $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
+
+    $this->assign('contactId', $this->_contactId);
+    $this->assign('id', $this->_participantId);
+
+    $paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_participantId, 'event');
+    $this->assign('paymentInfo', $paymentInfo);
+    CRM_Core_Resources::singleton()->addSetting(array('feePaid' => $paymentInfo['paid']));
+
+    $title = "Change selections for {$this->_contributorDisplayName}";
+    if ($title) {
+      CRM_Utils_System::setTitle(ts('%1', array(1 => $title)));
+    }
+  }
+
+  public function setDefaultValues() {
+    $params = array('id' => $this->_participantId);
+
+    CRM_Event_BAO_Participant::getValues($params, $defaults, $ids);
+    $priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $this->_eventId);
+
+    $priceSetValues = CRM_Event_Form_EventFees::setDefaultPriceSet($this->_participantId, $this->_eventId);
+    if (!empty($priceSetValues)) {
+      $defaults[$this->_participantId] = array_merge($defaults[$this->_participantId], $priceSetValues);
+    }
+
+    $this->assign('totalAmount', CRM_Utils_Array::value('fee_amount', $defaults[$this->_participantId]));
+    if ($this->_action == CRM_Core_Action::UPDATE) {
+      $fee_level = $defaults[$this->_participantId]['fee_level'];
+      CRM_Event_BAO_Participant::fixEventLevel($fee_level);
+      $this->assign('fee_level', $fee_level);
+      $this->assign('fee_amount', CRM_Utils_Array::value('fee_amount', $defaults[$this->_participantId]));
+    }
+    $defaults = $defaults[$this->_participantId];
+    return $defaults;
+  }
+
+  public function buildQuickForm() {
+    $config = CRM_Core_Config::singleton();
+    $this->assign('currencySymbol',  $config->defaultCurrencySymbol);
+
+    // line items block
+    $lineItem = $event = array();
+    $params = array('id' => $this->_eventId);
+    CRM_Event_BAO_Event::retrieve($params, $event);
+
+    //retrieve custom information
+    $this->_values = array();
+    CRM_Event_Form_Registration::initEventFee($this, $event['id']);
+    CRM_Event_Form_Registration_Register::buildAmount($this, TRUE);
+
+    if (!CRM_Utils_System::isNull(CRM_Utils_Array::value('line_items', $this->_values))) {
+      $lineItem[] = $this->_values['line_items'];
+    }
+    $this->assign('lineItem', empty($lineItem) ? FALSE : $lineItem);
+    $event = CRM_Event_BAO_Event::getEvents(0, $this->_eventId);
+    $this->assign('eventName', $event[$this->_eventId]);
+
+    $statusOptions = CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label');
+    $this->add('select', 'status_id', ts('Participant Status'),
+      array(
+        '' => ts('- select -')) + $statusOptions,
+      TRUE
+    );
+
+    $buttons[] = array(
+      'type' => 'upload',
+      'name' => ts('Save'),
+      'isDefault' => TRUE,
+    );
+
+    $buttons[] = array(
+      'type' => 'cancel',
+      'name' => ts('Cancel'),
+    );
+
+    $this->addButtons($buttons);
+    $this->addFormRule(array('CRM_Event_Form_ParticipantFeeSelection', 'formRule'), $this);
+  }
+
+  static function formRule($fields, $files, $self) {
+    $errors = array();
+    return $errors;
+  }
+
+  public function postProcess() {
+    $params = $this->controller->exportValues($this->_name);
+  }
+
+  static function emailReceipt(&$form, &$params) {
+    // email receipt sending
+  }
+}
\ No newline at end of file
index 41dda2e3f3066b302027ecd1dd021cb1fb7c7ecb..b8da44ab599d6a69a343e6b8f629e19d0b930730 100644 (file)
@@ -45,7 +45,6 @@ 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);
@@ -69,13 +68,8 @@ class CRM_Event_Form_ParticipantView extends CRM_Core_Form {
 
     $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) ';
@@ -208,9 +202,7 @@ 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');
-    }
+    CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
     $this->addButtons(array(
         array(
           'type' => 'cancel',
index 125e71e19aa657d56dcbe1d244ca9b6e19745981..be95ac376bd72e66090571e23ac8c632cbf69dd0 100644 (file)
     <is_public>true</is_public>
     <is_ssl>false</is_ssl>
   </item>
+  <item>
+    <path>civicrm/event/participant/feeselection</path>
+    <title>Change Registration Selections</title>
+    <page_callback>CRM_Event_Form_ParticipantFeeSelection</page_callback>
+    <access_arguments>access CiviEvent</access_arguments>
+  </item>
 </menu>
index 98a831ebc634929462f8a5fdc90a8294c6803d22..741a10c74dd1052fc399d54bbae0a446fb7427d6 100644 (file)
@@ -92,6 +92,16 @@ class CRM_Price_BAO_LineItem extends CRM_Price_DAO_LineItem {
     return NULL;
   }
 
+  static function getLineTotal($entityId, $entityTable) {
+    $sqlLineItemTotal = "SELECT SUM(li.line_total)
+FROM civicrm_line_item li
+INNER JOIN civicrm_participant_payment pp ON ( li.entity_id = pp.participant_id
+AND li.entity_table = '{$entityTable}'
+AND li.entity_id = {$entityId})";
+    $lineItemTotal = CRM_Core_DAO::singleValueQuery($sqlLineItemTotal);
+    return $lineItemTotal;
+  }
+
   /**
    * Given a participant id/contribution id,
    * return contribution/fee line items
index 37a339e0d512bdbb6bf1eb24e530804077b91a77..444250e3548febb07dda392f286ef189cd73b482 100644 (file)
   <a class="button" href='{crmURL p="civicrm/payment/add" q="reset=1&component=`$component`&id=`$id`&cid=`$cid`"}' title="{ts}Record Payment{/ts}"><span><div class="icon add-icon"></div> {ts}Record Payment{/ts}</span></a>
 {/if}
 {elseif $context eq 'transaction'}
-<table id='info'>
-  <tr class="columnheader">
-    <th>{ts}Amount{/ts}</th>
-    <th>{ts}Type{/ts}</th>
-    <th>{ts}Paid By{/ts}</th>
-    <th>{ts}Received{/ts}</th>
-    <th>{ts}Transaction ID{/ts}</th>
-    <th>{ts}Status{/ts}</th>
-  </tr>
-  {foreach from=$rows item=row}
-    <tr>
-      <td>{$row.total_amount|crmMoney}</td>
-      <td>{$row.financial_type}</td>
-      <td>{$row.payment_instrument}</td>
-      <td>{$row.receive_date|crmDate}</td>
-      <td>{$row.trxn_id}</td>
-      <td>{$row.status}</td>
-    </tr>
-  {/foreach}
-<table>
+  {if !empty($rows)}
+   <table id='info'>
+     <tr class="columnheader">
+       <th>{ts}Amount{/ts}</th>
+       <th>{ts}Type{/ts}</th>
+       <th>{ts}Paid By{/ts}</th>
+       <th>{ts}Received{/ts}</th>
+       <th>{ts}Transaction ID{/ts}</th>
+       <th>{ts}Status{/ts}</th>
+     </tr>
+     {foreach from=$rows item=row}
+     <tr>
+       <td>{$row.total_amount|crmMoney}</td>
+       <td>{$row.financial_type}</td>
+       <td>{$row.payment_instrument}</td>
+       <td>{$row.receive_date|crmDate}</td>
+       <td>{$row.trxn_id}</td>
+       <td>{$row.status}</td>
+     </tr>
+     {/foreach}
+    <table>
+  {else}
+     {if $component eq 'event'}
+       {assign var='entity' value='participant'}
+     {else}
+       {assign var='entity' value=$component}
+     {/if}
+    {ts 1=$entity}No additional payments found for this %1 record{/ts}
+  {/if}
 {/if}
\ No newline at end of file
index e4c76163bd4bc6a7306148ddd9c5881258d96bb0..bb6705bf658a9fcbe8ca19ed08b456a961c2b48b 100644 (file)
@@ -24,7 +24,7 @@
  +--------------------------------------------------------------------+
 *}
 {* This template is used for adding/editing/deleting offline Event Registrations *}
-{if $showFeeBlock }
+{if $showFeeBlock}
   {if $priceSet}
   <div id='validate_pricefield' class='messages crm-error hiddenElement'></div>
     {literal}
   </script>
   {/literal}
   {/if}
-  {if $participantId and $feePaymentBlock}
+  {if $participantId}
     {include file="CRM/Contribute/Page/PaymentInfo.tpl" show='event-payment'}
   {/if}
   {include file="CRM/Event/Form/EventFees.tpl"}
             <span class="description">{ts}Source for this registration (if applicable).{/ts}</span></td>
           </tr>
         </table>
-       {if $participantId and $feePaymentBlock}
+       {if $participantId}
         <table class='form-layout'>
           <tr>
             <td class='label'>{ts}Fees{/ts}</td>
diff --git a/templates/CRM/Event/Form/ParticipantFeeSelection.tpl b/templates/CRM/Event/Form/ParticipantFeeSelection.tpl
new file mode 100644 (file)
index 0000000..ea9641b
--- /dev/null
@@ -0,0 +1,91 @@
+{*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.4                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2013                                |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM.                                    |
+ |                                                                    |
+ | CiviCRM is free software; you can copy, modify, and distribute it  |
+ | under the terms of the GNU Affero General Public License           |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
+ |                                                                    |
+ | CiviCRM is distributed in the hope that it will be useful, but     |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
+ | See the GNU Affero General Public License for more details.        |
+ |                                                                    |
+ | You should have received a copy of the GNU Affero General Public   |
+ | License and the CiviCRM Licensing Exception along                  |
+ | with this program; if not, contact CiviCRM LLC                     |
+ | at info[AT]civicrm[DOT]org. If you have questions about the        |
+ | GNU Affero General Public License or the licensing of CiviCRM,     |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+ +--------------------------------------------------------------------+
+*}
+{* This template is used to change selections of fees for a participant *}
+   
+<h3>Change Registration Selections</h3>
+
+<div class="crm-block crm-form-block crm-payment-form-block">
+  <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
+  <table class="form-layout">    
+    <tr>
+      <td class="font-size12pt label"><strong>{ts}Participant{/ts}</strong></td><td class="font-size12pt"><strong>{$displayName}</strong></td>
+    </tr>
+    <tr>
+      <td class='label'>{ts}Event{/ts}</td><td>{$eventName}</td>
+    </tr>
+    <tr class="crm-participant-form-block-status_id">
+      <td class="label">{$form.status_id.label}</td>
+      <td>{$form.status_id.html}</td>
+    </tr>
+  {if $lineItem}
+     <tr class="crm-event-eventfees-form-block-line_items">
+       <td class="label">{ts}Current Selections{/ts}</td>
+       <td>{include file="CRM/Price/Page/LineItem.tpl" context="Event"}</td>
+     </tr>
+  {/if} 
+  </table>
+  
+  {if $priceSet.fields}
+    <fieldset id="priceset" class="crm-group priceset-group">
+      <table class='form-layout'>
+        <tr class="crm-event-eventfees-form-block-price_set_amount">
+          <td class="label" style="padding-top: 10px;">{$form.amount.label}</td>
+          <td class="view-value"><table class="form-layout">{include file="CRM/Price/Form/PriceSet.tpl" extends="Event"}</table></td>
+        </tr>  
+     {if $paymentInfo}
+       <tr><td></td><td>
+         <div class='crm-section'> 
+         <div class='label'>{ts}Updated Fee(s){/ts}</div><div id="pricevalue" class='content updated-fee'></div>
+         <div class='label'>{ts}Total Paid{/ts}</div>
+         <div class='content'><a class='action-item' href='{crmURL p="civicrm/payment/view" q="action=browse&cid=`$contactId`&id=`$paymentInfo.id`&component=`$paymentInfo.component`&context=transaction"}'>{$paymentInfo.paid|crmMoney}<br/>>> view payments</a>
+         </div>
+         <div class='label'><strong>{ts}Balance Owed{/ts}</strong></div><div id='balance-fee' class='content'></div>
+          </div>
+       {include file='CRM/Price/Form/Calculate.tpl' currencySymbol=$currencySymbol noCalcValueDisplay='false'}
+       {/if}    
+      </table>
+    </fieldset>
+  {/if}
+  <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
+</div>
+{literal}
+<script type='text/javascript'>
+cj(function(){
+  cj('.total_amount-section').remove();
+  cj('#pricevalue').val().trigger('populatebalanceFee');
+
+  function populatebalanceFee() {
+    console.log('dd');
+    // calculate the balance amount using total paid and updated amount
+    var updatedFeeUnFormatted = cj('#pricevalue').val();
+    var updatedAmt = parseFloat(updatedFeeUnFormatted.replace(/[^0-9-.]/g, ''));
+    var balanceAmt = updatedAmt - CRM.feePaid;
+    balanceAmt = formatMoney(balanceAmt, 2, seperator, thousandMarker);
+    cj('#balance-fee').val(balanceAmt);
+  }
+});
+</script>
+{/literal}
\ No newline at end of file
index 5b57e56d5e79f8fbe9e8438137d8b8e961ff3702..b889f590e88584a3f6da95e90359eb254f8bdf65 100644 (file)
@@ -99,7 +99,7 @@
         <td class="label">{ts}Event Source{/ts}</td><td>{$source}&nbsp;</td>
       </tr>
     {/if}
-    {if $participantId and $feePaymentBlock}
+    {if $participantId}
       <tr>
         <td class='label'>{ts}Fees{/ts}</td>
         <td id='payment-info'></td>
       {/if}
     {/foreach}
     </table>
-    {if $participantId and $feePaymentBlock}
+    {if $participantId}
       {include file="CRM/Contribute/Page/PaymentInfo.tpl" show='event-payment'}
     {/if}
     {include file="CRM/Custom/Page/CustomDataView.tpl"}
index 8e3d29c47e674f78e3b315052e315eb93768ca25..d8397508c31f6fc466e0d1d1cfc50c2819f73b01 100644 (file)
@@ -23,6 +23,7 @@
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
 *}
+{if $noCalcValueDisplay neq 'false'}
 <div id="pricesetTotal" class="crm-section section-pricesetTotal">
   <div class="label" id="pricelabel"><label>
     {if ( $extends eq 'Contribution' ) || ( $extends eq 'Membership' )}
@@ -30,7 +31,7 @@
     {/if}</label></div>
   <div class="content calc-value" id="pricevalue" ></div>
 </div>
-
+{/if}
 <script type="text/javascript">
 {literal}