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