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