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