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