/** * Create the financial Items and financial enity trxn. * * @param array $params * Associated array to create financial items. * @param array $ids * Financial item ids. * @param array $trxnIds * Financial item ids. * * @return object */ public static function create(&$params, $ids = NULL, $trxnIds = NULL) { $financialItem = new CRM_Financial_DAO_FinancialItem(); if (!empty($ids['id'])) { CRM_Utils_Hook::pre('edit', 'FinancialItem', $ids['id'], $params); } else { CRM_Utils_Hook::pre('create', 'FinancialItem', NULL, $params); } $financialItem->copyValues($params); if (!empty($ids['id'])) { $financialItem->id = $ids['id']; } $financialItem->save(); if (!empty($trxnIds['id'])) { $entity_financial_trxn_params = array('entity_table' => "civicrm_financial_item", 'entity_id' => $financialItem->id, 'financial_trxn_id' => $trxnIds['id'], 'amount' => $params['amount']); $entity_trxn = new CRM_Financial_DAO_EntityFinancialTrxn(); $entity_trxn->copyValues($entity_financial_trxn_params); if (!empty($ids['entityFinancialTrxnId'])) { $entity_trxn->id = $ids['entityFinancialTrxnId']; } $entity_trxn->save(); } if (!empty($ids['id'])) { CRM_Utils_Hook::post('edit', 'FinancialItem', $financialItem->id, $financialItem); } else { CRM_Utils_Hook::post('create', 'FinancialItem', $financialItem->id, $financialItem); } return $financialItem; }
/** * function to create the financial Items and financial enity trxn * * @param array $params associated array to create financial items * @param array $ids financial item ids * @param array $trxnIds financial item ids * * @access public * @static * @return object */ static function create(&$params, $ids = NULL, $trxnIds = NULL) { $financialItem = new CRM_Financial_DAO_FinancialItem(); $financialItem->copyValues($params); if (!empty($ids['id'])) { $financialItem->id = $ids['id']; } $financialItem->save(); if (!empty($trxnIds['id'])) { $entity_financial_trxn_params = array('entity_table' => "civicrm_financial_item", 'entity_id' => $financialItem->id, 'financial_trxn_id' => $trxnIds['id'], 'amount' => $params['amount']); $entity_trxn = new CRM_Financial_DAO_EntityFinancialTrxn(); $entity_trxn->copyValues($entity_financial_trxn_params); if (!empty($ids['entityFinancialTrxnId'])) { $entity_trxn->id = $ids['entityFinancialTrxnId']; } $entity_trxn->save(); } return $financialItem; }
/** * Returns the list of fields that can be exported * * @param bool $prefix * * @return array */ static function &export($prefix = false) { if (!self::$_export) { self::$_export = array(); $fields = self::fields(); foreach ($fields as $name => $field) { if (CRM_Utils_Array::value('export', $field)) { if ($prefix) { self::$_export['financial_item'] =& $fields[$name]; } else { self::$_export[$name] =& $fields[$name]; } } } } return self::$_export; }
/** * Create the financial Items and financial entity trxn. * * @param array $params * Associated array to create financial items. * @param array $ids * Financial item ids. * @param array $trxnIds * Financial item ids. * * @return CRM_Financial_DAO_FinancialItem */ public static function create(&$params, $ids = NULL, $trxnIds = NULL) { $financialItem = new CRM_Financial_DAO_FinancialItem(); if (!empty($ids['id'])) { CRM_Utils_Hook::pre('edit', 'FinancialItem', $ids['id'], $params); } else { CRM_Utils_Hook::pre('create', 'FinancialItem', NULL, $params); } $financialItem->copyValues($params); if (!empty($ids['id'])) { $financialItem->id = $ids['id']; } $financialItem->save(); $financialtrxnIDS = CRM_Utils_Array::value('id', $trxnIds); if (!empty($financialtrxnIDS)) { if (!is_array($financialtrxnIDS)) { $financialtrxnIDS = array($financialtrxnIDS); } foreach ($financialtrxnIDS as $tID) { $entity_financial_trxn_params = array('entity_table' => "civicrm_financial_item", 'entity_id' => $financialItem->id, 'financial_trxn_id' => $tID, 'amount' => $params['amount']); if (!empty($ids['entityFinancialTrxnId'])) { $entity_financial_trxn_params['id'] = $ids['entityFinancialTrxnId']; } self::createEntityTrxn($entity_financial_trxn_params); } } if (!empty($ids['id'])) { CRM_Utils_Hook::post('edit', 'FinancialItem', $financialItem->id, $financialItem); } else { CRM_Utils_Hook::post('create', 'FinancialItem', $financialItem->id, $financialItem); } return $financialItem; }