Merge remote-tracking branch 'upstream/4.6' into 4.6-master-2015-07-06-14-41-49
[civicrm-core.git] / CRM / Event / Form / Registration / Confirm.php
index 8609d6d556c5bf23be68be0e7bc6b8f22d67c750..11dcbcf4bba10fcf18af515fbcace2ab78fbd373 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -29,7 +29,7 @@
  *
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
  * $Id$
  *
  */
@@ -126,7 +126,6 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration {
         }
         $params['amount_level'] = $this->_params[0]['amount_level'];
         $params['currencyID'] = $this->_params[0]['currencyID'];
-        $params['payment_action'] = 'Sale';
 
         // also merge all the other values from the profile fields
         $values = $this->controller->exportValues('Register');
@@ -172,7 +171,6 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration {
       if ($this->_values['event']['is_monetary']) {
         $registerParams['ip_address'] = CRM_Utils_System::ipAddress();
         $registerParams['currencyID'] = $this->_params[0]['currencyID'];
-        $registerParams['payment_action'] = 'Sale';
       }
       //assign back primary participant params.
       $this->_params[0] = $registerParams;
@@ -234,6 +232,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration {
 
       $taxAmount = 0;
       foreach ($this->_params as $k => $v) {
+        $individualTaxAmount = 0;
         //display tax amount on confirmation page
         $taxAmount += $v['tax_amount'];
         if (is_array($v)) {
@@ -270,6 +269,10 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration {
           if (empty($v['first_name'])) {
             $this->_part[$k]['info'] = $append;
           }
+
+          /*CRM-16320 */
+          $individual[$k]['totalAmtWithTax'] = $this->_amount[$k]['amount'];
+          $individual[$k]['totalTaxAmt'] = $individualTaxAmount + $v['tax_amount'];
           $this->_totalAmount = $this->_totalAmount + $this->_amount[$k]['amount'];
           if (!empty($v['is_primary'])) {
             $this->set('primaryParticipantAmount', $this->_amount[$k]['amount']);
@@ -283,7 +286,10 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration {
       if ($invoicing) {
         $this->assign('totalTaxAmount', $taxAmount);
         $this->assign('taxTerm', $taxTerm);
+        $this->assign('individual', $individual);
+        $this->set('individual', $individual);
       }
+
       $this->assign('part', $this->_part);
       $this->set('part', $this->_part);
       $this->assign('amounts', $this->_amount);
@@ -766,7 +772,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration {
       }
     }
 
-    //update status and send mail to cancelled additonal participants, CRM-4320
+    //update status and send mail to cancelled additional participants, CRM-4320
     if ($this->_allowConfirmation && is_array($cancelledIds) && !empty($cancelledIds)) {
       $cancelledId = array_search('Cancelled',
         CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Negative'")
@@ -936,6 +942,14 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration {
             if ($lineItemValue = CRM_Utils_Array::value($participantNum, $lineItems)) {
               $lineItem[] = $lineItemValue;
             }
+            if ($invoicing) {
+              $individual = $this->get('individual');
+              $dataArray[key($dataArray)] = $individual[$participantNum]['totalTaxAmt'];
+              $this->assign('dataArray', $dataArray);
+              $this->assign('totalAmount', $individual[$participantNum]['totalAmtWithTax']);
+              $this->assign('totalTaxAmount', $individual[$participantNum]['totalTaxAmt']);
+              $this->assign('individual', array($individual[$participantNum]));
+            }
             $this->assign('lineItem', $lineItem);
           }
           $this->_values['params']['additionalParticipant'] = TRUE;