Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
06b69b18 | 4 | | CiviCRM version 4.5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06b69b18 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 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 | * | |
29 | * @package CRM | |
06b69b18 | 30 | * @copyright CiviCRM LLC (c) 2004-2014 |
6a488035 TO |
31 | * $Id$ |
32 | * | |
33 | */ | |
34 | require_once 'CRM/Core/DAO.php'; | |
35 | require_once 'CRM/Utils/Type.php'; | |
36 | class CRM_Upgrade_Snapshot_V4p2_Price_DAO_LineItem extends CRM_Core_DAO | |
37 | { | |
38 | /** | |
39 | * static instance to hold the table name | |
40 | * | |
41 | * @var string | |
42 | * @static | |
43 | */ | |
44 | static $_tableName = 'civicrm_line_item'; | |
45 | /** | |
46 | * static instance to hold the field values | |
47 | * | |
48 | * @var array | |
49 | * @static | |
50 | */ | |
51 | static $_fields = null; | |
52 | /** | |
53 | * static instance to hold the FK relationships | |
54 | * | |
55 | * @var string | |
56 | * @static | |
57 | */ | |
58 | static $_links = null; | |
59 | /** | |
60 | * static instance to hold the values that can | |
61 | * be imported | |
62 | * | |
63 | * @var array | |
64 | * @static | |
65 | */ | |
66 | static $_import = null; | |
67 | /** | |
68 | * static instance to hold the values that can | |
69 | * be exported | |
70 | * | |
71 | * @var array | |
72 | * @static | |
73 | */ | |
74 | static $_export = null; | |
75 | /** | |
76 | * static value to see if we should log any modifications to | |
77 | * this table in the civicrm_log table | |
78 | * | |
79 | * @var boolean | |
80 | * @static | |
81 | */ | |
82 | static $_log = true; | |
83 | /** | |
84 | * Line Item | |
85 | * | |
86 | * @var int unsigned | |
87 | */ | |
88 | public $id; | |
89 | /** | |
90 | * table which has the transaction | |
91 | * | |
92 | * @var string | |
93 | */ | |
94 | public $entity_table; | |
95 | /** | |
96 | * entry in table | |
97 | * | |
98 | * @var int unsigned | |
99 | */ | |
100 | public $entity_id; | |
101 | /** | |
102 | * FK to price_field | |
103 | * | |
104 | * @var int unsigned | |
105 | */ | |
106 | public $price_field_id; | |
107 | /** | |
108 | * descriptive label for item - from price_field_value.label | |
109 | * | |
110 | * @var string | |
111 | */ | |
112 | public $label; | |
113 | /** | |
114 | * How many items ordered | |
115 | * | |
116 | * @var int unsigned | |
117 | */ | |
118 | public $qty; | |
119 | /** | |
120 | * price of each item | |
121 | * | |
122 | * @var float | |
123 | */ | |
124 | public $unit_price; | |
125 | /** | |
126 | * qty * unit_price | |
127 | * | |
128 | * @var float | |
129 | */ | |
130 | public $line_total; | |
131 | /** | |
132 | * Participant count for field | |
133 | * | |
134 | * @var int unsigned | |
135 | */ | |
136 | public $participant_count; | |
137 | /** | |
138 | * Implicit FK to civicrm_option_value | |
139 | * | |
140 | * @var int unsigned | |
141 | */ | |
142 | public $price_field_value_id; | |
143 | /** | |
144 | * class constructor | |
145 | * | |
146 | * @access public | |
147 | * @return civicrm_line_item | |
148 | */ | |
149 | function __construct() | |
150 | { | |
151 | $this->__table = 'civicrm_line_item'; | |
152 | parent::__construct(); | |
153 | } | |
154 | /** | |
155 | * return foreign links | |
156 | * | |
157 | * @access public | |
158 | * @return array | |
159 | */ | |
160 | function links() | |
161 | { | |
162 | if (!(self::$_links)) { | |
163 | self::$_links = array( | |
164 | 'price_field_id' => 'civicrm_price_field:id', | |
165 | 'price_field_value_id' => 'civicrm_price_field_value:id', | |
166 | ); | |
167 | } | |
168 | return self::$_links; | |
169 | } | |
170 | /** | |
171 | * returns all the column names of this table | |
172 | * | |
173 | * @access public | |
174 | * @return array | |
175 | */ | |
176 | static function &fields() | |
177 | { | |
178 | if (!(self::$_fields)) { | |
179 | self::$_fields = array( | |
180 | 'id' => array( | |
181 | 'name' => 'id', | |
182 | 'type' => CRM_Utils_Type::T_INT, | |
183 | 'required' => true, | |
184 | ) , | |
185 | 'entity_table' => array( | |
186 | 'name' => 'entity_table', | |
187 | 'type' => CRM_Utils_Type::T_STRING, | |
188 | 'title' => ts('Entity Table') , | |
189 | 'required' => true, | |
190 | 'maxlength' => 64, | |
191 | 'size' => CRM_Utils_Type::BIG, | |
192 | ) , | |
193 | 'entity_id' => array( | |
194 | 'name' => 'entity_id', | |
195 | 'type' => CRM_Utils_Type::T_INT, | |
196 | 'required' => true, | |
197 | ) , | |
198 | 'price_field_id' => array( | |
199 | 'name' => 'price_field_id', | |
200 | 'type' => CRM_Utils_Type::T_INT, | |
201 | 'required' => true, | |
202 | 'FKClassName' => 'Snapshot_v4p2_Price_DAO_Field', | |
203 | ) , | |
204 | 'label' => array( | |
205 | 'name' => 'label', | |
206 | 'type' => CRM_Utils_Type::T_STRING, | |
207 | 'title' => ts('Label') , | |
208 | 'maxlength' => 255, | |
209 | 'size' => CRM_Utils_Type::HUGE, | |
210 | 'default' => 'UL', | |
211 | ) , | |
212 | 'qty' => array( | |
213 | 'name' => 'qty', | |
214 | 'type' => CRM_Utils_Type::T_INT, | |
215 | 'title' => ts('Qty') , | |
216 | 'required' => true, | |
217 | ) , | |
218 | 'unit_price' => array( | |
219 | 'name' => 'unit_price', | |
220 | 'type' => CRM_Utils_Type::T_MONEY, | |
221 | 'title' => ts('Unit Price') , | |
222 | 'required' => true, | |
223 | ) , | |
224 | 'line_total' => array( | |
225 | 'name' => 'line_total', | |
226 | 'type' => CRM_Utils_Type::T_MONEY, | |
227 | 'title' => ts('Line Total') , | |
228 | 'required' => true, | |
229 | ) , | |
230 | 'participant_count' => array( | |
231 | 'name' => 'participant_count', | |
232 | 'type' => CRM_Utils_Type::T_INT, | |
233 | 'title' => ts('Participant Count') , | |
234 | 'default' => 'UL', | |
235 | ) , | |
236 | 'price_field_value_id' => array( | |
237 | 'name' => 'price_field_value_id', | |
238 | 'type' => CRM_Utils_Type::T_INT, | |
239 | 'default' => 'UL', | |
240 | 'FKClassName' => 'Snapshot_v4p2_Price_DAO_FieldValue', | |
241 | ) , | |
242 | ); | |
243 | } | |
244 | return self::$_fields; | |
245 | } | |
246 | /** | |
247 | * returns the names of this table | |
248 | * | |
249 | * @access public | |
250 | * @static | |
251 | * @return string | |
252 | */ | |
253 | static function getTableName() | |
254 | { | |
255 | return self::$_tableName; | |
256 | } | |
257 | /** | |
258 | * returns if this table needs to be logged | |
259 | * | |
260 | * @access public | |
261 | * @return boolean | |
262 | */ | |
263 | function getLog() | |
264 | { | |
265 | return self::$_log; | |
266 | } | |
267 | /** | |
268 | * returns the list of fields that can be imported | |
269 | * | |
270 | * @access public | |
271 | * return array | |
272 | * @static | |
273 | */ | |
274 | static function &import($prefix = false) | |
275 | { | |
276 | if (!(self::$_import)) { | |
277 | self::$_import = array(); | |
278 | $fields = self::fields(); | |
279 | foreach($fields as $name => $field) { | |
a7488080 | 280 | if (!empty($field['import'])) { |
6a488035 TO |
281 | if ($prefix) { |
282 | self::$_import['line_item'] = & $fields[$name]; | |
283 | } else { | |
284 | self::$_import[$name] = & $fields[$name]; | |
285 | } | |
286 | } | |
287 | } | |
288 | } | |
289 | return self::$_import; | |
290 | } | |
291 | /** | |
292 | * returns the list of fields that can be exported | |
293 | * | |
294 | * @access public | |
295 | * return array | |
296 | * @static | |
297 | */ | |
298 | static function &export($prefix = false) | |
299 | { | |
300 | if (!(self::$_export)) { | |
301 | self::$_export = array(); | |
302 | $fields = self::fields(); | |
303 | foreach($fields as $name => $field) { | |
a7488080 | 304 | if (!empty($field['export'])) { |
6a488035 TO |
305 | if ($prefix) { |
306 | self::$_export['line_item'] = & $fields[$name]; | |
307 | } else { | |
308 | self::$_export[$name] = & $fields[$name]; | |
309 | } | |
310 | } | |
311 | } | |
312 | } | |
313 | return self::$_export; | |
314 | } | |
315 | } |