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