PHP-Code aus ERP entfernt. Wird als Extrapakete angeboten.
authorHolger Lindemann <hli@lx-system.de>
Mon, 7 Jan 2013 11:27:39 +0000 (12:27 +0100)
committerHolger Lindemann <hli@lx-system.de>
Mon, 7 Jan 2013 11:27:39 +0000 (12:27 +0100)
24 files changed:
peppershop/ArtikelErpToShop.php [deleted file]
peppershop/ArtikelShopToErp.php [deleted file]
peppershop/BestellungShopToErp.php [deleted file]
peppershop/LiesMich.txt [deleted file]
peppershop/Picture.php [deleted file]
peppershop/conf.php [deleted file]
peppershop/confedit.php [deleted file]
peppershop/dblib.php [deleted file]
peppershop/erplib.php [deleted file]
peppershop/error.php [deleted file]
peppershop/menu.ini [deleted file]
peppershop/pepper.php [deleted file]
shopxtc/ArtikelErpToShop.php [deleted file]
shopxtc/ArtikelShopToErp.php [deleted file]
shopxtc/BestellungShopToErp.php [deleted file]
shopxtc/LiesMich.txt [deleted file]
shopxtc/PictureXTC.php [deleted file]
shopxtc/conf.php.default [deleted file]
shopxtc/confedit.php [deleted file]
shopxtc/dblib.php [deleted file]
shopxtc/erplib.php [deleted file]
shopxtc/error.php [deleted file]
shopxtc/menu.ini [deleted file]
shopxtc/xtc.php [deleted file]

