Schema - Fix boolean fields in various tables
[civicrm-core.git] / CRM / Campaign / DAO / Campaign.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Campaign/Campaign.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:ec15aa356537755e66854f7da660cee2)
10 */
11
12 /**
13 * Database access object for the Campaign entity.
14 */
15 class CRM_Campaign_DAO_Campaign extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '3.3';
18 const COMPONENT = 'CiviCampaign';
19
20 /**
21 * Static instance to hold the table name.
22 *
23 * @var string
24 */
25 public static $_tableName = 'civicrm_campaign';
26
27 /**
28 * Icon associated with this entity.
29 *
30 * @var string
31 */
32 public static $_icon = 'fa-bullhorn';
33
34 /**
35 * Field to show when displaying a record.
36 *
37 * @var string
38 */
39 public static $_labelField = 'title';
40
41 /**
42 * Should CiviCRM log any modifications to this table in the civicrm_log table.
43 *
44 * @var bool
45 */
46 public static $_log = FALSE;
47
48 /**
49 * Paths for accessing this entity in the UI.
50 *
51 * @var string[]
52 */
53 protected static $_paths = [
54 'add' => 'civicrm/campaign/add?reset=1',
55 'update' => 'civicrm/campaign/add?reset=1&action=update&id=[id]',
56 'delete' => 'civicrm/campaign/add?reset=1&action=delete&id=[id]',
57 ];
58
59 /**
60 * Unique Campaign ID.
61 *
62 * @var int|string|null
63 * (SQL type: int unsigned)
64 * Note that values will be retrieved from the database as a string.
65 */
66 public $id;
67
68 /**
69 * Name of the Campaign.
70 *
71 * @var string
72 * (SQL type: varchar(255))
73 * Note that values will be retrieved from the database as a string.
74 */
75 public $name;
76
77 /**
78 * Title of the Campaign.
79 *
80 * @var string|null
81 * (SQL type: varchar(255))
82 * Note that values will be retrieved from the database as a string.
83 */
84 public $title;
85
86 /**
87 * Full description of Campaign.
88 *
89 * @var string|null
90 * (SQL type: text)
91 * Note that values will be retrieved from the database as a string.
92 */
93 public $description;
94
95 /**
96 * Date and time that Campaign starts.
97 *
98 * @var string|null
99 * (SQL type: datetime)
100 * Note that values will be retrieved from the database as a string.
101 */
102 public $start_date;
103
104 /**
105 * Date and time that Campaign ends.
106 *
107 * @var string|null
108 * (SQL type: datetime)
109 * Note that values will be retrieved from the database as a string.
110 */
111 public $end_date;
112
113 /**
114 * Campaign Type ID.Implicit FK to civicrm_option_value where option_group = campaign_type
115 *
116 * @var int|string|null
117 * (SQL type: int unsigned)
118 * Note that values will be retrieved from the database as a string.
119 */
120 public $campaign_type_id;
121
122 /**
123 * Campaign status ID.Implicit FK to civicrm_option_value where option_group = campaign_status
124 *
125 * @var int|string|null
126 * (SQL type: int unsigned)
127 * Note that values will be retrieved from the database as a string.
128 */
129 public $status_id;
130
131 /**
132 * Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.
133 *
134 * @var string|null
135 * (SQL type: varchar(32))
136 * Note that values will be retrieved from the database as a string.
137 */
138 public $external_identifier;
139
140 /**
141 * Optional parent id for this Campaign.
142 *
143 * @var int|string|null
144 * (SQL type: int unsigned)
145 * Note that values will be retrieved from the database as a string.
146 */
147 public $parent_id;
148
149 /**
150 * Is this Campaign enabled or disabled/cancelled?
151 *
152 * @var bool|string
153 * (SQL type: tinyint)
154 * Note that values will be retrieved from the database as a string.
155 */
156 public $is_active;
157
158 /**
159 * FK to civicrm_contact, who created this Campaign.
160 *
161 * @var int|string|null
162 * (SQL type: int unsigned)
163 * Note that values will be retrieved from the database as a string.
164 */
165 public $created_id;
166
167 /**
168 * Date and time that Campaign was created.
169 *
170 * @var string|null
171 * (SQL type: datetime)
172 * Note that values will be retrieved from the database as a string.
173 */
174 public $created_date;
175
176 /**
177 * FK to civicrm_contact, who recently edited this Campaign.
178 *
179 * @var int|string|null
180 * (SQL type: int unsigned)
181 * Note that values will be retrieved from the database as a string.
182 */
183 public $last_modified_id;
184
185 /**
186 * Date and time that Campaign was edited last time.
187 *
188 * @var string|null
189 * (SQL type: datetime)
190 * Note that values will be retrieved from the database as a string.
191 */
192 public $last_modified_date;
193
194 /**
195 * General goals for Campaign.
196 *
197 * @var string|null
198 * (SQL type: text)
199 * Note that values will be retrieved from the database as a string.
200 */
201 public $goal_general;
202
203 /**
204 * The target revenue for this campaign.
205 *
206 * @var float|string|null
207 * (SQL type: decimal(20,2))
208 * Note that values will be retrieved from the database as a string.
209 */
210 public $goal_revenue;
211
212 /**
213 * Class constructor.
214 */
215 public function __construct() {
216 $this->__table = 'civicrm_campaign';
217 parent::__construct();
218 }
219
220 /**
221 * Returns localized title of this entity.
222 *
223 * @param bool $plural
224 * Whether to return the plural version of the title.
225 */
226 public static function getEntityTitle($plural = FALSE) {
227 return $plural ? ts('Campaigns') : ts('Campaign');
228 }
229
230 /**
231 * Returns user-friendly description of this entity.
232 *
233 * @return string
234 */
235 public static function getEntityDescription() {
236 return ts('Campaigns link activities, contributions, mailings, etc. that share a programmatic goal.');
237 }
238
239 /**
240 * Returns foreign keys and entity references.
241 *
242 * @return array
243 * [CRM_Core_Reference_Interface]
244 */
245 public static function getReferenceColumns() {
246 if (!isset(Civi::$statics[__CLASS__]['links'])) {
247 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
248 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'parent_id', 'civicrm_campaign', 'id');
249 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id');
250 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'last_modified_id', 'civicrm_contact', 'id');
251 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
252 }
253 return Civi::$statics[__CLASS__]['links'];
254 }
255
256 /**
257 * Returns all the column names of this table
258 *
259 * @return array
260 */
261 public static function &fields() {
262 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
263 Civi::$statics[__CLASS__]['fields'] = [
264 'id' => [
265 'name' => 'id',
266 'type' => CRM_Utils_Type::T_INT,
267 'title' => ts('Campaign ID'),
268 'description' => ts('Unique Campaign ID.'),
269 'required' => TRUE,
270 'import' => TRUE,
271 'where' => 'civicrm_campaign.id',
272 'export' => TRUE,
273 'table_name' => 'civicrm_campaign',
274 'entity' => 'Campaign',
275 'bao' => 'CRM_Campaign_BAO_Campaign',
276 'localizable' => 0,
277 'html' => [
278 'type' => 'Number',
279 ],
280 'readonly' => TRUE,
281 'add' => '3.3',
282 ],
283 'name' => [
284 'name' => 'name',
285 'type' => CRM_Utils_Type::T_STRING,
286 'title' => ts('Campaign Name'),
287 'description' => ts('Name of the Campaign.'),
288 'required' => TRUE,
289 'maxlength' => 255,
290 'size' => CRM_Utils_Type::HUGE,
291 'import' => TRUE,
292 'where' => 'civicrm_campaign.name',
293 'export' => TRUE,
294 'table_name' => 'civicrm_campaign',
295 'entity' => 'Campaign',
296 'bao' => 'CRM_Campaign_BAO_Campaign',
297 'localizable' => 0,
298 'html' => [
299 'type' => 'Text',
300 ],
301 'add' => '3.3',
302 ],
303 'title' => [
304 'name' => 'title',
305 'type' => CRM_Utils_Type::T_STRING,
306 'title' => ts('Campaign Title'),
307 'description' => ts('Title of the Campaign.'),
308 'maxlength' => 255,
309 'size' => CRM_Utils_Type::HUGE,
310 'import' => TRUE,
311 'where' => 'civicrm_campaign.title',
312 'export' => TRUE,
313 'table_name' => 'civicrm_campaign',
314 'entity' => 'Campaign',
315 'bao' => 'CRM_Campaign_BAO_Campaign',
316 'localizable' => 0,
317 'html' => [
318 'type' => 'Text',
319 ],
320 'add' => '3.3',
321 ],
322 'description' => [
323 'name' => 'description',
324 'type' => CRM_Utils_Type::T_TEXT,
325 'title' => ts('Campaign Description'),
326 'description' => ts('Full description of Campaign.'),
327 'rows' => 8,
328 'cols' => 60,
329 'where' => 'civicrm_campaign.description',
330 'table_name' => 'civicrm_campaign',
331 'entity' => 'Campaign',
332 'bao' => 'CRM_Campaign_BAO_Campaign',
333 'localizable' => 0,
334 'html' => [
335 'type' => 'TextArea',
336 ],
337 'add' => '3.3',
338 ],
339 'start_date' => [
340 'name' => 'start_date',
341 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
342 'title' => ts('Campaign Start Date'),
343 'description' => ts('Date and time that Campaign starts.'),
344 'import' => TRUE,
345 'where' => 'civicrm_campaign.start_date',
346 'headerPattern' => '/^start|(s(tart\s)?date)$/i',
347 'export' => TRUE,
348 'table_name' => 'civicrm_campaign',
349 'entity' => 'Campaign',
350 'bao' => 'CRM_Campaign_BAO_Campaign',
351 'localizable' => 0,
352 'html' => [
353 'type' => 'Select Date',
354 'formatType' => 'activityDateTime',
355 ],
356 'add' => '3.3',
357 ],
358 'end_date' => [
359 'name' => 'end_date',
360 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
361 'title' => ts('Campaign End Date'),
362 'description' => ts('Date and time that Campaign ends.'),
363 'import' => TRUE,
364 'where' => 'civicrm_campaign.end_date',
365 'headerPattern' => '/^end|(e(nd\s)?date)$/i',
366 'export' => TRUE,
367 'table_name' => 'civicrm_campaign',
368 'entity' => 'Campaign',
369 'bao' => 'CRM_Campaign_BAO_Campaign',
370 'localizable' => 0,
371 'html' => [
372 'type' => 'Select Date',
373 'formatType' => 'activityDateTime',
374 ],
375 'add' => '3.3',
376 ],
377 'campaign_type_id' => [
378 'name' => 'campaign_type_id',
379 'type' => CRM_Utils_Type::T_INT,
380 'title' => ts('Campaign Type'),
381 'description' => ts('Campaign Type ID.Implicit FK to civicrm_option_value where option_group = campaign_type'),
382 'import' => TRUE,
383 'where' => 'civicrm_campaign.campaign_type_id',
384 'export' => TRUE,
385 'default' => NULL,
386 'table_name' => 'civicrm_campaign',
387 'entity' => 'Campaign',
388 'bao' => 'CRM_Campaign_BAO_Campaign',
389 'localizable' => 0,
390 'html' => [
391 'type' => 'Select',
392 ],
393 'pseudoconstant' => [
394 'optionGroupName' => 'campaign_type',
395 'optionEditPath' => 'civicrm/admin/options/campaign_type',
396 ],
397 'add' => '3.3',
398 ],
399 'status_id' => [
400 'name' => 'status_id',
401 'type' => CRM_Utils_Type::T_INT,
402 'title' => ts('Campaign Status'),
403 'description' => ts('Campaign status ID.Implicit FK to civicrm_option_value where option_group = campaign_status'),
404 'import' => TRUE,
405 'where' => 'civicrm_campaign.status_id',
406 'export' => TRUE,
407 'default' => NULL,
408 'table_name' => 'civicrm_campaign',
409 'entity' => 'Campaign',
410 'bao' => 'CRM_Campaign_BAO_Campaign',
411 'localizable' => 0,
412 'html' => [
413 'type' => 'Select',
414 ],
415 'pseudoconstant' => [
416 'optionGroupName' => 'campaign_status',
417 'optionEditPath' => 'civicrm/admin/options/campaign_status',
418 ],
419 'add' => '3.3',
420 ],
421 'external_identifier' => [
422 'name' => 'external_identifier',
423 'type' => CRM_Utils_Type::T_STRING,
424 'title' => ts('Campaign External ID'),
425 'description' => ts('Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.'),
426 'maxlength' => 32,
427 'size' => CRM_Utils_Type::MEDIUM,
428 'import' => TRUE,
429 'where' => 'civicrm_campaign.external_identifier',
430 'headerPattern' => '/external\s?id/i',
431 'dataPattern' => '/^\d{11,}$/',
432 'export' => TRUE,
433 'table_name' => 'civicrm_campaign',
434 'entity' => 'Campaign',
435 'bao' => 'CRM_Campaign_BAO_Campaign',
436 'localizable' => 0,
437 'html' => [
438 'type' => 'Text',
439 ],
440 'add' => '3.3',
441 ],
442 'parent_id' => [
443 'name' => 'parent_id',
444 'type' => CRM_Utils_Type::T_INT,
445 'title' => ts('Parent Campaign ID'),
446 'description' => ts('Optional parent id for this Campaign.'),
447 'import' => TRUE,
448 'where' => 'civicrm_campaign.parent_id',
449 'export' => TRUE,
450 'default' => NULL,
451 'table_name' => 'civicrm_campaign',
452 'entity' => 'Campaign',
453 'bao' => 'CRM_Campaign_BAO_Campaign',
454 'localizable' => 0,
455 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
456 'html' => [
457 'type' => 'EntityRef',
458 'label' => ts("Parent Campaign"),
459 ],
460 'add' => '3.3',
461 ],
462 'is_active' => [
463 'name' => 'is_active',
464 'type' => CRM_Utils_Type::T_BOOLEAN,
465 'title' => ts('Is Campaign Active?'),
466 'description' => ts('Is this Campaign enabled or disabled/cancelled?'),
467 'required' => TRUE,
468 'where' => 'civicrm_campaign.is_active',
469 'default' => '1',
470 'table_name' => 'civicrm_campaign',
471 'entity' => 'Campaign',
472 'bao' => 'CRM_Campaign_BAO_Campaign',
473 'localizable' => 0,
474 'html' => [
475 'type' => 'CheckBox',
476 ],
477 'add' => '3.3',
478 ],
479 'created_id' => [
480 'name' => 'created_id',
481 'type' => CRM_Utils_Type::T_INT,
482 'title' => ts('Created By Contact ID'),
483 'description' => ts('FK to civicrm_contact, who created this Campaign.'),
484 'where' => 'civicrm_campaign.created_id',
485 'table_name' => 'civicrm_campaign',
486 'entity' => 'Campaign',
487 'bao' => 'CRM_Campaign_BAO_Campaign',
488 'localizable' => 0,
489 'FKClassName' => 'CRM_Contact_DAO_Contact',
490 'html' => [
491 'label' => ts("Created By"),
492 ],
493 'add' => '3.3',
494 ],
495 'created_date' => [
496 'name' => 'created_date',
497 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
498 'title' => ts('Campaign Created Date'),
499 'description' => ts('Date and time that Campaign was created.'),
500 'where' => 'civicrm_campaign.created_date',
501 'table_name' => 'civicrm_campaign',
502 'entity' => 'Campaign',
503 'bao' => 'CRM_Campaign_BAO_Campaign',
504 'localizable' => 0,
505 'html' => [
506 'type' => 'Select Date',
507 'formatType' => 'activityDateTime',
508 ],
509 'add' => '3.3',
510 ],
511 'last_modified_id' => [
512 'name' => 'last_modified_id',
513 'type' => CRM_Utils_Type::T_INT,
514 'title' => ts('Modified By Contact ID'),
515 'description' => ts('FK to civicrm_contact, who recently edited this Campaign.'),
516 'where' => 'civicrm_campaign.last_modified_id',
517 'table_name' => 'civicrm_campaign',
518 'entity' => 'Campaign',
519 'bao' => 'CRM_Campaign_BAO_Campaign',
520 'localizable' => 0,
521 'FKClassName' => 'CRM_Contact_DAO_Contact',
522 'html' => [
523 'label' => ts("Modified By"),
524 ],
525 'add' => '3.3',
526 ],
527 'last_modified_date' => [
528 'name' => 'last_modified_date',
529 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
530 'title' => ts('Campaign Modified Date'),
531 'description' => ts('Date and time that Campaign was edited last time.'),
532 'where' => 'civicrm_campaign.last_modified_date',
533 'table_name' => 'civicrm_campaign',
534 'entity' => 'Campaign',
535 'bao' => 'CRM_Campaign_BAO_Campaign',
536 'localizable' => 0,
537 'add' => '3.3',
538 ],
539 'goal_general' => [
540 'name' => 'goal_general',
541 'type' => CRM_Utils_Type::T_TEXT,
542 'title' => ts('Campaign Goals'),
543 'description' => ts('General goals for Campaign.'),
544 'where' => 'civicrm_campaign.goal_general',
545 'table_name' => 'civicrm_campaign',
546 'entity' => 'Campaign',
547 'bao' => 'CRM_Campaign_BAO_Campaign',
548 'localizable' => 0,
549 'html' => [
550 'type' => 'RichTextEditor',
551 ],
552 'add' => '3.4',
553 ],
554 'goal_revenue' => [
555 'name' => 'goal_revenue',
556 'type' => CRM_Utils_Type::T_MONEY,
557 'title' => ts('Goal Revenue'),
558 'description' => ts('The target revenue for this campaign.'),
559 'precision' => [
560 20,
561 2,
562 ],
563 'where' => 'civicrm_campaign.goal_revenue',
564 'table_name' => 'civicrm_campaign',
565 'entity' => 'Campaign',
566 'bao' => 'CRM_Campaign_BAO_Campaign',
567 'localizable' => 0,
568 'html' => [
569 'type' => 'Text',
570 'label' => ts("Goal Revenue"),
571 ],
572 'add' => '3.4',
573 ],
574 ];
575 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
576 }
577 return Civi::$statics[__CLASS__]['fields'];
578 }
579
580 /**
581 * Return a mapping from field-name to the corresponding key (as used in fields()).
582 *
583 * @return array
584 * Array(string $name => string $uniqueName).
585 */
586 public static function &fieldKeys() {
587 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
588 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
589 }
590 return Civi::$statics[__CLASS__]['fieldKeys'];
591 }
592
593 /**
594 * Returns the names of this table
595 *
596 * @return string
597 */
598 public static function getTableName() {
599 return self::$_tableName;
600 }
601
602 /**
603 * Returns if this table needs to be logged
604 *
605 * @return bool
606 */
607 public function getLog() {
608 return self::$_log;
609 }
610
611 /**
612 * Returns the list of fields that can be imported
613 *
614 * @param bool $prefix
615 *
616 * @return array
617 */
618 public static function &import($prefix = FALSE) {
619 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'campaign', $prefix, []);
620 return $r;
621 }
622
623 /**
624 * Returns the list of fields that can be exported
625 *
626 * @param bool $prefix
627 *
628 * @return array
629 */
630 public static function &export($prefix = FALSE) {
631 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'campaign', $prefix, []);
632 return $r;
633 }
634
635 /**
636 * Returns the list of indices
637 *
638 * @param bool $localize
639 *
640 * @return array
641 */
642 public static function indices($localize = TRUE) {
643 $indices = [
644 'UI_campaign_name' => [
645 'name' => 'UI_campaign_name',
646 'field' => [
647 0 => 'name',
648 ],
649 'localizable' => FALSE,
650 'sig' => 'civicrm_campaign::0::name',
651 ],
652 'UI_campaign_type_id' => [
653 'name' => 'UI_campaign_type_id',
654 'field' => [
655 0 => 'campaign_type_id',
656 ],
657 'localizable' => FALSE,
658 'sig' => 'civicrm_campaign::0::campaign_type_id',
659 ],
660 'UI_campaign_status_id' => [
661 'name' => 'UI_campaign_status_id',
662 'field' => [
663 0 => 'status_id',
664 ],
665 'localizable' => FALSE,
666 'sig' => 'civicrm_campaign::0::status_id',
667 ],
668 'UI_external_identifier' => [
669 'name' => 'UI_external_identifier',
670 'field' => [
671 0 => 'external_identifier',
672 ],
673 'localizable' => FALSE,
674 'unique' => TRUE,
675 'sig' => 'civicrm_campaign::1::external_identifier',
676 ],
677 ];
678 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
679 }
680
681 }