curious
[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:9d4da1f7966af86e8426aa449826f41c)
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 user-friendly description of this entity.
198 *
199 * @return string
200 */
201 public static function getEntityDescription() {
202 return ts('Campaigns link activities, contributions, mailings, etc. that share a programmatic goal.');
203 }
204
205 /**
206 * Returns foreign keys and entity references.
207 *
208 * @return array
209 * [CRM_Core_Reference_Interface]
210 */
211 public static function getReferenceColumns() {
212 if (!isset(Civi::$statics[__CLASS__]['links'])) {
213 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
214 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'parent_id', 'civicrm_campaign', 'id');
215 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id');
216 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'last_modified_id', 'civicrm_contact', 'id');
217 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
218 }
219 return Civi::$statics[__CLASS__]['links'];
220 }
221
222 /**
223 * Returns all the column names of this table
224 *
225 * @return array
226 */
227 public static function &fields() {
228 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
229 Civi::$statics[__CLASS__]['fields'] = [
230 'id' => [
231 'name' => 'id',
232 'type' => CRM_Utils_Type::T_INT,
233 'title' => ts('Campaign ID'),
234 'description' => ts('Unique Campaign ID.'),
235 'required' => TRUE,
236 'import' => TRUE,
237 'where' => 'civicrm_campaign.id',
238 'export' => TRUE,
239 'table_name' => 'civicrm_campaign',
240 'entity' => 'Campaign',
241 'bao' => 'CRM_Campaign_BAO_Campaign',
242 'localizable' => 0,
243 'html' => [
244 'type' => 'Number',
245 ],
246 'readonly' => TRUE,
247 'add' => '3.3',
248 ],
249 'name' => [
250 'name' => 'name',
251 'type' => CRM_Utils_Type::T_STRING,
252 'title' => ts('Campaign Name'),
253 'description' => ts('Name of the Campaign.'),
254 'required' => TRUE,
255 'maxlength' => 255,
256 'size' => CRM_Utils_Type::HUGE,
257 'import' => TRUE,
258 'where' => 'civicrm_campaign.name',
259 'export' => TRUE,
260 'table_name' => 'civicrm_campaign',
261 'entity' => 'Campaign',
262 'bao' => 'CRM_Campaign_BAO_Campaign',
263 'localizable' => 0,
264 'html' => [
265 'type' => 'Text',
266 ],
267 'add' => '3.3',
268 ],
269 'title' => [
270 'name' => 'title',
271 'type' => CRM_Utils_Type::T_STRING,
272 'title' => ts('Campaign Title'),
273 'description' => ts('Title of the Campaign.'),
274 'maxlength' => 255,
275 'size' => CRM_Utils_Type::HUGE,
276 'import' => TRUE,
277 'where' => 'civicrm_campaign.title',
278 'export' => TRUE,
279 'table_name' => 'civicrm_campaign',
280 'entity' => 'Campaign',
281 'bao' => 'CRM_Campaign_BAO_Campaign',
282 'localizable' => 0,
283 'html' => [
284 'type' => 'Text',
285 ],
286 'add' => '3.3',
287 ],
288 'description' => [
289 'name' => 'description',
290 'type' => CRM_Utils_Type::T_TEXT,
291 'title' => ts('Campaign Description'),
292 'description' => ts('Full description of Campaign.'),
293 'rows' => 8,
294 'cols' => 60,
295 'where' => 'civicrm_campaign.description',
296 'table_name' => 'civicrm_campaign',
297 'entity' => 'Campaign',
298 'bao' => 'CRM_Campaign_BAO_Campaign',
299 'localizable' => 0,
300 'html' => [
301 'type' => 'TextArea',
302 ],
303 'add' => '3.3',
304 ],
305 'start_date' => [
306 'name' => 'start_date',
307 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
308 'title' => ts('Campaign Start Date'),
309 'description' => ts('Date and time that Campaign starts.'),
310 'import' => TRUE,
311 'where' => 'civicrm_campaign.start_date',
312 'headerPattern' => '/^start|(s(tart\s)?date)$/i',
313 'export' => TRUE,
314 'table_name' => 'civicrm_campaign',
315 'entity' => 'Campaign',
316 'bao' => 'CRM_Campaign_BAO_Campaign',
317 'localizable' => 0,
318 'html' => [
319 'type' => 'Select Date',
320 'formatType' => 'activityDateTime',
321 ],
322 'add' => '3.3',
323 ],
324 'end_date' => [
325 'name' => 'end_date',
326 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
327 'title' => ts('Campaign End Date'),
328 'description' => ts('Date and time that Campaign ends.'),
329 'import' => TRUE,
330 'where' => 'civicrm_campaign.end_date',
331 'headerPattern' => '/^end|(e(nd\s)?date)$/i',
332 'export' => TRUE,
333 'table_name' => 'civicrm_campaign',
334 'entity' => 'Campaign',
335 'bao' => 'CRM_Campaign_BAO_Campaign',
336 'localizable' => 0,
337 'html' => [
338 'type' => 'Select Date',
339 'formatType' => 'activityDateTime',
340 ],
341 'add' => '3.3',
342 ],
343 'campaign_type_id' => [
344 'name' => 'campaign_type_id',
345 'type' => CRM_Utils_Type::T_INT,
346 'title' => ts('Campaign Type'),
347 'description' => ts('Campaign Type ID.Implicit FK to civicrm_option_value where option_group = campaign_type'),
348 'import' => TRUE,
349 'where' => 'civicrm_campaign.campaign_type_id',
350 'export' => TRUE,
351 'default' => NULL,
352 'table_name' => 'civicrm_campaign',
353 'entity' => 'Campaign',
354 'bao' => 'CRM_Campaign_BAO_Campaign',
355 'localizable' => 0,
356 'html' => [
357 'type' => 'Select',
358 ],
359 'pseudoconstant' => [
360 'optionGroupName' => 'campaign_type',
361 'optionEditPath' => 'civicrm/admin/options/campaign_type',
362 ],
363 'add' => '3.3',
364 ],
365 'status_id' => [
366 'name' => 'status_id',
367 'type' => CRM_Utils_Type::T_INT,
368 'title' => ts('Campaign Status'),
369 'description' => ts('Campaign status ID.Implicit FK to civicrm_option_value where option_group = campaign_status'),
370 'import' => TRUE,
371 'where' => 'civicrm_campaign.status_id',
372 'export' => TRUE,
373 'default' => NULL,
374 'table_name' => 'civicrm_campaign',
375 'entity' => 'Campaign',
376 'bao' => 'CRM_Campaign_BAO_Campaign',
377 'localizable' => 0,
378 'html' => [
379 'type' => 'Select',
380 ],
381 'pseudoconstant' => [
382 'optionGroupName' => 'campaign_status',
383 'optionEditPath' => 'civicrm/admin/options/campaign_status',
384 ],
385 'add' => '3.3',
386 ],
387 'external_identifier' => [
388 'name' => 'external_identifier',
389 'type' => CRM_Utils_Type::T_STRING,
390 'title' => ts('Campaign External ID'),
391 'description' => ts('Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.'),
392 'maxlength' => 32,
393 'size' => CRM_Utils_Type::MEDIUM,
394 'import' => TRUE,
395 'where' => 'civicrm_campaign.external_identifier',
396 'headerPattern' => '/external\s?id/i',
397 'dataPattern' => '/^\d{11,}$/',
398 'export' => TRUE,
399 'table_name' => 'civicrm_campaign',
400 'entity' => 'Campaign',
401 'bao' => 'CRM_Campaign_BAO_Campaign',
402 'localizable' => 0,
403 'html' => [
404 'type' => 'Text',
405 ],
406 'add' => '3.3',
407 ],
408 'parent_id' => [
409 'name' => 'parent_id',
410 'type' => CRM_Utils_Type::T_INT,
411 'title' => ts('Parent Campaign ID'),
412 'description' => ts('Optional parent id for this Campaign.'),
413 'import' => TRUE,
414 'where' => 'civicrm_campaign.parent_id',
415 'export' => TRUE,
416 'default' => NULL,
417 'table_name' => 'civicrm_campaign',
418 'entity' => 'Campaign',
419 'bao' => 'CRM_Campaign_BAO_Campaign',
420 'localizable' => 0,
421 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
422 'html' => [
423 'type' => 'EntityRef',
424 'label' => ts("Parent Campaign"),
425 ],
426 'add' => '3.3',
427 ],
428 'is_active' => [
429 'name' => 'is_active',
430 'type' => CRM_Utils_Type::T_BOOLEAN,
431 'title' => ts('Is Campaign Active?'),
432 'description' => ts('Is this Campaign enabled or disabled/cancelled?'),
433 'where' => 'civicrm_campaign.is_active',
434 'default' => '1',
435 'table_name' => 'civicrm_campaign',
436 'entity' => 'Campaign',
437 'bao' => 'CRM_Campaign_BAO_Campaign',
438 'localizable' => 0,
439 'html' => [
440 'type' => 'CheckBox',
441 ],
442 'add' => '3.3',
443 ],
444 'created_id' => [
445 'name' => 'created_id',
446 'type' => CRM_Utils_Type::T_INT,
447 'title' => ts('Created By Contact ID'),
448 'description' => ts('FK to civicrm_contact, who created this Campaign.'),
449 'where' => 'civicrm_campaign.created_id',
450 'table_name' => 'civicrm_campaign',
451 'entity' => 'Campaign',
452 'bao' => 'CRM_Campaign_BAO_Campaign',
453 'localizable' => 0,
454 'FKClassName' => 'CRM_Contact_DAO_Contact',
455 'html' => [
456 'label' => ts("Created By"),
457 ],
458 'add' => '3.3',
459 ],
460 'created_date' => [
461 'name' => 'created_date',
462 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
463 'title' => ts('Campaign Created Date'),
464 'description' => ts('Date and time that Campaign was created.'),
465 'where' => 'civicrm_campaign.created_date',
466 'table_name' => 'civicrm_campaign',
467 'entity' => 'Campaign',
468 'bao' => 'CRM_Campaign_BAO_Campaign',
469 'localizable' => 0,
470 'html' => [
471 'type' => 'Select Date',
472 'formatType' => 'activityDateTime',
473 ],
474 'add' => '3.3',
475 ],
476 'last_modified_id' => [
477 'name' => 'last_modified_id',
478 'type' => CRM_Utils_Type::T_INT,
479 'title' => ts('Modified By Contact ID'),
480 'description' => ts('FK to civicrm_contact, who recently edited this Campaign.'),
481 'where' => 'civicrm_campaign.last_modified_id',
482 'table_name' => 'civicrm_campaign',
483 'entity' => 'Campaign',
484 'bao' => 'CRM_Campaign_BAO_Campaign',
485 'localizable' => 0,
486 'FKClassName' => 'CRM_Contact_DAO_Contact',
487 'html' => [
488 'label' => ts("Modified By"),
489 ],
490 'add' => '3.3',
491 ],
492 'last_modified_date' => [
493 'name' => 'last_modified_date',
494 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
495 'title' => ts('Campaign Modified Date'),
496 'description' => ts('Date and time that Campaign was edited last time.'),
497 'where' => 'civicrm_campaign.last_modified_date',
498 'table_name' => 'civicrm_campaign',
499 'entity' => 'Campaign',
500 'bao' => 'CRM_Campaign_BAO_Campaign',
501 'localizable' => 0,
502 'add' => '3.3',
503 ],
504 'goal_general' => [
505 'name' => 'goal_general',
506 'type' => CRM_Utils_Type::T_TEXT,
507 'title' => ts('Campaign Goals'),
508 'description' => ts('General goals for Campaign.'),
509 'where' => 'civicrm_campaign.goal_general',
510 'table_name' => 'civicrm_campaign',
511 'entity' => 'Campaign',
512 'bao' => 'CRM_Campaign_BAO_Campaign',
513 'localizable' => 0,
514 'html' => [
515 'type' => 'RichTextEditor',
516 ],
517 'add' => '3.4',
518 ],
519 'goal_revenue' => [
520 'name' => 'goal_revenue',
521 'type' => CRM_Utils_Type::T_MONEY,
522 'title' => ts('Goal Revenue'),
523 'description' => ts('The target revenue for this campaign.'),
524 'precision' => [
525 20,
526 2,
527 ],
528 'where' => 'civicrm_campaign.goal_revenue',
529 'table_name' => 'civicrm_campaign',
530 'entity' => 'Campaign',
531 'bao' => 'CRM_Campaign_BAO_Campaign',
532 'localizable' => 0,
533 'html' => [
534 'type' => 'Text',
535 'label' => ts("Goal Revenue"),
536 ],
537 'add' => '3.4',
538 ],
539 ];
540 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
541 }
542 return Civi::$statics[__CLASS__]['fields'];
543 }
544
545 /**
546 * Return a mapping from field-name to the corresponding key (as used in fields()).
547 *
548 * @return array
549 * Array(string $name => string $uniqueName).
550 */
551 public static function &fieldKeys() {
552 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
553 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
554 }
555 return Civi::$statics[__CLASS__]['fieldKeys'];
556 }
557
558 /**
559 * Returns the names of this table
560 *
561 * @return string
562 */
563 public static function getTableName() {
564 return self::$_tableName;
565 }
566
567 /**
568 * Returns if this table needs to be logged
569 *
570 * @return bool
571 */
572 public function getLog() {
573 return self::$_log;
574 }
575
576 /**
577 * Returns the list of fields that can be imported
578 *
579 * @param bool $prefix
580 *
581 * @return array
582 */
583 public static function &import($prefix = FALSE) {
584 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'campaign', $prefix, []);
585 return $r;
586 }
587
588 /**
589 * Returns the list of fields that can be exported
590 *
591 * @param bool $prefix
592 *
593 * @return array
594 */
595 public static function &export($prefix = FALSE) {
596 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'campaign', $prefix, []);
597 return $r;
598 }
599
600 /**
601 * Returns the list of indices
602 *
603 * @param bool $localize
604 *
605 * @return array
606 */
607 public static function indices($localize = TRUE) {
608 $indices = [
609 'UI_campaign_name' => [
610 'name' => 'UI_campaign_name',
611 'field' => [
612 0 => 'name',
613 ],
614 'localizable' => FALSE,
615 'sig' => 'civicrm_campaign::0::name',
616 ],
617 'UI_campaign_type_id' => [
618 'name' => 'UI_campaign_type_id',
619 'field' => [
620 0 => 'campaign_type_id',
621 ],
622 'localizable' => FALSE,
623 'sig' => 'civicrm_campaign::0::campaign_type_id',
624 ],
625 'UI_campaign_status_id' => [
626 'name' => 'UI_campaign_status_id',
627 'field' => [
628 0 => 'status_id',
629 ],
630 'localizable' => FALSE,
631 'sig' => 'civicrm_campaign::0::status_id',
632 ],
633 'UI_external_identifier' => [
634 'name' => 'UI_external_identifier',
635 'field' => [
636 0 => 'external_identifier',
637 ],
638 'localizable' => FALSE,
639 'unique' => TRUE,
640 'sig' => 'civicrm_campaign::1::external_identifier',
641 ],
642 ];
643 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
644 }
645
646 }