Add comment blocks
[civicrm-core.git] / CRM / Financial / DAO / FinancialItem.php
CommitLineData
e501603b
TO
1<?php
2/*
3+--------------------------------------------------------------------+
4| CiviCRM version 4.7 |
5+--------------------------------------------------------------------+
0f03f337 6| Copyright CiviCRM LLC (c) 2004-2017 |
e501603b
TO
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
0f03f337 29 * @copyright CiviCRM LLC (c) 2004-2017
e501603b
TO
30 *
31 * Generated from xml/schema/CRM/Financial/FinancialItem.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
437fafcf 33 * (GenCodeChecksum:4abc5641f9aab2a8d925cf5898a3a858)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
37class 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';
e501603b
TO
44 /**
45 * static value to see if we should log any modifications to
46 * this table in the civicrm_log table
47 *
48 * @var boolean
49 */
50 static $_log = true;
51 /**
52 *
53 * @var int unsigned
54 */
55 public $id;
56 /**
57 * Date and time the item was created
58 *
59 * @var timestamp
60 */
61 public $created_date;
62 /**
63 * Date and time of the source transaction
64 *
65 * @var datetime
66 */
67 public $transaction_date;
68 /**
69 * FK to Contact ID of contact the item is from
70 *
71 * @var int unsigned
72 */
73 public $contact_id;
74 /**
75 * Human readable description of this item, to ease display without lookup of source item.
76 *
77 * @var string
78 */
79 public $description;
80 /**
81 * Total amount of this item
82 *
83 * @var float
84 */
85 public $amount;
86 /**
87 * Currency for the amount
88 *
89 * @var string
90 */
91 public $currency;
92 /**
93 * FK to civicrm_financial_account
94 *
95 * @var int unsigned
96 */
97 public $financial_account_id;
98 /**
99 * Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)
100 *
101 * @var int unsigned
102 */
103 public $status_id;
104 /**
105 * The table providing the source of this item such as civicrm_line_item
106 *
107 * @var string
108 */
109 public $entity_table;
110 /**
111 * The specific source item that is responsible for the creation of this financial_item
112 *
113 * @var int unsigned
114 */
115 public $entity_id;
116 /**
117 * class constructor
118 *
119 * @return civicrm_financial_item
120 */
121 function __construct() {
122 $this->__table = 'civicrm_financial_item';
123 parent::__construct();
124 }
125 /**
126 * Returns foreign keys and entity references
127 *
128 * @return array
129 * [CRM_Core_Reference_Interface]
130 */
131 static function getReferenceColumns() {
346aaaba
TO
132 if (!isset(Civi::$statics[__CLASS__]['links'])) {
133 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
134 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'contact_id', 'civicrm_contact', 'id');
135 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'financial_account_id', 'civicrm_financial_account', 'id');
136 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName() , 'entity_id', NULL, 'id', 'entity_table');
137 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 138 }
346aaaba 139 return Civi::$statics[__CLASS__]['links'];
e501603b
TO
140 }
141 /**
142 * Returns all the column names of this table
143 *
144 * @return array
145 */
146 static function &fields() {
346aaaba
TO
147 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
148 Civi::$statics[__CLASS__]['fields'] = array(
e501603b
TO
149 'id' => array(
150 'name' => 'id',
151 'type' => CRM_Utils_Type::T_INT,
152 'title' => ts('Financial Item ID') ,
153 'required' => true,
154 ) ,
155 'created_date' => array(
156 'name' => 'created_date',
157 'type' => CRM_Utils_Type::T_TIMESTAMP,
158 'title' => ts('Financial Item Created Date') ,
159 'description' => 'Date and time the item was created',
160 'required' => true,
161 'default' => 'CURRENT_TIMESTAMP',
162 ) ,
163 'transaction_date' => array(
164 'name' => 'transaction_date',
165 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
166 'title' => ts('Financial Item Transaction Date') ,
167 'description' => 'Date and time of the source transaction',
168 'required' => true,
169 ) ,
170 'contact_id' => array(
171 'name' => 'contact_id',
172 'type' => CRM_Utils_Type::T_INT,
173 'title' => ts('Financial Item Contact ID') ,
174 'description' => 'FK to Contact ID of contact the item is from',
175 'required' => true,
176 'export' => true,
177 'where' => 'civicrm_financial_item.contact_id',
178 'headerPattern' => '',
179 'dataPattern' => '',
180 'FKClassName' => 'CRM_Contact_DAO_Contact',
181 ) ,
182 'description' => array(
183 'name' => 'description',
184 'type' => CRM_Utils_Type::T_STRING,
185 'title' => ts('Financial Item Description') ,
186 'description' => 'Human readable description of this item, to ease display without lookup of source item.',
187 'maxlength' => 255,
188 'size' => CRM_Utils_Type::HUGE,
189 ) ,
190 'amount' => array(
191 'name' => 'amount',
192 'type' => CRM_Utils_Type::T_MONEY,
193 'title' => ts('Amount') ,
194 'description' => 'Total amount of this item',
195 'required' => true,
196 'precision' => array(
197 20,
198 2
199 ) ,
200 ) ,
201 'currency' => array(
202 'name' => 'currency',
203 'type' => CRM_Utils_Type::T_STRING,
204 'title' => ts('Financial Item Currency') ,
205 'description' => 'Currency for the amount',
206 'maxlength' => 3,
207 'size' => CRM_Utils_Type::FOUR,
208 'export' => true,
209 'where' => 'civicrm_financial_item.currency',
210 'headerPattern' => '',
211 'dataPattern' => '',
212 'html' => array(
213 'type' => 'Select',
214 ) ,
215 'pseudoconstant' => array(
216 'table' => 'civicrm_currency',
217 'keyColumn' => 'name',
218 'labelColumn' => 'full_name',
219 'nameColumn' => 'name',
220 )
221 ) ,
222 'financial_account_id' => array(
223 'name' => 'financial_account_id',
224 'type' => CRM_Utils_Type::T_INT,
225 'title' => ts('Financial Account ID') ,
226 'description' => 'FK to civicrm_financial_account',
227 'FKClassName' => 'CRM_Financial_DAO_FinancialAccount',
228 'html' => array(
229 'type' => 'Select',
230 ) ,
231 'pseudoconstant' => array(
232 'table' => 'civicrm_financial_account',
233 'keyColumn' => 'id',
234 'labelColumn' => 'name',
235 )
236 ) ,
237 'status_id' => array(
238 'name' => 'status_id',
239 'type' => CRM_Utils_Type::T_INT,
240 'title' => ts('Financial Item Status ID') ,
241 'description' => 'Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)',
242 'export' => true,
243 'where' => 'civicrm_financial_item.status_id',
244 'headerPattern' => '',
245 'dataPattern' => '',
246 'html' => array(
247 'type' => 'Select',
248 ) ,
249 'pseudoconstant' => array(
250 'optionGroupName' => 'financial_item_status',
251 'optionEditPath' => 'civicrm/admin/options/financial_item_status',
252 )
253 ) ,
254 'entity_table' => array(
255 'name' => 'entity_table',
256 'type' => CRM_Utils_Type::T_STRING,
257 'title' => ts('Entity Table') ,
258 'description' => 'The table providing the source of this item such as civicrm_line_item',
259 'maxlength' => 64,
260 'size' => CRM_Utils_Type::BIG,
261 ) ,
262 'entity_id' => array(
263 'name' => 'entity_id',
264 'type' => CRM_Utils_Type::T_INT,
265 'title' => ts('Entity ID') ,
266 'description' => 'The specific source item that is responsible for the creation of this financial_item',
267 ) ,
268 );
346aaaba 269 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 270 }
346aaaba 271 return Civi::$statics[__CLASS__]['fields'];
e501603b
TO
272 }
273 /**
bd8e0b14 274 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
275 *
276 * @return array
bd8e0b14 277 * Array(string $name => string $uniqueName).
e501603b
TO
278 */
279 static function &fieldKeys() {
bd8e0b14
TO
280 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
281 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 282 }
bd8e0b14 283 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b
TO
284 }
285 /**
286 * Returns the names of this table
287 *
288 * @return string
289 */
290 static function getTableName() {
291 return self::$_tableName;
292 }
293 /**
294 * Returns if this table needs to be logged
295 *
296 * @return boolean
297 */
298 function getLog() {
299 return self::$_log;
300 }
301 /**
302 * Returns the list of fields that can be imported
303 *
304 * @param bool $prefix
305 *
306 * @return array
307 */
308 static function &import($prefix = false) {
60808919
TO
309 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'financial_item', $prefix, array());
310 return $r;
e501603b
TO
311 }
312 /**
313 * Returns the list of fields that can be exported
314 *
315 * @param bool $prefix
316 *
317 * @return array
318 */
319 static function &export($prefix = false) {
60808919
TO
320 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'financial_item', $prefix, array());
321 return $r;
e501603b
TO
322 }
323}