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:1ae35a7a60938212678c1585defc3506)
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 user-friendly description of this entity.
139 public static function getEntityDescription() {
140 return ts('Collections of activities and relationships for a given purpose.');
144 * Returns foreign keys and entity references.
147 * [CRM_Core_Reference_Interface]
149 public static function getReferenceColumns() {
150 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
151 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
152 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'case_type_id', 'civicrm_case_type', 'id');
153 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
155 return Civi
::$statics[__CLASS__
]['links'];
159 * Returns all the column names of this table
163 public static function &fields() {
164 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
165 Civi
::$statics[__CLASS__
]['fields'] = [
168 'type' => CRM_Utils_Type
::T_INT
,
169 'title' => ts('Case ID'),
170 'description' => ts('Unique Case ID'),
173 'where' => 'civicrm_case.id',
175 'table_name' => 'civicrm_case',
177 'bao' => 'CRM_Case_BAO_Case',
186 'name' => 'case_type_id',
187 'type' => CRM_Utils_Type
::T_INT
,
188 'title' => ts('Case Type ID'),
189 'description' => ts('FK to civicrm_case_type.id'),
192 'where' => 'civicrm_case.case_type_id',
194 'table_name' => 'civicrm_case',
196 'bao' => 'CRM_Case_BAO_Case',
198 'FKClassName' => 'CRM_Case_DAO_CaseType',
201 'label' => ts("Case Type"),
203 'pseudoconstant' => [
204 'table' => 'civicrm_case_type',
206 'labelColumn' => 'title',
212 'type' => CRM_Utils_Type
::T_STRING
,
213 'title' => ts('Case Subject'),
214 'description' => ts('Short name of the case.'),
216 'size' => CRM_Utils_Type
::HUGE
,
218 'where' => 'civicrm_case.subject',
220 'table_name' => 'civicrm_case',
222 'bao' => 'CRM_Case_BAO_Case',
229 'case_start_date' => [
230 'name' => 'start_date',
231 'type' => CRM_Utils_Type
::T_DATE
,
232 'title' => ts('Case Start Date'),
233 'description' => ts('Date on which given case starts.'),
235 'where' => 'civicrm_case.start_date',
237 'table_name' => 'civicrm_case',
239 'bao' => 'CRM_Case_BAO_Case',
242 'type' => 'Select Date',
243 'formatType' => 'activityDateTime',
248 'name' => 'end_date',
249 'type' => CRM_Utils_Type
::T_DATE
,
250 'title' => ts('Case End Date'),
251 'description' => ts('Date on which given case ends.'),
253 'where' => 'civicrm_case.end_date',
255 'table_name' => 'civicrm_case',
257 'bao' => 'CRM_Case_BAO_Case',
260 'type' => 'Select Date',
261 'formatType' => 'activityDateTime',
267 'type' => CRM_Utils_Type
::T_TEXT
,
268 'title' => ts('Details'),
269 'description' => ts('Details populated from Open Case. Only used in the CiviCase extension.'),
272 'where' => 'civicrm_case.details',
273 'table_name' => 'civicrm_case',
275 'bao' => 'CRM_Case_BAO_Case',
278 'type' => 'TextArea',
279 'label' => ts("Details"),
283 'case_status_id' => [
284 'name' => 'status_id',
285 'type' => CRM_Utils_Type
::T_INT
,
286 'title' => ts('Case Status'),
287 'description' => ts('ID of case status.'),
290 'where' => 'civicrm_case.status_id',
292 'table_name' => 'civicrm_case',
294 'bao' => 'CRM_Case_BAO_Case',
299 'pseudoconstant' => [
300 'optionGroupName' => 'case_status',
301 'optionEditPath' => 'civicrm/admin/options/case_status',
306 'name' => 'is_deleted',
307 'type' => CRM_Utils_Type
::T_BOOLEAN
,
308 'title' => ts('Case is in the Trash'),
310 'where' => 'civicrm_case.is_deleted',
313 'table_name' => 'civicrm_case',
315 'bao' => 'CRM_Case_BAO_Case',
318 'type' => 'CheckBox',
322 'case_created_date' => [
323 'name' => 'created_date',
324 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
325 'title' => ts('Created Date'),
326 'description' => ts('When was the case was created.'),
328 'where' => 'civicrm_case.created_date',
331 'table_name' => 'civicrm_case',
333 'bao' => 'CRM_Case_BAO_Case',
336 'label' => ts("Created Date"),
340 'case_modified_date' => [
341 'name' => 'modified_date',
342 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
343 'title' => ts('Modified Date'),
344 'description' => ts('When was the case (or closely related entity) was created or modified or deleted.'),
346 'where' => 'civicrm_case.modified_date',
348 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
349 'table_name' => 'civicrm_case',
351 'bao' => 'CRM_Case_BAO_Case',
354 'label' => ts("Modified Date"),
360 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
362 return Civi
::$statics[__CLASS__
]['fields'];
366 * Return a mapping from field-name to the corresponding key (as used in fields()).
369 * Array(string $name => string $uniqueName).
371 public static function &fieldKeys() {
372 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
373 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
375 return Civi
::$statics[__CLASS__
]['fieldKeys'];
379 * Returns the names of this table
383 public static function getTableName() {
384 return self
::$_tableName;
388 * Returns if this table needs to be logged
392 public function getLog() {
397 * Returns the list of fields that can be imported
399 * @param bool $prefix
403 public static function &import($prefix = FALSE) {
404 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'case', $prefix, []);
409 * Returns the list of fields that can be exported
411 * @param bool $prefix
415 public static function &export($prefix = FALSE) {
416 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'case', $prefix, []);
421 * Returns the list of indices
423 * @param bool $localize
427 public static function indices($localize = TRUE) {
429 'index_case_type_id' => [
430 'name' => 'index_case_type_id',
434 'localizable' => FALSE,
435 'sig' => 'civicrm_case::0::case_type_id',
437 'index_is_deleted' => [
438 'name' => 'index_is_deleted',
442 'localizable' => FALSE,
443 'sig' => 'civicrm_case::0::is_deleted',
446 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;