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