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