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