xml/templates/dao.tpl - Centralize export() / import() logic
[civicrm-core.git] / CRM / Financial / DAO / EntityFinancialTrxn.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/Financial/EntityFinancialTrxn.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
437fafcf 33 * (GenCodeChecksum:42848b82aaf63e76e1848ea1a6dbd4b2)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
37class CRM_Financial_DAO_EntityFinancialTrxn extends CRM_Core_DAO {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 */
43 static $_tableName = 'civicrm_entity_financial_trxn';
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 = false;
83 /**
84 * ID
85 *
86 * @var int unsigned
87 */
88 public $id;
89 /**
90 * May contain civicrm_financial_item, civicrm_contribution, civicrm_financial_trxn, civicrm_grant, etc
91 *
92 * @var string
93 */
94 public $entity_table;
95 /**
96 *
97 * @var int unsigned
98 */
99 public $entity_id;
100 /**
101 *
102 * @var int unsigned
103 */
104 public $financial_trxn_id;
105 /**
106 * allocated amount of transaction to this entity
107 *
108 * @var float
109 */
110 public $amount;
111 /**
112 * class constructor
113 *
114 * @return civicrm_entity_financial_trxn
115 */
116 function __construct() {
117 $this->__table = 'civicrm_entity_financial_trxn';
118 parent::__construct();
119 }
120 /**
121 * Returns foreign keys and entity references
122 *
123 * @return array
124 * [CRM_Core_Reference_Interface]
125 */
126 static function getReferenceColumns() {
127 if (!self::$_links) {
128 self::$_links = static ::createReferenceColumns(__CLASS__);
129 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'financial_trxn_id', 'civicrm_financial_trxn', 'id');
130 self::$_links[] = new CRM_Core_Reference_Dynamic(self::getTableName() , 'entity_id', NULL, 'id', 'entity_table');
131 }
132 return self::$_links;
133 }
134 /**
135 * Returns all the column names of this table
136 *
137 * @return array
138 */
139 static function &fields() {
140 if (!(self::$_fields)) {
141 self::$_fields = array(
142 'id' => array(
143 'name' => 'id',
144 'type' => CRM_Utils_Type::T_INT,
145 'title' => ts('Entity Financial Transaction ID') ,
146 'description' => 'ID',
147 'required' => true,
148 ) ,
149 'entity_table' => array(
150 'name' => 'entity_table',
151 'type' => CRM_Utils_Type::T_STRING,
152 'title' => ts('Entity Table') ,
153 'description' => 'May contain civicrm_financial_item, civicrm_contribution, civicrm_financial_trxn, civicrm_grant, etc',
154 'required' => true,
155 'maxlength' => 64,
156 'size' => CRM_Utils_Type::BIG,
157 'import' => true,
158 'where' => 'civicrm_entity_financial_trxn.entity_table',
159 'headerPattern' => '',
160 'dataPattern' => '',
161 'export' => true,
162 ) ,
163 'entity_id' => array(
164 'name' => 'entity_id',
165 'type' => CRM_Utils_Type::T_INT,
166 'title' => ts('Entity ID') ,
167 'required' => true,
168 ) ,
169 'financial_trxn_id' => array(
170 'name' => 'financial_trxn_id',
171 'type' => CRM_Utils_Type::T_INT,
172 'title' => ts('Financial Transaction Id') ,
173 'FKClassName' => 'CRM_Financial_DAO_FinancialTrxn',
174 ) ,
175 'amount' => array(
176 'name' => 'amount',
177 'type' => CRM_Utils_Type::T_MONEY,
178 'title' => ts('Amount') ,
179 'description' => 'allocated amount of transaction to this entity',
180 'required' => true,
181 'precision' => array(
182 20,
183 2
184 ) ,
185 'import' => true,
186 'where' => 'civicrm_entity_financial_trxn.amount',
187 'headerPattern' => '/amount/i',
188 'dataPattern' => '/^\d+(\.\d{2})?$/',
189 'export' => true,
190 ) ,
191 );
192 }
193 return self::$_fields;
194 }
195 /**
196 * Returns an array containing, for each field, the arary key used for that
197 * field in self::$_fields.
198 *
199 * @return array
200 */
201 static function &fieldKeys() {
202 if (!(self::$_fieldKeys)) {
203 self::$_fieldKeys = array(
204 'id' => 'id',
205 'entity_table' => 'entity_table',
206 'entity_id' => 'entity_id',
207 'financial_trxn_id' => 'financial_trxn_id',
208 'amount' => 'amount',
209 );
210 }
211 return self::$_fieldKeys;
212 }
213 /**
214 * Returns the names of this table
215 *
216 * @return string
217 */
218 static function getTableName() {
219 return self::$_tableName;
220 }
221 /**
222 * Returns if this table needs to be logged
223 *
224 * @return boolean
225 */
226 function getLog() {
227 return self::$_log;
228 }
229 /**
230 * Returns the list of fields that can be imported
231 *
232 * @param bool $prefix
233 *
234 * @return array
235 */
236 static function &import($prefix = false) {
237 if (!(self::$_import)) {
238 self::$_import = array();
239 $fields = self::fields();
240 foreach($fields as $name => $field) {
241 if (CRM_Utils_Array::value('import', $field)) {
242 if ($prefix) {
243 self::$_import['entity_financial_trxn'] = & $fields[$name];
244 } else {
245 self::$_import[$name] = & $fields[$name];
246 }
247 }
248 }
249 }
250 return self::$_import;
251 }
252 /**
253 * Returns the list of fields that can be exported
254 *
255 * @param bool $prefix
256 *
257 * @return array
258 */
259 static function &export($prefix = false) {
260 if (!(self::$_export)) {
261 self::$_export = array();
262 $fields = self::fields();
263 foreach($fields as $name => $field) {
264 if (CRM_Utils_Array::value('export', $field)) {
265 if ($prefix) {
266 self::$_export['entity_financial_trxn'] = & $fields[$name];
267 } else {
268 self::$_export[$name] = & $fields[$name];
269 }
270 }
271 }
272 }
273 return self::$_export;
274 }
275}