Add "labelField" metadata to entities
[civicrm-core.git] / CRM / Financial / DAO / FinancialType.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Financial/FinancialType.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:870f3b71b12b41ed1e0e59e1ff57b2db)
10 */
11
12 /**
13 * Database access object for the FinancialType entity.
14 */
15 class CRM_Financial_DAO_FinancialType extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.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_financial_type';
26
27 /**
28 * Field to show when displaying a record.
29 *
30 * @var string
31 */
32 public static $_labelField = 'name';
33
34 /**
35 * Should CiviCRM log any modifications to this table in the civicrm_log table.
36 *
37 * @var bool
38 */
39 public static $_log = TRUE;
40
41 /**
42 * ID of original financial_type so you can search this table by the financial_type.id and then select the relevant version based on the timestamp
43 *
44 * @var int
45 */
46 public $id;
47
48 /**
49 * Financial Type Name.
50 *
51 * @var string
52 */
53 public $name;
54
55 /**
56 * Financial Type Description.
57 *
58 * @var string
59 */
60 public $description;
61
62 /**
63 * Is this financial type tax-deductible? If true, contributions of this type may be fully OR partially deductible - non-deductible amount is stored in the Contribution record.
64 *
65 * @var bool
66 */
67 public $is_deductible;
68
69 /**
70 * Is this a predefined system object?
71 *
72 * @var bool
73 */
74 public $is_reserved;
75
76 /**
77 * Is this property active?
78 *
79 * @var bool
80 */
81 public $is_active;
82
83 /**
84 * Class constructor.
85 */
86 public function __construct() {
87 $this->__table = 'civicrm_financial_type';
88 parent::__construct();
89 }
90
91 /**
92 * Returns localized title of this entity.
93 *
94 * @param bool $plural
95 * Whether to return the plural version of the title.
96 */
97 public static function getEntityTitle($plural = FALSE) {
98 return $plural ? ts('Financial Types') : ts('Financial Type');
99 }
100
101 /**
102 * Returns all the column names of this table
103 *
104 * @return array
105 */
106 public static function &fields() {
107 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
108 Civi::$statics[__CLASS__]['fields'] = [
109 'id' => [
110 'name' => 'id',
111 'type' => CRM_Utils_Type::T_INT,
112 'title' => ts('Financial Type ID'),
113 'description' => ts('ID of original financial_type so you can search this table by the financial_type.id and then select the relevant version based on the timestamp'),
114 'required' => TRUE,
115 'where' => 'civicrm_financial_type.id',
116 'table_name' => 'civicrm_financial_type',
117 'entity' => 'FinancialType',
118 'bao' => 'CRM_Financial_BAO_FinancialType',
119 'localizable' => 0,
120 'add' => '1.3',
121 ],
122 'financial_type' => [
123 'name' => 'name',
124 'type' => CRM_Utils_Type::T_STRING,
125 'title' => ts('Financial Type'),
126 'description' => ts('Financial Type Name.'),
127 'required' => TRUE,
128 'maxlength' => 64,
129 'size' => CRM_Utils_Type::BIG,
130 'import' => TRUE,
131 'where' => 'civicrm_financial_type.name',
132 'headerPattern' => '/(finan(cial)?)?type/i',
133 'dataPattern' => '/donation|member|campaign/i',
134 'export' => TRUE,
135 'table_name' => 'civicrm_financial_type',
136 'entity' => 'FinancialType',
137 'bao' => 'CRM_Financial_BAO_FinancialType',
138 'localizable' => 0,
139 'html' => [
140 'type' => 'Text',
141 'label' => ts("Name"),
142 ],
143 'add' => '1.3',
144 ],
145 'description' => [
146 'name' => 'description',
147 'type' => CRM_Utils_Type::T_STRING,
148 'title' => ts('Description'),
149 'description' => ts('Financial Type Description.'),
150 'maxlength' => 255,
151 'size' => CRM_Utils_Type::HUGE,
152 'where' => 'civicrm_financial_type.description',
153 'table_name' => 'civicrm_financial_type',
154 'entity' => 'FinancialType',
155 'bao' => 'CRM_Financial_BAO_FinancialType',
156 'localizable' => 0,
157 'html' => [
158 'type' => 'TextArea',
159 'label' => ts("Description"),
160 ],
161 'add' => '1.3',
162 ],
163 'is_deductible' => [
164 'name' => 'is_deductible',
165 'type' => CRM_Utils_Type::T_BOOLEAN,
166 'title' => ts('Is Tax Deductible?'),
167 'description' => ts('Is this financial type tax-deductible? If true, contributions of this type may be fully OR partially deductible - non-deductible amount is stored in the Contribution record.'),
168 'required' => TRUE,
169 'where' => 'civicrm_financial_type.is_deductible',
170 'default' => '0',
171 'table_name' => 'civicrm_financial_type',
172 'entity' => 'FinancialType',
173 'bao' => 'CRM_Financial_BAO_FinancialType',
174 'localizable' => 0,
175 'html' => [
176 'type' => 'CheckBox',
177 'label' => ts("Tax-Deductible?"),
178 ],
179 'add' => '1.3',
180 ],
181 'is_reserved' => [
182 'name' => 'is_reserved',
183 'type' => CRM_Utils_Type::T_BOOLEAN,
184 'title' => ts('Financial Type is Reserved?'),
185 'description' => ts('Is this a predefined system object?'),
186 'required' => TRUE,
187 'where' => 'civicrm_financial_type.is_reserved',
188 'default' => '0',
189 'table_name' => 'civicrm_financial_type',
190 'entity' => 'FinancialType',
191 'bao' => 'CRM_Financial_BAO_FinancialType',
192 'localizable' => 0,
193 'html' => [
194 'type' => 'CheckBox',
195 'label' => ts("Reserved?"),
196 ],
197 'add' => '1.3',
198 ],
199 'is_active' => [
200 'name' => 'is_active',
201 'type' => CRM_Utils_Type::T_BOOLEAN,
202 'title' => ts('Financial Type Is Active?'),
203 'description' => ts('Is this property active?'),
204 'required' => TRUE,
205 'where' => 'civicrm_financial_type.is_active',
206 'default' => '1',
207 'table_name' => 'civicrm_financial_type',
208 'entity' => 'FinancialType',
209 'bao' => 'CRM_Financial_BAO_FinancialType',
210 'localizable' => 0,
211 'html' => [
212 'type' => 'CheckBox',
213 'label' => ts("Enabled?"),
214 ],
215 'add' => '1.3',
216 ],
217 ];
218 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
219 }
220 return Civi::$statics[__CLASS__]['fields'];
221 }
222
223 /**
224 * Return a mapping from field-name to the corresponding key (as used in fields()).
225 *
226 * @return array
227 * Array(string $name => string $uniqueName).
228 */
229 public static function &fieldKeys() {
230 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
231 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
232 }
233 return Civi::$statics[__CLASS__]['fieldKeys'];
234 }
235
236 /**
237 * Returns the names of this table
238 *
239 * @return string
240 */
241 public static function getTableName() {
242 return self::$_tableName;
243 }
244
245 /**
246 * Returns if this table needs to be logged
247 *
248 * @return bool
249 */
250 public function getLog() {
251 return self::$_log;
252 }
253
254 /**
255 * Returns the list of fields that can be imported
256 *
257 * @param bool $prefix
258 *
259 * @return array
260 */
261 public static function &import($prefix = FALSE) {
262 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'financial_type', $prefix, []);
263 return $r;
264 }
265
266 /**
267 * Returns the list of fields that can be exported
268 *
269 * @param bool $prefix
270 *
271 * @return array
272 */
273 public static function &export($prefix = FALSE) {
274 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'financial_type', $prefix, []);
275 return $r;
276 }
277
278 /**
279 * Returns the list of indices
280 *
281 * @param bool $localize
282 *
283 * @return array
284 */
285 public static function indices($localize = TRUE) {
286 $indices = [
287 'UI_id' => [
288 'name' => 'UI_id',
289 'field' => [
290 0 => 'id',
291 ],
292 'localizable' => FALSE,
293 'unique' => TRUE,
294 'sig' => 'civicrm_financial_type::1::id',
295 ],
296 ];
297 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
298 }
299
300 }