--- /dev/null
+The Artistic License
+
+Preamble
+
+The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications.
+
+Definitions:
+
+ * "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification.
+ * "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder.
+ * "Copyright Holder" is whoever is named in the copyright or copyrights for the package.
+ * "You" is you, if you're thinking about copying or distributing this Package.
+ * "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.)
+ * "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it.
+
+1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers.
+
+2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version.
+
+3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following:
+
+ a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package.
+
+ b) use the modified Package only within your corporation or organization.
+
+ c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version.
+
+ d) make other distribution arrangements with the Copyright Holder.
+
+4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following:
+
+ a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version.
+
+ b) accompany the distribution with the machine-readable source of the Package with your modifications.
+
+ c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version.
+
+ d) make other distribution arrangements with the Copyright Holder.
+
+5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own.
+
+6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package.
+
+7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package.
+
+8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission.
+
+9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+
+The End
+
--- /dev/null
+<?
+// Verbindung zur ERP-db
+$ERPuser="lxoffice";
+$ERPpass="geheim";
+$ERPhost="localhost";
+$ERPport="";
+$ERPdbname="stable";
+$ERPdns="pgsql://$ERPuser:$ERPpass@$ERPhost/$ERPdbname";
+$ERPusr["Name"]="hli";
+$ERPusr["ID"]="376";
+$ERPdir="tmp/shopartikel.csv";
+$ERPimgdir="/usr/lib/lx-office-erp";
+$maxSize="";
+$ERPftphost="localhost";
+$ERPftpuser="olcom";
+$ERPftppwd="olcom";
+//Verbindung zur osCommerce-db
+$SHOPuser="root";
+$SHOPpass="db4web";
+$SHOPhost="localhost";
+$SHOPport="";
+$SHOPdbname="olc";
+$dbprefix="";
+$SHOPlang="Array";
+$SHOPdns="mysql://$SHOPuser:$SHOPpass@$SHOPhost/$SHOPdbname";
+$SHOPdir="tmp/shopartikel.csv";
+$SHOPimgdir="/var/www/olcommerce/images/product_images";
+$SHOPftphost="localhost";
+$SHOPftpuser="olcom";
+$SHOPftppwd="olcom";
+$versand["ID"]="1568";
+$div16["ID"]="413";
+$div07["ID"]="414";
+$nachn["ID"]="413";
+$minder["ID"]="";
+$paypal["ID"]="413";
+$versand["TAX"]="16.00000";
+$div16["TAX"]="16.00000";
+$div07["TAX"]="7.00000";
+$nachn["TAX"]="16.00000";
+$minder["TAX"]="";
+$paypal["TAX"]="16.00000";
+$versand["NR"]="versand";
+$div16["NR"]="div16";
+$div07["NR"]="div07";
+$nachn["NR"]="div16";
+$minder["NR"]="";
+$paypal["NR"]="div16";
+$div16["TXT"]="Diverse Artikel 16% MWSt.";
+$div07["TXT"]="Diverse Artikel 7% MWSt.";
+$versand["TXT"]="Versandkosten";
+$nachn["TXT"]="Diverse Artikel 16% MWSt.";
+$minder["TXT"]="";
+$paypal["TXT"]="Diverse Artikel 16% MWSt.";
+$bgcol[1]="#ddddff";
+$bgcol[2]="#ddffdd";
+$preA="";
+$preK="";
+$auftrnr="1";
+$debug=false;
+$kdnum="1";
+$stdprice="0";
+$altprice="0";
+$KDGrp="";
+$nopic="bilder/lx-office-crm.png";
+$showErr="true";
+$Language[0]=array("ERP"=>0,"SHOP"=>2);
+$Language[1]=array("ERP"=>2204,"SHOP"=>0);
+$SHOPdefaultlang="2";
+$SpracheAlle="false";
+?>
\ No newline at end of file
--- /dev/null
+<?
+// $Id: confedit.php,v 1.3 2004/06/30 11:34: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üssen sich autentifizieren\n";
+ exit;
+} else {
+ $login=($_GET["login"])?$_GET["login"]:$_POST["login"];
+ if (file_exists ("conf$login.php")) {
+ require "conf$login.php";
+ } else {
+ require "conf.php";
+ }
+ 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üssen sich autentifizieren\n";
+ exit;
+ }
+ require_once "DB.php";
+ function pg($sel) {
+ global $dbP;
+ echo "\t<option value=0";
+ if ($sel==0) echo " selected";
+ echo ">Standard VK\n";
+ if (!$dbP) return;
+ $sql="select id,pricegroup from pricegroup";
+ $pgs=$dbP->getall($sql);
+ if ($pgs) foreach ($pgs as $row) {
+ echo "\t<option value=".$row[0];
+ if ($sel==$row[0]) echo " selected";
+ echo ">".$row[1]."\n";
+ }
+ }
+ function shoplang($sel,$default) {
+ global $dbM;
+ $sql="SELECT L.*, C.configuration_value FROM languages L LEFT JOIN configuration C ";
+ $sql.="ON L.code = C.configuration_value";
+ $rs=$dbM->getAll($sql,DB_FETCHMODE_ASSOC);
+ if (!$rs) {
+ echo "\t\t<option value='0'>keine Sprachen\n";
+ } else {
+ echo "\t\t<option value='0' ".(($sel==0)?"selected":"").">nicht verwenden\n";
+ foreach ($rs as $row) {
+ if ($default["id"]<>$row["languages_id"]) {
+ echo "\t\t<option value='".$row["languages_id"]."' ";
+ echo (($row["languages_id"]==$sel)?"selected":"").">";
+ echo ($row["code"]==$row["configuration_value"])?"!":" ";
+ echo $row["name"]."\n";
+ }
+ }
+ }
+ }
+ function erplang($sel) {
+ global $dbP;
+ $sql="select * from language";
+ $rs=$dbP->getAll($sql,DB_FETCHMODE_ASSOC);
+ if (!$rs) {
+ echo "\t\t<option>keine Sprachen\n";
+ } else {
+ //echo "\t\t<option value='0' ".(($sel==0)?"selected":"").">Standard\n";
+ foreach ($rs as $row) {
+ echo "\t\t<option value='".$row["id"]."' ";
+ echo ($sel==$row["id"])?"selected":"";
+ echo ">".$row["description"]."\n";
+ }
+ }
+ }
+ function getERPlangs() {
+ global $dbP;
+ $sql="select * from language";
+ $rs=$dbP->getAll($sql,DB_FETCHMODE_ASSOC);
+ return $rs;
+ }
+ function getShopDefault() {
+ global $dbM;
+ if (!$dbM) return false;
+ $sql="select * from languages L left join configuration C on L.code=C.configuration_value ";
+ $sql.="where configuration_key = 'DEFAULT_LANGUAGE'";
+ $rs=$dbM->getAll($sql,DB_FETCHMODE_ASSOC);
+ if ($rs) {
+ return array("id"=>$rs[0]["languages_id"],"name"=>$rs[0]["name"]);
+ } else {
+ return 0;
+ }
+ }
+ if ($_POST["ok"]=="sichern") {
+ $ok=true;
+ if ($_POST["ERPpass"]) {
+ $dsnP="pgsql://".$_POST["ERPuser"].":".$_POST["ERPpass"]."@".$_POST["ERPhost"]."/".$_POST["ERPdbname"];
+ } else {
+ $dsnP="pgsql://".$_POST["ERPuser"]."@".$_POST["ERPhost"]."/".$_POST["ERPdbname"];
+ }
+ $dbP=@DB::connect($dsnP);
+ if (DB::isError($dbP)||!$dbP) {
+ $ok=false;
+ echo "Keine Verbindung zur ERP<br>";
+ echo $dbP->userinfo;
+ $dbP=false;
+ } else {
+ //Steuertabelle ERP
+ $sql ="select BG.id as bugru,T.rate,TK.startdate from buchungsgruppen BG left join chart C ";
+ $sql.="on BG.income_accno_id_0=C.id left join taxkeys TK on TK.chart_id=C.id left join tax T ";
+ $sql.="on T.id=TK.tax_id where TK.startdate <= now()";
+ $rs=$dbP->getAll($sql,DB_FETCHMODE_ASSOC);
+ $erptax=array();
+ foreach ($rs as $row) {
+ if ($erptax[$row["bugru"]]["startdate"]<$row["startdate"]) {
+ $erptax[$row["bugru"]]["startdate"]=$row["startdate"];
+ $erptax[$row["bugru"]]["rate"]=sprintf("%1.4f",$row["rate"]*100);
+ }
+ }
+ $sql ="select P.id,P.description,P.buchungsgruppen_id as bugru from ";
+ $sql.="parts P where P.partnumber = '%s'";
+ $rs=$dbP->getall(sprintf($sql,$_POST["div16NR"]));
+ $_POST["div16ID"]=$rs[0][0];
+ $div16txt=$rs[0][1];
+ $_POST["div16TAX"]=$erptax[$rs[0][2]]["rate"];
+ $rs=$dbP->getall(sprintf($sql,$_POST["div07NR"]));
+ $_POST["div07ID"]=$rs[0][0];
+ $_POST["div07TAX"]=$erptax[$rs[0][2]]["rate"];
+ $div07txt=$rs[0][1];
+ $rs=$dbP->getall(sprintf($sql,$_POST["versandNR"]));
+ $_POST["versandID"]=$rs[0][0];
+ $_POST["versandTAX"]=$erptax[$rs[0][2]]["rate"];
+ $versandtxt=$rs[0][1];
+ $rs=$dbP->getall(sprintf($sql,$_POST["nachnNR"]));
+ $_POST["nachnID"]=$rs[0][0];
+ $_POST["nachnTAX"]=$erptax[$rs[0][2]]["rate"];
+ $nachntxt=$rs[0][1];
+ $rs=$dbP->getall(sprintf($sql,$_POST["minderNR"]));
+ $_POST["minderID"]=$rs[0][0];
+ $_POST["minderTAX"]=$erptax[$rs[0][2]]["rate"];
+ $mindertxt=$rs[0][1];
+ $rs=$dbP->getall(sprintf($sql,$_POST["paypalNR"]));
+ $_POST["paypalID"]=$rs[0][0];
+ $_POST["paypalTAX"]=$erptax[$rs[0][2]]["rate"];
+ $paypaltxt=$rs[0][1];
+ $rs=$dbP->getall("select id from employee where login = '".$_POST["ERPusrN"]."'");
+ $_POST["ERPusrID"]=$rs[0][0];
+ }
+ if ($_POST["SHOPpass"]) {
+ $dsnM="mysql://".$_POST["SHOPuser"].":".$_POST["SHOPpass"]."@".$_POST["SHOPhost"]."/".$_POST["SHOPdbname"];
+ } else {
+ $dsnM="mysql://".$_POST["SHOPuser"]."@".$_POST["SHOPhost"]."/".$_POST["SHOPdbname"];
+ }
+ $dbM=@DB::connect($dsnM);
+ if (DB::isError($dbM)||!$dbM) {
+ $ok=false;
+ echo "Keine Verbindung zum Shop<br>";
+ echo $dbM->userinfo;
+ $dbM=false;
+ };
+ if ($ok) {
+ $ShopDefaultLang=getShopDefault();
+ $f=fopen("conf$login.php","w");
+ $v="1.6";
+ $d=date("Y/m/d H:i:s");
+ fputs($f,"<?\n// Verbindung zur ERP-db\n");
+ fputs($f,"\$ERPuser=\"".$_POST["ERPuser"]."\";\n");
+ fputs($f,"\$ERPpass=\"".$_POST["ERPpass"]."\";\n");
+ fputs($f,"\$ERPhost=\"".$_POST["ERPhost"]."\";\n");
+ fputs($f,"\$ERPport=\"".$_POST["ERPport"]."\";\n");
+ fputs($f,"\$ERPdbname=\"".$_POST["ERPdbname"]."\";\n");
+ fputs($f,"\$ERPdns=\"pgsql://\$ERPuser:\$ERPpass@\$ERPhost/\$ERPdbname\";\n");
+ fputs($f,"\$ERPusr[\"Name\"]=\"".$_POST["ERPusrN"]."\";\n");
+ fputs($f,"\$ERPusr[\"ID\"]=\"".$_POST["ERPusrID"]."\";\n");
+ fputs($f,"\$ERPdir=\"".$_POST["ERPdir"]."\";\n");
+ fputs($f,"\$ERPimgdir=\"".$_POST["ERPimgdir"]."\";\n");
+ fputs($f,"\$maxSize=\"".$_POST["maxSize"]."\";\n");
+ fputs($f,"\$ERPftphost=\"".$_POST["ERPftphost"]."\";\n");
+ fputs($f,"\$ERPftpuser=\"".$_POST["ERPftpuser"]."\";\n");
+ fputs($f,"\$ERPftppwd=\"".$_POST["ERPftppwd"]."\";\n");
+ fputs($f,"//Verbindung zur osCommerce-db\n");
+ fputs($f,"\$SHOPuser=\"".$_POST["SHOPuser"]."\";\n");
+ fputs($f,"\$SHOPpass=\"".$_POST["SHOPpass"]."\";\n");
+ fputs($f,"\$SHOPhost=\"".$_POST["SHOPhost"]."\";\n");
+ fputs($f,"\$SHOPport=\"".$_POST["SHOPport"]."\";\n");
+ fputs($f,"\$SHOPdbname=\"".$_POST["SHOPdbname"]."\";\n");
+ fputs($f,"\$dbprefix=\"".$_POST["dbprefix"]."\";\n");
+ fputs($f,"\$SHOPlang=\"".$_POST["SHOPlang"]."\";\n");
+ fputs($f,"\$SHOPdns=\"mysql://\$SHOPuser:\$SHOPpass@\$SHOPhost/\$SHOPdbname\";\n");
+ fputs($f,"\$SHOPdir=\"".$_POST["SHOPdir"]."\";\n");
+ fputs($f,"\$SHOPimgdir=\"".$_POST["SHOPimgdir"]."\";\n");
+ fputs($f,"\$SHOPftphost=\"".$_POST["SHOPftphost"]."\";\n");
+ fputs($f,"\$SHOPftpuser=\"".$_POST["SHOPftpuser"]."\";\n");
+ fputs($f,"\$SHOPftppwd=\"".$_POST["SHOPftppwd"]."\";\n");
+ fputs($f,"\$versand[\"ID\"]=\"".$_POST["versandID"]."\";\n");
+ fputs($f,"\$div16[\"ID\"]=\"".$_POST["div16ID"]."\";\n");
+ fputs($f,"\$div07[\"ID\"]=\"".$_POST["div07ID"]."\";\n");
+ fputs($f,"\$nachn[\"ID\"]=\"".$_POST["nachnID"]."\";\n");
+ fputs($f,"\$minder[\"ID\"]=\"".$_POST["minderID"]."\";\n");
+ fputs($f,"\$paypal[\"ID\"]=\"".$_POST["paypalID"]."\";\n");
+ fputs($f,"\$versand[\"TAX\"]=\"".$_POST["versandTAX"]."\";\n");
+ fputs($f,"\$div16[\"TAX\"]=\"".$_POST["div16TAX"]."\";\n");
+ fputs($f,"\$div07[\"TAX\"]=\"".$_POST["div07TAX"]."\";\n");
+ fputs($f,"\$nachn[\"TAX\"]=\"".$_POST["nachnTAX"]."\";\n");
+ fputs($f,"\$minder[\"TAX\"]=\"".$_POST["minderTAX"]."\";\n");
+ fputs($f,"\$paypal[\"TAX\"]=\"".$_POST["paypalTAX"]."\";\n");
+ fputs($f,"\$versand[\"NR\"]=\"".$_POST["versandNR"]."\";\n");
+ fputs($f,"\$div16[\"NR\"]=\"".$_POST["div16NR"]."\";\n");
+ fputs($f,"\$div07[\"NR\"]=\"".$_POST["div07NR"]."\";\n");
+ fputs($f,"\$nachn[\"NR\"]=\"".$_POST["nachnNR"]."\";\n");
+ fputs($f,"\$minder[\"NR\"]=\"".$_POST["minderNR"]."\";\n");
+ fputs($f,"\$paypal[\"NR\"]=\"".$_POST["paypalNR"]."\";\n");
+ fputs($f,"\$div16[\"TXT\"]=\"".$div16txt."\";\n");
+ fputs($f,"\$div07[\"TXT\"]=\"".$div07txt."\";\n");
+ fputs($f,"\$versand[\"TXT\"]=\"".$versandtxt."\";\n");
+ fputs($f,"\$nachn[\"TXT\"]=\"".$nachntxt."\";\n");
+ fputs($f,"\$minder[\"TXT\"]=\"".$mindertxt."\";\n");
+ fputs($f,"\$paypal[\"TXT\"]=\"".$paypaltxt."\";\n");
+ fputs($f,"\$bgcol[1]=\"#ddddff\";\n");
+ fputs($f,"\$bgcol[2]=\"#ddffdd\";\n");
+ fputs($f,"\$preA=\"".$_POST["preA"]."\";\n");
+ fputs($f,"\$preK=\"".$_POST["preK"]."\";\n");
+ fputs($f,"\$auftrnr=\"".$_POST["auftrnr"]."\";\n");
+ fputs($f,"\$debug=".$_POST["debug"].";\n");
+ fputs($f,"\$kdnum=\"".$_POST["kdnum"]."\";\n");
+ fputs($f,"\$stdprice=\"".$_POST["stdprice"]."\";\n");
+ fputs($f,"\$altprice=\"".$_POST["altprice"]."\";\n");
+ fputs($f,"\$KDGrp=\"".$_POST["KDGrp"]."\";\n");
+ fputs($f,"\$nopic=\"".$_POST["nopic"]."\";\n");
+ fputs($f,"\$showErr=\"true\";\n");
+ $Language=array();
+ $DefaultLangOk=false;
+ if ($_POST["ERPlang"]) foreach ($_POST["ERPlang"] as $key=>$val) {
+ if ($_POST["SHOPlang"][$key]==$ShopDefaultLang["id"]) $DefaultLangOk=true;
+ $sl=($_POST["SHOPlang"][$key])?$_POST["SHOPlang"][$key]:0;
+ fputs($f,"\$Language[$key]=array(\"ERP\"=>$val,\"SHOP\"=>".$sl.");\n");
+ }
+ if (!$DefaultLangOk) {
+ fputs($f,"\$SHOPdbname=\"\";\n");
+ echo "Es wurde keine ERP-Sprache der Shopdefaultsprache zugewiesen.";
+ echo "Verbindung zum Shop abgebrochen<br>";
+ }
+ fputs($f,"\$SHOPdefaultlang=\"".$ShopDefaultLang["id"]."\";\n");
+ fputs($f,"\$SpracheAlle=\"".$_POST["SpracheAlle"]."\";\n");
+ fputs($f,"?>");
+ fclose($f);
+ require "conf$login.php";
+ if ($dbprefix<>"") $pre=$dbprefix."_";
+ $sql="select count(*) from ".$pre."customers_number";
+ $rc=@$dbM->query($sql);
+ if ($rc->code==-18) {
+ $sql="CREATE TABLE ".$pre."customers_number ( cid int(6) NOT NULL auto_increment, customers_id int(3) NOT NULL default '0', ";
+ $sql.="kdnr int NOT NULL default '0', shipto int, PRIMARY KEY (cid)) TYPE=MyISAM";
+ $rc=@$dbM->query($sql);
+ if ($rc->code==-1) {
+ echo "Fehler beim Erzeugen der Tabelle '".$pre."customers_number' in der Shop-db";
+ } else {
+ echo "Tabelle '".$pre."customers_number' in der Shop-db angelegt.";
+ }
+ } else {
+ $sql="select shipto from ".$pre."customers_number limit 1";
+ $rc=@$dbM->query($sql);
+ if ($rc->code==-19) {
+ $sql="alter table ".$pre."customers_number add column shipto int";
+ $rc=@$dbM->query($sql);
+ if ($rc->code==-1) {
+ echo "Fehler beim Anlegen der Spalte 'shipto' in 'customers_number'";
+ } else {
+ echo "'shipto' in 'customers_number' angelegt.";
+ }
+ }
+ }
+ } else {
+ $ERPuser=$_POST["ERPuser"];
+ $ERPpass=$_POST["ERPpass"];
+ $ERPhost=$_POST["ERPhost"];
+ $ERPport=$_POST["ERPport"];
+ $ERPdbname=$_POST["ERPdbname"];
+ $ERPusrN=$_POST["ERPusrN"];
+ $ERPdir=$_POST["ERPdir"];
+ $ERPimgdir=$_POST["ERPimgdir"];
+ $maxSize=$_POST["maxSize"];
+ $ERPftphost=$_POST["ERPftphost"];
+ $ERPftpuser=$_POST["ERPftpuser"];
+ $ERPftppwd=$_POST["ERPftppwd"];
+ $SHOPuser=$_POST["SHOPuser"];
+ $SHOPpass=$_POST["SHOPpass"];
+ $SHOPhost=$_POST["SHOPhost"];
+ $SHOPport=$_POST["SHOPport"];
+ $SHOPdbname=$_POST["SHOPdbname"];
+ $dbprefix=$_POST["dbprefix"];
+ $SHOPlang=$_POST["SHOPlang"];
+ $SHOPdir=$_POST["SHOPdir"];
+ $SHOPimgdir=$_POST["SHOPimgdir"];
+ $SHOPftphost=$_POST["SHOPftphost"];
+ $SHOPftpuser=$_POST["SHOPftpuser"];
+ $SHOPftppwd=$_POST["SHOPftppwd"];
+ $div16NR=$_POST["div16NR"];
+ $div07NR=$_POST["div07NR"];
+ $versandNR=$_POST["versandNR"];
+ $nachnNR=$_POST["nachnNR"];
+ $minderNR=$_POST["minderNR"];
+ $paypalNR=$_POST["paypalNR"];
+ $preA=$_POST["preA"];
+ $preK=$_POST["preK"];
+ $kdnum=$_POST["kdnum"];
+ $auftrnr=$_POST["auftrnr"];
+ $debug=$_POST["debug"];
+ $altprice=$_POST["altprice"];
+ $stdprice=$_POST["stdprice"];
+ $nopic=$_POST["nopic"];
+ }
+ $ERPlangs=getERPlangs();
+ $CntERPLang=count($ERPlangs); //$rs[0][0];
+ } else {
+ if (file_exists ("conf$login.php")) {
+ require "conf$login.php";
+ } else {
+ require "conf.php";
+ }
+ $dsnP = array(
+ 'phptype' => 'pgsql',
+ 'username' => $ERPuser,
+ 'password' => $ERPpass,
+ 'hostspec' => $ERPhost,
+ 'database' => $ERPdbname,
+ 'port' => $ERPport
+ );
+ $dbP=@DB::connect($dsnP);
+ if (DB::isError($dbP)||!$dbP) {
+ echo "Keine Verbindung zur ERP<br>";
+ $dbP=false;
+ //echo $dbP->userinfo;
+ } else {
+ //$rs=$dbP->getAll("select count(*) from language");
+ $ERPlangs=getERPlangs();
+ $CntERPLang=count($ERPlangs); //$rs[0][0];
+ }
+ $dsnM = array(
+ 'phptype' => 'mysql',
+ 'username' => $SHOPuser,
+ 'password' => $SHOPpass,
+ 'hostspec' => $SHOPhost,
+ 'database' => $SHOPdbname,
+ 'port' => $SHOPport
+ );
+ $dbM=@DB::connect($dsnM);
+ if (DB::isError($dbM)||!$dbM) {
+ echo "Keine Verbindung zum SHOP<br>";
+ //echo $dbM->userinfo;
+ $dbM=false;
+ } else {
+ $ShopDefaultLang=getShopDefault();
+ }
+ }
+ ?>
+<html>
+<body>
+<center>
+<table style="background-color:#cccccc">
+<form name="ConfEdit" method="post" action="confedit.php">
+<input type="hidden" name="div16ID" value="<?= $div16["ID"] ?>">
+<input type="hidden" name="div07ID" value="<?= $div07["ID"] ?>">
+<input type="hidden" name="minderID" value="<?= $minder["ID"] ?>">
+<input type="hidden" name="versandID" value="<?= $versand["ID"] ?>">
+<input type="hidden" name="nachnID" value="<?= $nachn["ID"] ?>">
+<input type="hidden" name="paypalID" value="<?= $paypal["ID"] ?>">
+<input type="hidden" name="ERPusrID" value="<?= $ERPusr["ID"] ?>">
+<input type="hidden" name="login" value="<?= $login ?>">
+<tr><th>Daten</th><th>Lx-ERP</th><th></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>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>User-ID</td>
+ <td colspan="2"><input type="text" name="ERPusrN" size="10" value="<?= $ERPusr["Name"] ?>">
+ <input type="checkbox" name="a1" <?= (empty($ERPusr["ID"])?"":"checked") ?> onFocus="blur();">
+ db-Prefix
+ </td>
+ <td><input type="text" name="dbprefix" size="15" value="<?= $dbprefix ?>"></td>
+</tr>
+<tr>
+ <td>CSV-Dir</td>
+ <td colspan="2"><input type="text" name="ERPdir" size="30" value="<?= $ERPdir ?>"></td>
+ <td><input type="text" name="SHOPdir" size="30" value="<?= $SHOPdir ?>"></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>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>ID Diverse 16%</td>
+ <td><input type="text" name="div16NR" size="10" value="<?= $div16["NR"] ?>">
+ <input type="checkbox" name="a1" <?= (empty($div16["ID"])?"":"checked") ?>></td>
+ <td>ID Diverse 7%</td>
+ <td><input type="text" name="div07NR" size="10" value="<?= $div07["NR"] ?>">
+ <input type="checkbox" name="a1" <?= (empty($div07["ID"])?"":"checked") ?>></td>
+</tr>
+<tr>
+ <td>ID Versand</td>
+ <td><input type="text" name="versandNR" size="10" value="<?= $versand["NR"] ?>">
+ <input type="checkbox" name="a1" <?= (empty($versand["ID"])?"":"checked") ?>></td>
+ <td>ID Nachname</td>
+ <td><input type="text" name="nachnNR" size="10" value="<?= $nachn["NR"] ?>">
+ <input type="checkbox" name="a1" <?= (empty($nachn["ID"])?"":"checked") ?>></td>
+</tr>
+<tr>
+ <td>ID Paypal</td>
+ <td><input type="text" name="paypalNR" size="10" value="<?= $paypal["NR"] ?>">
+ <input type="checkbox" name="a1" <?= (empty($paypal["ID"])?"":"checked") ?>></td>
+ <td>ID Mindemenge</td>
+ <td><input type="text" name="minderNR" size="10" value="<?= $minder["NR"] ?>">
+ <input type="checkbox" name="a1" <?= (empty($minder["ID"])?"":"checked") ?>></td>
+</tr>
+<tr>
+ <td >Sprachen</td>
+ <td ><input type="hidden" name="ERPlang[0]" value="0">Standard</td>
+ <td >--></td>
+ <td ><input type="hidden" name="SHOPlang[0]" value="<?= $ShopDefaultLang["id"] ?>"><?= $ShopDefaultLang["name"] ?></td>
+</tr>
+<? for($i=0; $i < $CntERPLang; $i++) { ?>
+<tr>
+ <td >Sprachen</td>
+ <td><input type="hidden" name="ERPlang[<?= $i+1 ?>]" value="<?= $ERPlangs[$i]["id"] ?>"><?= $ERPlangs[$i]["description"] ?>
+ <td >--></td>
+ <td ><select name="SHOPlang[<?= $i+1 ?>]">
+<?= shoplang($Language[$i+1]["SHOP"],$ShopDefaultLang); ?>
+ </select></td>
+</tr>
+<? } ?>
+<tr>
+ <td colspan="2">Nur übersetzte Artikel</td>
+ <td><input type="radio" name="SpracheAlle" value="true" <?= ($SpracheAlle=="true")?"checked":"" ?>> Ja</td>
+ <td><input type="radio" name="SpracheAlle" value="false" <?= ($SpracheAlle<>"true")?"checked":"" ?>> Nein</td>
+</tr>
+<tr>
+ <td>Standardpreis</td>
+ <td><select name="stdprice">
+<? pg($stdprice); ?>
+ </select></td>
+ <td>Defaultbild</td>
+ <td><input type="text" name="nopic" size="20" value="<?= $nopic ?>">
+<tr>
+ <td>abweichender Preis</td>
+ <td><select name="altprice">
+<? pg($altprice); ?>
+ </select></td>
+ <td>Kundengruppe</td>
+ <td><input type="text" name="KDGrp" size="3" value="<?= $KDGrp ?>">
+</tr>
+<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>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 colspan="4" align="center"><input type="submit" name="ok" value="sichern"></td></tr>
+</form>
+</table>
+</center>
+</body>
+</html>
+<? } ?>
--- /dev/null
+<?
+// $Id: diff.php,v 1.1 2004/06/30 10:12:15 hli Exp $
+require_once "DB.php";
+require_once "conf.php";
+if ($dbprefix<>"") { define("PREFIX",$dbprefix."_"); } else { define("PREFIX",""); }
+
+if (!$db) {
+ $db=DB::connect($SHOPdns);
+ if (!$db) dbFehler("",$db->getDebugInfo());
+ if (DB::isError($db)) {
+ dbFehler("",$db->getDebugInfo());
+ die ($db->getDebugInfo());
+ };
+ $db2=DB::connect($ERPdns);
+ if (!$db2) dbFehler("",$db2->getDebugInfo());
+ if (DB::isError($db2)) {
+ dbFehler("",$db2->getDebugInfo());
+ die ($db2->getDebugInfo());
+ };
+}
+if ($_POST["ok"]) {
+ foreach($_POST as $key=>$val) {
+ if ($key=="ok") continue;
+ if ($key=="alle") continue;
+ $sql="update ".PREFIX."products set products_status=0 where products_model=$key";
+ echo "$key ";
+ if ($db->query($sql)) { echo "deaktiviert<br>"; }
+ else { echo "konnte nicht deaktiviert werden<br>"; };
+ }
+} else {
+$sql="select partnumber from parts where shop='1' order by partnumber";
+$erp=$db2->getAll($sql,DB_FETCHMODE_ASSOC);
+if ($erp) foreach ($erp as $zeile) { $arE[]=$zeile["partnumber"]; };
+
+if ($SHOPlang>0) {
+ $defLang=$SHOPlang;
+} else {
+ $sql="select * from ".PREFIX."languages L left join ".PREFIX."configuration C on L.code=C.configuration_value where configuration_key = 'DEFAULT_LANGUAGE'";
+ $rs=$db->getAll($sql,DB_FETCHMODE_ASSOC);
+ if ($rs) {
+ $defLang=$rs[0]["languages_id"];
+ } else {
+ $defLang=1;
+ }
+}
+
+$sql="select products_model,P.products_id,products_name from ".PREFIX."products P left join ".PREFIX."products_description D on P.products_id=D.products_id where language_id=$defLang and products_status=1 order by products_model";
+$shop=$db->getAll($sql,DB_FETCHMODE_ASSOC);
+if ($shop) foreach ($shop as $zeile) {
+ $arS[]=$zeile["products_model"];
+ $arID[$zeile["products_model"]]=array("id"=>$zeile["products_id"],"name"=>$zeile["products_name"]);
+}
+$result=@array_diff($arS,$arE);
+if ($result) {
+?>
+<html>
+<head><title>Artikelpflege</title>
+<script language="JavaScript">
+<!--
+ function sel() {
+ val=document.doppel.alle.checked;
+ cnt=document.doppel.length;
+ for (i=0; i<cnt; i++) {
+ document.doppel.elements[i].checked=val;
+ }
+ }
+//-->
+</script>
+</head>
+<body>
+Folgende Artikel sind in der ERP nicht mehr als Shopartikel markiert.<br>
+Markieren Sie die Artikel, die deaktiviert werden sollen.<br>
+<form name='doppel' method='post' action='diff.php'>
+<table>
+<?
+foreach ($result as $data) {
+ echo "\t<tr><td><input type='checkbox' name='".$data."' value='1'></td><td>".$data."</td><td>".$arID[$data]["name"]."</td></tr>\n";
+}
+?>
+ <tr><td><input type='checkbox' name='alle' value='1' onClick="sel()"></td><td></td><td>alle Artikel</td></tr>
+ <tr><td colspan='3'><input type='submit' name='ok' value='ok'></td></tr>
+</table>
+<form>
+<? }
+ else { "Artikelbestand identisch"; };
+} ?>
+<!--a href="trans.php">zurück</a-->
--- /dev/null
+<?
+/***************************************************************
+* $Id: erpexport.php,v 1.1 2004/06/29 08:50:30 hli Exp $
+*Author: Holger Lindemann
+*Copyright: (c) 2004 Lx-System
+*License: non free
+*eMail: info@lx-system.de
+*Version: 1.0.0
+*ERP: Lx-Office ERP
+***************************************************************/
+?>
+<html>
+ <head><title>Lx-ERP Export der Shopartikel</title>
+ <link type="text/css" REL="stylesheet" HREF="css/main.css"></link>
+ <script language="JavaScript">
+ <!--
+ function xtcomm() {
+ document.fld.PN.value="products_model"; document.fld.partnumber.checked=true;
+ document.fld.BEZ.value="products_name"; document.fld.desctiption.checked=true;
+ document.fld.GEWICHT.value="products_weight"; document.fld.weight.checked=true;
+ document.fld.MWST.value="products_tax"; document.fld.rate.checked=true;
+ document.fld.VK.value="products_price"; document.fld.sellprice.checked=true;
+ document.fld.PG.value="categories_name"; document.fld.partsgroup.checked=true;
+ document.fld.BESCHR.value="products_description"; document.fld.notes.checked=true;
+ document.fld.LAGER.value="products_quantity"; document.fld.onhand.checked=true;
+ document.fld.encl.value="";
+ document.fld.deli.value=";";
+ document.fld.crln.value="\\n";
+ document.fld.head.checked=true;
+ document.fld.shop.value="xtcomm";
+ }
+ //-->
+ </script>
+<body>
+
+<?php
+require_once "DB.php";
+require_once "./conf.php";
+$db=DB::connect($ERPdns);
+if (!$db) dbFehler("",$db->getDebugInfo());
+if (DB::isError($db)) {
+ dbFehler("",$db->getDebugInfo());
+ die ($db->getDebugInfo());
+};
+/****************************************************
+* dbFehler
+* in: sql,err = string
+* out:
+* Fehlermeldungen ausgeben
+*****************************************************/
+function dbFehler($sql,$err) {
+global $showErr;
+ if ($showErr)
+ echo "</td></tr></table><font color='red'>$sql : $err</font><br>";
+}
+
+function shopartikel() {
+global $db;
+ $sql ="SELECT P.partnumber,P.description,P.unit,P.weight,t.rate,P.sellprice,P.listprice,P.priceupdate,PG.partsgroup,P.notes,P.image,P.onhand FROM ";
+ $sql.="parts P left join partsgroup PG on PG.id=P.partsgroup_id ";
+ $sql.="left join chart c on c.id = P.income_accno_id ";
+ $sql.="left join tax T on T.taxkey=C.taxkey_id ";
+ $sql.="where shop = 't'";
+ $rs=$db->getAll($sql,DB_FETCHMODE_ASSOC);
+ return $rs;
+}
+if ($_POST["export"]) {
+ $data=shopartikel();
+ $delim=($_POST["deli"])?$_POST["deli"]:",";
+ if (get_magic_quotes_gpc()) {
+ $crln = stripslashes($_POST["crln"]);
+ }
+ $crln = str_replace('\\r', "\015", $crln);
+ $crln = str_replace('\\n', "\012", $crln);
+ $crln = str_replace('\\t', "\011", $crln);
+ $encl=$_POST["encl"];
+ $i=0;
+ $f=fopen($ERPdir,"w");
+ if ($_POST["partnumber"]) {$header.=$_POST["PN"].$delim; };
+ if ($_POST["desctiption"]) {$header.=$_POST["BEZ"].$delim; };
+ if ($_POST["unit"]) {$header.=$_POST["EINHEIT"].$delim; };
+ if ($_POST["onhand"]) {$header.=$_POST["LAGER"].$delim; };
+ if ($_POST["weight"]) {$header.=$_POST["GEWICHT"].$delim; };
+ if ($_POST["rate"]) {$header.=$_POST["MWST"].$delim; };
+ if ($_POST["sellprice"]) {$header.=$_POST["VK"].$delim; };
+ if ($_POST["listprice"]) {$header.=$_POST["EK"].$delim; };
+ if ($_POST["priceupdate"]) {$header.=$_POST["PDATE"].$delim; };
+ if ($_POST["partsgroup"]) {$header.=$_POST["PG"].$delim; };
+ if ($_POST["notes"]) {$header.=$_POST["BESCHR"].$delim; };
+ if ($_POST["image"]) {$header.=$_POST["IMAGE"].$delim; };
+ $header=substr($header,0,-1);
+?>
+<table class="liste">
+<!-- BEGIN Artikel -->
+<? $i=0;
+ $f=fopen($ERPdir,"w");
+ if ($_POST["head"]) fputs($f,$header.$crln);
+ foreach($data as $zeile) {
+ $file=""; $html="";
+ if ($_POST["shop"]=="pepper") {
+ if (preg_match("/^\[.*\].*/",$zeile["partsgroup"])) { $PG=$zeile["partsgroup"]; }
+ else { $PG="[".$zeile["partsgroup"]."]"; };
+ $mwst=$zeile["rate"]*100;
+ } else if ($_POST["shop"]=="oscomm") {
+ $mwst=sprintf("%01.4f",($zeile["rate"]*100));
+ $PG=$zeile["partsgroup"];
+ } else {
+ $PG=$zeile["partsgroup"];
+ $mwst=$zeile["rate"]*100;
+ };
+ $LineCol = $bgcol[$i%2+1];
+ if ($_POST["partnumber"]) {$file.=$encl.$zeile["partnumber"].$encl.$delim; $html.="<td>".$zeile["partnumber"]."</td>";};
+ if ($_POST["desctiption"]) {$file.=$encl.strtr($zeile["description"],chr(13).chr(10)," ").$encl.$delim; $html.="<td>".$zeile["description"]."</td>";};
+ if ($_POST["unit"]) {$file.=$encl.$zeile["unit"].$encl.$delim; $html.="<td>".$zeile["unit"]."</td>";};
+ if ($_POST["onhand"]) {$file.=$encl.$zeile["onhand"].$encl.$delim; $html.="<td>".$zeile["onhand"]."</td>";};
+ if ($_POST["weight"]) {$file.=$encl.$zeile["weight"].$encl.$delim; $html.="<td>".$zeile["weight"]."</td>";};
+ if ($_POST["rate"]) {$file.=$encl.$mwst.$encl.$delim; $html.="<td>".$mwst."</td>";};
+ if ($_POST["sellprice"]) {$file.=$encl.(sprintf("%02.2f",$zeile["sellprice"])).$encl.$delim; $html.="<td>".(sprintf("%02.2f",$zeile["sellprice"]))."</td>";};
+ if ($_POST["listprice"]) {$file.=$encl.(sprintf("%02.2f",$zeile["listprice"])).$encl.$delim; $html.="<td>".(sprintf("%02.2f",$zeile["listprice"]))."</td>";};
+ if ($_POST["partsgroup"]) {$file.=$encl.$PG.$encl.$delim; $html.="<td>".$zeile["partsgroup"]."</td>";};
+ if ($_POST["notes"]) {$file.=$encl.strtr($zeile["notes"],chr(13).chr(10)," ").$encl.$delim; $html.="<td>".$zeile["notes"]."</td>";};
+ if ($_POST["image"]) {$file.=$encl.$zeile["image"].$encl.$delim; $html.="<td>".$zeile["image"]."</td>";};
+ $i++;
+ fputs($f,substr($file,0,-1).$crln);
+ if ($_POST["show"]) {
+?>
+ <tr class="smal" onMouseover="this.bgColor='#FF0000';" onMouseout="this.bgColor='<?= $LineCol ?>';" bgcolor="<?= $LineCol ?>">
+ <?= $html ?>
+ </tr>
+<? }
+ }
+?>
+<!-- END Artikel -->
+</table>
+Anzahl der Artikel: <?= $i ?><br>
+Export am : <?= date("d.m.Y : H:i") ?><br>
+download <a href="tmp/shopartikel.csv">Exportfile</a><br><hr>
+<?
+ fclose($f);
+} // if ($export)
+?>
+Export der Shopartikel aus Lx-ERP <br>
+Mögliche Felder
+<form name="fld" action="erpexport.php" method="post">
+<input type="hidden" name="shop" value="">
+<table>
+ <tr>
+ <td><input type="checkbox" name="partnumber" value="1">Artikelnummer</td>
+ <td><input type="checkbox" name="desctiption" value="1">Bezeichnung</td>
+ <td><input type="checkbox" name="unit" value="1">Einheit</td>
+ <td><input type="checkbox" name="weight" value="1">Gewicht</td>
+ </tr>
+ <tr>
+ <td><input type="text" name="PN" size="23"></td>
+ <td><input type="text" name="BEZ" size="23"></td>
+ <td><input type="text" name="EINHEIT" size="23"></td>
+ <td><input type="text" name="GEWICHT" size="23"></td>
+ </tr>
+ <tr><td colspan=5></td></tr>
+ <tr>
+ <td><input type="checkbox" name="sellprice" value="1">Verkaufspreis</td>
+ <td><input type="checkbox" name="listprice" value="1">Listenpreis</td>
+ <td><input type="checkbox" name="onhand" value="1">Lagerbestand</td>
+ <td><input type="checkbox" name="rate" value="1">MwSt</td>
+ </tr>
+ <tr>
+ <td><input type="text" name="VK" size="23"></td>
+ <td><input type="text" name="EK" size="23"></td>
+ <td><input type="text" name="LAGER" size="23"></td>
+ <td><input type="text" name="MWST" size="23"></td>
+ </tr>
+ <tr><td colspan=5></td></tr>
+ <tr>
+ <td><input type="checkbox" name="partsgroup" value="1">Gruppe</td>
+ <td><input type="checkbox" name="notes" value="1">Beschreibung</td>
+ <td><input type="checkbox" name="image" value="1">Bild</td>
+ <td><input type="checkbox" name="show" value="1" checked>HTML-Anzeige</td>
+ </tr>
+ <tr>
+ <td><input type="text" name="PG" size="23"></td>
+ <td><input type="text" name="BESCHR" size="23"></td>
+ <td><input type="text" name="IMAGE" size="23"></td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>Feldtrenner <input type="text" name="deli" size="2" value=","></td>
+ <td>Feldumrahmung <input type="text" name="encl" size="2" value="""></td>
+ <td>Zeilenende <input type="text" name="crln" size="2" value="\n"></td>
+ <td><input type="checkbox" name="head" value="1" checked>Headline</td>
+ </tr>
+ <tr>
+ <td colspan=5><input type="submit" name="export" value="Export"> <input type="button" name="xsc" value="xtCommerce" onClick="xtcomm()"></td>
+ </tr>
+</table>
+<a href="trans.php">zurück</a>
+</form>
+</body>
+</html>
--- /dev/null
+
+[olCom]
+
+[olCom--Warenexport]
+module=olcom/shopimport_db.php
+
+[olCom--Bestellungen]
+module=olcom/olcomexport.php
+
+[olCom--Konfiguration]
+module=olcom/confedit.php
+
--- /dev/null
+<?
+/***************************************************************
+*Author: Holger Lindemann
+*Copyright: (c) 2004 Lx-System
+*License: non free
+*eMail: info@lx-system.de
+*Version: 1.6
+*Shop: xt::Commerce
+*ERP: Lx-Office ERP 2.4.x
+***************************************************************/
+/*
+* Noch einzubauen:
+*/
+//echo <<<EOF
+echo "<html>";
+echo " <head><title>Lx-ERP Export der Shopartikel</title>";
+echo ' <link type="text/css" REL="stylesheet" HREF="css/main.css"></link>';
+echo "<body>";
+//EOF;
+
+require_once "shoplib.php";
+
+
+/**********************************************
+* getAttribut($oid,$pid)
+*
+**********************************************/
+function getAttribut($oid,$pid) {
+ $sql="select * from ".PREFIX."orders_products_attributes where orders_id=$oid and orders_products_id=$pid";
+ $rs=getAll("shop",$sql,"getAttribut");
+ $txt="";
+ foreach ($rs as $zeile) {
+ $txt.="\n - ".$zeile["products_options"].":".$zeile["products_options_values"];
+ };
+ return $txt;
+}
+
+/**********************************************
+* getBrutto($id)
+*
+**********************************************/
+function getBrutto($id) {
+ $sql="select * from ".PREFIX."orders_total where orders_id=$id and class='ot_total'";
+ $rs=getAll("shop",$sql,"getBrutto");
+ if ($rs) {
+ return $rs[0]["value"];
+ } else {
+ return 0;
+ }
+}
+
+/**********************************************
+* getMwst($id)
+*
+**********************************************/
+function getMwst($id) {
+ $sql="select * from ".PREFIX."orders_total where orders_id=$id and class='ot_tax'";
+ $rs=getAll("shop",$sql,"getMwst");
+ $mwst=0;
+ if ($rs) {
+ foreach ($rs as $zeile) {
+ $mwst+=$zeile["value"];
+ }
+ }
+ return $mwst;
+}
+
+/**********************************************
+* getSonderkosten($id,$art)
+*
+**********************************************/
+function getSonderkosten($id,$art) {
+ $sql="select * from ".PREFIX."orders_total where orders_id=$id and class='".$GLOBALS["skosten"][$art]."'";
+ $rs=getAll("shop",$sql,"getSonderkosten");
+ if ($rs[0]["value"]) {
+ $kosten=round($rs[0]["value"]/(100+$GLOBALS["versand"]["TAX"])*100,2);
+ } else {
+ $kosten=false;
+ }
+ return $kosten;
+}
+
+/**********************************************
+* insBestArtikel($zeile,$transID)
+*
+**********************************************/
+function insBestArtikel($ordersID,$transID) {
+global $div07,$div16;
+ $sql="select * from ".PREFIX."orders_products where orders_id=$ordersID";
+ $rs=getAll("shop",$sql,"insBestArtikel");
+ $ok=true;
+ if ($rs) foreach ($rs as $zeile) {
+ $sql="select * from parts where partnumber='".$zeile["products_model"]."'";
+ $rs2=getAll("erp",$sql,"insBestArtikel");
+ if ( $rs2[0]["id"]) {$artID=$rs2[0]["id"]; $artNr=$rs2[0]["partnumber"]; }
+ else {
+ if ($zeile["products_tax"]=="7.0000") {
+ $artID=$div07["ID"];
+ $artNr=$div07["NR"];
+ } else {
+ $artID=$div16["ID"];
+ $artNr=$div16["NR"];
+ };
+ }
+ $preis=round($zeile["products_price"]/(100+$zeile["products_tax"])*100,2);
+ $text=getAttribut($ordersID,$zeile["orders_products_id"]);
+ $sql="insert into orderitems (trans_id, parts_id, description, qty, sellprice, unit, ship, discount) values (";
+ $sql.=$transID.",".$artID.",'".$zeile["products_name"].$text."',".$zeile["products_quantity"].",".$preis.",'Stck',0,0)";
+ echo " - Artikel:[ BuNr.:$artID ArtNr:<b>$artNr</b> ".$zeile["products_name"]." ]<br>";
+ $rc=query("erp",$sql,"insBestArtikel");
+ if ($rc === -99) { $ok=false; break; };
+ }
+ return $ok;
+}
+
+function insAuftrag($data) {
+global $ERPusr,$versand,$nachn,$minder,$paypal,$auftrnr;
+ $Zahlmethode=array("authorizenet"=>"Authorize.net","banktransfer"=>"Lastschriftverfahren","cc"=>"Kreditkarte",
+ "cod"=>"Nachnahme","eustandardtransfer"=>"EU-Standard Bank Transfer","iclear"=>"iclear Rechnungskauf",
+ "invoice"=>"Rechnung","ipayment"=>"iPayment","liberecobanktransfer"=>"Lastschriftverfahren",
+ "liberecocc"=>"Kreditkarte","moneybookers"=>"Moneybookers.com","moneyorder"=>"Scheck/Vorkasse",
+ "nochex"=>"NOCHEX","paypal"=>"PayPal","pm2checkout"=>"2CheckOut","psigate"=>"PSiGate",
+ "qenta"=>"qenta.at","secpay"=>"SECPay");
+ $brutto=getBrutto($data["orders_id"]);
+ $mwst=getMwst($data["orders_id"]);
+ $netto=$brutto-$mwst;
+ $versandK=getSonderkosten($data["orders_id"],"Versand");
+ $nachnK =getSonderkosten($data["orders_id"],"NachName");
+ $mindermK=getSonderkosten($data["orders_id"],"Minder");
+ $paypalK =getSonderkosten($data["orders_id"],"Paypal");
+ // Hier beginnt die Transaktion
+ $rc=query("erp","BEGIN","chkKunde");
+ if ($rc === -99) { echo "Probleme mit Datenbank, Abbruch!"; exit(); };
+ if ($auftrnr) {
+ $auftrag=$GLOBALS["preA"].getNextAnr();
+ } else {
+ $auftrag=$GLOBALS["preA"].$data["orders_id"];
+ }
+ $sql="select count(*) as cnt from oe where ordnumber = '$auftrag'";
+ $rs=getAll("erp",$sql,"insAuftrag");
+ if ($rs[0]["cnt"]>0) {
+ $auftrag=$GLOBALS["preA"].getNextAnr();
+ }
+ $newID=uniqid (rand());
+ $sql="insert into oe (notes,ordnumber,cusordnumber) values ('$newID','$auftrag','".$data["kdnr"]."')";
+ $rc=query("erp",$sql,"insAuftrag");
+ $sql="select * from oe where notes = '$newID'";
+ $rs2=getAll("erp",$sql,"insAuftrag");
+ if ($data["cc_type"]) {
+ $BEZAHLEN.=$data["cc_type"]."\n".$data["cc_owner"]."\n".$data["cc_number"]."\n".$data["cc_expires"]."\n";
+ } else {
+ $BEZAHLEN=$Zahlmethode[$data["payment_method"]]."\nKontoinhaber: ";
+ $BEZAHLEN.=$data["banktransfer_owner"]."\nBanknummer: ".$data["banktransfer_blz"];
+ $BEZAHLEN.="\nKontonummer: ".$data["banktransfer_number"]."\nBank: ".$data["banktransfer_bankname"]."\n";
+ }
+ $sql="update oe set cusordnumber=".$data["orders_id"].", transdate='".$data["date_purchased"]."', customer_id=".$data["kdnr"].", ";
+ $sql.="amount=".$brutto.", netamount=".$netto.", reqdate='".$data["date_purchased"]."', taxincluded='f', ";
+ if ($data["shipto"]>0) $sql.="shipto_id=".$data["shipto"].", ";
+ $sql.="intnotes='".$data["comments"]."',notes='".$BEZAHLEN."', curr='EUR',employee_id=".$ERPusr["ID"].", vendor_id=0 ";
+ $sql.="where id=".$rs2[0]["id"];
+ $rc=query("erp",$sql,"insAuftrag");
+ if ($rc === -99) {
+ echo "Auftrag ".$data["orders_id"]." konnte nicht angelegt werden.<br>";
+ $rc=query("erp","ROLLBACK","chkKunde");
+ return false;
+ }
+ echo "Auftrag:[ Buchungsnummer:".$rs2[0]["id"]." AuftrNr:<b>".$auftrag."</b> ]<br>";
+ if (!insBestArtikel($data["orders_id"],$rs2[0]["id"])) {
+ echo "Auftrag ".$data["orders_id"]." konnte nicht angelegt werden.<br>";
+ $rc=query("erp","ROLLBACK","chkKunde");
+ return false;
+ };
+ if ($versandK) {
+ $sql="insert into orderitems (trans_id, parts_id, description, qty, sellprice, unit, ship, discount) values (";
+ $sql.=$rs2[0]["id"].",".$versand["ID"].",'".$versand["TXT"]."',1,".$versandK.",'mal',0,0)";
+ $rc=query("erp",$sql,"insAuftrag");
+ if ($rc === -99) echo "Auftrag $auftrag : Fehler bei den Versandkosten<br>";
+ }
+ if ($nachnK) {
+ $sql="insert into orderitems (trans_id, parts_id, description, qty, sellprice, unit, ship, discount) values (";
+ $sql.=$rs2[0]["id"].",".$nachn["ID"].",'".$nachn["TXT"]."',1,".$nachnK.",'mal',0,0)";
+ $rc=query("erp",$sql,"insAuftrag");
+ if ($rc === -99) echo "Auftrag $auftrag : Fehler bei den Nachnamekosten<br>";
+ }
+ if ($mindermK) {
+ $sql="insert into orderitems (trans_id, parts_id, description, qty, sellprice, unit, ship, discount) values (";
+ $sql.=$rs2[0]["id"].",".$minder["ID"].",'".$minder["TXT"]."',1,".$mindermK.",'mal',0,0)";
+ $rc=query("erp",$sql,"insAuftrag");
+ if ($rc === -99) echo "Auftrag $auftrag : Fehler beim Mindermengenzuschlag<br>";
+ }
+ if ($paypalK) {
+ $sql="insert into orderitems (trans_id, parts_id, description, qty, sellprice, unit, ship, discount) values (";
+ $sql.=$rs2[0]["id"].",".$paypal["ID"].",'".$paypal["TXT"]."',1,".$paypalK.",'mal',0,0)";
+ $rc=query("erp",$sql,"insAuftrag");
+ if ($rc === -99) echo "Auftrag $auftrag : Fehler bei den PayPal-Kosten<br>";
+ }
+ $rc=query("erp","COMMIT","Auftrag");
+ if ($rc === -99) {
+ echo "Probleme mit Datenbank, Abbruch!";
+ exit();
+ }
+ $sql="update ".PREFIX."orders set orders_status ='3' WHERE orders_id =".$data["orders_id"];
+ $rc=query("shop",$sql,"insBestArtikel");
+ return true;
+}
+
+/**********************************************
+* getBestellung()
+*
+**********************************************/
+function getBestellung() {
+ $sql="select b.*,h.comments,o.*,cn.kdnr from ".PREFIX."orders o left join ".PREFIX."orders_status_history h on h.orders_id=o.orders_id ";
+ $sql.="left join ".PREFIX."banktransfer b on b.orders_id =o.orders_id left join ".PREFIX."customers_number cn on ";
+ $sql.="cn.customers_id=o.customers_id where o.orders_status=1 order by o.orders_id";
+ $rs=getAll("shop",$sql,"getBestellung");
+ return $rs;
+}
+
+/**********************************************
+* chkKdData()
+*
+**********************************************/
+function chkKunden() {
+ $felder=array("firstname","lastname","company","street_address","city","postcode","country");
+ foreach ($GLOBALS["bestellungen"] as $bestellung) {
+ $rc=query("erp","BEGIN","chkKunde");
+ if ($rc === -99) { echo "Probleme mit Datenbank, Abbruch!"; exit(); };
+ if ($bestellung["kdnr"]>0) {
+ $msg="update ";
+ $kdnr=chkOldKd($bestellung);
+ if ($kdnr == -1) { //Kunde nicht gefunden, neu anlegen.
+ $msg="insert ";
+ $kdnr=insNewKd($bestellung);
+ $GLOBALS["neuKd"]++;
+ }
+ } else {
+ $msg="insert ";
+ $kdnr=insNewKd($bestellung);
+ $GLOBALS["neuKd"]++;
+ }
+ echo $bestellung["customers_company"]." ".$bestellung["customers_name"]." $kdnr<br>";
+ $GLOBALS["bestellungen"][$GLOBALS["gesKd"]]["kdnr"]=$kdnr;
+ $sql="delete from ".PREFIX."customers_number where customers_id=".$bestellung["customers_id"];
+ $rc=query("shop",$sql,"chkKunde");
+ $sql="insert into ".PREFIX."customers_number (customers_id,kdnr) values(".$bestellung["customers_id"].",".$kdnr.")";
+ $rc=query("shop",$sql,"chkKunde");
+ if ($kdnr>0) {
+ foreach($felder as $feld) {
+ if ($bestellung["delivery_$feld"]<>$bestellung["customers_$feld"]) {
+ $rc=insShData($bestellung,$kdnr);
+ if ($rc>0) $GLOBALS["bestellungen"][$GLOBALS["gesKd"]]["shipto"]=$rc;
+ break;
+ }
+ }
+ }
+ if (!$kdnr || $rc === -99) {
+ $rc=query("erp","ROLLBACK","chkKunde");
+ echo $msg." ".$bestellung["customers_name"]." fehlgeschlagen!<br>";
+ return false;
+ } else {
+ $rc=query("erp","COMMIT","chkKunde");
+ }
+ $GLOBALS["gesKd"]++;
+ }
+ return true;
+}
+
+function chkOldKd($data) {
+ $sql="select * from customer where id = ".$data["kdnr"];
+ $rs=getAll("erp",$sql,"chkKdData");
+ if ($rs[0]["id"]<>$data["kdnr"]) { return -1; }; // Kunde nicht gefunden
+ if ($rs[0]["zipcode"]<>$data["customers_postcode"]) $set.="zipcode='".$data["customers_postcode"]."',";
+ if ($rs[0]["city"]<>$data["customers_city"]) $set.="city='".$data["customers_city"]."',";
+ if ($rs[0]["country"]<>$GLOBALS["LAND"][$data["customers_country"]]) $set.="land='".$GLOBALS["LAND"][$data["customers_country"]]."',";
+ if ($rs[0]["phone"]<>$data["customers_phone"])$set.="phone='".$data["customers_phone"]."',";
+ if ($rs[0]["email"]<>$data["customers_email_address"])$set.="email='".$data["customers_mail_address"]."',";
+ if ($data["customers_company"]) {
+ if ($rs[0]["name"]<>$data["customers_company"]) $set.="set name='".$data["customers_company"]."',";
+ if ($rs[0]["department_1"]<>$data["customers_name"]) $set.="department_1='".$data["customers_name"]."',";
+ } else {
+ if ($rs[0]["name"]<>$data["customers_name"]) $set.="name='".$data["customers_name"]."',";
+ }
+ if ($rs[0]["street"]<>$data["customers_street_address"]) $set.="street='".$data["customers_street_address"]."',";
+ if ($set) {
+ $sql="update customer set ".substr($set,0,-1)." where id=".$rs[0]["id"];
+ $rc=query("erp",$sql,"chkKdData");
+ if ($rc === -99) {
+ return false;
+ } else {
+ return $data["kdnr"];
+ }
+ } else {
+ return $data["kdnr"];
+ }
+}
+
+/**********************************************
+* insShData($data,$id)
+*
+**********************************************/
+function insShData($data,$id) {
+ $set=$id;
+ if ($data["delivery_company"]) { $set.=",'".$data["delivery_company"]."','".$data["delivery_name"]."',"; }
+ else { $set.=",'".$data["delivery_name"]."','',"; }
+ $set.="'".$data["delivery_street_address"]."',";
+ $set.="'".$data["delivery_postcode"]."',";
+ $set.="'".$data["delivery_city"]."',";
+ $set.="'".$data["delivery_country"]."',";
+ $set.="'".$data["customers_telephone"]."',";
+ $set.="'".$data["customers_email_address"]."'";
+ $sql="insert into shipto (trans_id,shiptoname,shiptodepartment_1,shiptostreet,shiptozipcode,shiptocity,";
+ $sql.="shiptocountry,shiptophone,shiptoemail,module) values ($set,'CT')";
+ $rc=query("erp",$sql,"insShData");
+ if ($rc === -99) return false;
+ $sql="select shipto_id from shipto where trans_id = $id and module='CT' order by itime desc limit 1";
+ $rs=getAll("erp",$sql,"insKdData");
+ if ($rs[0]["shipto_id"]>0) {
+ $sid=$rs[0]["shipto_id"];
+ $sql="update ".PREFIX."customers_number set shipto = $sid where kdnr = $id";
+ $rc2=query("shop",$sql,"insShData");
+ if ($rc2 === -99) {
+ return false;
+ }
+ } else {
+ echo "Fehler bei abweichender Anschrift ".$data["delivery_name"];
+ }
+ if ($rc === -99) {
+ return false;
+ } else {
+ return $sid;
+ }
+}
+
+/**********************************************
+* insKdData($BID)
+*
+**********************************************/
+function insNewKd($data) {
+ $taxid=array("DE"=>0,"CH"=>2,"AU"=>1,"FR"=>1,"IT"=>1,"ES"=>1,"NL"=>1); // Muß erweitert werden
+ $newID=uniqid(rand(time(),1));
+ //Kundennummer generieren
+ if ($GLOBALS["kdnum"]==1) { // von der ERP
+ $kdnr=$GLOBALS["preK"].getNextKnr();
+ } else { // durch Shop
+ $kdnr=$GLOBALS["preK"].$data["customers_id"];
+ }
+ $sql="select count(*) as cnt from customer where customernumber = '$kdnr'";
+ $rs=getAll("erp",$sql,"insKdData");
+ if ($rs[0]["cnt"]>0) { // Kundennummer gibt es schon, eine neue aus ERP
+ $kdnr=$GLOBALS["preK"].getNextKnr();
+ }
+ $sql="insert into customer (name,customernumber) values ('$newID','$kdnr')";
+ $rc=query("erp",$sql,"insKdData");
+ if ($rc === -99) return false;
+ $sql="select * from customer where name = '$newID'";
+ $rs=getAll("erp",$sql,"insKdData");
+ if (!$rs) return false;
+ if ($data["customers_company"]) {
+ $set.="set name='".$data["customers_company"]."',contact='".$data["customers_name"]."',";
+ }else {
+ $set.="set name='".$data["customers_lastname"].", ".$data["customers_firstname"]."',";
+ }
+ $set.="street='".$data["customers_street_address"]."',";
+ $set.="zipcode='".$data["customers_postcode"]."',";
+ $set.="city='".$data["customers_city"]."',";
+ $set.="country='".$data["billing_country_iso_code_2"]."',";
+ $set.="phone='".$data["customers_telephone"]."',";
+ $set.="email='".$data["customers_email_address"]."',";
+ $tid=(in_array($data["billing_country_iso_code_2"],$taxid))?$taxid[$data["billing_country_iso_code_2"]]:3;
+ $set.="taxzone_id=$tid,";
+ $set.="taxincluded='f' ";
+ $sql="update customer ".$set;
+ $sql.="where id=".$rs[0]["id"];
+ $rc=query("erp",$sql,"insKdData");
+ if ($rc === -99) { return false; }
+ else { return $rs[0]["id"]; }
+}
+
+$LAND=array("Germany"=>"D","Austria"=>"A","Switzerland"=>"CH");
+$skosten=array("Versand"=>"ot_shipping","NachName"=>"ot_cod_fee","Paypal"=>"ot_cod_fee","Minder"=>"ot_loworderfee");
+$bestellungen=getBestellung();
+$ok=count($bestellungen);
+$gesKd=0;
+$neuKd=0;
+if ($ok) {
+ echo "Es liegen $ok Bestellungen vor. <br>";
+ chkKunden();
+ echo $gesKd." Kunde(n), davon ".$neuKd." neue(r) Kunde(n).<br>";
+ foreach ($bestellungen as $bestellung) {
+ $ok=insAuftrag($bestellung);
+ }
+} else { echo "Es liegen keine Bestellungen vor!<br>"; };
+?>
+<!--a href='trans.php'>zurück</a-->
+</body>
+</html>
--- /dev/null
+Shop - Schnittstelle Lx-ERP <-> osCommerce/xt:Commerce
+
+Vorraussetzungen:
+ Lx-ERP Version >= 2.4.0
+ xt:Commerce 2.0 RC1.2
+ Pear DB, PHP-ImageMagick
+
+Installation:
+Das tar-File unterhalb vom Webserververzeichnis oder dem ERP-Verzeichnis entpacken.
+
+ $ cd /var/www/html
+ $ tar xzf /pfad/zu/xtcomm.tgz
+
+In das Verzeichnis oscomm wechseln und Schreibrechte auf die Datei conf.php und
+das Verzeichnis tmp für den Webbenutzer (apache,www-data,httpd) vergeben.
+
+ $ chown apache conf.php
+ $ chmod 600 conf.php
+ $ chown apache tmp
+
+Im Browser folgende URL aufrufen:
+
+ http://webserver/pfad/xtcomm/confedit.php
+
+ z.B.: http://localhost/xtcomm/confedit.php
+
+Benutzer und Kennwort für die Erstinstallation sind:
+
+ xtcom / xtcom
+
+Die Maske sogfälltig ausfüllen.
+
+ db-Host db-Server für die jeweilige Anwendung
+ Database Namen der Datenbankinstanzen
+ db-User Username und Kennwort für die jeweilige Instanz
+ User-ID Mit dieser ID soll in die ERP geschrieben werden
+ CSV-Dir hier wird die csv-Datei erwartet (Schreibrechte!)
+ Image-Dir hier liegen die Bilder
+ ftp-Host Webserver der jeweiligen Anwendung
+ ftp-User Name und Kennwort für ftp-Zugang
+ ID-xxxx Interne ID der Waren. Lx-ERP:
+ Shopsprache Die Id der Voreingestellten Sprache. Nur für diese
+ werden die Artikel eingestellt.
+ Bildergröße in Byte
+
+Das Formular abschicken.
+
+Sollen später Änderungen durchgeführt werden, so muß bei der Anmeldung
+der ERP-ftp-User als Benutzer verwendet werden.
+
+In der Shopinstanz muß noch eine Tabelle angelegt werden. Das wird
+normalerweise durch das Programm condedit.php erledigt. Sollte das aus
+irgend einem Grund nicht funktionieren, führen Sie dazu die
+Datei oscom.sql als Datenbankbenutzer auf die Shopinstanz aus.
+
+ $ mysql -p -u dbuser dbinstanz < xtcom.sql
+ Enter password:
+
+Ist diese Tabelle nicht angelegt, werden Kunden in der ERP immer wieder neu
+angelegt.
+
+Fehlerquellen:
+Befinden sich ERP und Shop nicht auf dem gleichen Server, achten Sie darauf, das
+die entsprechende Datenbank von Aussen erreichbar ist. Dazu müssen folgende Ports
+freigeschaltet werden:
+
+ MySQL 3306
+ PostgreSQL 5432
+
+Auch muß auf dem Shopserver ein ftp-Dienst eingerichtet werden, wenn Bilder über-
+tragen werden sollen. Die Firewal ist entsprechend anzupassen.
+
+Arbeiten:
+In der ERP kann nun bei den Artikeln das Häckchen Shop gesetzt werden.
+Bitte auch eine Warengruppe vergeben, da sonst alle Artikel in Default landen.
+Da die ERP nur eine Kategorieebene verwalten kann, muß der ganze Kategorienpfad
+hintelegt werden. Die einzelnen Kategorien werden durch Ausrufezeichen (!) getrennt.
+
+ Hardware -> Monitore -> LCD = Hardware!Monitore!LCD
+
+Die URL für die Shopschnittstelle lautet:
+
+ http://webservername/pfad/xtcom/trans.php
+
+
+Die Schnittstelle kann auch in die ERP integriert werden. Dazu installieren Sie
+die Schnittstelle wie beschrieben unterhalb der ERP.
+Erweitern Sie die menu.ini um die Einträge im xtcom-Verzeichnis. z.B.:
+
+ $ cat /pfad/zu/xtcom/menu.ini >> /pfad/zu/lx-erp/menu.ini
+
+Unter dem Menüpunkt Shop stehen Ihnen nun die Module shopimport_db und xtcomexport
+zur Verfügung.
+
+Copyright:
+Die Schnittstelle mit ihren einzelnen Bestandteilen steht unter der "Artistic License".
+Das Copyright gehört Holger Lindemann.
--- /dev/null
+<?php
+/***************************************************************
+* $Id: shopimport_csv.php,v 1.2 2004/06/30 08:31:35 hli Exp $
+*Author: Holger Lindemann
+*Copyright: (c) 2004 Lx-System
+*License: non free
+*eMail: info@lx-system.de
+*Version: 1.0.0
+*Shop: olCommerce 1.2.2
+***************************************************************/
+
+require_once "DB.php";
+require_once "conf.php";
+if ($dbprefix<>"") { define("PREFIX",$dbprefix."_"); } else { define("PREFIX",""); }
+
+$LAND=array("Germany"=>"D");
+$db=DB::connect($SHOPdns);
+if (!$db) dbFehler("",$db->getDebugInfo());
+if (DB::isError($db)) {
+ dbFehler("",$db->getDebugInfo());
+ die ($db->getDebugInfo());
+};
+
+function createCategory($name,$maingroup) {
+global $db,$langs;
+ $newID=uniqid(rand());
+ $sql="insert into ".PREFIX."categories (categories_image,parent_id,date_added) values ('$newID',$maingroup,now())";
+ $rc=$db->query($sql);
+ $sql="select * from ".PREFIX."categories where categories_image = '$newID'";
+ $rs=$db->getAll($sql,DB_FETCHMODE_ASSOC);
+ $id=$rs[0]["categories_id"];
+ $sql="update ".PREFIX."categories set categories_image = null where categories_id=$id";
+ $rc=$db->query($sql);
+ echo "($name) ";
+ foreach ($langs as $LANG) {
+ $sql="insert into ".PREFIX."categories_description (categories_id,language_id,categories_name) values ($id,$LANG,'$name')";
+ $rc=$db->query($sql);
+ if (!$rc) break;
+ }
+ return ($rc)?$id:false;
+}
+function getCategory($name) {
+global $db;
+ if (empty($name)) $name="Default";
+ $tmp=split("!",$name);
+ $maingroup=0;
+ $found=true;
+ $i=0;
+ do {
+ $sql="select D.*,C.parent_id from ".PREFIX."categories C left join ".PREFIX."categories_description D on C.categories_id=D.categories_id where categories_name like '".$tmp[$i]."' and C.parent_id=$maingroup";
+ $rs=$db->getAll($sql,DB_FETCHMODE_ASSOC);
+ if ($rs[0]["categories_id"]) {
+ $maingroup=$rs[0]["categories_id"];
+ echo $maingroup.":".$rs[0]["categories_name"]." ";
+ $i++;
+ } else {
+ $found=false;
+ }
+ } while ($rs and $found and $i<count($tmp));
+ for (;$i<count($tmp); $i++) {
+ $maingroup=createCategory($tmp[$i],$maingroup);
+ }
+ return $maingroup;
+}
+function insartikel($data) {
+global $db,$header,$tax,$defLang;
+ $newID=uniqid(rand());
+ $sql="insert into ".PREFIX."products (products_model,products_image) values ('".$data[array_search("products_model")]."','$newID')";
+ $rc=$db->query($sql);
+ $sql="select * from ".PREFIX."products where products_image='$newID'";
+ $rs=$db->getAll($sql,DB_FETCHMODE_ASSOC);
+ $sql="update ".PREFIX."products set products_image=null,products_status=1 where products_id=".$rs[0]["products_id"];
+ $rc=$db->query($sql);
+ $sql="insert into ".PREFIX."products_description (products_id,language_id,products_name) values (".$rs[0]["products_id"].",$defLang,' ')";
+ $rc=$db->query($sql);
+ $sql="insert into ".PREFIX."products_to_categories (products_id,categories_id) values (".$rs[0]["products_id"].",".$data["categories_id"].")";
+ $rc=$db->query($sql);
+ echo " <b>insert</b> ";
+ updartikel($data,$rs[0]["products_id"]);
+}
+function updartikel($data,$id) {
+global $db,$header,$tax,$defLang;
+ $sql="update ".PREFIX."products set products_price=%01.2f,products_weight=%01.2f,products_tax_class_id=%d,products_last_modified=now() where products_id=%d";
+ $sql=sprintf($sql,$data[array_search("products_price",$header)],$data[array_search("products_weight",$header)],$tax[$data[array_search("products_tax",$header)]],$id);
+ $rc=$db->query($sql);
+ $sql="update ".PREFIX."products_description set products_name='%s',products_description='%s' where products_id=%d and language_id=$defLang";
+ $sql=sprintf($sql,$data[array_search("products_name",$header)],$data[array_search("products_description",$header)],$id);
+ $rc=$db->query($sql);
+ $sql="update ".PREFIX."products_to_categories set categories_id=".$data[array_search("categories_id",$header)]." where products_id=$id";
+ $rc=$db->query($sql);
+ echo "(".$id." ".$data[array_search("products_name",$header)].")+++<br>";
+}
+function chkartikel($data) {
+global $db,$header,$tax;
+ $sql="select * from ".PREFIX."products P left join ".PREFIX."products_description D on P.products_id=D.products_id left join ".PREFIX."products_to_categories C on P.products_id=C.products_id where products_model like '".$data[array_search("products_model",$header)]."' and language_id=2";
+ $rs=$db->getAll($sql,DB_FETCHMODE_ASSOC);
+ if ($rs) {
+ if ($rs[0]["products_price"]<>$data[array_search("products_price",$header)]) { updartikel($data,$rs[0]["products_id"]); }
+ else if ($rs[0]["products_weight"]<>$data[array_search("products_weight",$header)]) { updartikel($data,$rs[0]["products_id"]); }
+ else if ($rs[0]["products_name"]<>$data[array_search("products_name",$header)]) { updartikel($data,$rs[0]["products_id"]); }
+ else if ($rs[0]["products_description"]<>$data[array_search("products_description",$header)]) { updartikel($data,$rs[0]["products_id"]); }
+ else if ($rs[0]["products_tax_class_id"]<>$tax[$data[array_search("products_tax",$header)]]) { updartikel($data,$rs[0]["products_id"]); }
+ else if ($rs[0]["categories_id"]<>$data[array_search("categories_id",$header)]) { updartikel($data,$rs[0]["products_id"]); }
+ else { echo "(".$rs[0]["products_id"]." ".$rs[0]["products_name"].")...<br>"; };
+ } else {
+ insartikel($data);
+ }
+}
+
+$sql="select languages_id from languages";
+$rs=$db->getAll($sql,DB_FETCHMODE_ASSOC);
+if ($rs) {
+ foreach ($rs as $zeile) {
+ $langs[]=$zeile["languages_id"];
+ }
+} else {
+ $langs[]=1;
+}
+$sql="select * from ".PREFIX."languages L left join ".PREFIX."configuration C on L.code=C.configuration_value where configuration_key = 'DEFAULT_LANGUAGE'";
+$rs=$db->getAll($sql,DB_FETCHMODE_ASSOC);
+if ($rs) {
+ $defLang=$rs[0]["languages_id"];
+} else {
+ $defLang=$SHOPlang;
+}
+$sql="select * from ".PREFIX."tax_rates";
+$rs=$db->getAll($sql,DB_FETCHMODE_ASSOC);
+if ($rs) {
+ foreach ($rs as $zeile) {
+ $tax[$zeile["tax_rate"]]=$zeile["tax_class_id"];
+ }
+} else {
+ $tax[0]="";
+}
+
+if ($_FILES["csv"]["name"] || ($_POST["nofile"] && file_exists($SHOPdir)) ) {
+ if ($_FILES["csv"]["tmp_name"]) {
+ move_uploaded_file($_FILES["csv"]["tmp_name"],$SHOPdir);
+ }
+ $f=fopen($SHOPdir,"r");
+ $header=fgetcsv($f,1000,";");
+ $header[]="categories_id";
+ $data=fgetcsv($f,1000,";");
+ while (!feof($f)) {
+ $catId=getCategory($data[array_search("categories_name",$header)]);
+ $data[]=$catId;
+ chkartikel($data);
+ $data=fgetcsv($f,1000,";");
+ }
+ fclose($f);
+ echo "<a href='trans.php'>zurück</a>";
+} else {
+?>
+<html>
+ <head>
+ <title>Datenaustausch ERP-xt:Commerce</title>
+ </head>
+<body>
+<center>
+<br>
+<h1>Artikelimport aus csv-Datei in xt:Commerce</h1><br>
+<form name="csv" action="shopimport_csv.php" enctype="multipart/form-data" method="post">
+ <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="500000">
+ <input type="checkbox" name="nofile" value="1">Auf dem Server vorhandene Daten importieren<br>
+ Datenfile für Import <input type="file" name="csv"><br>
+ <input type="submit" name="ok" value="ok">
+</form>
+</center>
+<a href="trans.php">zurück</a>
+</body>
+</html>
+<?
+}
+?>
--- /dev/null
+<?php
+/***************************************************************
+* $Id: shopimport_db.php,v 2.0 2006/10/26 10:49:11 hli Exp $
+*Author: Holger Lindemann
+*Copyright: (c) 2004 Lx-System
+*License: non free
+*eMail: info@lx-system.de
+*Version: 2.0
+*Shop: xt:Commerce 3.04
+*ERP: Lx-Office ERP 2.4.0
+***************************************************************/
+require_once "shoplib.php";
+
+
+/*******************************************
+* createCategoryLang($id,$lang,$name)
+* Kategorie für eine Sprache anlegen. Ist immer
+* in der gleichen Sprache, da ERP nur eine hat.
+*******************************************/
+function createCategoryLang($id,$lang,$name) {
+ $sql="insert into ".PREFIX."categories_description (categories_id,language_id,categories_name,categories_meta_title) ";
+ $sql.="values ($id,$lang,'$name','$name')";
+ $rc=query("shop",$sql,"createCategoryLang");
+ return $rc;
+}
+
+/*******************************************
+* createCategory($name,$maingroup,$Lang,$Lanuages)
+* Eine Kategorie in der default-Sprache anlegen
+*******************************************/
+function createCategory($name,$maingroup,$Lang,$Languages) {
+ echo "Kategorie: $name<br>";
+ //Kategorie nicht vorhanden, anlegen
+ $newID=uniqid(rand());
+ $sql="insert into ".PREFIX."categories (categories_image,parent_id,date_added) values ('$newID',$maingroup,now())";
+ $rc=query("shop",$sql,"createCategory_1");
+ if ($rc === -99) return false;
+ $sql="select * from ".PREFIX."categories where categories_image = '$newID'";
+ $rs=getAll("shop",$sql,"createCategory_2");
+ $id=$rs[0]["categories_id"];
+ $sql="update ".PREFIX."categories set categories_image = null where categories_id=$id";
+ $rc=query("shop",$sql,"createCategory_3");
+ if ($rc === -99) return false;
+ createCategoryLang($id,$Lang,$name);
+ if ($Languages) foreach ($Languages as $erp=>$shop) {
+ if ($Lang<>$shop) {
+ createCategoryLang($id,$shop,$name);
+ }
+ }
+ return ($rc !== -99)?$id:false;
+}
+
+/*******************************************
+* getCategory($name,$Lang,$Languages)
+* gibt es die Kategorie schon?
+*******************************************/
+function getCategory($name,$Lang,$Languages) {
+ if (empty($name)) $name="Default";
+ $tmp=split("!",$name);
+ $maingroup=0;
+ $found=true;
+ $i=0;
+ do {
+ $sql="select D.*,C.parent_id from ".PREFIX."categories C left join ".PREFIX."categories_description D on C.categories_id=D.categories_id ";
+ $sql.="where (categories_name = '".$tmp[$i]."' or categories_meta_title ='".$tmp[$i]."') and ";
+ $sql.="C.parent_id=$maingroup and language_id=$Lang";
+ $rs=getAll("shop",$sql,"getCategory");
+ if ($rs) {
+ $maingroup=$rs[0]["categories_id"];
+ $i++;
+ } else {
+ $found=false;
+ }
+ } while ($rs and $found and $i<count($tmp));
+ for (;$i<count($tmp); $i++) {
+ $maingroup=createCategory($tmp[$i],$maingroup,$Lang,$Languages);
+ }
+ return $maingroup;
+}
+
+
+/*******************************************
+* bilder($width,$height,$dest
+* Bild in der gewünschten Größe erzeugen
+*******************************************/
+function bilder($width,$height,$dest) {
+ if (!function_exists("imagick_readimage")) { echo "Imagick-Extention nicht installiert"; return false; };
+ $handle=imagick_readimage("./tmp/tmp.file_org");
+ if (!$handle) {
+ $reason = imagick_failedreason( $handle ) ;
+ print "Lesen: $reason<BR>\n" ; flush();
+ return false;
+ }
+ if (!imagick_resize( $handle, $width, $height, IMAGICK_FILTER_UNKNOWN, 0)) {
+ $reason = imagick_failedreason( $handle ) ;
+ print "Resize: $reason<BR>\n" ; flush();
+ return false;
+ }
+ if (!imagick_writeimage( $handle,"./tmp/tmp.file_$dest")) {
+ $reason = imagick_failedreason( $handle ) ;
+ print "Schreiben: $reason<BR>\n" ; flush();
+ return false;
+ }
+ return true;
+}
+
+/*******************************************
+* uploadImage($image,$id)
+* Ein Bild zum Shop übertragen
+*******************************************/
+function uploadImage($image,$id) {
+global $ERPftphost,$ERPftpuser,$ERPftppwd,$ERPimgdir,$SHOPftphost,$SHOPftpuser,$SHOPftppwd,
+ $SHOPimgdir,$picsize;
+ $picdest = array("thumb"=>"thumbnail_images","info"=>"info_images","popup"=>"popup_images","org"=>"original_images");
+ $ok=true;
+ // Bilder holen
+ if ($ERPftphost=="localhost")
+ {
+ $aus=""; $rc2=0;
+ if (is_file($ERPimgdir."/".$image)) {
+ $rc3=@exec("cp $ERPimgdir/$image ./tmp/tmp.file_org",$aus,$rc2);
+ if ($rc2>0) { $ok=false; echo "[Downloadfehler: $image]<br>"; };
+ } else {
+ echo "[Downloadfehler: $ERPimgdir/$image nicht gefunden]";
+ return false;
+ }
+ } else {
+ $conn_id = ftp_connect($ERPftphost);
+ if ($conn_id==false) {
+ echo "[Kein FTP-Verbindung ERP]";
+ return false;
+ }
+ ftp_login($conn_id,$ERPftpuser,$ERPftppwd);
+ $src=$ERPimgdir."/".$image;
+ $upload=ftp_get($conn_id,"tmp/tmp.file_org","$src",FTP_BINARY);
+ if (!$upload) { $ok=false; echo "[Ftp Downloadfehler: $image]<br>";};
+ ftp_quit($conn_id);
+ }
+ if ($ok) {
+ //Bildergrößen erzeugen
+ if (!bilder($picsize["PRODUCT_IMAGE_THUMBNAIL_WIDTH"],$picsize["PRODUCT_IMAGE_THUMBNAIL_HEIGHT"],"thumb")) return false;
+ if (!bilder($picsize["PRODUCT_IMAGE_INFO_WIDTH"],$picsize["PRODUCT_IMAGE_INFO_HEIGHT"],"info")) return false;
+ if (!bilder($picsize["PRODUCT_IMAGE_POPUP_WIDTH"],$picsize["PRODUCT_IMAGE_POPUP_HEIGHT"],"popup")) return false;
+ $name=(strrpos($image,"/")>0)?substr($image,strrpos($image,"/")+1):$image;
+ //zum Shop übertragen
+ if ($SHOPftphost=="localhost") {
+ foreach ($picdest as $key => $val) {
+ if (is_dir($SHOPimgdir."/".$val."/")) {
+ $src=$SHOPimgdir."/".$val."/".$name;
+ $rc2=0; $aus="";
+ $rc3=@exec("cp ./tmp/tmp.file_$key $src",$aus,$rc2);
+ if ($rc2>0) { $ok=false; echo "[Uploadfehler: $src]"; };
+ } else {
+ echo "[Uploadfehler: $val nicht gefunden]";
+ return false;
+ }
+ }
+ } else {
+ $conn_id = ftp_connect($SHOPftphost);
+ if ($conn_id==false) {
+ echo "[Kein FTP-Verbindung Shop]";
+ return false;
+ }
+ ftp_login($conn_id,$SHOPftpuser,$SHOPftppwd);
+ foreach ($picdest as $key => $val) {
+ $src=$SHOPimgdir."/".$val."/".$name;
+ $upload=ftp_put($conn_id,"$src","tmp/tmp.file_".$key,FTP_BINARY);
+ if (!$upload) { $ok=false; echo $key."[FTP Uploadfehler $src]<br>";};
+ }
+ ftp_quit($conn_id);
+ }
+ if ($ok) {
+ $sql="update ".PREFIX."products set products_image='%s',products_last_modified=now() where products_id=%d";
+ $sql=sprintf($sql,$name,$id);
+ $rc=query("shop",$sql,"uploadImage");
+ if ($rc === -99) return false;
+ echo "i";
+ }
+ }
+ return true;
+}
+
+/*******************************************
+* insartikel($data,$defLang
+* Einen neuen Artikel im Shop anlegen
+*******************************************/
+function insartikel($data,$defLang) {
+ $newID=uniqid(rand());
+ $sql="insert into ".PREFIX."products (products_model,products_image) values ('".$data["partnumber"]."','$newID')";
+ $rc=query("shop",$sql,"insartikel_1");
+ if ($rc === -99) return false;
+ $sql="select * from ".PREFIX."products where products_image='$newID'";
+ $rs=getAll("shop",$sql,"insartikel_2");
+ $sql="update products set products_image=null where products_id=".$rs[0]["products_id"];
+ $rc=query("shop",$sql,"insartikel_3");
+ if ($rc === -99) return false;
+ $sql="insert into ".PREFIX."products_to_categories (products_id,categories_id) values ";
+ $sql.="(".$rs[0]["products_id"].",".$data["categories_id"].")";
+ $rc=query("shop",$sql,"insartikel_4");
+ if ($rc === -99) return false;
+ echo " + ";
+ updartikel($data,$rs[0]["products_id"],$defLang);
+ return $rs[0]["products_id"];
+}
+
+/*******************************************
+*
+*
+*******************************************/
+function updartikel($data,$id,$defLang) {
+global $tax,$KDGrp;
+ echo $id." ";
+ $sql="update ".PREFIX."products set products_status=1,products_price=%01.2f,products_weight=%01.2f,";
+ $sql.="products_tax_class_id=%d,products_last_modified=now(),products_quantity=%d where products_id=%d";
+ $price=($data["sellprice"]>0)?$data["sellprice"]:$data["stdprice"];
+ $sql=sprintf($sql,$price,$data["weight"],$tax[sprintf("%1.4f",$data["rate"])],$data["onhand"],$id);
+ $rc=query("shop",$sql,"updartikel_1");
+ $sql="update ".PREFIX."products_to_categories set categories_id=".$data["categories_id"]." where products_id=$id";
+ $rc=query("shop",$sql,"updartikel_2");
+ echo "~";
+ if ($KDGrp>0) personal_offer ($data["altprice"],$id);
+ $sql="select * from ".PREFIX."products_description where products_id=$id and language_id=$defLang";
+ $rs=getAll("shop",$sql,"updartikel_3");
+ if ($rs) { // bestehende Sprachen abgleichen
+ $sql="update ".PREFIX."products_description set products_name='%s',products_description='%s' where ";
+ $sql.="products_id=%d and language_id=$defLang";
+ $sql=sprintf($sql,$data["description"],$data["notes"],$id);
+ echo "l";
+ } else { // neue Sprache einfügen
+ $sql="insert into ".PREFIX."products_description (products_id,products_name,products_description,language_id) ";
+ $sql.="values (%d,'%s','%s',%d)";
+ $sql=sprintf($sql,$id,$data["description"],$data["notes"],$defLang);
+ echo "L";
+ }
+ $rc=query("shop",$sql,"updartikel_4");
+ if ($rc === -99) { return false;
+ } else { return true; }
+}
+
+/*******************************************
+* personal_offer ($personal_offer,$products_id)
+* Spezialangebote anlegen
+*******************************************/
+function personal_offer ($personal_offer,$products_id) {
+global $KDGrp;
+ $sql="select * from ".PREFIX."personal_offers_by_customers_status_$KDGrp where ";
+ $sql.="products_id=$products_id order by quantity limit 1";
+ $rs=getAll("shop",$sql,"personal_offer_1");
+ if ($rs) {
+ if ($personal_offer) {
+ $sql="update ".PREFIX."personal_offers_by_customers_status_$KDGrp ";
+ $sql.="set personal_offer=$personal_offer where price_id = ".$rs[0]["price_id"];
+ echo "p";
+ } else {
+ $sql="delete from ".PREFIX."personal_offers_by_customers_status_$KDGrp where price_id = ".$rs[0]["price_id"];
+ echo "q";
+ }
+ $rc=query("shop",$sql,"personal_offer_2");
+ } else {
+ if ($personal_offer) {
+ $sql="insert into ".PREFIX."personal_offers_by_customers_status_$KDGrp ";
+ $sql.="(price_id,products_id,quantity,personal_offer) ";
+ $sql.="values (0,$products_id,1,$personal_offer)";
+ $rc=query("shop",$sql,"personal_offer_3");
+ if ($rc === -99) return false;
+ echo "P";
+ }
+ };
+ return true;
+}
+
+/*******************************************
+* chkartikellang($data,$Lang)
+* Gibt es den Artikel und hat er sich geändert
+*******************************************/
+function chkartikellang($data,$Lang) {
+global $tax,$KDGrp,$GeoZone;
+ if ($data["partnumber"]=="") { echo "Artikelnummer fehlt!<br>"; return false;};
+ echo $data["partnumber"]." ".$data["translation"]." -> ";
+ $sql ="select P.products_id from ".PREFIX."products P left join ".PREFIX."products_description PD on P.products_id=PD.products_id where ";
+ $sql.="products_model like '".$data["partnumber"]."' and language_id=$Lang";
+ $rs=getAll("shop",$sql,"chkartikellang");
+ if (count($rs)>0) {
+ $sql="update ".PREFIX."products_description set products_name='".$data["translation"]."', products_description='".$data["longdescription"]."' ";
+ $sql.="where products_id='".$rs[0]["products_id"]."' and language_id=$Lang";
+ $rc=query("shop",$sql,"chkartikellang_u");
+ if ($rc === -99) return false;
+ } else {
+ $sql ="select products_id from ".PREFIX."products where products_model like '".$data["partnumber"]."'";
+ $rs=getAll("shop",$sql,"chkartikellang");
+ $sql="insert into ".PREFIX."products_description (products_id,language_id,products_name,products_description) values (";
+ $sql.=$rs[0]["products_id"].",$Lang,'".$data["translation"]."','".$data["longdescription"]."')";
+ $rc=query("shop",$sql,"chkartikellang_i");
+ if ($rc === -99) return false;
+ }
+ echo $rs[0]["products_id"]."<br>\n";
+ return true;
+}
+
+/*******************************************
+* chkartikel($data,$defLang)
+* Hat sich der Artikel verändert
+*******************************************/
+function chkartikel($data,$defLang) {
+global $tax,$erptax,$KDGrp,$GeoZone,$nopic;
+ if ($data["partnumber"]=="") { echo "Artikelnummer fehlt!<br>"; return;};
+ if ($data["image"]) {
+ $data["picname"]=(strrpos($data["image"],"/")>0)?substr($data["image"],strrpos($data["image"],"/")+1):$data["image"];
+ } else if ($nopic) {
+ $data["picname"]=(strrpos($nopic,"/")>0)?substr($nopic,strrpos($nopic,"/")+1):$nopic;
+ $data["image"]=$nopic;
+ }
+ $data["onhand"]=floor($data["onhand"]);
+ echo $data["partnumber"]." ".$data["description"]." -> ";
+ $sql ="select * from ".PREFIX."products where products_model like '".$data["partnumber"]."'";
+ $rs=getAll("shop",$sql,"chkartikel");
+ $data["rate"]=$erptax[$data["bugru"]]["rate"];
+ if ($rs) {
+ updartikel($data,$rs[0]["products_id"],$defLang);
+ if ($rs[0]["products_image"]<>$data["picname"] and $data["picname"]) uploadImage($data["image"],$rs[0]["products_id"]);
+ } else {
+ $id=insartikel($data,$defLang);
+ if ($data["image"]) uploadImage($data["image"],$id);
+ }
+ echo "<br>\n";
+}
+
+/*******************************************
+* Grafiken
+*******************************************/
+//Defaultwerte
+$picsize= array("PRODUCT_IMAGE_THUMBNAIL_WIDTH" => 120,"PRODUCT_IMAGE_THUMBNAIL_HEIGHT" => 80,
+ "PRODUCT_IMAGE_INFO_WIDTH" => 200,"PRODUCT_IMAGE_INFO_HEIGHT" => 160,
+ "PRODUCT_IMAGE_POPUP_WIDTH" => 300,"PRODUCT_IMAGE_POPUP_HEIGHT" => 240,"IMAGE_QUALITY" => 80);
+//persönliche Werte
+foreach ($picsize as $key => $val) {
+ $sql=sprintf("select configuration_value from ".PREFIX."configuration where configuration_key='%s'",$key);
+ $rs=getAll("shop",$sql,"Konfiguration");
+ if ($rs[0][$key]) $picsize[$key]=$rs[0][$key];
+}
+
+/*******************************************
+* Steuern
+*******************************************/
+//Steuertabelle ERP
+$sql ="select BG.id as bugru,T.rate,TK.startdate from buchungsgruppen BG left join chart C ";
+$sql.="on BG.income_accno_id_0=C.id left join taxkeys TK on TK.chart_id=C.id left join tax T ";
+$sql.="on T.id=TK.tax_id where TK.startdate <= now()";
+$rs=getAll("erp",$sql,"Tax ERP");
+$erptax=array();
+foreach ($rs as $row) {
+ if ($erptax[$row["bugru"]]["startdate"]<$row["startdate"]) {
+ $erptax[$row["bugru"]]["startdate"]=$row["startdate"];
+ $erptax[$row["bugru"]]["rate"]=$row["rate"]*100;
+ }
+}
+
+//Steuerzone Shop
+$sql="select GZ.geo_zone_id from ".PREFIX."configuration C, ".PREFIX."zones_to_geo_zones GZ ";
+$sql.="where C.configuration_key='STORE_COUNTRY' and GZ.zone_country_id=C.configuration_value";
+$rs=getAll("shop",$sql,"GZ");
+if ($rs) {
+ $GeoZone=$rs[0]["geo_zone_id"];
+} else {
+ echo "Steuerzone nicht gefunden";
+ exit;
+}
+
+//Steuersätze
+$sql="select * from ".PREFIX."tax_rates where tax_zone_id=$GeoZone";
+$rs=getAll("shop",$sql,"tax_rates");
+if ($rs) {
+ foreach ($rs as $zeile) {
+ $tax[$zeile["tax_rate"]]=$zeile["tax_class_id"];
+ }
+} else {
+ $tax[0]="";
+}
+
+/*******************************************
+* Sprache
+*******************************************/
+if (empty($Language) || !$Language) {
+ echo "Keine Sprachzuordnung definiert!";
+ exit;
+}
+
+//Default Shopsprache ermitteln
+$sql="select * from ".PREFIX."languages L left join ".PREFIX."configuration C on L.code=C.configuration_value ";
+$sql.="where configuration_key = 'DEFAULT_LANGUAGE'";
+$rs=getAll("shop",$sql,"DefaultLang");
+
+if ($rs) {
+ $ShopdefaultLang=$rs[0]["languages_id"];
+ if ($SHOPdefaultlang<>$ShopdefaultLang) {
+ echo "Defaultsprache im Shop wurde geändert";
+ exit;
+ }
+} else {
+ echo "Keine Defaultsprache im Shop eingestellt.";
+ exit;
+}
+
+$Languages=array();
+foreach ($Language as $Langrow) {
+ if ($Langrow["SHOP"]>0 and $Langrow["ERP"]>0) $Languages[$Langrow["ERP"]]=$Langrow["SHOP"];
+}
+
+/*******************************************
+* Import starten
+*******************************************/
+$artikel=shopartikel(); //array_keys($Languages));
+
+echo "Artikelexport ERP -> xt:Commerce (Standardsprache $ShopdefaultLang): ".count($artikel)." Artikel markiert.<br>";
+
+if ($artikel) { //Mit jedem Artikel in der Defaultsprache:
+ foreach ($artikel as $data) {
+ //Kategorie abfragen/anlegen
+ $data["categories_id"]=getCategory($data["partsgroup"],$ShopdefaultLang,$Languages);
+ chkartikel($data,$ShopdefaultLang,false);
+ }
+
+ foreach ($Languages as $erplang=>$shoplang) { //Mit jeder weiteren Sprache
+ $artikel=shopartikellang($erplang,$SpracheAlle);
+ echo "Shopsprache: $shoplang<br>";
+ if ($artikel) {
+ foreach ($artikel as $data) {
+ //Kategorie abfragen
+ $data["categories_id"]=getCategory($data["partsgroup"],$shoplang,$Languages);
+ if ($SpracheAlle) {
+ if ($data["translation"]=="") $data["translation"]=$data["description"];
+ if ($data["longdescription"]=="") $data["longdescription"]=$data["notes"];
+ }
+ chkartikellang($data,$shoplang);
+ }
+ }
+ }
+} else {
+ if ($debug) writelog("Fehler\n");
+}
+
+?>
--- /dev/null
+<?php
+
+$login=$_GET["login"];
+$debug=false;
+require_once "DB.php";
+require_once "conf$login.php";
+
+if ($dbprefix<>"") { define("PREFIX",$dbprefix."_"); } else { define("PREFIX",""); };
+
+$landarray=array("DEUTSCHLAND"=>"D","STEREICH"=>"A","OESTEREICH"=>"A","SCHWEIZ"=>"CH");
+$taxarray=array("D"=>0,"A"=>1,"CH"=>2);
+$defaultland="D";
+$taxid=0;
+$log=false;
+$erp=false;
+$shop=false;
+
+
+$ERPdns= array('phptype' => 'pgsql',
+ 'username' => $ERPuser,
+ 'password' => $ERPpass,
+ 'hostspec' => $ERPhost,
+ 'database' => $ERPdbname,
+ 'port' => $ERPport);
+
+$SHOPdns=array('phptype' => 'mysql',
+ 'username' => $SHOPuser,
+ 'password' => $SHOPpass,
+ 'hostspec' => $SHOPhost,
+ 'database' => $SHOPdbname,
+ 'port' => $SHOPport);
+
+/****************************************************
+* Debugmeldungen in File schreiben
+****************************************************/
+if ($debug) { $log=fopen("tmp/shop.log","a"); } // zum Debuggen
+else { $log=false; };
+
+/****************************************************
+* Shopverbindung aufbauen
+****************************************************/
+$shop=DB::connect($SHOPdns);
+if (!$shop) shopFehler("",$shop->getDebugInfo());
+if (DB::isError($shop)) {
+ $nun=date("Y-m-d H:i:s");
+ if ($log) fputs($log,$nun.": Shop-Connect\n");
+ shopFehler("",$shop->getDebugInfo());
+ die ($shop->getDebugInfo());
+};
+
+/****************************************************
+* ERPverbindung aufbauen
+****************************************************/
+$erp=DB::connect($ERPdns);
+if (!$erp) shopFehler("",$erp->getDebugInfo());
+if (DB::isError($erp)) {
+ $nun=date("Y-m-d H:i:s");
+ if ($log) fputs($log,$nun.": ERP-Connect\n");
+ shopFehler("",$erp->getDebugInfo());
+ die ($erp->getDebugInfo());
+} else {
+ if ($erp->autocommit) $erp->autocommit();
+};
+
+/****************************************************
+* SQL-Befehle absetzen
+****************************************************/
+function query($db,$sql,$function="--") {
+ $nun=date("d.m.y H:i:s");
+ if ($GLOBALS["log"]) fputs($GLOBALS["log"],$nun.": ".$function."\n".$sql."\n");
+ $rc=$GLOBALS[$db]->query($sql);
+ if ($GLOBALS["log"]) fputs($GLOBALS["log"],print_r($rc,true)."\n");
+ if ($rc!==1) {
+ return -99;
+ } else {
+ return true;
+ }
+}
+
+/****************************************************
+* Datenbank abfragen
+****************************************************/
+function getAll($db,$sql,$function="--") {
+ $nun=date("d.m.y H:i:s");
+ if ($GLOBALS["log"]) fputs($GLOBALS["log"],$nun.": ".$function."\n".$sql."\n");
+ $rs=$GLOBALS[$db]->getAll($sql,DB_FETCHMODE_ASSOC);
+ if ($rs["message"]<>"") {
+ if ($GLOBALS["log"]) fputs($GLOBALS["log"],print_r($rs,true)."\n");
+ return false;
+ } else {
+ return $rs;
+ }
+}
+
+/****************************************************
+* shopFehler
+* in: sql,err = string
+* out:
+* Fehlermeldungen ausgeben
+*****************************************************/
+function shopFehler($sql,$err) {
+global $showErr;
+ if ($showErr)
+ echo "</td></tr></table><font color='red'>$sql : $err</font><br>";
+}
+
+/****************************************************
+* Nächste Auftragsnummer (ERP) holen
+****************************************************/
+function getNextAnr() {
+ $sql="select * from defaults";
+ $sql1="update defaults set sonumber=";
+ if ($rc === -99) {
+ echo "Kann keine Auftragsnummer erzeugen - Abbruch";
+ $rc=query("erp","ROLLBACK","getNextKnr");
+ exit();
+ }
+ $rs2=getAll("erp",$sql,"getNextAnr");
+ $auftrag=$rs2[0]["sonumber"]+1;
+ $rc=query("erp",$sql1.$auftrag,"getNextAnr");
+ if ($rc === -99) {
+ echo "Kann keine Auftragsnummer erzeugen - Abbruch";
+ $rc=query("erp","ROLLBACK","getNextKnr");
+ exit();
+ }
+ return $auftrag;
+}
+
+/****************************************************
+* Nächste Kundennummer (ERP) holen
+****************************************************/
+function getNextKnr() {
+ $sql="select * from defaults";
+ $sql1="update defaults set customernumber='";
+ if ($rc === -99) {
+ echo "Kann keine Kundennummer erzeugen - Abbruch";
+ exit();
+ }
+ $rs2=getAll("erp",$sql,"getNextKnr");
+ $kdnr=$rs2[0]["customernumber"]+1;
+ $rc=query("erp",$sql1.$kdnr."'","getNextKnr");
+ if ($rc === -99) {
+ echo "Kann keine Kundennummer erzeugen - Abbruch";
+ $rc=query("erp","ROLLBACK","getNextKnr");
+ exit();
+ }
+ return $kdnr;
+}
+
+
+//$shopdata=array("firma"=>"","abteilung"=>"","vorname"=>"","nachname"=>"","strasse"=>"","plz"=>"","ort"=>"","telefon"=>"","email"=>"","land"=>"","fax"=>"","notiz"=>"","postfach"=>"")
+$shopdata=array( "id"=>"customers_id","kdnr"=>"customers_cid","bid"=>"orders_id", "anrede"=>" customers_gender",
+ "firma"=>"customers_company", "nachname"=>"customers_lastname", "vorname"=>"customers_firstname",
+ "strasse"=>"customers_street_address","plz"=>"customers_postcode","ort"=>"customers_city","land"=>"customers_country",
+ "telefon"=>"customers_phone","email"=>"customers_email_address","fax"=>"Fax","notiz"=>"comments",
+
+ "netto"=>"ot_subtotal","steuer"=>"ot_tax","datum"=>" date_purchased","bemerkung"=>"comments",
+ "artnr"=>"products_id","preis"=>"final_price","artikeltxt"=>" products_name","menge"=>" products_quantity");
+
+$shopartikel=array( "id"=>"Artikel_ID","artnr"=>"Artikel_Nr","arttxt"=>"Name","artbeschr"=>"Beschreibung","gruppe"=>"Kategorie_ID",
+ "preis"=>"Preis","preis2"=>"Haendlerpreis","preis3"=>"Aktionspreis","gewicht"=>"Gewicht",
+ "bild"=>"Bild_gross","bestand"=>"Lagerbestand","minbestand"=>"Mindestlagermenge","steuer"=>"MwSt_Satz");
+
+
+/****************************************************
+* Ab hier Artikelexport aus ERP
+****************************************************/
+// Ab hier Artikelexport aus ERP nur eine Sprache
+function shopartikellang($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=getAll("erp",$sql,"shopartikellang");
+ $data=array();
+ if ($rs) foreach ($rs as $row) {
+ if (!$data[$row["partnumber"]]) $data[$row["partnumber"]]=$row;
+ }
+ return $data;
+}
+// Ab hier alle Artikelexport aus ERP Defaultsprache
+function shopartikel() {
+global $stdprice,$altprice;
+ if ($stdprice>0) {
+ $sql="SELECT P.partnumber,P.description,P.weight,(t.rate * 100) as rate,G.price as sellprice,P.sellprice as stdprice, ";
+ $sql.="PG.partsgroup,P.notes,P.image,P.onhand,G.pricegroup_id,P.buchungsgruppen_id as bugru FROM ";
+ $sql.="chart c left join tax t on c.taxkey_id=t.taxkey, parts P left join partsgroup PG on ";
+ $sql.="PG.id=P.partsgroup_id left join prices G on G.parts_id=P.id ";
+ $sql.="buchungsgruppen B on P.buchungsgruppen_id = B.id ";
+ $sql.="where P.shop='t' and c.id=p.income_accno_id and ";
+ $sql.="(G.pricegroup_id=$stdprice or pricegroup_id=$altprice or G.pricegroup_id is null) ";
+ $sql.="order by P.partnumber";
+ } else {
+ $sql="SELECT P.partnumber,P.description,P.weight,(t.rate * 100) as rate,P.sellprice,PG.partsgroup,";
+ $sql.="P.notes,P.image,P.onhand,P.buchungsgruppen_id as bugru FROM ";
+ $sql.="chart c left join tax t on c.taxkey_id=t.taxkey, parts P left join partsgroup PG on ";
+ $sql.="PG.id=P.partsgroup_id left join buchungsgruppen B on P.buchungsgruppen_id = B.id ";
+ $sql.="WHERE P.shop='t' and c.id=B.income_accno_id_0";
+ }
+ $rs=getAll("erp",$sql,"shopartikel");
+ $i=0;
+ $data=array();
+ if ($rs) foreach ($rs as $row) {
+ if (!$data[$row["partnumber"]]) $data[$row["partnumber"]]=$row;
+ if ($row["pricegroup_id"]==$altprice) {
+ $data[$row["partnumber"]]["altprice"]=($row["sellprice"])?$row["sellprice"]:$row["stdprice"];
+ } else {
+ $data[$row["partnumber"]]["sellprice"]=($row["sellprice"])?$row["sellprice"]:$row["stdprice"];
+ }
+ $i++;
+ }
+ return $data;
+}
+
+/****************************************************
+* Artikelexport in ERP importieren
+****************************************************/
+function insertArtikel($data) {
+global $shopartikel;
+ foreach ($data as $row) {
+ $pg=$GLOBALS["warengruppen"][$row[$shopartikel["gruppe"]]]["partsgroup"];
+ $bg=$GLOBALS["buchungsgruppen"][sprintf("%0.2f",$row[$shopartikel["steuer"]])];
+ $artnr=($row[$shopartikel["artnr"]])?$row[$shopartikel["artnr"]]:getArtnr();
+ $sqltmp="insert into parts (partnumber,description,notes,weight,onhand,rop,image,sellprice,unit,partsgroup_id,buchungsgruppen_id) ";
+ $sqltmp.="values ('%s','%s','%s',%0.5f,%0.5f,%0.5f,'%s',%0.5f,'%s',%d,%d)";
+ $sql=sprintf($sqltmp,$artnr,$row[$shopartikel["arttxt"]],$row[$shopartikel["artbeschr"]],
+ $row[$shopartikel["gewicht"]],$row[$shopartikel["bestand"]],$row[$shopartikel["minbestand"]],
+ $row[$shopartikel["bild"]],$row[$shopartikel["preis"]],$row[$shopartikel["einheit"]],$pg,$bg);
+ $rc=query("erp",$sql,"insertArtikel");
+ if ($rc === -99) {
+ echo $row[$shopartikel["id"]]." ".$row[$shopartikel["arttxt"]]." nicht importiert<br>";
+ } else {
+ echo "";
+ }
+ echo $sql."<br>";
+ }
+}
+
+/****************************************************
+* Nächste Artikelnummer (ERP) holen
+****************************************************/
+function getArtnr() {
+ $sql="select * from defaults";
+ $sql1="update defaults set articlenumber='";
+ $rc=query("erp","BEGIN","getArtnr");
+ if ($rc === -99) {
+ echo "Kann keine Artikelnummer erzeugen - Abbruch";
+ exit();
+ }
+ $rs2=getAll("erp",$sql,"getArtnr");
+ $artnr=$rs2[0]["articelnumber"]+1;
+ $rc=query("erp",$sql1.$artnr."'","getArtnr");
+ if ($rc === -99) {
+ echo "Kann keine Artikelnummer erzeugen - Abbruch";
+ $rc=query("erp","ROLLBACK","getArtnr");
+ exit();
+ }
+ $rc=query("erp","COMMIT","getArtnr");
+ return $artnr;
+}
+
+$buchungsgruppen=array();
+$warengruppen=array();
+
+function getBugru() {
+ $sql ="select B.id,tax.rate from buchungsgruppen B left join chart on income_accno_id_0=chart.id left join taxkeys T on ";
+ $sql.="T.chart_id=income_accno_id_0 left join tax on tax.id=T.tax_id where T.startdate<=now()";
+ $rs=getAll("erp",$sql,"getBugru");
+ if ($rs) foreach ($rs as $row) {
+ $steuer=sprintf("%0.2f",$row["rate"]*100);
+ $GLOBALS["buchungsgruppen"][$steuer]=$row["id"];
+ }
+}
+
+$wg=1000;
+
+function insPartgroup($kat) {
+ $sql="insert into partsgroup () value ()";
+ $GLOBALS["wg"]++;
+ //$rc=query("erp",$sql,"insPartgroup");
+ if ($rc === -99) { return false; }
+ else { return $GLOBALS["wg"]; }
+}
+getBugru();
+?>
--- /dev/null
+<?
+/***************************************************************
+* $Id: trans.php,v 1.1 2004/06/29 08:50:30 hli Exp $
+*Author: Holger Lindemann
+*Copyright: (c) 2004 Lx-System
+*License: non free
+*eMail: info@lx-system.de
+*Version: 1.0.0
+*Shop: xt:Commerce 2.2
+*ERP: Lx-Office ERP
+***************************************************************/
+require_once "DB.php";
+require_once "conf.php";
+$LAND=array("Germany"=>"D");
+$db=DB::connect($SHOPdns);
+if (DB::isError($db)||!$db) { $shop="<font color='red'>Fehler</font>"; } else { $shop="ok"; };
+$db2=DB::connect($ERPdns);
+if (DB::isError($db2)||!$db2) { $erp="<font color='red'>Fehler</font>"; } else { $erp="ok"; };
+
+?>
+<html>
+ <head>
+ <title>Datenaustausch ERP-olCommerce</title>
+ </head>
+<body>
+<center>
+<table>
+ <tr>
+ <td colspan="2">
+ Eine direkte Verbindung beider Datenbanken ist erforderlich!<br>
+ Folgende Verbindungsdaten wurden gefunden:
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <b>Lx-ERP</b>
+ </td>
+ <td><?= $erp ?></td>
+ </tr>
+ <tr>
+ <td>Datenbank-Server</td>
+ <td><?= $ERPhost ?></td>
+ </tr>
+ <tr>
+ <td>Datenbank</td>
+ <td><?= $ERPdbname ?></td>
+ </tr>
+ <tr>
+ <td>
+ <b>xt:Commerce</b>
+ </td>
+ <td><?= $shop ?></td>
+ </tr>
+ <tr>
+ <td>Datenbank-Server</td>
+ <td><?= $SHOPhost ?></td>
+ </tr>
+ <tr>
+ <td>Datenbank</td>
+ <td><?= $SHOPdbname ?></td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <hr>
+ </td>
+ </tr>
+ <tr>
+ <td align="center"><a href="shopimport_db.php"><img src="e2s.gif" border="0"></a></td>
+ <td align="center"><a href="olcomexport.php"><img src="s2e.gif" border="0"></a></td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <hr>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ Für den Export der Artikeldaten aus der ERP in eine CSV-Datei<br>
+ oder den Import der Artikeldaten in den Shop ist nur die Verbindung<br>
+ zur entsprechenden Datenbank notwendig.<br>
+ Die CSV-Dateien werden in den konfigurierten Verzeichnissen erwartet.<br>
+ Der Webserver benötigt hier Schreibrechte.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <b>Lx-ERP</b>
+ </td>
+ <td><a href="<?= $ERPdir ?>"><?= $ERPdir ?></a></td>
+ </tr>
+ <tr>
+ <td>
+ <b>xt:Commerce</b>
+ </td>
+ <td><a href="<?= $SHOPdir ?>"><?= $SHOPdir ?></a></td>
+ </tr>
+ <tr>
+ <td align="center"><a href="erpexport.php"><img src="e2c.gif" border="0"></a></td>
+ <td align="center"><a href="shopimport_csv.php"><img src="c2s.gif" border="0"></a></td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <hr>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ Copyright (c) 2004 Lx-System - Version: 1.0 - <a href="mailto:info@lx-system.de">info@lx-system.de</a>
+ </td>
+ </tr>
+</table>
+</center>
+</body>
+</html>