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