X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=pepper%2Fshopimport_db.php;h=d7d16c7aef1d9029eb0e088b03b8560c8aa327ae;hb=f644f69456ae54104ac2cd069f8aaaa399130eb6;hp=b078a3f13a60d95648d69d760455af208cd33305;hpb=57096a4882de38f1aa0d3fd061f52b5cdfec8b38;p=kivitendo-erp.git diff --git a/pepper/shopimport_db.php b/pepper/shopimport_db.php index b078a3f13..d7d16c7ae 100644 --- a/pepper/shopimport_db.php +++ b/pepper/shopimport_db.php @@ -9,7 +9,12 @@ *Shop: PHPeppershop 2.0 *ERP: Lx-Office ERP ***************************************************************/ -require_once "conf.php"; +$login=($_GET["login"])?$_GET["login"]:$_POST["login"]; +if (file_exists ("conf$login.php")) { + require "conf$login.php"; +} else { + require "conf.php"; +} require_once "DB.php"; $db=DB::connect($SHOPdns); @@ -35,19 +40,31 @@ global $showErr; if ($showErr) echo "$sql : $err
"; } - +function getBugru() { +global $db2; + if (!$db2) return; + $sql ="select BG.id as bugru,(T.rate * 100) as rate,TK.startdate from buchungsgruppen BG "; + $sql.="left join chart C on BG.income_accno_id_0=C.id left join taxkeys TK "; + $sql.="on TK.chart_id=C.id left join tax T on T.id=TK.tax_id where "; + $sql.="TK.startdate <= now() order by BG.id, TK.startdate"; + $rs=$db2->getAll($sql,DB_FETCHMODE_ASSOC); + if ($rs) foreach ($rs as $row) { + $bugru[$row["bugru"]]=$row["rate"]; + } + return $bugru; +} // Ab hier Artikelexport aus ERP function shopartikel() { global $db2,$pricegroup; if ($pricegroup>0) { - $sql="SELECT P.partnumber,P.description,P.weight,(t.rate * 100) as rate,G.price as sellprice,P.sellprice as stdprice, "; + $sql="SELECT P.partnumber,P.description,P.weight,buchungsgruppen_id as bugru,G.price as sellprice,P.sellprice as stdprice, "; $sql.="PG.partsgroup,P.notes,P.image,P.onhand FROM "; - $sql.="chart c left join tax t on c.taxkey_id=t.taxkey, parts P left join partsgroup PG on PG.id=P.partsgroup_id left join prices G on G.parts_id=P.id "; - $sql.="where P.shop='t' and c.id=p.income_accno_id and (G.pricegroup_id=$pricegroup or G.pricegroup_id is null)"; + $sql.="parts P left join partsgroup PG on PG.id=P.partsgroup_id left join prices G on G.parts_id=P.id "; + $sql.="where P.shop='t' and (G.pricegroup_id=$pricegroup or G.pricegroup_id is null)"; } else { - $sql="SELECT P.partnumber,P.description,P.weight,(t.rate * 100) as rate,P.sellprice,PG.partsgroup,P.notes,P.image,P.onhand 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 where P.shop='t' and c.id=p.income_accno_id"; + $sql="SELECT P.partnumber,P.description,P.weight,buchungsgruppen_id as bugru,P.sellprice,PG.partsgroup,P.notes,P.image,P.onhand FROM "; + $sql.="parts P left join partsgroup PG on "; + $sql.="PG.id=P.partsgroup_id where P.shop='t'"; } $rs=$db2->getAll($sql,DB_FETCHMODE_ASSOC); return $rs; @@ -200,18 +217,19 @@ global $db; } else { return false; } } function updartikel($data,$id) { -global $db; +global $db,$bugru,$mwst; $sql ="update artikel set Preis=%01.2f,Gewicht=%0.2f,MwSt_Satz=%0.2f,letzteAenderung=now(),"; $sql.="Name='%s',Beschreibung='%s',Lagerbestand=%d where Artikel_ID=%d"; $preis=($data["sellprice"]>0)?$data["sellprice"]:$data["stdprice"]; - $sql=sprintf($sql,$preis,$data["weight"],$tax[sprintf("%1.4f",$data["rate"])],$data["description"],$data["notes"],$data["onhand"],$id); + if ($mwst) $preis+=$preis/100*$bugru[$data["bugru"]]; + $sql=sprintf($sql,$preis,$data["weight"],$bugru[$data["bugru"]],$data["description"],$data["notes"],$data["onhand"],$id); $rc=$db->query($sql); $sql="update artikel_kategorie set FK_Kategorie_ID=".$data["categories_id"]." where FK_Artikel_ID=$id"; $rc=$db->query($sql); echo "+++
"; } function chkartikel($data) { -global $db,$shop2erp; +global $db,$shop2erp,$mwst; if ($data["partnumber"]=="") { echo "Artikelnummer fehlt!
"; return false;}; $sql="select * from artikel A left join artikel_kategorie K on A.Artikel_id=K.FK_Artikel_ID where Artikel_Nr like '".$data["partnumber"]."'"; $rs=$db->getAll($sql,DB_FETCHMODE_ASSOC); @@ -223,6 +241,7 @@ global $db,$shop2erp; else { $data["picname"]=""; }; } $preis=($data["sellprice"]>0)?$data["sellprice"]:$data["stdprice"]; + if ($mwst) $preis+=$preis/100*$bugru[$data["bugru"]]; if ($rs[0]["Preis"]<>$preis) { updartikel($data,$rs[0]["Artikel_ID"]); } else if ($rs[0]["Gewicht"]<>$data["weight"]) { updartikel($data,$rs[0]["Artikel_ID"]); } else if ($rs[0]["Name"]<>$data["description"]) { updartikel($data,$rs[0]["Artikel_ID"]); } @@ -245,6 +264,7 @@ global $db,$shop2erp; $artikel=shopartikel(); echo "Artikelexport ERP -> PHPepper :".count($artikel)." Artikel markiert.
"; if ($artikel) { + $bugru=getBugru(); $sql="select Thumbnail_Breite from shop_settings"; $rs=$db->getAll($sql,DB_FETCHMODE_ASSOC); if ($rs) {