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:a306dc83df6e2e019a35a560841a702e)
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 * Field to show when displaying a record.
39 public static $_labelField = 'subject';
42 * Should CiviCRM log any modifications to this table in the civicrm_log table.
46 public static $_log = TRUE;
56 * FK to civicrm_case_type.id
63 * Short name of the case.
70 * Date on which given case starts.
77 * Date on which given case ends.
84 * Details populated from Open Case. Only used in the CiviCase extension.
103 * When was the case was created.
107 public $created_date;
110 * When was the case (or closely related entity) was created or modified or deleted.
114 public $modified_date;
119 public function __construct() {
120 $this->__table
= 'civicrm_case';
121 parent
::__construct();
125 * Returns localized title of this entity.
127 * @param bool $plural
128 * Whether to return the plural version of the title.
130 public static function getEntityTitle($plural = FALSE) {
131 return $plural ?
ts('Cases') : ts('Case');
135 * Returns foreign keys and entity references.
138 * [CRM_Core_Reference_Interface]
140 public static function getReferenceColumns() {
141 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
142 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
143 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'case_type_id', 'civicrm_case_type', 'id');
144 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
146 return Civi
::$statics[__CLASS__
]['links'];
150 * Returns all the column names of this table
154 public static function &fields() {
155 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
156 Civi
::$statics[__CLASS__
]['fields'] = [
159 'type' => CRM_Utils_Type
::T_INT
,
160 'title' => ts('Case ID'),
161 'description' => ts('Unique Case ID'),
164 'where' => 'civicrm_case.id',
166 'table_name' => 'civicrm_case',
168 'bao' => 'CRM_Case_BAO_Case',
177 'name' => 'case_type_id',
178 'type' => CRM_Utils_Type
::T_INT
,
179 'title' => ts('Case Type ID'),
180 'description' => ts('FK to civicrm_case_type.id'),
183 'where' => 'civicrm_case.case_type_id',
185 'table_name' => 'civicrm_case',
187 'bao' => 'CRM_Case_BAO_Case',
189 'FKClassName' => 'CRM_Case_DAO_CaseType',
192 'label' => ts("Case Type"),
194 'pseudoconstant' => [
195 'table' => 'civicrm_case_type',
197 'labelColumn' => 'title',
203 'type' => CRM_Utils_Type
::T_STRING
,
204 'title' => ts('Case Subject'),
205 'description' => ts('Short name of the case.'),
207 'size' => CRM_Utils_Type
::HUGE
,
209 'where' => 'civicrm_case.subject',
211 'table_name' => 'civicrm_case',
213 'bao' => 'CRM_Case_BAO_Case',
220 'case_start_date' => [
221 'name' => 'start_date',
222 'type' => CRM_Utils_Type
::T_DATE
,
223 'title' => ts('Case Start Date'),
224 'description' => ts('Date on which given case starts.'),
226 'where' => 'civicrm_case.start_date',
228 'table_name' => 'civicrm_case',
230 'bao' => 'CRM_Case_BAO_Case',
233 'type' => 'Select Date',
234 'formatType' => 'activityDateTime',
239 'name' => 'end_date',
240 'type' => CRM_Utils_Type
::T_DATE
,
241 'title' => ts('Case End Date'),
242 'description' => ts('Date on which given case ends.'),
244 'where' => 'civicrm_case.end_date',
246 'table_name' => 'civicrm_case',
248 'bao' => 'CRM_Case_BAO_Case',
251 'type' => 'Select Date',
252 'formatType' => 'activityDateTime',
258 'type' => CRM_Utils_Type
::T_TEXT
,
259 'title' => ts('Details'),
260 'description' => ts('Details populated from Open Case. Only used in the CiviCase extension.'),
263 'where' => 'civicrm_case.details',
264 'table_name' => 'civicrm_case',
266 'bao' => 'CRM_Case_BAO_Case',
269 'type' => 'TextArea',
270 'label' => ts("Details"),
274 'case_status_id' => [
275 'name' => 'status_id',
276 'type' => CRM_Utils_Type
::T_INT
,
277 'title' => ts('Case Status'),
278 'description' => ts('ID of case status.'),
281 'where' => 'civicrm_case.status_id',
283 'table_name' => 'civicrm_case',
285 'bao' => 'CRM_Case_BAO_Case',
290 'pseudoconstant' => [
291 'optionGroupName' => 'case_status',
292 'optionEditPath' => 'civicrm/admin/options/case_status',
297 'name' => 'is_deleted',
298 'type' => CRM_Utils_Type
::T_BOOLEAN
,
299 'title' => ts('Case is in the Trash'),
301 'where' => 'civicrm_case.is_deleted',
304 'table_name' => 'civicrm_case',
306 'bao' => 'CRM_Case_BAO_Case',
309 'type' => 'CheckBox',
313 'case_created_date' => [
314 'name' => 'created_date',
315 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
316 'title' => ts('Created Date'),
317 'description' => ts('When was the case was created.'),
319 'where' => 'civicrm_case.created_date',
322 'table_name' => 'civicrm_case',
324 'bao' => 'CRM_Case_BAO_Case',
327 'label' => ts("Created Date"),
331 'case_modified_date' => [
332 'name' => 'modified_date',
333 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
334 'title' => ts('Modified Date'),
335 'description' => ts('When was the case (or closely related entity) was created or modified or deleted.'),
337 'where' => 'civicrm_case.modified_date',
339 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
340 'table_name' => 'civicrm_case',
342 'bao' => 'CRM_Case_BAO_Case',
345 'label' => ts("Modified Date"),
351 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
353 return Civi
::$statics[__CLASS__
]['fields'];
357 * Return a mapping from field-name to the corresponding key (as used in fields()).
360 * Array(string $name => string $uniqueName).
362 public static function &fieldKeys() {
363 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
364 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
366 return Civi
::$statics[__CLASS__
]['fieldKeys'];
370 * Returns the names of this table
374 public static function getTableName() {
375 return self
::$_tableName;
379 * Returns if this table needs to be logged
383 public function getLog() {
388 * Returns the list of fields that can be imported
390 * @param bool $prefix
394 public static function &import($prefix = FALSE) {
395 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'case', $prefix, []);
400 * Returns the list of fields that can be exported
402 * @param bool $prefix
406 public static function &export($prefix = FALSE) {
407 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'case', $prefix, []);
412 * Returns the list of indices
414 * @param bool $localize
418 public static function indices($localize = TRUE) {
420 'index_case_type_id' => [
421 'name' => 'index_case_type_id',
425 'localizable' => FALSE,
426 'sig' => 'civicrm_case::0::case_type_id',
428 'index_is_deleted' => [
429 'name' => 'index_is_deleted',
433 'localizable' => FALSE,
434 'sig' => 'civicrm_case::0::is_deleted',
437 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;