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