xml/templates/dao.tpl - Centralize export() / import() logic
[civicrm-core.git] / CRM / Case / DAO / Case.php
CommitLineData
e501603b
TO
1<?php
2/*
3+--------------------------------------------------------------------+
4| CiviCRM version 4.7 |
5+--------------------------------------------------------------------+
6| Copyright CiviCRM LLC (c) 2004-2016 |
7+--------------------------------------------------------------------+
8| This file is a part of CiviCRM. |
9| |
10| CiviCRM is free software; you can copy, modify, and distribute it |
11| under the terms of the GNU Affero General Public License |
12| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13| |
14| CiviCRM is distributed in the hope that it will be useful, but |
15| WITHOUT ANY WARRANTY; without even the implied warranty of |
16| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17| See the GNU Affero General Public License for more details. |
18| |
19| You should have received a copy of the GNU Affero General Public |
20| License and the CiviCRM Licensing Exception along |
21| with this program; if not, contact CiviCRM LLC |
22| at info[AT]civicrm[DOT]org. If you have questions about the |
23| GNU Affero General Public License or the licensing of CiviCRM, |
24| see the CiviCRM license FAQ at http://civicrm.org/licensing |
25+--------------------------------------------------------------------+
26*/
27/**
28 * @package CRM
29 * @copyright CiviCRM LLC (c) 2004-2016
30 *
31 * Generated from xml/schema/CRM/Case/Case.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
437fafcf 33 * (GenCodeChecksum:04bab9fc8d6e510321735d25c97ca261)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
37class CRM_Case_DAO_Case extends CRM_Core_DAO {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 */
43 static $_tableName = 'civicrm_case';
44 /**
45 * static instance to hold the field values
46 *
47 * @var array
48 */
49 static $_fields = null;
50 /**
51 * static instance to hold the keys used in $_fields for each field.
52 *
53 * @var array
54 */
55 static $_fieldKeys = null;
56 /**
57 * static instance to hold the FK relationships
58 *
59 * @var string
60 */
61 static $_links = null;
62 /**
63 * static instance to hold the values that can
64 * be imported
65 *
66 * @var array
67 */
68 static $_import = null;
69 /**
70 * static instance to hold the values that can
71 * be exported
72 *
73 * @var array
74 */
75 static $_export = null;
76 /**
77 * static value to see if we should log any modifications to
78 * this table in the civicrm_log table
79 *
80 * @var boolean
81 */
82 static $_log = true;
83 /**
84 * Unique Case ID
85 *
86 * @var int unsigned
87 */
88 public $id;
89 /**
90 * FK to civicrm_case_type.id
91 *
92 * @var int unsigned
93 */
94 public $case_type_id;
95 /**
96 * Short name of the case.
97 *
98 * @var string
99 */
100 public $subject;
101 /**
102 * Date on which given case starts.
103 *
104 * @var date
105 */
106 public $start_date;
107 /**
108 * Date on which given case ends.
109 *
110 * @var date
111 */
112 public $end_date;
113 /**
114 * Details about the meeting (agenda, notes, etc).
115 *
116 * @var text
117 */
118 public $details;
119 /**
120 * Id of case status.
121 *
122 * @var int unsigned
123 */
124 public $status_id;
125 /**
126 *
127 * @var boolean
128 */
129 public $is_deleted;
130 /**
131 * class constructor
132 *
133 * @return civicrm_case
134 */
135 function __construct() {
136 $this->__table = 'civicrm_case';
137 parent::__construct();
138 }
139 /**
140 * Returns foreign keys and entity references
141 *
142 * @return array
143 * [CRM_Core_Reference_Interface]
144 */
145 static function getReferenceColumns() {
146 if (!self::$_links) {
147 self::$_links = static ::createReferenceColumns(__CLASS__);
148 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'case_type_id', 'civicrm_case_type', 'id');
149 }
150 return self::$_links;
151 }
152 /**
153 * Returns all the column names of this table
154 *
155 * @return array
156 */
157 static function &fields() {
158 if (!(self::$_fields)) {
159 self::$_fields = array(
160 'case_id' => array(
161 'name' => 'id',
162 'type' => CRM_Utils_Type::T_INT,
163 'title' => ts('Case ID') ,
164 'description' => 'Unique Case ID',
165 'required' => true,
166 'import' => true,
167 'where' => 'civicrm_case.id',
168 'headerPattern' => '',
169 'dataPattern' => '',
170 'export' => true,
171 ) ,
172 'case_type_id' => array(
173 'name' => 'case_type_id',
174 'type' => CRM_Utils_Type::T_INT,
175 'title' => ts('Case Type') ,
176 'description' => 'FK to civicrm_case_type.id',
177 'import' => true,
178 'where' => 'civicrm_case.case_type_id',
179 'headerPattern' => '',
180 'dataPattern' => '',
181 'export' => false,
182 'FKClassName' => 'CRM_Case_DAO_CaseType',
183 'html' => array(
184 'type' => 'Select',
185 ) ,
186 'pseudoconstant' => array(
187 'table' => 'civicrm_case_type',
188 'keyColumn' => 'id',
189 'labelColumn' => 'title',
190 )
191 ) ,
192 'case_subject' => array(
193 'name' => 'subject',
194 'type' => CRM_Utils_Type::T_STRING,
195 'title' => ts('Case Subject') ,
196 'description' => 'Short name of the case.',
197 'maxlength' => 128,
198 'size' => CRM_Utils_Type::HUGE,
199 'import' => true,
200 'where' => 'civicrm_case.subject',
201 'headerPattern' => '',
202 'dataPattern' => '',
203 'export' => true,
204 'html' => array(
205 'type' => 'Text',
206 ) ,
207 ) ,
208 'case_start_date' => array(
209 'name' => 'start_date',
210 'type' => CRM_Utils_Type::T_DATE,
211 'title' => ts('Case Start Date') ,
212 'description' => 'Date on which given case starts.',
213 'import' => true,
214 'where' => 'civicrm_case.start_date',
215 'headerPattern' => '',
216 'dataPattern' => '',
217 'export' => true,
218 'html' => array(
219 'type' => 'Select Date',
220 ) ,
221 ) ,
222 'case_end_date' => array(
223 'name' => 'end_date',
224 'type' => CRM_Utils_Type::T_DATE,
225 'title' => ts('Case End Date') ,
226 'description' => 'Date on which given case ends.',
227 'import' => true,
228 'where' => 'civicrm_case.end_date',
229 'headerPattern' => '',
230 'dataPattern' => '',
231 'export' => true,
232 'html' => array(
233 'type' => 'Select Date',
234 ) ,
235 ) ,
236 'details' => array(
237 'name' => 'details',
238 'type' => CRM_Utils_Type::T_TEXT,
239 'title' => ts('Details') ,
240 'description' => 'Details about the meeting (agenda, notes, etc).',
241 'rows' => 8,
242 'cols' => 60,
243 'html' => array(
244 'type' => 'TextArea',
245 ) ,
246 ) ,
247 'case_status_id' => array(
248 'name' => 'status_id',
249 'type' => CRM_Utils_Type::T_INT,
250 'title' => ts('Case Status') ,
251 'description' => 'Id of case status.',
252 'required' => true,
253 'import' => true,
254 'where' => 'civicrm_case.status_id',
255 'headerPattern' => '',
256 'dataPattern' => '',
257 'export' => false,
258 'html' => array(
259 'type' => 'Select',
260 ) ,
261 'pseudoconstant' => array(
262 'optionGroupName' => 'case_status',
263 'optionEditPath' => 'civicrm/admin/options/case_status',
264 )
265 ) ,
266 'case_deleted' => array(
267 'name' => 'is_deleted',
268 'type' => CRM_Utils_Type::T_BOOLEAN,
269 'title' => ts('Case is in the Trash') ,
270 'import' => true,
271 'where' => 'civicrm_case.is_deleted',
272 'headerPattern' => '',
273 'dataPattern' => '',
274 'export' => true,
275 ) ,
276 );
277 }
278 return self::$_fields;
279 }
280 /**
281 * Returns an array containing, for each field, the arary key used for that
282 * field in self::$_fields.
283 *
284 * @return array
285 */
286 static function &fieldKeys() {
287 if (!(self::$_fieldKeys)) {
288 self::$_fieldKeys = array(
289 'id' => 'case_id',
290 'case_type_id' => 'case_type_id',
291 'subject' => 'case_subject',
292 'start_date' => 'case_start_date',
293 'end_date' => 'case_end_date',
294 'details' => 'details',
295 'status_id' => 'case_status_id',
296 'is_deleted' => 'case_deleted',
297 );
298 }
299 return self::$_fieldKeys;
300 }
301 /**
302 * Returns the names of this table
303 *
304 * @return string
305 */
306 static function getTableName() {
307 return self::$_tableName;
308 }
309 /**
310 * Returns if this table needs to be logged
311 *
312 * @return boolean
313 */
314 function getLog() {
315 return self::$_log;
316 }
317 /**
318 * Returns the list of fields that can be imported
319 *
320 * @param bool $prefix
321 *
322 * @return array
323 */
324 static function &import($prefix = false) {
325 if (!(self::$_import)) {
326 self::$_import = array();
327 $fields = self::fields();
328 foreach($fields as $name => $field) {
329 if (CRM_Utils_Array::value('import', $field)) {
330 if ($prefix) {
331 self::$_import['case'] = & $fields[$name];
332 } else {
333 self::$_import[$name] = & $fields[$name];
334 }
335 }
336 }
337 }
338 return self::$_import;
339 }
340 /**
341 * Returns the list of fields that can be exported
342 *
343 * @param bool $prefix
344 *
345 * @return array
346 */
347 static function &export($prefix = false) {
348 if (!(self::$_export)) {
349 self::$_export = array();
350 $fields = self::fields();
351 foreach($fields as $name => $field) {
352 if (CRM_Utils_Array::value('export', $field)) {
353 if ($prefix) {
354 self::$_export['case'] = & $fields[$name];
355 } else {
356 self::$_export[$name] = & $fields[$name];
357 }
358 }
359 }
360 }
361 return self::$_export;
362 }
363}