Merge pull request #21433 from jmcclelland/import-preferred-communication-method
[civicrm-core.git] / CRM / Case / DAO / Case.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Case/Case.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:1ae35a7a60938212678c1585defc3506)
10 */
11
12 /**
13 * Database access object for the Case entity.
14 */
15 class CRM_Case_DAO_Case extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.8';
18 const COMPONENT = 'CiviCase';
19
20 /**
21 * Static instance to hold the table name.
22 *
23 * @var string
24 */
25 public static $_tableName = 'civicrm_case';
26
27 /**
28 * Icon associated with this entity.
29 *
30 * @var string
31 */
32 public static $_icon = 'fa-folder-open';
33
34 /**
35 * Field to show when displaying a record.
36 *
37 * @var string
38 */
39 public static $_labelField = 'subject';
40
41 /**
42 * Should CiviCRM log any modifications to this table in the civicrm_log table.
43 *
44 * @var bool
45 */
46 public static $_log = TRUE;
47
48 /**
49 * Unique Case ID
50 *
51 * @var int
52 */
53 public $id;
54
55 /**
56 * FK to civicrm_case_type.id
57 *
58 * @var int
59 */
60 public $case_type_id;
61
62 /**
63 * Short name of the case.
64 *
65 * @var string
66 */
67 public $subject;
68
69 /**
70 * Date on which given case starts.
71 *
72 * @var date
73 */
74 public $start_date;
75
76 /**
77 * Date on which given case ends.
78 *
79 * @var date
80 */
81 public $end_date;
82
83 /**
84 * Details populated from Open Case. Only used in the CiviCase extension.
85 *
86 * @var text
87 */
88 public $details;
89
90 /**
91 * ID of case status.
92 *
93 * @var int
94 */
95 public $status_id;
96
97 /**
98 * @var bool
99 */
100 public $is_deleted;
101
102 /**
103 * When was the case was created.
104 *
105 * @var timestamp
106 */
107 public $created_date;
108
109 /**
110 * When was the case (or closely related entity) was created or modified or deleted.
111 *
112 * @var timestamp
113 */
114 public $modified_date;
115
116 /**
117 * Class constructor.
118 */
119 public function __construct() {
120 $this->__table = 'civicrm_case';
121 parent::__construct();
122 }
123
124 /**
125 * Returns localized title of this entity.
126 *
127 * @param bool $plural
128 * Whether to return the plural version of the title.
129 */
130 public static function getEntityTitle($plural = FALSE) {
131 return $plural ? ts('Cases') : ts('Case');
132 }
133
134 /**
135 * Returns user-friendly description of this entity.
136 *
137 * @return string
138 */
139 public static function getEntityDescription() {
140 return ts('Collections of activities and relationships for a given purpose.');
141 }
142
143 /**
144 * Returns foreign keys and entity references.
145 *
146 * @return array
147 * [CRM_Core_Reference_Interface]
148 */
149 public static function getReferenceColumns() {
150 if (!isset(Civi::$statics[__CLASS__]['links'])) {
151 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
152 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'case_type_id', 'civicrm_case_type', 'id');
153 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
154 }
155 return Civi::$statics[__CLASS__]['links'];
156 }
157
158 /**
159 * Returns all the column names of this table
160 *
161 * @return array
162 */
163 public static function &fields() {
164 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
165 Civi::$statics[__CLASS__]['fields'] = [
166 'case_id' => [
167 'name' => 'id',
168 'type' => CRM_Utils_Type::T_INT,
169 'title' => ts('Case ID'),
170 'description' => ts('Unique Case ID'),
171 'required' => TRUE,
172 'import' => TRUE,
173 'where' => 'civicrm_case.id',
174 'export' => TRUE,
175 'table_name' => 'civicrm_case',
176 'entity' => 'Case',
177 'bao' => 'CRM_Case_BAO_Case',
178 'localizable' => 0,
179 'html' => [
180 'type' => 'Number',
181 ],
182 'readonly' => TRUE,
183 'add' => '1.8',
184 ],
185 'case_type_id' => [
186 'name' => 'case_type_id',
187 'type' => CRM_Utils_Type::T_INT,
188 'title' => ts('Case Type ID'),
189 'description' => ts('FK to civicrm_case_type.id'),
190 'required' => TRUE,
191 'import' => TRUE,
192 'where' => 'civicrm_case.case_type_id',
193 'export' => FALSE,
194 'table_name' => 'civicrm_case',
195 'entity' => 'Case',
196 'bao' => 'CRM_Case_BAO_Case',
197 'localizable' => 0,
198 'FKClassName' => 'CRM_Case_DAO_CaseType',
199 'html' => [
200 'type' => 'Select',
201 'label' => ts("Case Type"),
202 ],
203 'pseudoconstant' => [
204 'table' => 'civicrm_case_type',
205 'keyColumn' => 'id',
206 'labelColumn' => 'title',
207 ],
208 'add' => '2.0',
209 ],
210 'case_subject' => [
211 'name' => 'subject',
212 'type' => CRM_Utils_Type::T_STRING,
213 'title' => ts('Case Subject'),
214 'description' => ts('Short name of the case.'),
215 'maxlength' => 128,
216 'size' => CRM_Utils_Type::HUGE,
217 'import' => TRUE,
218 'where' => 'civicrm_case.subject',
219 'export' => TRUE,
220 'table_name' => 'civicrm_case',
221 'entity' => 'Case',
222 'bao' => 'CRM_Case_BAO_Case',
223 'localizable' => 0,
224 'html' => [
225 'type' => 'Text',
226 ],
227 'add' => '1.8',
228 ],
229 'case_start_date' => [
230 'name' => 'start_date',
231 'type' => CRM_Utils_Type::T_DATE,
232 'title' => ts('Case Start Date'),
233 'description' => ts('Date on which given case starts.'),
234 'import' => TRUE,
235 'where' => 'civicrm_case.start_date',
236 'export' => TRUE,
237 'table_name' => 'civicrm_case',
238 'entity' => 'Case',
239 'bao' => 'CRM_Case_BAO_Case',
240 'localizable' => 0,
241 'html' => [
242 'type' => 'Select Date',
243 'formatType' => 'activityDateTime',
244 ],
245 'add' => '1.8',
246 ],
247 'case_end_date' => [
248 'name' => 'end_date',
249 'type' => CRM_Utils_Type::T_DATE,
250 'title' => ts('Case End Date'),
251 'description' => ts('Date on which given case ends.'),
252 'import' => TRUE,
253 'where' => 'civicrm_case.end_date',
254 'export' => TRUE,
255 'table_name' => 'civicrm_case',
256 'entity' => 'Case',
257 'bao' => 'CRM_Case_BAO_Case',
258 'localizable' => 0,
259 'html' => [
260 'type' => 'Select Date',
261 'formatType' => 'activityDateTime',
262 ],
263 'add' => '1.8',
264 ],
265 'details' => [
266 'name' => 'details',
267 'type' => CRM_Utils_Type::T_TEXT,
268 'title' => ts('Details'),
269 'description' => ts('Details populated from Open Case. Only used in the CiviCase extension.'),
270 'rows' => 8,
271 'cols' => 60,
272 'where' => 'civicrm_case.details',
273 'table_name' => 'civicrm_case',
274 'entity' => 'Case',
275 'bao' => 'CRM_Case_BAO_Case',
276 'localizable' => 0,
277 'html' => [
278 'type' => 'TextArea',
279 'label' => ts("Details"),
280 ],
281 'add' => '1.8',
282 ],
283 'case_status_id' => [
284 'name' => 'status_id',
285 'type' => CRM_Utils_Type::T_INT,
286 'title' => ts('Case Status'),
287 'description' => ts('ID of case status.'),
288 'required' => TRUE,
289 'import' => TRUE,
290 'where' => 'civicrm_case.status_id',
291 'export' => FALSE,
292 'table_name' => 'civicrm_case',
293 'entity' => 'Case',
294 'bao' => 'CRM_Case_BAO_Case',
295 'localizable' => 0,
296 'html' => [
297 'type' => 'Select',
298 ],
299 'pseudoconstant' => [
300 'optionGroupName' => 'case_status',
301 'optionEditPath' => 'civicrm/admin/options/case_status',
302 ],
303 'add' => '1.8',
304 ],
305 'case_deleted' => [
306 'name' => 'is_deleted',
307 'type' => CRM_Utils_Type::T_BOOLEAN,
308 'title' => ts('Case is in the Trash'),
309 'import' => TRUE,
310 'where' => 'civicrm_case.is_deleted',
311 'export' => TRUE,
312 'default' => '0',
313 'table_name' => 'civicrm_case',
314 'entity' => 'Case',
315 'bao' => 'CRM_Case_BAO_Case',
316 'localizable' => 0,
317 'html' => [
318 'type' => 'CheckBox',
319 ],
320 'add' => '2.2',
321 ],
322 'case_created_date' => [
323 'name' => 'created_date',
324 'type' => CRM_Utils_Type::T_TIMESTAMP,
325 'title' => ts('Created Date'),
326 'description' => ts('When was the case was created.'),
327 'required' => FALSE,
328 'where' => 'civicrm_case.created_date',
329 'export' => TRUE,
330 'default' => 'NULL',
331 'table_name' => 'civicrm_case',
332 'entity' => 'Case',
333 'bao' => 'CRM_Case_BAO_Case',
334 'localizable' => 0,
335 'html' => [
336 'label' => ts("Created Date"),
337 ],
338 'add' => '4.7',
339 ],
340 'case_modified_date' => [
341 'name' => 'modified_date',
342 'type' => CRM_Utils_Type::T_TIMESTAMP,
343 'title' => ts('Modified Date'),
344 'description' => ts('When was the case (or closely related entity) was created or modified or deleted.'),
345 'required' => FALSE,
346 'where' => 'civicrm_case.modified_date',
347 'export' => TRUE,
348 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
349 'table_name' => 'civicrm_case',
350 'entity' => 'Case',
351 'bao' => 'CRM_Case_BAO_Case',
352 'localizable' => 0,
353 'html' => [
354 'label' => ts("Modified Date"),
355 ],
356 'readonly' => TRUE,
357 'add' => '4.7',
358 ],
359 ];
360 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
361 }
362 return Civi::$statics[__CLASS__]['fields'];
363 }
364
365 /**
366 * Return a mapping from field-name to the corresponding key (as used in fields()).
367 *
368 * @return array
369 * Array(string $name => string $uniqueName).
370 */
371 public static function &fieldKeys() {
372 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
373 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
374 }
375 return Civi::$statics[__CLASS__]['fieldKeys'];
376 }
377
378 /**
379 * Returns the names of this table
380 *
381 * @return string
382 */
383 public static function getTableName() {
384 return self::$_tableName;
385 }
386
387 /**
388 * Returns if this table needs to be logged
389 *
390 * @return bool
391 */
392 public function getLog() {
393 return self::$_log;
394 }
395
396 /**
397 * Returns the list of fields that can be imported
398 *
399 * @param bool $prefix
400 *
401 * @return array
402 */
403 public static function &import($prefix = FALSE) {
404 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'case', $prefix, []);
405 return $r;
406 }
407
408 /**
409 * Returns the list of fields that can be exported
410 *
411 * @param bool $prefix
412 *
413 * @return array
414 */
415 public static function &export($prefix = FALSE) {
416 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'case', $prefix, []);
417 return $r;
418 }
419
420 /**
421 * Returns the list of indices
422 *
423 * @param bool $localize
424 *
425 * @return array
426 */
427 public static function indices($localize = TRUE) {
428 $indices = [
429 'index_case_type_id' => [
430 'name' => 'index_case_type_id',
431 'field' => [
432 0 => 'case_type_id',
433 ],
434 'localizable' => FALSE,
435 'sig' => 'civicrm_case::0::case_type_id',
436 ],
437 'index_is_deleted' => [
438 'name' => 'index_is_deleted',
439 'field' => [
440 0 => 'is_deleted',
441 ],
442 'localizable' => FALSE,
443 'sig' => 'civicrm_case::0::is_deleted',
444 ],
445 ];
446 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
447 }
448
449 }