Merge pull request #5336 from colemanw/recurringFix
[civicrm-core.git] / CRM / Event / Form / Participant.php
index 7eadc6553c8873ba4b07972e5c045a3ab16582b7..7b6a868fec6591f452da51632ac945f4743dbd2a 100644 (file)
@@ -23,7 +23,7 @@
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
@@ -43,14 +43,14 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
   public $useLivePageJS = TRUE;
 
   /**
-   * The values for the contribution db object
+   * The values for the contribution db object.
    *
    * @var array
    */
   public $_values;
 
   /**
-   * The values for the quickconfig for priceset
+   * The values for the quickconfig for priceset.
    *
    * @var boolean
    */
@@ -64,35 +64,35 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
   public $_priceSetId;
 
   /**
-   * Array of fields for the price set
+   * Array of fields for the price set.
    *
    * @var array
    */
   public $_priceSet;
 
   /**
-   * The id of the participation that we are proceessing
+   * The id of the participation that we are proceessing.
    *
    * @var int
    */
   public $_id;
 
   /**
-   * The id of the note
+   * The id of the note.
    *
    * @var int
    */
   protected $_noteId = NULL;
 
   /**
-   * The id of the contact associated with this participation
+   * The id of the contact associated with this participation.
    *
    * @var int
    */
   public $_contactId;
 
   /**
-   * Array of event values
+   * Array of event values.
    *
    * @var array
    */
@@ -107,52 +107,52 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
   public $_single = FALSE;
 
   /**
-   * If event is paid or unpaid
+   * If event is paid or unpaid.
    */
   public $_isPaidEvent;
 
   /**
-   * Page action
+   * Page action.
    */
   public $_action;
 
   /**
-   * Role Id
+   * Role Id.
    */
   protected $_roleId = NULL;
 
   /**
-   * Event Type Id
+   * Event Type Id.
    */
   protected $_eventTypeId = NULL;
 
   /**
-   * Participant status Id
+   * Participant status Id.
    */
   protected $_statusId = NULL;
 
   /**
-   * Cache all the participant statuses
+   * Cache all the participant statuses.
    */
   protected $_participantStatuses;
 
   /**
-   * Participant mode
+   * Participant mode.
    */
   public $_mode = NULL;
 
   /**
-   * Event ID preselect
+   * Event ID preselect.
    */
   public $_eID = NULL;
 
   /**
-   * Line Item for Price Set
+   * Line Item for Price Set.
    */
   public $_lineItem = NULL;
 
-  /*
-   * Contribution mode for event registration for offline mode
+  /**
+   * Contribution mode for event registration for offline mode.
    */
   public $_contributeMode = 'direct';
 
@@ -169,12 +169,12 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
   protected $_eventNameCustomDataTypeID;
 
   /**
-   * Selected discount id
+   * Selected discount id.
    */
   public $_originalDiscountId = NULL;
 
   /**
-   * Event id
+   * Event id.
    */
   public $_eventId = NULL;
 
@@ -190,7 +190,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
   public $_onlinePendingContributionId = NULL;
 
   /**
-   * Set variables up before form is built
+   * Set variables up before form is built.
    *
    * @return void
    */
