CCRM-15821 Provide option to notify PCP owner
[civicrm-core.git] / CRM / Contribute / BAO / Contribution.php
index 758612be6ddfb0be5cfb4be1740dfdacad3da6eb..a936639b5e8048fe660e9b4f63056bd2bc20f9de 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        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
@@ -38,7 +38,6 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
    * Static field for all the contribution information that we can potentially import
    *
    * @var array
-   * @static
    */
   static $_importableFields = NULL;
 
@@ -46,7 +45,6 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
    * Static field for all the contribution information that we can potentially export
    *
    * @var array
-   * @static
    */
   static $_exportableFields = NULL;
 
@@ -66,16 +64,12 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
    */
   public $_component = NULL;
 
-  /*
-   * construct method
-   */
   /**
    * Class constructor
    *
    * @return \CRM_Contribute_DAO_Contribution
    */
   /**
-   *
    */
   public function __construct() {
     parent::__construct();
@@ -93,12 +87,11 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
    * @param array $ids
    *   The array that holds all the db ids.
    *
-   * @return CRM_Contribute_BAO_Contribution object
-   * @static
+   * @return CRM_Contribute_BAO_Contribution|void
    */
   public static function add(&$params, $ids = array()) {
     if (empty($params)) {
-      return;
+      return NULL;
     }
     //per http://wiki.civicrm.org/confluence/display/CRM/Database+layer we are moving away from $ids array
     $contributionID = CRM_Utils_Array::value('contribution', $ids, CRM_Utils_Array::value('id', $params));
@@ -227,7 +220,6 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
    *   The array that holds all the db ids.
    *
    * @return CRM_Contribute_BAO_Contribution|null the found object or null
-   * @static
    */
   public static function &getValues($params, &$values, &$ids) {
     if (empty($params)) {
@@ -298,8 +290,7 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
    * @param array $ids
    *   The array that holds all the db ids.
    *
-   * @return CRM_Contribute_BAO_Contribution object
-   * @static
+   * @return CRM_Contribute_BAO_Contribution
    */
   public static function create(&$params, $ids = array()) {
     $dateFields = array('receive_date', 'cancel_date', 'receipt_date', 'thankyou_date');
@@ -401,7 +392,11 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
       $softParams['pcp_roll_nickname'] = CRM_Utils_Array::value('pcp_roll_nickname', $pcp);
       $softParams['pcp_personal_note'] = CRM_Utils_Array::value('pcp_personal_note', $pcp);
       $softParams['soft_credit_type_id'] = CRM_Core_OptionGroup::getValue('soft_credit_type', 'pcp', 'name');
-      CRM_Contribute_BAO_ContributionSoft::add($softParams);
+      $contributionSoft = CRM_Contribute_BAO_ContributionSoft::add($softParams);
+      //Send notification to owner for PCP
+      if ($contributionSoft->pcp_id) {
+        CRM_Contribute_Form_Contribution_Confirm::pcpNotifyOwner($contribution, $contributionSoft);
+      }
     }
     if (isset($params['soft_credit'])) {
       $softParams = $params['soft_credit'];
@@ -489,7 +484,6 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
    *   True if we want to resolve the values in the reverse direction (value -> name).
    *
    * @return void
-   * @static
    */
   public static function resolveDefaults(&$defaults, $reverse = FALSE) {
     self::lookupValue($defaults, 'financial_type', CRM_Contribute_PseudoConstant::financialType(), $reverse);
@@ -499,7 +493,7 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
   }
 
   /**
-   * This function is used to convert associative array names to values
+   * convert associative array names to values
    * and vice-versa.
    *
    * This function is used by both the web form layer and the api. Note that
@@ -541,8 +535,7 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
    * @param array $ids
    *   (reference) the array that holds all the db ids.
    *
-   * @return CRM_Contribute_BAO_Contribution object
-   * @static
+   * @return CRM_Contribute_BAO_Contribution
    */
   public static function retrieve(&$params, &$defaults, &$ids) {
     $contribution = CRM_Contribute_BAO_Contribution::getValues($params, $defaults, $ids);
@@ -559,8 +552,8 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
    * @param string $contactType
    * @param bool $status
    *
-   * @return array array of importable Fields
-   * @static
+   * @return array
+   *   array of importable Fields
    */
   public static function &importableFields($contactType = 'Individual', $status = TRUE) {
     if (!self::$_importableFields) {
@@ -644,17 +637,25 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
         'contribution_status' => array(
           'title' => ts('Contribution Status'),
           'name' => 'contribution_status',
-          'data_type' => CRM_Utils_Type::T_STRING
-        )
+          'data_type' => CRM_Utils_Type::T_STRING,
+        ),
+      );
+
+      $contributionPage = array(
+        'contribution_page' => array(
+          'title' => ts('Contribution Page'),
+          'name' => 'contribution_page',
+          'where' => 'civicrm_contribution_page.title',
+          'data_type' => CRM_Utils_Type::T_STRING,
+        ),
       );
 
       $contributionNote = array(
-        'contribution_note' =>
-          array(
-            'title' => ts('Contribution Note'),
-            'name' => 'contribution_note',
-            'data_type' => CRM_Utils_Type::T_TEXT
-          )
+        'contribution_note' => array(
+          'title' => ts('Contribution Note'),
+          'name' => 'contribution_note',
+          'data_type' => CRM_Utils_Type::T_TEXT,
+        ),
       );
 
       $contributionRecurId = array(
@@ -662,14 +663,14 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
           'title' => ts('Recurring Contributions ID'),
           'name' => 'contribution_recur_id',
           'where' => 'civicrm_contribution.contribution_recur_id',
-          'data_type' => CRM_Utils_Type::T_INT
-        )
+          'data_type' => CRM_Utils_Type::T_INT,
+        ),
       );
 
       $extraFields = array(
         'contribution_batch' => array(
-          'title' => ts('Batch Name')
-        )
+          'title' => ts('Batch Name'),
+        ),
       );
 
       $softCreditFields = array(
@@ -677,29 +678,29 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
           'name' => 'contribution_soft_credit_name',
           'title' => 'Soft Credit For',
           'where' => 'civicrm_contact_d.display_name',
-          'data_type' => CRM_Utils_Type::T_STRING
+          'data_type' => CRM_Utils_Type::T_STRING,
         ),
         'contribution_soft_credit_amount' => array(
           'name' => 'contribution_soft_credit_amount',
           'title' => 'Soft Credit Amount',
           'where' => 'civicrm_contribution_soft.amount',
-          'data_type' => CRM_Utils_Type::T_MONEY
+          'data_type' => CRM_Utils_Type::T_MONEY,
         ),
         'contribution_soft_credit_type' => array(
           'name' => 'contribution_soft_credit_type',
           'title' => 'Soft Credit Type',
           'where' => 'contribution_softcredit_type.label',
-          'data_type' => CRM_Utils_Type::T_STRING
+          'data_type' => CRM_Utils_Type::T_STRING,
         ),
         'contribution_soft_credit_contribution_id' => array(
           'name' => 'contribution_soft_credit_contribution_id',
           'title' => 'Soft Credit For Contribution ID',
           'where' => 'civicrm_contribution_soft.contribution_id',
-          'data_type' => CRM_Utils_Type::T_INT
+          'data_type' => CRM_Utils_Type::T_INT,
         ),
       );
 
-      $fields = array_merge($impFields, $typeField, $contributionStatus, $optionField, $expFieldProduct,
+      $fields = array_merge($impFields, $typeField, $contributionStatus, $contributionPage, $optionField, $expFieldProduct,
         $expFieldsContrib, $contributionNote, $contributionRecurId, $extraFields, $softCreditFields, $financialAccount,
         CRM_Core_BAO_CustomField::getFieldsForImport('Contribution')
       );
@@ -771,8 +772,8 @@ INNER JOIN  civicrm_contact contact ON ( contact.id = civicrm_contribution.conta
    *
    * @param int $id
    *
-   * @return mixed|null $results no of deleted Contribution on success, false otherwise@access public
-   * @static
+   * @return mixed|null
+   *   $results no of deleted Contribution on success, false otherwise
    */
   public static function deleteContribution($id) {
     CRM_Utils_Hook::pre('delete', 'Contribution', $id, CRM_Core_DAO::$_nullArray);
@@ -844,12 +845,11 @@ INNER JOIN  civicrm_contact contact ON ( contact.id = civicrm_contribution.conta
    * @param array $input
    *   An assoc array of name/value pairs.
    * @param array $duplicates
-   *   (reference ) store ids of duplicate contribs.
-   *
+   *   (reference) store ids of duplicate contribs.
    * @param int $id
    *
-   * @return boolean true if duplicate, false otherwise
-   * static
+   * @return bool
+   *   true if duplicate, false otherwise
    */
   public static function checkDuplicate($input, &$duplicates, $id = NULL) {
     if (!$id) {
@@ -899,10 +899,9 @@ INNER JOIN  civicrm_contact contact ON ( contact.id = civicrm_contribution.conta
    * pairs
    *
    * @param array $params
-   *   (reference ) an assoc array of name/value pairs.
+   *   (reference) an assoc array of name/value pairs.
    *
-   * @return CRM_Contribute_BAO_ContributionProduct object
-   * @static
+   * @return CRM_Contribute_DAO_ContributionProduct
    */
   public static function addPremium(&$params) {
     $contributionProduct = new CRM_Contribute_DAO_ContributionProduct();
@@ -918,8 +917,8 @@ INNER JOIN  civicrm_contact contact ON ( contact.id = civicrm_contribution.conta
    * @param bool $addExtraFields
    *   True if special fields needs to be added.
    *
-   * @return array the list of contribution fields
-   * @static
+   * @return array
+   *   the list of contribution fields
    */
   public static function getContributionFields($addExtraFields = TRUE) {
     $contributionFields = CRM_Contribute_DAO_Contribution::export();
@@ -948,7 +947,6 @@ INNER JOIN  civicrm_contact contact ON ( contact.id = civicrm_contribution.conta
   /**
    * Add extra fields specific to contribtion
    *
-   * @static
    */
   public static function getSpecialContributionFields() {
     $extraFields = array(
@@ -1015,9 +1013,9 @@ GROUP BY p.id
    * @param int $honorId
    *   In Honor of Contact ID.
    *
-   * @return return the list of contribution fields
+   * @return array
+   *   list of contribution fields
    *
-   * @static
    */
   public static function getHonorContacts($honorId) {
     $params = array();
@@ -1053,8 +1051,8 @@ GROUP BY p.id
    * @param int $id
    *   Id of the contribution.
    *
-   * @return null|string     sort name of the contact if found
-   * @static
+   * @return null|string
+   *   sort name of the contact if found
    */
   public static function sortName($id) {
     $id = CRM_Utils_Type::escape($id, 'Integer');
@@ -1153,8 +1151,8 @@ WHERE  civicrm_contribution.contact_id = civicrm_contact.id
    * @param array $params
    *   An assoc array of name/value pairs.
    *
-   * @return array contribution id if success else NULL
-   * static
+   * @return array
+   *   contribution id if success else NULL
    */
   public static function checkDuplicateIds($params) {
     $dao = new CRM_Contribute_DAO_Contribution();
@@ -1185,9 +1183,9 @@ WHERE  civicrm_contribution.contact_id = civicrm_contact.id
    * @param string $componentIds
    *   Component ids.
    *
-   * @return array associated array
+   * @return array
+   *   associated array
    *
-   * @static
    */
   public static function getContributionDetails($exportMode, $componentIds) {
     $paymentDetails = array();
@@ -1246,11 +1244,10 @@ LEFT JOIN civicrm_option_value contribution_status ON (civicrm_contribution.cont
    * Create address associated with contribution record.
    *
    * @param array $params
-   *   An associated array.
    * @param int $billingLocationTypeID
    *
-   * @return address id
-   * @static
+   * @return int
+   *   address id
    */
   public static function createAddress(&$params, $billingLocationTypeID) {
     $billingFields = array(
@@ -1286,7 +1283,6 @@ LEFT JOIN civicrm_option_value contribution_status ON (civicrm_contribution.cont
    * @param int $contributionId
    * @param int $contactId
    *
-   * @static
    */
   public static function deleteAddress($contributionId = NULL, $contactId = NULL) {
     $clauses = array();
@@ -1331,8 +1327,8 @@ WHERE      $condition
    * @param string $componentName
    *   Event/Membership.
    *
-   * @return $contributionId pending contribution id.
-   * @static
+   * @return int
+   *   pending contribution id.
    */
   public static function checkOnlinePendingContribution($componentId, $componentName) {
     $contributionId = NULL;
@@ -1386,7 +1382,7 @@ LEFT JOIN  civicrm_contribution contribution ON ( componentPayment.contribution_
   }
 
   /**
-   * This function update contribution as well as related objects.
+   * Update contribution as well as related objects.
    */
   public static function transitionComponents($params, $processContributionObject = FALSE) {
     // get minimum required values.
@@ -1588,7 +1584,7 @@ LEFT JOIN  civicrm_contribution contribution ON ( componentPayment.contribution_
               WHERE     membership_id=$membership->id
               ORDER BY  id DESC
               LIMIT     1;";
-            $dao = new CRM_Core_DAO;
+            $dao = new CRM_Core_DAO();
             $dao->query($sql);
             if ($dao->fetch()) {
               if (!empty($dao->membership_type_id)) {
@@ -1742,7 +1738,7 @@ LEFT JOIN  civicrm_contribution contribution ON ( componentPayment.contribution_
   }
 
   /**
-   * This function returns all contribution related object ids.
+   * Returns all contribution related object ids.
    */
   public static function getComponentDetails($contributionId) {
     $componentDetails = $pledgePayment = array();
@@ -1839,7 +1835,8 @@ LEFT JOIN  civicrm_contribution contribution ON ( componentPayment.contribution_
    * @param int $contributorId
    *   Contributor id.
    *
-   * @return array $ids containing organization id and individual id
+   * @return array
+   *   containing organization id and individual id
    */
   public static function getOnbehalfIds($contributionId, $contributorId = NULL) {
 
@@ -1907,7 +1904,6 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac
 
   /**
    * @return array
-   * @static
    */
   public static function getContributionDates() {
     $config = CRM_Core_Config::singleton();
@@ -1939,11 +1935,13 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac
     );
   }
 
-  /*
+  /**
    * Load objects relations to contribution object
    * Objects are stored in the $_relatedObjects property
    * In the first instance we are just moving functionality from BASEIpn -
-   * see http://issues.civicrm.org/jira/browse/CRM-9996
+   * @see http://issues.civicrm.org/jira/browse/CRM-9996
+   *
+   * Note that the unit test for the BaseIPN class tests this function
    *
    * @param array $input
    *   Input as delivered from Payment Processor.
@@ -1953,13 +1951,6 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac
    *   Is Payment processor / contribution page required.
    * @param bool $loadAll
    *   Load all related objects - even where id not passed in? (allows API to call this).
-   * Note that the unit test for the BaseIPN class tests this function
-   */
-  /**
-   * @param $input
-   * @param $ids
-   * @param bool $required
-   * @param bool $loadAll
    *
    * @return bool
    * @throws Exception
@@ -2119,12 +2110,12 @@ WHERE  contribution_id = %1 ";
     return TRUE;
   }
 
-  /*
+  /**
    * Create array of message information - ie. return html version, txt version, to field
    *
    * @param array $input
    *   Incoming information.
-   *  - is_recur - should this be treated as recurring (not sure why you wouldn't
+   *   - is_recur - should this be treated as recurring (not sure why you wouldn't
    *    just check presence of recur object but maintaining legacy approach
    *    to be careful)
    * @param array $ids
@@ -2132,19 +2123,14 @@ WHERE  contribution_id = %1 ";
    * @param array $values
    *   Any values that may have already been compiled by calling process.
    *   This is augmented by values 'gathered' by gatherMessageValues
+   * @param bool $recur
    * @param bool $returnMessageText
    *   Distinguishes between whether to send message or return.
    *   message text. We are working towards this function ALWAYS returning message text & calling
    *   function doing emails / pdfs with it
-   * @return array $messageArray - messages
-   */
-  /**
-   * @param $input
-   * @param $ids
-   * @param $values
-   * @param bool $recur
-   * @param bool $returnMessageText
    *
+   * @return array
+   *   messages
    * @throws Exception
    */
   public function composeMessageArray(&$input, &$ids, &$values, $recur = FALSE, $returnMessageText = TRUE) {
@@ -2268,26 +2254,18 @@ WHERE  contribution_id = %1 ";
     }
   }
 
-  /*
+  /**
    * Gather values for contribution mail - this function has been created
    * as part of CRM-9996 refactoring as a step towards simplifying the composeMessage function
    * Values related to the contribution in question are gathered
    *
    * @param array $input
    *   Input into function (probably from payment processor).
+   * @param array $values
    * @param array $ids
-   *   The set of ids related to the inpurt.
-   *
-   * @return array $values
-   *
-   * NB don't add direct calls to the function as we intend to change the signature
-   */
-  /**
-   * @param $input
-   * @param $values
-   * @param array $ids
+   *   The set of ids related to the input.
    *
-   * @return mixed
+   * @return array
    */
   public function _gatherMessageValues($input, &$values, $ids = array()) {
     // set display address of contributor
@@ -2399,8 +2377,7 @@ WHERE  contribution_id = %1 ";
    *
    * @param $values
    * @param $input
-   * @param $template
-   *   CRM_Core_SMARTY.
+   * @param CRM_Core_SMARTY $template
    * @param bool $recur
    * @param bool $returnMessageText
    *
@@ -2436,7 +2413,7 @@ WHERE  contribution_id = %1 ";
           $softCreditTypes[$key] = $softCredit['soft_credit_type_label'];
           $softCredits[$key] = array(
             'Name' => $softCredit['contact_name'],
-            'Amount' => CRM_Utils_Money::format($softCredit['amount'], $softCredit['currency'])
+            'Amount' => CRM_Utils_Money::format($softCredit['amount'], $softCredit['currency']),
           );
         }
         $template->assign('softCreditTypes', $softCreditTypes);
@@ -2488,7 +2465,6 @@ WHERE  contribution_id = %1 ";
       $values['financial_type_id'] = $this->financial_type_id;
     }
 
-
     $template->assign('trxn_id', $this->trxn_id);
     $template->assign('receive_date',
       CRM_Utils_Date::mysqlToIso($this->receive_date)
@@ -2527,7 +2503,7 @@ WHERE  contribution_id = %1 ";
       $primaryEmail = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Email', $this->_relatedObjects['participant']->contact_id, 'email', 'contact_id');
       $primaryAmount[] = array(
         'label' => $this->_relatedObjects['participant']->fee_level . ' - ' . $primaryEmail,
-        'amount' => $this->_relatedObjects['participant']->fee_amount
+        'amount' => $this->_relatedObjects['participant']->fee_amount,
       );
       //build an array of cId/pId of participants
       $additionalIDs = CRM_Event_BAO_Event::buildCustomProfile($this->_relatedObjects['participant']->id, NULL, $this->_relatedObjects['contact']->id, $isTest, TRUE);
@@ -2556,7 +2532,7 @@ WHERE  contribution_id = %1 ";
           $amount[0] = array('label' => $additional->fee_level, 'amount' => $additional->fee_amount);
           $primaryAmount[] = array(
             'label' => $additional->fee_level . ' - ' . $additionalParticipantInfo,
-            'amount' => $additional->fee_amount
+            'amount' => $additional->fee_amount,
           );
           $additional->save();
           $additional->free();
@@ -2597,8 +2573,7 @@ WHERE  contribution_id = %1 ";
    *
    * @param bool $isNotCancelled
    *
-   * @return boolean
-   * @static
+   * @return bool
    */
   public static function isCancelSubscriptionSupported($contributionId, $isNotCancelled = TRUE) {
     $cacheKeyString = "$contributionId";
@@ -2628,8 +2603,8 @@ WHERE  contribution_id = %1 ";
    * @param int $contributionId
    *   Contribution id.
    *
-   * @return string $status contribution status
-   * @static
+   * @return string
+   *   contribution status
    */
   public static function isSubscriptionCancelled($contributionId) {
     $sql = "
@@ -2656,7 +2631,6 @@ WHERE  contribution_id = %1 ";
    * @param array $financialTrxnValues
    *
    * @return null|object
-   * @static
    */
   public static function recordFinancialAccounts(&$params, $financialTrxnValues = NULL) {
     $skipRecords = $update = $return = $isRelatedId = FALSE;
@@ -2744,7 +2718,7 @@ WHERE  contribution_id = %1 ";
       $skipRecords = TRUE;
       $pendingStatus = array(
         array_search('Pending', $contributionStatuses),
-        array_search('In Progress', $contributionStatuses)
+        array_search('In Progress', $contributionStatuses),
       );
       if (in_array(CRM_Utils_Array::value('contribution_status_id', $params), $pendingStatus)) {
         $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
@@ -2804,7 +2778,6 @@ WHERE  contribution_id = %1 ";
         $params['trxnParams']['trxn_id'] = $params['prevContribution']->trxn_id;
         $params['trxnParams']['status_id'] = $params['prevContribution']->contribution_status_id;
 
-
         if (!(($params['prevContribution']->contribution_status_id == array_search('Pending', $contributionStatuses)
             || $params['prevContribution']->contribution_status_id == array_search('In Progress', $contributionStatuses))
           && $params['contribution']->contribution_status_id == array_search('Completed', $contributionStatuses))
@@ -2958,7 +2931,6 @@ WHERE  contribution_id = %1 ";
    *
    * @param null $skipTrxn
    *
-   * @static
    */
   public static function updateFinancialAccounts(&$params, $context = NULL, $skipTrxn = NULL) {
     $itemAmount = $trxnID = NULL;
@@ -3101,7 +3073,7 @@ WHERE  contribution_id = %1 ";
             'status_id' => $prevfinancialItem->status_id,
             'financial_account_id' => $financialAccount,
             'entity_table' => 'civicrm_line_item',
-            'entity_id' => $fieldValues['id']
+            'entity_id' => $fieldValues['id'],
           );
           CRM_Financial_BAO_FinancialItem::create($itemParams, NULL, $trxnIds);
 
@@ -3133,7 +3105,6 @@ WHERE  contribution_id = %1 ";
    *   List of errors.
    *
    * @return bool
-   * @static
    */
   public static function checkStatusValidation($values, &$fields, &$errors) {
     if (CRM_Utils_System::isNull($values) && !empty($fields['id'])) {
@@ -3148,14 +3119,14 @@ WHERE  contribution_id = %1 ";
       'Completed' => array('Cancelled', 'Refunded'),
       'Pending' => array('Cancelled', 'Completed', 'Failed'),
       'In Progress' => array('Cancelled', 'Completed', 'Failed'),
-      'Refunded' => array('Cancelled', 'Completed')
+      'Refunded' => array('Cancelled', 'Completed'),
     );
 
     if (!in_array($contributionStatuses[$fields['contribution_status_id']], $checkStatus[$contributionStatuses[$values['contribution_status_id']]])) {
       $errors['contribution_status_id'] = ts("Cannot change contribution status from %1 to %2.", array(
-          1 => $contributionStatuses[$values['contribution_status_id']],
-          2 => $contributionStatuses[$fields['contribution_status_id']]
-        ));
+        1 => $contributionStatuses[$values['contribution_status_id']],
+        2 => $contributionStatuses[$fields['contribution_status_id']],
+      ));
     }
   }
 
@@ -3167,7 +3138,6 @@ WHERE  contribution_id = %1 ";
    * @param int $contactId
    *   Contact id.
    *
-   * @static
    */
   public static function deleteContactContribution($contactId) {
     $contribution = new CRM_Contribute_DAO_Contribution();
@@ -3183,12 +3153,10 @@ WHERE  contribution_id = %1 ";
    * @see CRM_Core_DAO::buildOptions
    *
    * @param string $fieldName
-   * @param string $context
-   *   : @see CRM_Core_DAO::buildOptionsContext.
-   * @param array $props
-   *   : whatever is known about this dao object.
+   * @param string $context see CRM_Core_DAO::buildOptionsContext.
+   * @param array $props  whatever is known about this dao object.
    *
-   * @return Array|bool
+   * @return array|bool
    */
   public static function buildOptions($fieldName, $context = NULL, $props = array()) {
     $className = __CLASS__;
@@ -3201,12 +3169,13 @@ WHERE  contribution_id = %1 ";
         if (!empty($props['contribution_page_id'])) {
           $page = civicrm_api('contribution_page', 'getsingle', array(
             'version' => 3,
-            'id' => ($props['contribution_page_id'])
+            'id' => ($props['contribution_page_id']),
           ));
           $types = (array) CRM_Utils_Array::value('payment_processor', $page, 0);
           $params['condition'] = 'id IN (' . implode(',', $types) . ')';
         }
         break;
+
       // CRM-13981 This field was combined with soft_credits in 4.5 but the api still supports it
       case 'honor_type_id':
         $className = 'CRM_Contribute_BAO_ContributionSoft';
@@ -3228,7 +3197,6 @@ WHERE  contribution_id = %1 ";
    * @param string $relationName
    *
    * @return array|bool
-   * @static
    */
   public static function validateFinancialType($financialTypeId, $relationName = 'Expense Account is') {
     $expenseTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE '{$relationName}' "));
@@ -3241,20 +3209,15 @@ WHERE  contribution_id = %1 ";
   }
 
 
-  /*
+  /**
    * Function to record additional payment for partial and refund contributions
    *
    * @param int $contributionId
-   *   is the invoice contribution id (got created after processing participant payment).
-   * @param array $trxnData
-   *   to take user provided input of transaction details.
+   *   is the invoice contribution id (got created after processing participant payment).
+   * @param array $trxnsData
+   *   to take user provided input of transaction details.
    * @param string $paymentType
    *   'owed' for purpose of recording partial payments, 'refund' for purpose of recording refund payments.
-   */
-  /**
-   * @param int $contributionId
-   * @param $trxnsData
-   * @param string $paymentType
    * @param int $participantId
    *
    * @return null|object
@@ -3383,7 +3346,7 @@ WHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']})
           'amount' => $financialTrxn->total_amount,
           'status_id' => array_search('Paid', $financialItemStatus),
           'entity_id' => $lineItemId->id,
-          'entity_table' => 'civicrm_line_item'
+          'entity_table' => 'civicrm_line_item',
         );
         $trxnIds['id'] = $financialTrxn->id;
         CRM_Financial_BAO_FinancialItem::create($addFinancialEntry, NULL, $trxnIds);
@@ -3671,4 +3634,5 @@ WHERE con.id = {$contributionId}
     }
     return $params;
   }
+
 }