Revision f33a755c
Von Holger Lindemann vor fast 16 Jahren hinzugefügt
pepper/shopimport_db.php | ||
---|---|---|
9 | 9 |
*Shop: PHPeppershop 2.0 |
10 | 10 |
*ERP: Lx-Office ERP |
11 | 11 |
***************************************************************/ |
12 |
require_once "conf.php"; |
|
12 |
$login=($_GET["login"])?$_GET["login"]:$_POST["login"]; |
|
13 |
if (file_exists ("conf$login.php")) { |
|
14 |
require "conf$login.php"; |
|
15 |
} else { |
|
16 |
require "conf.php"; |
|
17 |
} |
|
13 | 18 |
require_once "DB.php"; |
14 | 19 |
|
15 | 20 |
$db=DB::connect($SHOPdns); |
... | ... | |
35 | 40 |
if ($showErr) |
36 | 41 |
echo "</td></tr></table><font color='red'>$sql : $err</font><br>"; |
37 | 42 |
} |
38 |
|
|
43 |
function getBugru() { |
|
44 |
global $db2; |
|
45 |
if (!$db2) return; |
|
46 |
$sql ="select BG.id as bugru,(T.rate * 100) as rate,TK.startdate from buchungsgruppen BG "; |
|
47 |
$sql.="left join chart C on BG.income_accno_id_0=C.id left join taxkeys TK "; |
|
48 |
$sql.="on TK.chart_id=C.id left join tax T on T.id=TK.tax_id where "; |
|
49 |
$sql.="TK.startdate <= now() order by BG.id, TK.startdate"; |
|
50 |
$rs=$db2->getAll($sql,DB_FETCHMODE_ASSOC); |
|
51 |
if ($rs) foreach ($rs as $row) { |
|
52 |
$bugru[$row["bugru"]]=$row["rate"]; |
|
53 |
} |
|
54 |
return $bugru; |
|
55 |
} |
|
39 | 56 |
// Ab hier Artikelexport aus ERP |
40 | 57 |
function shopartikel() { |
41 | 58 |
global $db2,$pricegroup; |
42 | 59 |
if ($pricegroup>0) { |
43 |
$sql="SELECT P.partnumber,P.description,P.weight,(t.rate * 100) as rate,G.price as sellprice,P.sellprice as stdprice, ";
|
|
60 |
$sql="SELECT P.partnumber,P.description,P.weight,buchungsgruppen_id as bugru,G.price as sellprice,P.sellprice as stdprice, ";
|
|
44 | 61 |
$sql.="PG.partsgroup,P.notes,P.image,P.onhand FROM "; |
45 |
$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 ";
|
|
46 |
$sql.="where P.shop='t' and c.id=p.income_accno_id and (G.pricegroup_id=$pricegroup or G.pricegroup_id is null)";
|
|
62 |
$sql.="parts P left join partsgroup PG on PG.id=P.partsgroup_id left join prices G on G.parts_id=P.id "; |
|
63 |
$sql.="where P.shop='t' and (G.pricegroup_id=$pricegroup or G.pricegroup_id is null)"; |
|
47 | 64 |
} else { |
48 |
$sql="SELECT P.partnumber,P.description,P.weight,(t.rate * 100) as rate,P.sellprice,PG.partsgroup,P.notes,P.image,P.onhand FROM ";
|
|
49 |
$sql.="chart c left join tax t on c.taxkey_id=t.taxkey, parts P left join partsgroup PG on ";
|
|
50 |
$sql.="PG.id=P.partsgroup_id where P.shop='t' and c.id=p.income_accno_id";
|
|
65 |
$sql="SELECT P.partnumber,P.description,P.weight,buchungsgruppen_id as bugru,P.sellprice,PG.partsgroup,P.notes,P.image,P.onhand FROM ";
|
|
66 |
$sql.="parts P left join partsgroup PG on "; |
|
67 |
$sql.="PG.id=P.partsgroup_id where P.shop='t'"; |
|
51 | 68 |
} |
52 | 69 |
$rs=$db2->getAll($sql,DB_FETCHMODE_ASSOC); |
53 | 70 |
return $rs; |
... | ... | |
200 | 217 |
} else { return false; } |
201 | 218 |
} |
202 | 219 |
function updartikel($data,$id) { |
203 |
global $db; |
|
220 |
global $db,$bugru;
|
|
204 | 221 |
$sql ="update artikel set Preis=%01.2f,Gewicht=%0.2f,MwSt_Satz=%0.2f,letzteAenderung=now(),"; |
205 | 222 |
$sql.="Name='%s',Beschreibung='%s',Lagerbestand=%d where Artikel_ID=%d"; |
206 | 223 |
$preis=($data["sellprice"]>0)?$data["sellprice"]:$data["stdprice"]; |
207 |
$sql=sprintf($sql,$preis,$data["weight"],$tax[sprintf("%1.4f",$data["rate"])],$data["description"],$data["notes"],$data["onhand"],$id); |
|
224 |
$preis+=$preis/100*$bugru[$data["bugru"]]; |
|
225 |
$sql=sprintf($sql,$preis,$data["weight"],$bugru[$data["bugru"]],$data["description"],$data["notes"],$data["onhand"],$id); |
|
208 | 226 |
$rc=$db->query($sql); |
209 | 227 |
$sql="update artikel_kategorie set FK_Kategorie_ID=".$data["categories_id"]." where FK_Artikel_ID=$id"; |
210 | 228 |
$rc=$db->query($sql); |
... | ... | |
223 | 241 |
else { $data["picname"]=""; }; |
224 | 242 |
} |
225 | 243 |
$preis=($data["sellprice"]>0)?$data["sellprice"]:$data["stdprice"]; |
244 |
$preis+=$preis/100*$bugru[$data["bugru"]]; |
|
226 | 245 |
if ($rs[0]["Preis"]<>$preis) { updartikel($data,$rs[0]["Artikel_ID"]); } |
227 | 246 |
else if ($rs[0]["Gewicht"]<>$data["weight"]) { updartikel($data,$rs[0]["Artikel_ID"]); } |
228 | 247 |
else if ($rs[0]["Name"]<>$data["description"]) { updartikel($data,$rs[0]["Artikel_ID"]); } |
... | ... | |
245 | 264 |
$artikel=shopartikel(); |
246 | 265 |
echo "Artikelexport ERP -> PHPepper :".count($artikel)." Artikel markiert.<br>"; |
247 | 266 |
if ($artikel) { |
267 |
$bugru=getBugru(); |
|
248 | 268 |
$sql="select Thumbnail_Breite from shop_settings"; |
249 | 269 |
$rs=$db->getAll($sql,DB_FETCHMODE_ASSOC); |
250 | 270 |
if ($rs) { |
Auch abrufbar als: Unified diff
Buchungsgruppen, diverses