Merge pull request #22798 from civicrm/5.47
[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:dab6fdaa9d622daab580b32ae1172bc7)
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|null
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 'where' => 'civicrm_campaign.is_active',
468 'default' => '1',
469 'table_name' => 'civicrm_campaign',
470 'entity' => 'Campaign',
471 'bao' => 'CRM_Campaign_BAO_Campaign',
472 'localizable' => 0,
473 'html' => [
474 'type' => 'CheckBox',
475 ],
476 'add' => '3.3',
477 ],
478 'created_id' => [
479 'name' => 'created_id',
480 'type' => CRM_Utils_Type::T_INT,
481 'title' => ts('Created By Contact ID'),
482 'description' => ts('FK to civicrm_contact, who created this Campaign.'),
483 'where' => 'civicrm_campaign.created_id',
484 'table_name' => 'civicrm_campaign',
485 'entity' => 'Campaign',
486 'bao' => 'CRM_Campaign_BAO_Campaign',
487 'localizable' => 0,
488 'FKClassName' => 'CRM_Contact_DAO_Contact',
489 'html' => [
490 'label' => ts("Created By"),
491 ],
492 'add' => '3.3',
493 ],
494 'created_date' => [
495 'name' => 'created_date',
496 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
497 'title' => ts('Campaign Created Date'),
498 'description' => ts('Date and time that Campaign was created.'),
499 'where' => 'civicrm_campaign.created_date',
500 'table_name' => 'civicrm_campaign',
501 'entity' => 'Campaign',
502 'bao' => 'CRM_Campaign_BAO_Campaign',
503 'localizable' => 0,
504 'html' => [
505 'type' => 'Select Date',
506 'formatType' => 'activityDateTime',
507 ],
508 'add' => '3.3',
509 ],
510 'last_modified_id' => [
511 'name' => 'last_modified_id',
512 'type' => CRM_Utils_Type::T_INT,
513 'title' => ts('Modified By Contact ID'),
514 'description' => ts('FK to civicrm_contact, who recently edited this Campaign.'),
515 'where' => 'civicrm_campaign.last_modified_id',
516 'table_name' => 'civicrm_campaign',
517 'entity' => 'Campaign',
518 'bao' => 'CRM_Campaign_BAO_Campaign',
519 'localizable' => 0,
520 'FKClassName' => 'CRM_Contact_DAO_Contact',
521 'html' => [
522 'label' => ts("Modified By"),
523 ],
524 'add' => '3.3',
525 ],
526 'last_modified_date' => [
527 'name' => 'last_modified_date',
528 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
529 'title' => ts('Campaign Modified Date'),
530 'description' => ts('Date and time that Campaign was edited last time.'),
531 'where' => 'civicrm_campaign.last_modified_date',
532 'table_name' => 'civicrm_campaign',
533 'entity' => 'Campaign',
534 'bao' => 'CRM_Campaign_BAO_Campaign',
535 'localizable' => 0,
536 'add' => '3.3',
537 ],
538 'goal_general' => [
539 'name' => 'goal_general',
540 'type' => CRM_Utils_Type::T_TEXT,
541 'title' => ts('Campaign Goals'),
542 'description' => ts('General goals for Campaign.'),
543 'where' => 'civicrm_campaign.goal_general',
544 'table_name' => 'civicrm_campaign',
545 'entity' => 'Campaign',
546 'bao' => 'CRM_Campaign_BAO_Campaign',
547 'localizable' => 0,
548 'html' => [
549 'type' => 'RichTextEditor',
550 ],
551 'add' => '3.4',
552 ],
553 'goal_revenue' => [
554 'name' => 'goal_revenue',
555 'type' => CRM_Utils_Type::T_MONEY,
556 'title' => ts('Goal Revenue'),
557 'description' => ts('The target revenue for this campaign.'),
558 'precision' => [
559 20,
560 2,
561 ],
562 'where' => 'civicrm_campaign.goal_revenue',
563 'table_name' => 'civicrm_campaign',
564 'entity' => 'Campaign',
565 'bao' => 'CRM_Campaign_BAO_Campaign',
566 'localizable' => 0,
567 'html' => [
568 'type' => 'Text',
569 'label' => ts("Goal Revenue"),
570 ],
571 'add' => '3.4',
572 ],
573 ];
574 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
575 }
576 return Civi::$statics[__CLASS__]['fields'];
577 }
578
579 /**
580 * Return a mapping from field-name to the corresponding key (as used in fields()).
581 *
582 * @return array
583 * Array(string $name => string $uniqueName).
584 */
585 public static function &fieldKeys() {
586 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
587 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
588 }
589 return Civi::$statics[__CLASS__]['fieldKeys'];
590 }
591
592 /**
593 * Returns the names of this table
594 *
595 * @return string
596 */
597 public static function getTableName() {
598 return self::$_tableName;
599 }
600
601 /**
602 * Returns if this table needs to be logged
603 *
604 * @return bool
605 */
606 public function getLog() {
607 return self::$_log;
608 }
609
610 /**
611 * Returns the list of fields that can be imported
612 *
613 * @param bool $prefix
614 *
615 * @return array
616 */
617 public static function &import($prefix = FALSE) {
618 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'campaign', $prefix, []);
619 return $r;
620 }
621
622 /**
623 * Returns the list of fields that can be exported
624 *
625 * @param bool $prefix
626 *
627 * @return array
628 */
629 public static function &export($prefix = FALSE) {
630 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'campaign', $prefix, []);
631 return $r;
632 }
633
634 /**
635 * Returns the list of indices
636 *
637 * @param bool $localize
638 *
639 * @return array
640 */
641 public static function indices($localize = TRUE) {
642 $indices = [
643 'UI_campaign_name' => [
644 'name' => 'UI_campaign_name',
645 'field' => [
646 0 => 'name',
647 ],
648 'localizable' => FALSE,
649 'sig' => 'civicrm_campaign::0::name',
650 ],
651 'UI_campaign_type_id' => [
652 'name' => 'UI_campaign_type_id',
653 'field' => [
654 0 => 'campaign_type_id',
655 ],
656 'localizable' => FALSE,
657 'sig' => 'civicrm_campaign::0::campaign_type_id',
658 ],
659 'UI_campaign_status_id' => [
660 'name' => 'UI_campaign_status_id',
661 'field' => [
662 0 => 'status_id',
663 ],
664 'localizable' => FALSE,
665 'sig' => 'civicrm_campaign::0::status_id',
666 ],
667 'UI_external_identifier' => [
668 'name' => 'UI_external_identifier',
669 'field' => [
670 0 => 'external_identifier',
671 ],
672 'localizable' => FALSE,
673 'unique' => TRUE,
674 'sig' => 'civicrm_campaign::1::external_identifier',
675 ],
676 ];
677 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
678 }
679
680 }