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