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