Merge pull request #10110 from mattwire/contributor
[civicrm-core.git] / CRM / Financial / DAO / EntityFinancialTrxn.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2017 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26 */
27 /**
28 * @package CRM
29 * @copyright CiviCRM LLC (c) 2004-2017
30 *
31 * Generated from xml/schema/CRM/Financial/EntityFinancialTrxn.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:8650c2685e9d125bed6f9b65ce208621)
34 */
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 /**
38 * CRM_Financial_DAO_EntityFinancialTrxn constructor.
39 */
40 class CRM_Financial_DAO_EntityFinancialTrxn extends CRM_Core_DAO {
41 /**
42 * Static instance to hold the table name.
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_entity_financial_trxn';
47 /**
48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
49 *
50 * @var boolean
51 */
52 static $_log = false;
53 /**
54 * ID
55 *
56 * @var int unsigned
57 */
58 public $id;
59 /**
60 * May contain civicrm_financial_item, civicrm_contribution, civicrm_financial_trxn, civicrm_grant, etc
61 *
62 * @var string
63 */
64 public $entity_table;
65 /**
66 *
67 * @var int unsigned
68 */
69 public $entity_id;
70 /**
71 *
72 * @var int unsigned
73 */
74 public $financial_trxn_id;
75 /**
76 * allocated amount of transaction to this entity
77 *
78 * @var float
79 */
80 public $amount;
81 /**
82 * Class constructor.
83 */
84 function __construct() {
85 $this->__table = 'civicrm_entity_financial_trxn';
86 parent::__construct();
87 }
88 /**
89 * Returns foreign keys and entity references.
90 *
91 * @return array
92 * [CRM_Core_Reference_Interface]
93 */
94 static function getReferenceColumns() {
95 if (!isset(Civi::$statics[__CLASS__]['links'])) {
96 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
97 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'financial_trxn_id', 'civicrm_financial_trxn', 'id');
98 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName() , 'entity_id', NULL, 'id', 'entity_table');
99 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
100 }
101 return Civi::$statics[__CLASS__]['links'];
102 }
103 /**
104 * Returns all the column names of this table
105 *
106 * @return array
107 */
108 static function &fields() {
109 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
110 Civi::$statics[__CLASS__]['fields'] = array(
111 'id' => array(
112 'name' => 'id',
113 'type' => CRM_Utils_Type::T_INT,
114 'title' => ts('Entity Financial Transaction ID') ,
115 'description' => 'ID',
116 'required' => true,
117 'table_name' => 'civicrm_entity_financial_trxn',
118 'entity' => 'EntityFinancialTrxn',
119 'bao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
120 'localizable' => 0,
121 ) ,
122 'entity_table' => array(
123 'name' => 'entity_table',
124 'type' => CRM_Utils_Type::T_STRING,
125 'title' => ts('Entity Table') ,
126 'description' => 'May contain civicrm_financial_item, civicrm_contribution, civicrm_financial_trxn, civicrm_grant, etc',
127 'required' => true,
128 'maxlength' => 64,
129 'size' => CRM_Utils_Type::BIG,
130 'import' => true,
131 'where' => 'civicrm_entity_financial_trxn.entity_table',
132 'headerPattern' => '',
133 'dataPattern' => '',
134 'export' => true,
135 'table_name' => 'civicrm_entity_financial_trxn',
136 'entity' => 'EntityFinancialTrxn',
137 'bao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
138 'localizable' => 0,
139 ) ,
140 'entity_id' => array(
141 'name' => 'entity_id',
142 'type' => CRM_Utils_Type::T_INT,
143 'title' => ts('Entity ID') ,
144 'required' => true,
145 'table_name' => 'civicrm_entity_financial_trxn',
146 'entity' => 'EntityFinancialTrxn',
147 'bao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
148 'localizable' => 0,
149 ) ,
150 'financial_trxn_id' => array(
151 'name' => 'financial_trxn_id',
152 'type' => CRM_Utils_Type::T_INT,
153 'title' => ts('Financial Transaction Id') ,
154 'table_name' => 'civicrm_entity_financial_trxn',
155 'entity' => 'EntityFinancialTrxn',
156 'bao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
157 'localizable' => 0,
158 'FKClassName' => 'CRM_Financial_DAO_FinancialTrxn',
159 ) ,
160 'amount' => array(
161 'name' => 'amount',
162 'type' => CRM_Utils_Type::T_MONEY,
163 'title' => ts('Amount') ,
164 'description' => 'allocated amount of transaction to this entity',
165 'required' => true,
166 'precision' => array(
167 20,
168 2
169 ) ,
170 'import' => true,
171 'where' => 'civicrm_entity_financial_trxn.amount',
172 'headerPattern' => '/amount/i',
173 'dataPattern' => '/^\d+(\.\d{2})?$/',
174 'export' => true,
175 'table_name' => 'civicrm_entity_financial_trxn',
176 'entity' => 'EntityFinancialTrxn',
177 'bao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
178 'localizable' => 0,
179 ) ,
180 );
181 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
182 }
183 return Civi::$statics[__CLASS__]['fields'];
184 }
185 /**
186 * Return a mapping from field-name to the corresponding key (as used in fields()).
187 *
188 * @return array
189 * Array(string $name => string $uniqueName).
190 */
191 static function &fieldKeys() {
192 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
193 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
194 }
195 return Civi::$statics[__CLASS__]['fieldKeys'];
196 }
197 /**
198 * Returns the names of this table
199 *
200 * @return string
201 */
202 static function getTableName() {
203 return self::$_tableName;
204 }
205 /**
206 * Returns if this table needs to be logged
207 *
208 * @return boolean
209 */
210 function getLog() {
211 return self::$_log;
212 }
213 /**
214 * Returns the list of fields that can be imported
215 *
216 * @param bool $prefix
217 *
218 * @return array
219 */
220 static function &import($prefix = false) {
221 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'entity_financial_trxn', $prefix, array());
222 return $r;
223 }
224 /**
225 * Returns the list of fields that can be exported
226 *
227 * @param bool $prefix
228 *
229 * @return array
230 */
231 static function &export($prefix = false) {
232 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'entity_financial_trxn', $prefix, array());
233 return $r;
234 }
235 /**
236 * Returns the list of indices
237 */
238 public static function indices($localize = TRUE) {
239 $indices = array(
240 'UI_entity_financial_trxn_entity_table' => array(
241 'name' => 'UI_entity_financial_trxn_entity_table',
242 'field' => array(
243 0 => 'entity_table',
244 ) ,
245 'localizable' => false,
246 'sig' => 'civicrm_entity_financial_trxn::0::entity_table',
247 ) ,
248 'UI_entity_financial_trxn_entity_id' => array(
249 'name' => 'UI_entity_financial_trxn_entity_id',
250 'field' => array(
251 0 => 'entity_id',
252 ) ,
253 'localizable' => false,
254 'sig' => 'civicrm_entity_financial_trxn::0::entity_id',
255 ) ,
256 );
257 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
258 }
259 }