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