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