03e3669020e188cc98ada19334b71b976f34734c
[civicrm-core.git] / CRM / Financial / DAO / EntityFinancialAccount.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Financial/EntityFinancialAccount.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:caf02136c148fe50dbc39d8d29605f72)
10 */
11
12 /**
13 * Database access object for the EntityFinancialAccount entity.
14 */
15 class CRM_Financial_DAO_EntityFinancialAccount extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '4.3';
18 const COMPONENT = 'CiviContribute';
19
20 /**
21 * Static instance to hold the table name.
22 *
23 * @var string
24 */
25 public static $_tableName = 'civicrm_entity_financial_account';
26
27 /**
28 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 *
30 * @var bool
31 */
32 public static $_log = TRUE;
33
34 /**
35 * ID
36 *
37 * @var int
38 */
39 public $id;
40
41 /**
42 * Links to an entity_table like civicrm_financial_type
43 *
44 * @var string
45 */
46 public $entity_table;
47
48 /**
49 * Links to an id in the entity_table, such as vid in civicrm_financial_type
50 *
51 * @var int
52 */
53 public $entity_id;
54
55 /**
56 * FK to a new civicrm_option_value (account_relationship)
57 *
58 * @var int
59 */
60 public $account_relationship;
61
62 /**
63 * FK to the financial_account_id
64 *
65 * @var int
66 */
67 public $financial_account_id;
68
69 /**
70 * Class constructor.
71 */
72 public function __construct() {
73 $this->__table = 'civicrm_entity_financial_account';
74 parent::__construct();
75 }
76
77 /**
78 * Returns localized title of this entity.
79 *
80 * @param bool $plural
81 * Whether to return the plural version of the title.
82 */
83 public static function getEntityTitle($plural = FALSE) {
84 return $plural ? ts('Entity Financial Accounts') : ts('Entity Financial Account');
85 }
86
87 /**
88 * Returns foreign keys and entity references.
89 *
90 * @return array
91 * [CRM_Core_Reference_Interface]
92 */
93 public static function getReferenceColumns() {
94 if (!isset(Civi::$statics[__CLASS__]['links'])) {
95 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
96 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_account_id', 'civicrm_financial_account', 'id');
97 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
98 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
99 }
100 return Civi::$statics[__CLASS__]['links'];
101 }
102
103 /**
104 * Returns all the column names of this table
105 *
106 * @return array
107 */
108 public static function &fields() {
109 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
110 Civi::$statics[__CLASS__]['fields'] = [
111 'id' => [
112 'name' => 'id',
113 'type' => CRM_Utils_Type::T_INT,
114 'title' => ts('Entity Financial Account ID'),
115 'description' => ts('ID'),
116 'required' => TRUE,
117 'where' => 'civicrm_entity_financial_account.id',
118 'table_name' => 'civicrm_entity_financial_account',
119 'entity' => 'EntityFinancialAccount',
120 'bao' => 'CRM_Financial_DAO_EntityFinancialAccount',
121 'localizable' => 0,
122 'html' => [
123 'type' => 'Number',
124 ],
125 'readonly' => TRUE,
126 'add' => '4.3',
127 ],
128 'entity_table' => [
129 'name' => 'entity_table',
130 'type' => CRM_Utils_Type::T_STRING,
131 'title' => ts('Entity Table'),
132 'description' => ts('Links to an entity_table like civicrm_financial_type'),
133 'required' => TRUE,
134 'maxlength' => 64,
135 'size' => CRM_Utils_Type::BIG,
136 'import' => TRUE,
137 'where' => 'civicrm_entity_financial_account.entity_table',
138 'export' => TRUE,
139 'table_name' => 'civicrm_entity_financial_account',
140 'entity' => 'EntityFinancialAccount',
141 'bao' => 'CRM_Financial_DAO_EntityFinancialAccount',
142 'localizable' => 0,
143 'add' => '4.3',
144 ],
145 'entity_id' => [
146 'name' => 'entity_id',
147 'type' => CRM_Utils_Type::T_INT,
148 'title' => ts('Entity ID'),
149 'description' => ts('Links to an id in the entity_table, such as vid in civicrm_financial_type'),
150 'required' => TRUE,
151 'where' => 'civicrm_entity_financial_account.entity_id',
152 'table_name' => 'civicrm_entity_financial_account',
153 'entity' => 'EntityFinancialAccount',
154 'bao' => 'CRM_Financial_DAO_EntityFinancialAccount',
155 'localizable' => 0,
156 'add' => '4.3',
157 ],
158 'account_relationship' => [
159 'name' => 'account_relationship',
160 'type' => CRM_Utils_Type::T_INT,
161 'title' => ts('Account Relationship'),
162 'description' => ts('FK to a new civicrm_option_value (account_relationship)'),
163 'required' => TRUE,
164 'where' => 'civicrm_entity_financial_account.account_relationship',
165 'table_name' => 'civicrm_entity_financial_account',
166 'entity' => 'EntityFinancialAccount',
167 'bao' => 'CRM_Financial_DAO_EntityFinancialAccount',
168 'localizable' => 0,
169 'html' => [
170 'type' => 'Select',
171 ],
172 'pseudoconstant' => [
173 'optionGroupName' => 'account_relationship',
174 'optionEditPath' => 'civicrm/admin/options/account_relationship',
175 ],
176 'add' => '4.3',
177 ],
178 'financial_account_id' => [
179 'name' => 'financial_account_id',
180 'type' => CRM_Utils_Type::T_INT,
181 'title' => ts('Financial Account ID'),
182 'description' => ts('FK to the financial_account_id'),
183 'required' => TRUE,
184 'where' => 'civicrm_entity_financial_account.financial_account_id',
185 'table_name' => 'civicrm_entity_financial_account',
186 'entity' => 'EntityFinancialAccount',
187 'bao' => 'CRM_Financial_DAO_EntityFinancialAccount',
188 'localizable' => 0,
189 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
190 'html' => [
191 'type' => 'Select',
192 'label' => ts("Financial Account"),
193 ],
194 'pseudoconstant' => [
195 'table' => 'civicrm_financial_account',
196 'keyColumn' => 'id',
197 'labelColumn' => 'name',
198 ],
199 'add' => '4.3',
200 ],
201 ];
202 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
203 }
204 return Civi::$statics[__CLASS__]['fields'];
205 }
206
207 /**
208 * Return a mapping from field-name to the corresponding key (as used in fields()).
209 *
210 * @return array
211 * Array(string $name => string $uniqueName).
212 */
213 public static function &fieldKeys() {
214 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
215 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
216 }
217 return Civi::$statics[__CLASS__]['fieldKeys'];
218 }
219
220 /**
221 * Returns the names of this table
222 *
223 * @return string
224 */
225 public static function getTableName() {
226 return self::$_tableName;
227 }
228
229 /**
230 * Returns if this table needs to be logged
231 *
232 * @return bool
233 */
234 public function getLog() {
235 return self::$_log;
236 }
237
238 /**
239 * Returns the list of fields that can be imported
240 *
241 * @param bool $prefix
242 *
243 * @return array
244 */
245 public static function &import($prefix = FALSE) {
246 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'entity_financial_account', $prefix, []);
247 return $r;
248 }
249
250 /**
251 * Returns the list of fields that can be exported
252 *
253 * @param bool $prefix
254 *
255 * @return array
256 */
257 public static function &export($prefix = FALSE) {
258 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'entity_financial_account', $prefix, []);
259 return $r;
260 }
261
262 /**
263 * Returns the list of indices
264 *
265 * @param bool $localize
266 *
267 * @return array
268 */
269 public static function indices($localize = TRUE) {
270 $indices = [
271 'index_entity_id_entity_table_account_relationship' => [
272 'name' => 'index_entity_id_entity_table_account_relationship',
273 'field' => [
274 0 => 'entity_id',
275 1 => 'entity_table',
276 2 => 'account_relationship',
277 ],
278 'localizable' => FALSE,
279 'unique' => TRUE,
280 'sig' => 'civicrm_entity_financial_account::1::entity_id::entity_table::account_relationship',
281 ],
282 ];
283 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
284 }
285
286 }