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