<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
* $Id$
*
*/
-
class CRM_Financial_BAO_FinancialTypeAccount extends CRM_Financial_DAO_EntityFinancialAccount {
/**
* Class constructor
*/
- function __construct( ) {
- parent::__construct( );
+ public function __construct() {
+ parent::__construct();
}
/**
* Financial account
* @var array
- * @static
*/
private static $financialAccount;
/**
* Fetch object based on array of properties
*
- * @param array $params (reference ) an assoc array of name/value pairs
- * @param array $defaults (reference ) an assoc array to hold the flattened values
+ * @param array $params
+ * (reference ) an assoc array of name/value pairs.
+ * @param array $defaults
+ * (reference ) an assoc array to hold the flattened values.
*
* @param array $allValues
*
- * @return CRM_Contribute_BAO_ContributionType object
- * @access public
- * @static
+ * @return CRM_Contribute_BAO_ContributionType
*/
- static function retrieve(&$params, &$defaults, &$allValues = array()) {
+ public static function retrieve(&$params, &$defaults, &$allValues = array()) {
$financialTypeAccount = new CRM_Financial_DAO_EntityFinancialAccount();
$financialTypeAccount->copyValues($params);
$financialTypeAccount->find();
/**
* Add the financial types
*
- * @param array $params reference array contains the values submitted by the form
- * @param array $ids reference array contains the id
+ * @param array $params
+ * Reference array contains the values submitted by the form.
+ * @param array $ids
+ * Reference array contains the id.
*
- * @access public
- * @static
* @return object
*/
- static function add(&$params, &$ids = NULL) {
+ public static function add(&$params, &$ids = NULL) {
// action is taken depending upon the mode
$financialTypeAccount = new CRM_Financial_DAO_EntityFinancialAccount();
if ($params['entity_table'] != 'civicrm_financial_type') {
* @param int $financialTypeAccountId
* @param int $accountId
*
- * @static
*/
- static function del($financialTypeAccountId, $accountId = null) {
+ public static function del($financialTypeAccountId, $accountId = NULL) {
//checking if financial type is present
- $check = false;
+ $check = FALSE;
$relationValues = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship');
- $financialTypeId = CRM_Core_DAO::getFieldValue( 'CRM_Financial_DAO_EntityFinancialAccount', $financialTypeAccountId, 'entity_id' );
+ $financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_EntityFinancialAccount', $financialTypeAccountId, 'entity_id');
//check dependencies
// FIXME more table containing financial_type_id to come
$dependancy = array(
$daoString = 'CRM_' . $name[0] . '_DAO_' . $name[1];
$dao = new $daoString();
$dao->financial_type_id = $financialTypeId;
- if ($dao->find(true)) {
- $check = true;
+ if ($dao->find(TRUE)) {
+ $check = TRUE;
break;
}
}
}
else {
$accountRelationShipId = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_EntityFinancialAccount', $financialTypeAccountId, 'account_relationship');
- CRM_Core_Session::setStatus(ts('You cannot remove an account with a %1 relationship because it is being referenced by one or more of the following types of records: Contributions, Contribution Pages, or Membership Types. Consider disabling this type instead if you no longer want it used.', array(1 => $relationValues[$accountRelationShipId])), NUll, 'error');
+ CRM_Core_Session::setStatus(ts('You cannot remove an account with a %1 relationship because it is being referenced by one or more of the following types of records: Contributions, Contribution Pages, or Membership Types. Consider disabling this type instead if you no longer want it used.', array(1 => $relationValues[$accountRelationShipId])), NULL, 'error');
}
- return CRM_Utils_System::redirect( CRM_Utils_System::url( 'civicrm/admin/financial/financialType/accounts', "reset=1&action=browse&aid={$accountId}" ));
+ return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/financial/financialType/accounts', "reset=1&action=browse&aid={$accountId}"));
}
//delete from financial Type table
- $financialType = new CRM_Financial_DAO_EntityFinancialAccount( );
+ $financialType = new CRM_Financial_DAO_EntityFinancialAccount();
$financialType->id = $financialTypeAccountId;
$financialType->find(TRUE);
$financialType->delete();
*
* @param string $entityTable
*
- * @param string $columnName Column to fetch
+ * @param string $columnName
+ * Column to fetch.
*
* @return null|string
- * @static
*/
- static function getFinancialAccount($entityId, $entityTable, $columnName = 'name') {
+ public static function getFinancialAccount($entityId, $entityTable, $columnName = 'name') {
$join = $columnName == 'name' ? 'LEFT JOIN civicrm_financial_account ON civicrm_entity_financial_account.financial_account_id = civicrm_financial_account.id' : NULL;
$query = "
SELECT {$columnName}
/**
* Financial Account for payment instrument
*
- * @param int $paymentInstrumentValue payment instrument value
+ * @param int $paymentInstrumentValue
+ * Payment instrument value.
*
* @return array|null|string
- * @static
*/
- static function getInstrumentFinancialAccount($paymentInstrumentValue = NULL) {
+ public static function getInstrumentFinancialAccount($paymentInstrumentValue = NULL) {
if (!self::$financialAccount) {
$query = "SELECT ceft.financial_account_id, cov.value
FROM civicrm_entity_financial_account ceft
* @param $financialType
*
* @return array
- * @static
*/
- static function createDefaultFinancialAccounts($financialType) {
+ public static function createDefaultFinancialAccounts($financialType) {
$titles = array();
$financialAccountTypeID = CRM_Core_PseudoConstant::accountOptionValues('financial_account_type');
$accountRelationship = CRM_Core_PseudoConstant::accountOptionValues('account_relationship');
- $relationships = array (
+ $relationships = array(
array_search('Accounts Receivable Account is', $accountRelationship) => array_search('Asset', $financialAccountTypeID),
array_search('Expense Account is', $accountRelationship) => array_search('Expenses', $financialAccountTypeID),
array_search('Cost of Sales Account is', $accountRelationship) => array_search('Cost of Sales', $financialAccountTypeID),
array_search('Income Account is', $accountRelationship) => array_search('Revenue', $financialAccountTypeID),
);
- $dao = CRM_Core_DAO::executeQuery('SELECT id, financial_account_type_id FROM civicrm_financial_account WHERE name LIKE %1',
+ $dao = CRM_Core_DAO::executeQuery('SELECT id, financial_account_type_id FROM civicrm_financial_account WHERE name LIKE %1',
array(1 => array($financialType->name, 'String'))
);
$dao->fetch();
else {
$existingFinancialAccount[$dao->financial_account_type_id] = $dao->id;
}
- $params = array (
+ $params = array(
'entity_table' => 'civicrm_financial_type',
'entity_id' => $financialType->id,
);
}
}
else {
- $params['financial_account_id'] = $existingFinancialAccount[$value];
- $titles[] = $financialType->name;
+ $params['financial_account_id'] = $existingFinancialAccount[$value];
+ $titles[] = $financialType->name;
}
$params['account_relationship'] = $key;
self::add($params);
}
return $titles;
}
-}
+}