Commit | Line | Data |
---|---|---|
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 | |
28979d65 | 9 | * (GenCodeChecksum:9255efc8fc0b791899a006e23eb55341) |
e501603b | 10 | */ |
c3fc2621 | 11 | |
f41f0342 | 12 | /** |
c3fc2621 | 13 | * Database access object for the Case entity. |
f41f0342 | 14 | */ |
e501603b | 15 | class 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 | /** |
28979d65 CW |
112 | * @var bool|string|null |
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 CW |
328 | 'title' => ts('Case is in the Trash'), |
329 | 'import' => TRUE, | |
e501603b | 330 | 'where' => 'civicrm_case.is_deleted', |
c3fc2621 | 331 | 'export' => TRUE, |
45a83e42 | 332 | 'default' => '0', |
522a26c9 | 333 | 'table_name' => 'civicrm_case', |
334 | 'entity' => 'Case', | |
335 | 'bao' => 'CRM_Case_BAO_Case', | |
6a7e5e5d | 336 | 'localizable' => 0, |
b62aa188 MD |
337 | 'html' => [ |
338 | 'type' => 'CheckBox', | |
339 | ], | |
a9d0587b | 340 | 'add' => '2.2', |
c3fc2621 CW |
341 | ], |
342 | 'case_created_date' => [ | |
3ed77291 TO |
343 | 'name' => 'created_date', |
344 | 'type' => CRM_Utils_Type::T_TIMESTAMP, | |
c3fc2621 | 345 | 'title' => ts('Created Date'), |
215b423e | 346 | 'description' => ts('When was the case was created.'), |
c3fc2621 | 347 | 'required' => FALSE, |
3ed77291 | 348 | 'where' => 'civicrm_case.created_date', |
a36434b9 | 349 | 'export' => TRUE, |
5fb0de1f | 350 | 'default' => NULL, |
3ed77291 TO |
351 | 'table_name' => 'civicrm_case', |
352 | 'entity' => 'Case', | |
353 | 'bao' => 'CRM_Case_BAO_Case', | |
354 | 'localizable' => 0, | |
c23563e3 SL |
355 | 'html' => [ |
356 | 'label' => ts("Created Date"), | |
357 | ], | |
da5b05fa | 358 | 'readonly' => TRUE, |
a9d0587b | 359 | 'add' => '4.7', |
c3fc2621 CW |
360 | ], |
361 | 'case_modified_date' => [ | |
3ed77291 TO |
362 | 'name' => 'modified_date', |
363 | 'type' => CRM_Utils_Type::T_TIMESTAMP, | |
c3fc2621 | 364 | 'title' => ts('Modified Date'), |
215b423e | 365 | 'description' => ts('When was the case (or closely related entity) was created or modified or deleted.'), |
c3fc2621 | 366 | 'required' => FALSE, |
3ed77291 | 367 | 'where' => 'civicrm_case.modified_date', |
a36434b9 | 368 | 'export' => TRUE, |
3ed77291 TO |
369 | 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', |
370 | 'table_name' => 'civicrm_case', | |
371 | 'entity' => 'Case', | |
372 | 'bao' => 'CRM_Case_BAO_Case', | |
373 | 'localizable' => 0, | |
c23563e3 SL |
374 | 'html' => [ |
375 | 'label' => ts("Modified Date"), | |
376 | ], | |
a0e733f3 | 377 | 'readonly' => TRUE, |
a9d0587b | 378 | 'add' => '4.7', |
c3fc2621 CW |
379 | ], |
380 | ]; | |
346aaaba | 381 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); |
e501603b | 382 | } |
346aaaba | 383 | return Civi::$statics[__CLASS__]['fields']; |
e501603b | 384 | } |
c3fc2621 | 385 | |
e501603b | 386 | /** |
bd8e0b14 | 387 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
e501603b TO |
388 | * |
389 | * @return array | |
bd8e0b14 | 390 | * Array(string $name => string $uniqueName). |
e501603b | 391 | */ |
c3fc2621 | 392 | public static function &fieldKeys() { |
bd8e0b14 TO |
393 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { |
394 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); | |
e501603b | 395 | } |
bd8e0b14 | 396 | return Civi::$statics[__CLASS__]['fieldKeys']; |
e501603b | 397 | } |
c3fc2621 | 398 | |
e501603b TO |
399 | /** |
400 | * Returns the names of this table | |
401 | * | |
402 | * @return string | |
403 | */ | |
c3fc2621 | 404 | public static function getTableName() { |
e501603b TO |
405 | return self::$_tableName; |
406 | } | |
c3fc2621 | 407 | |
e501603b TO |
408 | /** |
409 | * Returns if this table needs to be logged | |
410 | * | |
c3fc2621 | 411 | * @return bool |
e501603b | 412 | */ |
c3fc2621 | 413 | public function getLog() { |
e501603b TO |
414 | return self::$_log; |
415 | } | |
c3fc2621 | 416 | |
e501603b TO |
417 | /** |
418 | * Returns the list of fields that can be imported | |
419 | * | |
420 | * @param bool $prefix | |
421 | * | |
422 | * @return array | |
423 | */ | |
c3fc2621 CW |
424 | public static function &import($prefix = FALSE) { |
425 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'case', $prefix, []); | |
60808919 | 426 | return $r; |
e501603b | 427 | } |
c3fc2621 | 428 | |
e501603b TO |
429 | /** |
430 | * Returns the list of fields that can be exported | |
431 | * | |
432 | * @param bool $prefix | |
433 | * | |
434 | * @return array | |
435 | */ | |
c3fc2621 CW |
436 | public static function &export($prefix = FALSE) { |
437 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'case', $prefix, []); | |
60808919 | 438 | return $r; |
e501603b | 439 | } |
c3fc2621 | 440 | |
e7a6b91a AS |
441 | /** |
442 | * Returns the list of indices | |
c3fc2621 CW |
443 | * |
444 | * @param bool $localize | |
445 | * | |
446 | * @return array | |
e7a6b91a AS |
447 | */ |
448 | public static function indices($localize = TRUE) { | |
c3fc2621 CW |
449 | $indices = [ |
450 | 'index_case_type_id' => [ | |
e7a6b91a | 451 | 'name' => 'index_case_type_id', |
c3fc2621 | 452 | 'field' => [ |
e7a6b91a | 453 | 0 => 'case_type_id', |
c3fc2621 CW |
454 | ], |
455 | 'localizable' => FALSE, | |
e7a6b91a | 456 | 'sig' => 'civicrm_case::0::case_type_id', |
c3fc2621 CW |
457 | ], |
458 | 'index_is_deleted' => [ | |
e7a6b91a | 459 | 'name' => 'index_is_deleted', |
c3fc2621 | 460 | 'field' => [ |
e7a6b91a | 461 | 0 => 'is_deleted', |
c3fc2621 CW |
462 | ], |
463 | 'localizable' => FALSE, | |
e7a6b91a | 464 | 'sig' => 'civicrm_case::0::is_deleted', |
c3fc2621 CW |
465 | ], |
466 | ]; | |
e7a6b91a AS |
467 | return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; |
468 | } | |
c3fc2621 | 469 | |
e501603b | 470 | } |