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