2 // $Id: confedit.php 2009/02/10 14:41:30 hli Exp $
3 if (!isset($_SERVER['PHP_AUTH_USER'])) {
4 Header("WWW-Authenticate: Basic realm='Configurations-Editor'");
5 Header("HTTP/1.0 401 Unauthorized");
6 echo "Sie müssen sich autentifizieren\n";
10 //Je Shop ein Conf-File == Multishop
12 if ($Shop != "" and file_exists ("conf$Shop.php")) {
13 require "conf$Shop.php";
14 $out = "Konfiguration für Shop $Shop gelesen";
16 //Singleshop oder noch kein Shop definiert
18 $out = "Standard-Konfiguration gelesen";
20 if ($_SERVER['PHP_AUTH_USER']<>$ERPftpuser || $_SERVER['PHP_AUTH_PW']<>$ERPftppwd) {
21 Header("WWW-Authenticate: Basic realm='My Realm'");
22 Header("HTTP/1.0 401 Unauthorized");
23 echo "Sie müssen sich autentifizieren\n";
31 include_once("error.php");
32 include_once("dblib.php");
33 $api = php_sapi_name();
34 if ( $api == 'cli' ) {
35 echo "Nur im Browser benutzen\n";
38 $err = new error($api);
40 $zeichen = array("","UTF-8","ISO-8859-1","ISO-8859-15","Windows-1252","ASCII");
41 function lager($sel,$db) {
43 $sql = "select w.description as lager,b.description as platz,b.id from ";
44 $sql .= "bin b left join warehouse w on w.id=b.warehouse_id ";
45 $sql .= "order by b.warehouse_id,b.id";
46 $bin=$db->getall($sql);
47 echo "\t<option value=-1 ".(($sel==-1)?'selected':'').">kein Lagerbestand\n";
48 echo "\t<option value=1 ".(($sel==1)?'selected':'').">Gesamtbestand\n";
49 if ($bin) foreach ($bin as $row) {
50 echo "\t<option value=".$row['id'];
51 if ($sel==$row['id']) echo " selected";
52 echo ">".$row['lager']." ".$row['platz']."\n";
55 function unit($sel,$db) {
57 $sql="select name from units order by sortkey";
58 $pgs=$db->getall($sql);
59 if ($sel=='') $sel=$pgs[0]['name'];
60 if ($pgs) foreach ($pgs as $row) {
61 echo "\t<option value=".$row['name'];
62 if ($sel==$row['name']) echo " selected";
63 echo ">".$row['name']."\n";
66 function pg($sel,$db) {
68 $sql="select id,pricegroup from pricegroup";
69 $pgs=$db->getall($sql);
70 echo "\t<option value=0";
71 if ($sel==0) echo " selected";
72 echo ">Standard VK\n";
73 if ($pgs) foreach ($pgs as $row) {
74 echo "\t<option value=".$row['id'];
75 if ($sel==$row['id']) echo " selected";
76 echo ">".$row['pricegroup']."\n";
79 function getTax($db) {
80 $sql = "SELECT BG.id AS bugru,T.rate,TK.startdate,C.taxkey_id, ";
81 $sql .= "(SELECT id FROM chart WHERE accno = T.taxnumber) AS tax_id, ";
82 $sql .= "BG.income_accno_id_0,BG.expense_accno_id_0 ";
83 $sql .= "FROM buchungsgruppen BG LEFT JOIN chart C ON BG.income_accno_id_0=C.id ";
84 $sql .= "LEFT JOIN taxkeys TK ON TK.chart_id=C.id ";
85 $sql .= "LEFT JOIN tax T ON T.id=TK.tax_id WHERE TK.startdate <= now()";
86 $rs = $db->getAll($sql);
87 if ($rs) foreach ($rs as $row) {
91 $data['startdate'] = $row['startdate'];
92 $data['rate'] = $row['rate']*100.0;
94 } else if ($TAX[$nr]['startdate'] < $row['startdate']) {
95 $TAX[$nr]["startdate"] = $row['startdate'];
96 $TAX[$nr]["rate"] = $row['rate']*100.0;
101 function fputsA($f,$key,$var,$bg=false) {
103 fputs($f,'$'.$key.'["ID"]=\''. $var['ID'].'\';'.$lf);
104 fputs($f,'$'.$key.'["NR"]=\''. $var['NR'].'\';'.$lf);
105 fputs($f,'$'.$key.'["Unit"]=\''. $var['Unit'].'\';'.$lf);
106 fputs($f,'$'.$key.'["TXT"]=\''. $var['TXT'].'\';'.$lf);
107 if ($bg) fputs($f,'$'.$key.'["BUGRU"]=\''. $var['BUGRU'].'\';'.$lf);
108 if ($bg) fputs($f,'$'.$key.'["TAX"]=\''. $var['TAX'].'\';'.$lf);
110 if ($_POST["ok"]=="sichern") {
111 foreach ($_POST as $key=>$val) {
116 $dbP = new mydb($ERPhost,$ERPdbname,$ERPuser,$ERPpass,$ERPport,'pgsql',$err,$debug);
119 echo "Keine Verbindung zur ERP<br>";
121 unset($divStd['ID']);
122 unset($divVerm['ID']);
123 unset($minder['ID']);
124 unset($versand['ID']);
126 unset($paypal['ID']);
127 unset($ERPusr['ID']);
130 $sql="SELECT id,description,unit,buchungsgruppen_id FROM parts where partnumber = '%s'";
131 $rs=$dbP->getOne(sprintf($sql,$divStd['NR']));
132 $divStd['ID']=$rs['id'];
133 $divStd['Unit']=$rs['unit'];
134 $divStd['BUGRU']=$rs['buchungsgruppen_id'];
135 $divStd['TAX']=$tax[$rs['buchungsgruppen_id']]['rate'];
136 $divStd['TXT']=addslashes($rs['description']);
137 $rs=$dbP->getOne(sprintf($sql,$divVerm['NR']));
138 $divVerm['ID']=$rs['id'];
139 $divVerm['Unit']=$rs['unit'];
140 $divVerm['BUGRU']=$rs['buchungsgruppen_id'];
141 $divVerm['TAX']=$tax[$rs['buchungsgruppen_id']]['rate'];
142 $divVerm['TXT']=addslashes($rs['description']);
143 $rs=$dbP->getOne(sprintf($sql,$versandS['NR']));
144 $versandS['ID']=$rs['id'];
145 $versandS['Unit']=$rs['unit'];
146 $versandS['BUGRU']=$rs['buchungsgruppen_id'];
147 $versandS['TAX']=$tax[$rs['buchungsgruppen_id']]['rate'];
148 if ($versandS['TXT'] == '') $versandS['TXT']=addslashes($rs['description']);
149 $rs=$dbP->getOne(sprintf($sql,$versandV['NR']));
150 $versandV['ID']=$rs['id'];
151 $versandV['Unit']=$rs['unit'];
152 $versandV['BUGRU']=$rs['buchungsgruppen_id'];
153 $versandV['TAX']=$tax[$rs['buchungsgruppen_id']]['rate'];
154 if ($versandV['TXT'] == '') $versandV['TXT']=addslashes($rs['description']);
155 $rs=$dbP->getOne(sprintf($sql,$nachn['NR']));
156 $nachn['ID']=$rs['id'];
157 $nachn['Unit']=$rs['unit'];
158 $nachn['BUGRU']=$rs['buchungsgruppen_id'];
159 $nachn['TAX']=$tax[$rs['buchungsgruppen_id']]['rate'];
160 if ($nachn['TXT'] == '') $nachn['TXT']=addslashes($rs['description']);
161 $rs=$dbP->getOne(sprintf($sql,$minder['NR']));
162 $minder['ID']=$rs['id'];
163 $minder['Unit']=$rs['unit'];
164 $minder['BUGRU']=$rs['buchungsgruppen_id'];
165 $minder['TAX']=$tax[$rs['buchungsgruppen_id']]['rate'];
166 if ($minder['TXT'] == '') $minder['TXT']=addslashes($rs['description']);
167 $rs=$dbP->getOne(sprintf($sql,$paypal['NR']));
168 $paypal['ID']=$rs['id'];
169 $paypal['Unit']=$rs['unit'];
170 $paypal['BUGRU']=$rs['buchungsgruppen_id'];
171 $paypal['TAX']=$tax[$rs['buchungsgruppen_id']]['rate'];
172 if ($paypal['TXT'] == '') $paypal['TXT']=addslashes($rs['description']);
173 $rs=$dbP->getOne("select id from employee where login = '".$ERPusrName."'");
176 $dbM = new mydb($SHOPhost,$SHOPdbname,$SHOPuser,$SHOPpass,$SHOPport,'mysql',$err,$debug);
179 echo "Keine Verbindung zum Shop<br>";
182 if ($_POST["ok"]=="sichern") {
184 $f=@fopen("conf$Shop.php","w");
187 $d=date("Y/m/d H:i:s");
188 fputs($f,"<?php$lf// Verbindung zur ERP-db$lf");
189 fputs($f,'$ERPuser=\''.$ERPuser.'\';'.$lf);
190 fputs($f,'$ERPpass=\''.$ERPpass.'\';'.$lf);
191 fputs($f,'$ERPhost=\''.$ERPhost.'\';'.$lf);
192 fputs($f,'$ERPport=\''.$ERPport.'\';'.$lf);
193 fputs($f,'$ERPdbname=\''.$ERPdbname.'\';'.$lf);
194 fputs($f,'$codeLX=\''.$codeLX.'\';'.$lf);
195 fputs($f,'$mwstLX=\''.$mwstLX.'\';'.$lf);
196 fputs($f,'$ERPusrName=\''.$ERPusrName.'\';'.$lf);
197 fputs($f,'$ERPusrID=\''.$ERPusrID.'\';'.$lf);
198 fputs($f,'$ERPimgdir=\''.$ERPimgdir.'\';'.$lf);
199 fputs($f,'$maxSize=\''.$maxSize.'\';'.$lf);
200 fputs($f,'$ERPftphost=\''.$ERPftphost.'\';'.$lf);
201 fputs($f,'$ERPftpuser=\''.$ERPftpuser.'\';'.$lf);
202 fputs($f,'$ERPftppwd=\''.$ERPftppwd.'\';'.$lf);
203 fputs($f,'//Verbindung zur osCommerce-db'.$lf);
204 fputs($f,'$SHOPuser=\''.$SHOPuser.'\';'.$lf);
205 fputs($f,'$SHOPpass=\''.$SHOPpass.'\';'.$lf);
206 fputs($f,'$SHOPhost=\''.$SHOPhost.'\';'.$lf);
207 fputs($f,'$SHOPport=\''.$SHOPport.'\';'.$lf);
208 fputs($f,'$SHOPdbname=\''.$SHOPdbname.'\';'.$lf);
209 fputs($f,'$codeS=\''.$codeS.'\';'.$lf);
210 fputs($f,'$mwstS=\''.$mwstS.'\';'.$lf);
211 fputs($f,'$SHOPimgdir=\''.$SHOPimgdir.'\';'.$lf);
212 fputs($f,'$SHOPftphost=\''.$SHOPftphost.'\';'.$lf);
213 fputs($f,'$SHOPftpuser=\''.$SHOPftpuser.'\';'.$lf);
214 fputs($f,'$SHOPftppwd=\''.$SHOPftppwd.'\';'.$lf);
215 fputs($f,'$nopic=\''.$nopic.'\';'.$lf);
216 fputs($f,'$nopicerr=\''.$nopicerr.'\';'.$lf);
217 fputs($f,'$nofiles=\''.$nofiles.'\';'.$lf);
218 fputsA($f,'divStd',$divStd,true);
219 fputsA($f,'divVerm',$divVerm,true);
220 fputsA($f,'versandS',$versandS,true);
221 fputsA($f,'versandV',$versandV,true);
222 fputsA($f,'minder',$minder,true);
223 fputsA($f,'nachn',$nachn,true);
224 fputsA($f,'paypal',$paypal,true);
225 fputs($f,'$bgcol[1]=\'#ddddff\';'.$lf);
226 fputs($f,'$bgcol[2]=\'#ddffdd\';'.$lf);
227 fputs($f,'$preA=\''.$preA.'\';'.$lf);
228 fputs($f,'$preK=\''.$preK.'\';'.$lf);
229 fputs($f,'$auftrnr=\''.$auftrnr.'\';'.$lf);
230 //fputs($f,'$utftrans=\''.$utftrans.'\';'.$lf);
231 fputs($f,'$kdnum=\''.$kdnum.'\';'.$lf);
232 fputs($f,'$pricegroup=\''.$pricegroup.'\';'.$lf);
233 fputs($f,'$unit=\''.$unit.'\';'.$lf);
234 fputs($f,'$longtxt=\''.$longtxt.'\';'.$lf);
235 fputs($f,'$invbrne=\''.$invbrne.'\';'.$lf);
236 fputs($f,'$variantnr=\''.$variantnr.'\';'.$lf);
237 fputs($f,'$OEinsPart=\''.$OEinsPart.'\';'.$lf);
238 fputs($f,'$lager=\''.$lager.'\';'.$lf);
239 //fputs($f,'$showErr=true;'.$lf);
242 echo "Konfiguration conf$Shop.php gesichert.";
244 echo "Konfigurationsdatei (conf$Shop.php) konnte nicht geschrieben werden";
251 <table style="background-color:#cccccc" border="0">
252 <form name="ConfEdit" method="post" action="confedit.php">
253 <input type="hidden" name="Shop" value="<?= $Shop ?>">
254 <input type="hidden" name="divStd[ID]" value="<?= $divStd['ID'] ?>">
255 <input type="hidden" name="divVerm[ID]" value="<?= $divVerm['ID'] ?>">
256 <input type="hidden" name="minder[ID]" value="<?= $minder['ID'] ?>">
257 <input type="hidden" name="versandS[ID]" value="<?= $versandS['ID'] ?>">
258 <input type="hidden" name="versandV[ID]" value="<?= $versandV['ID'] ?>">
259 <input type="hidden" name="nachn[ID]" value="<?= $nachn['ID'] ?>">
260 <input type="hidden" name="paypal[ID]" value="<?= $paypal['ID'] ?>">
261 <input type="hidden" name="ERPusr[ID]" value="<?= $ERPusr['ID'] ?>">
263 <tr><th>Daten</th><th>Lx-ERP</th><th><?php echo $Shop ?></th><th>Shop</th></tr>
266 <td colspan="2"><input type="text" name="ERPhost" size="25" value="<?= $ERPhost ?>"></td>
267 <td><input type="text" name="SHOPhost" size="25" value="<?= $SHOPhost ?>"></td>
271 <td colspan="2"><input type="text" name="ERPdbname" size="20" value="<?= $ERPdbname ?>"></td>
272 <td><input type="text" name="SHOPdbname" size="20" value="<?= $SHOPdbname ?>"></td>
276 <td colspan="2"><input type="text" name="ERPport" size="25" value="<?= $ERPport ?>"></td>
277 <td><input type="text" name="SHOPport" size="25" value="<?= $SHOPport ?>"></td>
280 <td>db-User Name</td>
281 <td colspan="2"><input type="text" name="ERPuser" size="15" value="<?= $ERPuser ?>"></td>
282 <td><input type="text" name="SHOPuser" size="15" value="<?= $SHOPuser ?>"></td>
286 <td colspan="2"><input type="text" name="ERPpass" size="15" value="<?= $ERPpass ?>"></td>
287 <td><input type="text" name="SHOPpass" size="15" value="<?= $SHOPpass ?>"></td>
291 <td colspan="2"><select name="codeLX">
292 <?php foreach($zeichen as $code) {
293 echo "<option value='".$code."'";
294 if ($code == $codeLX) echo " selected";
295 echo ">".$code."\n"; };
298 <td ><select name="codeS">
299 <?php foreach($zeichen as $code) {
300 echo "<option value='".$code."'";
301 if ($code == $codeS) echo " selected";
302 echo ">".$code."\n"; };
308 <td colspan="2"> <input type="radio" name="mwstLX" value="1" <?= ($mwstLX==1)?"checked":'' ?>> incl.
309 <input type="radio" name="mwstLX" value="0" <?= ($mwstLX<>1)?"checked":'' ?>> excl. MwSt</td>
310 <td><input type="radio" name="mwstS" value="1" <?= ($mwstS==1)?"checked":'' ?>> incl.
311 <input type="radio" name="mwstS" value="0" <?= ($mwstS<>1)?"checked":'' ?>> excl. MwSt</td>
315 <td colspan="2"><input type="text" name="ERPusrName" size="10" value="<?= $ERPusrName ?>">
316 <input type="checkbox" name="a1" <?= (empty($ERPusrID)?'':"checked") ?>></td>
321 <td colspan="2"><input type="text" name="ERPimgdir" size="30" value="<?= $ERPimgdir ?>"></td>
322 <td><input type="text" name="SHOPimgdir" size="30" value="<?= $SHOPimgdir ?>"></td>
325 <td>Platzhalterbild</td>
326 <td colspan="2"><input type="text" name="nopic" size="20" value="<?php echo $nopic; ?>"></td>
327 <td colspan="2"><input type="checkbox" value="1" name="nopicerr" <?= (empty($nopicerr)?'':"checked") ?>>nur bei fehlerhaftem Upload verwenden</td>
331 <td colspan="2"><input type="checkbox" value="1" name="nofiles" <?= (empty($nofiles)?'':"checked") ?>>nur bei neuen Artikeln</td>
332 <td colspan="2"></td>
336 <td colspan="2"><input type="text" name="ERPftphost" size="20" value="<?= $ERPftphost ?>"></td>
337 <td><input type="text" name="SHOPftphost" size="20" value="<?= $SHOPftphost ?>"></td>
341 <td colspan="2"><input type="text" name="ERPftpuser" size="15" value="<?= $ERPftpuser ?>"></td>
342 <td><input type="text" name="SHOPftpuser" size="15" value="<?= $SHOPftpuser ?>"></td>
345 <td>FTP-User PWD</td>
346 <td colspan="2"><input type="text" name="ERPftppwd" size="15" value="<?= $ERPftppwd ?>"></td>
347 <td><input type="text" name="SHOPftppwd" size="15" value="<?= $SHOPftppwd ?>"></td>
350 <td>Nr Diverse Std-MwSt</td>
351 <td><input type="text" name="divStd[NR]" size="10" value="<?= $divStd['NR'] ?>">
352 <input type="checkbox" name="a1" <?= (empty($divStd['ID'])?'':"checked") ?>></td>
353 <td>Nr Diverse Verm-MwSt</td>
354 <td><input type="text" name="divVerm[NR]" size="10" value="<?= $divVerm['NR'] ?>">
355 <input type="checkbox" name="a1" <?= (empty($divVerm['ID'])?'':"checked") ?>></td>
358 <td>Nr Versand Std-MwSt</td>
359 <td><input type="text" name="versandS[NR]" size="10" value="<?= $versandS['NR'] ?>">
360 <input type="checkbox" name="a1" <?= (empty($versandS['ID'])?'':"checked") ?>></td>
362 <td><input type="text" name="versandS[TXT]" size="20" value="<?= $versandS['TXT'] ?>"><?= $versandS['TAX'] ?></td>
364 <td>Nr Versand Verm-MwSt</td>
365 <td><input type="text" name="versandV[NR]" size="10" value="<?= $versandV['NR'] ?>">
366 <input type="checkbox" name="a1" <?= (empty($versandV['ID'])?'':"checked") ?>></td>
368 <td><input type="text" name="versandV[TXT]" size="20" value="<?= $versandV['TXT'] ?>"><?= $versandV['TAX'] ?></td>
372 <td><input type="text" name="paypal[NR]" size="10" value="<?= $paypal['NR'] ?>">
373 <input type="checkbox" name="a1" <?= (empty($paypal['ID'])?'':"checked") ?>></td>
375 <td><input type="text" name="paypal[TXT]" size="20" value="<?= $paypal['TXT'] ?>"></td>
378 <td>Nr Mindermenge</td>
379 <td><input type="text" name="minder[NR]" size="10" value="<?= $minder['NR'] ?>">
380 <input type="checkbox" name="a1" <?= (empty($minder['ID'])?'':"checked") ?>></td>
382 <td><input type="text" name="minder[TXT]" size="20" value="<?= $minder['TXT'] ?>"></td>
386 <td><input type="text" name="nachn[NR]" size="10" value="<?= $nachn['NR'] ?>">
387 <input type="checkbox" name="a1" <?= (empty($nachn['ID'])?'':"checked") ?>></td>
389 <td><input type="text" name="nachn[TXT]" size="20" value="<?= $nachn['TXT'] ?>"></td>
393 <td><select name="unit">
394 <? unit($unit,$dbP); ?>
397 <td><select name="pricegroup">
398 <? pg($pricegroup,$dbP); ?>
401 <td colspan="2">Auftragsnummern durch</td>
402 <td><input type="radio" name="auftrnr" value="1" <?= ($auftrnr==1)?"checked":'' ?>> LxO</td>
403 <td><input type="radio" name="auftrnr" value="0" <?= ($auftrnr<>1)?"checked":'' ?>> Shop</td>
406 <td colspan="2">Kundennummern durch</td>
407 <td><input type="radio" name="kdnum" value="1" <?= ($kdnum==1)?"checked":'' ?>> LxO</td>
408 <td><input type="radio" name="kdnum" value="0" <?= ($kdnum<>1)?"checked":'' ?>> Shop</td>
411 <td colspan="2">Nummernerweiterung</td>
412 <td>Auftrag<input type="text" name="preA" size="5" value="<?= $preA ?>"></td>
413 <td>Kunde<input type="text" name="preK" size="5" value="<?= $preK ?>"></td>
416 <td>Lagerbestand aus</td>
417 <td><select name="lager">
418 <? lager($lager,$dbP); ?>
424 <td colspan="3">Langbeschreibung aus Shop übernehmen</td>
425 <td><input type="radio" name="longtxt" value="1" <?= ($longtxt<>2)?"checked":'' ?>>Ja
426 <input type="radio" name="longtxt" value="2" <?= ($longtxt==2)?"checked":'' ?>>Nein</td>
430 <td colspan="3">LxO-Rechnungen sind Netto</td>
431 <td><input type="radio" name="invbrne" value="1" <?= ($invbrne<>2)?"checked":'' ?>>Ja
432 <input type="radio" name="invbrne" value="2" <?= ($invbrne==2)?"checked":'' ?>>Nein</td>
435 <td >Variantentext</td>
436 <td colspan="3"><input type="radio" name="variantnr" value="1" <?= ($variantnr<>2)?"checked":'' ?>>Artikelbezeichnung anhängen
437 <input type="radio" name="variantnr" value="2" <?= ($variantnr==2)?"checked":'' ?>>Langebeschreibung voranstellen</td>
440 <td colspan="3">Unbekannte Artikel beim Bestellimport anlegen</td>
441 <td><input type="radio" name="OEinsPart" value="1" <?= ($OEinsPart<>2)?"checked":'' ?>>Ja
442 <input type="radio" name="OEinsPart" value="2" <?= ($OEinsPart==2)?"checked":'' ?>>Nein</td>
446 <td>Bildergrösse (byte)</td>
447 <td><input type="text" name="maxSize" size="10" value="<?= $maxSize ?>"></td>
452 <tr><td colspan="4" align="center"><input type="submit" name="ok" value="sichern"></td></tr>