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;
14 $p = array('shopnr','nofiles');
16 for( $i=1; $i<count($argv); $i++) {
17 $tmp = explode("=",trim($argv[$i]));
18 if ( count($tmp) < 2 ) {
19 echo "Falscher Aufruf: php ArtikelErpToShop.php shopnr=1 [nofiles=1]\n";
22 if ( ! in_array(strtolower($tmp[0]),$p) ) {
23 echo "Falscher Aufruf: php ArtikelErpToShop.php shopnr=1 [nofiles=1]\n";
26 ${$tmp[0]} = trim($tmp[1]);
34 include_once("conf$shopnr.php");
35 include_once("error.php");
37 $err = new error($api);
39 include_once("dblib.php");
40 include_once("pepper.php");
41 include_once("erplib.php");
43 $err->out("Shop $shopnr, Bestellimport",true);
46 $erpdb = new mydb($ERPhost,$ERPdbname,$ERPuser,$ERPpass,$ERPport,'pgsql',$err,$debug);
47 if ($erpdb->db->connected_database_name == $ERPdbname) {
48 $erp = new erp($erpdb,$err,$divStd,$divVerm,$auftrnr,$kdnum,$preA,$preK,$invbrne,$mwstS,$OEinsPart,$lager,$pricegroup,$ERPusrID);
50 $err->out('Keine Verbindung zur ERP',true);
55 $shopdb = new mydb($SHOPhost,$SHOPdbname,$SHOPuser,$SHOPpass,$SHOPport,'mysql',$err,$debug);
56 if ($shopdb->db->connected_database_name == $SHOPdbname) {
57 $shop = new pepper($shopdb,$err,$SHOPdbname,$divStd,$divVerm,$minder,$nachn,$versandS,$versandV,$paypal,$treuhand,$mwstLX,$mwstS,$variantnr);
58 //echo "<pre>"; print_r($shopdb->db); print_r($shopnr); echo "</pre>";
60 $err->out('Keine Verbindung zum Shop',true);
64 $bestellungen = $shop->getBestellung($ERPusrID);
65 //print_r($bestellungen); exit(1);
69 $err->out("Bestellimport vom Shop $shopnr",true);
71 if ($bestellungen) foreach ($bestellungen as $row) {
72 $rc = $erp->mkAuftrag($row,$shopnr,$longtxt);
74 $rc = $shop->setKundenNr($row['customer']['shopid'],$rc);
76 $shop->setAbgeholt($row['cusordnumber']);
81 $err->out("Fehler setKdNr ".$row['customer']['shopid'],true);
83 } else if ($rc == -1) {
85 $err->out("Fehler mkAuftrag ".$row['cusordnumber'],true);
87 $err->out("Fehler Kunde zuordnen ".$row['customer']['shopid'].":".$row['cusordnumber'],true);
91 $err->out('Von '.count($bestellungen)." Bestellungen $cnt übertragen, $errors nicht",true);
92 if ( $api != "cli" ) {
93 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>";
94 echo "</body>\n</html>\n";