@@ -200,9 +200,9 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
     $this->assign('feeBlockPaid', FALSE);
 
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
-    $this->_mode      = CRM_Utils_Request::retrieve('mode', 'String', $this);
-    $this->_eID       = CRM_Utils_Request::retrieve('eid', 'Positive', $this);
-    $this->_context   = CRM_Utils_Request::retrieve('context', 'String', $this);
+    $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
+    $this->_eID = CRM_Utils_Request::retrieve('eid', 'Positive', $this);
+    $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('context', $this->_context);
 
     if ($this->_contactId) {
@@ -220,7 +220,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
     if (
       strpos($path, 'civicrm/contact/search') === 0 ||
       strpos($path, 'civicrm/group/search') === 0
-      ) {
+    ) {
       $this->_id = NULL;
     }
     else {
@@ -286,17 +286,20 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
       $this->_single = TRUE;
       $this->assign('urlPath', 'civicrm/contact/view/participant');
       if (!$this->_id && !$this->_contactId) {
-        $breadCrumbs = array(array('title' => ts('CiviEvent Dashboard'),
+        $breadCrumbs = array(
+          array(
+            'title' => ts('CiviEvent Dashboard'),
             'url' => CRM_Utils_System::url('civicrm/event', 'reset=1'),
-          ));
+          ),
+        );
 
         CRM_Utils_System::appendBreadCrumb($breadCrumbs);
       }
     }
     else {
       //set the appropriate action
-      $context       = $this->get('context');
-      $urlString     = 'civicrm/contact/search';
+      $context = $this->get('context');
+      $urlString = 'civicrm/contact/search';
       $this->_action = CRM_Core_Action::BASIC;
       switch ($context) {
         case 'advanced':
@@ -527,11 +530,8 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
       }
     }
 
-    list($defaults[$this->_id]['register_date'],
-      $defaults[$this->_id]['register_date_time']
-    ) = CRM_Utils_Date::setDateDefaults(
-      CRM_Utils_Array::value('register_date', $defaults[$this->_id]), 'activityDateTime'
-    );
+    list($defaults[$this->_id]['register_date'], $defaults[$this->_id]['register_date_time'])
+      = CRM_Utils_Date::setDateDefaults(CRM_Utils_Array::value('register_date', $defaults[$this->_id]), 'activityDateTime');
 
     //assign event and role id, this is needed for Custom data building
     $sep = CRM_Core_DAO::VALUE_SEPARATOR;
@@ -542,7 +542,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
       $eventID = $_POST['event_id'];
     }
 
-    if($this->_eID) {
+    if ($this->_eID) {
       $eventID = $this->_eID;
       //@todo - rationalise the $this->_eID with $POST['event_id'],  $this->_eid is set when eid=x is in the url
       $roleID = CRM_Core_DAO::getFieldValue(
@@ -550,7 +550,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
         $this->_eID,
         'default_role_id'
       );
-      if(empty($roleIDs)) {
+      if (empty($roleIDs)) {
         $roleIDs = (array) $defaults[$this->_id]['participant_role_id'] = $roleID;
       }
       $defaults[$this->_id]['event_id'] = $eventID;
@@ -560,7 +560,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
     }
     //these should take precedence so we state them last
     $urlRoleIDS = CRM_Utils_Request::retrieve('roles', 'String');
-    if($urlRoleIDS) {
+    if ($urlRoleIDS) {
       $roleIDs = explode(',', $urlRoleIDS);
     }
     if (isset($roleIDs)) {
@@ -581,7 +581,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
   }
 
   /**
-   * Build the form object
+   * Build the form object.
    *
    * @return void
    */
@@ -612,7 +612,8 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
             TRUE
           )) - 1;
         if ($additionalParticipant) {
-          $deleteParticipants = array(1 => ts('Delete this participant record along with associated participant record(s).'),
+          $deleteParticipants = array(
+            1 => ts('Delete this participant record along with associated participant record(s).'),
             2 => ts('Delete only this participant record.'),
           );
           $this->addRadio('delete_participant', NULL, $deleteParticipants, NULL, '<br />');
@@ -636,9 +637,11 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
       return;
     }
 
-
     if ($this->_single && $this->_context == 'standalone') {
-      $this->addEntityRef('contact_id', ts('Contact'), array('create' => TRUE, 'api' => array('extra' => array('email'))), TRUE);
+      $this->addEntityRef('contact_id', ts('Contact'), array(
+          'create' => TRUE,
+          'api' => array('extra' => array('email')),
+        ), TRUE);
     }
 
     $eventFieldParams = array(
@@ -646,7 +649,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
       'select' => array('minimumInputLength' => 0),
       'api' => array(
         'extra' => array('campaign_id', 'default_role_id', 'event_type_id'),
-      )
+      ),
     );
 
     if ($this->_mode) {
@@ -660,8 +663,9 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
     //frozen the field fix for CRM-4171
     if ($this->_action & CRM_Core_Action::UPDATE && $this->_id) {
       if (CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment',
-          $this->_id, 'contribution_id', 'participant_id'
-        )) {
+        $this->_id, 'contribution_id', 'participant_id'
+      )
+      ) {
         $element->freeze();
       }
     }
