Merge branch 'master' of vc.linet-services.de:public/lx-office-erp
[kivitendo-erp.git] / oscom / oscomexport.php
1 <?
2 /***************************************************************
3 *Author: Holger Lindemann
4 *Copyright: (c) 2004 Lx-System
5 *License: non free
6 *eMail: info@lx-system.de
7 *Version: 1.6
8 *Shop: osCommerce 2.2 ms2
9 *ERP: Lx-Office ERP 2.4.x
10 ***************************************************************/
11 /*
12 * Noch einzubauen:
13 */
14 ?>
15 <html>
16         <head><title>Lx-ERP Export der Shopartikel</title>
17         <!--link type="text/css" REL="stylesheet" HREF="../css/main.css"></link-->
18 <body>
19
20 <?php
21 require_once "shoplib.php";
22
23 function sonderkosten($transID,$data,$id,$f) {
24 global $versand,$nachn,$minder,$treuh,$paypal;
25         $sql="insert into orderitems (trans_id, parts_id, description, qty, sellprice, unit, ship, discount) values (";
26         $sql.=$transID.",".${$id}["ID"].",'".${$id}["TXT"]."',1,".$data.",'Stck',0,0)";
27         fputs($f,"$transID,".${$id}["ID"].",'".${$id}["TXT"]."',1,$data\n");
28         if (!query("erp",$sql,"sonderkosten")) { return false; }
29         else { return true; };
30 }
31
32 function getBestellKunde($KID,$BID,$OID) {
33 global $neuKd,$gesKd;
34         $sql="select kdnr from customers_number where customers_id=$KID";
35         $rs=getAll("shop",$sql,"getBestellKunde");
36         if (!$rs or $rs[0]["kdnr"]<1) {
37                 $kdnr=insKdData($BID);
38                 if ($kdnr>0) {
39                         $sql="insert into customers_number (customers_id,kdnr) values(".$KID.",".$kdnr.")";
40                         $rc=query("shop",$sql,"getBestellKunde");
41                         if ($rc === -99) {
42                                 echo "Kundennummer nicht im Shop gespeichert: $KID<br>";
43                         }
44                 } else {
45                         $neuKd++;
46                 }
47         } else {
48                 $kdnr=$rs[0]["kdnr"];
49         }
50         chkKdData($kdnr,$BID,$OID);
51         $gesKd++;
52         return $kdnr;
53 }
54 /**********************************************
55 * getAttribut($oid,$pid)
56 *
57 **********************************************/
58 function getAttribut($oid,$pid) {
59         $sql="select * from orders_products_attributes where orders_id=$oid and orders_products_id=$pid";
60         $rs=getAll("shop",$sql,"getAttribut");
61         $txt="";
62         foreach ($rs as $zeile) {
63                 $txt.="\n - ".$zeile["products_options"].":".$zeile["products_options_values"];
64         };
65         return $txt;
66 }
67 function getTaxRate() {
68         $sql="select tax_rate from tax_rates R left join configuration C on C.configuration_value=R.tax_class_id ";
69         $sql.="where C.configuration_key like 'MODULE_SHIPPING%TAX%' limit 1";
70         $rs=getAll("shop",$sql,"getTaxRate");
71         if ($rs[0]["tax_rate"]) {
72                 return (100+$rs[0]["tax_rate"])/100 ;
73         } else {
74                 echo "Bitte mind. eine Versandart mit Steuer anlegen.";
75                 return 1;
76         }
77 }
78 function checkTaxIncl() {
79         $sql="select * from configuration where  configuration_key = 'DISPLAY_PRICE_WITH_TAX'";
80         $rs=getAll("shop",$sql,"checkTaxIncl");
81         if ($rs[0]["configuration_value"]=="false") { return false; }
82         else { return true; }
83 }
84 function getNetto($id) {
85         $sql="select * from orders_total where orders_id=$id and class='ot_subtotal'";
86         $rs=getAll("shop",$sql,"getNetto");
87         return $rs[0]["value"];
88 }
89 /**********************************************
90 * getBrutto($id)
91 *
92 **********************************************/
93 function getBrutto($id) {
94         $sql="select * from orders_total where orders_id=$id and class='ot_total'";
95         $rs=getAll("shop",$sql,"getBrutto");
96         return $rs[0]["value"];
97 }
98
99 /**********************************************
100 * getMwst($id)
101 *
102 **********************************************/
103 function getMwSt($id) {
104 global $TaxFactor;
105         $mwst=0;
106         $sql="select * from orders_total where orders_id=$id and class='ot_tax'";
107         $rs=getAll("shop",$sql,"getMwSt");
108         if ($rs) {
109                 foreach ($rs as $zeile) {
110                         $mwst+=$zeile["value"];
111                 }
112         }
113         return $mwst;
114         //return $rs[0]["value"]/$TaxFactor;
115 }
116 /**********************************************
117 * getSonderkosten($id,$art)
118 *
119 **********************************************/
120 function getSonderkosten($id,$art) {
121         $sql="select * from orders_total where orders_id=$id and class='".$GLOBALS["skosten"][$art]."'";
122         $rs=getAll("shop",$sql,"getSonderkosten");
123         if ($rs[0]["value"]) {
124                 $kosten=round($rs[0]["value"]/(100+$GLOBALS["versand"]["TAX"])*100,2);
125         } else {
126                 $kosten=false;
127         }
128         return $kosten;
129 }
130 /**********************************************
131 * insBestArtikel($zeile,$transID)
132 *
133 **********************************************/
134 function insBestArtikel($ordersID,$transID) {
135 global $div07,$div16;
136         $sql="select * from orders_products where orders_id=$ordersID";
137         $rs=getAll("shop",$sql,"insBestArtikel");
138         $ok=true;
139         if ($rs) foreach ($rs as $zeile) {
140                 $sql="select * from parts where partnumber='".$zeile["products_model"]."'";
141                 $rs2=getAll("erp",$sql,"insBestArtikel");
142                 if ( $rs2[0]["id"]) {
143                                 $artID=$rs2[0]["id"];
144                                 $artNr=$rs2[0]["partnumber"];
145                 } else {
146                         if ($zeile["products_tax"]=="19.0000") {
147                                 $artID=$div16["ID"];
148                                 $artNr=$div16["NR"];
149                         } else {
150                                 $artID=$div07["ID"];
151                                 $artNr=$div07["NR"];
152                         };
153                 }
154                 $preis=$zeile["final_price"];
155                 $text=getAttribut($ordersID,$zeile["orders_products_id"]);
156                 $sql="insert into orderitems (trans_id, parts_id, description, qty, sellprice, unit, ship, discount) ";
157                 $sql.="values (";
158                 $sql.=$transID.",".$artID.",'".$zeile["products_name"].$text."',".$zeile["products_quantity"].",";
159                 $sql.=$preis.",'Stck',0,0)";
160                 echo " - Artikel:[ BuNr.:$artID ArtNr:<b>$artNr</b> ".$zeile["products_name"]." ]<br>";
161                 $rc=query("erp",$sql,"insBestArtikel");
162                 if ($rc === -99) { $ok=false; break; };
163         }
164         return $ok;
165 }
166 function insAuftrag($data) {
167 global $ERPusr,$versand,$nachn,$minder,$paypal,$auftrnr;
168         $Zahlmethode=array("authorizenet"=>"Authorize.net","banktransfer"=>"Lastschriftverfahren","cc"=>"Kreditkarte",
169                 "cod"=>"Nachnahme","eustandardtransfer"=>"EU-Standard Bank Transfer","iclear"=>"iclear Rechnungskauf",
170                 "invoice"=>"Rechnung","ipayment"=>"iPayment","liberecobanktransfer"=>"Lastschriftverfahren",
171                 "liberecocc"=>"Kreditkarte","moneybookers"=>"Moneybookers.com","moneyorder"=>"Scheck/Vorkasse",
172                 "nochex"=>"NOCHEX","paypal"=>"PayPal","pm2checkout"=>"2CheckOut","psigate"=>"PSiGate",
173                 "qenta"=>"qenta.at","secpay"=>"SECPay");
174         $brutto=getBrutto($data["orders_id"]);
175         $mwst=getMwSt($data["orders_id"]);
176         if ($GLOBALS["inclTax"]) {
177                 $netto=$brutto-$mwst;
178         } else {
179                 $netto=getNetto($data["orders_id"]);
180         }
181         $versandK=getSonderkosten($data["orders_id"],"Versand");
182         $nachnK  =getSonderkosten($data["orders_id"],"NachName");
183         $mindermK=getSonderkosten($data["orders_id"],"Minder");
184         $paypalK =getSonderkosten($data["orders_id"],"Paypal");
185         $netto+=$versandK;
186         $netto+=$nachnK;
187         $netto+=$mindermK;
188         $netto+=$paypalK;
189         // Hier beginnt die Transaktion
190         $rc=query("erp","BEGIN WORK","insAuftrag");
191         if ($rc === -99) { echo "Probleme mit Transaktion. Abbruch!"; exit(); };
192         if ($auftrnr) {
193                 $auftrag=$GLOBALS["preA"].getNextAnr();
194         } else {
195                 $auftrag=$GLOBALS["preA"].$data["orders_id"];
196         }
197         $sql="select count(*) as cnt from oe where ordnumber = '$auftrag'";
198         $rs=getAll("erp",$sql,"insAuftrag 1");
199         if ($rs[0]["cnt"]>0) {
200                 $auftrag=$GLOBALS["preA"].getNextAnr();
201         }
202         $newID=uniqid (rand());
203         $sql="insert into oe (notes,ordnumber,cusordnumber) values ('$newID','$auftrag','".$data["kdnr"]."')";
204         $rc=query("erp",$sql,"insAuftrag 2");
205         if ($rc === -99) {
206                 echo "Auftrag ".$data["orders_id"]." konnte nicht angelegt werden.<br>";
207                 $rc=query("erp","ROLLBACK WORK","chkKunde");
208                 if ($rc === -99) { echo "Probleme mit Transaktion. Abbruch!"; exit(); };
209                 return false;
210         }
211         $sql="select * from oe where notes = '$newID'";
212         $rs2=getAll("erp",$sql,"insAuftrag 3");
213         if (!$rs2>0) {
214                 echo "Auftrag ".$data["orders_id"]." konnte nicht angelegt werden.<br>";
215                 $rc=query("erp","ROLLBACK WORK","chkKunde");
216                 if ($rc === -99) { echo "Probleme mit Transaktion. Abbruch!"; exit(); };
217                 return false;
218         }
219         $zahlart=$data["payment_method"]."\n";
220         if ($data["cc_type"]) $zahlart.=$data["cc_type"]."\n".$data["cc_owner"]."\n".$data["cc_number"]."\n".$data["cc_expires"]."\n";
221         $sql="update oe set cusordnumber=".$data["orders_id"].", transdate='".$data["date_purchased"]."', customer_id=".$data["kdnr"].", ";
222         $sql.="amount=".$brutto.", netamount=".$netto.", reqdate='".$data["date_purchased"]."', taxincluded='f', ";
223         if ($data["shipto"]>0) $sql.="shipto_id=".$data["shipto"].", ";
224         $sql.="intnotes='".$data["comments"]."',notes='".$zahlart."', curr='EUR',employee_id=".$ERPusr["ID"].", vendor_id=0 ";
225         $sql.="where id=".$rs2[0]["id"];
226         $rc=query("erp",$sql,"insAuftrag 4");
227         if ($rc === -99) {
228                 echo "Auftrag ".$data["orders_id"]." konnte nicht angelegt werden.<br>";
229                 $rc=query("erp","ROLLBACK WORK","chkKunde");
230                 if ($rc === -99) { echo "Probleme mit Transaktion. Abbruch!"; exit(); };
231                 return false;
232         }
233         echo "Auftrag:[ Buchungsnummer:".$rs2[0]["id"]." AuftrNr:<b>".$auftrag."</b> ]<br>";
234         if (!insBestArtikel($data["orders_id"],$rs2[0]["id"])) {
235                 echo "Auftrag ".$data["orders_id"]." konnte nicht angelegt werden.<br>";
236                 $rc=query("erp","ROLLBACK WORK","chkKunde");
237                 if ($rc === -99) { echo "Probleme mit Transaktion. Abbruch!"; exit(); };
238                 return false;
239         };
240         if ($versandK) {
241                 $sql="insert into orderitems (trans_id, parts_id, description, qty, sellprice, unit, ship, discount) values (";
242                 $sql.=$rs2[0]["id"].",".$versand["ID"].",'".$versand["TXT"]."',1,".$versandK.",'Stck',0,0)";
243                 $rc=query("erp",$sql,"insAuftrag 8");
244                 if ($rc === -99) echo "Auftrag $auftrag : Fehler bei den Versandkosten<br>";
245         }
246         if ($nachnK) {
247                 $sql="insert into orderitems (trans_id, parts_id, description, qty, sellprice, unit, ship, discount) values (";
248                 $sql.=$rs2[0]["id"].",".$nachn["ID"].",'".$nachn["TXT"]."',1,".$nachnK.",'Stck',0,0)";
249                 $rc=query("erp",$sql,"insAuftrag 9");
250                 if ($rc === -99) echo "Auftrag $auftrag : Fehler bei den Nachnamekosten<br>";
251         }
252         if ($mindermK) {
253                 $sql="insert into orderitems (trans_id, parts_id, description, qty, sellprice, unit, ship, discount) values (";
254                 $sql.=$rs2[0]["id"].",".$minder["ID"].",'".$minder["TXT"]."',1,".$mindermK.",'Stck',0,0)";
255                 $rc=query("erp",$sql,"insAuftrag 10");
256                 if ($rc === -99) echo "Auftrag $auftrag : Fehler beim Mindermengenzuschlag<br>";
257         }
258         if ($paypalK) {
259                 $sql="insert into orderitems (trans_id, parts_id, description, qty, sellprice, unit, ship, discount) values (";
260                 $sql.=$rs2[0]["id"].",".$paypal["ID"].",'".$paypal["TXT"]."',1,".$paypalK.",'Stck',0,0)";
261                 $rc=query("erp",$sql,"insAuftrag 11");
262                 if ($rc === -99) echo "Auftrag $auftrag : Fehler bei den PayPal-Kosten<br>";
263         }
264         $sql="update orders set orders_status ='3' WHERE orders_id =".$data["orders_id"];
265         $rc=query("shop",$sql,"insBestArtikel 12");
266         if ($rc === -99) echo "Bestellung im Shop nicht geschlossen";
267         $rc=query("erp","COMMIT WORK","chkKunde");
268         if ($rc === -99) { echo "Probleme mit Transaktion. Abbruch!"; exit(); };
269         return true;
270 }
271
272 /**********************************************
273 * getBestellung()
274 *
275 **********************************************/
276 function getBestellung() {
277         $sql="select o.*,h.comments,cn.kdnr from orders o left join orders_status_history h on h.orders_id=o.orders_id ";
278         $sql.="left join customers_number cn on ";
279         $sql.="cn.customers_id=o.customers_id where o.orders_status=1 order by o.orders_id";
280         $rs=getAll("shop",$sql,"getBestellung");
281         return $rs;
282 }
283
284 /**********************************************
285 * chkKdData()
286 *
287 **********************************************/
288 function chkKunden() {
289         $felder=array("firstname","lastname","company","street_address","city","postcode","country");
290         foreach ($GLOBALS["bestellungen"] as $bestellung) {
291                 $rc=query("erp","BEGIN WORK","chkKunden");
292                 if ($rc === -99) { echo "Probleme mit Transaktion. Abbruch!"; exit(); };
293                 if ($bestellung["kdnr"]>0) { // Bestandskunde; kdnr == ID in customers
294                         $msg="update ";
295                         $kdnr=chkOldKd($bestellung);
296                         if ($kdnr == -1) { //Kunde nicht gefunden, neu anlegen.
297                                 $msg="insert ";
298                                 $kdnr=insNewKd($bestellung);
299                                 $GLOBALS["neuKd"]++;
300                         } else if (!$kdnr) {
301                                 echo $msg." ".$bestellung["customers_name"]." fehlgeschlagen!<br>";
302                                 $GLOBALS["gesKd"]++;
303                                 continue;
304                         }
305                 } else { // Neukunde
306                         $msg="insert ";
307                         $kdnr=insNewKd($bestellung);
308                         $GLOBALS["neuKd"]++;
309                 }
310                 echo $bestellung["customers_company"]." ".$bestellung["customers_name"]." $kdnr<br>";
311                 $GLOBALS["bestellungen"][$GLOBALS["gesKd"]]["kdnr"]=$kdnr;
312                 $sql="delete from customers_number where customers_id=".$bestellung["customers_id"];
313                 $rc=query("shop",$sql,"chkKunde");
314                 $sql="insert into customers_number (customers_id,kdnr) values(".$bestellung["customers_id"].",".$kdnr.")";
315                 $rc=query("shop",$sql,"chkKunde");
316                 if ($kdnr>0) {
317                         foreach($felder as $feld) {
318                                 if ($bestellung["delivery_$feld"]<>$bestellung["customers_$feld"]) {
319                                         $rc=insShData($bestellung,$kdnr);
320                                         if ($rc>0) $GLOBALS["bestellungen"][$GLOBALS["gesKd"]]["shipto"]=$rc;
321                                         break;
322                                 }
323                         }
324                 }
325                 if (!$kdnr || $rc === -99) {
326                         echo $msg." ".$bestellung["customers_name"]." fehlgeschlagen! ($kdnr,$rc)<br>";
327                         $rc=query("erp","ROLLBACK WORK","chkKunde");
328                         if ($rc === -99) { echo "Probleme mit Transaktion. Abbruch!"; exit(); };
329                 } else {
330                         $rc=query("erp","COMMIT WORK","chkKunde");
331                         if ($rc === -99) { echo "Probleme mit Transaktion. Abbruch!"; exit(); };
332                 }
333                 $GLOBALS["gesKd"]++;
334         }
335         return true;
336 }
337
338 function chkOldKd($data) {
339         $sql="select * from customer where id = ".$data["kdnr"];
340         $rs=getAll("erp",$sql,"chkKdData");
341         if (!$rs or count($rs)==0) { return -1; }; // Kunde nicht gefunden
342         if ($rs[0]["zipcode"]<>$data["customers_postcode"]) $set.="zipcode='".$data["customers_postcode"]."',";
343         if ($rs[0]["city"]<>$data["customers_city"]) $set.="city='".$data["customers_city"]."',";
344         if ($rs[0]["country"]<>$GLOBALS["taxarray"][$data["billing_country"]]["code"]) $set.="country='".$GLOBALS["taxarray"][$data["billing_country"]]["code"]."',";
345         if ($rs[0]["phone"]<>$data["customers_phone"])$set.="phone='".$data["customers_phone"]."',";
346         if ($rs[0]["email"]<>$data["customers_email_address"])$set.="email='".$data["customers_email_address"]."',";
347         if ($data["customers_company"]) {
348                 if ($rs[0]["name"]<>$data["customers_company"]) $set.="name='".$data["customers_company"]."',";
349                 if ($rs[0]["contact"]<>$data["customers_name"]) $set.="contact='".$data["customers_name"]."',";
350         } else {
351                 if ($rs[0]["name"]<>$data["customers_name"]) $set.="name='".$data["customers_name"]."',";
352         }
353         if ($rs[0]["street"]<>$data["customers_street_address"]) $set.="street='".$data["customers_street_address"]."',";
354         if ($set) {
355                         $set=substr($set,0,-1);
356                 $sql="update customer set $set where id=".$data["kdnr"];
357                 $rc=query("erp",$sql,"chkKdData");
358                 if ($rc === -99) {
359                         return false;
360                 } else {
361                         return $data["kdnr"];
362                 }
363         } else {
364                 return $data["kdnr"];
365         }
366 }
367
368 /**********************************************
369 * insShData($data,$id)
370 *
371 **********************************************/
372 function insShData($data,$id) {
373         $set=$id;
374         if ($data["delivery_company"]) { $set.=",'".$data["delivery_company"]."','".$data["delivery_name"]."',"; }
375         else { $set.=",'".$data["delivery_name"]."','',"; }
376         $set.="'".$data["delivery_street_address"]."',";
377         $set.="'".$data["delivery_postcode"]."',";
378         $set.="'".$data["delivery_city"]."',";
379         if (in_array($data["delivery_country"],$GLOBALS["LAND"])) {
380                 $set.="'".$GLOBALS["LAND"][$data["delivery_country"]]."',";
381         } else {
382                 $set.="'".$data["delivery_country"]."',";
383         }
384         $set.="'".$data["customers_telephone"]."',";
385         $set.="'".$data["customers_email_address"]."'";
386         $sql="insert into shipto (trans_id,shiptoname,shiptodepartment_1,shiptostreet,shiptozipcode,shiptocity,";
387         $sql.="shiptocountry,shiptophone,shiptoemail,module) values ($set,'CT')";
388         $rc=query("erp",$sql,"insShData");
389         if ($rc === -99) return false;
390         $sql="select shipto_id from shipto where trans_id = $id and module='CT' order by itime desc limit 1";
391         $rs=getAll("erp",$sql,"insKdData");
392         if ($rs[0]["shipto_id"]>0) {
393                 $sid=$rs[0]["shipto_id"];
394                 $sql="update customers_number set shipto = $sid where kdnr = $id";
395                 $rc2=query("shop",$sql,"insShData");
396                 if ($rc2 === -99) {
397                         //$sql="delete from shipto where shipto_id=$sid";
398                         //$rc=query("shop",$sql,"insShData");
399                         return false;
400                 }
401                 return $sid;
402         } else  {
403                 echo "Fehler bei abweichender Anschrift ".$data["delivery_name"];
404                 //$sql="delete from shipto where shipto_id=$sid";
405                 //$rc=query("shop",$sql,"insShData");
406                 return false;
407         }
408 }
409
410 /**********************************************
411 * insKdData($BID)
412 *
413 **********************************************/
414 function insNewKd($data) {
415         $newID=uniqid(rand(time(),1));
416         //Kundennummer generieren
417         if ($GLOBALS["kdnum"]==1) { // von der ERP
418                 $kdnr=$GLOBALS["preK"].getNextKnr();
419         } else {                    // durch Shop
420                 $kdnr=$GLOBALS["preK"].$data["customers_id"];
421         }
422         $sql="select count(*) as cnt from customer where customernumber = '$kdnr'";
423         $rs=getAll("erp",$sql,"insKdData");
424         if ($rs[0]["cnt"]>0) {  // Kundennummer gibt es schon, eine neue aus ERP
425                 $kdnr=$GLOBALS["preK"].getNextKnr();
426         }
427         $sql="insert into customer (name,customernumber) values ('$newID','$kdnr')";
428         $rc=query("erp",$sql,"insKdData");
429         if ($rc === -99) return false;
430         $sql="select * from customer where name = '$newID'";
431         $rs=getAll("erp",$sql,"insKdData");
432         if (!$rs) return false;
433         if ($data["customers_company"]) {
434                 $set.="set name='".$data["customers_company"]."',contact='".$data["customers_name"]."',";
435         }else {
436                 $tmp=strrpos($data["customers_name"]," ");
437                 if ($tmp>0) {
438                         $set.="set name='".substr($data["customers_name"],$tmp+1).", ".substr($data["customers_name"],0,$tmp)."',";
439                         $set.="contact='".$data["customers_name"]."',";
440                 } else {
441                         $set.="set name='".$data["customers_name"]."',";
442                 }
443         }
444         $set.="street='".$data["customers_street_address"]."',";
445         $set.="zipcode='".$data["customers_postcode"]."',";
446         $set.="city='".$data["customers_city"]."',";
447         $set.="country='".$GLOBALS["taxarray"][$data["billing_country"]]["code"]."',";
448         $set.="phone='".$data["customers_telephone"]."',";
449         $set.="email='".$data["customers_email_address"]."',";
450         $tid=(in_array($data["billing_country"],array_keys($GLOBALS["taxarray"])))?$GLOBALS["taxarray"][$data["billing_country"]]["tax"]:3;
451         $set.="taxzone_id=$tid,";
452         $set.="taxincluded='f' ";
453         $sql="update customer ".$set;
454         $sql.="where id=".$rs[0]["id"];
455         $rc=query("erp",$sql,"insKdData");
456         if ($rc === -99) {
457                 //$sql="delete from customer where id=".$rs[0]["id"];
458                 //$rc=query("shop",$sql,"insNewKd");
459                 return false;
460         } else { return $rs[0]["id"]; }
461 }
462
463
464 $LAND=array("Germany"=>"D","Austria"=>"A","Switzerland"=>"CH");
465 $skosten=array("Versand"=>"ot_shipping","NachName"=>"ot_cod_fee","Paypal"=>"ot_cod_fee","Minder"=>"ot_loworderfee");
466 $inclTax=checkTaxIncl();
467 $TaxFactor=($inclTax)?getTaxRate():1;
468 $bestellungen=getBestellung();
469 $ok=count($bestellungen);
470 $gesKd=0;
471 $neuKd=0;
472 if ($ok) {
473         echo "Es liegen $ok Bestellungen vor. <br>";
474         chkKunden();
475         echo $gesKd." Kunde(n), davon ".$neuKd." neue(r) Kunde(n).<br>";
476         foreach ($bestellungen as $bestellung) {
477                 insAuftrag($bestellung);
478         }
479 } else { echo "Es liegen keine Bestellungen vor!<br>"; };
480 ?>
481 <!--a href='trans.php'>zur&uuml;ck</a-->
482 </body>
483 </html>