CRM-14885 - Import DAO's
[civicrm-core.git] / CRM / Financial / DAO / FinancialItem.php
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/Financial/FinancialItem.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:576910be69f2500aa8b4f37cc6b823ad)
34 */
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 class CRM_Financial_DAO_FinancialItem extends CRM_Core_DAO {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 */
43 static $_tableName = 'civicrm_financial_item';
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 *
85 * @var int unsigned
86 */
87 public $id;
88 /**
89 * Date and time the item was created
90 *
91 * @var timestamp
92 */
93 public $created_date;
94 /**
95 * Date and time of the source transaction
96 *
97 * @var datetime
98 */
99 public $transaction_date;
100 /**
101 * FK to Contact ID of contact the item is from
102 *
103 * @var int unsigned
104 */
105 public $contact_id;
106 /**
107 * Human readable description of this item, to ease display without lookup of source item.
108 *
109 * @var string
110 */
111 public $description;
112 /**
113 * Total amount of this item
114 *
115 * @var float
116 */
117 public $amount;
118 /**
119 * Currency for the amount
120 *
121 * @var string
122 */
123 public $currency;
124 /**
125 * FK to civicrm_financial_account
126 *
127 * @var int unsigned
128 */
129 public $financial_account_id;
130 /**
131 * Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)
132 *
133 * @var int unsigned
134 */
135 public $status_id;
136 /**
137 * The table providing the source of this item such as civicrm_line_item
138 *
139 * @var string
140 */
141 public $entity_table;
142 /**
143 * The specific source item that is responsible for the creation of this financial_item
144 *
145 * @var int unsigned
146 */
147 public $entity_id;
148 /**
149 * class constructor
150 *
151 * @return civicrm_financial_item
152 */
153 function __construct() {
154 $this->__table = 'civicrm_financial_item';
155 parent::__construct();
156 }
157 /**
158 * Returns foreign keys and entity references
159 *
160 * @return array
161 * [CRM_Core_Reference_Interface]
162 */
163 static function getReferenceColumns() {
164 if (!self::$_links) {
165 self::$_links = static ::createReferenceColumns(__CLASS__);
166 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'contact_id', 'civicrm_contact', 'id');
167 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'financial_account_id', 'civicrm_financial_account', 'id');
168 self::$_links[] = new CRM_Core_Reference_Dynamic(self::getTableName() , 'entity_id', NULL, 'id', 'entity_table');
169 }
170 return self::$_links;
171 }
172 /**
173 * Returns all the column names of this table
174 *
175 * @return array
176 */
177 static function &fields() {
178 if (!(self::$_fields)) {
179 self::$_fields = array(
180 'id' => array(
181 'name' => 'id',
182 'type' => CRM_Utils_Type::T_INT,
183 'title' => ts('Financial Item ID') ,
184 'required' => true,
185 ) ,
186 'created_date' => array(
187 'name' => 'created_date',
188 'type' => CRM_Utils_Type::T_TIMESTAMP,
189 'title' => ts('Financial Item Created Date') ,
190 'description' => 'Date and time the item was created',
191 'required' => true,
192 'default' => 'CURRENT_TIMESTAMP',
193 ) ,
194 'transaction_date' => array(
195 'name' => 'transaction_date',
196 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
197 'title' => ts('Financial Item Transaction Date') ,
198 'description' => 'Date and time of the source transaction',
199 'required' => true,
200 ) ,
201 'contact_id' => array(
202 'name' => 'contact_id',
203 'type' => CRM_Utils_Type::T_INT,
204 'title' => ts('Financial Item Contact ID') ,
205 'description' => 'FK to Contact ID of contact the item is from',
206 'required' => true,
207 'export' => true,
208 'where' => 'civicrm_financial_item.contact_id',
209 'headerPattern' => '',
210 'dataPattern' => '',
211 'FKClassName' => 'CRM_Contact_DAO_Contact',
212 ) ,
213 'description' => array(
214 'name' => 'description',
215 'type' => CRM_Utils_Type::T_STRING,
216 'title' => ts('Financial Item Description') ,
217 'description' => 'Human readable description of this item, to ease display without lookup of source item.',
218 'maxlength' => 255,
219 'size' => CRM_Utils_Type::HUGE,
220 ) ,
221 'amount' => array(
222 'name' => 'amount',
223 'type' => CRM_Utils_Type::T_MONEY,
224 'title' => ts('Amount') ,
225 'description' => 'Total amount of this item',
226 'required' => true,
227 'precision' => array(
228 20,
229 2
230 ) ,
231 ) ,
232 'currency' => array(
233 'name' => 'currency',
234 'type' => CRM_Utils_Type::T_STRING,
235 'title' => ts('Financial Item Currency') ,
236 'description' => 'Currency for the amount',
237 'maxlength' => 3,
238 'size' => CRM_Utils_Type::FOUR,
239 'export' => true,
240 'where' => 'civicrm_financial_item.currency',
241 'headerPattern' => '',
242 'dataPattern' => '',
243 'html' => array(
244 'type' => 'Select',
245 ) ,
246 'pseudoconstant' => array(
247 'table' => 'civicrm_currency',
248 'keyColumn' => 'name',
249 'labelColumn' => 'full_name',
250 'nameColumn' => 'name',
251 )
252 ) ,
253 'financial_account_id' => array(
254 'name' => 'financial_account_id',
255 'type' => CRM_Utils_Type::T_INT,
256 'title' => ts('Financial Account ID') ,
257 'description' => 'FK to civicrm_financial_account',
258 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
259 'html' => array(
260 'type' => 'Select',
261 ) ,
262 'pseudoconstant' => array(
263 'table' => 'civicrm_financial_account',
264 'keyColumn' => 'id',
265 'labelColumn' => 'name',
266 )
267 ) ,
268 'status_id' => array(
269 'name' => 'status_id',
270 'type' => CRM_Utils_Type::T_INT,
271 'title' => ts('Financial Item Status ID') ,
272 'description' => 'Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)',
273 'export' => true,
274 'where' => 'civicrm_financial_item.status_id',
275 'headerPattern' => '',
276 'dataPattern' => '',
277 'html' => array(
278 'type' => 'Select',
279 ) ,
280 'pseudoconstant' => array(
281 'optionGroupName' => 'financial_item_status',
282 'optionEditPath' => 'civicrm/admin/options/financial_item_status',
283 )
284 ) ,
285 'entity_table' => array(
286 'name' => 'entity_table',
287 'type' => CRM_Utils_Type::T_STRING,
288 'title' => ts('Entity Table') ,
289 'description' => 'The table providing the source of this item such as civicrm_line_item',
290 'maxlength' => 64,
291 'size' => CRM_Utils_Type::BIG,
292 ) ,
293 'entity_id' => array(
294 'name' => 'entity_id',
295 'type' => CRM_Utils_Type::T_INT,
296 'title' => ts('Entity ID') ,
297 'description' => 'The specific source item that is responsible for the creation of this financial_item',
298 ) ,
299 );
300 }
301 return self::$_fields;
302 }
303 /**
304 * Returns an array containing, for each field, the arary key used for that
305 * field in self::$_fields.
306 *
307 * @return array
308 */
309 static function &fieldKeys() {
310 if (!(self::$_fieldKeys)) {
311 self::$_fieldKeys = array(
312 'id' => 'id',
313 'created_date' => 'created_date',
314 'transaction_date' => 'transaction_date',
315 'contact_id' => 'contact_id',
316 'description' => 'description',
317 'amount' => 'amount',
318 'currency' => 'currency',
319 'financial_account_id' => 'financial_account_id',
320 'status_id' => 'status_id',
321 'entity_table' => 'entity_table',
322 'entity_id' => 'entity_id',
323 );
324 }
325 return self::$_fieldKeys;
326 }
327 /**
328 * Returns the names of this table
329 *
330 * @return string
331 */
332 static function getTableName() {
333 return self::$_tableName;
334 }
335 /**
336 * Returns if this table needs to be logged
337 *
338 * @return boolean
339 */
340 function getLog() {
341 return self::$_log;
342 }
343 /**
344 * Returns the list of fields that can be imported
345 *
346 * @param bool $prefix
347 *
348 * @return array
349 */
350 static function &import($prefix = false) {
351 if (!(self::$_import)) {
352 self::$_import = array();
353 $fields = self::fields();
354 foreach($fields as $name => $field) {
355 if (CRM_Utils_Array::value('import', $field)) {
356 if ($prefix) {
357 self::$_import['financial_item'] = & $fields[$name];
358 } else {
359 self::$_import[$name] = & $fields[$name];
360 }
361 }
362 }
363 }
364 return self::$_import;
365 }
366 /**
367 * Returns the list of fields that can be exported
368 *
369 * @param bool $prefix
370 *
371 * @return array
372 */
373 static function &export($prefix = false) {
374 if (!(self::$_export)) {
375 self::$_export = array();
376 $fields = self::fields();
377 foreach($fields as $name => $field) {
378 if (CRM_Utils_Array::value('export', $field)) {
379 if ($prefix) {
380 self::$_export['financial_item'] = & $fields[$name];
381 } else {
382 self::$_export[$name] = & $fields[$name];
383 }
384 }
385 }
386 }
387 return self::$_export;
388 }
389 }