Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezorderitem.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezorderitem.php 7299 2001-09-17 11:34:36Z pkej $
5 //
6 // Definition of eZOrderItem class
7 //
8 // Created on: <29-Sep-2000 10:27:55 bf>
9 //
10 // This source file is part of Exponential Basic, publishing software.
11 //
12 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
13 //
14 // This program is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU General Public License
16 // as published by the Free Software Foundation; either version 2
17 // of the License, or (at your option) any later version.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
27 //
30
43 // include_once( "classes/ezdb.php" );
44 // include_once( "eztrade/classes/ezorderoptionvalue.php" );
45 // include_once( "eztrade/classes/ezproduct.php" );
46
47 class eZOrderItem
48 {
55 function __construct( $id="" )
56 {
57 $this->ExpiryDate = 0;
58 if ( $id != "" )
59 {
60 $this->ID = $id;
61 $this->get( $this->ID );
62 }
63 }
64
68 function store()
69 {
70 $db =& eZDB::globalDatabase();
71 $db->begin();
72 if ( !isset( $this->ID ) )
73 {
74
75 $db->lock( "eZTrade_OrderItem" );
76 $nextID = $db->nextID( "eZTrade_OrderItem", "ID");
77 $ret[] = $db->query( "INSERT INTO eZTrade_OrderItem
78 ( ID,
79 OrderID,
80 Count,
81 Price,
82 VAT,
83 ProductID,
84 ExpiryDate )
85 VALUES
86 ( '$nextID',
87 '$this->OrderID',
88 '$this->Count',
89 '$this->Price',
90 '$this->VAT',
91 '$this->ProductID',
92 '$this->ExpiryDate' )" );
93 $db->unlock();
94 $this->ID = $nextID;
95
96 }
97 else
98 {
99 $ret[] = $db->query( "UPDATE eZTrade_OrderItem SET
100 OrderID='$this->OrderID',
101 Count='$this->Count',
102 Price='$this->Price',
103 ProductID='$this->ProductID',
104 VAT='$this->VAT',
105 ExpiryDate='$this->ExpiryDate'
106 WHERE ID='$this->ID'
107 " );
108
109 }
110 eZDB::finish( $ret, $db );
111 return true;
112 }
113
117 function get( $id="" )
118 {
119 $db =& eZDB::globalDatabase();
120 $ret = false;
121
122 if ( $id != "" )
123 {
124 $db->array_query( $cart_array, "SELECT * FROM eZTrade_OrderItem WHERE ID='$id'" );
125 if ( count( $cart_array ) > 1 )
126 {
127 die( "Error: Cart's with the same ID was found in the database. This shouldent happen." );
128 }
129 else if ( count( $cart_array ) == 1 )
130 {
131 $this->ID =& $cart_array[0][$db->fieldName("ID")];
132 $this->OrderID =& $cart_array[0][$db->fieldName("OrderID")];
133 $this->Count =& $cart_array[0][$db->fieldName("Count")];
134 $this->Price =& $cart_array[0][$db->fieldName("Price")];
135 $this->ProductID =& $cart_array[0][$db->fieldName("ProductID")];
136 $this->ExpiryDate =& $cart_array[0][$db->fieldName("ExpiryDate")];
137 $this->VAT =& $cart_array[0][ "VAT" ];
138 $ret = true;
139 }
140 }
141 return $ret;
142 }
143
147 function delete()
148 {
149 $db =& eZDB::globalDatabase();
150 $db->begin();
151
152 $ret[] = $db->query( "DELETE FROM eZTrade_OrderOptionValue WHERE OrderItemID='$this->ID'" );
153 $ret[] = $db->query( "DELETE FROM eZTrade_OrderItem WHERE ID='$this->ID'" );
154
155 eZDB::finish( $ret, $db );
156 return true;
157 }
158
162 function id()
163 {
164 return $this->ID;
165 }
166
170 function count( )
171 {
172 return $this->Count;
173 }
174
178 function price( )
179 {
180 return $this->Price;
181 }
182
186 function product()
187 {
188 $ret = new eZProduct( $this->ProductID );
189
190 return $ret;
191 }
192
196 function priceIncVAT( )
197 {
198 return $this->Price + $this->VAT;
199 }
200
204 function VAT( )
205 {
206 return $this->VAT;
207 }
208
212 function expiryDate()
213 {
214 return $this->ExpiryDate;
215 }
216
220 function optionValues()
221 {
222 $db =& eZDB::globalDatabase();
223
224 $return_array = array();
225
226 $db->array_query( $res_array, "SELECT ID FROM eZTrade_OrderOptionValue
227 WHERE
228 OrderItemID='$this->ID'
229 " );
230
231 foreach ( $res_array as $item )
232 {
233 $return_array[] = new eZOrderOptionValue( $item[$db->fieldName("ID")] );
234 }
235
236 return $return_array;
237 }
238
242 function setOrder( $order )
243 {
244 if ( is_a( $order, "eZOrder" ) )
245 {
246 $this->OrderID = $order->id();
247 }
248 }
249
253 function setProduct( $product )
254 {
255 if ( is_a( $product, "eZProduct" ) )
256 {
257 $this->ProductID = $product->id();
258 }
259 }
260
264 function setCount( $value )
265 {
266 $this->Count = $value;
267 setType( $this->Count, "integer" );
268 }
269
273 function setPrice( $value )
274 {
275 $this->Price = $value;
276 setType( $this->Price, "double" );
277 }
278
282 function setVAT( $value )
283 {
284 if ( $this->State_ == "Dirty" )
285 $this->get( $this->ID );
286
287 $this->VAT = $value;
288 setType( $this->VAT, "double" );
289 }
290
291
295 function setExpiryDate( $date )
296 {
297 if ( is_a( $date, "eZDate" ) || is_a( $date, "eZDateTime" ) )
298 $timestamp = $date->timeStamp();
299 else if ( is_numeric( $date ) )
300 $timestamp = $date;
301 else
302 return false;
303
304 $this->ExpiryDate = $timestamp;
305 }
306
310 function order()
311 {
312 return new eZOrder( $this->OrderID );
313 }
314
319 function correctPrice( $calcCount=true, $withOptions=true, $calcVAT=true )
320 {
321 if ( $calcVAT == true )
322 {
323 $price = $this->Price + $this->VAT;
324 }
325 else
326 {
327 $price = $this->Price;
328 }
329
330 if ( $calcCount == true )
331 {
332 $price = $price * $this->Count;
333 }
334
335 return $price;
336 }
337
341 function localePrice( $calcCount=true, $withOptions=true, $calcVAT=true )
342 {
343 $ini =& eZINI::instance( 'site.ini' );
344 $Language = $ini->variable( "eZTradeMain", "Language" );
345 $locale = new eZLocale( $Language );
346 $currency = new eZCurrency();
347
348 $price = $this->correctPrice( $calcCount, $withOptions, $calcVAT );
349
350 $currency->setValue( $price );
351 return $locale->format( $currency );
352 }
353
354
355
356 var $ID;
357 var $OrderID;
358 var $Count;
359 var $Price;
360 var $ProductID;
361 var $ExpiryDate;
362 var $VAT;
363
364 }
365
366 ?>
$locale
$locale
Definition: admin/adlist.php:127
$date
$date
Definition: bugpreview.php:66
eZCurrency
Definition: ezcurrency.php:46
eZDB\finish
static finish(&$resultArray, &$db)
Definition: ezdb.php:204
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZLocale
Definition: ezlocale.php:119
eZOrderItem
Definition: ezorderitem.php:48
eZOrderItem\setOrder
setOrder( $order)
Definition: ezorderitem.php:242
eZOrderItem\$VAT
$VAT
Definition: ezorderitem.php:362
eZOrderItem\setProduct
setProduct( $product)
Definition: ezorderitem.php:253
eZOrderItem\store
store()
Definition: ezorderitem.php:68
eZOrderItem\localePrice
localePrice( $calcCount=true, $withOptions=true, $calcVAT=true)
Definition: ezorderitem.php:341
eZOrderItem\priceIncVAT
priceIncVAT()
Definition: ezorderitem.php:196
eZOrderItem\$Count
$Count
Definition: ezorderitem.php:358
eZOrderItem\__construct
__construct( $id="")
Definition: ezorderitem.php:55
eZOrderItem\$ID
$ID
Definition: ezorderitem.php:356
eZOrderItem\optionValues
optionValues()
Definition: ezorderitem.php:220
eZOrderItem\$OrderID
$OrderID
Definition: ezorderitem.php:357
eZOrderItem\$ProductID
$ProductID
Definition: ezorderitem.php:360
eZOrderItem\price
price()
Definition: ezorderitem.php:178
eZOrderItem\setExpiryDate
setExpiryDate( $date)
Definition: ezorderitem.php:295
eZOrderItem\setCount
setCount( $value)
Definition: ezorderitem.php:264
eZOrderItem\order
order()
Definition: ezorderitem.php:310
eZOrderItem\setVAT
setVAT( $value)
Definition: ezorderitem.php:282
eZOrderItem\product
product()
Definition: ezorderitem.php:186
eZOrderItem\count
count()
Definition: ezorderitem.php:170
eZOrderItem\expiryDate
expiryDate()
Definition: ezorderitem.php:212
eZOrderItem\correctPrice
correctPrice( $calcCount=true, $withOptions=true, $calcVAT=true)
Definition: ezorderitem.php:319
eZOrderItem\id
id()
Definition: ezorderitem.php:162
eZOrderItem\$Price
$Price
Definition: ezorderitem.php:359
eZOrderItem\setPrice
setPrice( $value)
Definition: ezorderitem.php:273
eZOrderItem\$ExpiryDate
$ExpiryDate
Definition: ezorderitem.php:361
eZOrderItem\VAT
VAT()
Definition: ezorderitem.php:204
eZOrderOptionValue
Definition: ezorderoptionvalue.php:42
eZOrder
Definition: ezorder.php:52
eZProduct
Definition: ezproduct.php:71
$Language
$Language
Definition: classes/admin/linklist.php:65
$ini
$ini
Definition: classes/admin/linklist.php:64
$item
$item
Definition: classes/admin/linklist.php:228
$id
$id
Definition: companytypelist.php:193
$currency
$currency
Definition: companyview.php:529
$db
$db
Definition: ezarticle/user/authorlist.php:53
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$timestamp
$timestamp
Definition: ezstats/admin/cron.php:35
$product
$product
Definition: homepage.php:202
$price
$price
Definition: pricegroupedit.php:39
$order
$order
Definition: productreport.php:182
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.