Kleinere Dokumentationsupdates
[kivitendo-erp.git] / pepper / confedit.php
1 <?
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&uuml;ssen sich autentifizieren\n";
7        exit;
8 } else {
9         $login=($_GET["login"])?$_GET["login"]:$_POST["login"];
10         if (file_exists ("conf$login.php")) {
11                 require "conf$login.php";
12         } else {
13                 require "conf.php";
14         }
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&uuml;ssen sich autentifizieren\n";
19                 exit;
20         }
21         require_once "DB.php";
22         function unit($sel) {
23         global $dbP;
24                 $sql="select name from units order by sortkey";
25                 $pgs=$dbP->getall($sql);
26                 if ($sel=='') $sel=$pgs[0][0];
27                 if ($pgs) foreach ($pgs as $row) {
28                         echo "\t<option value=".$row[0];
29                         if ($sel==$row[0]) echo " selected";
30                         echo ">".$row[0]."\n";
31                 }
32         }
33         function pg($sel) {
34         global $dbP;
35                 $sql="select id,pricegroup from pricegroup";
36                 $pgs=$dbP->getall($sql);
37                 echo "\t<option value=0";
38                 if ($sel==0) echo " selected";
39                 echo ">Standard VK\n";
40                 if ($pgs) foreach ($pgs as $row) {
41                         echo "\t<option value=".$row[0];
42                         if ($sel==$row[0]) echo " selected";
43                         echo ">".$row[1]."\n";
44                 }
45         }
46         if ($_POST["ok"]=="sichern") {
47                 $ok=true;
48         $dsnP = array(
49                                 'phptype'  => 'pgsql',
50                                 'username' => $_POST["ERPuser"],
51                                 'password' => $_POST["ERPpass"],
52                                 'hostspec' => $_POST["ERPhost"],
53                                 'database' => $_POST["ERPdbname"],
54                                 'port'     => $_POST["ERPport"]
55         );
56                 $dbP=@DB::connect($dsnP);
57                 if (DB::isError($dbP)||!$dbP) {
58                         $ok=false;
59                         echo "Keine Verbindung zur ERP<br>";
60                         echo $dbP->userinfo;
61                         $dbP=false;             
62                 }
63                 else {
64                         $sql="SELECT id,description,buchungsgruppen_id FROM parts where partnumber = '%s'";
65                         $rs=$dbP->getall(sprintf($sql,$_POST["div16NR"]));
66                         $_POST["div16ID"]=$rs[0][0];
67                         $div16txt=addslashes($rs[0][1]);
68                     $rs=$dbP->getall(sprintf($sql,$_POST["div07NR"]));
69                         $_POST["div07ID"]=$rs[0][0];
70                         $div07txt=addslashes($rs[0][1]);
71                         $rs=$dbP->getall(sprintf($sql,$_POST["versandNR"]));
72                         $_POST["versandID"]=$rs[0][0];
73                         $versandtxt=addslashes($rs[0][1]);
74                         $rs=$dbP->getall(sprintf($sql,$_POST["nachnNR"]));
75                         $_POST["nachnID"]=$rs[0][0];
76                         $nachntxt=addslashes($rs[0][1]);
77                         $rs=$dbP->getall(sprintf($sql,$_POST["minderNR"]));
78                         $_POST["minderID"]=$rs[0][0];
79                         $mindertxt=addslashes($rs[0][1]);
80                         $rs=$dbP->getall(sprintf($sql,$_POST["paypalNR"]));
81                         $_POST["paypalID"]=$rs[0][0];
82                         $paypaltxt=addslashes($rs[0][1]);
83                         $rs=$dbP->getall(sprintf($sql,$_POST["treuhNR"]));
84                         $_POST["treuhID"]=$rs[0][0];
85                         $treuhtxt=addslashes($rs[0][1]);
86                         $rs=$dbP->getall("select id from employee where login = '".$_POST["ERPusrN"]."'");
87                         $_POST["ERPusrID"]=$rs[0][0];
88                 }
89         $dsnM = array(
90                                 'phptype'  => 'mysql',
91                                 'username' => $_POST["SHOPuser"],
92                                 'password' => $_POST["SHOPpass"],
93                                 'hostspec' => $_POST["SHOPhost"],
94                                 'database' => $_POST["SHOPdbname"],
95                                 'port'     => $_POST["SHOPport"]
96         );
97                 $dbM=@DB::connect($dsnM);
98                 if (DB::isError($dbM)||!$dbM) {
99                         //$ok=false;
100                         echo "Keine Verbindung zum Shop<br>";
101                         echo $dbM->userinfo;
102                         $dbM=false;
103                 };              
104                 if (ok) {
105                         $f=fopen("conf$login.php","w");
106                         $v="1.5";
107                         $d=date("Y/m/d H:i:s");
108                         fputs($f,"<?\n// Verbindung zur ERP-db\n");
109                         fputs($f,"\$ERPuser=\"".$_POST["ERPuser"]."\";\n");
110                         fputs($f,"\$ERPpass=\"".$_POST["ERPpass"]."\";\n");
111                         fputs($f,"\$ERPhost=\"".$_POST["ERPhost"]."\";\n");
112                         fputs($f,"\$ERPdbname=\"".$_POST["ERPdbname"]."\";\n");
113                         fputs($f,"\$ERPdns=\"pgsql://\$ERPuser:\$ERPpass@\$ERPhost/\$ERPdbname\";\n");
114                         fputs($f,"\$ERPusr[\"Name\"]=\"".$_POST["ERPusrN"]."\";\n");
115                         fputs($f,"\$ERPusr[\"ID\"]=\"".$_POST["ERPusrID"]."\";\n");
116                         fputs($f,"\$ERPdir=\"".$_POST["ERPdir"]."\";\n");
117                         fputs($f,"\$ERPimgdir=\"".$_POST["ERPimgdir"]."\";\n");
118                         fputs($f,"\$maxSize=\"".$_POST["maxSize"]."\";\n");
119                         fputs($f,"\$ERPftphost=\"".$_POST["ERPftphost"]."\";\n");
120                         fputs($f,"\$ERPftpuser=\"".$_POST["ERPftpuser"]."\";\n");
121                         fputs($f,"\$ERPftppwd=\"".$_POST["ERPftppwd"]."\";\n");
122                         fputs($f,"//Verbindung zur osCommerce-db\n");
123                         fputs($f,"\$SHOPuser=\"".$_POST["SHOPuser"]."\";\n");
124                         fputs($f,"\$SHOPpass=\"".$_POST["SHOPpass"]."\";\n");
125                         fputs($f,"\$SHOPhost=\"".$_POST["SHOPhost"]."\";\n");
126                         fputs($f,"\$SHOPdbname=\"".$_POST["SHOPdbname"]."\";\n");
127                         fputs($f,"\$SHOPdns=\"mysql://\$SHOPuser:\$SHOPpass@\$SHOPhost/\$SHOPdbname\";\n");
128                         fputs($f,"\$SHOPdir=\"".$_POST["SHOPdir"]."\";\n");
129                         fputs($f,"\$SHOPimgdir=\"".$_POST["SHOPimgdir"]."\";\n");
130                         fputs($f,"\$SHOPftphost=\"".$_POST["SHOPftphost"]."\";\n");
131                         fputs($f,"\$SHOPftpuser=\"".$_POST["SHOPftpuser"]."\";\n");
132                         fputs($f,"\$SHOPftppwd=\"".$_POST["SHOPftppwd"]."\";\n");
133                         fputs($f,"\$div16[\"ID\"]=\"".$_POST["div16ID"]."\";\n");
134                         fputs($f,"\$div07[\"ID\"]=\"".$_POST["div07ID"]."\";\n");
135                         fputs($f,"\$versand[\"ID\"]=\"".$_POST["versandID"]."\";\n");
136                         fputs($f,"\$nachn[\"ID\"]=\"".$_POST["nachnID"]."\";\n");
137                         fputs($f,"\$minder[\"ID\"]=\"".$_POST["minderID"]."\";\n");
138                         fputs($f,"\$treuh[\"ID\"]=\"".$_POST["treuhID"]."\";\n");
139                         fputs($f,"\$paypal[\"ID\"]=\"".$_POST["paypalID"]."\";\n");
140                         fputs($f,"\$div16[\"NR\"]=\"".$_POST["div16NR"]."\";\n");
141                         fputs($f,"\$div07[\"NR\"]=\"".$_POST["div07NR"]."\";\n");
142                         fputs($f,"\$versand[\"NR\"]=\"".$_POST["versandNR"]."\";\n");
143                         fputs($f,"\$nachn[\"NR\"]=\"".$_POST["nachnNR"]."\";\n");
144                         fputs($f,"\$minder[\"NR\"]=\"".$_POST["minderNR"]."\";\n");
145                         fputs($f,"\$treuh[\"NR\"]=\"".$_POST["treuhNR"]."\";\n");
146                         fputs($f,"\$paypal[\"NR\"]=\"".$_POST["paypalNR"]."\";\n");
147                         fputs($f,"\$div16[\"TXT\"]=\"".$div16txt."\";\n");
148                         fputs($f,"\$div07[\"TXT\"]=\"".$div07txt."\";\n");
149                         fputs($f,"\$versand[\"TXT\"]=\"".$versandtxt."\";\n");
150                         fputs($f,"\$nachn[\"TXT\"]=\"".$nachntxt."\";\n");
151                         fputs($f,"\$minder[\"TXT\"]=\"".$mindertxt."\";\n");
152                         fputs($f,"\$treuh[\"TXT\"]=\"".$treuhtxt."\";\n");
153                         fputs($f,"\$paypal[\"TXT\"]=\"".$paypaltxt."\";\n");
154                         fputs($f,"\$bgcol[1]=\"#ddddff\";\n");
155                         fputs($f,"\$bgcol[2]=\"#ddffdd\";\n");
156                         fputs($f,"\$preA=\"".$_POST["preA"]."\";\n");
157                         fputs($f,"\$preK=\"".$_POST["preK"]."\";\n");
158                         fputs($f,"\$auftrnr=\"".$_POST["auftrnr"]."\";\n");
159                         fputs($f,"\$utftrans=\"".$_POST["utftrans"]."\";\n");
160                         fputs($f,"\$kdnum=\"".$_POST["kdnum"]."\";\n");
161                         fputs($f,"\$mwst=\"".$_POST["mwst"]."\";\n");
162                         fputs($f,"\$pricegroup=\"".$_POST["pricegroup"]."\";\n");
163                         fputs($f,"\$unit=\"".$_POST["unit"]."\";\n");
164                         fputs($f,"\$showErr=\"true\";\n");
165                         fputs($f,"?>");
166                         fclose($f);
167                         require "conf.php";
168                 } else {
169                         $ERPuser=$_POST["ERPuser"];
170                         $ERPpass=$_POST["ERPpass"];
171                         $ERPhost=$_POST["ERPhost"];
172                         $ERPdbname=$_POST["ERPdbname"];
173                         $ERPusrN=$_POST["ERPusrN"];
174                         $ERPdir=$_POST["ERPdir"];
175                         $ERPimgdir=$_POST["ERPimgdir"];
176                         $maxSize=$_POST["maxSize"];
177                         $ERPftphost=$_POST["ERPftphost"];
178                         $ERPftpuser=$_POST["ERPftpuser"];
179                         $ERPftppwd=$_POST["ERPftppwd"];
180                         $SHOPuser=$_POST["SHOPuser"];
181                         $SHOPpass=$_POST["SHOPpass"];
182                         $SHOPhost=$_POST["SHOPhost"];
183                         $SHOPdbname=$_POST["SHOPdbname"];
184                         $SHOPdir=$_POST["SHOPdir"];
185                         $SHOPimgdir=$_POST["SHOPimgdir"];
186                         $SHOPftphost=$_POST["SHOPftphost"];
187                         $SHOPftpuser=$_POST["SHOPftpuser"];
188                         $SHOPftppwd=$_POST["SHOPftppwd"];
189                         $div16NR=$_POST["div16NR"];
190                         $div07NR=$_POST["div07NR"];
191                         $versandNR=$_POST["versandNR"];
192                         $nachnNR=$_POST["nachnNR"];
193                         $treuhNR=$_POST["treuhNR"];
194                         $minderNR=$_POST["minderNR"];
195                         $paypalNR=$_POST["paypalNR"];
196                         $preA=$_POST["preA"];
197                         $preK=$_POST["preK"];
198                         $mwst=empty($_POST["mwst"])?1:$_POST["mwst"];
199                         $kdnum=$_POST["kdnum"];
200                         $pricegroup=$_POST["pricegroup"];
201                         $unit=$_POST["unit"];
202                         $auftrnr=$_POST["auftrnr"];
203                         $utftrans=$_POST["utftrans"];
204                 }
205         }       else {
206                 if (file_exists ("conf$login.php")) {
207                         require "conf$login.php";
208                 } else {
209                         require "conf.php";
210                 }
211                 $dsnP = array(
212                     'phptype'  => 'pgsql',
213                     'username' => $ERPuser,
214                     'password' => $ERPpass,
215                     'hostspec' => $ERPhost,
216                     'database' => $ERPdbname,
217                     'port'     => $ERPport
218                 );
219                 $dbP=@DB::connect($dsnP);
220                 if (DB::isError($dbP)||!$dbP) {
221                         echo "Keine Verbindung zur ERP<br>";
222                         $dbP=false;
223                         //echo $dbP->userinfo;
224                 }
225         }
226         ?>
227 <html>
228 <body>
229 <center>
230 <table style="background-color:#cccccc" border="0">
231 <form name="ConfEdit" method="post" action="confedit.php">
232 <input type="hidden" name="div16ID" value="<?= $div16["ID"] ?>">
233 <input type="hidden" name="div07ID" value="<?= $div07["ID"] ?>">
234 <input type="hidden" name="minderID" value="<?= $minder["ID"] ?>">
235 <input type="hidden" name="versandID" value="<?= $versand["ID"] ?>">
236 <input type="hidden" name="nachnID" value="<?= $nachn["ID"] ?>">
237 <input type="hidden" name="paypalID" value="<?= $paypal["ID"] ?>">
238 <input type="hidden" name="treuhID" value="<?= $treuh["ID"] ?>">
239 <input type="hidden" name="ERPusrID" value="<?= $ERPusr["ID"] ?>">
240
241 <tr><th>Daten</th><th>Lx-ERP</th><th></th><th>Shop</th></tr>
242 <tr>
243         <td>db-Host</td>
244         <td colspan="2"><input type="text" name="ERPhost" size="25" value="<?= $ERPhost ?>"></td>
245         <td><input type="text" name="SHOPhost" size="25" value="<?= $SHOPhost ?>"></td>
246 </tr>
247 <tr>
248         <td>Database</td>
249         <td colspan="2"><input type="text" name="ERPdbname" size="20" value="<?= $ERPdbname ?>"></td>
250         <td><input type="text" name="SHOPdbname" size="20" value="<?= $SHOPdbname ?>"></td>
251 </tr>
252 <tr>
253         <td>db-User Name</td>
254         <td colspan="2"><input type="text" name="ERPuser" size="15" value="<?= $ERPuser ?>"></td>
255         <td><input type="text" name="SHOPuser" size="15" value="<?= $SHOPuser ?>"></td>
256 </tr>
257 <tr>
258         <td>db-User PWD</td>
259         <td colspan="2"><input type="text" name="ERPpass" size="15" value="<?= $ERPpass ?>"></td>
260         <td><input type="text" name="SHOPpass" size="15" value="<?= $SHOPpass ?>"></td>
261 </tr>
262 <tr>
263         <td>UTF8-Transl.</td>
264         <td colspan="2"><input type="checkbox" name="utftrans" <?= (empty($utftrans)?"":"checked") ?>></td>
265         <td>Preise <input type="radio" name="mwst" value="1" <?= ($mwst==1)?"checked":"" ?>> incl.
266             <input type="radio" name="mwst" value="0" <?= ($mwst<>1)?"checked":"" ?>> excl. MwSt</td>
267 </tr>
268 <tr>
269         <td>User-ID</td>
270         <td colspan="2"><input type="text" name="ERPusrN" size="10" value="<?= $ERPusr["Name"] ?>">
271                 <input type="checkbox" name="a1" <?= (empty($ERPusr["ID"])?"":"checked") ?>></td>
272         <td></td>
273 </tr>
274 <tr>
275         <td>CSV-Dir</td>
276         <td colspan="2"><input type="text" name="ERPdir" size="30" value="<?= $ERPdir ?>"></td>
277         <td><input type="text" name="SHOPdir" size="30" value="<?= $SHOPdir ?>"></td>
278 </tr>
279 <tr>
280         <td>Image-Dir</td>
281         <td colspan="2"><input type="text" name="ERPimgdir" size="30" value="<?= $ERPimgdir ?>"></td>
282         <td><input type="text" name="SHOPimgdir" size="30" value="<?= $SHOPimgdir ?>"></td>
283 </tr>
284 <tr>
285         <td>FTP-Host</td>
286         <td colspan="2"><input type="text" name="ERPftphost" size="20" value="<?= $ERPftphost ?>"></td>
287         <td><input type="text" name="SHOPftphost" size="20" value="<?= $SHOPftphost ?>"></td>
288 </tr>
289 <tr>
290         <td>FTP-User</td>
291         <td colspan="2"><input type="text" name="ERPftpuser" size="15" value="<?= $ERPftpuser ?>"></td>
292         <td><input type="text" name="SHOPftpuser" size="15" value="<?= $SHOPftpuser ?>"></td>
293 </tr>
294 <tr>
295         <td>FTP-User PWD</td>
296         <td colspan="2"><input type="text" name="ERPftppwd" size="15" value="<?= $ERPftppwd ?>"></td>
297         <td><input type="text" name="SHOPftppwd" size="15" value="<?= $SHOPftppwd ?>"></td>
298 </tr>
299 <tr>
300         <td>ID Diverse 16%</td>
301         <td><input type="text" name="div16NR" size="10" value="<?= $div16["NR"] ?>">
302                 <input type="checkbox" name="a1" <?= (empty($div16["ID"])?"":"checked") ?>></td>
303         <td>ID Diverse 7%</td>
304         <td><input type="text" name="div07NR" size="10" value="<?= $div07["NR"] ?>">
305                 <input type="checkbox" name="a1" <?= (empty($div07["ID"])?"":"checked") ?>></td>
306 </tr>
307 <tr>
308         <td>ID Versand</td>
309         <td><input type="text" name="versandNR" size="10" value="<?= $versand["NR"] ?>">
310                 <input type="checkbox" name="a1" <?= (empty($versand["ID"])?"":"checked") ?>></td>
311         <td>ID Nachname</td>
312         <td><input type="text" name="nachnNR" size="10" value="<?= $nachn["NR"] ?>">
313                 <input type="checkbox" name="a1" <?= (empty($nachn["ID"])?"":"checked") ?>></td>
314 </tr>
315 <tr>
316         <td>ID Paypal</td>
317         <td><input type="text" name="paypalNR" size="10" value="<?= $paypal["NR"] ?>">
318                 <input type="checkbox" name="a1" <?= (empty($paypal["ID"])?"":"checked") ?>></td>
319         <td>ID Treuhand</td>
320         <td><input type="text" name="treuhNR" size="10" value="<?= $treuh["NR"] ?>">
321                 <input type="checkbox" name="a1" <?= (empty($treuh["ID"])?"":"checked") ?>></td>
322 </tr>
323 <tr>
324         <td>ID Mindermenge</td>
325         <td><input type="text" name="minderNR" size="10" value="<?= $minder["NR"] ?>">
326                 <input type="checkbox" name="a1" <?= (empty($minder["ID"])?"":"checked") ?>></td>
327         <td></td>       
328 </tr>
329 <tr>
330         <td>Std-Einheit</td>
331         <td><select name="unit">
332 <? unit($unit); ?>
333             </select></td>
334         <td>Preisgruppe</td>
335         <td><select name="pricegroup">
336 <? pg($pricegroup); ?>
337             </select></td>
338 <tr>
339         <td colspan="2">Auftragsnummern durch</td>
340         <td><input type="radio" name="auftrnr" value="1" <?= ($auftrnr==1)?"checked":"" ?>> LxO</td>
341         <td><input type="radio" name="auftrnr" value="0" <?= ($auftrnr<>1)?"checked":"" ?>> Shop</td>
342 </tr>
343 <tr>
344         <td colspan="2">Kundennummern durch</td>
345         <td><input type="radio" name="kdnum" value="1" <?= ($kdnum==1)?"checked":"" ?>> LxO</td>
346         <td><input type="radio" name="kdnum" value="0" <?= ($kdnum<>1)?"checked":"" ?>> Shop</td>
347 </tr>
348 <tr>
349         <td colspan="2">Nummernerweiterung</td>
350         <td>Auftrag<input type="text" name="preA" size="5" value="<?= $preA ?>"></td>
351         <td>Kunde<input type="text" name="preK" size="5" value="<?= $preK ?>"></td>
352 </tr>
353 <!--tr>
354         <td>Bildergr&ouml;sse (byte)</td>
355         <td><input type="text" name="maxSize" size="10" value="<?= $maxSize ?>"></td>
356         <td></td>
357 </tr-->
358
359
360
361
362 <tr><td colspan="4" align="center"><input type="submit" name="ok" value="sichern"></td></tr>
363 </form>
364 </table>
365 </center>
366 </body>
367 </html>
368 <? } ?>