Issue template - Small tweak
[civicrm-core.git] / CRM / Campaign / DAO / Campaign.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
6b83d5bd 5 * @copyright CiviCRM LLC (c) 2004-2019
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/Campaign/Campaign.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
74db51d3 9 * (GenCodeChecksum:ab19aa73d01b529988c178673fc38d58)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the Campaign entity.
f41f0342 14 */
e501603b 15class CRM_Campaign_DAO_Campaign extends CRM_Core_DAO {
c3fc2621 16
e501603b 17 /**
f41f0342 18 * Static instance to hold the table name.
e501603b
TO
19 *
20 * @var string
21 */
fa45b5b9 22 public static $_tableName = 'civicrm_campaign';
c3fc2621 23
e501603b 24 /**
f41f0342 25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 26 *
c3fc2621 27 * @var bool
e501603b 28 */
fa45b5b9 29 public static $_log = FALSE;
c3fc2621 30
e501603b
TO
31 /**
32 * Unique Campaign ID.
33 *
e6ca0a57 34 * @var int
e501603b
TO
35 */
36 public $id;
c3fc2621 37
e501603b
TO
38 /**
39 * Name of the Campaign.
40 *
41 * @var string
42 */
43 public $name;
c3fc2621 44
e501603b
TO
45 /**
46 * Title of the Campaign.
47 *
48 * @var string
49 */
50 public $title;
c3fc2621 51
e501603b
TO
52 /**
53 * Full description of Campaign.
54 *
55 * @var text
56 */
57 public $description;
c3fc2621 58
e501603b
TO
59 /**
60 * Date and time that Campaign starts.
61 *
62 * @var datetime
63 */
64 public $start_date;
c3fc2621 65
e501603b
TO
66 /**
67 * Date and time that Campaign ends.
68 *
69 * @var datetime
70 */
71 public $end_date;
c3fc2621 72
e501603b
TO
73 /**
74 * Campaign Type ID.Implicit FK to civicrm_option_value where option_group = campaign_type
75 *
e6ca0a57 76 * @var int
e501603b
TO
77 */
78 public $campaign_type_id;
c3fc2621 79
e501603b
TO
80 /**
81 * Campaign status ID.Implicit FK to civicrm_option_value where option_group = campaign_status
82 *
e6ca0a57 83 * @var int
e501603b
TO
84 */
85 public $status_id;
c3fc2621 86
e501603b
TO
87 /**
88 * Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.
89 *
90 * @var string
91 */
92 public $external_identifier;
c3fc2621 93
e501603b
TO
94 /**
95 * Optional parent id for this Campaign.
96 *
e6ca0a57 97 * @var int
e501603b
TO
98 */
99 public $parent_id;
c3fc2621 100
e501603b
TO
101 /**
102 * Is this Campaign enabled or disabled/cancelled?
103 *
e6ca0a57 104 * @var bool
e501603b
TO
105 */
106 public $is_active;
c3fc2621 107
e501603b
TO
108 /**
109 * FK to civicrm_contact, who created this Campaign.
110 *
e6ca0a57 111 * @var int
e501603b
TO
112 */
113 public $created_id;
c3fc2621 114
e501603b
TO
115 /**
116 * Date and time that Campaign was created.
117 *
118 * @var datetime
119 */
120 public $created_date;
c3fc2621 121
e501603b
TO
122 /**
123 * FK to civicrm_contact, who recently edited this Campaign.
124 *
e6ca0a57 125 * @var int
e501603b
TO
126 */
127 public $last_modified_id;
c3fc2621 128
e501603b
TO
129 /**
130 * Date and time that Campaign was edited last time.
131 *
132 * @var datetime
133 */
134 public $last_modified_date;
c3fc2621 135
e501603b
TO
136 /**
137 * General goals for Campaign.
138 *
139 * @var text
140 */
141 public $goal_general;
c3fc2621 142
e501603b
TO
143 /**
144 * The target revenue for this campaign.
145 *
146 * @var float
147 */
148 public $goal_revenue;
c3fc2621 149
e501603b 150 /**
f41f0342 151 * Class constructor.
e501603b 152 */
c3fc2621 153 public function __construct() {
e501603b
TO
154 $this->__table = 'civicrm_campaign';
155 parent::__construct();
156 }
c3fc2621 157
e501603b 158 /**
f41f0342 159 * Returns foreign keys and entity references.
e501603b
TO
160 *
161 * @return array
162 * [CRM_Core_Reference_Interface]
163 */
c3fc2621 164 public static function getReferenceColumns() {
346aaaba 165 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 166 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
167 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'parent_id', 'civicrm_campaign', 'id');
168 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id');
169 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'last_modified_id', 'civicrm_contact', 'id');
346aaaba 170 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 171 }
346aaaba 172 return Civi::$statics[__CLASS__]['links'];
e501603b 173 }
c3fc2621 174
e501603b
TO
175 /**
176 * Returns all the column names of this table
177 *
178 * @return array
179 */
c3fc2621 180 public static function &fields() {
346aaaba 181 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
182 Civi::$statics[__CLASS__]['fields'] = [
183 'id' => [
e501603b
TO
184 'name' => 'id',
185 'type' => CRM_Utils_Type::T_INT,
c3fc2621 186 'title' => ts('Campaign ID'),
215b423e 187 'description' => ts('Unique Campaign ID.'),
c3fc2621
CW
188 'required' => TRUE,
189 'import' => TRUE,
e501603b 190 'where' => 'civicrm_campaign.id',
c3fc2621 191 'export' => TRUE,
522a26c9 192 'table_name' => 'civicrm_campaign',
193 'entity' => 'Campaign',
194 'bao' => 'CRM_Campaign_BAO_Campaign',
6a7e5e5d 195 'localizable' => 0,
c3fc2621
CW
196 ],
197 'name' => [
e501603b
TO
198 'name' => 'name',
199 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 200 'title' => ts('Campaign Name'),
215b423e 201 'description' => ts('Name of the Campaign.'),
c3fc2621 202 'required' => TRUE,
e501603b
TO
203 'maxlength' => 255,
204 'size' => CRM_Utils_Type::HUGE,
c3fc2621 205 'import' => TRUE,
e501603b 206 'where' => 'civicrm_campaign.name',
c3fc2621 207 'export' => TRUE,
522a26c9 208 'table_name' => 'civicrm_campaign',
209 'entity' => 'Campaign',
210 'bao' => 'CRM_Campaign_BAO_Campaign',
6a7e5e5d 211 'localizable' => 0,
c3fc2621 212 'html' => [
e501603b 213 'type' => 'Text',
c3fc2621
CW
214 ],
215 ],
216 'title' => [
e501603b
TO
217 'name' => 'title',
218 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 219 'title' => ts('Campaign Title'),
215b423e 220 'description' => ts('Title of the Campaign.'),
e501603b
TO
221 'maxlength' => 255,
222 'size' => CRM_Utils_Type::HUGE,
c3fc2621 223 'import' => TRUE,
e501603b 224 'where' => 'civicrm_campaign.title',
c3fc2621 225 'export' => TRUE,
522a26c9 226 'table_name' => 'civicrm_campaign',
227 'entity' => 'Campaign',
228 'bao' => 'CRM_Campaign_BAO_Campaign',
6a7e5e5d 229 'localizable' => 0,
c3fc2621 230 'html' => [
e501603b 231 'type' => 'Text',
c3fc2621
CW
232 ],
233 ],
234 'description' => [
e501603b
TO
235 'name' => 'description',
236 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 237 'title' => ts('Campaign Description'),
215b423e 238 'description' => ts('Full description of Campaign.'),
e501603b
TO
239 'rows' => 8,
240 'cols' => 60,
a36434b9 241 'where' => 'civicrm_campaign.description',
522a26c9 242 'table_name' => 'civicrm_campaign',
243 'entity' => 'Campaign',
244 'bao' => 'CRM_Campaign_BAO_Campaign',
6a7e5e5d 245 'localizable' => 0,
c3fc2621 246 'html' => [
e501603b 247 'type' => 'TextArea',
c3fc2621
CW
248 ],
249 ],
250 'start_date' => [
e501603b
TO
251 'name' => 'start_date',
252 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 253 'title' => ts('Campaign Start Date'),
215b423e 254 'description' => ts('Date and time that Campaign starts.'),
c3fc2621 255 'import' => TRUE,
e501603b
TO
256 'where' => 'civicrm_campaign.start_date',
257 'headerPattern' => '/^start|(s(tart\s)?date)$/i',
c3fc2621 258 'export' => TRUE,
522a26c9 259 'table_name' => 'civicrm_campaign',
260 'entity' => 'Campaign',
261 'bao' => 'CRM_Campaign_BAO_Campaign',
6a7e5e5d 262 'localizable' => 0,
c3fc2621 263 'html' => [
e501603b 264 'type' => 'Select Date',
c3fc2621
CW
265 ],
266 ],
267 'end_date' => [
e501603b
TO
268 'name' => 'end_date',
269 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 270 'title' => ts('Campaign End Date'),
215b423e 271 'description' => ts('Date and time that Campaign ends.'),
c3fc2621 272 'import' => TRUE,
e501603b
TO
273 'where' => 'civicrm_campaign.end_date',
274 'headerPattern' => '/^end|(e(nd\s)?date)$/i',
c3fc2621 275 'export' => TRUE,
522a26c9 276 'table_name' => 'civicrm_campaign',
277 'entity' => 'Campaign',
278 'bao' => 'CRM_Campaign_BAO_Campaign',
6a7e5e5d 279 'localizable' => 0,
c3fc2621 280 'html' => [
e501603b 281 'type' => 'Select Date',
c3fc2621
CW
282 ],
283 ],
284 'campaign_type_id' => [
e501603b
TO
285 'name' => 'campaign_type_id',
286 'type' => CRM_Utils_Type::T_INT,
c3fc2621 287 'title' => ts('Campaign Type'),
215b423e 288 'description' => ts('Campaign Type ID.Implicit FK to civicrm_option_value where option_group = campaign_type'),
c3fc2621 289 'import' => TRUE,
e501603b 290 'where' => 'civicrm_campaign.campaign_type_id',
c3fc2621 291 'export' => TRUE,
e501603b 292 'default' => 'NULL',
522a26c9 293 'table_name' => 'civicrm_campaign',
294 'entity' => 'Campaign',
295 'bao' => 'CRM_Campaign_BAO_Campaign',
6a7e5e5d 296 'localizable' => 0,
c3fc2621 297 'html' => [
e501603b 298 'type' => 'Select',
c3fc2621
CW
299 ],
300 'pseudoconstant' => [
e501603b
TO
301 'optionGroupName' => 'campaign_type',
302 'optionEditPath' => 'civicrm/admin/options/campaign_type',
e6ca0a57 303 ],
c3fc2621
CW
304 ],
305 'status_id' => [
e501603b
TO
306 'name' => 'status_id',
307 'type' => CRM_Utils_Type::T_INT,
c3fc2621 308 'title' => ts('Campaign Status'),
215b423e 309 'description' => ts('Campaign status ID.Implicit FK to civicrm_option_value where option_group = campaign_status'),
c3fc2621 310 'import' => TRUE,
e501603b 311 'where' => 'civicrm_campaign.status_id',
c3fc2621 312 'export' => TRUE,
e501603b 313 'default' => 'NULL',
522a26c9 314 'table_name' => 'civicrm_campaign',
315 'entity' => 'Campaign',
316 'bao' => 'CRM_Campaign_BAO_Campaign',
6a7e5e5d 317 'localizable' => 0,
c3fc2621 318 'html' => [
e501603b 319 'type' => 'Select',
c3fc2621
CW
320 ],
321 'pseudoconstant' => [
e501603b
TO
322 'optionGroupName' => 'campaign_status',
323 'optionEditPath' => 'civicrm/admin/options/campaign_status',
e6ca0a57 324 ],
c3fc2621
CW
325 ],
326 'external_identifier' => [
e501603b
TO
327 'name' => 'external_identifier',
328 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 329 'title' => ts('Campaign External ID'),
215b423e 330 'description' => ts('Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.'),
e501603b
TO
331 'maxlength' => 32,
332 'size' => CRM_Utils_Type::MEDIUM,
c3fc2621 333 'import' => TRUE,
e501603b
TO
334 'where' => 'civicrm_campaign.external_identifier',
335 'headerPattern' => '/external\s?id/i',
336 'dataPattern' => '/^\d{11,}$/',
c3fc2621 337 'export' => TRUE,
522a26c9 338 'table_name' => 'civicrm_campaign',
339 'entity' => 'Campaign',
340 'bao' => 'CRM_Campaign_BAO_Campaign',
6a7e5e5d 341 'localizable' => 0,
c3fc2621 342 'html' => [
e501603b 343 'type' => 'Text',
c3fc2621
CW
344 ],
345 ],
346 'parent_id' => [
e501603b
TO
347 'name' => 'parent_id',
348 'type' => CRM_Utils_Type::T_INT,
c3fc2621 349 'title' => ts('Parent Campaign'),
215b423e 350 'description' => ts('Optional parent id for this Campaign.'),
c3fc2621 351 'import' => TRUE,
e501603b 352 'where' => 'civicrm_campaign.parent_id',
c3fc2621 353 'export' => TRUE,
e501603b 354 'default' => 'NULL',
522a26c9 355 'table_name' => 'civicrm_campaign',
356 'entity' => 'Campaign',
357 'bao' => 'CRM_Campaign_BAO_Campaign',
6a7e5e5d 358 'localizable' => 0,
e501603b 359 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
c3fc2621 360 'html' => [
e501603b 361 'type' => 'EntityRef',
c3fc2621
CW
362 ],
363 ],
364 'is_active' => [
e501603b
TO
365 'name' => 'is_active',
366 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 367 'title' => ts('Is Campaign Active?'),
215b423e 368 'description' => ts('Is this Campaign enabled or disabled/cancelled?'),
a36434b9 369 'where' => 'civicrm_campaign.is_active',
e501603b 370 'default' => '1',
522a26c9 371 'table_name' => 'civicrm_campaign',
372 'entity' => 'Campaign',
373 'bao' => 'CRM_Campaign_BAO_Campaign',
6a7e5e5d 374 'localizable' => 0,
c3fc2621 375 'html' => [
e501603b 376 'type' => 'CheckBox',
c3fc2621
CW
377 ],
378 ],
379 'created_id' => [
e501603b
TO
380 'name' => 'created_id',
381 'type' => CRM_Utils_Type::T_INT,
c3fc2621 382 'title' => ts('Campaign Created By'),
215b423e 383 'description' => ts('FK to civicrm_contact, who created this Campaign.'),
a36434b9 384 'where' => 'civicrm_campaign.created_id',
522a26c9 385 'table_name' => 'civicrm_campaign',
386 'entity' => 'Campaign',
387 'bao' => 'CRM_Campaign_BAO_Campaign',
6a7e5e5d 388 'localizable' => 0,
e501603b 389 'FKClassName' => 'CRM_Contact_DAO_Contact',
c3fc2621
CW
390 ],
391 'created_date' => [
e501603b
TO
392 'name' => 'created_date',
393 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 394 'title' => ts('Campaign Created Date'),
215b423e 395 'description' => ts('Date and time that Campaign was created.'),
a36434b9 396 'where' => 'civicrm_campaign.created_date',
522a26c9 397 'table_name' => 'civicrm_campaign',
398 'entity' => 'Campaign',
399 'bao' => 'CRM_Campaign_BAO_Campaign',
6a7e5e5d 400 'localizable' => 0,
c3fc2621 401 'html' => [
e501603b 402 'type' => 'Select Date',
c3fc2621
CW
403 ],
404 ],
405 'last_modified_id' => [
e501603b
TO
406 'name' => 'last_modified_id',
407 'type' => CRM_Utils_Type::T_INT,
c3fc2621 408 'title' => ts('Campaign Modified By'),
215b423e 409 'description' => ts('FK to civicrm_contact, who recently edited this Campaign.'),
a36434b9 410 'where' => 'civicrm_campaign.last_modified_id',
522a26c9 411 'table_name' => 'civicrm_campaign',
412 'entity' => 'Campaign',
413 'bao' => 'CRM_Campaign_BAO_Campaign',
6a7e5e5d 414 'localizable' => 0,
e501603b 415 'FKClassName' => 'CRM_Contact_DAO_Contact',
c3fc2621
CW
416 ],
417 'last_modified_date' => [
e501603b
TO
418 'name' => 'last_modified_date',
419 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 420 'title' => ts('Campaign Modified Date'),
215b423e 421 'description' => ts('Date and time that Campaign was edited last time.'),
a36434b9 422 'where' => 'civicrm_campaign.last_modified_date',
522a26c9 423 'table_name' => 'civicrm_campaign',
424 'entity' => 'Campaign',
425 'bao' => 'CRM_Campaign_BAO_Campaign',
6a7e5e5d 426 'localizable' => 0,
c3fc2621
CW
427 ],
428 'goal_general' => [
e501603b
TO
429 'name' => 'goal_general',
430 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 431 'title' => ts('Campaign Goals'),
215b423e 432 'description' => ts('General goals for Campaign.'),
a36434b9 433 'where' => 'civicrm_campaign.goal_general',
522a26c9 434 'table_name' => 'civicrm_campaign',
435 'entity' => 'Campaign',
436 'bao' => 'CRM_Campaign_BAO_Campaign',
6a7e5e5d 437 'localizable' => 0,
c3fc2621 438 'html' => [
e501603b 439 'type' => 'RichTextEditor',
c3fc2621
CW
440 ],
441 ],
442 'goal_revenue' => [
e501603b
TO
443 'name' => 'goal_revenue',
444 'type' => CRM_Utils_Type::T_MONEY,
c3fc2621 445 'title' => ts('Goal Revenue'),
215b423e 446 'description' => ts('The target revenue for this campaign.'),
c3fc2621 447 'precision' => [
e501603b 448 20,
fb607354 449 2,
c3fc2621 450 ],
a36434b9 451 'where' => 'civicrm_campaign.goal_revenue',
522a26c9 452 'table_name' => 'civicrm_campaign',
453 'entity' => 'Campaign',
454 'bao' => 'CRM_Campaign_BAO_Campaign',
6a7e5e5d 455 'localizable' => 0,
c3fc2621 456 'html' => [
e501603b 457 'type' => 'Text',
c3fc2621
CW
458 ],
459 ],
460 ];
346aaaba 461 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 462 }
346aaaba 463 return Civi::$statics[__CLASS__]['fields'];
e501603b 464 }
c3fc2621 465
e501603b 466 /**
bd8e0b14 467 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
468 *
469 * @return array
bd8e0b14 470 * Array(string $name => string $uniqueName).
e501603b 471 */
c3fc2621 472 public static function &fieldKeys() {
bd8e0b14
TO
473 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
474 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 475 }
bd8e0b14 476 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 477 }
c3fc2621 478
e501603b
TO
479 /**
480 * Returns the names of this table
481 *
482 * @return string
483 */
c3fc2621 484 public static function getTableName() {
e501603b
TO
485 return self::$_tableName;
486 }
c3fc2621 487
e501603b
TO
488 /**
489 * Returns if this table needs to be logged
490 *
c3fc2621 491 * @return bool
e501603b 492 */
c3fc2621 493 public function getLog() {
e501603b
TO
494 return self::$_log;
495 }
c3fc2621 496
e501603b
TO
497 /**
498 * Returns the list of fields that can be imported
499 *
500 * @param bool $prefix
501 *
502 * @return array
503 */
c3fc2621
CW
504 public static function &import($prefix = FALSE) {
505 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'campaign', $prefix, []);
60808919 506 return $r;
e501603b 507 }
c3fc2621 508
e501603b
TO
509 /**
510 * Returns the list of fields that can be exported
511 *
512 * @param bool $prefix
513 *
514 * @return array
515 */
c3fc2621
CW
516 public static function &export($prefix = FALSE) {
517 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'campaign', $prefix, []);
60808919 518 return $r;
e501603b 519 }
c3fc2621 520
e7a6b91a
AS
521 /**
522 * Returns the list of indices
c3fc2621
CW
523 *
524 * @param bool $localize
525 *
526 * @return array
e7a6b91a
AS
527 */
528 public static function indices($localize = TRUE) {
c3fc2621
CW
529 $indices = [
530 'UI_campaign_type_id' => [
e7a6b91a 531 'name' => 'UI_campaign_type_id',
c3fc2621 532 'field' => [
e7a6b91a 533 0 => 'campaign_type_id',
c3fc2621
CW
534 ],
535 'localizable' => FALSE,
e7a6b91a 536 'sig' => 'civicrm_campaign::0::campaign_type_id',
c3fc2621
CW
537 ],
538 'UI_campaign_status_id' => [
e7a6b91a 539 'name' => 'UI_campaign_status_id',
c3fc2621 540 'field' => [
e7a6b91a 541 0 => 'status_id',
c3fc2621
CW
542 ],
543 'localizable' => FALSE,
e7a6b91a 544 'sig' => 'civicrm_campaign::0::status_id',
c3fc2621
CW
545 ],
546 'UI_external_identifier' => [
e7a6b91a 547 'name' => 'UI_external_identifier',
c3fc2621 548 'field' => [
e7a6b91a 549 0 => 'external_identifier',
c3fc2621
CW
550 ],
551 'localizable' => FALSE,
552 'unique' => TRUE,
e7a6b91a 553 'sig' => 'civicrm_campaign::1::external_identifier',
c3fc2621
CW
554 ],
555 ];
e7a6b91a
AS
556 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
557 }
c3fc2621 558
e501603b 559}