5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Case/Case.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:8b354d7c2a0e40d82d27cbfd08776c15)
13 * Database access object for the Case entity.
15 class CRM_Case_DAO_Case
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.8';
18 const COMPONENT
= 'CiviCase';
21 * Static instance to hold the table name.
25 public static $_tableName = 'civicrm_case';
28 * Icon associated with this entity.
32 public static $_icon = 'fa-folder-open';
35 * Should CiviCRM log any modifications to this table in the civicrm_log table.
39 public static $_log = TRUE;
49 * FK to civicrm_case_type.id
56 * Short name of the case.
63 * Date on which given case starts.
70 * Date on which given case ends.
77 * Details populated from Open Case. Only used in the CiviCase extension.
96 * When was the case was created.
100 public $created_date;
103 * When was the case (or closely related entity) was created or modified or deleted.
107 public $modified_date;
112 public function __construct() {
113 $this->__table
= 'civicrm_case';
114 parent
::__construct();
118 * Returns localized title of this entity.
120 * @param bool $plural
121 * Whether to return the plural version of the title.
123 public static function getEntityTitle($plural = FALSE) {
124 return $plural ?
ts('Cases') : ts('Case');
128 * Returns foreign keys and entity references.
131 * [CRM_Core_Reference_Interface]
133 public static function getReferenceColumns() {
134 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
135 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
136 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'case_type_id', 'civicrm_case_type', 'id');
137 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
139 return Civi
::$statics[__CLASS__
]['links'];
143 * Returns all the column names of this table
147 public static function &fields() {
148 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
149 Civi
::$statics[__CLASS__
]['fields'] = [
152 'type' => CRM_Utils_Type
::T_INT
,
153 'title' => ts('Case ID'),
154 'description' => ts('Unique Case ID'),
157 'where' => 'civicrm_case.id',
159 'table_name' => 'civicrm_case',
161 'bao' => 'CRM_Case_BAO_Case',
169 'name' => 'case_type_id',
170 'type' => CRM_Utils_Type
::T_INT
,
171 'title' => ts('Case Type'),
172 'description' => ts('FK to civicrm_case_type.id'),
175 'where' => 'civicrm_case.case_type_id',
177 'table_name' => 'civicrm_case',
179 'bao' => 'CRM_Case_BAO_Case',
181 'FKClassName' => 'CRM_Case_DAO_CaseType',
185 'pseudoconstant' => [
186 'table' => 'civicrm_case_type',
188 'labelColumn' => 'title',
194 'type' => CRM_Utils_Type
::T_STRING
,
195 'title' => ts('Case Subject'),
196 'description' => ts('Short name of the case.'),
198 'size' => CRM_Utils_Type
::HUGE
,
200 'where' => 'civicrm_case.subject',
202 'table_name' => 'civicrm_case',
204 'bao' => 'CRM_Case_BAO_Case',
211 'case_start_date' => [
212 'name' => 'start_date',
213 'type' => CRM_Utils_Type
::T_DATE
,
214 'title' => ts('Case Start Date'),
215 'description' => ts('Date on which given case starts.'),
217 'where' => 'civicrm_case.start_date',
219 'table_name' => 'civicrm_case',
221 'bao' => 'CRM_Case_BAO_Case',
224 'type' => 'Select Date',
225 'formatType' => 'activityDateTime',
230 'name' => 'end_date',
231 'type' => CRM_Utils_Type
::T_DATE
,
232 'title' => ts('Case End Date'),
233 'description' => ts('Date on which given case ends.'),
235 'where' => 'civicrm_case.end_date',
237 'table_name' => 'civicrm_case',
239 'bao' => 'CRM_Case_BAO_Case',
242 'type' => 'Select Date',
243 'formatType' => 'activityDateTime',
249 'type' => CRM_Utils_Type
::T_TEXT
,
250 'title' => ts('Details'),
251 'description' => ts('Details populated from Open Case. Only used in the CiviCase extension.'),
254 'where' => 'civicrm_case.details',
255 'table_name' => 'civicrm_case',
257 'bao' => 'CRM_Case_BAO_Case',
260 'type' => 'TextArea',
264 'case_status_id' => [
265 'name' => 'status_id',
266 'type' => CRM_Utils_Type
::T_INT
,
267 'title' => ts('Case Status'),
268 'description' => ts('Id of case status.'),
271 'where' => 'civicrm_case.status_id',
273 'table_name' => 'civicrm_case',
275 'bao' => 'CRM_Case_BAO_Case',
280 'pseudoconstant' => [
281 'optionGroupName' => 'case_status',
282 'optionEditPath' => 'civicrm/admin/options/case_status',
287 'name' => 'is_deleted',
288 'type' => CRM_Utils_Type
::T_BOOLEAN
,
289 'title' => ts('Case is in the Trash'),
291 'where' => 'civicrm_case.is_deleted',
294 'table_name' => 'civicrm_case',
296 'bao' => 'CRM_Case_BAO_Case',
299 'type' => 'CheckBox',
303 'case_created_date' => [
304 'name' => 'created_date',
305 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
306 'title' => ts('Created Date'),
307 'description' => ts('When was the case was created.'),
309 'where' => 'civicrm_case.created_date',
312 'table_name' => 'civicrm_case',
314 'bao' => 'CRM_Case_BAO_Case',
318 'case_modified_date' => [
319 'name' => 'modified_date',
320 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
321 'title' => ts('Modified Date'),
322 'description' => ts('When was the case (or closely related entity) was created or modified or deleted.'),
324 'where' => 'civicrm_case.modified_date',
326 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
327 'table_name' => 'civicrm_case',
329 'bao' => 'CRM_Case_BAO_Case',
334 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
336 return Civi
::$statics[__CLASS__
]['fields'];
340 * Return a mapping from field-name to the corresponding key (as used in fields()).
343 * Array(string $name => string $uniqueName).
345 public static function &fieldKeys() {
346 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
347 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
349 return Civi
::$statics[__CLASS__
]['fieldKeys'];
353 * Returns the names of this table
357 public static function getTableName() {
358 return self
::$_tableName;
362 * Returns if this table needs to be logged
366 public function getLog() {
371 * Returns the list of fields that can be imported
373 * @param bool $prefix
377 public static function &import($prefix = FALSE) {
378 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'case', $prefix, []);
383 * Returns the list of fields that can be exported
385 * @param bool $prefix
389 public static function &export($prefix = FALSE) {
390 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'case', $prefix, []);
395 * Returns the list of indices
397 * @param bool $localize
401 public static function indices($localize = TRUE) {
403 'index_case_type_id' => [
404 'name' => 'index_case_type_id',
408 'localizable' => FALSE,
409 'sig' => 'civicrm_case::0::case_type_id',
411 'index_is_deleted' => [
412 'name' => 'index_is_deleted',
416 'localizable' => FALSE,
417 'sig' => 'civicrm_case::0::is_deleted',
420 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;