Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

user/orderview.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: orderview.php 8850 2002-01-02 21:42:12Z kaid $
5 //
6 // Created on: <30-Sep-2000 13:03:13 bf>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27 if ( isset( $Cancel ) )
28 {
29 eZHTTPTool::header( "Location: /trade/orderlist/" );
30 exit();
31 }
32
33 // include_once( "classes/INIFile.php" );
34 // include_once( "classes/eztemplate.php" );
35 // include_once( "classes/ezlocale.php" );
36 // include_once( "classes/ezcurrency.php" );
37 // include_once( "ezcontact/classes/ezperson.php" );
38 // include_once( "ezcontact/classes/ezcompany.php" );
39 // include_once( "ezuser/classes/ezuser.php" );
40
41
42 $ini =& eZINI::instance( 'site.ini' );
43 $Language = $ini->variable( "eZTradeMain", "Language" );
44
45 $TinyImageWidth = $ini->variable( "eZImageCatalogueMain", "TinyImageWidth" );
46 $TinyImageHeight = $ini->variable( "eZImageCatalogueMain", "TinyImageHeight" );
47
48 $ShowPriceGroups = $ini->variable( "eZTradeMain", "PriceGroupsEnabled" ) == "true";
49 $upscheck = $ini->variable( "eZTradeMain", "UPSXMLShipping" ) == "enabled"?1:0;
50 $uspscheck = $ini->variable( "eZTradeMain", "USPSXMLShipping" ) == "enabled"?1:0;
51 if(($upscheck==0)&&($uspscheck==0))
52 $checkups=0;
53 else
54 $checkups=1;
55
56 $languageINI = new eZINI( "kernel/eztrade/user/intl/" . $Language . "/orderview.php.ini", false );
57
58
59 // include_once( "eztrade/classes/ezproductcategory.php" );
60 // include_once( "eztrade/classes/ezproduct.php" );
61 // include_once( "eztrade/classes/ezorder.php" );
62 // include_once( "eztrade/classes/ezcheckout.php" );
63 // include_once( "eztrade/classes/ezpricegroup.php" );
64
65 // include_once( "eztrade/classes/ezorderstatustype.php" );
66
67 $t = new eZTemplate( "kernel/eztrade/user/" . $ini->variable( "eZTradeMain", "TemplateDir" ),
68 "kernel/eztrade/user/intl/", $Language, "orderview.php" );
69
70 $t->setAllStrings();
71
72 $t->set_file( "order_edit_tpl", "orderview.tpl" );
73
74 $t->set_block( "order_edit_tpl", "visa_tpl", "visa" );
75 $t->set_block( "order_edit_tpl", "mastercard_tpl", "mastercard" );
76 $t->set_block( "order_edit_tpl", "cod_tpl", "cod" );
77 $t->set_block( "order_edit_tpl", "invoice_tpl", "invoice" );
78
79 $t->set_block( "order_edit_tpl", "order_item_list_tpl", "order_item_list" );
80 $t->set_block( "order_item_list_tpl", "order_item_tpl", "order_item" );
81
82 //$t->set_block( "order_edit_tpl", "order_status_option_tpl", "order_status_option" );
83 $t->set_block( "order_item_list_tpl", "order_status_history_tpl", "order_status_history" );
84
85 $t->set_block( "order_item_tpl", "order_item_option_tpl", "order_item_option" );
86
87 $order = new eZOrder( $OrderID );
88
89 $user = eZUser::currentUser();
90
91 if ( !$user )
92 {
93 eZHTTPTool::header( "Location: /error/403/" );
94 exit();
95
96 }
97
98
99 // get the customer
100 if ( !$order->isOwner( eZUser::currentUser() ) )
101 {
102 eZHTTPTool::header( "Location: /error/403" );
103 exit();
104 }
105 else
106 $localUser = $order->user();
107
108 if ( $localUser )
109 {
110 if ( $order->personID() == 0 && $order->companyID() == 0 )
111 {
112 $t->set_var( "customer_email", $localUser->email() );
113 $t->set_var( "customer_first_name", $localUser->firstName() );
114 $t->set_var( "customer_last_name", $localUser->lastName() );
115 }
116 else
117 {
118 if ( $order->personID() > 0 )
119 {
120 $customer = new eZPerson( $order->personID() );
121 $t->set_var( "customer_first_name", $customer->firstName() );
122 $t->set_var( "customer_last_name", $customer->lastName() );
123 }
124 else
125 {
126 $customer = new eZCompany( $order->companyID() );
127 $t->set_var( "customer_first_name", $customer->name() );
128 $t->set_var( "customer_last_name", "" );
129 }
130 $emailList = $customer->emailAddress();
131 $t->set_var( "customer_email", $emailList[0] );
132 }
133
134 // print out the addresses
135 $shippingAddress =& $order->shippingAddress();
136
137 $t->set_var( "shipping_street1", $shippingAddress->street1() );
138 $t->set_var( "shipping_street2", $shippingAddress->street2() );
139 $t->set_var( "shipping_zip", $shippingAddress->zip() );
140 $t->set_var( "shipping_place", $shippingAddress->place() );
141
142 if ( $order->personID() == 0 && $order->companyID() == 0 )
143 {
144 $shippingUser = $order->shippingUser();
145
146 if ( $shippingUser )
147 {
148 $t->set_var( "shipping_first_name", $shippingUser->firstName() );
149 $t->set_var( "shipping_last_name", $shippingUser->lastName() );
150 }
151 }
152 else
153 {
154 if ( $order->personID() > 0 )
155 {
156 $customer = new eZPerson( $order->personID() );
157 $t->set_var( "shipping_first_name", $customer->firstName() );
158 $t->set_var( "shipping_last_name", $customer->lastName() );
159 }
160 else
161 {
162 $customer = new eZCompany( $order->companyID() );
163 $t->set_var( "shipping_first_name", $customer->name() );
164 $t->set_var( "shipping_last_name", "" );
165 }
166 }
167
168 $region= $shippingAddress->region();
169 if ( is_object( $region ) )
170 {
171 $t->set_var( "shipping_region", $region->name() );
172 }
173 else
174 {
175 $t->set_var( "shipping_region", "" );
176 }
177
178 $country = $shippingAddress->country();
179 if ( is_object( $country ) )
180 {
181 $t->set_var( "shipping_country", $country->name() );
182 }
183 else
184 {
185 $t->set_var( "shipping_country", "" );
186 }
187 $billingAddress =& $order->billingAddress();
188
189 $t->set_var( "billing_street1", $billingAddress->street1() );
190 $t->set_var( "billing_street2", $billingAddress->street2() );
191 $t->set_var( "billing_zip", $billingAddress->zip() );
192 $t->set_var( "billing_place", $billingAddress->place() );
193
194 $PriceGroup = eZPriceGroup::correctPriceGroup( $localUser->groups( false ), true );
195
196 $region = $billingAddress->region();
197 if ( is_object( $region ) )
198 {
199 $t->set_var( "billing_region", $region->name() );
200 }
201 else
202 {
203 $t->set_var( "billing_region", "" );
204 }
205
206 $country = $billingAddress->country();
207 if ( is_object( $country ) )
208 {
209 $t->set_var( "billing_country", $country->name() );
210 }
211 else
212 {
213 $t->set_var( "billing_country", "" );
214 }
215 }
216
217 if( !isset( $OrderType ) )
218 $OrderType = false;
219
220 // fetch the order items
221 $items = $order->items( $OrderType );
222 $locale = new eZLocale( $Language );
223 $currency = new eZCurrency();
224
225 $i = 0;
226 $sum = 0.0;
227 $t->set_var( "product_image_caption", "" );
228
229
230 foreach ( $items as $item )
231 {
232 $product =& $item->product();
233
234 $image = $product->thumbnailImage();
235
236 if ( $image )
237 {
238 $thumbnail =& $image->requestImageVariation( $TinyImageWidth, $TinyImageHeight );
239
240 $t->set_var( "product_image_path", "/" . $thumbnail->imagePath() );
241 $t->set_var( "product_image_width", $thumbnail->width() );
242 $t->set_var( "product_image_height", $thumbnail->height() );
243 $t->set_var( "product_image_caption", $image->caption() );
244 }
245
246 $price = $item->price() * $item->count();
247
248 $currency->setValue( $price );
249
250 $sum += $price;
251 $t->set_var( "product_name", $product->name() );
252 $t->set_var( "product_id", $product->id() );
253 $t->set_var( "product_number", $product->productNumber() );
254 $t->set_var( "product_price", $locale->format( $currency ) );
255
256 $t->set_var( "order_item_count", $item->count() );
257
258 if ( ( $i % 2 ) == 0 )
259 $t->set_var( "td_class", "bglight" );
260 else
261 $t->set_var( "td_class", "bgdark" );
262
263 $optionValues =& $item->optionValues();
264
265 $t->set_var( "order_item_option", "" );
266 foreach ( $optionValues as $optionValue )
267 {
268 $t->set_var( "option_name", $optionValue->optionName() );
269 $t->set_var( "option_value", $optionValue->valueName() );
270
271 $t->parse( "order_item_option", "order_item_option_tpl", true );
272 }
273 $t->parse( "order_item", "order_item_tpl", true );
274
275 $i++;
276 }
277 $shippingCost = $order->shippingCharge();
278
279 $currency->setValue( $shippingCost );
280 $t->set_var( "shipping_cost", $locale->format( $currency ) );
281
282 //print_r($order); print_r( $order->shippingVAT() ); exit();
283
284 $totalVAT = $order->totalVAT();
285 $currency->setValue( $totalVAT );
286 $t->set_var( "vat_cost", $locale->format( $currency ) );
287 if ( $order->isVATInc() )
288 {
289 $totalVAT = $order->totalVAT();
290 if ( $order->shippingVAT() > 0 )
291 $totalVAT = $totalVAT + $order->shippingVAT();
292 $currency->setValue( $totalVAT );
293 $t->set_var( "vat_cost", $locale->format( $currency ) );
294 $sum = $order->totalPriceIncVAT() + $shippingCost + $order->shippingVAT();
295 $currency->setValue( $sum );
296 $t->set_var( "order_sum", $locale->format( $currency ) );
297 }
298 else
299 {
300 $currency->setValue( 0 );
301 $t->set_var( "vat_cost", $locale->format( $currency ) );
302 $sum += $shippingCost;
303 $currency->setValue( $sum );
304 $t->set_var( "order_sum", $locale->format( $currency ) );
305 }
306
307 //$statusType = new eZOrderStatusType();
308 /*
309 $statusTypeArray = $statusType->getAll();
310 foreach ( $statusTypeArray as $status )
311 {
312 $statusName = preg_replace( "#intl-#", "", $status->name() );
313 $statusName = $languageINI->variable( "strings", $statusName );
314
315 $t->set_var( "option_name", $statusName );
316 $t->set_var( "option_id", $status->id() );
317 $t->parse( "order_status_option", "order_status_option_tpl", true );
318 }
319 */
320
321 $historyArray = $order->statusHistory();
322 /*
323 echo "<pre>";
324 print_r($historyArray);
325 echo "</pre>";
326 exit();
327 */
328 $j=0;
329 foreach ( $historyArray as $status )
330 {
331 if ( ( $j % 2 ) == 0 )
332 $t->set_var( "td_class", "bglight" );
333 else
334 $t->set_var( "td_class", "bgdark" );
335
336 $admin = $status->admin();
337
338 $statusType = $status->type();
339 if( $statusType && $statusType->name() != null )
340 $statusName = preg_replace( "#intl-#", "", $statusType->name() );
341 else
342 $statusName = "Pending";
343
344 // $statusName = $languageINI->variable( "strings", $statusName );
345
346 $t->set_var( "status_date", $locale->format( $status->altered() ) );
347 $t->set_var( "status_name", $statusName );
348 $t->set_var( "status_comment", $status->comment() );
349 $t->set_var( "admin_login", $admin->login() );
350 $t->parse( "order_status_history", "order_status_history_tpl", true );
351 $j++;
352 }
353
354
355
356 $checkout = new eZCheckout();
357 $instance =& $checkout->instance();
358 $paymentMethod = $instance->paymentName( $order->paymentMethod() );
359
360 $t->set_var( "payment_method", $paymentMethod );
361
362 $shippingType = $order->shippingType();
363
364 $t->set_var( "shipping_method", "" );
365
366
367 if (( $shippingType )&&($checkups==1))
368 {
369 $getnames =array (
370 '01' => 'UPS Next Day Air',
371 '02' => 'UPS 2nd Day Air',
372 '03' => 'UPS Ground',
373 '07' => 'UPS Worldwide Express',
374 '08' => 'UPS Worldwide Expedited',
375 '11' => 'UPS Standard',
376 '12' => 'UPS 3 Day Select',
377 '13' => 'UPS Next Day Air Saver',
378 '14' => 'UPS Next Day Air Early A.M.',
379 '54' => 'UPS Worldwide Express Plus',
380 '59' => 'UPS 2nd Day Air A.M.',
381 '64' => '',
382 '65' => 'UPS Express Saver',
383 );
384
385 if (!$getnames["$shippingType"])
386 $service_name=$shippingType;
387 else
388 $service_name=$getnames["$shippingType"];
389
390 $t->set_var( "shipping_method", $service_name );
391 }
392
393 if (( $shippingType && is_object($shippingType) ) && ( $checkups !=1 ) )
394 {
395 $t->set_var( "shipping_method", $shippingType->name() );
396 }
397 else
398 {
399 $t->set_var( "shipping_method", $shippingType );
400 }
401
402 $t->set_var( "order_id", $order->id() );
403
404 $t->parse( "order_item_list", "order_item_list_tpl" );
405
406 $t->pparse( "output", "order_edit_tpl" );
407
408 ?>
$status
$status
Definition: bugedit.php:473
$shippingAddress
$shippingAddress
Definition: checkout.php:615
eZCheckout
Definition: ezcheckout.php:48
eZCompany
Definition: ezcompany.php:54
eZCurrency
Definition: ezcurrency.php:46
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZINI
Reads and writes .ini style configuration files.
eZLocale
Definition: ezlocale.php:119
eZOrder
Definition: ezorder.php:52
eZPerson
Definition: ezperson.php:43
eZPriceGroup\correctPriceGroup
static correctPriceGroup( $group_id, $debug=false)
Definition: ezpricegroup.php:240
eZTemplate
Definition: eztemplate.php:107
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$item
$item
Definition: classes/admin/linklist.php:228
$customer
$customer
Definition: customerview.php:72
$thumbnail
$thumbnail
Definition: ezarticle/admin/imagelist.php:59
exit
exit
Definition: folder.php:81
$product
$product
Definition: homepage.php:202
$statusType
if(count( $usedVouchers) > 0) $statusType
Definition: orderedit.php:620
$country
$country
Definition: paypal.php:46
$billingAddress
$billingAddress
Definition: paypal.php:44
$region
$region
Definition: paypal.php:45
$price
$price
Definition: pricegroupedit.php:39
$PriceGroup
$PriceGroup
Definition: productedit.php:1073
$image
$image
Definition: user/articlelist.php:242
$shippingCost
foreach( $items as $item) $shippingCost
Definition: user/orderview.php:277
$TinyImageWidth
$TinyImageWidth
Definition: user/orderview.php:45
$order
$order
Definition: user/orderview.php:87
$checkups
else $checkups
Definition: user/orderview.php:54
$shippingType
$shippingType
Definition: user/orderview.php:362
$totalVAT
$totalVAT
Definition: user/orderview.php:284
$currency
$currency
Definition: user/orderview.php:223
$locale
$locale
Definition: user/orderview.php:222
$t
$t
Definition: user/orderview.php:67
$languageINI
$languageINI
Definition: user/orderview.php:56
$user
$user
Definition: user/orderview.php:89
$j
$j
Definition: user/orderview.php:328
$items
$items
Definition: user/orderview.php:221
$i
$i
Definition: user/orderview.php:225
$ini
if(isset( $Cancel)) $ini
Definition: user/orderview.php:42
$Language
$Language
Definition: user/orderview.php:43
$sum
$sum
Definition: user/orderview.php:226
$paymentMethod
$paymentMethod
Definition: user/orderview.php:358
$TinyImageHeight
$TinyImageHeight
Definition: user/orderview.php:46
$ShowPriceGroups
$ShowPriceGroups
Definition: user/orderview.php:48
$upscheck
$upscheck
Definition: user/orderview.php:49
$instance
$instance
Definition: user/orderview.php:357
$historyArray
$historyArray
Definition: user/orderview.php:321
$localUser
if(! $user) if(! $order->isOwner(eZUser::currentUser())) else $localUser
Definition: user/orderview.php:106
$uspscheck
$uspscheck
Definition: user/orderview.php:50
$checkout
foreach( $historyArray as $status) $checkout
Definition: user/orderview.php:356
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.