2 // $Id: confedit.php,v 1.6 2007/01/07
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";
9 $login=($_GET["login"])?$_GET["login"]:$_POST["login"];
10 if (file_exists ("conf$login.php")) {
11 require "conf$login.php";
15 if ($_SERVER['PHP_AUTH_USER']<>$ERPftpuser || $_SERVER['PHP_AUTH_PW']<>$ERPftppwd) {
16 Header("WWW-Authenticate: Basic realm=\"My Realm\"");
17 Header("HTTP/1.0 401 Unauthorized");
18 echo "Sie müssen sich autentifizieren\n";
21 require_once "DB.php";
22 $db=@DB::connect($ERPdns);
23 if (!DB::isError($db)) {
24 $sql="select id,pricegroup from pricegroup";
25 $pgs=$db->getall($sql);
29 echo "\t<option value=0";
30 if ($sel==0) echo " selected";
31 echo ">Standard VK\n";
32 if ($pgs) foreach ($pgs as $row) {
33 echo "\t<option value=".$row[0];
34 if ($sel==$row[0]) echo " selected";
35 echo ">".$row[1]."\n";
38 if ($_POST["ok"]=="sichern") {
40 if ($_POST["ERPpass"]) {
41 $dsnP="pgsql://".$_POST["ERPuser"].":".$_POST["ERPpass"]."@".$_POST["ERPhost"]."/".$_POST["ERPdbname"];
43 $dsnP="pgsql://".$_POST["ERPuser"]."@".$_POST["ERPhost"]."/".$_POST["ERPdbname"];
45 $dbP=@DB::connect($dsnP);
46 if (DB::isError($dbP)||!$dbP) {
48 echo "Keine Verbindung zur ERP<br>";
49 echo $dbP->userinfo."<br>";
52 $sql ="select BG.id as bugru,T.rate,TK.startdate from buchungsgruppen BG left join chart C ";
53 $sql.="on BG.income_accno_id_0=C.id left join taxkeys TK on TK.chart_id=C.id left join tax T ";
54 $sql.="on T.id=TK.tax_id where TK.startdate <= now()";
55 $rs=$dbP->getAll($sql,DB_FETCHMODE_ASSOC);
57 foreach ($rs as $row) {
58 if ($erptax[$row["bugru"]]["startdate"]<$row["startdate"]) {
59 $erptax[$row["bugru"]]["startdate"]=$row["startdate"];
60 $erptax[$row["bugru"]]["rate"]=sprintf("%1.4f",$row["rate"]*100);
63 $sql ="select P.id,P.description,P.buchungsgruppen_id as bugru from ";
64 $sql.="parts P where P.partnumber = '%s'";
65 $rs=$dbP->getall(sprintf($sql,$_POST["div16NR"]));
66 $_POST["div16ID"]=$rs[0][0];
68 $_POST["div16TAX"]=$erptax[$rs[0][2]]["rate"];
69 $rs=$dbP->getall(sprintf($sql,$_POST["div07NR"]));
70 $_POST["div07ID"]=$rs[0][0];
71 $_POST["div07TAX"]=$erptax[$rs[0][2]]["rate"];
73 $rs=$dbP->getall(sprintf($sql,$_POST["versandNR"]));
74 $_POST["versandID"]=$rs[0][0];
75 $_POST["versandTAX"]=$erptax[$rs[0][2]]["rate"];
76 $versandtxt=$rs[0][1];
77 $rs=$dbP->getall(sprintf($sql,$_POST["nachnNR"]));
78 $_POST["nachnID"]=$rs[0][0];
79 $_POST["nachnTAX"]=$erptax[$rs[0][2]]["rate"];
81 $rs=$dbP->getall(sprintf($sql,$_POST["minderNR"]));
82 $_POST["minderID"]=$rs[0][0];
83 $_POST["minderTAX"]=$erptax[$rs[0][2]]["rate"];
85 $rs=$dbP->getall(sprintf($sql,$_POST["paypalNR"]));
86 $_POST["paypalID"]=$rs[0][0];
87 $_POST["paypalTAX"]=$erptax[$rs[0][2]]["rate"];
89 $rs=$dbP->getall(sprintf($sql,$_POST["treuhNR"]));
90 $_POST["treuhID"]=$rs[0][0];
91 $_POST["treuhTAX"]=$erptax[$rs[0][2]]["rate"];
93 $rs=$dbP->getall("select id from employee where login = '".$_POST["ERPusrN"]."'");
94 $_POST["ERPusrID"]=$rs[0][0];
96 if ($_POST["SHOPpass"]) {
97 $dsnM="mysql://".$_POST["SHOPuser"].":".$_POST["SHOPpass"]."@".$_POST["SHOPhost"]."/".$_POST["SHOPdbname"];
99 $dsnM="mysql://".$_POST["SHOPuser"]."@".$_POST["SHOPhost"]."/".$_POST["SHOPdbname"];
101 $dbM=@DB::connect($dsnM);
102 if (DB::isError($dbM)||!$dbM) {
104 echo "Keine Verbindung zum Shop<br>";
105 echo $dbM->userinfo."<br>";
108 $f=fopen("conf$login.php","w");
110 $d=date("Y/m/d H:i:s");
111 fputs($f,"<?\n// Verbindung zur ERP-db\n");
112 fputs($f,"\$ERPuser=\"".$_POST["ERPuser"]."\";\n");
113 fputs($f,"\$ERPpass=\"".$_POST["ERPpass"]."\";\n");
114 fputs($f,"\$ERPhost=\"".$_POST["ERPhost"]."\";\n");
115 fputs($f,"\$ERPdbname=\"".$_POST["ERPdbname"]."\";\n");
116 fputs($f,"\$ERPdns=\"pgsql://\$ERPuser:\$ERPpass@\$ERPhost/\$ERPdbname\";\n");
117 fputs($f,"\$ERPusr[\"Name\"]=\"".$_POST["ERPusrN"]."\";\n");
118 fputs($f,"\$ERPusr[\"ID\"]=\"".$_POST["ERPusrID"]."\";\n");
119 fputs($f,"\$ERPdir=\"".$_POST["ERPdir"]."\";\n");
120 fputs($f,"\$ERPimgdir=\"".$_POST["ERPimgdir"]."\";\n");
121 fputs($f,"\$maxSize=\"".$_POST["maxSize"]."\";\n");
122 fputs($f,"\$ERPftphost=\"".$_POST["ERPftphost"]."\";\n");
123 fputs($f,"\$ERPftpuser=\"".$_POST["ERPftpuser"]."\";\n");
124 fputs($f,"\$ERPftppwd=\"".$_POST["ERPftppwd"]."\";\n");
125 fputs($f,"//Verbindung zur osCommerce-db\n");
126 fputs($f,"\$SHOPuser=\"".$_POST["SHOPuser"]."\";\n");
127 fputs($f,"\$SHOPpass=\"".$_POST["SHOPpass"]."\";\n");
128 fputs($f,"\$SHOPhost=\"".$_POST["SHOPhost"]."\";\n");
129 fputs($f,"\$SHOPdbname=\"".$_POST["SHOPdbname"]."\";\n");
130 fputs($f,"\$SHOPlang=\"".$_POST["SHOPlang"]."\";\n");
131 fputs($f,"\$SHOPdns=\"mysql://\$SHOPuser:\$SHOPpass@\$SHOPhost/\$SHOPdbname\";\n");
132 fputs($f,"\$SHOPdir=\"".$_POST["SHOPdir"]."\";\n");
133 fputs($f,"\$SHOPimgdir=\"".$_POST["SHOPimgdir"]."\";\n");
134 fputs($f,"\$SHOPftphost=\"".$_POST["SHOPftphost"]."\";\n");
135 fputs($f,"\$SHOPftpuser=\"".$_POST["SHOPftpuser"]."\";\n");
136 fputs($f,"\$SHOPftppwd=\"".$_POST["SHOPftppwd"]."\";\n");
137 fputs($f,"\$div16[\"ID\"]=\"".$_POST["div16ID"]."\";\n");
138 fputs($f,"\$div07[\"ID\"]=\"".$_POST["div07ID"]."\";\n");
139 fputs($f,"\$versand[\"ID\"]=\"".$_POST["versandID"]."\";\n");
140 fputs($f,"\$nachn[\"ID\"]=\"".$_POST["nachnID"]."\";\n");
141 fputs($f,"\$minder[\"ID\"]=\"".$_POST["minderID"]."\";\n");
142 fputs($f,"\$treuh[\"ID\"]=\"".$_POST["treuhID"]."\";\n");
143 fputs($f,"\$paypal[\"ID\"]=\"".$_POST["paypalID"]."\";\n");
144 fputs($f,"\$div16[\"NR\"]=\"".$_POST["div16NR"]."\";\n");
145 fputs($f,"\$div07[\"NR\"]=\"".$_POST["div07NR"]."\";\n");
146 fputs($f,"\$versand[\"NR\"]=\"".$_POST["versandNR"]."\";\n");
147 fputs($f,"\$nachn[\"NR\"]=\"".$_POST["nachnNR"]."\";\n");
148 fputs($f,"\$minder[\"NR\"]=\"".$_POST["minderNR"]."\";\n");
149 fputs($f,"\$treuh[\"NR\"]=\"".$_POST["treuhNR"]."\";\n");
150 fputs($f,"\$paypal[\"NR\"]=\"".$_POST["paypalNR"]."\";\n");
151 fputs($f,"\$div16[\"TAX\"]=\"".$_POST["div16TAX"]."\";\n");
152 fputs($f,"\$div07[\"TAX\"]=\"".$_POST["div07TAX"]."\";\n");
153 fputs($f,"\$versand[\"TAX\"]=\"".$_POST["versandTAX"]."\";\n");
154 fputs($f,"\$nachn[\"TAX\"]=\"".$_POST["nachnTAX"]."\";\n");
155 fputs($f,"\$minder[\"TAX\"]=\"".$_POST["minderTAX"]."\";\n");
156 fputs($f,"\$treuh[\"TAX\"]=\"".$_POST["treuhTAX"]."\";\n");
157 fputs($f,"\$paypal[\"TAX\"]=\"".$_POST["paypalTAX"]."\";\n");
158 fputs($f,"\$div16[\"TXT\"]=\"".$div16txt."\";\n");
159 fputs($f,"\$div07[\"TXT\"]=\"".$div07txt."\";\n");
160 fputs($f,"\$versand[\"TXT\"]=\"".$versandtxt."\";\n");
161 fputs($f,"\$nachn[\"TXT\"]=\"".$nachntxt."\";\n");
162 fputs($f,"\$minder[\"TXT\"]=\"".$mindertxt."\";\n");
163 fputs($f,"\$treuh[\"TXT\"]=\"".$treuhtxt."\";\n");
164 fputs($f,"\$paypal[\"TXT\"]=\"".$paypaltxt."\";\n");
165 fputs($f,"\$pricegroup=\"".$_POST["pricegroup"]."\";\n");
166 fputs($f,"\$bgcol[1]=\"#ddddff\";\n");
167 fputs($f,"\$bgcol[2]=\"#ddffdd\";\n");
168 fputs($f,"\$preA=\"".$_POST["preA"]."\";\n");
169 fputs($f,"\$preK=\"".$_POST["preK"]."\";\n");
170 fputs($f,"\$auftrnr=\"".$_POST["auftrnr"]."\";\n");
171 fputs($f,"\$debug=".$_POST["debug"].";\n");
172 fputs($f,"\$kdnum=\"".$_POST["kdnum"]."\";\n");
173 fputs($f,"\$stdprice=\"".$_POST["stdprice"]."\";\n");
174 fputs($f,"\$nopic=\"".$_POST["nopic"]."\";\n");
175 fputs($f,"\$showErr=\"true\";\n");
178 if (file_exists ("conf$login.php")) {
179 require "conf$login.php";
183 $sql="select count(*) from customers_number";
184 $rc=@$dbM->query($sql);
185 if ($rc->code==-18) {
186 $sql="CREATE TABLE customers_number ( cid int(6) NOT NULL auto_increment, customers_id int NOT NULL default '0', ";
187 $sql.="kdnr int NOT NULL default '0', shipto int, PRIMARY KEY (cid)) TYPE=MyISAM";
188 $rc=@$dbM->query($sql);
190 echo "Fehler beim Erzeugen der Tabelle 'customers_number' in der Shop-db";
192 echo "Tabelle 'customers_number' in der Shop-db angelegt.";
195 $sql="select shipto from customers_number limit 1";
196 $rc=@$dbM->query($sql);
197 if ($rc->code==-19) {
198 $sql="alter table customers_number add column shipto int";
199 $rc=@$dbM->query($sql);
201 echo "Fehler beim Anlegen der Spalte 'shipto' in 'customers_number'";
203 echo "'shipto' in 'customers_number' angelegt.";
208 $ERPuser=$_POST["ERPuser"];
209 $ERPpass=$_POST["ERPpass"];
210 $ERPhost=$_POST["ERPhost"];
211 $ERPdbname=$_POST["ERPdbname"];
212 $ERPusrN=$_POST["ERPusrN"];
213 $ERPdir=$_POST["ERPdir"];
214 $ERPimgdir=$_POST["ERPimgdir"];
215 $maxSize=$_POST["maxSize"];
216 $ERPftphost=$_POST["ERPftphost"];
217 $ERPftpuser=$_POST["ERPftpuser"];
218 $ERPftppwd=$_POST["ERPftppwd"];
219 $SHOPuser=$_POST["SHOPuser"];
220 $SHOPpass=$_POST["SHOPpass"];
221 $SHOPhost=$_POST["SHOPhost"];
222 $SHOPdbname=$_POST["SHOPdbname"];
223 $SHOPlang=$_POST["SHOPlang"];
224 $SHOPdir=$_POST["SHOPdir"];
225 $SHOPimgdir=$_POST["SHOPimgdir"];
226 $SHOPftphost=$_POST["SHOPftphost"];
227 $SHOPftpuser=$_POST["SHOPftpuser"];
228 $SHOPftppwd=$_POST["SHOPftppwd"];
229 $div16NR=$_POST["div16NR"];
230 $div07NR=$_POST["div07NR"];
231 $versandNR=$_POST["versandNR"];
232 $nachnNR=$_POST["nachnNR"];
233 $treuhNR=$_POST["treuhNR"];
234 $minderNR=$_POST["minderNR"];
235 $paypalNR=$_POST["paypalNR"];
236 $pricegroup=$_POST["pricegroup"];
237 $preA=$_POST["preA"];
238 $preK=$_POST["preK"];
239 $kdnum=$_POST["kdnum"];
240 $auftrnr=$_POST["auftrnr"];
241 $debug=$_POST["debug"];
242 $stdprice=$_POST["stdprice"];
243 $nopic=$_POST["nopic"];
246 if (file_exists ("conf$login.php")) {
247 require "conf$login.php";
256 <table style="background-color:#cccccc">
257 <form name="ConfEdit" method="post" action="confedit.php">
258 <input type="hidden" name="div16ID" value="<?= $div16["ID"] ?>">
259 <input type="hidden" name="div07ID" value="<?= $div07["ID"] ?>">
260 <input type="hidden" name="minderID" value="<?= $minder["ID"] ?>">
261 <input type="hidden" name="versandID" value="<?= $versand["ID"] ?>">
262 <input type="hidden" name="nachnID" value="<?= $nachn["ID"] ?>">
263 <input type="hidden" name="paypalID" value="<?= $paypal["ID"] ?>">
264 <input type="hidden" name="treuhID" value="<?= $treuh["ID"] ?>">
265 <input type="hidden" name="ERPusrID" value="<?= $ERPusr["ID"] ?>">
266 <input type="hidden" name="login" value="<?= $login ?>">
267 <tr><th>Daten</th><th>Lx-ERP</th><th></th><th>Shop</th></tr>
270 <td colspan="2"><input type="text" name="ERPhost" size="25" value="<?= $ERPhost ?>"></td>
271 <td><input type="text" name="SHOPhost" size="25" value="<?= $SHOPhost ?>"></td>
275 <td colspan="2"><input type="text" name="ERPdbname" size="20" value="<?= $ERPdbname ?>"></td>
276 <td><input type="text" name="SHOPdbname" size="20" value="<?= $SHOPdbname ?>"></td>
279 <td>db-User Name</td>
280 <td colspan="2"><input type="text" name="ERPuser" size="15" value="<?= $ERPuser ?>"></td>
281 <td><input type="text" name="SHOPuser" size="15" value="<?= $SHOPuser ?>"></td>
285 <td colspan="2"><input type="text" name="ERPpass" size="15" value="<?= $ERPpass ?>"></td>
286 <td><input type="text" name="SHOPpass" size="15" value="<?= $SHOPpass ?>"></td>
290 <td colspan="2"><input type="text" name="ERPusrN" size="10" value="<?= $ERPusr["Name"] ?>">
291 <input type="checkbox" name="a1" <?= (empty($ERPusr["ID"])?"":"checked") ?> onFocus="blur();"></td>
296 <td colspan="2"><input type="text" name="ERPdir" size="30" value="<?= $ERPdir ?>"></td>
297 <td><input type="text" name="SHOPdir" size="30" value="<?= $SHOPdir ?>"></td>
301 <td colspan="2"><input type="text" name="ERPimgdir" size="30" value="<?= $ERPimgdir ?>"></td>
302 <td><input type="text" name="SHOPimgdir" size="30" value="<?= $SHOPimgdir ?>"></td>
306 <td colspan="2"><input type="text" name="ERPftphost" size="20" value="<?= $ERPftphost ?>"></td>
307 <td><input type="text" name="SHOPftphost" size="20" value="<?= $SHOPftphost ?>"></td>
311 <td colspan="2"><input type="text" name="ERPftpuser" size="15" value="<?= $ERPftpuser ?>"></td>
312 <td><input type="text" name="SHOPftpuser" size="15" value="<?= $SHOPftpuser ?>"></td>
315 <td>FTP-User PWD</td>
316 <td colspan="2"><input type="text" name="ERPftppwd" size="15" value="<?= $ERPftppwd ?>"></td>
317 <td><input type="text" name="SHOPftppwd" size="15" value="<?= $SHOPftppwd ?>"></td>
320 <td>ID Diverse 19%</td>
321 <td><input type="text" name="div16NR" size="10" value="<?= $div16["NR"] ?>">
322 <input type="checkbox" name="a1" <?= (empty($div16["ID"])?"":"checked") ?>></td>
323 <td>ID Diverse 7%</td>
324 <td><input type="text" name="div07NR" size="10" value="<?= $div07["NR"] ?>">
325 <input type="checkbox" name="a1" <?= (empty($div07["ID"])?"":"checked") ?>></td>
329 <td><input type="text" name="versandNR" size="10" value="<?= $versand["NR"] ?>">
330 <input type="checkbox" name="a1" <?= (empty($versand["ID"])?"":"checked") ?>></td>
332 <td><input type="text" name="nachnNR" size="10" value="<?= $nachn["NR"] ?>">
333 <input type="checkbox" name="a1" <?= (empty($nachn["ID"])?"":"checked") ?>></td>
337 <td><input type="text" name="paypalNR" size="10" value="<?= $paypal["NR"] ?>">
338 <input type="checkbox" name="a1" <?= (empty($paypal["ID"])?"":"checked") ?>></td>
340 <td><input type="text" name="treuhNR" size="10" value="<?= $treuh["NR"] ?>">
341 <input type="checkbox" name="a1" <?= (empty($treuh["ID"])?"":"checked") ?>></td>
344 <td>ID Mindemenge</td>
345 <td><input type="text" name="minderNR" size="10" value="<?= $minder["NR"] ?>">
346 <input type="checkbox" name="a1" <?= (empty($minder["ID"])?"":"checked") ?>></td>
351 <td colspan="2">Abweichende Shopsprache</td>
352 <td colspan="2"><input type="text" name="SHOPlang" size="5" value="<?= $SHOPlang ?>"> leer = Default</td>
356 <td><select name="pricegroup">
357 <? pg($pricegroup); ?>
360 <td><input type="text" name="nopic" size="20" value="<?= $nopic ?>">
363 <td colspan="2">Auftragsnummern durch</td>
364 <td><input type="radio" name="auftrnr" value="1" <?= ($auftrnr==1)?"checked":"" ?>> LxO</td>
365 <td><input type="radio" name="auftrnr" value="0" <?= ($auftrnr<>1)?"checked":"" ?>> Shop</td>
368 <td colspan="2">Kundennummern durch</td>
369 <td><input type="radio" name="kdnum" value="1" <?= ($kdnum==1)?"checked":"" ?>> LxO</td>
370 <td><input type="radio" name="kdnum" value="0" <?= ($kdnum<>1)?"checked":"" ?>> Shop</td>
373 <td colspan="2">Nummernerweiterung</td>
374 <td>Auftrag<input type="text" name="preA" size="5" value="<?= $preA ?>"></td>
375 <td>Kunde<input type="text" name="preK" size="5" value="<?= $preK ?>"></td>
379 <td>ein<input type="radio" name="debug" value="true" <?= ($debug=="true")?"checked":"" ?>>
380 aus<input type="radio" name="debug" value="false" <?= ($debug!="true")?"checked":"" ?>></td>
383 <tr><td colspan="4" align="center"><input type="submit" name="ok" value="sichern"></td></tr>