Merge pull request #12457 from omarabuhussein/dev/core#253
[civicrm-core.git] / CRM / Financial / DAO / FinancialType.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC (c) 2004-2019
6 *
7 * Generated from xml/schema/CRM/Financial/FinancialType.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:760550280aaa0da48232ebdfb11170f9)
10 */
11
12 /**
13 * Database access object for the FinancialType entity.
14 */
15 class CRM_Financial_DAO_FinancialType extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 static $_tableName = 'civicrm_financial_type';
23
24 /**
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
26 *
27 * @var bool
28 */
29 static $_log = TRUE;
30
31 /**
32 * 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
33 *
34 * @var int unsigned
35 */
36 public $id;
37
38 /**
39 * Financial Type Name.
40 *
41 * @var string
42 */
43 public $name;
44
45 /**
46 * Financial Type Description.
47 *
48 * @var string
49 */
50 public $description;
51
52 /**
53 * 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.
54 *
55 * @var boolean
56 */
57 public $is_deductible;
58
59 /**
60 * Is this a predefined system object?
61 *
62 * @var boolean
63 */
64 public $is_reserved;
65
66 /**
67 * Is this property active?
68 *
69 * @var boolean
70 */
71 public $is_active;
72
73 /**
74 * Class constructor.
75 */
76 public function __construct() {
77 $this->__table = 'civicrm_financial_type';
78 parent::__construct();
79 }
80
81 /**
82 * Returns all the column names of this table
83 *
84 * @return array
85 */
86 public static function &fields() {
87 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
88 Civi::$statics[__CLASS__]['fields'] = [
89 'id' => [
90 'name' => 'id',
91 'type' => CRM_Utils_Type::T_INT,
92 'title' => ts('Financial Type ID'),
93 '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'),
94 'required' => TRUE,
95 'table_name' => 'civicrm_financial_type',
96 'entity' => 'FinancialType',
97 'bao' => 'CRM_Financial_BAO_FinancialType',
98 'localizable' => 0,
99 ],
100 'financial_type' => [
101 'name' => 'name',
102 'type' => CRM_Utils_Type::T_STRING,
103 'title' => ts('Financial Type'),
104 'description' => ts('Financial Type Name.'),
105 'required' => TRUE,
106 'maxlength' => 64,
107 'size' => CRM_Utils_Type::BIG,
108 'import' => TRUE,
109 'where' => 'civicrm_financial_type.name',
110 'headerPattern' => '/(finan(cial)?)?type/i',
111 'dataPattern' => '/donation|member|campaign/i',
112 'export' => TRUE,
113 'table_name' => 'civicrm_financial_type',
114 'entity' => 'FinancialType',
115 'bao' => 'CRM_Financial_BAO_FinancialType',
116 'localizable' => 0,
117 'html' => [
118 'type' => 'Text',
119 'label' => ts("Name"),
120 ],
121 ],
122 'description' => [
123 'name' => 'description',
124 'type' => CRM_Utils_Type::T_STRING,
125 'title' => ts('Description'),
126 'description' => ts('Financial Type Description.'),
127 'maxlength' => 255,
128 'size' => CRM_Utils_Type::HUGE,
129 'table_name' => 'civicrm_financial_type',
130 'entity' => 'FinancialType',
131 'bao' => 'CRM_Financial_BAO_FinancialType',
132 'localizable' => 0,
133 'html' => [
134 'type' => 'TextArea',
135 'label' => ts("Description"),
136 ],
137 ],
138 'is_deductible' => [
139 'name' => 'is_deductible',
140 'type' => CRM_Utils_Type::T_BOOLEAN,
141 'title' => ts('Is Tax Deductible?'),
142 '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.'),
143 'default' => '1',
144 'table_name' => 'civicrm_financial_type',
145 'entity' => 'FinancialType',
146 'bao' => 'CRM_Financial_BAO_FinancialType',
147 'localizable' => 0,
148 'html' => [
149 'type' => 'CheckBox',
150 'label' => ts("Tax-Deductible?"),
151 ],
152 ],
153 'is_reserved' => [
154 'name' => 'is_reserved',
155 'type' => CRM_Utils_Type::T_BOOLEAN,
156 'title' => ts('Financial Type is Reserved?'),
157 'description' => ts('Is this a predefined system object?'),
158 'table_name' => 'civicrm_financial_type',
159 'entity' => 'FinancialType',
160 'bao' => 'CRM_Financial_BAO_FinancialType',
161 'localizable' => 0,
162 'html' => [
163 'type' => 'CheckBox',
164 'label' => ts("Reserved?"),
165 ],
166 ],
167 'is_active' => [
168 'name' => 'is_active',
169 'type' => CRM_Utils_Type::T_BOOLEAN,
170 'title' => ts('Financial Type Is Active?'),
171 'description' => ts('Is this property active?'),
172 'table_name' => 'civicrm_financial_type',
173 'entity' => 'FinancialType',
174 'bao' => 'CRM_Financial_BAO_FinancialType',
175 'localizable' => 0,
176 'html' => [
177 'type' => 'CheckBox',
178 'label' => ts("Enabled?"),
179 ],
180 ],
181 ];
182 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
183 }
184 return Civi::$statics[__CLASS__]['fields'];
185 }
186
187 /**
188 * Return a mapping from field-name to the corresponding key (as used in fields()).
189 *
190 * @return array
191 * Array(string $name => string $uniqueName).
192 */
193 public static function &fieldKeys() {
194 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
195 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
196 }
197 return Civi::$statics[__CLASS__]['fieldKeys'];
198 }
199
200 /**
201 * Returns the names of this table
202 *
203 * @return string
204 */
205 public static function getTableName() {
206 return self::$_tableName;
207 }
208
209 /**
210 * Returns if this table needs to be logged
211 *
212 * @return bool
213 */
214 public function getLog() {
215 return self::$_log;
216 }
217
218 /**
219 * Returns the list of fields that can be imported
220 *
221 * @param bool $prefix
222 *
223 * @return array
224 */
225 public static function &import($prefix = FALSE) {
226 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'financial_type', $prefix, []);
227 return $r;
228 }
229
230 /**
231 * Returns the list of fields that can be exported
232 *
233 * @param bool $prefix
234 *
235 * @return array
236 */
237 public static function &export($prefix = FALSE) {
238 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'financial_type', $prefix, []);
239 return $r;
240 }
241
242 /**
243 * Returns the list of indices
244 *
245 * @param bool $localize
246 *
247 * @return array
248 */
249 public static function indices($localize = TRUE) {
250 $indices = [
251 'UI_id' => [
252 'name' => 'UI_id',
253 'field' => [
254 0 => 'id',
255 ],
256 'localizable' => FALSE,
257 'unique' => TRUE,
258 'sig' => 'civicrm_financial_type::1::id',
259 ],
260 ];
261 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
262 }
263
264 }