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