Merge pull request #22954 from JMAConsulting/booleanFields
[civicrm-core.git] / CRM / Contribute / DAO / ContributionSoft.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Contribute/ContributionSoft.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:9d890f5a0f0efc24ce1adaf5c84ac54e)
10 */
11
12 /**
13 * Database access object for the ContributionSoft entity.
14 */
15 class CRM_Contribute_DAO_ContributionSoft extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '2.2';
18 const COMPONENT = 'CiviContribute';
19
20 /**
21 * Static instance to hold the table name.
22 *
23 * @var string
24 */
25 public static $_tableName = 'civicrm_contribution_soft';
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 * Soft Credit ID
36 *
37 * @var int|string|null
38 * (SQL type: int unsigned)
39 * Note that values will be retrieved from the database as a string.
40 */
41 public $id;
42
43 /**
44 * FK to contribution table.
45 *
46 * @var int|string
47 * (SQL type: int unsigned)
48 * Note that values will be retrieved from the database as a string.
49 */
50 public $contribution_id;
51
52 /**
53 * FK to Contact ID
54 *
55 * @var int|string
56 * (SQL type: int unsigned)
57 * Note that values will be retrieved from the database as a string.
58 */
59 public $contact_id;
60
61 /**
62 * Amount of this soft credit.
63 *
64 * @var float|string
65 * (SQL type: decimal(20,2))
66 * Note that values will be retrieved from the database as a string.
67 */
68 public $amount;
69
70 /**
71 * 3 character string, value from config setting or input via user.
72 *
73 * @var string|null
74 * (SQL type: varchar(3))
75 * Note that values will be retrieved from the database as a string.
76 */
77 public $currency;
78
79 /**
80 * FK to civicrm_pcp.id
81 *
82 * @var int|string|null
83 * (SQL type: int unsigned)
84 * Note that values will be retrieved from the database as a string.
85 */
86 public $pcp_id;
87
88 /**
89 * @var bool|string
90 * (SQL type: tinyint)
91 * Note that values will be retrieved from the database as a string.
92 */
93 public $pcp_display_in_roll;
94
95 /**
96 * @var string|null
97 * (SQL type: varchar(255))
98 * Note that values will be retrieved from the database as a string.
99 */
100 public $pcp_roll_nickname;
101
102 /**
103 * @var string|null
104 * (SQL type: varchar(255))
105 * Note that values will be retrieved from the database as a string.
106 */
107 public $pcp_personal_note;
108
109 /**
110 * Soft Credit Type ID.Implicit FK to civicrm_option_value where option_group = soft_credit_type.
111 *
112 * @var int|string|null
113 * (SQL type: int unsigned)
114 * Note that values will be retrieved from the database as a string.
115 */
116 public $soft_credit_type_id;
117
118 /**
119 * Class constructor.
120 */
121 public function __construct() {
122 $this->__table = 'civicrm_contribution_soft';
123 parent::__construct();
124 }
125
126 /**
127 * Returns localized title of this entity.
128 *
129 * @param bool $plural
130 * Whether to return the plural version of the title.
131 */
132 public static function getEntityTitle($plural = FALSE) {
133 return $plural ? ts('Contribution Soft Credits') : ts('Contribution Soft Credit');
134 }
135
136 /**
137 * Returns foreign keys and entity references.
138 *
139 * @return array
140 * [CRM_Core_Reference_Interface]
141 */
142 public static function getReferenceColumns() {
143 if (!isset(Civi::$statics[__CLASS__]['links'])) {
144 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
145 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contribution_id', 'civicrm_contribution', 'id');
146 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
147 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'pcp_id', 'civicrm_pcp', 'id');
148 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
149 }
150 return Civi::$statics[__CLASS__]['links'];
151 }
152
153 /**
154 * Returns all the column names of this table
155 *
156 * @return array
157 */
158 public static function &fields() {
159 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
160 Civi::$statics[__CLASS__]['fields'] = [
161 'contribution_soft_id' => [
162 'name' => 'id',
163 'type' => CRM_Utils_Type::T_INT,
164 'title' => ts('Soft Credit ID'),
165 'description' => ts('Soft Credit ID'),
166 'required' => TRUE,
167 'import' => TRUE,
168 'where' => 'civicrm_contribution_soft.id',
169 'export' => TRUE,
170 'table_name' => 'civicrm_contribution_soft',
171 'entity' => 'ContributionSoft',
172 'bao' => 'CRM_Contribute_BAO_ContributionSoft',
173 'localizable' => 0,
174 'html' => [
175 'type' => 'Number',
176 ],
177 'readonly' => TRUE,
178 'add' => '2.2',
179 ],
180 'contribution_id' => [
181 'name' => 'contribution_id',
182 'type' => CRM_Utils_Type::T_INT,
183 'title' => ts('Contribution ID'),
184 'description' => ts('FK to contribution table.'),
185 'required' => TRUE,
186 'where' => 'civicrm_contribution_soft.contribution_id',
187 'table_name' => 'civicrm_contribution_soft',
188 'entity' => 'ContributionSoft',
189 'bao' => 'CRM_Contribute_BAO_ContributionSoft',
190 'localizable' => 0,
191 'FKClassName' => 'CRM_Contribute_DAO_Contribution',
192 'html' => [
193 'label' => ts("Contribution"),
194 ],
195 'add' => '2.2',
196 ],
197 'contribution_soft_contact_id' => [
198 'name' => 'contact_id',
199 'type' => CRM_Utils_Type::T_INT,
200 'title' => ts('Contact ID'),
201 'description' => ts('FK to Contact ID'),
202 'required' => TRUE,
203 'import' => TRUE,
204 'where' => 'civicrm_contribution_soft.contact_id',
205 'headerPattern' => '/contact(.?id)?/i',
206 'dataPattern' => '/^\d+$/',
207 'export' => TRUE,
208 'table_name' => 'civicrm_contribution_soft',
209 'entity' => 'ContributionSoft',
210 'bao' => 'CRM_Contribute_BAO_ContributionSoft',
211 'localizable' => 0,
212 'FKClassName' => 'CRM_Contact_DAO_Contact',
213 'html' => [
214 'label' => ts("Contact"),
215 ],
216 'add' => '2.2',
217 ],
218 'amount' => [
219 'name' => 'amount',
220 'type' => CRM_Utils_Type::T_MONEY,
221 'title' => ts('Soft Credit Amount'),
222 'description' => ts('Amount of this soft credit.'),
223 'required' => TRUE,
224 'precision' => [
225 20,
226 2,
227 ],
228 'import' => TRUE,
229 'where' => 'civicrm_contribution_soft.amount',
230 'headerPattern' => '/total(.?am(ou)?nt)?/i',
231 'dataPattern' => '/^\d+(\.\d{2})?$/',
232 'export' => TRUE,
233 'table_name' => 'civicrm_contribution_soft',
234 'entity' => 'ContributionSoft',
235 'bao' => 'CRM_Contribute_BAO_ContributionSoft',
236 'localizable' => 0,
237 'add' => '2.2',
238 ],
239 'currency' => [
240 'name' => 'currency',
241 'type' => CRM_Utils_Type::T_STRING,
242 'title' => ts('Soft Contribution Currency'),
243 'description' => ts('3 character string, value from config setting or input via user.'),
244 'maxlength' => 3,
245 'size' => CRM_Utils_Type::FOUR,
246 'where' => 'civicrm_contribution_soft.currency',
247 'default' => NULL,
248 'table_name' => 'civicrm_contribution_soft',
249 'entity' => 'ContributionSoft',
250 'bao' => 'CRM_Contribute_BAO_ContributionSoft',
251 'localizable' => 0,
252 'html' => [
253 'type' => 'Select',
254 ],
255 'pseudoconstant' => [
256 'table' => 'civicrm_currency',
257 'keyColumn' => 'name',
258 'labelColumn' => 'full_name',
259 'nameColumn' => 'name',
260 'abbrColumn' => 'symbol',
261 ],
262 'add' => '3.2',
263 ],
264 'pcp_id' => [
265 'name' => 'pcp_id',
266 'type' => CRM_Utils_Type::T_INT,
267 'title' => ts('PCP ID'),
268 'description' => ts('FK to civicrm_pcp.id'),
269 'where' => 'civicrm_contribution_soft.pcp_id',
270 'default' => NULL,
271 'table_name' => 'civicrm_contribution_soft',
272 'entity' => 'ContributionSoft',
273 'bao' => 'CRM_Contribute_BAO_ContributionSoft',
274 'localizable' => 0,
275 'FKClassName' => 'CRM_PCP_DAO_PCP',
276 'html' => [
277 'label' => ts("PCP"),
278 ],
279 'pseudoconstant' => [
280 'table' => 'civicrm_pcp',
281 'keyColumn' => 'id',
282 'labelColumn' => 'title',
283 ],
284 'add' => '2.2',
285 ],
286 'pcp_display_in_roll' => [
287 'name' => 'pcp_display_in_roll',
288 'type' => CRM_Utils_Type::T_BOOLEAN,
289 'title' => ts('Soft Contribution Display on PCP'),
290 'required' => TRUE,
291 'where' => 'civicrm_contribution_soft.pcp_display_in_roll',
292 'default' => '0',
293 'table_name' => 'civicrm_contribution_soft',
294 'entity' => 'ContributionSoft',
295 'bao' => 'CRM_Contribute_BAO_ContributionSoft',
296 'localizable' => 0,
297 'add' => '2.2',
298 ],
299 'pcp_roll_nickname' => [
300 'name' => 'pcp_roll_nickname',
301 'type' => CRM_Utils_Type::T_STRING,
302 'title' => ts('Soft Contribution PCP Nickname'),
303 'maxlength' => 255,
304 'size' => CRM_Utils_Type::HUGE,
305 'where' => 'civicrm_contribution_soft.pcp_roll_nickname',
306 'default' => NULL,
307 'table_name' => 'civicrm_contribution_soft',
308 'entity' => 'ContributionSoft',
309 'bao' => 'CRM_Contribute_BAO_ContributionSoft',
310 'localizable' => 0,
311 'add' => '2.2',
312 ],
313 'pcp_personal_note' => [
314 'name' => 'pcp_personal_note',
315 'type' => CRM_Utils_Type::T_STRING,
316 'title' => ts('Soft Contribution PCP Note'),
317 'maxlength' => 255,
318 'size' => CRM_Utils_Type::HUGE,
319 'where' => 'civicrm_contribution_soft.pcp_personal_note',
320 'default' => NULL,
321 'table_name' => 'civicrm_contribution_soft',
322 'entity' => 'ContributionSoft',
323 'bao' => 'CRM_Contribute_BAO_ContributionSoft',
324 'localizable' => 0,
325 'html' => [
326 'type' => 'TextArea',
327 ],
328 'add' => '2.2',
329 ],
330 'soft_credit_type_id' => [
331 'name' => 'soft_credit_type_id',
332 'type' => CRM_Utils_Type::T_INT,
333 'title' => ts('Soft Credit Type'),
334 'description' => ts('Soft Credit Type ID.Implicit FK to civicrm_option_value where option_group = soft_credit_type.'),
335 'where' => 'civicrm_contribution_soft.soft_credit_type_id',
336 'default' => NULL,
337 'table_name' => 'civicrm_contribution_soft',
338 'entity' => 'ContributionSoft',
339 'bao' => 'CRM_Contribute_BAO_ContributionSoft',
340 'localizable' => 0,
341 'pseudoconstant' => [
342 'optionGroupName' => 'soft_credit_type',
343 'optionEditPath' => 'civicrm/admin/options/soft_credit_type',
344 ],
345 'add' => '2.2',
346 ],
347 ];
348 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
349 }
350 return Civi::$statics[__CLASS__]['fields'];
351 }
352
353 /**
354 * Return a mapping from field-name to the corresponding key (as used in fields()).
355 *
356 * @return array
357 * Array(string $name => string $uniqueName).
358 */
359 public static function &fieldKeys() {
360 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
361 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
362 }
363 return Civi::$statics[__CLASS__]['fieldKeys'];
364 }
365
366 /**
367 * Returns the names of this table
368 *
369 * @return string
370 */
371 public static function getTableName() {
372 return self::$_tableName;
373 }
374
375 /**
376 * Returns if this table needs to be logged
377 *
378 * @return bool
379 */
380 public function getLog() {
381 return self::$_log;
382 }
383
384 /**
385 * Returns the list of fields that can be imported
386 *
387 * @param bool $prefix
388 *
389 * @return array
390 */
391 public static function &import($prefix = FALSE) {
392 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'contribution_soft', $prefix, []);
393 return $r;
394 }
395
396 /**
397 * Returns the list of fields that can be exported
398 *
399 * @param bool $prefix
400 *
401 * @return array
402 */
403 public static function &export($prefix = FALSE) {
404 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'contribution_soft', $prefix, []);
405 return $r;
406 }
407
408 /**
409 * Returns the list of indices
410 *
411 * @param bool $localize
412 *
413 * @return array
414 */
415 public static function indices($localize = TRUE) {
416 $indices = [
417 'index_id' => [
418 'name' => 'index_id',
419 'field' => [
420 0 => 'pcp_id',
421 ],
422 'localizable' => FALSE,
423 'sig' => 'civicrm_contribution_soft::0::pcp_id',
424 ],
425 ];
426 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
427 }
428
429 }