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