5 $api = php_sapi_name();
7 echo "<html>\n<head>\n<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>\n</head>\n<body>\n";
8 @apache_setenv('no-gzip', 1);
9 @ini_set('zlib.output_compression', 0);
10 @ini_set('implicit_flush', 1);
11 $shopnr = $_GET["Shop"];
12 $nofiles = ( $_GET["nofiles"] == '1' )?true:false;
15 $tmp = explode("=",trim($argv[1]));
16 if ( count($tmp) != 2 ) {
17 echo "Falscher Aufruf: php <scriptname.php> shop=1\n";
25 include_once("conf$shopnr.php");
26 include_once("error.php");
28 $err = new error($api);
29 include_once("dblib.php");
30 include_once("xtc.php");
31 include_once("erplib.php");
33 $err->out("Shop $shopnr, Bestellimport",true);
36 $erpdb = new mydb($ERPhost,$ERPdbname,$ERPuser,$ERPpass,$ERPport,'pgsql',$err,$debug);
37 if ($erpdb->db->connected_database_name == $ERPdbname) {
38 $erp = new erp($erpdb,$err,$divStd,$divVerm,$auftrnr,$kdnum,$preA,$preK,$invbrne,$mwstLX,$OEinsPart,$lager,$pricegroup,$ERPusrID);
40 $err->out('Keine Verbindung zur ERP',true);
45 $shopdb = new mydb($SHOPhost,$SHOPdbname,$SHOPuser,$SHOPpass,$SHOPport,'mysql',$err,$debug);
46 if ($shopdb->db->connected_database_name == $SHOPdbname) {
47 $shop = new xtc($shopdb,$err,$SHOPdbname,$divStd,$divVerm,$minder,$nachn,$versandS,$versandV,$paypal,$mwstLX,$mwstS,$variantnr,$unit);
49 $err->out('Keine Verbindung zum Shop',true);
53 $bestellungen = $shop->getBestellung($ERPusrID);
57 $err->out("Bestellimport vom Shop $shopnr",true);
59 if ($bestellungen) foreach ($bestellungen as $row) {
60 $rc = $erp->mkAuftrag($row,$shopnr,$longtxt);
63 $rc = $shop->setKundenNr($row['customer']['shopid'],$rc);
65 $shop->setAbgeholt($row['cusordnumber']);
70 $err->out("Fehler setKdNr ".$row['customer']['shopid'],true);
72 } else if ($rc == -1) {
74 $err->out("Fehler mkAuftrag ".$row['cusordnumber'],true);
76 $err->out("Fehler Kunde zuordnen ".$row['customer']['shopid'].":".$row['cusordnumber'],true);
80 $err->out('Von '.count($bestellungen)." Bestellungen $cnt übertragen, $errors nicht",true);
81 if ( $api != "cli" ) {
82 echo "<br /><a href='../oe.pl?vc=customer&type=sales_order&nextsub=orders&action=Weiter&open=1¬delivered=1&delivered=1&l_ordnumber=Y&l_transdate=Y&l_reqdate=1&l_name=Y&l_employee=Y&l_amount=Y'>Auftragsliste</a>";
83 echo "</body>\n</html>\n";