Merge pull request #22953 from civicrm/5.48
[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:78899ec4310e1facc05fdb11cfac1432)
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|null
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 'where' => 'civicrm_contribution_soft.pcp_display_in_roll',
291 'default' => '0',
292 'table_name' => 'civicrm_contribution_soft',
293 'entity' => 'ContributionSoft',
294 'bao' => 'CRM_Contribute_BAO_ContributionSoft',
295 'localizable' => 0,
296 'add' => '2.2',
297 ],
298 'pcp_roll_nickname' => [
299 'name' => 'pcp_roll_nickname',
300 'type' => CRM_Utils_Type::T_STRING,
301 'title' => ts('Soft Contribution PCP Nickname'),
302 'maxlength' => 255,
303 'size' => CRM_Utils_Type::HUGE,
304 'where' => 'civicrm_contribution_soft.pcp_roll_nickname',
305 'default' => NULL,
306 'table_name' => 'civicrm_contribution_soft',
307 'entity' => 'ContributionSoft',
308 'bao' => 'CRM_Contribute_BAO_ContributionSoft',
309 'localizable' => 0,
310 'add' => '2.2',
311 ],
312 'pcp_personal_note' => [
313 'name' => 'pcp_personal_note',
314 'type' => CRM_Utils_Type::T_STRING,
315 'title' => ts('Soft Contribution PCP Note'),
316 'maxlength' => 255,
317 'size' => CRM_Utils_Type::HUGE,
318 'where' => 'civicrm_contribution_soft.pcp_personal_note',
319 'default' => NULL,
320 'table_name' => 'civicrm_contribution_soft',
321 'entity' => 'ContributionSoft',
322 'bao' => 'CRM_Contribute_BAO_ContributionSoft',
323 'localizable' => 0,
324 'html' => [
325 'type' => 'TextArea',
326 ],
327 'add' => '2.2',
328 ],
329 'soft_credit_type_id' => [
330 'name' => 'soft_credit_type_id',
331 'type' => CRM_Utils_Type::T_INT,
332 'title' => ts('Soft Credit Type'),
333 'description' => ts('Soft Credit Type ID.Implicit FK to civicrm_option_value where option_group = soft_credit_type.'),
334 'where' => 'civicrm_contribution_soft.soft_credit_type_id',
335 'default' => NULL,
336 'table_name' => 'civicrm_contribution_soft',
337 'entity' => 'ContributionSoft',
338 'bao' => 'CRM_Contribute_BAO_ContributionSoft',
339 'localizable' => 0,
340 'pseudoconstant' => [
341 'optionGroupName' => 'soft_credit_type',
342 'optionEditPath' => 'civicrm/admin/options/soft_credit_type',
343 ],
344 'add' => '2.2',
345 ],
346 ];
347 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
348 }
349 return Civi::$statics[__CLASS__]['fields'];
350 }
351
352 /**
353 * Return a mapping from field-name to the corresponding key (as used in fields()).
354 *
355 * @return array
356 * Array(string $name => string $uniqueName).
357 */
358 public static function &fieldKeys() {
359 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
360 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
361 }
362 return Civi::$statics[__CLASS__]['fieldKeys'];
363 }
364
365 /**
366 * Returns the names of this table
367 *
368 * @return string
369 */
370 public static function getTableName() {
371 return self::$_tableName;
372 }
373
374 /**
375 * Returns if this table needs to be logged
376 *
377 * @return bool
378 */
379 public function getLog() {
380 return self::$_log;
381 }
382
383 /**
384 * Returns the list of fields that can be imported
385 *
386 * @param bool $prefix
387 *
388 * @return array
389 */
390 public static function &import($prefix = FALSE) {
391 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'contribution_soft', $prefix, []);
392 return $r;
393 }
394
395 /**
396 * Returns the list of fields that can be exported
397 *
398 * @param bool $prefix
399 *
400 * @return array
401 */
402 public static function &export($prefix = FALSE) {
403 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'contribution_soft', $prefix, []);
404 return $r;
405 }
406
407 /**
408 * Returns the list of indices
409 *
410 * @param bool $localize
411 *
412 * @return array
413 */
414 public static function indices($localize = TRUE) {
415 $indices = [
416 'index_id' => [
417 'name' => 'index_id',
418 'field' => [
419 0 => 'pcp_id',
420 ],
421 'localizable' => FALSE,
422 'sig' => 'civicrm_contribution_soft::0::pcp_id',
423 ],
424 ];
425 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
426 }
427
428 }