Merge pull request #22603 from colemanw/searchKitAdminDocs
[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
2562d09a 9 * (GenCodeChecksum:1ae35a7a60938212678c1585defc3506)
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 *
e6ca0a57 51 * @var int
e501603b
TO
52 */
53 public $id;
c3fc2621 54
e501603b
TO
55 /**
56 * FK to civicrm_case_type.id
57 *
e6ca0a57 58 * @var int
e501603b
TO
59 */
60 public $case_type_id;
c3fc2621 61
e501603b
TO
62 /**
63 * Short name of the case.
64 *
65 * @var string
66 */
67 public $subject;
c3fc2621 68
e501603b
TO
69 /**
70 * Date on which given case starts.
71 *
72 * @var date
73 */
74 public $start_date;
c3fc2621 75
e501603b
TO
76 /**
77 * Date on which given case ends.
78 *
79 * @var date
80 */
81 public $end_date;
c3fc2621 82
e501603b 83 /**
17f78bae 84 * Details populated from Open Case. Only used in the CiviCase extension.
e501603b
TO
85 *
86 * @var text
87 */
88 public $details;
c3fc2621 89
e501603b 90 /**
2cbbebe8 91 * ID of case status.
e501603b 92 *
e6ca0a57 93 * @var int
e501603b
TO
94 */
95 public $status_id;
c3fc2621 96
e501603b 97 /**
e6ca0a57 98 * @var bool
e501603b
TO
99 */
100 public $is_deleted;
c3fc2621 101
3ed77291
TO
102 /**
103 * When was the case was created.
104 *
105 * @var timestamp
106 */
107 public $created_date;
c3fc2621 108
3ed77291
TO
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;
c3fc2621 115
e501603b 116 /**
f41f0342 117 * Class constructor.
e501603b 118 */
c3fc2621 119 public function __construct() {
e501603b
TO
120 $this->__table = 'civicrm_case';
121 parent::__construct();
122 }
c3fc2621 123
449c4e6b
CW
124 /**
125 * Returns localized title of this entity.
7b66c3b5
AH
126 *
127 * @param bool $plural
128 * Whether to return the plural version of the title.
449c4e6b 129 */
7b66c3b5
AH
130 public static function getEntityTitle($plural = FALSE) {
131 return $plural ? ts('Cases') : ts('Case');
449c4e6b
CW
132 }
133
2562d09a
CW
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
e501603b 143 /**
f41f0342 144 * Returns foreign keys and entity references.
e501603b
TO
145 *
146 * @return array
147 * [CRM_Core_Reference_Interface]
148 */
c3fc2621 149 public static function getReferenceColumns() {
346aaaba 150 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 151 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621 152 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'case_type_id', 'civicrm_case_type', 'id');
346aaaba 153 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 154 }
346aaaba 155 return Civi::$statics[__CLASS__]['links'];
e501603b 156 }
c3fc2621 157
e501603b
TO
158 /**
159 * Returns all the column names of this table
160 *
161 * @return array
162 */
c3fc2621 163 public static function &fields() {
346aaaba 164 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
165 Civi::$statics[__CLASS__]['fields'] = [
166 'case_id' => [
e501603b
TO
167 'name' => 'id',
168 'type' => CRM_Utils_Type::T_INT,
c3fc2621 169 'title' => ts('Case ID'),
215b423e 170 'description' => ts('Unique Case ID'),
c3fc2621
CW
171 'required' => TRUE,
172 'import' => TRUE,
e501603b 173 'where' => 'civicrm_case.id',
c3fc2621 174 'export' => TRUE,
522a26c9 175 'table_name' => 'civicrm_case',
176 'entity' => 'Case',
177 'bao' => 'CRM_Case_BAO_Case',
6a7e5e5d 178 'localizable' => 0,
b62aa188 179 'html' => [
2cbbebe8 180 'type' => 'Number',
b62aa188 181 ],
1fe423d6 182 'readonly' => TRUE,
a9d0587b 183 'add' => '1.8',
c3fc2621
CW
184 ],
185 'case_type_id' => [
e501603b
TO
186 'name' => 'case_type_id',
187 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 188 'title' => ts('Case Type ID'),
215b423e 189 'description' => ts('FK to civicrm_case_type.id'),
c3fc2621
CW
190 'required' => TRUE,
191 'import' => TRUE,
e501603b 192 'where' => 'civicrm_case.case_type_id',
c3fc2621 193 'export' => FALSE,
522a26c9 194 'table_name' => 'civicrm_case',
195 'entity' => 'Case',
196 'bao' => 'CRM_Case_BAO_Case',
6a7e5e5d 197 'localizable' => 0,
e501603b 198 'FKClassName' => 'CRM_Case_DAO_CaseType',
c3fc2621 199 'html' => [
e501603b 200 'type' => 'Select',
2cbbebe8 201 'label' => ts("Case Type"),
c3fc2621
CW
202 ],
203 'pseudoconstant' => [
e501603b
TO
204 'table' => 'civicrm_case_type',
205 'keyColumn' => 'id',
206 'labelColumn' => 'title',
e6ca0a57 207 ],
a9d0587b 208 'add' => '2.0',
c3fc2621
CW
209 ],
210 'case_subject' => [
e501603b
TO
211 'name' => 'subject',
212 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 213 'title' => ts('Case Subject'),
215b423e 214 'description' => ts('Short name of the case.'),
e501603b
TO
215 'maxlength' => 128,
216 'size' => CRM_Utils_Type::HUGE,
c3fc2621 217 'import' => TRUE,
e501603b 218 'where' => 'civicrm_case.subject',
c3fc2621 219 'export' => TRUE,
522a26c9 220 'table_name' => 'civicrm_case',
221 'entity' => 'Case',
222 'bao' => 'CRM_Case_BAO_Case',
6a7e5e5d 223 'localizable' => 0,
c3fc2621 224 'html' => [
e501603b 225 'type' => 'Text',
c3fc2621 226 ],
a9d0587b 227 'add' => '1.8',
c3fc2621
CW
228 ],
229 'case_start_date' => [
e501603b
TO
230 'name' => 'start_date',
231 'type' => CRM_Utils_Type::T_DATE,
c3fc2621 232 'title' => ts('Case Start Date'),
215b423e 233 'description' => ts('Date on which given case starts.'),
c3fc2621 234 'import' => TRUE,
e501603b 235 'where' => 'civicrm_case.start_date',
c3fc2621 236 'export' => TRUE,
522a26c9 237 'table_name' => 'civicrm_case',
238 'entity' => 'Case',
239 'bao' => 'CRM_Case_BAO_Case',
6a7e5e5d 240 'localizable' => 0,
c3fc2621 241 'html' => [
e501603b 242 'type' => 'Select Date',
e0d4ddde 243 'formatType' => 'activityDateTime',
c3fc2621 244 ],
a9d0587b 245 'add' => '1.8',
c3fc2621
CW
246 ],
247 'case_end_date' => [
e501603b
TO
248 'name' => 'end_date',
249 'type' => CRM_Utils_Type::T_DATE,
c3fc2621 250 'title' => ts('Case End Date'),
215b423e 251 'description' => ts('Date on which given case ends.'),
c3fc2621 252 'import' => TRUE,
e501603b 253 'where' => 'civicrm_case.end_date',
c3fc2621 254 'export' => TRUE,
522a26c9 255 'table_name' => 'civicrm_case',
256 'entity' => 'Case',
257 'bao' => 'CRM_Case_BAO_Case',
6a7e5e5d 258 'localizable' => 0,
c3fc2621 259 'html' => [
e501603b 260 'type' => 'Select Date',
e0d4ddde 261 'formatType' => 'activityDateTime',
c3fc2621 262 ],
a9d0587b 263 'add' => '1.8',
c3fc2621
CW
264 ],
265 'details' => [
e501603b
TO
266 'name' => 'details',
267 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 268 'title' => ts('Details'),
17f78bae 269 'description' => ts('Details populated from Open Case. Only used in the CiviCase extension.'),
e501603b
TO
270 'rows' => 8,
271 'cols' => 60,
a36434b9 272 'where' => 'civicrm_case.details',
522a26c9 273 'table_name' => 'civicrm_case',
274 'entity' => 'Case',
275 'bao' => 'CRM_Case_BAO_Case',
6a7e5e5d 276 'localizable' => 0,
c3fc2621 277 'html' => [
e501603b 278 'type' => 'TextArea',
c23563e3 279 'label' => ts("Details"),
c3fc2621 280 ],
a9d0587b 281 'add' => '1.8',
c3fc2621
CW
282 ],
283 'case_status_id' => [
e501603b
TO
284 'name' => 'status_id',
285 'type' => CRM_Utils_Type::T_INT,
c3fc2621 286 'title' => ts('Case Status'),
2cbbebe8 287 'description' => ts('ID of case status.'),
c3fc2621
CW
288 'required' => TRUE,
289 'import' => TRUE,
e501603b 290 'where' => 'civicrm_case.status_id',
c3fc2621 291 'export' => FALSE,
522a26c9 292 'table_name' => 'civicrm_case',
293 'entity' => 'Case',
294 'bao' => 'CRM_Case_BAO_Case',
6a7e5e5d 295 'localizable' => 0,
c3fc2621 296 'html' => [
e501603b 297 'type' => 'Select',
c3fc2621
CW
298 ],
299 'pseudoconstant' => [
e501603b
TO
300 'optionGroupName' => 'case_status',
301 'optionEditPath' => 'civicrm/admin/options/case_status',
e6ca0a57 302 ],
a9d0587b 303 'add' => '1.8',
c3fc2621
CW
304 ],
305 'case_deleted' => [
e501603b
TO
306 'name' => 'is_deleted',
307 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621
CW
308 'title' => ts('Case is in the Trash'),
309 'import' => TRUE,
e501603b 310 'where' => 'civicrm_case.is_deleted',
c3fc2621 311 'export' => TRUE,
45a83e42 312 'default' => '0',
522a26c9 313 'table_name' => 'civicrm_case',
314 'entity' => 'Case',
315 'bao' => 'CRM_Case_BAO_Case',
6a7e5e5d 316 'localizable' => 0,
b62aa188
MD
317 'html' => [
318 'type' => 'CheckBox',
319 ],
a9d0587b 320 'add' => '2.2',
c3fc2621
CW
321 ],
322 'case_created_date' => [
3ed77291
TO
323 'name' => 'created_date',
324 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 325 'title' => ts('Created Date'),
215b423e 326 'description' => ts('When was the case was created.'),
c3fc2621 327 'required' => FALSE,
3ed77291 328 'where' => 'civicrm_case.created_date',
a36434b9 329 'export' => TRUE,
5fb0de1f 330 'default' => NULL,
3ed77291
TO
331 'table_name' => 'civicrm_case',
332 'entity' => 'Case',
333 'bao' => 'CRM_Case_BAO_Case',
334 'localizable' => 0,
c23563e3
SL
335 'html' => [
336 'label' => ts("Created Date"),
337 ],
a9d0587b 338 'add' => '4.7',
c3fc2621
CW
339 ],
340 'case_modified_date' => [
3ed77291
TO
341 'name' => 'modified_date',
342 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 343 'title' => ts('Modified Date'),
215b423e 344 'description' => ts('When was the case (or closely related entity) was created or modified or deleted.'),
c3fc2621 345 'required' => FALSE,
3ed77291 346 'where' => 'civicrm_case.modified_date',
a36434b9 347 'export' => TRUE,
3ed77291
TO
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,
c23563e3
SL
353 'html' => [
354 'label' => ts("Modified Date"),
355 ],
a0e733f3 356 'readonly' => TRUE,
a9d0587b 357 'add' => '4.7',
c3fc2621
CW
358 ],
359 ];
346aaaba 360 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 361 }
346aaaba 362 return Civi::$statics[__CLASS__]['fields'];
e501603b 363 }
c3fc2621 364
e501603b 365 /**
bd8e0b14 366 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
367 *
368 * @return array
bd8e0b14 369 * Array(string $name => string $uniqueName).
e501603b 370 */
c3fc2621 371 public static function &fieldKeys() {
bd8e0b14
TO
372 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
373 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 374 }
bd8e0b14 375 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 376 }
c3fc2621 377
e501603b
TO
378 /**
379 * Returns the names of this table
380 *
381 * @return string
382 */
c3fc2621 383 public static function getTableName() {
e501603b
TO
384 return self::$_tableName;
385 }
c3fc2621 386
e501603b
TO
387 /**
388 * Returns if this table needs to be logged
389 *
c3fc2621 390 * @return bool
e501603b 391 */
c3fc2621 392 public function getLog() {
e501603b
TO
393 return self::$_log;
394 }
c3fc2621 395
e501603b
TO
396 /**
397 * Returns the list of fields that can be imported
398 *
399 * @param bool $prefix
400 *
401 * @return array
402 */
c3fc2621
CW
403 public static function &import($prefix = FALSE) {
404 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'case', $prefix, []);
60808919 405 return $r;
e501603b 406 }
c3fc2621 407
e501603b
TO
408 /**
409 * Returns the list of fields that can be exported
410 *
411 * @param bool $prefix
412 *
413 * @return array
414 */
c3fc2621
CW
415 public static function &export($prefix = FALSE) {
416 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'case', $prefix, []);
60808919 417 return $r;
e501603b 418 }
c3fc2621 419
e7a6b91a
AS
420 /**
421 * Returns the list of indices
c3fc2621
CW
422 *
423 * @param bool $localize
424 *
425 * @return array
e7a6b91a
AS
426 */
427 public static function indices($localize = TRUE) {
c3fc2621
CW
428 $indices = [
429 'index_case_type_id' => [
e7a6b91a 430 'name' => 'index_case_type_id',
c3fc2621 431 'field' => [
e7a6b91a 432 0 => 'case_type_id',
c3fc2621
CW
433 ],
434 'localizable' => FALSE,
e7a6b91a 435 'sig' => 'civicrm_case::0::case_type_id',
c3fc2621
CW
436 ],
437 'index_is_deleted' => [
e7a6b91a 438 'name' => 'index_is_deleted',
c3fc2621 439 'field' => [
e7a6b91a 440 0 => 'is_deleted',
c3fc2621
CW
441 ],
442 'localizable' => FALSE,
e7a6b91a 443 'sig' => 'civicrm_case::0::is_deleted',
c3fc2621
CW
444 ],
445 ];
e7a6b91a
AS
446 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
447 }
c3fc2621 448
e501603b 449}