diff --git a/peppershop/ArtikelErpToShop.php b/peppershop/ArtikelErpToShop.php
deleted file mode 100644 (file)
index 087e207..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-<?php
-
-$debug = False;
-
-$api = php_sapi_name();
-if ( $api != "cli" ) {
-    echo "<html>\n<head>\n<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>\n</head>\n<body>\n";
-    @apache_setenv('no-gzip', 1);
-    @ini_set('zlib.output_compression', 0);
-    @ini_set('implicit_flush', 1);
-    $shopnr = $_GET["Shop"];
-    $nofiles = ( $_GET["nofiles"] == '1' )?true:false;
-} else {
-    $p = array('shopnr','nofiles');
-    if ( $argc > 1 ) {
-        for( $i=1; $i<count($argv); $i++)  {
-                $tmp = explode("=",trim($argv[$i]));
-                if ( count($tmp) < 2 ) {
-                    echo "Falscher Aufruf: php ArtikelErpToShop.php shopnr=1 [nofiles=1]\n";
-                    exit (-1);
-                };
-                if ( ! in_array(strtolower($tmp[0]),$p) ) {
-                    echo "Falscher Aufruf: php ArtikelErpToShop.php shopnr=1 [nofiles=1]\n";
-                    exit (-1);
-                };
-                ${$tmp[0]} = trim($tmp[1]);
-        }
-    } else {
-        $shopnr=false;
-        $nofiles=false;
-    }
-}
-
-include_once("conf$shopnr.php");
-include_once("error.php");
-//Fehlerinstanz
-$err = new error($api);
-
-include_once("dblib.php");
-include_once("pepper.php");
-include_once("erplib.php");
-include_once("Picture.php");
-
-
-//Bilder
-$pict = new picture($ERPftphost,$ERPftpuser,$ERPftppwd,$ERPimgdir,$SHOPftphost,$SHOPftpuser,$SHOPftppwd,$SHOPimgdir,$err);
-//$pict->original = false;
-
-//ERP-Instanz
-$erpdb = new mydb($ERPhost,$ERPdbname,$ERPuser,$ERPpass,$ERPport,'pgsql',$err,$debug);
-if ($erpdb->db->connected_database_name == $ERPdbname) {
-    $erp = new erp($erpdb,$err,$divStd,$divVerm,$auftrnr,$kdnum,$preA,$preK,$invbrne,$mwstS,$OEinsPart,$lager,$pricegroup,$ERPusrID);
-} else {
-    $err->out('Keine Verbindung zur ERP',true);
-    exit();
-}
-//Shop-Instanz
-$shopdb = new mydb($SHOPhost,$SHOPdbname,$SHOPuser,$SHOPpass,$SHOPport,'mysql',$err,$debug);
-
-if ($shopdb->db->connected_database_name == $SHOPdbname) {
-     $shop = new pepper($shopdb,$err,$SHOPdbname,$divStd,$divVerm,$minder,$nachn,$versandS,$versandV,$paypal,$treuhand,$mwstLX,$mwstS,$variantnr,$pict,$nopic,$nopicerr,$nofiles);
-} else {
-    $err->out('Keine Verbindung zum Shop',true);
-    exit();
-}
-$artikel = $erp->getParts($pricegroup);
-$lang = $shop->getLang("de");
-$cnt = 0;
-$errors = 0;
-
-if ( $api != 'cli' ) ob_start();
-
-$err->out("Artikelexport für Shop $shopnr",true);
-
-if ($artikel) foreach ($artikel as $row) {
-    $rc = $shop->saveArtikel($row,"de");
-    if ($rc) { 
-       $cnt++;
-       if ( $cnt % 10 == 0 ) $err->out(".");  
-    } else {
-       $errors++;
-    }
-}
-$err->out('',true);
-$err->out("$cnt Artikel übertragen, $errors Artikel nicht",true);
-if ( $api != "cli" ) {
-    echo "</body>\n</html>\n";
-}
-?>
diff --git a/peppershop/ArtikelShopToErp.php b/peppershop/ArtikelShopToErp.php
deleted file mode 100644 (file)
index 173e2fa..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-<?php
-
-$debug = False;
-
-$api = php_sapi_name();
-if ( $api != "cli" ) {
-    echo "<html>\n<head>\n<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>\n</head>\n<body>\n";
-    @apache_setenv('no-gzip', 1);
-    @ini_set('zlib.output_compression', 0);
-    @ini_set('implicit_flush', 1);
-    $shopnr = $_GET["Shop"];
-    $nofiles = ( $_GET["nofiles"] == '1' )?true:false;
-} else {
-    $p = array('shopnr','nofiles');
-    if ( $argc > 1 ) {
-        for( $i=1; $i<count($argv); $i++)  {
-                $tmp = explode("=",trim($argv[$i]));
-                if ( count($tmp) < 2 ) {
-                    echo "Falscher Aufruf: php ArtikelErpToShop.php shopnr=1 [nofiles=1]\n";
-                    exit (-1);
-                };
-                if ( ! in_array(strtolower($tmp[0]),$p) ) {
-                    echo "Falscher Aufruf: php ArtikelErpToShop.php shopnr=1 [nofiles=1]\n";
-                    exit (-1);
-                };
-                ${$tmp[0]} = trim($tmp[1]);
-        }
-    } else {
-        $shopnr=false;
-        $nofiles=false;
-    }
-}
-
-include_once("conf$shopnr.php");
-include_once("error.php");
-//Fehlerinstanz
-$err = new error($api);
-
-include_once("dblib.php");
-include_once("pepper.php");
-include_once("erplib.php");
-
-
-
-//ERP-Instanz
-$erpdb = new mydb($ERPhost,$ERPdbname,$ERPuser,$ERPpass,$ERPport,'pgsql',$err,$debug);
-if ($erpdb->db->connected_database_name == $ERPdbname) {
-    $erp = new erp($erpdb,$err,$divStd,$divVerm,$auftrnr,$kdnum,$preA,$preK,$invbrne,$mwstS,$OEinsPart,$lager,$pricegroup,$ERPusrID);
-} else {
-    $err->out('Keine Verbindung zur ERP',true);
-    exit();
-}
-
-//Shop-Instanz
-$shopdb = new mydb($SHOPhost,$SHOPdbname,$SHOPuser,$SHOPpass,$SHOPport,'mysql',$err,$debug);
-if ($shopdb->db->connected_database_name == $SHOPdbname) {
-     $shop = new pepper($shopdb,$err,$SHOPdbname,$divStd,$divVerm,$minder,$nachn,$versandS,$versandV,$paypal,$treuhand,$mwstLX,$mwstS,$variantnr);
-} else {
-    $err->out('Keine Verbindung zum Shop',true);
-    exit();
-}
-
-$artikel = $shop->getAllArtikel();
-$cnt = 0;
-$errors = 0;
-//Artikel die mehreren Warengruppen zugeordnet sind, werden nur einmal importiert.
-//Es wird dann auch nur die erste Warengruppe angelegt.
-if ( $api != 'cli' ) ob_start();
-
-$err->out("Artikelimport von Shop $shopnr",true);
-
-if ($artikel) foreach ($artikel as $row) {
-     $rc = $erp->chkPartnumber($row,true);
-     if ($rc) { 
-       $cnt++;
-     } else { 
-        $err->out('Fehler: '.$row['partnumber'],true);
-       $errors++;
-     }
-}
-$err->out('',true);
-$err->out("$cnt Artikel geprüft bzw. übertragen, $errors Artikel nicht",true);
-if ( $api != "cli" ) {
-    echo "</body>\n</html>\n";
-}
-?>
diff --git a/peppershop/BestellungShopToErp.php b/peppershop/BestellungShopToErp.php
deleted file mode 100644 (file)
index 6031024..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-<?php
-
-$debug = False;
-
-$api = php_sapi_name();
-if ( $api != "cli" ) {
-    echo "<html>\n<head>\n<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>\n</head>\n<body>\n";
-    @apache_setenv('no-gzip', 1);
-    @ini_set('zlib.output_compression', 0);
-    @ini_set('implicit_flush', 1);
-    $shopnr = $_GET["Shop"];
-    $nofiles = ( $_GET["nofiles"] == '1' )?true:false;
-} else {
-    $p = array('shopnr','nofiles');
-    if ( $argc > 1 ) {
-        for( $i=1; $i<count($argv); $i++)  {
-                $tmp = explode("=",trim($argv[$i]));
-                if ( count($tmp) < 2 ) {
-                    echo "Falscher Aufruf: php ArtikelErpToShop.php shopnr=1 [nofiles=1]\n";
-                    exit (-1);
-                };
-                if ( ! in_array(strtolower($tmp[0]),$p) ) {
-                    echo "Falscher Aufruf: php ArtikelErpToShop.php shopnr=1 [nofiles=1]\n";
-                    exit (-1);
-                };
-                ${$tmp[0]} = trim($tmp[1]);
-        }
-    } else {
-        $shopnr=false;
-        $nofiles=false;
-    }
-}
-
-include_once("conf$shopnr.php");
-include_once("error.php");
-//Fehlerinstanz
-$err = new error($api);
-
-include_once("dblib.php");
-include_once("pepper.php");
-include_once("erplib.php");
-
-$err->out("Shop $shopnr, Bestellimport",true);
-
-//ERP-Instanz
-$erpdb = new mydb($ERPhost,$ERPdbname,$ERPuser,$ERPpass,$ERPport,'pgsql',$err,$debug);
-if ($erpdb->db->connected_database_name == $ERPdbname) {
-    $erp = new erp($erpdb,$err,$divStd,$divVerm,$auftrnr,$kdnum,$preA,$preK,$invbrne,$mwstS,$OEinsPart,$lager,$pricegroup,$ERPusrID);
-} else {
-    $err->out('Keine Verbindung zur ERP',true);
-    exit();
-}
-
-//Shop-Instanz
-$shopdb = new mydb($SHOPhost,$SHOPdbname,$SHOPuser,$SHOPpass,$SHOPport,'mysql',$err,$debug);
-if ($shopdb->db->connected_database_name == $SHOPdbname) {
-     $shop = new pepper($shopdb,$err,$SHOPdbname,$divStd,$divVerm,$minder,$nachn,$versandS,$versandV,$paypal,$treuhand,$mwstLX,$mwstS,$variantnr);
-//echo "<pre>"; print_r($shopdb->db); print_r($shopnr); echo "</pre>";
-} else {
-    $err->out('Keine Verbindung zum Shop',true);
-    exit();
-}
-
-$bestellungen = $shop->getBestellung($ERPusrID);
-//print_r($bestellungen); exit(1);
-$cnt = 0;
-$errors = 0;
-
-$err->out("Bestellimport vom Shop $shopnr",true);
-
-if ($bestellungen) foreach ($bestellungen as $row) {
-    $rc = $erp->mkAuftrag($row,$shopnr,$longtxt);
-    if ($rc>0) {
-        $rc = $shop->setKundenNr($row['customer']['shopid'],$rc);
-        if ($rc>0) {
-           $shop->setAbgeholt($row['cusordnumber']); 
-           $cnt++;
-           $err->out("ok",true);
-        } else {
-           $errors++;
-           $err->out("Fehler setKdNr ".$row['customer']['shopid'],true);
-        }
-    } else if ($rc == -1) {
-           $errors++;
-           $err->out("Fehler mkAuftrag ".$row['cusordnumber'],true);
-    } else {
-        $err->out("Fehler Kunde zuordnen ".$row['customer']['shopid'].":".$row['cusordnumber'],true);
-        $errors++;
-    } 
-}
-$err->out('Von '.count($bestellungen)." Bestellungen $cnt übertragen, $errors nicht",true);
-if ( $api != "cli" ) {
-    echo "<br /><a href='../oe.pl?vc=customer&type=sales_order&nextsub=orders&action=Weiter&open=1&notdelivered=1&delivered=1&l_ordnumber=Y&l_transdate=Y&l_reqdate=1&l_name=Y&l_employee=Y&l_amount=Y'>Auftragsliste</a>";
-    echo "</body>\n</html>\n";
-}
-
-?>
diff --git a/peppershop/LiesMich.txt b/peppershop/LiesMich.txt
deleted file mode 100644 (file)
index 152317e..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-Varianten können in LxO eigene Artikelnummern haben.
-Die Artikelnummer wird dann automatisch ergänzt um "-" und die Variarions-ID.
-Aus "A1001" wird z.B. "A1001-1" für die erste (Standard) Variante.
-Variations-IDs MÜSSEN!! Lückenlos bei 1 beginnen, da sonst der Shop ins Schleudern kommt!!!!!
-
-Preise werden berechnet: Grundpreis + Preis für die Variante
-Text wird ergänzt: Standardtext + ", Variantengruppe: Variante"
-
-Ein beschreibbares Verzeichnis "tmp" wird als Unterverzeichnis erwartet. 
-z.B.:
-ln -s /tmp
-
-Wenn ein Platzhalterbild eingesetzt werden soll, so muß das Bild zuerst auf 
-den Shopserver übertragen werden.
-<bildname>_gr.jpg und <bildname>_kl.jpg
-
-Dann den Namen <bildname> in der Maske eintragen. Man kann bestimmen, ob
-das Bild immer genommen wird, wenn kein Bild angegeben wird oder nur wenn
-der Upload schief gegangen ist.
-
-Artikelexport (Lx -> Shop) kann ohne Bilderupload durchgeführt werden.
-Spart Bandbreite und Zeit, wenn nur Updates gemacht werden.
-Parameterübergabe:  nofiles=1
-[Shop--Warenexport]
-module=shop/ArtikelErpToShop.php
-nofiles=1
-
-Shop ist Mehrshopfähig. Shopnummer muß beim Aufruf übergeben werden:
-Shop=1
-
-Die Im-/Exportmodule lassen sich auch auf der Konsole oder per Cron-Job aufrufen:
-
-php ArtikelShopToErp.php shop=1 > /tmp/export.log
diff --git a/peppershop/Picture.php b/peppershop/Picture.php
deleted file mode 100644 (file)
index 55184da..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-<?php
-
-
-class picture {
-
-    var $smallwidth = 150;
-    var $bigwidth = 800;
-    var $original = true;
-    var $err = false;
-
-    function picture($ERPhost,$ERPuser,$ERPpass,$ERPimgdir,$SHOPhost,$SHOPuser,$SHOPpass,$SHOPimgdir,$err) {
-        $this->ERPftphost = $ERPhost;
-        $this->ERPftpuser = $ERPuser;
-        $this->ERPftppwd = $ERPpass;
-        $this->ERPimgdir = $ERPimgdir;
-        $this->SHOPftphost = $SHOPhost;
-        $this->SHOPftpuser = $SHOPuser;
-        $this->SHOPftppwd = $SHOPpass;
-        $this->SHOPimgdir = $SHOPimgdir;
-        $this->err = $err;
-    }
-
-    function copyImage($id,$image,$typ) {
-        if ( !$this->fromERP($image) ) return false;
-        if ( !$this->mkbilder() ) return false;
-        return $this->toShop($id,$typ);
-    }
-
-    function mkbilder() {
-        if ( !class_exists("Imagick") ) { $this->err->out("Imagick-Extention nicht installiert",true); return false; };
-        $handle = new Imagick();
-        if ( !$handle->readImage("./tmp/tmp.file_org") ) return false;
-        $d = $handle->getImageGeometry();
-        if ( $d["width"]<$d["height"] ) {
-            $faktor = $d["height"]/$d["width"];
-        } else {
-            $faktor = $d["width"]/$d["height"];
-        }
-        $smallheight = floor($this->smallwidth*$faktor);
-        $handle->thumbnailImage($this->smallwidth, $smallheight, true);
-        $rc = $handle->writeImage( "./tmp/tmp.file_small");
-        if ( !$this->original ) {
-            $handle->readImage("./tmp/tmp.file_org");
-            $bigheight = floor($this->bigwidth * $faktor);
-            $handle->thumbnailImage( $this->bigwidth, $bigheight,true);
-            return $handle->writeImage( "./tmp/tmp.file_org");
-        }
-        return $rc;
-    }
-
-    function fromERP($image) {
-        if ( $this->ERPftphost == 'localhost' ) {
-            exec("cp $this->ERPimgdir/$image ./tmp/tmp.file_org",$aus,$rc2);
-            if ( $rc2>0 ) { $this->err->out("[Downloadfehler: $image]",true); return false; };
-        } else {
-            $conn_id = ftp_connect($this->ERPftphost);
-            $rc = @ftp_login($conn_id,$this->ERPftpuser,$this->ERPftppwd);
-            $src = $this->ERPimgdir."/".$image;
-            $upload = @ftp_get($conn_id,"tmp/tmp.file_org","$src",FTP_BINARY);
-            if ( !$upload ) { $this->err->out("[Ftp Downloadfehler! $image]",true); return false; };
-            ftp_quit($conn_id);
-        }
-        $this->image = $image;
-        return true;
-    }
-
-    function toShop($id,$typ) {
-        $grpic = $id."_gr.".$typ;
-        $klpic = $id."_kl.".$typ;
-        if ( $this->SHOPftphost == 'localhost' ) {
-            exec("cp ./tmp/tmp.file_org $this->SHOPimgdir/$grpic",$aus,$rc1);
-            exec("cp ./tmp/tmp.file_small $this->SHOPimgdir/$klpic",$aus,$rc2);
-            if ( $rc1>0 || $rc2>0 ) { $this->err->out("[Uploadfehler: $this->image / $grpic]",true); return false; };
-        } else {
-            $conn_id = ftp_connect($this->SHOPftphost);
-            @ftp_login($conn_id,$this->SHOPftpuser,$this->SHOPftppwd);
-            @ftp_chdir($conn_id,$this->SHOPimgdir);
-            $upload = @ftp_put($conn_id,$this->SHOPimgdir."/$grpic","tmp/tmp.file_org",FTP_BINARY);
-            if ( !$upload ) { $this->err->out("[Ftp Uploadfehler! $grpic]",true); return false; };
-            $upload = @ftp_put($conn_id,$this->SHOPimgdir."/$klpic","tmp/tmp.file_small",FTP_BINARY);
-            if ( !$upload ) { $this->err->out("[Ftp Uploadfehler! $klpic]",true); return false; };
-            @ftp_quit($conn_id);
-        }
-        return true;
-    }
-
-
-}
-?>
diff --git a/peppershop/conf.php b/peppershop/conf.php
deleted file mode 100644 (file)
index 77466ed..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-<?php
-// Verbindung zur ERP-db
-$ERPuser='lxoffice';
-$ERPpass='lxgeheim';
-$ERPhost='localhost';
-$ERPdbname='demo';
-$codeLX='UTF-8';
-$mwstLX='1';
-$ERPusrName='demo';
-$ERPusrID='';
-$ERPimgdir='/var/www/lx-office-erp';
-$maxSize='';
-$ERPftphost='localhost';
-$ERPftpuser='pepper';
-$ERPftppwd='pepper';
-//Verbindung zur osCommerce-db
-$SHOPuser='pepper';
-$SHOPpass='sehrgeheim';
-$SHOPhost='localhost';
-$SHOPdbname='Pepper';
-$codeS='UTF-8';
-$mwstS='1';
-$SHOPimgdir='/var/www/Pepper/shop/ProdukteBilder';
-$SHOPftphost='localhost';
-$SHOPftpuser='pepper';
-$SHOPftppwd='pepper';
-$nopic='nopic';
-$nopicerr='1';
-$divStd["ID"]='';
-$divStd["NR"]='divStd';
-$divStd["Unit"]='';
-$divStd["TXT"]='';
-$divStd["BUGRU"]='';
-$divStd["TAX"]='';
-$divVerm["ID"]='';
-$divVerm["NR"]='divVerm';
-$divVerm["Unit"]='';
-$divVerm["TXT"]='';
-$divVerm["BUGRU"]='';
-$divVerm["TAX"]='';
-$versandS["ID"]='';
-$versandS["NR"]='divStd';
-$versandS["Unit"]='';
-$versandS["TXT"]='Versandkosten';
-$versandS["BUGRU"]='';
-$versandS["TAX"]='';
-$versandV["ID"]='';
-$versandV["NR"]='divVerm';
-$versandV["Unit"]='';
-$versandV["TXT"]='Versandkosten';
-$versandV["BUGRU"]='';
-$versandV["TAX"]='';
-$minder["ID"]='';
-$minder["NR"]='divStd';
-$minder["Unit"]='';
-$minder["TXT"]='Mindermengenzuschlag';
-$minder["BUGRU"]='';
-$minder["TAX"]='';
-$nachn["ID"]='';
-$nachn["NR"]='';
-$nachn["Unit"]='';
-$nachn["TXT"]='';
-$nachn["BUGRU"]='';
-$nachn["TAX"]='';
-$treuh["ID"]='';
-$treuh["NR"]='';
-$treuh["Unit"]='';
-$treuh["TXT"]='Treuhandkosten';
-$treuh["BUGRU"]='';
-$treuh["TAX"]='';
-$paypal["ID"]='';
-$paypal["NR"]='divStd';
-$paypal["Unit"]='';
-$paypal["TXT"]='Paypalkosten';
-$paypal["BUGRU"]='';
-$paypal["TAX"]='';
-$bgcol[1]='#ddddff';
-$bgcol[2]='#ddffdd';
-$preA='G_';
-$preK='';
-$auftrnr='1';
-$kdnum='1';
-$pricegroup='';
-$unit='Stck';
-$longtxt='2';
-$invbrne='2';
-$variantnr='1';
-$OEinsPart='1';
-$lager='';
-?>
diff --git a/peppershop/confedit.php b/peppershop/confedit.php
deleted file mode 100644 (file)
index fbf9572..0000000
+++ /dev/null
@@ -1,481 +0,0 @@
-<?
-// $Id: confedit.php 2009/02/10 14:41:30 hli Exp $
-if (!isset($_SERVER['PHP_AUTH_USER'])) {
-       Header("WWW-Authenticate: Basic realm='Configurations-Editor'");
-       Header("HTTP/1.0 401 Unauthorized");
-       echo "Sie m&uuml;ssen sich autentifizieren\n";
-       exit;
-} else {
-        if (!$_POST) {
-            //Je Shop ein Conf-File == Multishop
-            if( isset($_GET["Shop"]) ) {
-                 $Shop = $_GET["Shop"];
-            } else {
-                 $Shop = '';
-            };
-            if ( $Shop != "" and file_exists ('conf'.$Shop.'.php') ) {
-                require 'conf'.$Shop.'.php';
-                $out = "Konfiguration für Shop $Shop gelesen";
-            } else {
-                 //Singleshop oder noch kein Shop definiert
-                require "conf.php";
-                 $out = "Standard-Konfiguration gelesen";
-            }
-            if ( $_SERVER['PHP_AUTH_USER']<>$ERPftpuser || $_SERVER['PHP_AUTH_PW']<>$ERPftppwd ) {
-                Header("WWW-Authenticate: Basic realm='My Realm'");
-                Header("HTTP/1.0 401 Unauthorized");
-                echo "Sie m&uuml;ssen sich autentifizieren\n";
-                exit;
-            }
-            echo $out;
-    }
-}
-
-include_once("error.php");
-include_once("dblib.php");
-$api = php_sapi_name();
-if ( $api == 'cli' ) {
-    echo "Nur im Browser benutzen\n";
-    exit(-1);
-};
-$err = new error($api);
-
-$zeichen = array("","UTF-8","ISO-8859-1","ISO-8859-15","Windows-1252","ASCII");
-function lager($sel,$db) {
-        if (!$db) return '';
-        $sql  = "select w.description as lager,b.description as platz,b.id from ";
-        $sql .= "bin b left join warehouse w on w.id=b.warehouse_id ";
-        $sql .= "order by b.warehouse_id,b.id";
-        $bin=$db->getall($sql);
-        echo "\t<option value=-1 ".(($sel==-1)?'selected':'').">kein Lagerbestand\n";
-        echo "\t<option value=1 ".(($sel==1)?'selected':'').">Gesamtbestand\n";
-        if ($bin) foreach ($bin as $row) {
-        echo "\t<option value=".$row['id'];
-        if ($sel==$row['id']) echo " selected";
-        echo ">".$row['lager']." ".$row['platz']."\n";
-        }
-}
-function unit($sel,$db) {
-        if (!$db) return '';
-    $sql="select name from units order by sortkey";
-    $pgs=$db->getall($sql);
-    if ($sel=='') $sel=$pgs[0]['name'];
-    if ($pgs) foreach ($pgs as $row) {
-        echo "\t<option value=".$row['name'];
-        if ($sel==$row['name']) echo " selected";
-        echo ">".$row['name']."\n";
-    }
-}
-function pg($sel,$db) {
-    if (!$db) return '';
-    $sql="select id,pricegroup from pricegroup";
-    $pgs=$db->getall($sql);
-    echo "\t<option value=0";
-    if ($sel==0) echo " selected";
-    echo ">Standard VK\n";
-    if ($pgs) foreach ($pgs as $row) {
-        echo "\t<option value=".$row['id'];
-        if ($sel==$row['id']) echo " selected";
-        echo ">".$row['pricegroup']."\n";
-    }
-}
-function getTax($db) {
-    $sql  = "SELECT  BG.id AS bugru,T.rate,TK.startdate,C.taxkey_id, ";
-    $sql .= "(SELECT id FROM chart WHERE accno = T.taxnumber) AS tax_id, ";
-    $sql .= "BG.income_accno_id_0,BG.expense_accno_id_0 ";
-    $sql .= "FROM buchungsgruppen BG LEFT JOIN chart C ON BG.income_accno_id_0=C.id ";
-    $sql .= "LEFT JOIN taxkeys TK ON TK.chart_id=C.id ";
-    $sql .= "LEFT JOIN tax T ON T.id=TK.tax_id WHERE TK.startdate <= now()";
-    $rs = $db->getAll($sql);
-    if ($rs) foreach ($rs as $row) {
-        $nr = $row['bugru'];
-        if (!$TAX[$nr]) {
-            $data = array();
-            $data['startdate'] =    $row['startdate'];
-            $data['rate'] =         $row['rate']*100.0;
-            $TAX[$nr] = $data;
-        } else if ($TAX[$nr]['startdate'] < $row['startdate']) {
-            $TAX[$nr]["startdate"] =     $row['startdate'];
-            $TAX[$nr]["rate"] =     $row['rate']*100.0;
-        }
-    }
-    return $TAX;
-}
-function fputsA($f,$key,$var,$bg=false) {
-    $lf="\n";
-    fputs($f,'$'.$key.'["ID"]=\''. $var['ID'].'\';'.$lf);
-    fputs($f,'$'.$key.'["NR"]=\''. $var['NR'].'\';'.$lf);
-    fputs($f,'$'.$key.'["Unit"]=\''. $var['Unit'].'\';'.$lf);
-    fputs($f,'$'.$key.'["TXT"]=\''. $var['TXT'].'\';'.$lf);
-    if ($bg) fputs($f,'$'.$key.'["BUGRU"]=\''. $var['BUGRU'].'\';'.$lf);
-    if ($bg) fputs($f,'$'.$key.'["TAX"]=\''. $var['TAX'].'\';'.$lf);
-}
-
-if ( isset($_POST["ok"]) ) {
-    foreach ($_POST as $key=>$val) {
-        ${$key} = $val;
-    }
-};
-    if ( empty($ERPport) ) $ERPport = '5432';
-    if ( empty($SHOPport) ) $SHOPport = '3306';
-
-    $ok=true;
-    $dbP = new mydb($ERPhost,$ERPdbname,$ERPuser,$ERPpass,$ERPport,'pgsql',$err,$debug);
-    if (!$dbP->db) {
-        $ok=false;
-        echo "Keine Verbindung zur ERP<br>";
-        $dbP=false;
-        unset($divStd['ID']);
-        unset($divVerm['ID']);
-        unset($minder['ID']);
-        unset($versand['ID']);
-        unset($nachn['ID']);
-        unset($paypal['ID']);
-        unset($treuhand['ID']);
-        unset($ERPusr['ID']);
-    } else {
-        $tax = getTax($dbP);
-        $sql="SELECT id,description,unit,buchungsgruppen_id FROM parts where partnumber = '%s'";
-        $rs=$dbP->getOne(sprintf($sql,$divStd['NR']));
-        $divStd['ID']=$rs['id'];
-        $divStd['Unit']=$rs['unit'];
-        $divStd['BUGRU']=$rs['buchungsgruppen_id'];
-        $divStd['TAX']=$tax[$rs['buchungsgruppen_id']]['rate'];
-        $divStd['TXT']=addslashes($rs['description']);
-        $rs=$dbP->getOne(sprintf($sql,$divVerm['NR']));
-        $divVerm['ID']=$rs['id'];
-        $divVerm['Unit']=$rs['unit'];
-        $divVerm['BUGRU']=$rs['buchungsgruppen_id'];
-        $divVerm['TAX']=$tax[$rs['buchungsgruppen_id']]['rate'];
-        $divVerm['TXT']=addslashes($rs['description']);
-        $rs=$dbP->getOne(sprintf($sql,$versandS['NR']));
-        $versandS['ID']=$rs['id'];
-        $versandS['Unit']=$rs['unit'];
-        $versandS['BUGRU']=$rs['buchungsgruppen_id'];
-        $versandS['TAX']=$tax[$rs['buchungsgruppen_id']]['rate'];
-        if ($versandS['TXT'] == '') $versandS['TXT']=addslashes($rs['description']);
-        $rs=$dbP->getOne(sprintf($sql,$versandV['NR']));
-        $versandV['ID']=$rs['id'];
-        $versandV['Unit']=$rs['unit'];
-        $versandV['BUGRU']=$rs['buchungsgruppen_id'];
-        $versandV['TAX']=$tax[$rs['buchungsgruppen_id']]['rate'];
-        if ($versandV['TXT'] == '') $versandV['TXT']=addslashes($rs['description']);
-        $rs=$dbP->getOne(sprintf($sql,$nachn['NR']));
-        $nachn['ID']=$rs['id'];
-        $nachn['Unit']=$rs['unit'];
-        $nachn['BUGRU']=$rs['buchungsgruppen_id'];
-        $nachn['TAX']=$tax[$rs['buchungsgruppen_id']]['rate'];
-        if ($nachn['TXT'] == '') $nachn['TXT']=addslashes($rs['description']);
-        $rs=$dbP->getOne(sprintf($sql,$minder['NR']));
-        $minder['ID']=$rs['id'];
-        $minder['Unit']=$rs['unit'];
-        $minder['BUGRU']=$rs['buchungsgruppen_id'];
-        $minder['TAX']=$tax[$rs['buchungsgruppen_id']]['rate'];
-        if ($minder['TXT'] == '') $minder['TXT']=addslashes($rs['description']);
-        $rs=$dbP->getOne(sprintf($sql,$paypal['NR']));
-        $paypal['ID']=$rs['id'];
-        $paypal['Unit']=$rs['unit'];
-        $paypal['BUGRU']=$rs['buchungsgruppen_id'];
-        $paypal['TAX']=$tax[$rs['buchungsgruppen_id']]['rate'];
-        if ($paypal['TXT'] == '') $paypal['TXT']=addslashes($rs['description']);
-        $rs=$dbP->getOne(sprintf($sql,$treuhand['NR']));
-        $treuhand['ID']=$rs['id'];
-        $treuhand['Unit']=$rs['unit'];
-        $treuhand['BUGRU']=$rs['buchungsgruppen_id'];
-        $treuhand['TAX']=$tax[$rs['buchungsgruppen_id']]['rate'];
-        if ($treuhand['TXT'] == '') $treuhand['TXT']=addslashes($rs['description']);
-        $rs=$dbP->getOne("select id from employee where login = '".$ERPusrName."'");
-        $ERPusrID=$rs['id'];
-    }
-    $dbM = new mydb($SHOPhost,$SHOPdbname,$SHOPuser,$SHOPpass,$SHOPport,'mysql',$err,$debug);
-    if (!$dbM->db) {
-        $ok=false;
-        echo "Keine Verbindung zum Shop<br>";
-        $dbM=false;
-    };
-if ( isset($_POST["ok"]) ) {
-   $lf = "\n";
-   $f = @fopen('conf'.$Shop.'.php','w');
-   if ($f) {
-        $v="1.5";
-        $d=date("Y/m/d H:i:s");
-        fputs($f,"<?php$lf// Verbindung zur ERP-db$lf");
-        fputs($f,'$debug=\''.$debug.'\';'.$lf);
-        fputs($f,'$ERPuser=\''.$ERPuser.'\';'.$lf);
-        fputs($f,'$ERPpass=\''.$ERPpass.'\';'.$lf);
-        fputs($f,'$ERPhost=\''.$ERPhost.'\';'.$lf);
-        fputs($f,'$ERPport=\''.$ERPport.'\';'.$lf);
-        fputs($f,'$ERPdbname=\''.$ERPdbname.'\';'.$lf);
-        fputs($f,'$codeLX=\''.$codeLX.'\';'.$lf);
-        fputs($f,'$mwstLX=\''.$mwstLX.'\';'.$lf);
-        fputs($f,'$ERPusrName=\''.$ERPusrName.'\';'.$lf);
-        fputs($f,'$ERPusrID=\''.$ERPusrID.'\';'.$lf);
-        fputs($f,'$ERPimgdir=\''.$ERPimgdir.'\';'.$lf);
-        fputs($f,'$maxSize=\''.$maxSize.'\';'.$lf);
-        fputs($f,'$ERPftphost=\''.$ERPftphost.'\';'.$lf);
-        fputs($f,'$ERPftpuser=\''.$ERPftpuser.'\';'.$lf);
-        fputs($f,'$ERPftppwd=\''.$ERPftppwd.'\';'.$lf);
-        fputs($f,'//Verbindung zur osCommerce-db'.$lf);
-        fputs($f,'$SHOPuser=\''.$SHOPuser.'\';'.$lf);
-        fputs($f,'$SHOPpass=\''.$SHOPpass.'\';'.$lf);
-        fputs($f,'$SHOPhost=\''.$SHOPhost.'\';'.$lf);
-        fputs($f,'$SHOPport=\''.$SHOPport.'\';'.$lf);
-        fputs($f,'$SHOPdbname=\''.$SHOPdbname.'\';'.$lf);
-        fputs($f,'$codeS=\''.$codeS.'\';'.$lf);
-        fputs($f,'$mwstS=\''.$mwstS.'\';'.$lf);
-        fputs($f,'$SHOPimgdir=\''.$SHOPimgdir.'\';'.$lf);
-        fputs($f,'$SHOPftphost=\''.$SHOPftphost.'\';'.$lf);
-        fputs($f,'$SHOPftpuser=\''.$SHOPftpuser.'\';'.$lf);
-        fputs($f,'$SHOPftppwd=\''.$SHOPftppwd.'\';'.$lf);
-        fputs($f,'$nopic=\''.$nopic.'\';'.$lf);
-        fputs($f,'$nopicerr=\''.$nopicerr.'\';'.$lf);
-        fputsA($f,'divStd',$divStd,true);
-        fputsA($f,'divVerm',$divVerm,true);
-        fputsA($f,'versandS',$versandS,true);
-        fputsA($f,'versandV',$versandV,true);
-        fputsA($f,'minder',$minder,true);
-        fputsA($f,'nachn',$nachn,true);
-        fputsA($f,'treuhand',$treuhand,true);
-        fputsA($f,'paypal',$paypal,true);
-        fputs($f,'$bgcol[1]=\'#ddddff\';'.$lf);
-        fputs($f,'$bgcol[2]=\'#ddffdd\';'.$lf);
-        fputs($f,'$preA=\''.$preA.'\';'.$lf);
-        fputs($f,'$preK=\''.$preK.'\';'.$lf);
-        fputs($f,'$auftrnr=\''.$auftrnr.'\';'.$lf);
-        //fputs($f,'$utftrans=\''.$utftrans.'\';'.$lf);
-        fputs($f,'$kdnum=\''.$kdnum.'\';'.$lf);
-        fputs($f,'$pricegroup=\''.$pricegroup.'\';'.$lf);
-        fputs($f,'$unit=\''.$unit.'\';'.$lf);
-        fputs($f,'$longtxt=\''.$longtxt.'\';'.$lf);
-        fputs($f,'$invbrne=\''.$invbrne.'\';'.$lf);
-        fputs($f,'$variantnr=\''.$variantnr.'\';'.$lf);
-        fputs($f,'$OEinsPart=\''.$OEinsPart.'\';'.$lf);
-        fputs($f,'$lager=\''.$lager.'\';'.$lf);
-        //fputs($f,'$showErr=true;'.$lf);
-        fputs($f,"?>");
-        fclose($f);
-        echo "Konfiguration conf$Shop.php gesichert.";
-    } else {
-        echo "Konfigurationsdatei (conf$Shop.php) konnte nicht geschrieben werden";
-    }
-} 
-?>
-<html>
-<body>
-<center>
-<table style="background-color:#cccccc" border="0">
-<form name="ConfEdit" method="post" action="confedit.php">
-<input type="hidden" name="Shop" value="<?= $Shop ?>">
-<input type="hidden" name="divStd[ID]" value="<?= $divStd['ID'] ?>">
-<input type="hidden" name="divVerm[ID]" value="<?= $divVerm['ID'] ?>">
-<input type="hidden" name="minder[ID]" value="<?= $minder['ID'] ?>">
-<input type="hidden" name="versandS[ID]" value="<?= $versandS['ID'] ?>">
-<input type="hidden" name="versandV[ID]" value="<?= $versandV['ID'] ?>">
-<input type="hidden" name="nachn[ID]" value="<?= $nachn['ID'] ?>">
-<input type="hidden" name="paypal[ID]" value="<?= $paypal['ID'] ?>">
-<input type="hidden" name="treuhand[ID]" value="<?= $treuhand['ID'] ?>">
-<input type="hidden" name="ERPusr[ID]" value="<?= $ERPusr['ID'] ?>">
-
-<tr><th>Daten</th><th>Lx-ERP</th><th><?php echo $Shop ?></th><th>Shop</th></tr>
-<tr>
-    <td>db-Host</td>
-    <td colspan="2"><input type="text" name="ERPhost" size="25" value="<?= $ERPhost ?>"></td>
-    <td><input type="text" name="SHOPhost" size="25" value="<?= $SHOPhost ?>"></td>
-</tr>
-<tr>
-    <td>db-Port</td>
-    <td colspan="2"><input type="text" name="ERPport" size="25" value="<?= $ERPport ?>"></td>
-    <td><input type="text" name="SHOPport" size="25" value="<?= $SHOPport ?>"></td>
-</tr>
-<tr>
-    <td>Database</td>
-    <td colspan="2"><input type="text" name="ERPdbname" size="20" value="<?= $ERPdbname ?>"></td>
-    <td><input type="text" name="SHOPdbname" size="20" value="<?= $SHOPdbname ?>"></td>
-</tr>
-<tr>
-    <td>db-User Name</td>
-    <td colspan="2"><input type="text" name="ERPuser" size="15" value="<?= $ERPuser ?>"></td>
-    <td><input type="text" name="SHOPuser" size="15" value="<?= $SHOPuser ?>"></td>
-</tr>
-<tr>
-    <td>db-User PWD</td>
-    <td colspan="2"><input type="text" name="ERPpass" size="15" value="<?= $ERPpass ?>"></td>
-    <td><input type="text" name="SHOPpass" size="15" value="<?= $SHOPpass ?>"></td>
-</tr>
-</tr>
-    <td>Zeichensatz</td>
-    <td colspan="2"><select name="codeLX">
-<?php   foreach($zeichen as $code) {
-             echo "<option value='".$code."'";
-             if ($code == $codeLX) echo " selected";
-             echo ">".$code."\n"; };
-?>
-    </select></td>
-    <td ><select name="codeS">
-<?php   foreach($zeichen as $code) {
-             echo "<option value='".$code."'";
-             if ($code == $codeS) echo " selected";
-             echo ">".$code."\n"; };
-?>
-    </select></td>
-</tr>
-<tr>
-    <td>Preise </td>
-        <td colspan="2"> <input type="radio" name="mwstLX" value="1" <?= ($mwstLX==1)?"checked":'' ?>> incl.
-        <input type="radio" name="mwstLX" value="0" <?= ($mwstLX<>1)?"checked":'' ?>> excl. MwSt</td>
-    <td><input type="radio" name="mwstS" value="1" <?= ($mwstS==1)?"checked":'' ?>> incl.
-        <input type="radio" name="mwstS" value="0" <?= ($mwstS<>1)?"checked":'' ?>> excl. MwSt</td>
-</tr>
-<tr>
-    <td>User-ID</td>
-    <td colspan="2"><input type="text" name="ERPusrName" size="10" value="<?= $ERPusrName ?>">
-        <input type="checkbox" name="a1" <?= (empty($ERPusrID)?'':"checked") ?>></td>
-    <td></td>
-</tr>
-<tr>
-    <td>Image-Dir</td>
-    <td colspan="2"><input type="text" name="ERPimgdir" size="30" value="<?= $ERPimgdir ?>"></td>
-    <td><input type="text" name="SHOPimgdir" size="30" value="<?= $SHOPimgdir ?>"></td>
-</tr>
-<tr>
-    <td>Platzhalterbild</td>
-    <td colspan="2"><input type="text" name="nopic" size="20" value="<?php echo $nopic; ?>">ohne Endung</td>
-    <td colspan="2"><input type="checkbox" value="1" name="nopicerr" <?= (empty($nopicerr)?'':"checked") ?>>nur bei fehlerhaftem Upload verwenden</td>
-</tr>
-<tr>
-    <td>FTP-Host</td>
-    <td colspan="2"><input type="text" name="ERPftphost" size="20" value="<?= $ERPftphost ?>"></td>
-    <td><input type="text" name="SHOPftphost" size="20" value="<?= $SHOPftphost ?>"></td>
-</tr>
-<tr>
-    <td>FTP-User</td>
-    <td colspan="2"><input type="text" name="ERPftpuser" size="15" value="<?= $ERPftpuser ?>"></td>
-    <td><input type="text" name="SHOPftpuser" size="15" value="<?= $SHOPftpuser ?>"></td>
-</tr>
-<tr>
-    <td>FTP-User PWD</td>
-    <td colspan="2"><input type="text" name="ERPftppwd" size="15" value="<?= $ERPftppwd ?>"></td>
-    <td><input type="text" name="SHOPftppwd" size="15" value="<?= $SHOPftppwd ?>"></td>
-</tr>
-<tr>
-    <td>Nr Diverse Std-MwSt</td>
-    <td><input type="text" name="divStd[NR]" size="10" value="<?= $divStd['NR'] ?>">
-        <input type="checkbox" name="a1" <?= (empty($divStd['ID'])?'':"checked") ?>></td>
-    <td>Nr Diverse Verm-MwSt</td>
-    <td><input type="text" name="divVerm[NR]" size="10" value="<?= $divVerm['NR'] ?>">
-        <input type="checkbox" name="a1" <?= (empty($divVerm['ID'])?'':"checked") ?>></td>
-</tr>
-<tr>
-    <td>Nr Versand Std-MwSt</td>
-    <td><input type="text" name="versandS[NR]" size="10" value="<?= $versandS['NR'] ?>">
-        <input type="checkbox" name="a1" <?= (empty($versandS['ID'])?'':"checked") ?>></td>
-    <td>Text:</td>
-    <td><input type="text" name="versandS[TXT]" size="20" value="<?= $versandS['TXT'] ?>"><?= $versandS['TAX'] ?></td>
-<tr>
-    <td>Nr Versand Verm-MwSt</td>
-    <td><input type="text" name="versandV[NR]" size="10" value="<?= $versandV['NR'] ?>">
-        <input type="checkbox" name="a1" <?= (empty($versandV['ID'])?'':"checked") ?>></td>
-    <td>Text:</td>
-    <td><input type="text" name="versandV[TXT]" size="20" value="<?= $versandV['TXT'] ?>"><?= $versandV['TAX'] ?></td>
-</tr>
-<tr>
-    <td>Nr Paypal</td>
-    <td><input type="text" name="paypal[NR]" size="10" value="<?= $paypal['NR'] ?>">
-        <input type="checkbox" name="a1" <?= (empty($paypal['ID'])?'':"checked") ?>></td>
-    <td>Text:</td>
-    <td><input type="text" name="paypal[TXT]" size="20" value="<?= $paypal['TXT'] ?>"></td>
-</tr>
-<tr>
-    <td>Nr Treuhand</td>
-    <td><input type="text" name="treuhand[NR]" size="10" value="<?= $treuhand['NR'] ?>">
-        <input type="checkbox" name="a1" <?= (empty($treuhand['ID'])?'':"checked") ?>></td>
-    <td>Text:</td>
-    <td><input type="text" name="treuhand[TXT]" size="20" value="<?= $treuhand['TXT'] ?>"></td>
-</tr>
-<tr>
-    <td>Nr Mindermenge</td>
-    <td><input type="text" name="minder[NR]" size="10" value="<?= $minder['NR'] ?>">
-        <input type="checkbox" name="a1" <?= (empty($minder['ID'])?'':"checked") ?>></td>
-    <td>Text:</td>
-    <td><input type="text" name="minder[TXT]" size="20" value="<?= $minder['TXT'] ?>"></td>
-</tr>
-<tr>
-    <td>Nr Nachname</td>
-    <td><input type="text" name="nachn[NR]" size="10" value="<?= $nachn['NR'] ?>">
-        <input type="checkbox" name="a1" <?= (empty($nachn['ID'])?'':"checked") ?>></td>
-    <td>Text:</td>
-    <td><input type="text" name="nachn[TXT]" size="20" value="<?= $nachn['TXT'] ?>"></td>
-</tr>
-<tr>
-    <td>Std-Einheit</td>
-    <td><select name="unit">
-<? unit($unit,$dbP); ?>
-        </select></td>
-    <td>Preisgruppe</td>
-    <td><select name="pricegroup">
-<? pg($pricegroup,$dbP); ?>
-        </select></td>
-<tr>
-    <td colspan="2">Auftragsnummern durch</td>
-    <td><input type="radio" name="auftrnr" value="1" <?= ($auftrnr==1)?"checked":'' ?>> LxO</td>
-    <td><input type="radio" name="auftrnr" value="0" <?= ($auftrnr<>1)?"checked":'' ?>> Shop</td>
-</tr>
-<tr>
-    <td colspan="2">Kundennummern durch</td>
-    <td><input type="radio" name="kdnum" value="1" <?= ($kdnum==1)?"checked":'' ?>> LxO</td>
-    <td><input type="radio" name="kdnum" value="0" <?= ($kdnum<>1)?"checked":'' ?>> Shop</td>
-</tr>
-<tr>
-    <td colspan="2">Nummernerweiterung</td>
-    <td>Auftrag<input type="text" name="preA" size="5" value="<?= $preA ?>"></td>
-    <td>Kunde<input type="text" name="preK" size="5" value="<?= $preK ?>"></td>
-</tr>
-<tr>
-    <td>Lagerbestand aus</td>
-    <td><select name="lager">
-<? lager($lager,$dbP); ?>
-        </select></td>
-    <td></td>
-    <td></td>
-<tr>
-<tr>
-    <td colspan="3">Langbeschreibung aus Shop &uuml;bernehmen</td>
-    <td><input type="radio" name="longtxt"  value="1" <?= ($longtxt<>2)?"checked":'' ?>>Ja
-    <input type="radio" name="longtxt"  value="2" <?= ($longtxt==2)?"checked":'' ?>>Nein</td>
-
-</tr>
-<tr>
-    <td colspan="3">LxO-Rechnungen sind Netto</td>
-    <td><input type="radio" name="invbrne"  value="1" <?= ($invbrne<>2)?"checked":'' ?>>Ja
-    <input type="radio" name="invbrne"  value="2" <?= ($invbrne==2)?"checked":'' ?>>Nein</td>
-</tr>
-<tr>
-    <td colspan="3">Varianten sind eigene Nummern in Lx (-n)</td>
-    <td><input type="radio" name="variantnr"  value="1" <?= ($variantnr<>2)?"checked":'' ?>>Ja
-    <input type="radio" name="variantnr"  value="2" <?= ($variantnr==2)?"checked":'' ?>>Nein</td>
-</tr>
-<tr>
-    <td colspan="3">Unbekannte Artikel beim Bestellimport anlegen</td>
-    <td><input type="radio" name="OEinsPart"  value="1" <?= ($OEinsPart<>2)?"checked":'' ?>>Ja
-    <input type="radio" name="OEinsPart"  value="2" <?= ($OEinsPart==2)?"checked":'' ?>>Nein</td>
-</tr>
-<tr>
-    <td>Logging</td>
-    <td>ein<input type="radio" name="debug" value="true" <?= ($debug=="true")?"checked":"" ?>>
-    aus<input type="radio" name="debug" value="false" <?= ($debug!="true")?"checked":"" ?>></td>
-    <td></td><td></td>
-</tr>
-
-<!--tr>
-    <td>Bildergr&ouml;sse (byte)</td>
-    <td><input type="text" name="maxSize" size="10" value="<?= $maxSize ?>"></td>
-    <td></td>
-</tr-->
-
-
-<tr><td colspan="4" align="center"><input type="submit" name="ok" value="sichern"></td></tr>
-</form>
-</table>
-</center>
-</body>
-</html>
diff --git a/peppershop/dblib.php b/peppershop/dblib.php
deleted file mode 100644 (file)
index c0797b6..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-<?php
-
-include_once("MDB2.php");
-
-class mydb {
-
-   var $db = false;
-   var $error = false;
-   var $debug = true;
-   var $dbf = false;
-   var $database = false;
-
-   function mydb($host,$db,$user,$pass,$port,$proto,$error,$debug) {
-       $this->error = $error;
-       $dsn = array('phptype'  => $proto,
-               'username' => $user,
-               'password' => $pass,
-               'hostspec' => $host,
-               'database' => $db,
-               'port'     => $port);
-       $this->debug = $debug;
-       $this->database = "-< $db >-";
-       $this->connect($dsn);
-    }
-
-    function connect($dsn) {
-       $options = array('result_buffering' => false,);
-       $this->db = MDB2::connect($dsn,$options);
-       if ( $this->debug ) $this->error->write('dblib->connect '.$this->database,'Connect:');
-       if (PEAR::isError($this->db)) {
-           $this->error->write('dblib->connect '.$this->database,$this->db->getMessage());
-           $this->error->write('dblib->connect '.$this->database,print_r($dsn,true));
-           $this->db = false;
-           return false;
-       }
-       $this->db->setFetchMode(MDB2_FETCHMODE_ASSOC);
-    }
-    function Begin() {
-        return $this->db->beginTransaction();
-    }
-    function Commit() {
-        return $this->db->commit();
-    }
-    function Rollback() {
-        return $this->db->rollback();
-    }
-
-    function getAll($sql) {
-        $rs = $this->db->queryAll($sql);
-        if ( $this->debug ) $this->error->write('dblib->getAll '.$this->database,$sql);
-        if (PEAR::isError($rs)) {
-            $this->error->write('dblib->getAll '.$this->database,$rs->getUserinfo());
-            return false;
-        }
-        return $rs;
-    } 
-    function getOne($sql) {
-        $rs = $this->db->queryRow($sql);
-        if ( $this->debug ) $this->error->write('dblib->getOne '.$this->database,$sql);
-        if (PEAR::isError($rs)) {
-            $this->error->write('dblib->getOne '.$this->database,$rs->getUserinfo());
-            return false;
-        }
-        return $rs;
-    }
-    function query($sql) {
-        $rc = $this->db->query($sql);
-        if ( $this->debug ) $this->error->write('dblib->query '.$this->database,$sql);
-        if (PEAR::isError($rc)) {
-            $this->error->write('dblib->query '.$this->database,$rc->getUserinfo());
-            return false;
-        }
-        return $rc;
-    } 
-    function insert($statement,$data) {
-        if ( $this->debug ) $this->error->write("dblib->insert ".$this->database,$statement);
-        $sth = $this->db->prepare($statement);                      //Prepare
-        if (PEAR::isError($sth)) {
-            $this->error->write('dblib->insert 1 '.$this->database,$sth->getMessage());
-            $this->error->write('dblib->insert 2',$sth->getUserinfo());
-            $this->rollback();
-            return false;
-        }
-        if ( $this->debug ) $this->error->write('dblib->insert',print_r($data,true));
-        $rc =& $sth->execute($data);
-        if (PEAR::isError($rc)) {
-            $this->error->write('dblib->insert 3 '.$this->database,$rc->getUserinfo());
-            return false;
-        }//else{
-        //    $rc = $this->commit();
-        //}
-        return $rc;
-    }
-    function update($statement,$data) {  
-        if ( $this->debug ) $this->error->write("dblib->update ".$this->database,$statement);
-        $sth = $this->db->prepare($statement);                      //Prepare
-        if (PEAR::isError($sth)) {
-            $this->error->write('dblib->update 1 '.$this->database,$sth->getMessage());
-            $this->error->write('dblib->update 2',$sth->getUserinfo());
-            $this->rollback();
-            return false;
-        }
-        if ( $this->debug ) $this->error->write('dblib->insert',print_r($data,true));
-        $rc =& $sth->execute($data);
-        if (PEAR::isError($rc)) {
-            $this->error->write('dblib->update 3 '.$this->database,$rc->getUserinfo());
-            return false;
-        }//else{
-        //    $rc = $this->commit();
-        //}
-        return $rc;
-    }
-    function insertMultipe($statement,$data) {
-        $this->db->loadModule('Extended');
-        if (!$this->db->supports('transactions')){
-            return false;
-        }
-        $sth = $this->db->prepare($statement);                      //Prepare
-        if (PEAR::isError($sth)) {
-            $this->error->write('dblib->insertMultiple '.$this->database,$sth->getMessage());
-            $this->rollback();
-            return false;
-        }
-        $rc =& $this->db->beginTransaction();
-        $rc =& $this->db->extended->executeMultiple($sth, $data);
-        if (PEAR::isError($rc)) {
-            $this->error->write('dblib->insertMultiple '.$this->database,$rc->getUserinfo());
-            $this->rollback();
-            return false;
-        }else{
-                $rc = $this->commit();
-        }
-        return $rc;
-    }
-}
-
-?>
diff --git a/peppershop/erplib.php b/peppershop/erplib.php
deleted file mode 100644 (file)
index 8b22d42..0000000
+++ /dev/null
@@ -1,460 +0,0 @@
-<?php
-/*
-
-shop muß gesetzt sein, obsolet nicht
-
-Multishop: Hierfür müssen benutzerdefinierte Variablen angelegt werden.
-Typ:checkbox,  Name=shop[0-9A-Z]+, Bearbeitbar=nein 
-
-
-*/
-
-class erp {
-
-    var $db = false;
-    var $error = false;
-    var $pricegroup = 0;
-    var $TAX = false;
-    var $mkPart = true;
-    var $divStd = false;
-    var $divVerm = false;
-    var $doordnr = false;
-    var $docustnr = false;
-    var $lager = 1;
-    var $warehouse_id = 0;
-    var $transtype = 0;
-    var $preordnr = '';
-    var $precustnr = '';
-    var $OEinsPart = false;
-    var $INVnetto = true; //Rechnungen mit Nettopreisen
-    var $SHOPincl = true; //Shoppreise sind Brutto
-
-    function erp($db,$error,$divStd,$divVerm,$doordnr,$docustnr,$preordnr,$precustnr,$INVnetto,$SHOPincl,$OEinsPart,$lager,$pricegroup,$ERPusrID) {
-        $this->db = $db;
-        $this->pricegroup = $pricegroup;
-        $this->employee_id = $ERPusrID;
-        $this->error = $error;
-        $this->divStd  = $divStd;
-        $this->divVerm = $divVerm;
-        $this->doordnr = $doordnr;
-        $this->preordnr = $preordnr;
-        $this->docustnr = $docustnr;
-        $this->precustnr = $precustnr;
-        $this->INVnetto = ($INVnetto == 1)?true:false;
-        $this->SHOPincl = ($SHOPincl == 1)?true:false;
-        $this->OEinsPart = ($OEinsPart == 1)?true:false;
-        $this->lager = ($lager)?$lager:1;
-        $this->getTax();
-        if ( $lager > 1 ) {
-            $sql  = "SELECT warehouse_id from bin where id = ".$this->lager;
-            $rs = $this->db->getOne($sql);
-            if ( $rs['warehouse_id'] > 0 ) {
-                       $this->warehouse_id = $rs['warehouse_id'];
-                $sql = "SELECT id from transfer_type WHERE direction = 'in' and description = 'stock'";
-                $rs = $this->db->getOne($sql);
-                $this->transtype = $rs['id'];
-            } else {
-                $this->lager = 1;
-            }
-        }
-    }
-
-    function getTax() {
-        $sql  = "SELECT  BG.id AS bugru,T.rate,TK.startdate,C.taxkey_id, ";
-        $sql .= "(SELECT id FROM chart WHERE accno = T.taxnumber) AS tax_id, ";
-        $sql .= "BG.income_accno_id_0,BG.expense_accno_id_0 ";
-        $sql .= "FROM buchungsgruppen BG LEFT JOIN chart C ON BG.income_accno_id_0=C.id ";
-        $sql .= "LEFT JOIN taxkeys TK ON TK.chart_id=C.id ";
-        $sql .= "LEFT JOIN tax T ON T.id=TK.tax_id WHERE TK.startdate <= now()";
-        $rs = $this->db->getAll($sql);
-        if ($rs) foreach ($rs as $row) {
-            $nr = $row['bugru'];
-            if ( !$this->TAX[$nr] || !array_key_exists($nr, $this->TAX) ) {
-                $data = array();
-                $data['startdate'] =     $row['startdate'];
-                $data['rate'] =     $row['rate'];
-                $data['taxkey'] =     $row['taxkey_id'];
-                $data['taxid'] =     $row['tax_id'];
-                $data['income'] =     $row['income_accno_id_0'];
-                $data['expense'] =     $row['expense_accno_id_0'];
-                $this->TAX[$nr] = $data;
-            } else if ($this->TAX[$nr]['startdate'] < $row['startdate']) {
-                $this->TAX[$nr]["startdate"] =     $row['startdate'];
-                $this->TAX[$nr]["rate"] =     $row['rate'];
-                $this->TAX[$nr]["taxkey"] =     $row['taxkey_id'];
-                $this->TAX[$nr]["taxid"] =     $row['tax_id'];
-                $this->TAX[$nr]["income"] =     $row['income_accno_id_0'];
-                $this->TAX[$nr]["expense"] =     $row['expense_accno_id_0'];
-            }
-        }
-    }
-
-    function getParts($stdprice=0,$shop=0) {
-        $where = "WHERE 1=1 ";
-        if ($stdprice>0) {
-             $sql  = "SELECT P.partnumber,P.description,P.notes,P.weight,G.price as sellprice,P.sellprice as stdprice,";
-             $sql .= "PG.partsgroup,P.image,P.buchungsgruppen_id as bugru,P.unit";
-             if ($this->lager>1) {
-                   $sql .= ",(select sum(qty) from inventory where bin_id = ".$this->lager." and parts_id = P.id) as onhand ";
-             } else {
-                   $sql .= ",P.onhand ";
-             }
-             $sql .= "FROM parts P ";
-             $sql .= "LEFT JOIN partsgroup PG on PG.id=P.partsgroup_id ";
-             $sql .= "LEFT JOIN prices G on G.parts_id=P.id ";
-             $where .= "AND (G.pricegroup_id=$stdprice ";
-             $where .= "or G.pricegroup_id is null) ";
-        } else {
-             $sql  = "SELECT P.partnumber,P.description,P.notes,P.weight,P.sellprice,";
-             $sql .= "PG.partsgroup,P.image,P.buchungsgruppen_id as bugru,P.unit ";
-             if ($this->lager>1) {
-                   $sql .= ",(select sum(qty) from inventory where bin_id = ".$this->lager." and parts_id = P.id) as onhand ";
-             } else {
-                   $sql .= ",P.onhand ";
-             }
-             $sql .= "FROM parts P left join partsgroup PG on PG.id=P.partsgroup_id ";
-        }
-        if ($shop>0) {  
-            $sql .= "LEFT JOIN custom_variables CV on CV.trans_id=P.id ";
-            $where .= "AND (CV.config_id = $shop AND bool_value = 't')";
-        }
-        $where .= "AND shop = 't' ";
-        $where .= "AND obsolete = 'f' ORDER BY P.partnumber";
-        $rs = $this->db->getAll($sql.$where);
-        if ($rs) for($i = 0; $i < count($rs); $i++) {
-           $rs[$i]['tax'] = $this->TAX[$rs[$i]['bugru']]['rate'];
-        }
-        return $rs;
-    }
-
-    function getPartsLang($lang,$alle) {
-        $sql  = "SELECT P.partnumber,L.translation,P.description,L.longdescription,P.notes,PG.partsgroup ";
-        $sql .= "FROM parts P left join translation L on L.parts_id=P.id left join partsgroup PG on PG.id=P.partsgroup_id ";
-        $sql .= "WHERE P.shop='t' and (L.language_id = $lang";
-        if ($alle) {
-            $sql .= " or L.language_id is Null)";
-        } else { 
-            $sql.=")"; 
-        };
-        $rs = $this->getAll($sql);
-        $data=array();
-        if ($rs) foreach ($rs as $row) {
-            if (!$data[$row["partnumber"]]) $data[$row["partnumber"]]=$row;
-        }
-        return $data;
-    }
-    function getNewNr($typ) {
-        /*
-          so = Auftragsnummer
-          customer = Kundennummer 
-        */
-        $typ .= "number";
-        $sql = "SELECT $typ FROM defaults";
-        $rs = $this->db->getOne($sql);
-        $i=strlen($rs["$typ"])-1;
-        //Nummern können Buchstaben, Zeichen und Zahlen enthalten
-        //nur die Zahlen von rechts werden aber inkrementiert.
-        while($i>=0) {
-            if ($rs["$typ"][$i] >= "0" and $rs["$typ"][$i]<="9") {
-                $n=$rs["$typ"][$i].$n;
-                $i--;
-            } else {
-                $pre = substr($rs["$typ"],0,$i+1);
-                $i=-1;
-            }
-        };
-        $nr = (int)$n + 1;
-        $sonr = $pre.$nr;
-        $sql = "UPDATE defaults SET $typ = '$sonr'";
-        $rc = $this->db->query($sql);
-        if (!$rc) {
-            $this->error->write('erplib','Neue Nummer ($typ) nicht gesichert: '.$sonr);
-        }
-        return $sonr;
-    }
-    function newOrder($data) {
-        /*Einen neuen Auftrag anlegen. Folgendes Array muß übergeben werden:
-        $data = array(ordnumber,customer_id,employee_id,taxzone_id,amount,netamount,transdate,notes,intnotes,shipvia)
-        Rückgabe oe.id */
-        $this->db->begin();
-        $incltax = ($this->INVnetto)?'f':'t';
-        $sql  = "INSERT INTO oe (ordnumber,customer_id,employee_id,taxzone_id,taxincluded,curr,amount,netamount,transdate,notes,intnotes,shipvia,cusordnumber) ";
-        $sql .= "values (:ordnumber,:customer_id,:employee_id,:taxzone_id,'$incltax',:curr,:amount,:netamount,:transdate,:notes,:intnotes,:shipvia,:cusordnumber)";
-        $rc = $this->db->insert($sql,$data);
-        $sql = "SELECT * FROM oe where ordnumber = '".$data["ordnumber"]."'";
-        $rs = $this->db->getOne($sql);
-        if (!$rs['id']) {
-            $this->error->write('erplib','Auftrag erzeugen: '.$data["ordnumber"]);
-            $this->db->rollback();
-            return false;
-        } else {
-            $this->error->out(" Auftrag: ".$data["ordnumber"]." ");
-            return $rs['id'];
-        }
-    }
-    function insParts($trans_id,$data,$longtxt) {
-        /*Artikel in die orderitem einfügen. Folgende Daten müssen übergeben werden:
-        $trans_id = (int) oe.id
-        $data = array(trans_id,partnumber,description,longdescription,qty,sellprice,unit)*/
-        foreach ($data as $row) {
-             $row['trans_id'] = $trans_id;
-             //$sql = "SELECT id FROM parts WHERE partnumber = '".$row['partnumber']."'";
-             //$tmp = $this->db->getOne($sql);
-             $tmp = $this->chkPartnumber($row,$this->OEinsPart,true);
-             if ($tmp) {
-                 $row['parts_id'] = $tmp['id'];
-             } else {
-                 if ($this->TAX[$this->divStd['BUGRU']]['rate'] == $row['mwst']/100) {
-                      $row['parts_id'] = $this->divStd['ID'];
-                 } else if ($this->TAX[$this->divVerm['BUGRU']]['rate'] == $row['mwst']/100) {
-                      $row['parts_id'] = $this->divVerm['ID'];
-                 } else {
-                      $row['parts_id'] = $this->divStd['ID'];
-                 }
-             }
-             if ($this->INVnetto) {
-                 if ($this->SHOPincl) 
-                     $row['sellprice'] = round($row['sellprice'] / (100 + $row['taxrate']) * 100,2);
-             } else {
-                 if (!$this->SHOPincl) 
-                     $row['sellprice'] = round($row['sellprice'] * (100 + $row['taxrate']) * 100,2);
-             }
-             $row['unit'] = $this->chkUnit($row['unit']);
-             if ($longtxt == 1) {
-                 //$row['longdescription'] = addslashes($row['longdescription']);
-                 $row['longdescription'] = $row['longdescription'];
-             } else {
-                 //$row['longdescription'] = addslashes($tmp['longdescription']);
-                 $row['longdescription'] = $tmp['longdescription'];
-             }
-             //$row['description'] = addslashes($row['description']);
-             $sql  = "INSERT INTO orderitems (trans_id,parts_id,description,longdescription,qty,sellprice,unit,pricegroup_id,discount) ";
-             $sql .= "VALUES (:trans_id,:parts_id,:description,:longdescription,:qty,:sellprice,:unit,0,0)";
-             $row["trans_id"]=$trans_id;
-             $rc = $this->db->insert($sql,$row);
-             if (!$rc) {
-                 $this->db->rollback();
-                 return false;
-             };
-        };
-        $this->db->commit();
-        return true;
-    }
-    function insCustomer($data) {
-        $this->error->out('Insert:'.$data["name"].' ');
-        if ($this->docustnr == 1) {
-            $data['customernumber'] = $this->getNewNr('customer');
-        } else {
-            $data['customernumber'] = $data['shopid'];
-        }
-        $data['customernumber'] = $this->precustnr.$data['customernumber'];
-            if ($data['customernumber']>0) {
-                if (!$data['greeting']) $data['greeting'] = '';
-                $sql  = "INSERT INTO customer (greeting,name,street,city,zipcode,country,contact,phone,email,customernumber)";
-                $sql .= " VALUES (:greeting,:name,:street,:city,:zipcode,:country,:contact,:phone,:email,:customernumber)";
-                $rc =  $this->db->insert($sql,$data);
-                $sql = "SELECT id FROM customer WHERE customernumber = '".$data['customernumber']."'";
-                $rs = $this->db->getOne($sql);
-                $rc = $rs['id'];
-                $this->error->out("Kd-Nr: ".$data['customernumber'].":".$rs['id']);
-            } else {
-                $this->error->write('erplib','Kunde anlegen: '.$data["name"]);
-                $this->db->rollback();
-                return false;
-            }
-            return $rc;
-    }
-    function chkCustomer($data) {
-        if ($data['customer_id']>0) {
-            $sql = "SELECT * FROM customer WHERE id = ".$data['customer_id'];
-            $rs = $this->db->getOne($sql);
-            if ($rs['id'] == $data['customer_id']) {
-                 $this->error->out('Update:'.$data['customer_id'].' ');
-                 $sql  = "UPDATE customer SET greeting = :greeting,name = :name,street = :street,city = :city,country = :country,";
-                 $sql .= "zipcode = :zipcode,contact = :contact,phone = :phone,email = :email WHERE id = :customer_id";
-                 $rc =  $this->db->update($sql,$data);
-                 if ($rc) $rc = $data['customer_id'];
-            } else {
-                $rc = $this->insCustomer($data);
-            }
-        } else {
-            $rc = $this->insCustomer($data);
-        }
-        return $rc;
-    }
-    function mkAuftrag($data,$shop,$longtxt) {
-        $this->db->Begin();
-        $data["notes"] .= "\nBezahlung:".$data['bezahlung']."\n";
-        if ($data['bezahlung'] == "Kreditkarte")   $data["notes"] .= $data['kreditkarte']."\n"; 
-        if ($shop) { 
-           $data["intnotes"] = "Shop: $shop";
-        } else {
-           $data["intnotes"] = "";
-        };
-        $data["customer_id"] = $this->chkCustomer($data["customer"]);
-        $parts = $data['parts'];
-        unset($data['parts']);
-        unset($data['customer']);
-        if ($this->doordnr == 1) {
-            $data["ordnumber"] = $this->getNewNr('so');
-        } else {
-            $data["ordnumber"] = $data['cusordnumber'];
-        }
-        $data["ordnumber"] = $this->preordnr.$data["ordnumber"];
-        $tid = $this->newOrder($data);
-        if ($tid) {
-            $rc = $this->insParts($tid,$parts,$longtxt);  
-            if (!$rc) {
-                 $this->error->write('erplib','Artikel zu Auftrag');
-                 return -1;
-            }
-        } else {
-            $this->error->write('erplib','Auftrag anlegen');
-            return -1;
-        }
-        $this->error->out($data["customer"]["firma"]." ");
-        $rc = $this->db->Commit();
-        return $data["customer_id"];
-    }
-    function chkPartsgroup($pg,$new=True) {
-       /*gibt es die Warengruppe?
-       Rückgabe nichts oder die partsgroup.id
-       ggf neu anlegen*/
-       $sql = "SELECT * FROM partsgroup WHERE partsgroup = '".$pg."'";
-       $rs = $this->db->getOne($sql);
-       if ($rs) {
-           return $rs['id'];
-       } else if ($this->mkPart and $new) {
-           return $this->mkNewPartsgroup($pg);
-       } else {
-           return '';
-       };
-    }
-    function mkNewPartsgroup($name) {
-       $sql = "INSERT INTO partsgroup (partsgroup) VALUES ('".$name."')";
-       $rc = $this->db->query($sql);
-       if ($rc) {
-           return $this->chkPartsgroup($name,False);
-       } else {
-           return '';
-       }
-    }
-    function chkUnit($unit) {
-       /*Prüfen ob es die Unit gibt.
-         wenn nicht, die Standardunit zurückgeben*/
-       if ($unit == '') {
-           return $this->stdUnit();
-       } else {
-           $sql = "SELECT * FROM units WHERE name ilike '".$unit."'";
-           $rs = $this->db->getOne($sql);
-           if ($rs) {
-              return $rs["name"];
-           } else {
-               return $this->stdUnit();
-           }
-       }
-    }
-    function stdUnit() {
-       $sql = "SELECT * FROM units WHERE type = 'dimension' ORDER BY sortkey LIMIT 1";
-       $rs = $this->db->getOne($sql);
-       return $rs["name"];
-    }
-    function chkPartnumber($data,$new=True,$long=false) {
-       $sql = "SELECT * FROM parts WHERE partnumber = '".$data["partnumber"]."'";
-       $rs = $this->db->getOne($sql);
-       if ($rs) {
-           if ($long) {
-               return $rs;
-           } else {
-               return $rs['id'];
-           }
-       } else if ($new and $this->mkPart) {
-           $data['id'] = $this->mkNewPart($data);
-           if ($long) {
-               return $data;
-           } else {
-               return $data['id'];
-           }
-       } else {
-           return '';
-       };
-    }
-    function mkNewPart($data) {
-       /*eine neue Ware anlegen, sollte nicht direkt aufgerufen werden.
-       Auf vorhandene partnumber wird nicht geprüft.
-       Folgendes Array muß übergeben werden:
-       $data = array(partnumber,description,longdescription,weight,sellprice,taxrate,partsgroup,unit)
-       Rückgabe parts.id
-       */
-       $link = '<a href="../ic.pl?action=edit&id=%d" target="_blank">';
-       if ($data['partnumber'] == '') {
-           $this->error->write('erplib','Artikelnummer fehlt');
-           return false;
-       }
-       if ($data['description'] == '') {
-           $this->error->write('erplib','Artikelbezeichnung fehlt');
-           return false;
-       }
-       $data['notes'] = addslashes($data['longdescription']);
-       if ($data['weight']*1 != $data['weight']) $data['weight']=0;
-       if ($data['sellprice']*1 != $data['sellprice']) $data['sellprice']=0;
-       if (!in_array($data["buchungsgruppen_id"],$this->TAX)) {
-           foreach ($this->TAX as $key=>$tax) {
-                if ($tax["rate"] == $data["taxrate"]/100) {
-                    $data["buchungsgruppen_id"] = $key;
-                    break;
-                }
-           }
-           if (!$data["buchungsgruppen_id"]) {
-               $this->error->write('erplib','Buchungsgruppe konnte nicht zugeordnet werden');
-               return false;
-           }
-       };
-       if ($data["partsgroup"]) {
-           $data["partsgroup_id"] = $this->chkPartsgroup($data["partsgroup"]);
-       } else {
-           $data["partsgroup_id"] = '';
-       };
-       $data['unit'] = $this->chkUnit($data['unit']);
-       if ($data['unit'] == '') {
-           $this->error->write('erplib','Artikeleinheit fehlt oder falsch');
-           return false;
-       }
-       $data['shop'] = 't';
-       $sql  = "INSERT INTO parts (partnumber,description,sellprice,weight,notes,shop,unit,partsgroup_id,";
-       $sql .= "image,buchungsgruppen_id,inventory_accno_id,income_accno_id,expense_accno_id) ";
-       $sql .= "VALUES (:partnumber,:description,:sellprice,:weight,:notes,:shop,:unit,:partsgroup_id,";
-       $sql .= ":image,:buchungsgruppen_id,1,1,1)";
-       $rc = $this->db->insert($sql,$data);
-       $data['parts_id'] = $this->chkPartnumber($data,false);
-       if ( $this->pricegroup > 0 ) {
-            $sql  = "INSERT INTO prices (parts_id,pricegroup_id,price) VALUES (:parts_id,:pricegroup,:shoppreis)";
-            $data['pricegroup'] = $this->pricegroup;
-            $rc = $this->db->insert($sql,$data);
-       };
-       if ( $data['onhand'] > 0 and $this->lager > 1) $this->insLager($data);
-       $x =  $this->chkPartnumber($data,False);
-       $this->error->write('erplib',$data['description'].' '.$data['partnumber']);
-       $this->error->out(sprintf($link,$data['parts_id']).$data['description'].' '.$data['partnumber'].'</a>',true);
-       return $x;
-    }
-    function insLager($data) {
-        $rc = $this->db->Begin();
-        $sql = "SELECT nextval(('id'::text)::regclass) as id from id";
-        $rs = $this->db->getOne($sql);
-        $sql  = "INSERT INTO inventory (warehouse_id,parts_id,shippingdate,employee_id,bin_id,qty,trans_id,trans_type_id,comment) ";
-        $sql .= "VALUES (:wid,:parts_id,now(),:employee_id,:bid,:onhand,:next,:tt,'Shopübernahme')";
-        $data['next'] = $rs['id'];
-        $data['tt'] = $this->transtype;
-        $data['bid'] = $this->lager;
-        $data['wid'] = $this->warehouse_id;
-        $data['employee_id'] = $this->employee_id;
-        $rc = $this->db->insert($sql,$data);
-        if ( $rc ) {
-           $this->db->Commit();
-        } else {
-           $this->db->Rollback();
-        }
-    }
-}
-?>
diff --git a/peppershop/error.php b/peppershop/error.php
deleted file mode 100644 (file)
index 7d36d46..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-
-class error {
-
-  var $log = false; 
-  var $api = '';
-  var $lf  = '<br />';
-
-  function error($api) {
-     $this->log = fopen("/tmp/shop.log","a");
-     $this->api = $api;
-     if ( $api == 'cli' ) { $this->lf = "\n"; }
-     else { $this->lf = "<br />"; };
-  }
-
-  function write($func,$string) {
-     $now = date('Y-m-d H:m:i ');
-     fputs($this->log,$now.$func."\n");
-     fputs($this->log,$string."\n");
-  }
-
-  function close() {
-     fclose($this->log);
-  }
-  function out($txt,$lf=false) {
-    if ( $this->api != 'cli' ) {
-        echo str_repeat(" ", 256);
-        echo $txt;
-        if ( $lf ) echo $this->lf;
-        flush(); ob_flush();
-    } else {
-        echo $txt;
-        if ( $lf ) echo $this->lf;
-    }
-  }
-}
-?>
diff --git a/peppershop/menu.ini b/peppershop/menu.ini
deleted file mode 100644 (file)
index bbbf7dc..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-
-[Shop]
-
-[Shop--Warenexport]
-module=peppershop/ArtikelErpToShop.php
-
-[Shop--Warenexport]
-module=peppershop/ArtikelShopToErp.php
-
-[Shop--Bestellungen]
-module=peppershop/BestellungShop.php
-
-[Shop--Konfiguration]
-module=peppershop/confedit.php
-
diff --git a/peppershop/pepper.php b/peppershop/pepper.php
deleted file mode 100644 (file)
index 094c610..0000000
+++ /dev/null
@@ -1,460 +0,0 @@
-<?php
-/*
-Funktionen für den Zugriff auf den Peppershop
-*/
-
-class pepper {
-
-    var $db = false;
-    var $error = false;
-    var $divStd = false;
-    var $divVerm = false;
-    var $minder = false;
-    var $paypal = false;
-    var $treuhand = false;
-    var $nachn = false;
-    var $shopcode = 'ISO-8859-1';
-    var $erpcode = 'UTF-8';
-    var $VariantNr = true;
-    var $EU = array('AT','BE','BG','CZ','DK','EE','ES','FI','FR','GB','GR','HR','HU','IE','IT','LU','LV','MT','NL','PL','PT','RO','SE','SI','SK');
-    var $Kategorien = False;
-    var $dezimal = 2;
-
-    var $tableerp  = array("partnumber"=>"artikel_nr","description"=>"name","notes"=>"beschreibung",
-                           "unit"=>"anzahl_einheit","weight"=>"gewicht","sellprice"=>"preis",
-                           "tax"=>"mwst_satz","image"=>"bild_gross","onhand"=>"lagerbestand");
-    var $tableshop = array("datum"=>"transdate","rechnungsbetrag"=>"amount","nettobetrag"=>"netamount","waehrung"=>"curr",
-                           "anmerkung"=>"notes","mwst"=>"mwst","bestellungs_id"=>"cusordnumber","bezahlungsart"=>"bezahlung",
-                           "kreditkarte"=>"kreditkarte","versandart"=>"shipvia");
-    var $custshop   = array("kontakt"=>"contact","ort"=>"city","plz"=>"zipcode","land"=>"country","tel"=>"phone",
-                            "fax"=>"fax","email"=>"email","beschreibung"=>"notes","strasse"=>"street","firma"=>"name",
-                            "kunden_nr"=>"customer_id","anrede"=>"greeting","k_id"=>"shopid",
-                            "bankname"=>"bank","blz"=>"bank_code","kontonummer"=>"account_number",
-                            "iban"=>"iban","bic"=>"bic","attributwert1"=>"ustid");
-    var $ordershop  = array("datum"=>"transdate","rechnungsbetrag"=>"amount","rechnungs_nr"=>"",
-                            "waehrung"=>"currency","beschreibung"=>"notes",
-                            "mwst"=>"mwst","versandart"=>"shipvia");
-    var $orderparts = array("artikelname"=>"description","name"=>"description","preis"=>"sellprice","anzahl"=>"qty","artikel_nr"=>"partnumber",
-                            "partsgroup"=>"partsgroup","beschreibung"=>"longdescription","gewicht"=>"weight","shoppreis"=>"shoppreis",
-                            "mwst_satz"=>"taxrate","bild_gross"=>"image","anzahl_einheit"=>"unit","lagerbestand"=>"onhand");
-    var $pic = false;
-
-    function pepper($db,$error,$dbname,
-                    $divStd,$divVerm,$minder,$nachn,$versandS,$versandV,$paypal,$treuhand,
-                    $mwstLX,$mwstS,$variantnr,$pic=false,$nopic=false,$nopicerr=false,$nofiles=false,
-                    $erpcode='UTF-8',$shopcode='ISO-8859-1') {
-        $this->db       = $db;
-        $this->error    = $error;
-        $this->divStd   = $divStd  ;
-        $this->divVerm  = $divVerm ;
-        $this->minder   = $minder  ;
-        $this->nachn    = $nachn   ;
-        $this->versandS = $versandS ;
-        $this->versandV = $versandV ;
-        $this->paypal   = $paypal  ;
-        $this->treuhand = $treuhand;
-        $this->erpcode  = $erpcode;
-        $this->mwstLX   = $mwstLX;
-        $this->mwstS    = $mwstS;
-        $this->VariantNr = ($variantnr==1)?true:false;
-        $this->pic       = $pic;
-        $this->nopic     = ( $nopic != '' )?$nopic:false;
-        $this->nopicerr  = ( $nopicerr != '' )?true:false;
-        $this->nofiles     = $nofiles;
-        if ($shopcode == 'AUTO') {
-            $sql = "SELECT TABLE_COLLATION FROM information_schema.TABLES WHERE table_schema = '$dbname' AND table_name = 'kunde'";
-            $rs = $this->db->getOne($sql);
-            if ($rs) {
-                preg_match('/([^_]+)/',$rs['table_collation'],$hits);
-                if (count($hits)>0) {
-                    $this->shopcode = $hits[1];
-                } else {
-                    $this->shopcode =  'ISO-8859-1';
-                }
-            }
-        } else {
-            $this->shopcode = $shopcode;
-        }
-    }
-    function _toERP($txt) {
-        return mb_convert_encoding($txt,$this->erpcode,$this->shopcode);
-    }
-    function _toShop($txt) {
-        return mb_convert_encoding($txt,$this->shopcode,$this->erpcode);
-    }
-    function translateTable($data,$table) {
-        $newdata = array();
-        foreach ($data as $key=>$val) {
-             if (array_key_exists($key, $this->{$table}))
-                 $newdata[$this->{$table}[$key]] = $val;
-        }
-        return $newdata;
-    }
-    function getCategoryID($name,$mwst) {
-        if (empty($name)) {
-              $name = "Default";
-        } else {
-              $name = $this->_toShop($name);
-        }
-        //Kategorien werden durch die ERP mit "!" getrennt
-        preg_match_all("/([^!]+)!?/",$name,$kat);
-        if (count($kat)>0) {
-            $kat = $kat[1];
-        } else {
-            return false;
-        };
-        $parent = 0;
-        $sql = "select * from kategorien where name like '%s' and parent_id = %d";
-        if (count($kat)>0) foreach ($kat as $wg) {
-            $sql_ = sprintf($sql,$wg,$parent);
-            $rs=$this->db->getOne($sql_);
-            if ($rs["kategorie_id"]) {                   // gefunden
-                $parent=$rs["kategorie_id"];
-                $mwst=$rs["mwst_satz"];
-            } else {                    // nicht gefunden, anlegen
-                $parent=$this->createCategory($wg,$mwst,$parent);
-            }
-        }
-        return $parent;
-    }
-    function createCategory($name,$mwst,$parent) {
-        $sql = "select max(positions_nr) as cnt from kategorien WHERE parent_id = ".$parent;
-        $rs=$this->db->getOne($sql);
-        $pos = $rs['cnt'] + 1;
-        $sql  = "INSERT INTO kategorien (positions_nr,name,mwst_satz,ist_sichtbar,parent_id) ";
-        $sql .= "VALUES (".$pos.",'".$name."',".$mwst.",'Y',".$parent.")";
-        $rc = $this->db->query($sql);
-        if ($rc) {
-            $sql = "SELECT kategorie_id FROM kategorien where name = '".$name."' and parent_id = ".$parent;
-            $rs = $this->db->getOne($sql);
-            return $rs['kategorie_id'];
-        } else {
-            return false;
-        }
-    }
-    function getLang($lang) {
-         $sql = "SELECT * FROM locale WHERE iso_639_1_code like '$lang' and aktiviert = 'Y'";
-         $rs = $this->db->getOne($sql);
-         return $rs['locale_id'];
-    }
-    function saveArtikel($data,$lang) {
-         $langID = $this->getLang(strtolower($lang));
-         $values = $this->translateTable($data,"tableerp"); //$this->tableerp);
-         if ($this->mwstLX and !$this->mwstS) { //ERP-Bruttopreis Shop-Nettopreis
-              $values['preis'] = round($values['preis'] / (1 + $values["mwst_satz"]),2);
-         } else if (!$this->mwstLX and $this->mwstS) { //ERP-Nettopreis Shop-Bruttopreis
-              $values['preis'] = round($values['preis'] * (1 + $values["mwst_satz"]),2);
-         }
-         $values["name"] = $this->_toShop($values["name"]);
-         $values["beschreibung"] = $this->_toShop($values["beschreibung"]);
-         $values["mwst_satz"] = $values["mwst_satz"] * 100;
-         $values["kategorie_id"] = $this->getCategoryID($data["partsgroup"],$values["mwst_satz"]);
-         $values["artikel_id"] = $this->checkArtikelOK($values["artikel_nr"]);  
-         if ($values["artikel_id"]>0)  {
-             $rc = $this->updateArtikel($values);
-         } else {
-             $rc = $this->insertArtikel($values);
-         };
-         return $rc;
-    }
-    function checkArtikelOK($nr) {
-        $sql = "SELECT artikel_id,artikel_nr FROM artikel WHERE artikel_nr = '".$nr."'";
-        $rs = $this->db->getOne($sql);
-        if ( $rs["artikel_nr"] == $nr ) {
-            return $rs["artikel_id"];
-        } else {
-            return false;
-        }
-    }
-    function insertArtikel($data) {
-        $newID = uniqid(rand());
-        $this->db->Begin();
-        $sql = "INSERT INTO artikel (artikel_nr,name) VALUES ('".$data["artikel_nr"]."','$newID')";
-        $rc = $this->db->query($sql);
-        $sql = "SELECT * FROM artikel WHERE name='$newID'";
-        $rs = $this->db->getOne($sql);
-        if ($rs['name'] == $newID) {
-            $data["artikel_id"] = $rs["artikel_id"];
-            $statement = "INSERT INTO artikel_kategorie (fk_artikel_id,fk_kategorie_id) VALUES (?,?)";
-            $values = array($rs["artikel_id"],$data["kategorie_id"]);
-            $rc = $this->db->insert($statement,$values);
-            if (!$rc) {
-                 $this->error->out($data['artikel_nr'].' konnte nicht zur Gruppe '.$data['kategorie_id'].' zugef&uuml;gt werden.');
-                 $this->error->write('pepper',$data['artikel_nr'].' konnte nicht zur Gruppe '.$data['kategorie_id'].' zugefügt werden.');
-                 $this->db->Rollback();
-                 return false;
-            }
-            $this->db->Commit();
-            $this->error->out($data['artikel_nr']." insert ",true);
-            $rc = $this->updateArtikel($data);
-        } else { return false; }
-        return $rc;
-    }
-    function updateArtikel($values) {
-        $sql  = "UPDATE artikel SET name = :name, beschreibung = :beschreibung, preis = :preis, gewicht = :gewicht, ";
-        if ( !$this->nofiles ) {
-             //vorhandene Bilder übertragen
-             if ( $values['bild_gross'] != '' ) {
-                 preg_match("/(.+)\.(jpg|png|jpeg|gif)/i",$values['bild_gross'],$tmp);
-                 $sql .= "bild_gross = :bild_gross, bild_klein = :bild_klein, bildtyp = :bildtyp, ";
-                 if ( count($tmp) == 3 ) {
-                     if ( $this->pic &&  $this->pic->copyImage($values['artikel_id'],$values['bild_gross'],$tmp[2]) ) {
-                         $values['bild_gross'] = $values['artikel_id']."_gr.".$tmp[2];
-                         $values['bild_klein'] = $values['artikel_id']."_kl.".$tmp[2];
-                         $values['bildtyp'] = $tmp[2];
-                     } else if ( $this->nopic ){
-                         $sql .= "bild_gross = :bild_gross, bild_klein = :bild_klein, bildtyp = :bildtyp, ";
-                         $values['bild_gross'] = $this->nopic."_gr.jpg";
-                         $values['bild_klein'] = $this->nopic."_kl.jpg";
-                         $values['bildtyp'] = 'jpg';
-                     }
-                 } 
-             } else if ( $this->nopic && !$this->nopicerr ){
-                 $sql .= "bild_gross = :bild_gross, bild_klein = :bild_klein, bildtyp = :bildtyp, ";
-                 $values['bild_gross'] = $this->nopic."_gr.jpg";
-                 $values['bild_klein'] = $this->nopic."_kl.jpg";
-                 $values['bildtyp'] = 'jpg';
-             }
-        }
-        $sql .= "mwst_satz = :mwst_satz, anzahl_einheit = :anzahl_einheit ";
-        //Kein Lagerbestand übergeben, also nichts ändern
-        if ( $values['lagerbestand'] != '' ) $sql .= ",lagerbestand = :lagerbestand ";
-        $sql .= "WHERE artikel_id = :artikel_id ";
-        $rc = $this->db->update($sql,$values);
-        if ($rc) { 
-            return $values["artikel_id"];
-        } else {
-            return false;
-        }
-    }
-    function getBestellung($employee_id) {
-        $sql = "SELECT * FROM mehrwertsteuer WHERE beschreibung = 'Porto und Verpackung'";
-        $rs = $this->db->getOne($sql);
-        $versandsteuer = $rs["mwst_satz"];
-        $sql = "SELECT * FROM bestellung WHERE bestellung_bezahlt='N' ";
-        $sql .= "AND rechnungs_nr != '' AND session_id = '' ";
-        $sql .= 'ORDER BY bestellungs_id';
-        $rs=$this->db->getAll($sql);
-        if (!$rs) return array(); 
-        $data = false; 
-        foreach ($rs as $row) {
-             $tmp = $this->getBestellArtikel($row["bestellungs_id"]);
-             $artikel = $tmp['data'];
-             if ($versandsteuer == -2) $versandsteuer = $tmp['mwst'];
-             if ($row["versandkosten"]>0) {
-                 if ($versandsteuer ==  $this->versandV['TAX']) {
-                     $artikel[]  = array("partnumber"=>$this->versandV['NR'],"description"=>$this->versandV['TXT'],
-                                          "qty"=>1,"unit"=>$this->versandV['Unit'],"sellprice"=>$row["versandkosten"]);
-                 } else {
-                     $artikel[]  = array("partnumber"=>$this->versandS['NR'],"description"=>$this->versandS['TXT'],"taxrate"=>$this->versandS['TAX'],
-                                          "qty"=>1,"unit"=>$this->versandS['Unit'],"sellprice"=>$row["versandkosten"]);
-                 }
-             }
-             if ($row["nachnamebetrag"]>0) 
-                 $artikel[] = array("partnumber"=>$this->nachn['NR'],"description"=>$this->nachn['TXT'],"taxrate"=>$this->nachn['TAX'],
-                                    "qty"=>1,"unit"=>$this->nachn['Unit'],"sellprice"=>$row["nachnamebetrag"]);
-             if ($row["paypalkosten"]>0) 
-                 $artikel[]   = array("partnumber"=>$this->paypal['NR'],"description"=>$this->paypal['TXT'],"taxrate"=>$this->paypal['TAX'],
-                                      "qty"=>1,"unit"=>$this->paypal['Unit'],"sellprice"=>round($row["paypalkosten"],2));
-             if ($row["treuhandkosten"]>0) 
-                 $artikel[] = array("partnumber"=>$this->treuhand['NR'],"description"=>$this->treuhand['TXT'],"taxrate"=>$this->treuhand['TAX'],
-                                      "qty"=>1,"unit"=>$this->treuhand['Unit'],"sellprice"=>$row["treuhandkosten"]);
-             if ($row["mindermengenzuschlag"]>0) 
-                 $artikel[] = array("partnumber"=>$this->minder['NR'],"description"=>$this->minder['TXT'],"taxrate"=>$this->minder['TAX'],
-                                    "qty"=>1,"unit"=>$this->minder['Unit'],"sellprice"=>$row["mindermengenzuschlag"]);
-             if ($row["versandland_id"] == "DE") {
-                 $taxzone_id = 0;
-             } else if (in_array($this->EU,$row["versandland_id"])) {
-                 if (preg_match('/^[^0-9]{2,3}[ 0-9]+$/',$row["customer"]['ustid'])) {
-                     $taxzone_id = 1;
-                 } else {
-                     $taxzone_id = 2;
-                 }
-             } else {
-                 $taxzone_id = 3;
-             }
-             if ($row["kreditkarten_nummer"]) {
-                 $row["kreditkarte"] = $row['kreditkarten_hersteller']."\n";
-                 $row["kreditkarte"] = $row['kreditkarten_nummer']." ID:".$row['kreditkarten_id']."\n";
-                 $row["kreditkarte"] = $row['kreditkarten_ablaufdatum']."\n";
-                 $row["kreditkarte"] = $row['kreditkarten_vorname']." ".$row['kreditkarten_nachname']."\n";
-             }
-             $row["versandart"] = $this->_toERP($row["versandart"]);
-             $row = $this->translateTable($row,"tableshop");
-             $row["taxzone_id"] = $taxzone_id;
-             $row["notes"] = $this->_toERP($row["notes"]);
-             $row["employee_id"] = $employee_id;
-             $row["parts"] = $artikel;
-             $row["mwst"] = round($row["mwst"],2);
-             $row["amount"]= round($row["amount"],2);
-             $row["netamount"] = $row["amount"] - $row["mwst"];
-             $row["customer"] = $this->getBestellungKunde($row["cusordnumber"]);
-             $data[] = $row;
-        }
-        return $data;
-    }
-    function getBestellungKunde($bestellung) {
-        $sql  = "SELECT * FROM kunde LEFT JOIN bestellung_kunde ON Kunden_ID=FK_Kunden_ID ";
-        $sql .= "WHERE  FK_Bestellungs_ID=$bestellung";
-        $rs=$this->db->getOne($sql);
-        if ($rs["firma"]) {
-            $rs["kontakt"] = $this->_toERP($rs["vorname"]." ".$rs["nachname"]);
-            $rs["firma"]  = $this->_toERP($rs["firma"]);
-        } else {
-            $rs["kontakt"] = $this->_toERP($rs["vorname"]." ".$rs["nachname"]);
-            $rs["firma"] = $this->_toERP($rs["nachname"].", ".$rs["vorname"]);
-        }
-        $rs["strasse"] = $this->_toERP($rs["strasse"])." ".$rs['hausnummer'];
-        $rs["ort"] = $this->_toERP($rs["ort"]);
-        $rs["bankname"] = $this->_toERP($rs["bankname"]);
-        if ($rs) {
-            return $this->translateTable($rs,"custshop");
-        } else {
-            $this->error->write("pepper","Die Kunde der Bestellung $bestellung konnte nicht gelesen werden");
-            return false;
-        }
-    }
-    function getBestellArtikel($bestellung) {
-        if (!$this->kategorien) $this->getKategorien();
-        $sql  = "SELECT B.*,P.artikel_nr,P.beschreibung,P.mwst_satz,P.anzahl_einheit,P.bild_gross,";
-        $sql .= "AK.fk_kategorie_id as partsgroup ";
-        $sql .= "FROM artikel_bestellung B LEFT JOIN artikel P ";
-        $sql .= "ON B.fk_artikel_id=P.artikel_id LEFT JOIN artikel_kategorie AK on AK.fk_artikel_id=P.artikel_id ";
-        $sql .= "WHERE fk_bestellungs_id=".$bestellung;
-        $rs=$this->db->getAll($sql);
-        if (!$rs) {
-             $this->error->write("pepper","Die Artikel der Bestellung $bestellung konnte nicht gelesen werden");
-             return false;
-        }
-        $a_b_ID = array();
-        foreach ($rs as $row) {
-            if (in_array($row['a_b_id'],$a_b_ID)) continue; 
-            $row['artikelname'] = $this->_toERP($row['artikelname']);
-            $row['beschreibung'] = $this->_toERP($row['beschreibung']);
-            if ($row['variation'] != '') {
-                  $tmp = $this->splitVariant($row['variation'],$row['anzahl'],$row['fk_artikel_id']);
-                  $row['artikelname'] .= $this->_toERP($tmp['text']);
-                  $row['preis'] += $tmp['preis'];
-                  if ($tmp['nr']) $row['artikel_nr'] .= '-'.$tmp['nr'];
-            }
-            if ($row['optionen'] != '') {
-                  $tmp = $this->splitOption($row['optionen'],$row['anzahl']);
-                  $row['artikelname'] .= $this->_toERP($tmp['text']);
-                  $row['preis'] += $tmp['preis'];
-            }
-            $row['anzahl_einheit'] = $this->_toERP($row['anzahl_einheit']);
-            $row['partsgroup'] = $this->_toERP($this->Kategorien[$row['partsgroup']]);
-            $mwst[$row['mwst_satz']] = $row['preis'] * $row['anzahl'] / (100+$row['mwst_satz']) * 100;
-            $data[] = $this->translateTable($row,"orderparts");
-            $a_b_ID[] = $row['a_b_id'];
-        }
-        arsort($mwst);
-        $tmp = each($mwst); //MwSt-Satz mit grösstem Anteil
-        return array('data'=>$data,'mwst'=>$tmp['key']);
-    }
-    function splitVariant($txt,$qty,$artnr) {
-          $vari=split(chr(254),$txt);
-          $text = '';
-          $preis = 0;
-          if ($vari) { 
-              for($cnt=0; $cnt<count($vari); $cnt++) {
-                  $nr = false;
-                  $tmp = split('<::>',$vari[$cnt]);
-                  if ($this->VariantNr) {
-                      //$nr = $this->_getVariantNr($tmp[0],$tmp[1],$artnr);
-                      $sql  = 'SELECT variations_nr FROM artikel_variationen where fk_artikel_id = '.$artnr;
-                      $sql .= ' and variationstext = \''.$tmp[1].'\' and variations_grp = (';
-                      $sql .= 'SELECT gruppen_nr FROM artikel_variationsgruppen WHERE fk_artikel_id = '.$artnr;
-                      $sql .= ' AND gruppentext = \''.$tmp[0].'\')';
-                      $rs=$this->db->getOne($sql);
-                      $nr = $rs['variations_nr'];
-                  } 
-                  //$text.="\n".$tmp[0].": ".$tmp[1];
-                  $text.=", ".$tmp[0].": ".$tmp[1];
-                  $cnt++;
-                  $preis+=trim($vari[$cnt]) * $qty;
-              }
-          };
-          return array("preis"=>$preis,"text"=>$text,"nr"=>$nr);
-    }
-    function splitOption($txt,$qty) {
-          $vari=split(chr(254),$txt);
-          $text = '';
-          $preis = 0;
-          if ($vari) { 
-              for($cnt=0; $cnt<count($vari); $cnt++) {
-                  $text.="\n".str_replace('<::>',': ',$vari[$cnt]);
-                  $cnt++;
-                  $preis+=trim($vari[$cnt]) * $qty;
-              }
-          };
-          return array("preis"=>$preis,"text"=>$text);
-    }
-    function setAbgeholt($bestellung) {
-        $sql = "UPDATE bestellung SET Bestellung_bezahlt='Y' WHERE Bestellungs_ID = $bestellung"; // in ($bestellungen)";
-        $rc = $this->db->query($sql);
-        if (!$rc) {
-            $this->error->write("pepper","Die Bestellung $bestellung konnten nicht als abgeholt markiert werden");
-            return false;
-        } else {
-            return true;
-        }
-    }
-    function setKundenNr($id,$nr) {
-        $sql = "UPDATE kunde SET kunden_nr = '$nr' WHERE k_id = $id";
-        $rc = $this->db->query($sql);
-        if (!$rc) {
-            $this->error->write("pepper","Die Kundennummer $nr konnte nicht dem Kunden $id zugeordnet werden");
-            return false;
-        } else {
-            return true;
-        }
-    }
-    function getAllArtikel() {
-        if (!$this->Kategorien) $this->getKategorien();
-        $sql = "SELECT a.*,k.fk_kategorie_id as katid FROM artikel a LEFT JOIN artikel_kategorie k on a.artikel_id = k.fk_artikel_id";
-        $rs = $this->db->getAll($sql);
-        if ($rs) foreach ($rs as $row) {
-            $row['partsgroup'] = $this->_toERP($this->Kategorien[$row['katid']]);
-            $row['name'] = $this->_toERP($row['name']);
-            $row['beschreibung'] = $this->_toERP($row['beschreibung']);
-            $row['shoppreis'] = $row['preis'];
-            if (!$this->mwstLX) $row['preis'] = round(($row['preis'] / (100 + $row['mwst_satz']) * 100),$this->dezimal);
-            $data[] = $this->translateTable($row,"orderparts");
-        }
-        return $data;
-    }
-    function getKategorien() {
-        $sql = "SELECT kategorie_id,name,parent_id FROM kategorien WHERE parent_id >= 0 order by parent_id";
-        $rs = $this->db->getAll($sql);
-        if ($rs) {
-            foreach($rs as $row) { $this->katrs[$row['kategorie_id']] = $row;};
-            foreach($this->katrs as $row) {
-            if ($row['parent_id'] == '0') {
-                $name = $row['name'];
-            } else {
-                $name = $this->mkKategorien($row['kategorie_id'],'');
-            }
-            $this->Kategorien[$row['kategorie_id']] = $name;
-            }
-        }
-    }
-    function mkKategorien($id,$name) {
-        if ($this->katrs[$id]['parent_id'] == '0') {
-            if ($name) {
-                return $this->katrs[$id]['name'].'!'.$name;
-            } else {
-                return $this->katrs[$id]['name']."#";
-            }
-        } else {
-            if (!$name) {
-            $name = $this->katrs[$id]['name'];
-        } else {
-            $name = $this->katrs[$id]['name'].'!'.$name;
-        }
-            $name = $this->mkKategorien($this->katrs[$id]['parent_id'],$name);
-        }
-        return $name;
-    }
-}
-?>
diff --git a/shopxtc/ArtikelErpToShop.php b/shopxtc/ArtikelErpToShop.php
deleted file mode 100755 (executable)
index f22d150..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-<?php
-
-$debug = False;
-
-$api = php_sapi_name();
-if ( $api != "cli" ) {
-    echo "<html>\n<head>\n<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>\n</head>\n<body>\n";
-    @apache_setenv('no-gzip', 1);
-    @ini_set('zlib.output_compression', 0);
-    @ini_set('implicit_flush', 1);
-    $shopnr = $_GET["Shop"];
-    //$nofiles = ( $_GET["nofiles"] == '1' )?true:false;
-} else {
-    if ( $argc > 1 ) {
-        $tmp = explode("=",trim($argv[1]));
-        if ( count($tmp) != 2 ) {
-            echo "Falscher Aufruf: php <scriptname.php> shop=1\n";
-            exit (-1);
-        } else {
-            $shopnr = $tmp[1];
-        }
-    }
-}
-
-include_once("conf$shopnr.php");
-include_once("error.php");
-//Fehlerinstanz
-$err = new error($api);
-
-include_once("dblib.php");
-include_once("xtc.php");
-include_once("erplib.php");
-include_once("PictureXTC.php");
-
-
-//Bilder
-$pict = new picture($ERPftphost,$ERPftpuser,$ERPftppwd,$ERPimgdir,$SHOPftphost,$SHOPftpuser,$SHOPftppwd,$SHOPimgdir,$err);
-//$pict->original = false;
-
-//ERP-Instanz
-$erpdb = new mydb($ERPhost,$ERPdbname,$ERPuser,$ERPpass,$ERPport,'pgsql',$err,$debug);
-if ($erpdb->db->connected_database_name == $ERPdbname) {
-    $erp = new erp($erpdb,$err,$divStd,$divVerm,$auftrnr,$kdnum,$preA,$preK,$invbrne,$mwstLX,$OEinsPart,$lager,$pricegroup,$ERPusrID);
-} else {
-    $err->out('Keine Verbindung zur ERP',true);
-    exit();
-}
-//Shop-Instanz
-$shopdb = new mydb($SHOPhost,$SHOPdbname,$SHOPuser,$SHOPpass,$SHOPport,'mysql',$err,$debug);
-if ($shopdb->db->connected_database_name == $SHOPdbname) {
-     $shop = new xtc($shopdb,$err,$SHOPdbname,$divStd,$divVerm,$minder,$nachn,$versandS,$versandV,$paypal,$treuhand,$mwstLX,$mwstS,$variantnr,$unit,$pict,$nopic,$nopicerr,$nofiles);
-} else {
-    $err->out('Keine Verbindung zum Shop',true);
-    exit();
-}
-$artikel = $erp->getParts($pricegroup);
-$cnt = 0;
-$errors = 0;
-if ( $api != 'cli' ) ob_start();
-
-$err->out("Artikelexport für Shop $shopnr",true);
-
-if ($artikel) foreach ($artikel as $row) {
-    $rc = $shop->saveArtikel($row,"de");
-    if ($rc) { 
-       $cnt++;
-       if ( $cnt % 10 == 0 ) $err->out(".");  
-    } else {
-       $errors++;
-    }
-}
-$err->out('',true);
-$err->out("$cnt Artikel übertragen, $errors Artikel nicht",true);
-if ( $api != "cli" ) {
-    echo "</body>\n</html>\n";
-}
-?>
diff --git a/shopxtc/ArtikelShopToErp.php b/shopxtc/ArtikelShopToErp.php
deleted file mode 100755 (executable)
index 5b6a09a..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-<?php
-
-$debug = true;
-
-$api = php_sapi_name();
-if ( $api != "cli" ) {
-    echo "<html>\n<head>\n<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>\n</head>\n<body>\n";
-    @apache_setenv('no-gzip', 1);
-    @ini_set('zlib.output_compression', 0);
-    @ini_set('implicit_flush', 1);
-    $shopnr = $_GET["Shop"];
-    $nofiles = ( $_GET["nofiles"] == '1' )?true:false;
-} else {
-    if ( $argc > 1 ) {
-        $tmp = explode("=",trim($argv[1]));
-        if ( count($tmp) != 2 ) {
-             echo "Falscher Aufruf: php <scriptname.php> shop=1\n";
-             exit (-1);
-         } else {
-              $shopnr = $tmp[1];
-         }
-    }
-}
-
-include_once("conf$shopnr.php");
-include_once("error.php");
-//Fehlerinstanz
-$err = new error($api);
-
-include_once("dblib.php");
-include_once("xtc.php");
-include_once("erplib.php");
-
-
-
-//ERP-Instanz
-$erpdb = new mydb($ERPhost,$ERPdbname,$ERPuser,$ERPpass,$ERPport,'pgsql',$err,$debug);
-if ($erpdb->db->connected_database_name == $ERPdbname) {
-    $erp = new erp($erpdb,$err,$divStd,$divVerm,$auftrnr,$kdnum,$preA,$preK,$invbrne,$mwstLX,$OEinsPart,$lager,$pricegroup,$ERPusrID);
-} else {
-    $err->out('Keine Verbindung zur ERP',true);
-    exit();
-}
-
-//Shop-Instanz
-$shopdb = new mydb($SHOPhost,$SHOPdbname,$SHOPuser,$SHOPpass,$SHOPport,'mysql',$err,$debug);
-if ($shopdb->db->connected_database_name == $SHOPdbname) {
-     $shop = new xtc($shopdb,$err,$SHOPdbname,$divStd,$divVerm,$minder,$nachn,$versandS,$versandV,$paypal,$treuhand,$mwstLX,$mwstS,$variantnr,$unit);
-} else {
-    $err->out('Keine Verbindung zum Shop',true);
-    exit();
-}
-
-$artikel = $shop->getAllArtikel();
-echo "<pre>"; print_r($artikel); echo "</pre>";
-$cnt = 0;
-$errors = 0;
-//Artikel die mehreren Warengruppen zugeordnet sind, werden nur einmal importiert.
-//Es wird dann auch nur die erste Warengruppe angelegt.
-if ( $api != 'cli' ) ob_start();
-
-$err->out("Artikelimport von Shop $shopnr",true);
-
-if ($artikel) foreach ($artikel as $row) {
-     $rc = $erp->chkPartnumber($row,true);
-     if ($rc) { 
-       $cnt++;
-     } else { 
-        $err->out('Fehler: '.$row['partnumber'],true);
-       $errors++;
-     }
-}
-$err->out('',true);
-$err->out("$cnt Artikel geprüft bzw. übertragen, $errors Artikel nicht",true);
-if ( $api != "cli" ) {
-    echo "</body>\n</html>\n";
-}
-?>
diff --git a/shopxtc/BestellungShopToErp.php b/shopxtc/BestellungShopToErp.php
deleted file mode 100755 (executable)
index f5f3048..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-<?php
-
-$debug = True;
-
-$api = php_sapi_name();
-if ( $api != "cli" ) {
-    echo "<html>\n<head>\n<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>\n</head>\n<body>\n";
-    @apache_setenv('no-gzip', 1);
-    @ini_set('zlib.output_compression', 0);
-    @ini_set('implicit_flush', 1);
-    $shopnr = $_GET["Shop"];
-    $nofiles = ( $_GET["nofiles"] == '1' )?true:false;
-} else {
-    if ( $argc > 1 ) {
-        $tmp = explode("=",trim($argv[1]));
-        if ( count($tmp) != 2 ) {
-            echo "Falscher Aufruf: php <scriptname.php> shop=1\n";
-            exit (-1);
-        } else {
-             $shopnr = $tmp[1];
-        }
-    }
-}
-
-include_once("conf$shopnr.php");
-include_once("error.php");
-//Fehlerinstanz
-$err = new error($api);
-include_once("dblib.php");
-include_once("xtc.php");
-include_once("erplib.php");
-
-$err->out("Shop $shopnr, Bestellimport",true);
-
-//ERP-Instanz
-$erpdb = new mydb($ERPhost,$ERPdbname,$ERPuser,$ERPpass,$ERPport,'pgsql',$err,$debug);
-if ($erpdb->db->connected_database_name == $ERPdbname) {
-    $erp = new erp($erpdb,$err,$divStd,$divVerm,$auftrnr,$kdnum,$preA,$preK,$invbrne,$mwstLX,$OEinsPart,$lager,$pricegroup,$ERPusrID);
-} else {
-    $err->out('Keine Verbindung zur ERP',true);
-    exit();
-}
-
-//Shop-Instanz
-$shopdb = new mydb($SHOPhost,$SHOPdbname,$SHOPuser,$SHOPpass,$SHOPport,'mysql',$err,$debug);
-if ($shopdb->db->connected_database_name == $SHOPdbname) {
-     $shop = new xtc($shopdb,$err,$SHOPdbname,$divStd,$divVerm,$minder,$nachn,$versandS,$versandV,$paypal,$mwstLX,$mwstS,$variantnr,$unit);
-} else {
-    $err->out('Keine Verbindung zum Shop',true);
-    exit();
-}
-
-$bestellungen = $shop->getBestellung($ERPusrID);
-$cnt = 0;
-$errors = 0;
-
-$err->out("Bestellimport vom Shop $shopnr",true);
-
-if ($bestellungen) foreach ($bestellungen as $row) {
-    $rc = $erp->mkAuftrag($row,$shopnr,$longtxt);
-    echo "!$rc!";
-    if ($rc>0) {
-        $rc = $shop->setKundenNr($row['customer']['shopid'],$rc);
-        if ($rc>0) {
-           $shop->setAbgeholt($row['cusordnumber']); 
-           $cnt++;
-           $err->out("ok",true);
-        } else {
-           $errors++;
-           $err->out("Fehler setKdNr ".$row['customer']['shopid'],true);
-        }
-    } else if ($rc == -1) {
-           $errors++;
-           $err->out("Fehler mkAuftrag ".$row['cusordnumber'],true);
-    } else {
-        $err->out("Fehler Kunde zuordnen ".$row['customer']['shopid'].":".$row['cusordnumber'],true);
-        $errors++;
-    } 
-}
-$err->out('Von '.count($bestellungen)." Bestellungen $cnt übertragen, $errors nicht",true);
-if ( $api != "cli" ) {
-    echo "<br /><a href='../oe.pl?vc=customer&type=sales_order&nextsub=orders&action=Weiter&open=1&notdelivered=1&delivered=1&l_ordnumber=Y&l_transdate=Y&l_reqdate=1&l_name=Y&l_employee=Y&l_amount=Y'>Auftragsliste</a>";
-    echo "</body>\n</html>\n";
-}
-
-?>
diff --git a/shopxtc/LiesMich.txt b/shopxtc/LiesMich.txt
deleted file mode 100755 (executable)
index 13d294c..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-Varianten können in LxO eigene Artikelnummern haben.
-Die Artikelnummer wird dann automatisch ergänzt um "-" und die Variarions-ID.
-Aus "A1001" wird z.B. "A1001-1" für die erste (Standard) Variante.
-Variations-IDs MÜSSEN!! Lückenlos bei 1 beginnen, da sonst der Shop ins Schleudern kommt!!!!!
-
-Preise werden berechnet: Grundpreis + Preis für die Variante
-Text wird ergänzt: Standardtext + ", Variantengruppe: Variante"
-
-Ein beschreibbares Verzeichnis "tmp" wird als Unterverzeichnis erwartet. 
-z.B.:
-ln -s /tmp
-
-Wenn ein Platzhalterbild eingesetzt werden soll, so muß das Bild zuerst auf 
-den Shopserver übertragen werden.
-<bildname>.jpg 
-
-Dann den Namen <bildname> in der Maske eintragen. Man kann bestimmen, ob
-das Bild immer genommen wird, wenn kein Bild angegeben wird oder nur wenn
-der Upload schief gegangen ist.
-
-Artikelexport (Lx -> Shop) kann ohne Bilderupload durchgeführt werden.
-Spart Bandbreite und Zeit, wenn nur Updates gemacht werden.
-Parameterübergabe:  nofiles=1
-[Shop--Warenexport]
-module=shopxtc/ArtikelErpToShop.php
-nofiles=1
-
-Shop ist Mehrshopfähig. Shopnummer muß beim Aufruf übergeben werden:
-Shop=1
-
-Die Im-/Exportmodule lassen sich auch auf der Konsole oder per Cron-Job aufrufen:
-
-php ArtikelShopToErp.php shop=1 > /tmp/export.log
diff --git a/shopxtc/PictureXTC.php b/shopxtc/PictureXTC.php
deleted file mode 100644 (file)
index 7bd6c96..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-<?php
-
-
-class picture {
-
-    var $popupwidth = 800;
-    var $infowidth = 150;
-    var $thumbwidth = 80;
-    var $err = false;
-
-    function picture($ERPhost,$ERPuser,$ERPpass,$ERPimgdir,$SHOPhost,$SHOPuser,$SHOPpass,$SHOPimgdir,$err) {
-        $this->ERPftphost = $ERPhost;
-        $this->ERPftpuser = $ERPuser;
-        $this->ERPftppwd = $ERPpass;
-        $this->ERPimgdir = $ERPimgdir;
-        $this->SHOPftphost = $SHOPhost;
-        $this->SHOPftpuser = $SHOPuser;
-        $this->SHOPftppwd = $SHOPpass;
-        $this->SHOPimgdir = $SHOPimgdir;
-        $this->err = $err;
-    }
-
-    function copyImage($id,$image,$typ) {
-        if ( !$this->fromERP($image) ) return false;
-        if ( !$this->mkbilder() ) return false;
-        return $this->toShop($id,$typ);
-    }
-
-    function mkbilder() {
-        if ( !class_exists("Imagick") ) { $this->err->out("Imagick-Extention nicht installiert",true); return false; };
-        $handle = new Imagick();
-        if ( !$handle->readImage("./tmp/tmp.file_org") ) return false;
-        $d = $handle->getImageGeometry();
-        if ( $d["width"]<$d["height"] ) {
-            $faktor = $d["height"]/$d["width"];
-        } else {
-            $faktor = $d["width"]/$d["height"];
-        }
-
-        $thumbheight = floor($this->thumbwidth*$faktor);
-        $handle->thumbnailImage($this->thumbwidth, $thumbheight);
-        $rc = $handle->writeImage( "./tmp/tmp.file_thumb");
-
-        $handle->readImage("./tmp/tmp.file_org");
-        $popupheight = floor($this->popupwidth * $faktor);
-        $handle->thumbnailImage( $this->popupwidth, $popupheight);
-        $rc = $handle->writeImage( "./tmp/tmp.file_popup");
-
-        $handle->readImage("./tmp/tmp.file_org");
-        $infoheight = floor($this->infowidth * $faktor);
-        $handle->thumbnailImage( $this->infowidth, $infoheight);
-        $rc = $handle->writeImage( "./tmp/tmp.file_info");
-        return $rc;
-    }
-
-    function fromERP($image) {
-        if ( $this->ERPftphost == 'localhost' ) {
-            exec("cp $this->ERPimgdir/$image ./tmp/tmp.file_org",$aus,$rc2);
-            if ( $rc2>0 ) { $this->err->out("[Downloadfehler: $image]",true); return false; };
-        } else {
-            $conn_id = ftp_connect($this->ERPftphost);
-            $rc = @ftp_login($conn_id,$this->ERPftpuser,$this->ERPftppwd);
-            $src = $this->ERPimgdir."/".$image;
-            $upload = @ftp_get($conn_id,"tmp/tmp.file_org","$src",FTP_BINARY);
-            if ( !$upload ) { $this->err->out("[Ftp Downloadfehler! $image]",true); return false; };
-            ftp_quit($conn_id);
-        }
-        $this->image = $image;
-        return true;
-    }
-
-    function toShop($id,$typ) {
-        $picname = $id."_0.".$typ;
-        if ( $this->SHOPftphost == 'localhost' ) {
-            exec("cp ./tmp/tmp.file_org   $this->SHOPimgdir/original_images/$picname",$aus,$rc1);
-            exec("cp ./tmp/tmp.file_info  $this->SHOPimgdir/info_images/$picname",$aus,$rc2);
-            exec("cp ./tmp/tmp.file_popup $this->SHOPimgdir/popup_images/$picname",$aus,$rc3);
-            exec("cp ./tmp/tmp.file_thumb $this->SHOPimgdir/thumbnail_images/$picname",$aus,$rc4);
-            if ( $rc1>0 || $rc2>0 || $rc3>0 || $rc4>0 ) { $this->err->out("[Uploadfehler: $this->image / $picname]",true); return false; };
-        } else {
-            $conn_id = ftp_connect($this->SHOPftphost);
-            @ftp_login($conn_id,$this->SHOPftpuser,$this->SHOPftppwd);
-            @ftp_chdir($conn_id,$this->SHOPimgdir);
-            $upload = @ftp_put($conn_id,$this->SHOPimgdir."/original_images/$picname","tmp/tmp.file_org",FTP_BINARY);
-            if ( !$upload ) { $this->err->out("[Ftp Uploadfehler! original_images/$picname]",true); return false; };
-            $upload = @ftp_put($conn_id,$this->SHOPimgdir."/info_images/$picname","tmp/tmp.file_info",FTP_BINARY);
-            if ( !$upload ) { $this->err->out("[Ftp Uploadfehler! info_images/$picname]",true); return false; };
-            $upload = @ftp_put($conn_id,$this->SHOPimgdir."/popup_images/$picname","tmp/tmp.file_popup",FTP_BINARY);
-            if ( !$upload ) { $this->err->out("[Ftp Uploadfehler! popup_images/$picname]",true); return false; };
-            $upload = @ftp_put($conn_id,$this->SHOPimgdir."/thumbnail_images/$picname","tmp/tmp.file_thumb",FTP_BINARY);
-            if ( !$upload ) { $this->err->out("[Ftp Uploadfehler! thumb_images/$picname]",true); return false; };
-            @ftp_quit($conn_id);
-        }
-        return true;
-    }
-
-
-}
-?>
diff --git a/shopxtc/conf.php.default b/shopxtc/conf.php.default
deleted file mode 100644 (file)
index 77466ed..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-<?php
-// Verbindung zur ERP-db
-$ERPuser='lxoffice';
-$ERPpass='lxgeheim';
-$ERPhost='localhost';
-$ERPdbname='demo';
-$codeLX='UTF-8';
-$mwstLX='1';
-$ERPusrName='demo';
-$ERPusrID='';
-$ERPimgdir='/var/www/lx-office-erp';
-$maxSize='';
-$ERPftphost='localhost';
-$ERPftpuser='pepper';
-$ERPftppwd='pepper';
-//Verbindung zur osCommerce-db
-$SHOPuser='pepper';
-$SHOPpass='sehrgeheim';
-$SHOPhost='localhost';
-$SHOPdbname='Pepper';
-$codeS='UTF-8';
-$mwstS='1';
-$SHOPimgdir='/var/www/Pepper/shop/ProdukteBilder';
-$SHOPftphost='localhost';
-$SHOPftpuser='pepper';
-$SHOPftppwd='pepper';
-$nopic='nopic';
-$nopicerr='1';
-$divStd["ID"]='';
-$divStd["NR"]='divStd';
-$divStd["Unit"]='';
-$divStd["TXT"]='';
-$divStd["BUGRU"]='';
-$divStd["TAX"]='';
-$divVerm["ID"]='';
-$divVerm["NR"]='divVerm';
-$divVerm["Unit"]='';
-$divVerm["TXT"]='';
-$divVerm["BUGRU"]='';
-$divVerm["TAX"]='';
-$versandS["ID"]='';
-$versandS["NR"]='divStd';
-$versandS["Unit"]='';
-$versandS["TXT"]='Versandkosten';
-$versandS["BUGRU"]='';
-$versandS["TAX"]='';
-$versandV["ID"]='';
-$versandV["NR"]='divVerm';
-$versandV["Unit"]='';
-$versandV["TXT"]='Versandkosten';
-$versandV["BUGRU"]='';
-$versandV["TAX"]='';
-$minder["ID"]='';
-$minder["NR"]='divStd';
-$minder["Unit"]='';
-$minder["TXT"]='Mindermengenzuschlag';
-$minder["BUGRU"]='';
-$minder["TAX"]='';
-$nachn["ID"]='';
-$nachn["NR"]='';
-$nachn["Unit"]='';
-$nachn["TXT"]='';
-$nachn["BUGRU"]='';
-$nachn["TAX"]='';
-$treuh["ID"]='';
-$treuh["NR"]='';
-$treuh["Unit"]='';
-$treuh["TXT"]='Treuhandkosten';
-$treuh["BUGRU"]='';
-$treuh["TAX"]='';
-$paypal["ID"]='';
-$paypal["NR"]='divStd';
-$paypal["Unit"]='';
-$paypal["TXT"]='Paypalkosten';
-$paypal["BUGRU"]='';
-$paypal["TAX"]='';
-$bgcol[1]='#ddddff';
-$bgcol[2]='#ddffdd';
-$preA='G_';
-$preK='';
-$auftrnr='1';
-$kdnum='1';
-$pricegroup='';
-$unit='Stck';
-$longtxt='2';
-$invbrne='2';
-$variantnr='1';
-$OEinsPart='1';
-$lager='';
-?>
diff --git a/shopxtc/confedit.php b/shopxtc/confedit.php
deleted file mode 100755 (executable)
index 824c411..0000000
+++ /dev/null
@@ -1,457 +0,0 @@
-<?
-// $Id: confedit.php 2009/02/10 14:41:30 hli Exp $
-if (!isset($_SERVER['PHP_AUTH_USER'])) {
-       Header("WWW-Authenticate: Basic realm='Configurations-Editor'");
-       Header("HTTP/1.0 401 Unauthorized");
-       echo "Sie m&uuml;ssen sich autentifizieren\n";
-       exit;
-} else {
-        if (!$_POST) {
-               //Je Shop ein Conf-File == Multishop
-               $Shop=$_GET["Shop"];
-               if ($Shop != "" and file_exists ("conf$Shop.php")) {
-                       require "conf$Shop.php";
-                        $out = "Konfiguration für Shop $Shop gelesen";
-               } else {
-                        //Singleshop oder noch kein Shop definiert
-                       require "conf.php";
-                        $out = "Standard-Konfiguration gelesen";
-               }
-               if ($_SERVER['PHP_AUTH_USER']<>$ERPftpuser || $_SERVER['PHP_AUTH_PW']<>$ERPftppwd) {
-                       Header("WWW-Authenticate: Basic realm='My Realm'");
-                       Header("HTTP/1.0 401 Unauthorized");
-                       echo "Sie m&uuml;ssen sich autentifizieren\n";
-                       exit;
-               }
-                echo $out;
-       }
-}
-$debug = true;
-
-include_once("error.php");
-include_once("dblib.php");
-$api = php_sapi_name();
-if ( $api == 'cli' ) {
-    echo "Nur im Browser benutzen\n";
-    exit(-1);
-};
-$err = new error($api);
-
-$zeichen = array("","UTF-8","ISO-8859-1","ISO-8859-15","Windows-1252","ASCII");
-function lager($sel,$db) {
-        if (!$db) return '';
-        $sql  = "select w.description as lager,b.description as platz,b.id from ";
-        $sql .= "bin b left join warehouse w on w.id=b.warehouse_id ";
-        $sql .= "order by b.warehouse_id,b.id";
-       $bin=$db->getall($sql);
-        echo "\t<option value=-1 ".(($sel==-1)?'selected':'').">kein Lagerbestand\n";
-        echo "\t<option value=1 ".(($sel==1)?'selected':'').">Gesamtbestand\n";
-        if ($bin) foreach ($bin as $row) {
-               echo "\t<option value=".$row['id'];
-               if ($sel==$row['id']) echo " selected";
-               echo ">".$row['lager']." ".$row['platz']."\n";
-        }
-}
-function unit($sel,$db) {
-        if (!$db) return '';
-       $sql="select name from units order by sortkey";
-       $pgs=$db->getall($sql);
-       if ($sel=='') $sel=$pgs[0]['name'];
-       if ($pgs) foreach ($pgs as $row) {
-               echo "\t<option value=".$row['name'];
-               if ($sel==$row['name']) echo " selected";
-               echo ">".$row['name']."\n";
-       }
-}
-function pg($sel,$db) {
-        if (!$db) return '';
-       $sql="select id,pricegroup from pricegroup";
-       $pgs=$db->getall($sql);
-       echo "\t<option value=0";
-       if ($sel==0) echo " selected";
-       echo ">Standard VK\n";
-       if ($pgs) foreach ($pgs as $row) {
-               echo "\t<option value=".$row['id'];
-               if ($sel==$row['id']) echo " selected";
-               echo ">".$row['pricegroup']."\n";
-       }
-}
-function getTax($db) {
-    $sql  = "SELECT  BG.id AS bugru,T.rate,TK.startdate,C.taxkey_id, ";
-    $sql .= "(SELECT id FROM chart WHERE accno = T.taxnumber) AS tax_id, ";
-    $sql .= "BG.income_accno_id_0,BG.expense_accno_id_0 ";
-    $sql .= "FROM buchungsgruppen BG LEFT JOIN chart C ON BG.income_accno_id_0=C.id ";
-    $sql .= "LEFT JOIN taxkeys TK ON TK.chart_id=C.id ";
-    $sql .= "LEFT JOIN tax T ON T.id=TK.tax_id WHERE TK.startdate <= now()";
-    $rs = $db->getAll($sql);
-    if ($rs) foreach ($rs as $row) {
-        $nr = $row['bugru'];
-        if (!$TAX[$nr]) {
-            $data = array();
-            $data['startdate'] =    $row['startdate'];
-            $data['rate'] =        $row['rate']*100.0;
-            $TAX[$nr] = $data;
-        } else if ($TAX[$nr]['startdate'] < $row['startdate']) {
-            $TAX[$nr]["startdate"] =   $row['startdate'];
-            $TAX[$nr]["rate"] =        $row['rate']*100.0;
-        }
-    }
-    return $TAX;
-}
-function fputsA($f,$key,$var,$bg=false) {
-    $lf="\n";
-    fputs($f,'$'.$key.'["ID"]=\''. $var['ID'].'\';'.$lf);
-    fputs($f,'$'.$key.'["NR"]=\''. $var['NR'].'\';'.$lf);
-    fputs($f,'$'.$key.'["Unit"]=\''. $var['Unit'].'\';'.$lf);
-    fputs($f,'$'.$key.'["TXT"]=\''. $var['TXT'].'\';'.$lf);
-    if ($bg) fputs($f,'$'.$key.'["BUGRU"]=\''. $var['BUGRU'].'\';'.$lf);
-    if ($bg) fputs($f,'$'.$key.'["TAX"]=\''. $var['TAX'].'\';'.$lf);
-}
-if ($_POST["ok"]=="sichern") {
-       foreach ($_POST as $key=>$val) {
-               ${$key} = $val;
-       }
-};
-       $ok=true;
-       $dbP = new mydb($ERPhost,$ERPdbname,$ERPuser,$ERPpass,$ERPport,'pgsql',$err,$debug);
-       if (!$dbP->db) {
-               $ok=false;
-               echo "Keine Verbindung zur ERP<br>";
-               $dbP=false;             
-               unset($divStd['ID']);
-                unset($divVerm['ID']);
-                unset($minder['ID']);
-                unset($versand['ID']);
-                unset($nachn['ID']);
-                unset($paypal['ID']);
-               unset($ERPusr['ID']);
-       } else {
-                $tax = getTax($dbP);
-               $sql="SELECT id,description,unit,buchungsgruppen_id FROM parts where partnumber = '%s'";
-               $rs=$dbP->getOne(sprintf($sql,$divStd['NR']));
-               $divStd['ID']=$rs['id'];
-               $divStd['Unit']=$rs['unit'];
-               $divStd['BUGRU']=$rs['buchungsgruppen_id'];
-               $divStd['TAX']=$tax[$rs['buchungsgruppen_id']]['rate'];
-               $divStd['TXT']=addslashes($rs['description']);
-               $rs=$dbP->getOne(sprintf($sql,$divVerm['NR']));
-               $divVerm['ID']=$rs['id'];
-               $divVerm['Unit']=$rs['unit'];
-               $divVerm['BUGRU']=$rs['buchungsgruppen_id'];
-               $divVerm['TAX']=$tax[$rs['buchungsgruppen_id']]['rate'];
-               $divVerm['TXT']=addslashes($rs['description']);
-               $rs=$dbP->getOne(sprintf($sql,$versandS['NR']));
-               $versandS['ID']=$rs['id'];
-               $versandS['Unit']=$rs['unit'];
-               $versandS['BUGRU']=$rs['buchungsgruppen_id'];
-               $versandS['TAX']=$tax[$rs['buchungsgruppen_id']]['rate'];
-                if ($versandS['TXT'] == '') $versandS['TXT']=addslashes($rs['description']);
-               $rs=$dbP->getOne(sprintf($sql,$versandV['NR']));
-               $versandV['ID']=$rs['id'];
-               $versandV['Unit']=$rs['unit'];
-               $versandV['BUGRU']=$rs['buchungsgruppen_id'];
-               $versandV['TAX']=$tax[$rs['buchungsgruppen_id']]['rate'];
-                if ($versandV['TXT'] == '') $versandV['TXT']=addslashes($rs['description']);
-               $rs=$dbP->getOne(sprintf($sql,$nachn['NR']));
-               $nachn['ID']=$rs['id'];
-               $nachn['Unit']=$rs['unit'];
-               $nachn['BUGRU']=$rs['buchungsgruppen_id'];
-               $nachn['TAX']=$tax[$rs['buchungsgruppen_id']]['rate'];
-                if ($nachn['TXT'] == '') $nachn['TXT']=addslashes($rs['description']);
-               $rs=$dbP->getOne(sprintf($sql,$minder['NR']));
-               $minder['ID']=$rs['id'];
-               $minder['Unit']=$rs['unit'];
-               $minder['BUGRU']=$rs['buchungsgruppen_id'];
-               $minder['TAX']=$tax[$rs['buchungsgruppen_id']]['rate'];
-               if ($minder['TXT'] == '') $minder['TXT']=addslashes($rs['description']);
-               $rs=$dbP->getOne(sprintf($sql,$paypal['NR']));
-               $paypal['ID']=$rs['id'];
-               $paypal['Unit']=$rs['unit'];
-               $paypal['BUGRU']=$rs['buchungsgruppen_id'];
-               $paypal['TAX']=$tax[$rs['buchungsgruppen_id']]['rate'];
-               if ($paypal['TXT'] == '') $paypal['TXT']=addslashes($rs['description']);
-               $rs=$dbP->getOne("select id from employee where login = '".$ERPusrName."'");
-               $ERPusrID=$rs['id'];
-       }
-        $dbM = new mydb($SHOPhost,$SHOPdbname,$SHOPuser,$SHOPpass,$SHOPport,'mysql',$err,$debug);
-       if (!$dbM->db) {
-               $ok=false;
-               echo "Keine Verbindung zum Shop<br>";
-               $dbM=false;
-       };              
-if ($_POST["ok"]=="sichern") {
-        $lf="\n";
-       $f=@fopen("conf$Shop.php","w");
-        if ($f) {
-       $v="1.5";
-       $d=date("Y/m/d H:i:s");
-       fputs($f,"<?php$lf// Verbindung zur ERP-db$lf");
-       fputs($f,'$ERPuser=\''.$ERPuser.'\';'.$lf);
-       fputs($f,'$ERPpass=\''.$ERPpass.'\';'.$lf);
-       fputs($f,'$ERPhost=\''.$ERPhost.'\';'.$lf);
-       fputs($f,'$ERPport=\''.$ERPport.'\';'.$lf);
-       fputs($f,'$ERPdbname=\''.$ERPdbname.'\';'.$lf);
-       fputs($f,'$codeLX=\''.$codeLX.'\';'.$lf);
-       fputs($f,'$mwstLX=\''.$mwstLX.'\';'.$lf);
-       fputs($f,'$ERPusrName=\''.$ERPusrName.'\';'.$lf);
-       fputs($f,'$ERPusrID=\''.$ERPusrID.'\';'.$lf);
-       fputs($f,'$ERPimgdir=\''.$ERPimgdir.'\';'.$lf);
-       fputs($f,'$maxSize=\''.$maxSize.'\';'.$lf);
-       fputs($f,'$ERPftphost=\''.$ERPftphost.'\';'.$lf);
-       fputs($f,'$ERPftpuser=\''.$ERPftpuser.'\';'.$lf);
-       fputs($f,'$ERPftppwd=\''.$ERPftppwd.'\';'.$lf);
-       fputs($f,'//Verbindung zur osCommerce-db'.$lf);
-       fputs($f,'$SHOPuser=\''.$SHOPuser.'\';'.$lf);
-       fputs($f,'$SHOPpass=\''.$SHOPpass.'\';'.$lf);
-       fputs($f,'$SHOPhost=\''.$SHOPhost.'\';'.$lf);
-       fputs($f,'$SHOPport=\''.$SHOPport.'\';'.$lf);
-       fputs($f,'$SHOPdbname=\''.$SHOPdbname.'\';'.$lf);
-       fputs($f,'$codeS=\''.$codeS.'\';'.$lf);
-       fputs($f,'$mwstS=\''.$mwstS.'\';'.$lf);
-       fputs($f,'$SHOPimgdir=\''.$SHOPimgdir.'\';'.$lf);
-       fputs($f,'$SHOPftphost=\''.$SHOPftphost.'\';'.$lf);
-       fputs($f,'$SHOPftpuser=\''.$SHOPftpuser.'\';'.$lf);
-       fputs($f,'$SHOPftppwd=\''.$SHOPftppwd.'\';'.$lf);
-       fputs($f,'$nopic=\''.$nopic.'\';'.$lf);
-       fputs($f,'$nopicerr=\''.$nopicerr.'\';'.$lf);
-       fputs($f,'$nofiles=\''.$nofiles.'\';'.$lf);
-        fputsA($f,'divStd',$divStd,true);
-        fputsA($f,'divVerm',$divVerm,true);
-        fputsA($f,'versandS',$versandS,true);
-        fputsA($f,'versandV',$versandV,true);
-        fputsA($f,'minder',$minder,true);
-        fputsA($f,'nachn',$nachn,true);
-        fputsA($f,'paypal',$paypal,true);
-       fputs($f,'$bgcol[1]=\'#ddddff\';'.$lf);
-       fputs($f,'$bgcol[2]=\'#ddffdd\';'.$lf);
-       fputs($f,'$preA=\''.$preA.'\';'.$lf);
-       fputs($f,'$preK=\''.$preK.'\';'.$lf);
-       fputs($f,'$auftrnr=\''.$auftrnr.'\';'.$lf);
-       //fputs($f,'$utftrans=\''.$utftrans.'\';'.$lf);
-       fputs($f,'$kdnum=\''.$kdnum.'\';'.$lf);
-       fputs($f,'$pricegroup=\''.$pricegroup.'\';'.$lf);
-       fputs($f,'$unit=\''.$unit.'\';'.$lf);
-       fputs($f,'$longtxt=\''.$longtxt.'\';'.$lf);
-       fputs($f,'$invbrne=\''.$invbrne.'\';'.$lf);
-       fputs($f,'$variantnr=\''.$variantnr.'\';'.$lf);
-       fputs($f,'$OEinsPart=\''.$OEinsPart.'\';'.$lf);
-       fputs($f,'$lager=\''.$lager.'\';'.$lf);
-       //fputs($f,'$showErr=true;'.$lf);
-       fputs($f,"?>");
-       fclose($f);
-        echo "Konfiguration conf$Shop.php gesichert.";
-        } else {
-             echo "Konfigurationsdatei (conf$Shop.php) konnte nicht geschrieben werden";
-        }
-} 
-?>
-<html>
-<body>
-<center>
-<table style="background-color:#cccccc" border="0">
-<form name="ConfEdit" method="post" action="confedit.php">
-<input type="hidden" name="Shop" value="<?= $Shop ?>">
-<input type="hidden" name="divStd[ID]" value="<?= $divStd['ID'] ?>">
-<input type="hidden" name="divVerm[ID]" value="<?= $divVerm['ID'] ?>">
-<input type="hidden" name="minder[ID]" value="<?= $minder['ID'] ?>">
-<input type="hidden" name="versandS[ID]" value="<?= $versandS['ID'] ?>">
-<input type="hidden" name="versandV[ID]" value="<?= $versandV['ID'] ?>">
-<input type="hidden" name="nachn[ID]" value="<?= $nachn['ID'] ?>">
-<input type="hidden" name="paypal[ID]" value="<?= $paypal['ID'] ?>">
-<input type="hidden" name="ERPusr[ID]" value="<?= $ERPusr['ID'] ?>">
-
-<tr><th>Daten</th><th>Lx-ERP</th><th><?php echo $Shop ?></th><th>Shop</th></tr>
-<tr>
-       <td>db-Host</td>
-       <td colspan="2"><input type="text" name="ERPhost" size="25" value="<?= $ERPhost ?>"></td>
-       <td><input type="text" name="SHOPhost" size="25" value="<?= $SHOPhost ?>"></td>
-</tr>
-<tr>
-       <td>Database</td>
-       <td colspan="2"><input type="text" name="ERPdbname" size="20" value="<?= $ERPdbname ?>"></td>
-       <td><input type="text" name="SHOPdbname" size="20" value="<?= $SHOPdbname ?>"></td>
-</tr>
-<tr>
-        <td>db-Port</td>
-        <td colspan="2"><input type="text" name="ERPport" size="25" value="<?= $ERPport ?>"></td>
-        <td><input type="text" name="SHOPport" size="25" value="<?= $SHOPport ?>"></td>
-</tr>
-<tr>
-       <td>db-User Name</td>
-       <td colspan="2"><input type="text" name="ERPuser" size="15" value="<?= $ERPuser ?>"></td>
-       <td><input type="text" name="SHOPuser" size="15" value="<?= $SHOPuser ?>"></td>
-</tr>
-<tr>
-       <td>db-User PWD</td>
-       <td colspan="2"><input type="text" name="ERPpass" size="15" value="<?= $ERPpass ?>"></td>
-       <td><input type="text" name="SHOPpass" size="15" value="<?= $SHOPpass ?>"></td>
-</tr>
-</tr>
-       <td>Zeichensatz</td>
-       <td colspan="2"><select name="codeLX">
-<?php   foreach($zeichen as $code) {
-             echo "<option value='".$code."'";
-             if ($code == $codeLX) echo " selected";
-             echo ">".$code."\n"; };
-?>
-       </select></td>
-       <td ><select name="codeS">
-<?php   foreach($zeichen as $code) {
-             echo "<option value='".$code."'";
-             if ($code == $codeS) echo " selected";
-             echo ">".$code."\n"; };
-?>
-       </select></td>
-</tr>
-<tr>
-       <td>Preise </td>
-        <td colspan="2"> <input type="radio" name="mwstLX" value="1" <?= ($mwstLX==1)?"checked":'' ?>> incl.
-           <input type="radio" name="mwstLX" value="0" <?= ($mwstLX<>1)?"checked":'' ?>> excl. MwSt</td>
-       <td><input type="radio" name="mwstS" value="1" <?= ($mwstS==1)?"checked":'' ?>> incl.
-           <input type="radio" name="mwstS" value="0" <?= ($mwstS<>1)?"checked":'' ?>> excl. MwSt</td>
-</tr>
-<tr>
-       <td>User-ID</td>
-       <td colspan="2"><input type="text" name="ERPusrName" size="10" value="<?= $ERPusrName ?>">
-               <input type="checkbox" name="a1" <?= (empty($ERPusrID)?'':"checked") ?>></td>
-       <td></td>
-</tr>
-<tr>
-       <td>Image-Dir</td>
-       <td colspan="2"><input type="text" name="ERPimgdir" size="30" value="<?= $ERPimgdir ?>"></td>
-       <td><input type="text" name="SHOPimgdir" size="30" value="<?= $SHOPimgdir ?>"></td>
-</tr>
-<tr>
-       <td>Platzhalterbild</td>
-       <td colspan="2"><input type="text" name="nopic" size="20" value="<?php echo $nopic; ?>"></td>
-       <td colspan="2"><input type="checkbox" value="1" name="nopicerr" <?= (empty($nopicerr)?'':"checked") ?>>nur bei fehlerhaftem Upload verwenden</td>
-</tr>
-<tr>
-       <td>Bildupload</td>
-       <td colspan="2"><input type="checkbox" value="1" name="nofiles" <?= (empty($nofiles)?'':"checked") ?>>nur bei neuen Artikeln</td>
-       <td colspan="2"></td>
-</tr>
-<tr>
-       <td>FTP-Host</td>
-       <td colspan="2"><input type="text" name="ERPftphost" size="20" value="<?= $ERPftphost ?>"></td>
-       <td><input type="text" name="SHOPftphost" size="20" value="<?= $SHOPftphost ?>"></td>
-</tr>
-<tr>
-       <td>FTP-User</td>
-       <td colspan="2"><input type="text" name="ERPftpuser" size="15" value="<?= $ERPftpuser ?>"></td>
-       <td><input type="text" name="SHOPftpuser" size="15" value="<?= $SHOPftpuser ?>"></td>
-</tr>
-<tr>
-       <td>FTP-User PWD</td>
-       <td colspan="2"><input type="text" name="ERPftppwd" size="15" value="<?= $ERPftppwd ?>"></td>
-       <td><input type="text" name="SHOPftppwd" size="15" value="<?= $SHOPftppwd ?>"></td>
-</tr>
-<tr>
-       <td>Nr Diverse Std-MwSt</td>
-       <td><input type="text" name="divStd[NR]" size="10" value="<?= $divStd['NR'] ?>">
-               <input type="checkbox" name="a1" <?= (empty($divStd['ID'])?'':"checked") ?>></td>
-       <td>Nr Diverse Verm-MwSt</td>
-       <td><input type="text" name="divVerm[NR]" size="10" value="<?= $divVerm['NR'] ?>">
-               <input type="checkbox" name="a1" <?= (empty($divVerm['ID'])?'':"checked") ?>></td>
-</tr>
-<tr>
-       <td>Nr Versand Std-MwSt</td>
-       <td><input type="text" name="versandS[NR]" size="10" value="<?= $versandS['NR'] ?>">
-               <input type="checkbox" name="a1" <?= (empty($versandS['ID'])?'':"checked") ?>></td>
-       <td>Text:</td>
-       <td><input type="text" name="versandS[TXT]" size="20" value="<?= $versandS['TXT'] ?>"><?= $versandS['TAX'] ?></td>
-<tr>
-       <td>Nr Versand Verm-MwSt</td>
-       <td><input type="text" name="versandV[NR]" size="10" value="<?= $versandV['NR'] ?>">
-               <input type="checkbox" name="a1" <?= (empty($versandV['ID'])?'':"checked") ?>></td>
-       <td>Text:</td>
-       <td><input type="text" name="versandV[TXT]" size="20" value="<?= $versandV['TXT'] ?>"><?= $versandV['TAX'] ?></td>
-</tr>
-<tr>
-       <td>Nr Paypal</td>
-       <td><input type="text" name="paypal[NR]" size="10" value="<?= $paypal['NR'] ?>">
-               <input type="checkbox" name="a1" <?= (empty($paypal['ID'])?'':"checked") ?>></td>
-       <td>Text:</td>
-       <td><input type="text" name="paypal[TXT]" size="20" value="<?= $paypal['TXT'] ?>"></td>
-</tr>
-<tr>
-       <td>Nr Mindermenge</td>
-       <td><input type="text" name="minder[NR]" size="10" value="<?= $minder['NR'] ?>">
-               <input type="checkbox" name="a1" <?= (empty($minder['ID'])?'':"checked") ?>></td>
-       <td>Text:</td>
-       <td><input type="text" name="minder[TXT]" size="20" value="<?= $minder['TXT'] ?>"></td>
-</tr>
-<tr>
-       <td>Nr Nachname</td>
-       <td><input type="text" name="nachn[NR]" size="10" value="<?= $nachn['NR'] ?>">
-               <input type="checkbox" name="a1" <?= (empty($nachn['ID'])?'':"checked") ?>></td>
-       <td>Text:</td>
-       <td><input type="text" name="nachn[TXT]" size="20" value="<?= $nachn['TXT'] ?>"></td>
-</tr>
-<tr>
-       <td>Std-Einheit</td>
-       <td><select name="unit">
-<? unit($unit,$dbP); ?>
-           </select></td>
-       <td>Preisgruppe</td>
-       <td><select name="pricegroup">
-<? pg($pricegroup,$dbP); ?>
-           </select></td>
-<tr>
-       <td colspan="2">Auftragsnummern durch</td>
-       <td><input type="radio" name="auftrnr" value="1" <?= ($auftrnr==1)?"checked":'' ?>> LxO</td>
-       <td><input type="radio" name="auftrnr" value="0" <?= ($auftrnr<>1)?"checked":'' ?>> Shop</td>
-</tr>
-<tr>
-       <td colspan="2">Kundennummern durch</td>
-       <td><input type="radio" name="kdnum" value="1" <?= ($kdnum==1)?"checked":'' ?>> LxO</td>
-       <td><input type="radio" name="kdnum" value="0" <?= ($kdnum<>1)?"checked":'' ?>> Shop</td>
-</tr>
-<tr>
-       <td colspan="2">Nummernerweiterung</td>
-       <td>Auftrag<input type="text" name="preA" size="5" value="<?= $preA ?>"></td>
-       <td>Kunde<input type="text" name="preK" size="5" value="<?= $preK ?>"></td>
-</tr>
-<tr>
-       <td>Lagerbestand aus</td>
-       <td><select name="lager">
-<? lager($lager,$dbP); ?>
-           </select></td>
-       <td></td>
-       <td></td>
-<tr>
-<tr>
-       <td colspan="3">Langbeschreibung aus Shop &uuml;bernehmen</td>
-       <td><input type="radio" name="longtxt"  value="1" <?= ($longtxt<>2)?"checked":'' ?>>Ja
-       <input type="radio" name="longtxt"  value="2" <?= ($longtxt==2)?"checked":'' ?>>Nein</td>
-
-</tr>
-<tr>
-       <td colspan="3">LxO-Rechnungen sind Netto</td>
-       <td><input type="radio" name="invbrne"  value="1" <?= ($invbrne<>2)?"checked":'' ?>>Ja
-       <input type="radio" name="invbrne"  value="2" <?= ($invbrne==2)?"checked":'' ?>>Nein</td>
-</tr>
-<tr>
-       <td >Variantentext</td>
-       <td colspan="3"><input type="radio" name="variantnr"  value="1" <?= ($variantnr<>2)?"checked":'' ?>>Artikelbezeichnung anhängen
-       <input type="radio" name="variantnr"  value="2" <?= ($variantnr==2)?"checked":'' ?>>Langebeschreibung voranstellen</td>
-</tr>
-<tr>
-       <td colspan="3">Unbekannte Artikel beim Bestellimport anlegen</td>
-       <td><input type="radio" name="OEinsPart"  value="1" <?= ($OEinsPart<>2)?"checked":'' ?>>Ja
-       <input type="radio" name="OEinsPart"  value="2" <?= ($OEinsPart==2)?"checked":'' ?>>Nein</td>
-</tr>
-
-<!--tr>
-       <td>Bildergr&ouml;sse (byte)</td>
-       <td><input type="text" name="maxSize" size="10" value="<?= $maxSize ?>"></td>
-       <td></td>
-</tr-->
-
-
-<tr><td colspan="4" align="center"><input type="submit" name="ok" value="sichern"></td></tr>
-</form>
-</table>
-</center>
-</body>
-</html>
diff --git a/shopxtc/dblib.php b/shopxtc/dblib.php
deleted file mode 100755 (executable)
index cae6e51..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-<?php
-
-include_once("MDB2.php");
-
-class mydb {
-
-   var $db = false;
-   var $error = false;
-   var $debug = true;
-   var $dbf = false;
-   var $database = false;
-
-   function mydb($host,$db,$user,$pass,$port,$proto,$error,$debug) {
-       $this->error = $error;
-       $dsn = array('phptype'  => $proto,
-               'username' => $user,
-               'password' => $pass,
-               'hostspec' => $host,
-               'database' => $db,
-               'port'     => $port);
-       $this->debug = $debug;
-       $this->database = "-< $db >-";
-       $this->connect($dsn);
-    }
-
-    function connect($dsn) {
-       $options = array('result_buffering' => false,);
-       $this->db = MDB2::connect($dsn,$options);
-       if ( $this->debug ) $this->error->write('dblib->connect '.$this->database,'Connect:');
-       if (PEAR::isError($this->db)) {
-           $this->error->write('dblib->connect '.$this->database,$this->db->getMessage());
-           $this->error->write('dblib->connect '.$this->database,print_r($dsn,true));
-           $this->db = false;
-           return false;
-       }
-       $this->db->setFetchMode(MDB2_FETCHMODE_ASSOC);
-    }
-    function Begin() {
-        return $this->db->beginTransaction();
-    }
-    function Commit() {
-        return $this->db->commit();
-    }
-    function Rollback() {
-        return $this->db->rollback();
-    }
-
-    function getAll($sql) {
-        $rs = $this->db->queryAll($sql);
-        if ( $this->debug ) $this->error->write('dblib->getAll '.$this->database,$sql);
-        if (PEAR::isError($rs)) {
-            $this->error->write('dblib->getAll '.$this->database,$rs->getUserinfo());
-            return false;
-        }
-        return $rs;
-    } 
-    function getOne($sql) {
-        $rs = $this->db->queryRow($sql);
-        if ( $this->debug ) $this->error->write('dblib->getOne '.$this->database,$sql);
-        if (PEAR::isError($rs)) {
-            $this->error->write('dblib->getOne '.$this->database,$rs->getUserinfo());
-            return false;
-        }
-        return $rs;
-    }
-    function query($sql) {
-        $rc = $this->db->query($sql);
-        if ( $this->debug ) $this->error->write('dblib->query '.$this->database,$sql);
-        if (PEAR::isError($rc)) {
-            $this->error->write('dblib->query '.$this->database,$rc->getUserinfo());
-            return false;
-        }
-        return $rc;
-    } 
-    function insert($statement,$data) {
-        if ( $this->debug ) $this->error->write("dblib->insert ".$this->database,$statement);
-        $sth = $this->db->prepare($statement);                      //Prepare
-        if (PEAR::isError($sth)) {
-            $this->error->write('dblib->insert 1 '.$this->database,$sth->getMessage());
-            $this->error->write('dblib->insert 2',$sth->getUserinfo());
-            $this->rollback();
-            return false;
-        }
-        if ( $this->debug ) $this->error->write('dblib->insert',print_r($data,true));
-        $rc =& $sth->execute($data);
-        if (PEAR::isError($rc)) {
-            $this->error->write('dblib->insert 3 '.$this->database,$rc->getUserinfo());
-            $this->error->write('SQL ',$statement);
-            $this->error->write('Data ',print_r($data,true));
-            return false;
-        }//else{
-        //    $rc = $this->commit();
-        //}
-        return $rc;
-    }
-    function update($statement,$data) {  
-        if ( $this->debug ) $this->error->write("dblib->update ".$this->database,$statement);
-        $sth = $this->db->prepare($statement);                      //Prepare
-        if (PEAR::isError($sth)) {
-            $this->error->write('dblib->update 1 '.$this->database,$sth->getMessage());
-            $this->error->write('dblib->update 2',$sth->getUserinfo());
-            $this->rollback();
-            return false;
-        }
-        if ( $this->debug ) $this->error->write('dblib->insert',print_r($data,true));
-        $rc =& $sth->execute($data);
-        if (PEAR::isError($rc)) {
-            $this->error->write('dblib->update 3 '.$this->database,$rc->getUserinfo());
-            return false;
-        }//else{
-        //    $rc = $this->commit();
-        //}
-        return $rc;
-    }
-    function insertMultipe($statement,$data) {
-        $this->db->loadModule('Extended');
-        if (!$this->db->supports('transactions')){
-            return false;
-        }
-        $sth = $this->db->prepare($statement);                      //Prepare
-        if (PEAR::isError($sth)) {
-            $this->error->write('dblib->insertMultiple '.$this->database,$sth->getMessage());
-            $this->rollback();
-            return false;
-        }
-        $rc =& $this->db->beginTransaction();
-        $rc =& $this->db->extended->executeMultiple($sth, $data);
-        if (PEAR::isError($rc)) {
-            $this->error->write('dblib->insertMultiple '.$this->database,$rc->getUserinfo());
-            $this->rollback();
-            return false;
-        }else{
-                $rc = $this->commit();
-        }
-        return $rc;
-    }
-}
-
-?>
diff --git a/shopxtc/erplib.php b/shopxtc/erplib.php
deleted file mode 100755 (executable)
index 249028a..0000000
+++ /dev/null
@@ -1,460 +0,0 @@
-<?php
-/*
-
-shop muß gesetzt sein, obsolet nicht
-
-Multishop: Hierfür müssen benutzerdefinierte Variablen angelegt werden.
-Typ:checkbox,  Name=shop[0-9A-Z]+, Bearbeitbar=nein 
-
-
-*/
-
-class erp {
-
-    var $db = false;
-    var $error = false;
-    var $pricegroup = 0;
-    var $TAX = false;
-    var $mkPart = true;
-    var $divStd = false;
-    var $divVerm = false;
-    var $doordnr = false;
-    var $docustnr = false;
-    var $lager = 1;
-    var $warehouse_id = 0;
-    var $transtype = 0;
-    var $preordnr = '';
-    var $precustnr = '';
-    var $OEinsPart = false;
-    var $INVnetto = true; //Rechnungen mit Nettopreisen
-    var $ERPincl = false; //ERP-Preise sind Netto
-
-    function erp($db,$error,$divStd,$divVerm,$doordnr,$docustnr,$preordnr,$precustnr,$INVnetto,$ERPincl,$OEinsPart,$lager,$pricegroup,$ERPusrID) {
-        $this->db = $db;
-        $this->pricegroup = $pricegroup;
-        $this->employee_id = $ERPusrID;
-        $this->error = $error;
-        $this->divStd  = $divStd;
-        $this->divVerm = $divVerm;
-        $this->doordnr = $doordnr;
-        $this->preordnr = $preordnr;
-        $this->docustnr = $docustnr;
-        $this->precustnr = $precustnr;
-        $this->INVnetto = ($INVnetto == 1)?true:false;
-        $this->ERPincl = ($ERPincl == 1)?true:false;
-        $this->OEinsPart = ($OEinsPart == 1)?true:false;
-        $this->lager = ($lager)?$lager:1;
-        $this->getTax();
-        if ( $lager > 1 ) {
-            $sql  = "SELECT warehouse_id from bin where id = ".$this->lager;
-            $rs = $this->db->getOne($sql);
-            if ( $rs['warehouse_id'] > 0 ) {
-                       $this->warehouse_id = $rs['warehouse_id'];
-                $sql = "SELECT id from transfer_type WHERE direction = 'in' and description = 'stock'";
-                $rs = $this->db->getOne($sql);
-                $this->transtype = $rs['id'];
-            } else {
-                $this->lager = 1;
-            }
-        }
-    }
-
-    function getTax() {
-        $sql  = "SELECT  BG.id AS bugru,T.rate,TK.startdate,C.taxkey_id, ";
-        $sql .= "(SELECT id FROM chart WHERE accno = T.taxnumber) AS tax_id, ";
-        $sql .= "BG.income_accno_id_0,BG.expense_accno_id_0 ";
-        $sql .= "FROM buchungsgruppen BG LEFT JOIN chart C ON BG.income_accno_id_0=C.id ";
-        $sql .= "LEFT JOIN taxkeys TK ON TK.chart_id=C.id ";
-        $sql .= "LEFT JOIN tax T ON T.id=TK.tax_id WHERE TK.startdate <= now()";
-        $rs = $this->db->getAll($sql);
-        if ($rs) foreach ($rs as $row) {
-            $nr = $row['bugru'];
-            if (!$this->TAX[$nr]) {
-                $data = array();
-                $data['startdate'] =     $row['startdate'];
-                $data['rate'] =     $row['rate'];
-                $data['taxkey'] =     $row['taxkey_id'];
-                $data['taxid'] =     $row['tax_id'];
-                $data['income'] =     $row['income_accno_id_0'];
-                $data['expense'] =     $row['expense_accno_id_0'];
-                $this->TAX[$nr] = $data;
-            } else if ($this->TAX[$nr]['startdate'] < $row['startdate']) {
-                $this->TAX[$nr]["startdate"] =     $row['startdate'];
-                $this->TAX[$nr]["rate"] =     $row['rate'];
-                $this->TAX[$nr]["taxkey"] =     $row['taxkey_id'];
-                $this->TAX[$nr]["taxid"] =     $row['tax_id'];
-                $this->TAX[$nr]["income"] =     $row['income_accno_id_0'];
-                $this->TAX[$nr]["expense"] =     $row['expense_accno_id_0'];
-            }
-        }
-    }
-
-    function getParts($stdprice=0,$shop=0) {
-        $where = "WHERE 1=1 ";
-        if ($stdprice>0) {
-             $sql  = "SELECT P.partnumber,P.description,P.notes,P.weight,G.price as sellprice,P.sellprice as stdprice,";
-             $sql .= "PG.partsgroup,P.image,P.buchungsgruppen_id as bugru,P.unit,P.ean ";
-             if ($this->lager>1) {
-                   $sql .= ",(select sum(qty) from inventory where bin_id = ".$this->lager." and parts_id = P.id) as onhand ";
-             } else {
-                   $sql .= ",P.onhand ";
-             }
-             $sql .= "FROM parts P ";
-             $sql .= "LEFT JOIN partsgroup PG on PG.id=P.partsgroup_id ";
-             $sql .= "LEFT JOIN prices G on G.parts_id=P.id ";
-             $where .= "AND (G.pricegroup_id=$stdprice ";
-             $where .= "or G.pricegroup_id is null) ";
-        } else {
-             $sql  = "SELECT P.partnumber,P.description,P.notes,P.weight,P.sellprice,";
-             $sql .= "PG.partsgroup,P.image,P.buchungsgruppen_id as bugru,P.unit,P.ean ";
-             if ($this->lager>1) {
-                   $sql .= ",(select sum(qty) from inventory where bin_id = ".$this->lager." and parts_id = P.id) as onhand ";
-             } else {
-                   $sql .= ",P.onhand ";
-             }
-             $sql .= "FROM parts P left join partsgroup PG on PG.id=P.partsgroup_id ";
-        }
-        if ($shop>0) {  
-            $sql .= "LEFT JOIN custom_variables CV on CV.trans_id=P.id ";
-            $where .= "AND (CV.config_id = $shop AND bool_value = 't')";
-        }
-        $where .= "AND shop = 't' ";
-        $where .= "AND obsolete = 'f' ORDER BY P.partnumber";
-        $rs = $this->db->getAll($sql.$where);
-        if ($rs) for($i = 0; $i < count($rs); $i++) {
-           $rs[$i]['tax'] = $this->TAX[$rs[$i]['bugru']]['rate'];
-        }
-        return $rs;
-    }
-
-    function getPartsLang($lang,$alle) {
-        $sql  = "SELECT P.partnumber,L.translation,P.description,L.longdescription,P.notes,PG.partsgroup ";
-        $sql .= "FROM parts P left join translation L on L.parts_id=P.id left join partsgroup PG on PG.id=P.partsgroup_id ";
-        $sql .= "WHERE P.shop='t' and (L.language_id = $lang";
-        if ($alle) {
-            $sql .= " or L.language_id is Null)";
-        } else { 
-            $sql.=")"; 
-        };
-        $rs = $this->getAll($sql);
-        $data=array();
-        if ($rs) foreach ($rs as $row) {
-            if (!$data[$row["partnumber"]]) $data[$row["partnumber"]]=$row;
-        }
-        return $data;
-    }
-    function getNewNr($typ) {
-        /*
-          so = Auftragsnummer
-          customer = Kundennummer 
-        */
-        $typ .= "number";
-        $sql = "SELECT $typ FROM defaults";
-        $rs = $this->db->getOne($sql);
-        $i=strlen($rs["$typ"])-1;
-        //Nummern können Buchstaben, Zeichen und Zahlen enthalten
-        //nur die Zahlen von rechts werden aber inkrementiert.
-        while($i>=0) {
-            if ($rs["$typ"][$i] >= "0" and $rs["$typ"][$i]<="9") {
-                $n=$rs["$typ"][$i].$n;
-                $i--;
-            } else {
-                $pre = substr($rs["$typ"],0,$i+1);
-                $i=-1;
-            }
-        };
-        $nr = (int)$n + 1;
-        $sonr = $pre.$nr;
-        $sql = "UPDATE defaults SET $typ = '$sonr'";
-        $rc = $this->db->query($sql);
-        if (!$rc) {
-            $this->error->write('erplib','Neue Nummer ($typ) nicht gesichert: '.$sonr);
-        }
-        return $sonr;
-    }
-    function newOrder($data) {
-        /*Einen neuen Auftrag anlegen. Folgendes Array muß übergeben werden:
-        $data = array(ordnumber,customer_id,employee_id,taxzone_id,amount,netamount,transdate,notes,intnotes,shipvia)
-        Rückgabe oe.id */
-        $this->db->begin();
-        $incltax = ($this->INVnetto)?'f':'t';
-        $sql  = "INSERT INTO oe (ordnumber,customer_id,employee_id,taxzone_id,taxincluded,curr,amount,netamount,transdate,notes,intnotes,shipvia,cusordnumber) ";
-        $sql .= "values (:ordnumber,:customer_id,:employee_id,:taxzone_id,'$incltax',:curr,:amount,:netamount,:transdate,:notes,:intnotes,:shipvia,:cusordnumber)";
-        $rc = $this->db->insert($sql,$data);
-        $sql = "SELECT * FROM oe where ordnumber = '".$data["ordnumber"]."'";
-        $rs = $this->db->getOne($sql);
-        if (!$rs['id']) {
-            $this->error->write('erplib','Auftrag erzeugen: '.$data["ordnumber"]);
-            $this->db->rollback();
-            return false;
-        } else {
-            $this->error->out(" Auftrag: ".$data["ordnumber"]." ");
-            return $rs['id'];
-        }
-    }
-    function insParts($trans_id,$data,$longtxt) {
-        /*Artikel in die orderitem einfügen. Folgende Daten müssen übergeben werden:
-        $trans_id = (int) oe.id
-        $data = array(trans_id,partnumber,description,longdescription,qty,sellprice,unit)*/
-        foreach ($data as $row) {
-             $row['trans_id'] = $trans_id;
-             //$sql = "SELECT id FROM parts WHERE partnumber = '".$row['partnumber']."'";
-             //$tmp = $this->db->getOne($sql);
-             $tmp = $this->chkPartnumber($row,$this->OEinsPart,true,true);
-             if ($tmp) {
-                 $row['parts_id'] = $tmp['id'];
-             } else {
-                 if ($this->TAX[$this->divStd['BUGRU']]['rate'] == $row['mwst']/100) {
-                      $row['parts_id'] = $this->divStd['ID'];
-                 } else if ($this->TAX[$this->divVerm['BUGRU']]['rate'] == $row['mwst']/100) {
-                      $row['parts_id'] = $this->divVerm['ID'];
-                 } else {
-                      $row['parts_id'] = $this->divStd['ID'];
-                 }
-             }
-             //Shop soll immer Nettopreise liefern!
-             if (!$this->INVnetto) {
-                     $row['sellprice'] = round($row['sellprice'] * (100 + $row['taxrate']) / 100,2);
-             }
-             $row['unit'] = $this->chkUnit($row['unit']);
-             if ($longtxt == 1) {
-                 //$row['longdescription'] = addslashes($row['longdescription']);
-                 $row['longdescription'] = $row['longdescription'];
-             } else {
-                 //$row['longdescription'] = addslashes($tmp['longdescription']);
-                 $row['longdescription'] = $tmp['longdescription'];
-             }
-             //$row['description'] = addslashes($row['description']);
-             $sql  = "INSERT INTO orderitems (trans_id,parts_id,description,longdescription,qty,sellprice,unit,pricegroup_id,discount) ";
-             $sql .= "VALUES (:trans_id,:parts_id,:description,:longdescription,:qty,:sellprice,:unit,0,0)";
-             $row["trans_id"]=$trans_id;
-             $rc = $this->db->insert($sql,$row);
-             if (!$rc) {
-                 $this->db->rollback();
-                 return false;
-             };
-        };
-        $this->db->commit();
-        return true;
-    }
-    function insCustomer($data) {
-        $this->error->out('Insert:'.$data["name"].' ');
-        if ($this->docustnr == 1) {
-            $data['customernumber'] = $this->getNewNr('customer');
-        } else {
-            $data['customernumber'] = $data['shopid'];
-        }
-        $data['customernumber'] = $this->precustnr.$data['customernumber'];
-            if ($data['customernumber']>0) {
-                if (!$data['greeting']) $data['greeting'] = '';
-                $sql  = "INSERT INTO customer (greeting,name,street,city,zipcode,country,contact,phone,email,customernumber)";
-                $sql .= " VALUES (:greeting,:name,:street,:city,:zipcode,:country,:contact,:phone,:email,:customernumber)";
-                $rc =  $this->db->insert($sql,$data);
-                $sql = "SELECT id FROM customer WHERE customernumber = '".$data['customernumber']."'";
-                $rs = $this->db->getOne($sql);
-                $rc = $rs['id'];
-                $this->error->out("Kd-Nr: ".$data['customernumber'].":".$rs['id']);
-            } else {
-                $this->error->write('erplib','Kunde anlegen: '.$data["name"]);
-                $this->db->rollback();
-                return false;
-            }
-            return $rc;
-    }
-    function chkCustomer($data) {
-        if ($data['customer_id']>0) {
-            $sql = "SELECT * FROM customer WHERE id = ".$data['customer_id'];
-            $rs = $this->db->getOne($sql);
-            if ($rs['id'] == $data['customer_id']) {
-                 $this->error->out('Update:'.$data['customer_id'].' ');
-                 $sql  = "UPDATE customer SET greeting = :greeting,name = :name,street = :street,city = :city,country = :country,";
-                 $sql .= "zipcode = :zipcode,contact = :contact,phone = :phone,email = :email WHERE id = :customer_id";
-                 $rc =  $this->db->update($sql,$data);
-                 if ($rc) $rc = $data['customer_id'];
-            } else {
-                $rc = $this->insCustomer($data);
-            }
-        } else {
-            $rc = $this->insCustomer($data);
-        }
-        return $rc;
-    }
-    function mkAuftrag($data,$shop,$longtxt) {
-        $this->db->Begin();
-        $data["notes"] .= "\nBezahlung:".$data['bezahlung']."\n";
-        if ($data['bezahlung'] == "Kreditkarte")   $data["notes"] .= $data['kreditkarte']."\n"; 
-        if ($shop) { 
-           $data["intnotes"] = "Shop: $shop";
-        } else {
-           $data["intnotes"] = "";
-        };
-        $data["customer_id"] = $this->chkCustomer($data["customer"]);
-        $parts = $data['parts'];
-        unset($data['parts']);
-        unset($data['customer']);
-        if ($this->doordnr == 1) {
-            $data["ordnumber"] = $this->getNewNr('so');
-        } else {
-            $data["ordnumber"] = $data['cusordnumber'];
-        }
-        $data["ordnumber"] = $this->preordnr.$data["ordnumber"];
-        $tid = $this->newOrder($data);
-        if ($tid) {
-            $rc = $this->insParts($tid,$parts,$longtxt);  
-            if (!$rc) {
-                 $this->error->write('erplib','Artikel zu Auftrag');
-                 return -1;
-            }
-        } else {
-            $this->error->write('erplib','Auftrag anlegen');
-            return -1;
-        }
-        $this->error->out($data["customer"]["firma"]." ".$data["shopid"]);
-        $rc = $this->db->Commit();
-        return $data["customer_id"];
-    }
-    function chkPartsgroup($pg,$new=True) {
-       /*gibt es die Warengruppe?
-       Rückgabe nichts oder die partsgroup.id
-       ggf neu anlegen*/
-       $sql = "SELECT * FROM partsgroup WHERE partsgroup = '".$pg."'";
-       $rs = $this->db->getOne($sql);
-       if ($rs) {
-           return $rs['id'];
-       } else if ($this->mkPart and $new) {
-           return $this->mkNewPartsgroup($pg);
-       } else {
-           return '';
-       };
-    }
-    function mkNewPartsgroup($name) {
-       $sql = "INSERT INTO partsgroup (partsgroup) VALUES ('".$name."')";
-       $rc = $this->db->query($sql);
-       if ($rc) {
-           return $this->chkPartsgroup($name,False);
-       } else {
-           return '';
-       }
-    }
-    function chkUnit($unit) {
-       /*Prüfen ob es die Unit gibt.
-         wenn nicht, die Standardunit zurückgeben*/
-       if ($unit == '') {
-           return $this->stdUnit();
-       } else {
-           $sql = "SELECT * FROM units WHERE name ilike '".$unit."'";
-           $rs = $this->db->getOne($sql);
-           if ($rs) {
-              return $rs["name"];
-           } else {
-               return $this->stdUnit();
-           }
-       }
-    }
-    function stdUnit() {
-       $sql = "SELECT * FROM units WHERE type = 'dimension' ORDER BY sortkey LIMIT 1";
-       $rs = $this->db->getOne($sql);
-       return $rs["name"];
-    }
-    function chkPartnumber($data,$new=True,$long=false,$bestellung=false) {
-       $sql = "SELECT * FROM parts WHERE partnumber = '".$data["partnumber"]."'";
-       $rs = $this->db->getOne($sql);
-       if ($rs) {
-           if ($long) {
-               return $rs;
-           } else {
-               return $rs['id'];
-           }
-       } else if ($new and $this->mkPart) {
-           $data['id'] = $this->mkNewPart($data,$bestellung);
-           if ($long) {
-               return $data;
-           } else {
-               return $data['id'];
-           }
-       } else {
-           return '';
-       };
-    }
-    function mkNewPart($data,$bestellung) {
-       /*eine neue Ware anlegen, sollte nicht direkt aufgerufen werden.
-       Auf vorhandene partnumber wird nicht geprüft.
-       Folgendes Array muß übergeben werden:
-       $data = array(partnumber,description,longdescription,weight,sellprice,taxrate,partsgroup,unit)
-       Rückgabe parts.id
-       */
-       $link = '<a href="../ic.pl?action=edit&id=%d" target="_blank">';
-       if ($data['partnumber'] == '') {
-           $this->error->write('erplib','Artikelnummer fehlt');
-           return false;
-       }
-       if ($data['description'] == '') {
-           $this->error->write('erplib','Artikelbezeichnung fehlt');
-           return false;
-       }
-       $data['notes'] = addslashes($data['longdescription']);
-       if ($data['weight']*1 != $data['weight']) $data['weight']=0;
-       if ($data['sellprice']*1 != $data['sellprice']) $data['sellprice']=0;
-       if (!in_array($data["buchungsgruppen_id"],$this->TAX)) {
-           foreach ($this->TAX as $key=>$tax) {
-                if ($tax["rate"] == $data["taxrate"]/100) {
-                    $data["buchungsgruppen_id"] = $key;
-                    break;
-                }
-           }
-           if (!$data["buchungsgruppen_id"]) {
-               $this->error->write('erplib','Buchungsgruppe konnte nicht zugeordnet werden');
-               return false;
-           }
-       };
-       if ($data["partsgroup"]) {
-           $data["partsgroup_id"] = $this->chkPartsgroup($data["partsgroup"]);
-       } else {
-           $data["partsgroup_id"] = '';
-       };
-       $data['unit'] = $this->chkUnit($data['unit']);
-       if ($data['unit'] == '') {
-           $this->error->write('erplib','Artikeleinheit fehlt oder falsch');
-           return false;
-       }
-       $data['shop'] = 't';
-       $sql  = "INSERT INTO parts (partnumber,description,sellprice,weight,notes,shop,unit,partsgroup_id,";
-       $sql .= "ean,image,buchungsgruppen_id,inventory_accno_id,income_accno_id,expense_accno_id) ";
-       $sql .= "VALUES (:partnumber,:description,:sellprice,:weight,:notes,:shop,:unit,:partsgroup_id,";
-       $sql .= ":ean,:image,:buchungsgruppen_id,1,1,1)";
-       if ($this->ERPincl) {
-          $data['sellprice'] = round($data['sellprice'] * (100+$data['taxrate'])/100,2);
-       }
-       $rc = $this->db->insert($sql,$data);
-       $data['parts_id'] = $this->chkPartnumber($data,false);
-       if ( $this->pricegroup > 0 ) {
-            $sql  = "INSERT INTO prices (parts_id,pricegroup_id,price) VALUES (:parts_id,:pricegroup,:sellprice)";
-            $data['pricegroup'] = $this->pricegroup;
-            $rc = $this->db->insert($sql,$data);
-       };
-       if ( $data['onhand'] > 0 and $this->lager > 1) $this->insLager($data);
-       $x =  $this->chkPartnumber($data,False);
-       $this->error->write('erplib',$data['description'].' '.$data['partnumber']);
-       $this->error->out(sprintf($link,$data['parts_id']).$data['description'].' '.$data['partnumber'].'</a>',true);
-       return $x;
-    }
-    function insLager($data) {
-        $rc = $this->db->Begin();
-        $sql = "SELECT nextval(('id'::text)::regclass) as id from id";
-        $rs = $this->db->getOne($sql);
-        $sql  = "INSERT INTO inventory (warehouse_id,parts_id,shippingdate,employee_id,bin_id,qty,trans_id,trans_type_id,comment) ";
-        $sql .= "VALUES (:wid,:parts_id,now(),:employee_id,:bid,:onhand,:next,:tt,'Shopübernahme')";
-        $data['next'] = $rs['id'];
-        $data['tt'] = $this->transtype;
-        $data['bid'] = $this->lager;
-        $data['wid'] = $this->warehouse_id;
-        $data['employee_id'] = $this->employee_id;
-        $rc = $this->db->insert($sql,$data);
-        if ( $rc ) {
-           $this->db->Commit();
-        } else {
-           $this->db->Rollback();
-        }
-    }
-}
-?>
diff --git a/shopxtc/error.php b/shopxtc/error.php
deleted file mode 100755 (executable)
index 7d36d46..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-
-class error {
-
-  var $log = false; 
-  var $api = '';
-  var $lf  = '<br />';
-
-  function error($api) {
-     $this->log = fopen("/tmp/shop.log","a");
-     $this->api = $api;
-     if ( $api == 'cli' ) { $this->lf = "\n"; }
-     else { $this->lf = "<br />"; };
-  }
-
-  function write($func,$string) {
-     $now = date('Y-m-d H:m:i ');
-     fputs($this->log,$now.$func."\n");
-     fputs($this->log,$string."\n");
-  }
-
-  function close() {
-     fclose($this->log);
-  }
-  function out($txt,$lf=false) {
-    if ( $this->api != 'cli' ) {
-        echo str_repeat(" ", 256);
-        echo $txt;
-        if ( $lf ) echo $this->lf;
-        flush(); ob_flush();
-    } else {
-        echo $txt;
-        if ( $lf ) echo $this->lf;
-    }
-  }
-}
-?>
diff --git a/shopxtc/menu.ini b/shopxtc/menu.ini
deleted file mode 100644 (file)
index 1800dce..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-
-[Shop]
-
-[Shop--Warenexport]
-module=shopxtc/ArtikelErpToShop.php
-
-[Shop--Warenexport]
-module=shopxtc/ArtikelShopToErp.php
-
-[Shop--Bestellungen]
-module=shopxtc/BestellungShop.php
-
-[Shop--Konfiguration]
-module=shopxtc/confedit.php
-
diff --git a/shopxtc/xtc.php b/shopxtc/xtc.php
deleted file mode 100755 (executable)
index 75c37f5..0000000
+++ /dev/null
@@ -1,508 +0,0 @@
-<?php
-/*
-Funktionen für den Zugriff auf den xtc 3.04 newxtc 1.05
-*/
-
-
-class xtc {
-
-    var $db = false;
-    var $error = false;
-    var $divStd = false;
-    var $divVerm = false;
-    var $minder = false;
-    var $paypal = false;
-    var $nachn = false;
-    var $shopcode = 'ISO-8859-1';
-    var $erpcode = 'UTF-8';
-    var $VariantNr = 1;
-    var $EU = array('AT','BE','BG','CZ','DK','EE','ES','FI','FR','GB','GR','HR','HU','IE','IT','LU','LV','MT','NL','PL','PT','RO','SE','SI','SK');
-    var $Kategorien = False;
-    var $dezimal = 2;
-    var $tax_zone = 5;
-    var $language = 2;
-    var $geozone = 5;
-
-    var $tableerp  = array("partnumber"=>"products_model","description"=>"products_name","notes"=>"products_description","ean"=>"products_ean",
-                           "unit"=>"products_vpe","weight"=>"products_weight","sellprice"=>"products_price","partsgroup"=>"products_partsgroup",
-                           "tax"=>"products_tax","image"=>"products_image","onhand"=>"products_quantity");
-    var $custshop   = array("kontakt"=>"contact","ort"=>"city","plz"=>"zipcode","land"=>"country","tel"=>"phone",
-                            "fax"=>"fax","email"=>"email","beschreibung"=>"notes","strasse"=>"street","firma"=>"name",
-                            "kunden_nr"=>"customer_id","anrede"=>"greeting","k_id"=>"shopid",
-                            "bankname"=>"bank","blz"=>"bank_code","kontonummer"=>"account_number",
-                            "iban"=>"iban","bic"=>"bic","attributwert1"=>"ustid");
-    var $ordershop  = array("datum"=>"transdate","rechnungsbetrag"=>"amount","rechnungs_nr"=>"",
-                            "waehrung"=>"currency","beschreibung"=>"notes",
-                            "mwst"=>"mwst","versandart"=>"shipvia");
-    var $orderparts = array("products_name"=>"description","products_description"=>"longdescription","products_price"=>"sellprice",
-                            "products_quantity"=>"qty","products_model"=>"partnumber",
-                            "partsgroup"=>"partsgroup","products_weight"=>"weight","products_ean"=>"ean",
-                            "products_tax"=>"taxrate","products_image"=>"image","products_vpe_name"=>"unit");
-
-    function xtc($db,$error,$dbname,$divStd,$divVerm,$minder,$nachn,$versandS,$versandV,$paypal,$mwstLX,$mwstS,$variantnr,$unit,
-                 $pic=false,$nopic=false,$nopicerr=false,$nofiles=false,
-                 $erpcode='UTF-8',$shopcode='ISO-8859-1') {
-        $this->db       = $db;
-        $this->error    = $error;
-        $this->divStd   = $divStd  ;
-        $this->divVerm  = $divVerm ;
-        $this->minder   = $minder  ;
-        $this->nachn    = $nachn   ;
-        $this->versandS = $versandS ;
-        $this->versandV = $versandV ;
-        $this->paypal   = $paypal  ;
-        $this->erpcode  = $erpcode;
-        $this->mwstLX   = $mwstLX;
-        $this->mwstS    = $mwstS;
-        $this->unit     = $unit;
-        $this->VariantNr = $variantnr;
-        $this->language  = $this->defaultLang();        
-        $this->geozone   = $this->getDefaultGZ();
-        $this->pic       = $pic;
-        $this->nopic     = ( $nopic != '' )?$nopic:false;
-        $this->nopicerr  = ( $nopicerr != '' )?true:false;
-        $this->nofiles     = $nofiles;
-        if ($shopcode == 'AUTO') {
-            $sql = "SELECT TABLE_COLLATION FROM information_schema.TABLES WHERE table_schema = '$dbname' AND table_name = 'customers'";
-            $rs = $this->db->getOne($sql);
-            if ($rs) {
-                preg_match('/([^_]+)/',$rs['table_collation'],$hits);
-                if (count($hits)>0) {
-                    $this->shopcode = $hits[1];
-                } else {
-                    $this->shopcode =  'ISO-8859-1';
-                }
-            }
-        } else {
-            $this->shopcode = $shopcode;
-        }
-    }
-    function getDefaultGZ() {
-        $sql  = "SELECT geo_zone_id FROM  zones_to_geo_zones Z ";
-        $sql .= "LEFT JOIN countries CO ON Z.zone_country_id=CO.countries_id ";
-        $sql .= "LEFT JOIN configuration CF ON CO.countries_iso_code_2=CF.configuration_value ";
-        $sql .= "WHERE configuration_key = 'DEFAULT_LANGUAGE'";
-        $rs = $this->db->getOne($sql);
-        return $rs['geo_zone_id'];
-    }
-    function defaultLang() {
-        $sql  = "SELECT languages_id FROM languages L LEFT JOIN configuration C ON L.code = C.configuration_value ";
-        $sql .= "WHERE C.configuration_key = 'DEFAULT_LANGUAGE'";
-        $rs = $this->db->getOne($sql);
-        return $rs['languages_id'];
-    }
-    function _toERP($txt) {
-        return mb_convert_encoding($txt,$this->erpcode,$this->shopcode);
-    }
-    function _toShop($txt) {
-        return mb_convert_encoding($txt,$this->shopcode,$this->erpcode);
-    }
-    function translateTable($data,$table) {
-        $newdata = array();
-        foreach ($data as $key=>$val) {
-             if ($this->{$table}[$key]) 
-                 $newdata[$this->{$table}[$key]] = $val;
-        }
-        return $newdata;
-    }
-    function getCategoryID($name) {
-        if (empty($name)) {
-              $name = "Default";
-        } else {
-              $name = $this->_toShop($name);
-        }
-        //Kategorien werden durch die ERP mit "!" getrennt
-        preg_match_all("/([^!]+)!?/",$name,$kat);
-        if (count($kat)>0) {
-            $kat = $kat[1];
-        } else {
-            return false;
-        };
-        $parent = 0;
-        $sql="select D.*,C.parent_id from categories C left join categories_description D on C.categories_id=D.categories_id ";
-        $sql.="where categories_name = '%s' and ";
-        $sql.="C.parent_id=%d and language_id=".$this->language;
-        if (count($kat)>0) foreach ($kat as $wg) {
-            $sql_ = sprintf($sql,$wg,$parent);
-            $rs=$this->db->getOne($sql_);
-            if ($rs["categories_id"]) {                   // gefunden
-                $parent=$rs["categories_id"];
-            } else {                    // nicht gefunden, anlegen
-                $parent=$this->createCategory($wg,$parent);
-            }
-        }
-        return $parent;
-    }
-    function createCategory($name,$parent) {
-        echo "Kategorie: $name<br>";
-        //Kategorie nicht vorhanden, anlegen
-        $newID = uniqid(rand());
-        $sql = "INSERT INTO categories (categories_image,parent_id,date_added) VALUES  ('$newID',$parent,now())";
-        $rc = $this->db->query($sql);
-        if ( !$rc ) return false;
-        $sql = "SELECT * FROM categories WHERE categories_image = '$newID'";
-        $rs = $this->db->getOne($sql);
-        $id = $rs["categories_id"];
-        $sql = "UPDATE categories SET categories_image = null WHERE categories_id=$id";
-        $rc = $this->db->query($sql);
-        if ( !$rc ) return false;
-        $rc = $this->createCategoryLang($id,$name);
-        return $id;
-    }
-    /*******************************************
-    * createCategoryLang($id,$lang,$name)
-    * Kategorie für eine Sprache anlegen. Ist immer
-    * in der gleichen Sprache, da ERP nur eine hat.
-    *******************************************/
-    function createCategoryLang($id,$name) {
-        $sql  = "INSERT INTO categories_description (categories_id,language_id,categories_name,categories_meta_title) ";
-        $sql .= "VALUES ($id,".$this->language.",'$name','$name')";
-        $rc = $this->db->query($sql);
-        return $rc;
-    }
-    function getTax($tax) {
-        $sql = "SELECT * FROM tax_rates WHERE tax_rate = $tax and tax_zone_id =".$this->geozone;
-        $rs = $this->db->getOne($sql);
-        return $rs['tax_class_id'];
-    }
-    function getVPE($vpe) {
-        $sql  = "SELECT products_vpe_id FROM products_vpe WHERE products_vpe_name = '$vpe' AND language_id = ".$this->language;
-        $rs = $this->db->getOne($sql);
-        return $rs['products_vpe_id'];
-    }
-    function saveArtikel($data,$lang) {
-         $values = $this->translateTable($data,"tableerp"); //$this->tableerp);
-         if ($this->mwstLX) { //ERP-Bruttopreis
-              $values['products_price'] = round($values['products_price'] / (1 + $values["products_tax"]),2);
-         }
-         $values["products_name"] = $this->_toShop($values["products_name"]);
-         $values["products_description"] = $this->_toShop($values["products_description"]);
-         $values["products_tax_class_id"] = $this->getTax($values["products_tax"]*100);
-         $values["categories_id"] = $this->getCategoryID($values["products_partsgroup"]);
-         $values["products_vpe"] = $this->getVPE($values["products_vpe"]);
-         $values["products_id"] = $this->checkArtikelOK($values["products_model"]);  
-         if ($values["products_id"]>0)  {
-             $rc = $this->updateArtikel($values);
-         } else {
-             $rc = $this->insertArtikel($values);
-         };
-         return $rc;
-    }
-    function checkArtikelOK($nr) {
-        $sql = "SELECT * FROM products WHERE products_model = '".$nr."'";
-        $rs = $this->db->getOne($sql);
-        return $rs["products_id"];
-    }
-    function insertArtikel($data) {
-        $newID = uniqid(rand());
-        $this->db->Begin();
-       $sql = "INSERT INTO products (products_model,products_image,products_status) VALUES ('".$data["products_model"]."','$newID',1)";
-           $rc = $this->db->query($sql);
-       $sql = "SELECT * FROM products WHERE products_image='$newID'";
-           $rs = $this->db->getOne($sql);
-        $sql = "INSERT INTO products_description (products_id,products_name,language_id) VALUES (".$rs['products_id'].",'".$data['products_name']."',".$this->language.")";
-           $rc = $this->db->query($sql);
-           if ($rs['products_image'] == $newID) {
-            $data["products_id"] = $rs["products_id"];
-               $statement = "INSERT INTO products_to_categories (products_id,categories_id) VALUES (?,?)";
-            $values = array($rs["products_id"],$data["categories_id"]);
-               $rc = $this->db->insert($statement,$values);
-            if (!$rc) {
-                 echo $data['products_model'].' konnte nicht zur Gruppe '.$data['categories_id'].' zugef&uuml;gt werden.';
-                 $this->error->write('xtc',$data['products_model'].' konnte nicht zur Gruppe '.$data['categories_id'].' zugefügt werden.');
-                 $this->db->Rollback();
-                 return false;
-            }
-            $this->db->Commit();
-           echo " insert ";
-           $rc = $this->updateArtikel($data,true);
-       } else { return false; }
-        return $rc;
-    }
-    function updateArtikel($values,$insert=false) {
-        if ($this->mwstLX) $values['products_price'] = round($values['products_price'] / (100+$values['products_tax'])*100,2);
-        $sql  = "UPDATE products SET products_price = :products_price, products_weight = :products_weight, ";
-        if ( !$this->nofiles || $insert) {
-             //vorhandene Bilder übertragen
-             $sql .= "products_image = :products_image,  ";
-             if ( $values['products_image'] != '' ) {
-                 preg_match("/(.+)\.(jpg|png|jpeg|gif)/i",$values['products_image'],$tmp);
-                 $sql .= "products_image = :products_image,  ";
-                 if ( count($tmp) == 3 ) {
-                     if ( $this->pic &&  $this->pic->copyImage($values['products_id'],$values['products_image'],$tmp[2]) ) {
-                         $values['products_image'] = $values['products_id']."_0.".$tmp[2];
-                     } else if ( $this->nopic ){
-                         $values['products_image'] = $this->nopic;
-                     }
-                 } 
-             } else if ( $this->nopic && !$this->nopicerr ){
-                 $values['products_image'] = $this->nopic;
-             }
-        }
-        $sql .= "products_tax_class_id = :products_tax_class_id, products_vpe = :products_vpe, products_ean = :products_ean ";
-        //Kein Lagerbestand übergeben, also nichts ändern
-        if ($values['products_quantity'] != '') $sql .= ",products_quantity = :products_quantity ";
-        $sql .= "WHERE products_id = :products_id ";
-        $rc = $this->db->update($sql,$values);
-        $sql  = "UPDATE products_description SET products_name = :products_name, products_description = :products_description ";
-        #products_short_description products_keywords <== aus CVars
-        $sql .= "WHERE products_id = :products_id AND language_id = ".$this->language;
-        $rc = $this->db->update($sql,$values);
-        if ($rc) { 
-            return $values["products_id"];
-        } else {
-            return false;
-        }
-    }
-    function getVersand($class,$orderid,$country) {
-        $tmp = explode("_",$class);
-        if ( $tmp[1] == "" ) $tmp[1] = "dp";
-        $sql  = "SELECT geo_zone_id FROM zones_to_geo_zones WHERE zone_country_id = (";
-        $sql .= "SELECT countries_id FROM countries WHERE countries_name = '$country')";
-        $rs = $this->db->getOne($sql);
-        $sql  = "SELECT tax_rate FROM tax_rates WHERE tax_zone_id = ".$rs['geo_zone_id']." AND tax_class_id = (";
-        $sql .= "SELECT configuration_value FROM  configuration WHERE configuration_key = 'MODULE_SHIPPING_".strtoupper($tmp[1])."_TAX_CLASS') ";
-        $rs = $this->db->getOne($sql);
-        $preis = $this->getTotal($orderid,'ot_shipping');
-        if ( $preis > 0 ) {
-            if ($this->mwstS) {
-                $preis = round($preis/(100+$rs['tax_rate'])*100,2);
-            } 
-            if ($rs['tax_rate'] ==  $this->versandV['TAX']) {
-                     $artikel  = array("partnumber"=>$this->versandV['NR'],"description"=>$this->versandV['TXT'],
-                                       "qty"=>1,"unit"=>$this->versandV['Unit'],"sellprice"=>$preis);
-            } else {
-                     $artikel  = array("partnumber"=>$this->versandS['NR'],"description"=>$this->versandS['TXT'],"taxrate"=>$this->versandS['TAX'],
-                                       "qty"=>1,"unit"=>$this->versandS['Unit'],"sellprice"=>$preis);
-            }
-            return $artikel;
-        }
-        return false;
-    }
-    function getKosten($kosten,$orderid,$country) {
-        $sql  = "SELECT geo_zone_id FROM zones_to_geo_zones WHERE zone_country_id = (";
-        $sql .= "SELECT countries_id FROM countries WHERE countries_name = '$country')";
-        $rs = $this->db->getOne($sql);
-        $sql  = "SELECT tax_rate FROM tax_rates WHERE tax_zone_id = ".$rs['geo_zone_id']." AND tax_class_id = (";
-        $sql .= "SELECT configuration_value FROM  configuration WHERE configuration_key = 'MODULE_SHIPPING_".strtoupper($kosten)."_TAX_CLASS') ";
-        $rs = $this->db->getOne($sql);
-        $preis = $this->getTotal($orderid,'ot_'.$kosten);
-        if ( $preis > 0 ) {
-            //Shop muß immer Nettopreise liefern.
-            if ( $this->mwstS ) {
-                $preis = round($preis / (100+$rs['tax_rate'])*100,2);
-            } 
-                 if ( $kosten == 'cod_fee' )     { $erp = $this->nachn; }
-            else if ( $kosten == 'loworderfee' ) { $erp = $this->minder; }
-            else if ( $kosten == 'paypal_fee' )      { $erp = $this->paypal; }
-            $artikel  = array("partnumber"=>$erp['NR'],"description"=>$erp['TXT'],
-                               "qty"=>1,"unit"=>$erp['Unit'],"sellprice"=>$preis);
-            return $artikel;
-        }
-        return false;
-    }
-    function getTotal($orderid,$type) {
-        $sql = "SELECT value FROM orders_total WHERE orders_id = $orderid AND class = '$type'";
-        $rs = $this->db->getOne($sql);
-        return $rs['value'];
-    }
-    function getBestellung($employee_id) {
-        $sql = "SELECT * FROM orders WHERE orders_status=1 order by orders_id limit 1";
-        $rs=$this->db->getAll($sql);
-        if (!$rs) return array(); 
-        $data = false; 
-        foreach ($rs as $row) {
-             $artikel = $this->getBestellArtikel($row["orders_id"]);
-             $versand = $this->getVersand($row["shipping_class"],$row['orders_id'],$row['delivery_country']);
-             if ($versand) $artikel[] = $versand;
-             $nachn = $this->getKosten('cod_fee',$row['orders_id'],$row['delivery_country']);
-             if ($nachn) $artikel[] = $nachn;
-             $minder = $this->getKosten('loworderfee',$row['orders_id'],$row['delivery_country']);
-             if ($minder) $artikel[] = $minder;
-             $paypal = $this->getKosten('paypal',$row['orders_id'],$row['delivery_country']);
-             if ($paypal) $artikel[] = $paypal;
-             if ($row["delivery_country_iso_code_2"] == "DE") {
-                 $rowdata['taxzone_id'] = 0;
-             } else if (in_array($this->EU,$row["delivery_country_iso_code_2"])) {
-                 if (preg_match('/^[^0-9]{2,3}[ 0-9]+$/',$row["customers_vat_id"])) {
-                     $rowdata['taxzone_id'] = 1;
-                 } else {
-                     $rowdata['taxzone_id'] = 2;
-                 }
-             } else {
-                 $rowdata['taxzone_id'] = 3;
-             }
-             if ($rowdata["cc_number"]) {
-                 $rowdata["kreditkarte"] = $row['cc_type']."\n";
-                 $rowdata["kreditkarte"] = $row['cc_number']." ID:".$row['cc_cvv']."\n";
-                 $rowdata["kreditkarte"] = $row['cc_expires']."\n";
-                 $rowdata["kreditkarte"] = $row['cc_owner']."\n";
-             }
-             $rowdata['cusordnumber']   = $row['orders_id'];
-             $rowdata["versandart"] = $this->_toERP($row["shipping_method"]);
-             $rowdata["notes"] = $this->_toERP($row["comments"]);
-             $rowdata["curr"] = $this->_toERP($row["currency"]);
-             $rowdata["transdate"] = substr($row["date_purchased"],0,10);
-             $rowdata["shipvia"] = $this->_toERP($row["shipping_method"]);
-             $rowdata["employee_id"] = $employee_id;
-             $rowdata["parts"] = $artikel;
-             $rowdata["mwst"] = $this->getTotal($row['orders_id'],'ot_tax');
-             $rowdata["amount"]= $this->getTotal($row['orders_id'],'ot_total');
-             $rowdata["netamount"] = $this->getTotal($row['orders_id'],'ot_subtotal');
-             if ($row['delivery_company']) {
-                 $delivery['name']    = $row['delivery_company'];
-                 $delivery['contact'] = $row['delivery_firstname']." ".$row['delivery_lastname'];
-             } else {
-                 $delivery['name']  = $row['delivery_lastname'].', '.$row['delivery_firstname'];
-             }
-             $delivery['street']    = $row['delivery_street_address'];
-             $delivery['city']      = $row['delivery_city'];
-             $delivery['zipcode']   = $row['delivery_postcode'];
-             $delivery['country']   = $row['delivery_country'];
-             $delivery['phone']     = $row['delivery_telephone'];
-             $delivery['email']     = $row['delivery_email_address'];
-             if ($row['customers_company']) {
-                 $customer['name']    = $row['customers_company'];
-                 $customer['contact'] = $row['customers_firstname']." ".$row['customers_lastname'];
-                 $customer['greeting']  = 'Firma';
-             } else {
-                 $customer['name']  = $row['customers_lastname'].', '.$row['customers_firstname'];
-                 $customer['greeting']  = ($row['customers_gender'] == 'm')?'Herr':'Frau';
-             }
-             $customer['shopid']    = $row['customers_id'];
-             $customer['street']    = $row['customers_street_address'];
-             $customer['city']      = $row['customers_city'];
-             $customer['zipcode']   = $row['customers_postcode'];
-             $customer['country']   = $row['customers_country'];
-             $customer['phone']     = $row['customers_telephone'];
-             $customer['email']     = $row['customers_email_address'];
-             $customer['contact']   = $row['customers_name'];
-             $customer['customer_id']   = $row['customers_cid'];
-             $rowdata['customer']   = $customer;
-             if ( $customer != $delivery ) $rowdata['delivery'] = $delivery;
-             $rowdata["customer"]['customernumber'] = $row['customers_cid'];
-             $data[] = $rowdata;
-        }
-        return $data;
-    }
-    function getBestellArtikel($bestellung) {
-        if (!$this->kategorien) $this->getKategorien();
-       $sql  = "SELECT OP.*,D.products_description,PC.categories_id as katid,PV.products_vpe_name,P.products_ean,P.products_image,P.products_weight ";
-        $sql .= "FROM orders_products OP ";
-        $sql .= "LEFT JOIN products_description D on OP.products_id=D.products_id ";
-        $sql .= "LEFT JOIN products P on OP.products_id=P.products_id ";
-        $sql .= "LEFT JOIN products_to_categories PC on OP.products_id = PC.products_id ";
-        $sql .= "LEFT JOIN products_vpe PV ON PV.products_vpe_id = P.products_vpe ";
-        $sql .= "WHERE (PV.language_id = ".$this->language." OR PV.language_id is Null) AND D.language_id = ".$this->language;
-        $sql .= " AND OP.orders_id = $bestellung";
-        $rs=$this->db->getAll($sql);
-        if (!$rs) {
-             $this->error->write("xtc","Die Artikel der Bestellung $bestellung konnte nicht gelesen werden");
-             return false;
-        }
-        foreach ($rs as $row) {
-            $row['partsgroup'] = $this->_toERP($this->Kategorien[$row['katid']]);
-            $variant = $this->getVariant($row['orders_id'],$row['orders_products_id']);
-            if ( $this->variantnr == 1 ) {
-                $row['products_name'] = $this->_toERP($row['products_name'].$variant);
-                $row['products_description'] = $this->_toERP($row['products_description']);
-            } else {
-                $row['products_name'] = $this->_toERP($row['products_name']);
-                $row['products_description'] = $this->_toERP($variant.$row['products_description']);
-            }
-            //Shop muß immer Nettopreise liefern.
-            if ($this->mwstS) {
-                $row['products_price'] = round($row['products_price'] / (100+$row['products_tax'])*100,2);
-            }
-            $row['products_vpe_name'] = ( $row['products_vpe_name'] )?$this->_toERP($row['products_vpe_name']):$this->unit;
-            $row['partsgroup'] = $this->_toERP($this->Kategorien[$row['katid']]);
-            $data[] = $this->translateTable($row,"orderparts");
-        }
-        return $data;
-    }
-    function getVariant($oid,$aid) {
-        $sql  = "SELECT * FROM orders_products_attributes WHERE orders_id = $oid AND orders_products_id = $aid";
-        $rs = $this->db->getAll($sql);
-        if ( $this->variantnr == 1 ) { $start = "\n"; $end = ""; }
-        else { $start = ""; $end = "\n"; }
-        $txt = '';
-        if ($rs) foreach ($rs as $row) {
-            $txt .= $start.sprintf('%s: %s %s%0.2f',$row['products_options'],$row['products_options_values'],$row['price_prefix'],$row['options_values_price']).$end;
-        };
-        return $txt;
-    }
-    function setAbgeholt($bestellung) {
-        $sql = "UPDATE orders SET orders_status ='3' WHERE orders_id = $bestellung"; // in ($bestellungen)";
-        $rc = $this->db->query($sql);
-        if (!$rc) {
-            $this->error->write("xtc","Die Bestellung $bestellung konnten nicht als abgeholt markiert werden");
-            return false;
-        } else {
-            return true;
-        }
-    }
-    function setKundenNr($id,$nr) {
-        $sql = "UPDATE customers SET customers_cid = '$nr' WHERE customers_id = $id";
-        $rc = $this->db->query($sql);
-        if (!$rc) {
-            $this->error->write("xtc","Die Kundennummer $nr konnte nicht dem Kunden $id zugeordnet werden");
-            return false;
-        } else {
-            return true;
-        }
-    }
-    function getAllArtikel() {
-        if (!$this->Kategorien) $this->getKategorien();
-       $sql  = "SELECT P.*,D.*,PC.categories_id as katid,T.tax_rate as products_tax,PV.products_vpe_name FROM products P ";
-        $sql .= "LEFT JOIN products_description D on P.products_id=D.products_id ";
-        $sql .= "LEFT JOIN products_to_categories PC on P.products_id = PC.products_id ";
-        $sql .= "LEFT JOIN tax_rates T ON T.tax_class_id = P.products_tax_class_id ";
-        $sql .= "LEFT JOIN products_vpe PV ON PV.products_vpe_id = P.products_vpe ";
-        $sql .= "WHERE T.tax_zone_id = ".$this->tax_zone." AND ";
-        $sql .= "PV.language_id = ".$this->language." AND D.language_id = ".$this->language;
-        $rs = $this->db->getAll($sql);
-        if ($rs) foreach ($rs as $row) {
-            $row['partsgroup'] = $this->_toERP($this->Kategorien[$row['katid']]);
-            $row['name'] = $this->_toERP($row['products_name']);
-            $row['beschreibung'] = $this->_toERP($row['products_description']);
-            //if (!$this->mwstLX) $row['products_price'] = round(($row['products_price'] / (100 + $row['mwst_satz']) * 100),$this->dezimal);
-            $data[] = $this->translateTable($row,"orderparts");
-        }
-        return $data;
-    }
-    function getKategorien() {
-        $sql  = "SELECT C.categories_id,D.categories_name,C.parent_id ";
-        $sql .= "FROM categories C LEFT JOIN categories_description D ON C.categories_id=D.categories_id ";
-        $sql .= "WHERE C.parent_id >= 0 order by C.parent_id AND D.language_id = ".$this->language;
-        $rs = $this->db->getAll($sql);
-        if ($rs) {
-            foreach($rs as $row) { $this->katrs[$row['categories_id']] = $row;};
-            foreach($this->katrs as $row) {
-            if ($row['parent_id'] == '0') {
-                $name = $row['categories_name'];
-            } else {
-                $name = $this->mkKategorien($row['categories_id'],'');
-            }
-            $this->Kategorien[$row['categories_id']] = $name;
-            }
-        }
-    }
-    function mkKategorien($id,$name) {
-        if ($this->katrs[$id]['parent_id'] == '0') {
-           if ($name) {
-                return $this->katrs[$id]['categories_name'].'!'.$name;
-            } else {
-                return $this->katrs[$id]['categories_name']."#";
-            }
-        } else {
-           if (!$name) {
-               $name = $this->katrs[$id]['categories_name'];
-           } else {
-               $name = $this->katrs[$id]['categories_name'].'!'.$name;
-           }
-               $name = $this->mkKategorien($this->katrs[$id]['parent_id'],$name);
-        }
-        return $name;
-    }
-}
-?>