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