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