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