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