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