@@ -696,8 +700,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
         CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name')
       );
       $checkCancelledJs = array(
-        'onchange' =>
-        "checkCancelled( this.value, {$cancelledparticipantStatusId},{$cancelledContributionStatusId});",
+        'onchange' => "checkCancelled( this.value, {$cancelledparticipantStatusId},{$cancelledContributionStatusId});",
       );
 
       $participantStatusId = array_search('Pending from pay later',
@@ -733,7 +736,10 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
       }
     }
 
-    $this->addSelect('status_id', $checkCancelledJs + array('options' => $statusOptions, 'option_url' => 'civicrm/admin/participant_status'), TRUE);
+    $this->addSelect('status_id', $checkCancelledJs + array(
+        'options' => $statusOptions,
+        'option_url' => 'civicrm/admin/participant_status',
+      ), TRUE);
 
     $this->addElement('checkbox', 'is_notify', ts('Send Notification'), NULL);
 
@@ -751,7 +757,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
     $path = CRM_Utils_System::currentPath();
     $excludeForPaths = array(
       'civicrm/contact/search',
-      'civicrm/group/search'
+      'civicrm/group/search',
     );
     if (!in_array($path, $excludeForPaths)) {
       $buttons[] = array(
@@ -774,7 +780,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
   }
 
   /**
-   * Add local and global form rules
+   * Add local and global form rules.
    *
    *
    * @return void
@@ -784,14 +790,15 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
   }
 
   /**
-   * Global validation rules for the form
+   * Global validation rules for the form.
    *
-   * @param array $values posted values of the form
+   * @param array $values
+   *   Posted values of the form.
    * @param $files
    * @param $self
    *
-   * @return array list of errors to be posted back to the form
-   * @static
+   * @return array
+   *   list of errors to be posted back to the form
    */
   public static function formRule($values, $files, $self) {
     // If $values['_qf_Participant_next'] is Delete or
@@ -807,8 +814,8 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
     $errorMsg = array();
 
     if (!empty($values['payment_processor_id'])) {
-      // make sure that credit card number and cvv are valid
-      CRM_Core_Payment_Form::validateCreditCard($values, $errorMsg);
+      // make sure that payment instrument values (e.g. credit card number and cvv) are valid
+      CRM_Core_Payment_Form::validatePaymentInstrument($values['payment_processor_id'], $values, $errorMsg, $self);
     }
 
     if (!empty($values['record_contribution'])) {
@@ -842,15 +849,15 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
     }
     // For single additions - show validation error if the contact has already been registered
     // for this event with the same role.
-    if($self->_single && ($self->_action & CRM_Core_Action::ADD)) {
+    if ($self->_single && ($self->_action & CRM_Core_Action::ADD)) {
       $contactId = $self->_contactId;
       $eventId = CRM_Utils_Array::value('event_id', $values);
-      if(!empty($contactId) && !empty($eventId)) {
-        $dupeCheck = new CRM_Event_BAO_Participant;
+      if (!empty($contactId) && !empty($eventId)) {
+        $dupeCheck = new CRM_Event_BAO_Participant();
         $dupeCheck->contact_id = $contactId;
         $dupeCheck->event_id = $eventId;
         $dupeCheck->find(TRUE);
-        if(!empty($dupeCheck->id)) {
+        if (!empty($dupeCheck->id)) {
           $errorMsg['event_id'] = ts("This contact has already been assigned to this event.");
         }
       }
@@ -859,8 +866,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
   }
 
   /**
-   * Process the form submission
-   *
+   * Process the form submission.
    */
   public function postProcess() {
     // get the submitted form values.
@@ -880,7 +886,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
       CRM_Event_BAO_Participant::deleteParticipant($this->_id);
       CRM_Core_Session::setStatus(ts('Selected participant was deleted successfully.'), ts('Record Deleted'), 'success');
       if (!empty($participantLinks)) {
-        $status = ts('The following participants no longer have an event fee recorded. You can edit their registration and record a replacement contribution by clicking the links below:') . '<br>' . $participantLinks;
+        $status = ts('The following participants no longer have an event fee recorded. You can edit their registration and record a replacement contribution by clicking the links below:') . '<br/>' . $participantLinks;
         CRM_Core_Session::setStatus($status, ts('Group Payment Deleted'));
       }
       return;
@@ -890,30 +896,30 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
     // removed automatically and the user receives one notification.
     if ($this->_action & CRM_Core_Action::ADD) {
       $event_id = $this->_eventId;
-      if(empty($event_id) && !empty($params['event_id'])) {
+      if (empty($event_id) && !empty($params['event_id'])) {
         $event_id = $params['event_id'];
       }
-      if(!$this->_single && !empty($event_id)) {
+      if (!$this->_single && !empty($event_id)) {
         $duplicateContacts = 0;
-        while(list($k,$dupeCheckContactId) = each($this->_contactIds)) {
+        while (list($k, $dupeCheckContactId) = each($this->_contactIds)) {
           // Eliminate contacts that have already been assigned to this event.
-          $dupeCheck = new CRM_Event_BAO_Participant;
+          $dupeCheck = new CRM_Event_BAO_Participant();
           $dupeCheck->contact_id = $dupeCheckContactId;
           $dupeCheck->event_id = $event_id;
           $dupeCheck->find(TRUE);
-          if(!empty($dupeCheck->id)) {
+          if (!empty($dupeCheck->id)) {
             $duplicateContacts++;
             unset($this->_contactIds[$k]);
           }
         }
-        if($duplicateContacts > 0) {
+        if ($duplicateContacts > 0) {
           $msg = ts(
             "%1 contacts have already been assigned to this event. They were not added a second time.",
             array(1 => $duplicateContacts)
           );
           CRM_Core_Session::setStatus($msg);
         }
-        if(count($this->_contactIds) == 0) {
+        if (count($this->_contactIds) == 0) {
           CRM_Core_Session::setStatus(ts("No participants were added."));
           return;
         }
@@ -924,7 +930,6 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
       }
     }
 
-
     $participantStatus = CRM_Event_PseudoConstant::participantStatus();
     // set the contact, when contact is selected
     if (!empty($params['contact_id'])) {
@@ -995,9 +1000,11 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
         $params['fee_level'] = $params['amount_level'];
         $contributionParams['total_amount'] = $params['amount'];
         if ($this->_quickConfig && !empty($params['total_amount']) &&
-          $params['status_id'] != array_search('Partially paid', $participantStatus)) {
+          $params['status_id'] != array_search('Partially paid', $participantStatus)
+        ) {
           $params['fee_amount'] = $params['total_amount'];
-        } else {
+        }
+        else {
           //fix for CRM-3086
           $params['fee_amount'] = $params['amount'];
         }
@@ -1007,8 +1014,8 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
         if (!empty($lineItem[0])) {
           $this->set('lineItem', $lineItem);
 
-          $this->_lineItem  = $lineItem;
-          $lineItem         = array_merge($lineItem, $additionalParticipantDetails);
+          $this->_lineItem = $lineItem;
+          $lineItem = array_merge($lineItem, $additionalParticipantDetails);
 
           $participantCount = array();
           foreach ($lineItem as $k) {
@@ -1022,7 +1029,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
         if (isset($participantCount)) {
           $this->assign('pricesetFieldsCount', $participantCount);
         }
-         $this->assign('lineItem', empty($lineItem[0]) || $this->_quickConfig? FALSE : $lineItem);
+        $this->assign('lineItem', empty($lineItem[0]) || $this->_quickConfig ? FALSE : $lineItem);
       }
       else {
         $this->assign('amount_level', $params['amount_level']);
@@ -1044,13 +1051,12 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
       $contributionParams['total_amount'] = CRM_Utils_Array::value('total_amount', $params);
     }
 
-
     // Retrieve the name and email of the current user - this will be the FROM for the receipt email
     $session = CRM_Core_Session::singleton();
     $userID = $session->get('userID');
     list($userName,
       $userEmail
-    ) = CRM_Contact_BAO_Contact_Location::getEmailDetails($userID);
+      ) = CRM_Contact_BAO_Contact_Location::getEmailDetails($userID);
 
     if ($this->_contactId) {
       list($this->_contributorDisplayName, $this->_contributorEmail, $this->_toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($this->_contactId);
@@ -1068,8 +1074,8 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
         CRM_Core_Error::fatal(ts('Selected Event is not Paid Event '));
       }
 
-      $eventTitle =
-        CRM_Core_DAO::getFieldValue(
+      $eventTitle
+        CRM_Core_DAO::getFieldValue(
           'CRM_Event_DAO_Event',
           $params['event_id'],
           'title'
@@ -1077,7 +1083,10 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
 
       // set source if not set
       if (empty($params['source'])) {
-        $this->_params['participant_source'] = ts('Offline Registration for Event: %2 by: %1', array(1 => $userName, 2 => $eventTitle));
+        $this->_params['participant_source'] = ts('Offline Registration for Event: %2 by: %1', array(
+            1 => $userName,
+            2 => $eventTitle,
+          ));
       }
       else {
         $this->_params['participant_source'] = $params['source'];
@@ -1102,8 +1111,8 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
       }
 
       // also add location name to the array
-      $params["address_name-{$this->_bltID}"] =
-        CRM_Utils_Array::value('billing_first_name', $params)  . ' ' .
+      $params["address_name-{$this->_bltID}"]
+        = CRM_Utils_Array::value('billing_first_name', $params) . ' ' .
         CRM_Utils_Array::value('billing_middle_name', $params) . ' ' .
         CRM_Utils_Array::value('billing_last_name', $params);
 
@@ -1155,7 +1164,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
     }
 
     //do cleanup line  items if participant edit the Event Fee.
-      if (($this->_lineItem || !isset($params['proceSetId'])) && !$this->_paymentId && $this->_id) {
+    if (($this->_lineItem || !isset($params['proceSetId'])) && !$this->_paymentId && $this->_id) {
       CRM_Price_BAO_LineItem::deleteLineItems($this->_id, 'civicrm_participant');
     }
 
@@ -1191,8 +1200,8 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
       if (is_a($result, 'CRM_Core_Error')) {
         CRM_Core_Error::displaySessionError($result);
         CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/participant',
-            "reset=1&action=add&cid={$this->_contactId}&context=participant&mode={$this->_mode}"
-          ));
+          "reset=1&action=add&cid={$this->_contactId}&context=participant&mode={$this->_mode}"
+        ));
       }
 
       if ($result) {
@@ -1215,8 +1224,8 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
       );
 
       //add contribution record
-      $this->_params['financial_type_id'] =
-        CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $params['event_id'], 'financial_type_id');
+      $this->_params['financial_type_id']
+        CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $params['event_id'], 'financial_type_id');
       $this->_params['mode'] = $this->_mode;
 
       //add contribution reocord
@@ -1231,7 +1240,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
       }
 
       //CRM-15372 patch to fix fee amount replacing amount
-      $this->_params['fee_amount'] =  $this->_params['amount'];
+      $this->_params['fee_amount'] = $this->_params['amount'];
 
       $participants[] = CRM_Event_Form_Registration::addParticipant($this, $contactID);
 
@@ -1307,7 +1316,10 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
         //build contribution params
         if (!$this->_onlinePendingContributionId) {
           if (empty($params['source'])) {
-            $contributionParams['source'] = ts('%1 : Offline registration (by %2)', array(1 => $eventTitle, 2 => $userName));
+            $contributionParams['source'] = ts('%1 : Offline registration (by %2)', array(
+                1 => $eventTitle,
+                2 => $userName,
+              ));
           }
           else {
             $contributionParams['source'] = $params['source'];
@@ -1318,10 +1330,15 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
         $contributionParams['non_deductible_amount'] = 'null';
         $contributionParams['receipt_date'] = !empty($params['send_receipt']) ? CRM_Utils_Array::value('receive_date', $params) : 'null';
 
-        $recordContribution = array( 'contact_id', 'financial_type_id',
-          'payment_instrument_id', 'trxn_id',
-          'contribution_status_id', 'receive_date',
-          'check_number', 'campaign_id',
+        $recordContribution = array(
+          'contact_id',
+          'financial_type_id',
+          'payment_instrument_id',
+          'trxn_id',
+          'contribution_status_id',
+          'receive_date',
+          'check_number',
+          'campaign_id',
         );
 
         foreach ($recordContribution as $f) {
@@ -1404,7 +1421,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
             $feeLevel = $this->_params['amount_priceset_level_radio'];
           }
           else {
-            $feeLevel[] = $this->_params['fee_level'] ;
+            $feeLevel[] = $this->_params['fee_level'];
           }
           CRM_Event_BAO_Participant::createDiscountTrxn($this->_eventId, $contributionParams, $feeLevel);
         }
@@ -1441,7 +1458,8 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
     $updateStatusMsg = NULL;
     //send mail when participant status changed, CRM-4326
     if ($this->_id && $this->_statusId &&
-      $this->_statusId != CRM_Utils_Array::value('status_id', $params) && !empty($params['is_notify'])) {
+      $this->_statusId != CRM_Utils_Array::value('status_id', $params) && !empty($params['is_notify'])
+    ) {
 
       $updateStatusMsg = CRM_Event_BAO_Participant::updateStatusMessage($this->_id,
         $params['status_id'],
@@ -1515,7 +1533,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
         if (isset($contributionParams['partial_payment_total'])) {
           // balance amount
           $balanceAmount = $contributionParams['partial_payment_total'] - $contributionParams['partial_amount_pay'];
-          $this->assign('balanceAmount', $balanceAmount );
+          $this->assign('balanceAmount', $balanceAmount);
         }
         $this->assign('isPrimary', 1);
         $this->assign('checkNumber', CRM_Utils_Array::value('check_number', $params));
@@ -1607,7 +1625,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
         if ($this->_isPaidEvent) {
           // fix amount for each of participants ( for bulk mode )
           $eventAmount = array();
-          $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME,'contribution_invoice_settings');
+          $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
           $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
           $totalTaxAmount = 0;
 
@@ -1654,7 +1672,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
           'valueName' => 'event_offline_receipt',
           'contactId' => $contactID,
           'isTest' => (bool) CRM_Utils_Array::value('is_test', $this->_defaultValues),
-          'PDFFilename' => ts('confirmation').'.pdf',
+          'PDFFilename' => ts('confirmation') . '.pdf',
         );
 
         // try to send emails only if email id is present
@@ -1668,15 +1686,15 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
         }
 
         //send email with pdf invoice
-        $template = CRM_Core_Smarty::singleton( );
+        $template = CRM_Core_Smarty::singleton();
         $taxAmt = $template->get_template_vars('dataArray');
         $contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment',
-                                                      $this->_id, 'contribution_id', 'participant_id'
-                                                      );
+          $this->_id, 'contribution_id', 'participant_id'
+        );
         $prefixValue = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
         $invoicing = CRM_Utils_Array::value('invoicing', $prefixValue);
         if (count($taxAmt) > 0 && (isset($invoicing) && isset($prefixValue['is_email_pdf']))) {
-          $sendTemplateParams['isEmailPdf'] = True;
+          $sendTemplateParams['isEmailPdf'] = TRUE;
           $sendTemplateParams['contributionId'] = $contributionId;
         }
         list($mailSent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
@@ -1744,14 +1762,15 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
       }
       else {
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view',
-            "reset=1&cid={$this->_contactId}&selectedChild=participant"
-          ));
+          "reset=1&cid={$this->_contactId}&selectedChild=participant"
+        ));
       }
     }
     elseif ($buttonName == $this->getButtonName('upload', 'new')) {
       $session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view/participant',
-          "reset=1&action=add&context={$this->_context}&cid={$this->_contactId}"
-        ));
+        "reset=1&action=add&context={$this->_context}&cid={$this->_contactId}"
+      ));
     }
   }
+
 }