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