DAOs with singular/plural options for entity titles
[civicrm-core.git] / CRM / Financial / DAO / EntityFinancialTrxn.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
ca5cec67 5 * @copyright CiviCRM LLC https://civicrm.org/licensing
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/Financial/EntityFinancialTrxn.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
7b66c3b5 9 * (GenCodeChecksum:bbf884307aab01daa88aa7f3c06c2624)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the EntityFinancialTrxn entity.
f41f0342 14 */
e501603b 15class CRM_Financial_DAO_EntityFinancialTrxn extends CRM_Core_DAO {
929a1c14
CW
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '3.2';
c3fc2621 18
e501603b 19 /**
f41f0342 20 * Static instance to hold the table name.
e501603b
TO
21 *
22 * @var string
23 */
fa45b5b9 24 public static $_tableName = 'civicrm_entity_financial_trxn';
c3fc2621 25
e501603b 26 /**
f41f0342 27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 28 *
c3fc2621 29 * @var bool
e501603b 30 */
fa45b5b9 31 public static $_log = FALSE;
c3fc2621 32
e501603b
TO
33 /**
34 * ID
35 *
e6ca0a57 36 * @var int
e501603b
TO
37 */
38 public $id;
c3fc2621 39
e501603b
TO
40 /**
41 * May contain civicrm_financial_item, civicrm_contribution, civicrm_financial_trxn, civicrm_grant, etc
42 *
43 * @var string
44 */
45 public $entity_table;
c3fc2621 46
e501603b 47 /**
e6ca0a57 48 * @var int
e501603b
TO
49 */
50 public $entity_id;
c3fc2621 51
e501603b 52 /**
e6ca0a57 53 * @var int
e501603b
TO
54 */
55 public $financial_trxn_id;
c3fc2621 56
e501603b
TO
57 /**
58 * allocated amount of transaction to this entity
59 *
60 * @var float
61 */
62 public $amount;
c3fc2621 63
e501603b 64 /**
f41f0342 65 * Class constructor.
e501603b 66 */
c3fc2621 67 public function __construct() {
e501603b
TO
68 $this->__table = 'civicrm_entity_financial_trxn';
69 parent::__construct();
70 }
c3fc2621 71
449c4e6b
CW
72 /**
73 * Returns localized title of this entity.
7b66c3b5
AH
74 *
75 * @param bool $plural
76 * Whether to return the plural version of the title.
449c4e6b 77 */
7b66c3b5
AH
78 public static function getEntityTitle($plural = FALSE) {
79 return $plural ? ts('Entity Financial Trxns') : ts('Entity Financial Trxn');
449c4e6b
CW
80 }
81
e501603b 82 /**
f41f0342 83 * Returns foreign keys and entity references.
e501603b
TO
84 *
85 * @return array
86 * [CRM_Core_Reference_Interface]
87 */
c3fc2621 88 public static function getReferenceColumns() {
346aaaba 89 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 90 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
91 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_trxn_id', 'civicrm_financial_trxn', 'id');
92 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
346aaaba 93 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 94 }
346aaaba 95 return Civi::$statics[__CLASS__]['links'];
e501603b 96 }
c3fc2621 97
e501603b
TO
98 /**
99 * Returns all the column names of this table
100 *
101 * @return array
102 */
c3fc2621 103 public static function &fields() {
346aaaba 104 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
105 Civi::$statics[__CLASS__]['fields'] = [
106 'id' => [
e501603b
TO
107 'name' => 'id',
108 'type' => CRM_Utils_Type::T_INT,
c3fc2621 109 'title' => ts('Entity Financial Transaction ID'),
215b423e 110 'description' => ts('ID'),
c3fc2621 111 'required' => TRUE,
a36434b9 112 'where' => 'civicrm_entity_financial_trxn.id',
522a26c9 113 'table_name' => 'civicrm_entity_financial_trxn',
114 'entity' => 'EntityFinancialTrxn',
115 'bao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
6a7e5e5d 116 'localizable' => 0,
a9d0587b 117 'add' => '3.2',
c3fc2621
CW
118 ],
119 'entity_table' => [
e501603b
TO
120 'name' => 'entity_table',
121 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 122 'title' => ts('Entity Table'),
215b423e 123 'description' => ts('May contain civicrm_financial_item, civicrm_contribution, civicrm_financial_trxn, civicrm_grant, etc'),
c3fc2621 124 'required' => TRUE,
e501603b
TO
125 'maxlength' => 64,
126 'size' => CRM_Utils_Type::BIG,
c3fc2621 127 'import' => TRUE,
e501603b 128 'where' => 'civicrm_entity_financial_trxn.entity_table',
c3fc2621 129 'export' => TRUE,
522a26c9 130 'table_name' => 'civicrm_entity_financial_trxn',
131 'entity' => 'EntityFinancialTrxn',
132 'bao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
6a7e5e5d 133 'localizable' => 0,
a9d0587b 134 'add' => '3.2',
c3fc2621
CW
135 ],
136 'entity_id' => [
e501603b
TO
137 'name' => 'entity_id',
138 'type' => CRM_Utils_Type::T_INT,
c3fc2621
CW
139 'title' => ts('Entity ID'),
140 'required' => TRUE,
a36434b9 141 'where' => 'civicrm_entity_financial_trxn.entity_id',
522a26c9 142 'table_name' => 'civicrm_entity_financial_trxn',
143 'entity' => 'EntityFinancialTrxn',
144 'bao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
6a7e5e5d 145 'localizable' => 0,
a9d0587b 146 'add' => '3.2',
c3fc2621
CW
147 ],
148 'financial_trxn_id' => [
e501603b
TO
149 'name' => 'financial_trxn_id',
150 'type' => CRM_Utils_Type::T_INT,
c3fc2621 151 'title' => ts('Financial Transaction Id'),
a36434b9 152 'where' => 'civicrm_entity_financial_trxn.financial_trxn_id',
522a26c9 153 'table_name' => 'civicrm_entity_financial_trxn',
154 'entity' => 'EntityFinancialTrxn',
155 'bao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
6a7e5e5d 156 'localizable' => 0,
e501603b 157 'FKClassName' => 'CRM_Financial_DAO_FinancialTrxn',
a9d0587b 158 'add' => '3.2',
c3fc2621
CW
159 ],
160 'amount' => [
e501603b
TO
161 'name' => 'amount',
162 'type' => CRM_Utils_Type::T_MONEY,
c3fc2621 163 'title' => ts('Amount'),
215b423e 164 'description' => ts('allocated amount of transaction to this entity'),
c3fc2621
CW
165 'required' => TRUE,
166 'precision' => [
e501603b 167 20,
fb607354 168 2,
c3fc2621
CW
169 ],
170 'import' => TRUE,
e501603b
TO
171 'where' => 'civicrm_entity_financial_trxn.amount',
172 'headerPattern' => '/amount/i',
173 'dataPattern' => '/^\d+(\.\d{2})?$/',
c3fc2621 174 'export' => TRUE,
522a26c9 175 'table_name' => 'civicrm_entity_financial_trxn',
176 'entity' => 'EntityFinancialTrxn',
177 'bao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
6a7e5e5d 178 'localizable' => 0,
a9d0587b 179 'add' => '3.2',
c3fc2621
CW
180 ],
181 ];
346aaaba 182 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 183 }
346aaaba 184 return Civi::$statics[__CLASS__]['fields'];
e501603b 185 }
c3fc2621 186
e501603b 187 /**
bd8e0b14 188 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
189 *
190 * @return array
bd8e0b14 191 * Array(string $name => string $uniqueName).
e501603b 192 */
c3fc2621 193 public static function &fieldKeys() {
bd8e0b14
TO
194 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
195 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 196 }
bd8e0b14 197 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 198 }
c3fc2621 199
e501603b
TO
200 /**
201 * Returns the names of this table
202 *
203 * @return string
204 */
c3fc2621 205 public static function getTableName() {
e501603b
TO
206 return self::$_tableName;
207 }
c3fc2621 208
e501603b
TO
209 /**
210 * Returns if this table needs to be logged
211 *
c3fc2621 212 * @return bool
e501603b 213 */
c3fc2621 214 public function getLog() {
e501603b
TO
215 return self::$_log;
216 }
c3fc2621 217
e501603b
TO
218 /**
219 * Returns the list of fields that can be imported
220 *
221 * @param bool $prefix
222 *
223 * @return array
224 */
c3fc2621
CW
225 public static function &import($prefix = FALSE) {
226 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'entity_financial_trxn', $prefix, []);
60808919 227 return $r;
e501603b 228 }
c3fc2621 229
e501603b
TO
230 /**
231 * Returns the list of fields that can be exported
232 *
233 * @param bool $prefix
234 *
235 * @return array
236 */
c3fc2621
CW
237 public static function &export($prefix = FALSE) {
238 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'entity_financial_trxn', $prefix, []);
60808919 239 return $r;
e501603b 240 }
c3fc2621 241
e7a6b91a
AS
242 /**
243 * Returns the list of indices
c3fc2621
CW
244 *
245 * @param bool $localize
246 *
247 * @return array
e7a6b91a
AS
248 */
249 public static function indices($localize = TRUE) {
c3fc2621
CW
250 $indices = [
251 'UI_entity_financial_trxn_entity_table' => [
e7a6b91a 252 'name' => 'UI_entity_financial_trxn_entity_table',
c3fc2621 253 'field' => [
e7a6b91a 254 0 => 'entity_table',
c3fc2621
CW
255 ],
256 'localizable' => FALSE,
e7a6b91a 257 'sig' => 'civicrm_entity_financial_trxn::0::entity_table',
c3fc2621
CW
258 ],
259 'UI_entity_financial_trxn_entity_id' => [
e7a6b91a 260 'name' => 'UI_entity_financial_trxn_entity_id',
c3fc2621 261 'field' => [
e7a6b91a 262 0 => 'entity_id',
c3fc2621
CW
263 ],
264 'localizable' => FALSE,
e7a6b91a 265 'sig' => 'civicrm_entity_financial_trxn::0::entity_id',
c3fc2621
CW
266 ],
267 ];
e7a6b91a
AS
268 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
269 }
c3fc2621 270
e501603b 271}