Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

classes/seti.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: seti.php,v 0.1 2004/01/10
5 //
6 // Created on: <10-Jan-2004 Bob Sims>
7 //
8 // This source file integrates Stone Edge Order Manager
9 // with Exponential Basic v2.2 publishing software.
10 //
11 // Copyright (C) 2004 Bob Sims. All rights reserved.
12 include_once( "eztrade/classes/ezorder.php" );
13 echo"test";
14 include_once( "classes/INIFile.php" );
15 include_once( "classes/ezhttptool.php" );
16 include_once( "classes/ezlocale.php" );
17 include_once( "ezcontact/classes/ezperson.php" );
18 include_once( "ezcontact/classes/ezcompany.php" );
19 include_once( "eztrade/classes/ezcheckout.php" );
20 //include_once( "eztrade/classes/ezorder.php" );
21 include_once( "eztrade/classes/ezproduct.php" );
22 include_once( "classes/ezcurrency.php" );
23
24 $ini =& eZINI::instance( 'site.ini' );
25 $wwwDir = $ini->WWWDir;
26 $indexFile = $ini->Index;
27
28 $UserName = $ini->variable( "eZTradeMain", "SetiUser" );
29 $Password = $ini->variable( "eZTradeMain", "SetiPassword" );
30 $Code = $ini->variable( "eZTradeMain", "Code" );
31 $Version = $ini->variable( "eZTradeMain", "Version" );
32 $AdminSite = $ini->variable( "site", "AdminSiteURL" );
33
34 //print_r($_SERVER); exit();
35 /*
36 // check for secure connection
37 if( ($_SERVER['SERVER_PORT'] != 443) || ($_SERVER['HTTPS'] != 'on') )
38 { //header( "Location: https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
39 echo "SETIError: Connetion not secure!";
40 exit();
41 }
42 */
43 //send version number
44 /*
45 if ($setifunction=="sendversion")
46 {
47 echo "SetiResponse: version=".$Version;
48 exit();
49 }
50
51 //check for proper username/password
52 if ($setiuser!=$UserName)
53 {
54 echo "SETIError: Incorrect username-> ".$setiuser;
55 exit();
56 }
57
58 if ($password!=$Password)
59 {
60 echo "SETIError: Incorrect password-> ".$password;
61 exit();
62 }
63
64 //check for correct cart code
65 if ($code!=$Code)
66 {
67 echo "SETIError: Incorrect code-> ".$code;
68 exit();
69 }
70
71 //check for $setifunction variable
72 if ( !isset($setifunction) )
73 {
74 echo "SETIError: No setifunction variable provided";
75 exit();
76 }
77
78
79 switch ( $setifunction )
80 {
81 case "ordercount":
82 {
83 // return number of order
84 $order=new eZOrder();
85 $allOrders=$order->getAll( 0, $order->getTotalCount, "Date" );
86 if ($lastorder)
87 $lastorder=0;
88 foreach ( $allOrders as $eachOrder ) {
89 if ( $eachOrder->id() > $lastorder )
90 $newOrders[]=$eachOrder;
91 }
92 echo "SetiResponse: ordercount=".count( $newOrders );
93 // echo "<br>".strtotime($lastdate);
94 break;
95 }
96
97 case "downloadorders":
98 {
99 // return orders
100 $order=new eZOrder();
101 $allOrders=$order->getAll( 0, $order->getTotalCount, "Date" );
102 if (!$lastorder)
103 $lastorder=0;
104 if (!$startnum)
105 $starnum=0;
106 if (!$batchsize)
107 $batchsize=count($allOrders);
108 $locale = new eZLocale( $Language );
109 //print header record
110 echo "SETI_OH_START"."\t"."SETIOrders"."\t"."SETI_OM_IMP_VER=2.0"."\t"."eZTrade"."\t".$Code."\t".
111 date("n/j/Y").
112 "\t".date("H:i:s").
113 "Approved\t".
114 "\t"."=".
115 "\t"."SETI_OH_END".
116 "\n";
117 $i=1;
118 foreach ( $allOrders as $eachOrder ) {
119 if ( ($eachOrder->id() > $lastorder) && ($i >= $startnum) && ($i <= $batchsize) )
120 {
121 // print order start field
122 echo "SETI_ORD_START"."\t".
123 $eachOrder->id()."\t";
124 // print date/time
125 $status = $eachOrder->initialStatus();
126 $dateTime = $status->altered();
127 $orderDate=$locale->format( $dateTime );
128 $orderDate=str_replace(".", "/", $orderDate);
129 $orderDate=str_replace(" ", "\t", $orderDate);
130 echo $orderDate."\t";
131
132 //print bill to names
133 $user = $eachOrder->user();
134
135 if ( $eachOrder->personID() == 0 && $eachOrder->companyID() == 0 ) {
136 $billtoFullName = $user->firstName()." ".$user->lastName();
137 $emailAddress = $user->email();
138 }
139 else
140 {
141 if ( $order->personID() > 0 )
142 {
143 $customer = new eZPerson( $eachOrder->personID() );
144 $billtoFullName=$customer->firstName()." ".$customer->lastName();
145 }
146 else
147 {
148 $customer = new eZCompany( $eachOrder->companyID() );
149 $billtoFullName=$customer->name();
150 }
151 $emailList = $customer->emailAddress();
152 $emailAddress = $emailList[0];
153 }
154
155 //print bill to first name (optional)
156 if ($user->firstName())
157 echo $user->firstName()."\t";
158 else echo "\t";
159 //print bill to last name (optional)
160 if ($user->lastName())
161 echo $user->lastName()."\t";
162 else echo "\t";
163 //print bill to full name
164 echo $billtoFullName."\t";
165 // print bill to company (?)
166 if ($eachOrder->companyID() > 0)
167 echo $customer->name()."\t";
168 else echo "\t";
169 // print email address
170 echo $emailAddress."\t";
171 // print bill to address1
172 $billingAddress =& $eachOrder->billingAddress();
173 echo $billingAddress->street1()."\t";
174 // print bill to address2
175 if ( $billingAddress->street2() )
176 echo $billingAddress->street2()."\t";
177 else echo "\t";
178 // print bill to city
179 echo $billingAddress->place()."\t";
180 // print bill to state
181 $region = $billingAddress->region();
182 if ( is_object($region))
183 echo $region->Abbreviation()."\t";
184 else
185 echo "\t";
186 // print bill to ZIP
187 echo $billingAddress->zip()."\t";
188 // print bill to country
189 $country = $billingAddress->country();
190 if ( is_object($country))
191 echo $country->ISO()."\t";
192 else
193 echo "\t";
194 // echo "no country\t";
195
196 //print bill to phone
197 // echo $eachOrder->phone;
198 echo "\t";
199 //print ship to full name
200 echo $billtoFullName."\t";
201 //print ship to company
202 if ($eachOrder->companyID() > 0)
203 echo $customer->name()."\t";
204 else echo "\t";
205 //print ship to address1
206 $shippingAddress =& $eachOrder->shippingAddress();
207 echo $shippingAddress->street1()."\t";
208 // print ship to address2
209 if ($shippingAddress->street2())
210 echo $shippingAddress->street2()."\t";
211 else echo "\t";
212 // print ship to city
213 echo $shippingAddress->place()."\t";
214 // print ship to state
215 $region = $shippingAddress->region();
216 if ( is_object($region))
217 echo $region->Abbreviation()."\t";
218 else
219 echo "\t";
220 // print ship to zip
221 echo $shippingAddress->zip()."\t";
222 // print ship to country
223 $country = $shippingAddress->country();
224 if ( is_object($country))
225 echo $country->ISO()."\t";
226 else
227 echo "\t";
228 // echo "no country\t";
229
230 // print ship to phone
231 // echo $eachOrder->phone;
232 echo "\t";
233 // print special instructions
234 echo "\t";
235 // print comments
236 if ($eachOrder->comment())
237 echo preg_replace('/\r\n?|\n/', ' ', $eachOrder->comment())."\t";
238 else echo "\t";
239 // print payment type
240 $checkout = new eZCheckout();
241 $instance =& $checkout->instance();
242 echo $instance->paymentName( $eachOrder->paymentMethod() )."\t";
243 // print credit card acct number
244 echo "\t";
245 // print credit card expiration date
246 echo "\t";
247 // print credit card bank name (optional)
248 echo "\t";
249 // print credit card auth code
250 echo "\t";
251 // print credit card AVS code
252 echo "\t";
253 // print credit card transaction ID
254 echo "\t";
255 // print CVV2 code
256 echo "\t";
257 // print product total
258 $currency = new eZCurrency();
259 $eachOrder->orderTotals( $tax, $total );
260 $currency->setValue( $total["subextax"] );
261 echo str_replace( "�&nbsp;", "", $locale->format( $currency ) )."\t";
262 // print small order fee
263 echo "\t";
264 // print shipping charges
265 $currency->setValue( $total["shipextax"] );
266 echo str_replace( "�&nbsp;", "", $locale->format( $currency ) )."\t";
267 // print shipping insurance
268 echo "\t";
269 // print sales tax
270 $currency->setValue( $total["inctax"]-$total["shipextax"]-$total["subextax"] );
271 echo str_replace( "�&nbsp;", "", $locale->format( $currency ) )."\t";
272 // print discount message
273 echo "\t";
274 // print discount percentage
275 echo "\t";
276 // print COD charge
277 echo "\t";
278 // print coupon code
279 echo "\t";
280 // print coupon discount amount
281 echo "\t";
282 // print surcharge reason
283 echo "\t";
284 // print surchage amount
285 echo "\t";
286 // print grand total
287 $currency->setValue( $total["inctax"] );
288 echo str_replace( "�&nbsp;", "", $locale->format( $currency ) )."\t";
289 // print shipping method
290 $shippingType = $eachOrder->shippingType();
291 echo $shippingType->name()."\t";
292 // print total weight
293 echo "\t";
294 // print affilliate name
295 echo "\t";
296 // print gift message
297 echo "\t";
298 // print name or ID of checkout form (Americart only?)
299 echo "\t";
300 // print number of line items
301 $items = $eachOrder->items( $OrderType );
302 echo count($items)."\t";
303 //print payment string
304 echo "\t";
305 //print current order status
306 $status = $eachOrder->lastStatus();
307 $statusType = $status->type();
308 echo preg_replace( "#intl-#", "", $statusType->name() )."\t";
309 // print optional field 57 (for future expansion)
310 echo "\t";
311 // print optional field 58 (for future expansion)
312 echo "\t";
313 // print optional field 59 (for future expansion)
314 echo "\t";
315 // print optional field 60 (for future expansion)
316 echo "\t";
317 // print optional field 61 (for future expansion)
318 echo "\t";
319 // print optional field 62 (for future expansion)
320 echo "\t";
321 // print optional field 63 (for future expansion)
322 echo "\t";
323 // print optional field 64 (for future expansion)
324 echo "\t";
325 // print optional field 65 (for future expansion)
326 echo "\t";
327 // print optional field 66 (for future expansion)
328 echo "\t";
329
330 // print line items
331 foreach ($items as $item)
332 {
333 // print out each line item
334 $product =& $item->product();
335 // print line item header
336 echo "BEGIN_ITEM"."\t";
337 // print item SKU
338 echo $product->productNumber()."\t";
339 //print item name
340 echo html_entity_decode($product->name())."\t";
341 // print unit price
342 echo str_replace( "$&nbsp;", "", $item->localePrice( true, true, false ) )."\t";
343 // print quantity ordered
344 echo $item->count()."\t";
345 // print options
346 $numberOfOptions = 0;
347 $optionValues =& $item->optionValues();
348 foreach ( $optionValues as $optionValue )
349 echo $optionValue->optionName()."=".$optionValue->valueName()."\t";
350 // print end of line item
351 echo "END_ITEM\t";
352 }
353 echo "SETI_ORD_END\n";
354 $i++;
355 }
356 }
357
358 break;
359 }
360
361 case "downloadcustomers":
362 {
363 // return customers
364 $customers =& eZOrder::customers();
365 echo "SETICustomers\n";
366 foreach ($customers as $customer)
367 {
368 echo $customer->id()."\t";
369 echo $customer->login()."\t";
370 echo $customer->firstName()."\t";
371 echo $customer->lastName()."\t";
372 echo $customer->email()."\t";
373 //company name
374 echo "\t";
375 //phone number
376 echo "\t";
377 $mainAddress = eZAddress::mainAddress( $customer );
378 echo $mainAddress->street1()."\t";
379 echo $mainAddress->street2()."\t";
380 echo $mainAddress->place()."\t";
381
382 $region = $mainAddress->region();
383 if ($region)
384 echo $region->Abbreviation()."\t";
385 else
386 echo "\t";
387
388 echo $mainAddress->zip()."\t";
389
390 $country = $mainAddress->country();
391 if ($country)
392 echo $country->ISO()."\n";
393 else
394 echo "\n";
395 }
396 echo "SETIEndOfData\n";
397 break;
398 }
399
400 case "downloadprods":
401 {
402 // return product data
403 $product = new eZProduct();
404 $productList = $product->activeProducts( "time", 0, "" );
405 echo "SETIProducts"."\n";
406 foreach ($productList as $product)
407 {
408 echo $product->id()."\t";
409 echo $product->productNumber()."\t";
410 $prodName=html_entity_decode( $product->name() );
411 echo $prodName."\t";
412 echo $product->price()."\t";
413 // Cost (not currently supported)
414 echo "\t";
415 $prodDesc=html_entity_decode( $product->brief() );
416 echo $prodDesc."\t";
417 echo $product->weight()."\t";
418 // taxable (0=false, 1=true)
419 echo "1\t";
420 if ($product->discontinued() == true )
421 echo "1\t";
422 else
423 echo "0\t";
424 if ($product->totalQuantity())
425 echo $product->totalQuantity()."\n";
426 else
427 echo "0\n";
428 }
429 echo "SETIEndOfData\n";
430 break;
431 }
432
433 case "downloadqoh":
434 {
435 // return current product quantities
436 $product = new eZProduct();
437 $productList = $product->activeProducts( "time", 0, "" );
438 echo "SETIProducts"."\n";
439 foreach ($productList as $product)
440 {
441 echo $product->id()."\t";
442 echo $product->productNumber()."\t";
443 if ($product->totalQuantity())
444 echo $product->totalQuantity()."\n";
445 else
446 echo "0\n";
447 }
448 echo "SETIEndOfData\n";
449 break;
450 }
451
452 case "qohreplace":
453 {
454 // upload bulk inventory data
455 $skuArray = explode("|", $update);
456 echo "SETIResponse\n";
457 foreach ($skuArray as $item)
458 {
459 $product=new eZProduct();
460 $itemArray=explode("~", $item);
461 $item=$product->findProductNumber($itemArray[0]);
462 if ($item)
463 {
464 $item->setTotalQuantity($itemArray[1]);
465 $item->store();
466 echo $itemArray[0]."=OK\n";
467 }
468 else echo $itemArray[0]."=NF\n";
469 }
470 echo "SETIEndOfData\n";
471 break;
472 }
473
474 case "invupdate":
475 {
476 // upload individual inventory data
477 if ($update)
478 $skuArray = explode("~", $update);
479 else echo "SETIRESPONSE=False;SKU=".$skuArray[0].";QOH=NA;NOTE=SKU data missing or incorrectly formatted.";
480 $product=new eZProduct();
481 $item=$product->findProductNumber($skuArray[0]);
482 if ($item)
483 {
484 $item->setTotalQuantity($skuArray[1]);
485 $item->store();
486 echo "SETIRESPONSE=OK;"."SKU=".$skuArray[0].";QOH=".$skuArray[1].";Note=".$item->name();
487 }
488 else echo "SETIRESPONSE=False;SKU=".$skuArray[0].";QOH=NA;NOTE=SKU missing or formatted differently.";
489 break;
490 }
491 }
492
493 exit();
494 */
495 ?>
$UserName
$UserName
Definition: admin/seti.php:20
$Code
$Code
Definition: admin/seti.php:22
$Password
$Password
Definition: admin/seti.php:21
$AdminSite
$AdminSite
Definition: admin/seti.php:23
$ini
$ini
Definition: classes/admin/linklist.php:64
$indexFile
$indexFile
Definition: singlelist.php:34
$wwwDir
$wwwDir
Definition: singlelist.php:33
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.