Revision 9d1e363b
Von Holger Lindemann vor fast 16 Jahren hinzugefügt
pepper/pepperexport.php | ||
---|---|---|
1 | 1 |
<? |
2 | 2 |
/*************************************************************** |
3 |
* $Id: pepperexport.php,v 2.0 2006/02/06 13:49:11 hli Exp $
|
|
3 |
* $Id: pepperexport.php 2009/02/10 14:41:11 hli Exp $
|
|
4 | 4 |
*Author: Holger Lindemann |
5 | 5 |
*Copyright: (c) 2004 Lx-System |
6 | 6 |
*License: non free |
7 | 7 |
*eMail: info@lx-system.de |
8 |
*Version: 1.3.0
|
|
8 |
*Version: 1.4.0
|
|
9 | 9 |
*Shop: PHPeppershop 2.0 |
10 |
*ERP: Lx-Office ERP >= 2.2.0
|
|
10 |
*ERP: Lx-Office ERP >= 2.4.0
|
|
11 | 11 |
***************************************************************/ |
12 | 12 |
?> |
13 | 13 |
<html> |
... | ... | |
16 | 16 |
<body> |
17 | 17 |
|
18 | 18 |
<?php |
19 |
$login=($_GET["login"])?$_GET["login"]:$_POST["login"]; |
|
20 |
if (file_exists ("conf$login.php")) { |
|
21 |
require "conf$login.php"; |
|
22 |
} else { |
|
23 |
require "conf.php"; |
|
24 |
} |
|
19 | 25 |
require_once "DB.php"; |
20 |
require_once "conf.php"; |
|
21 | 26 |
$db=DB::connect($SHOPdns); |
22 | 27 |
if (!$db) dbFehler("",$db->getDebugInfo()); |
23 | 28 |
if (DB::isError($db)) { |
... | ... | |
30 | 35 |
dbFehler("",$db2->getDebugInfo()); |
31 | 36 |
die ($db2->getDebugInfo()); |
32 | 37 |
}; |
38 |
function query($db,$sql) { |
|
39 |
global $utftrans; |
|
40 |
if ($utftrans) $sql=utf8_encode($sql); |
|
41 |
$rc=$db->query($sql); |
|
42 |
if (DB::isError($rc)) { |
|
43 |
dbFehler($sql,$rc->userinfo); |
|
44 |
return false; |
|
45 |
} |
|
46 |
return $rc; |
|
47 |
} |
|
33 | 48 |
/**************************************************** |
34 | 49 |
* dbFehler |
35 | 50 |
* in: sql,err = string |
... | ... | |
56 | 71 |
return $rs[0]["Kunden_Nr"]; |
57 | 72 |
} |
58 | 73 |
function sonderkosten($transID,$data,$id,$f) { |
59 |
global $db2,$versand,$nachn,$minder,$treuh,$paypal; |
|
74 |
global $db2,$versand,$nachn,$minder,$treuh,$paypal,$unit;
|
|
60 | 75 |
$sql="insert into orderitems (trans_id, parts_id, description, qty, sellprice, unit, ship, discount) values ("; |
61 |
$sql.=$transID.",".${$id}["ID"].",'".${$id}["TXT"]."',1,".$data.",'mal',0,0)";
|
|
76 |
$sql.=$transID.",".${$id}["ID"].",'".${$id}["TXT"]."',1,".$data.",'".$unit."',0,0)";
|
|
62 | 77 |
fputs($f,"$transID,".${$id}["ID"].",'".${$id}["TXT"]."',1,$data\n"); |
63 |
if (!$db2->query($sql)) { return false; }
|
|
78 |
if (!query($sql)) { return false; } |
|
64 | 79 |
else { return true; }; |
65 | 80 |
} |
66 | 81 |
function insBestArtikel($zeile,$transID) { |
... | ... | |
99 | 114 |
} |
100 | 115 |
$sql="insert into orderitems (trans_id, parts_id, description, qty, sellprice, unit, ship, discount) values ("; |
101 | 116 |
$sql.=$transID.",".$artID.",'".$notes."',".$zeile["Anzahl"].",".$preis.",'Stck',0,0)"; |
102 |
$rc=$db2->query($sql); |
|
117 |
$rc=query($db2,$sql); |
|
118 |
|
|
103 | 119 |
if (!$rc) { $ok=false; break; }; |
104 | 120 |
fputs($f,$transID.",".$artID.",'".$zeile["Artikelname"]."',".$zeile["Anzahl"].",".$preis."\n"); |
105 | 121 |
echo " - Artikel:[ BuNr.:$artID ArtNr:<b> ".$zeile["Anzahl"]." x ".$zeile["Artikel_Nr"]."</b> :".$zeile["Artikelname"]." ]<br>"; |
... | ... | |
121 | 137 |
} |
122 | 138 |
if ($ok) { |
123 | 139 |
$sql="update bestellung set Bestellung_bezahlt='Y' WHERE Bestellungs_ID =$BID"; |
124 |
$rc=$db->query($sql);
|
|
140 |
$rc=query($db,$sql);
|
|
125 | 141 |
fputs($f,"ok\n"); |
126 | 142 |
return true; |
127 | 143 |
} else { |
128 | 144 |
$sql="delete from orderitems where trans_id=$transID"; |
129 |
$rc=$db->query($sql);
|
|
145 |
$rc=query($db,$sql);
|
|
130 | 146 |
$sql="delete from oe where id=$transID"; |
131 |
$rc=$db->query($sql);
|
|
147 |
$rc=query($db,$sql);
|
|
132 | 148 |
fputs($f,"Fehler (insBestArtikel)!!!!\n"); |
133 | 149 |
return false; |
134 | 150 |
} |
... | ... | |
137 | 153 |
global $db2; |
138 | 154 |
$sql="select * from defaults"; |
139 | 155 |
$sql1="update defaults set sonumber="; |
140 |
$rc=$db2->query("BEGIN");
|
|
156 |
$rc=query($db2,"BEGIN");
|
|
141 | 157 |
$rs2=$db2->getAll($sql,DB_FETCHMODE_ASSOC); |
142 | 158 |
$auftrag=$rs2[0]["sonumber"]+1; |
143 |
$rc=$db2->query($sql1.$auftrag);
|
|
144 |
$rc=$db2->query("COMMIT");
|
|
159 |
$rc=query($db2,$sql1.$auftrag);
|
|
160 |
$rc=query($db2,"COMMIT");
|
|
145 | 161 |
return $auftrag; |
146 | 162 |
} |
147 | 163 |
function getNextKnr() { |
148 | 164 |
global $db2; |
149 | 165 |
$sql="select * from defaults"; |
150 | 166 |
$sql1="update defaults set customernumber='"; |
151 |
$rc=$db2->query("BEGIN");
|
|
167 |
$rc=query($db2,"BEGIN");
|
|
152 | 168 |
$rs2=$db2->getAll($sql,DB_FETCHMODE_ASSOC); |
153 | 169 |
$kdnr=$rs2[0]["customernumber"]+1; |
154 |
$rc=$db2->query($sql1.$kdnr."'");
|
|
155 |
$rc=$db2->query("COMMIT");
|
|
170 |
$rc=query($db2,$sql1.$kdnr."'");
|
|
171 |
$rc=query($db2,"COMMIT");
|
|
156 | 172 |
return $kdnr; |
157 | 173 |
} |
158 | 174 |
function getBestellung() { |
... | ... | |
175 | 191 |
$anr=$preA.$refnr; |
176 | 192 |
} |
177 | 193 |
$sql="insert into oe (notes,ordnumber,cusordnumber) values ('$newID','$anr','$refnr')"; |
178 |
$rc=$db2->query($sql);
|
|
194 |
$rc=query($db2,$sql);
|
|
179 | 195 |
$sql="select * from oe where notes = '$newID'"; |
180 | 196 |
$rs2=$db2->getAll($sql,DB_FETCHMODE_ASSOC); |
181 | 197 |
$Bezahlung=$zeile["Bezahlungsart"]; |
... | ... | |
191 | 207 |
$sql.="', customer_id=$kdnr, amount=".$zeile["Rechnungsbetrag"].", netamount=".($zeile["Rechnungsbetrag"]-$zeile["MwSt"]); |
192 | 208 |
$sql.=", reqdate='".$zeile["Datum"]."', notes='$Bezahlung', taxincluded='f', curr='EUR',employee_id=".$ERPusr["ID"].", vendor_id=0 "; |
193 | 209 |
$sql.="where id=".$rs2[0]["id"]; |
194 |
$rc=$db2->query($sql);
|
|
210 |
$rc=query($db2,$sql);
|
|
195 | 211 |
fputs($f,"ordnumber=".$zeile["Bestellungs_ID"].", transdate='".$zeile["Datum"]."', customer_id=$kdnr, amount=".($zeile["Rechnungsbetrag"]+$zeile["MwSt"]).", notes=".$zeile["Bezahlungsart"]."\n"); |
196 | 212 |
echo "Auftrag:[ Buchungsnummer:".$rs2[0]["id"]." AuftrNr:<b>".$anr."</b> ]<br>"; |
197 | 213 |
if (!insBestArtikel($zeile,$rs2[0]["id"])) { $ok=false; echo " Fehler<br>"; break; } else { echo " ok<br>"; }; |
... | ... | |
222 | 238 |
}; |
223 | 239 |
if ($set) { |
224 | 240 |
$sql="update customer set ".substr($set,0,-1)." where id=".$rs[0]["id"]; |
225 |
$rc=$db2->query($sql);
|
|
241 |
$rc=query($db2,$sql);
|
|
226 | 242 |
} |
227 | 243 |
} |
228 | 244 |
function insKdData($data) { |
... | ... | |
234 | 250 |
$kdnr=$preK.$data["customers_id"]; |
235 | 251 |
} |
236 | 252 |
$sql="insert into customer (name,customernumber) values ('$newID','$kdnr')"; |
237 |
$rc=$db2->query($sql);
|
|
253 |
$rc=query($db2,$sql);
|
|
238 | 254 |
$sql="select * from customer where name = '$newID'"; |
239 | 255 |
$rs=$db2->getAll($sql,DB_FETCHMODE_ASSOC); |
240 | 256 |
if ($data["Firma"]) { $set.="set name='".$data["Firma"]."',contact='".$data["Vorname"]." ".$data["Nachname"]."',"; } |
... | ... | |
251 | 267 |
$set.="taxincluded='f' "; |
252 | 268 |
$sql="update customer ".$set; |
253 | 269 |
$sql.="where id=".$rs[0]["id"]; |
254 |
$rc=$db2->query($sql); |
|
270 |
$sql=utf8_encode($sql); |
|
271 |
echo $sql."<br>"; |
|
272 |
$rc=query($db2,$sql); |
|
273 |
if (DB::isError($rc)) { |
|
274 |
print_r($rc); echo "<br>"; |
|
275 |
} |
|
255 | 276 |
return $rs[0]["id"]; |
256 | 277 |
} |
257 | 278 |
function checkKunde() { |
... | ... | |
269 | 290 |
$zeile["Kunden_Nr"]=insKdData($zeile); |
270 | 291 |
if ($zeile["Kunden_Nr"]>0) { |
271 | 292 |
$sql="update kunde set Kunden_Nr='".$zeile["Kunden_Nr"]."' where k_ID=".$zeile["k_ID"]; |
272 |
$rc=$db->query($sql);
|
|
293 |
$rc=query($db,$sql);
|
|
273 | 294 |
} else { |
274 | 295 |
$ok=false; break; |
275 | 296 |
} |
Auch abrufbar als: Unified diff
Units, UTF-Trans, Query-Funktion, Buchungsgruppen