Benutzereinstellungen/Administration: Beschriftungen für die Menüart geändert.
[kivitendo-erp.git] / bin / mozilla / admin.pl
1 #=====================================================================
2 # LX-Office ERP
3 # Copyright (C) 2004
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
6 #
7 #=====================================================================
8 # SQL-Ledger Accounting
9 # Copyright (c) 2002
10 #
11 #  Author: Dieter Simader
12 #   Email: dsimader@sql-ledger.org
13 #     Web: http://www.sql-ledger.org
14 #
15 #
16 # This program is free software; you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation; either version 2 of the License, or
19 # (at your option) any later version.
20 #
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #======================================================================
29 #
30 # setup module
31 # add/edit/delete users
32 #
33 #======================================================================
34
35 $menufile = "menu.ini";
36
37 use SL::Form;
38 use SL::User;
39
40 $form = new Form;
41 $form->{"root"} = "root login";
42
43 $locale = new Locale $language, "admin";
44
45 eval { require DBI; };
46 $form->error($locale->text('DBI not installed!')) if ($@);
47
48 # customization
49 if (-f "$form->{path}/custom_$form->{script}") {
50   eval { require "$form->{path}/custom_$form->{script}"; };
51   $form->error($@) if ($@);
52 }
53
54 $form->{stylesheet} = "lx-office-erp.css";
55 $form->{favicon}    = "favicon.ico";
56
57 if ($form->{action}) {
58
59
60   $subroutine = $locale->findsub($form->{action});
61
62   if ($subroutine eq 'login') {
63     if ($form->{rpw}) {
64       $form->{rpw} = crypt $form->{rpw}, "ro";
65     }
66   }
67
68   &check_password;
69
70   &$subroutine;
71
72 } else {
73
74   # if there are no drivers bail out
75   $form->error($locale->text('No Database Drivers available!'))
76     unless (User->dbdrivers);
77
78   # create memberfile
79   if (!-f $memberfile) {
80     open(FH, ">$memberfile") or $form->error("$memberfile : $!");
81     print FH qq|# SQL-Ledger Accounting members
82
83 [root login]
84 password=
85
86 |;
87     close FH;
88   }
89
90   &adminlogin;
91
92 }
93
94 1;
95
96 # end
97
98 sub adminlogin {
99
100   $form->{title} =
101     qq|Lx-Office ERP $form->{version} | . $locale->text('Administration');
102
103   $form->header;
104
105   print qq|
106 <body class=admin>
107
108
109 <div align=center>
110
111 <a href="http://www.lx-office.org"><img src="image/lx-office-erp.png" border=0></a>
112 <h1 class=login>|
113     . $locale->text('Version')
114     . qq| $form->{version}<p>|
115     . $locale->text('Administration')
116     . qq|</h1>
117
118 <form method=post action="$form->{script}">
119
120 <table>
121   <tr>
122     <th>| . $locale->text('Password') . qq|</th>
123     <td><input type=password name=rpw></td>
124     <td><input type=submit class=submit name=action value="|
125     . $locale->text('Login') . qq|"></td>
126   </tr>
127 <input type=hidden name=action value=login>
128 <input type=hidden name=path value=$form->{path}>
129 </table>
130
131
132 </form>
133
134 <a href=http://www.lx-office.org>Lx-Office |
135     . $locale->text('website') . qq|</a>
136
137 </div>
138
139 </body>
140 </html>
141 |;
142
143 }
144
145 sub login {
146
147   &list_users;
148
149 }
150
151 sub add_user {
152
153   $form->{title} =
154       "Lx-Office ERP "
155     . $locale->text('Administration') . " / "
156     . $locale->text('Add User');
157
158   $form->{Oracle_sid}    = $sid;
159   $form->{Oracle_dbport} = '1521';
160   $form->{Oracle_dbhost} = `hostname`;
161
162   if (-f "css/lx-office-erp.css") {
163     $myconfig->{stylesheet} = "lx-office-erp.css";
164   }
165   $myconfig->{vclimit} = 200;
166
167   $myconfig->{"countrycode"} = "de";
168   $myconfig->{"numberformat"} = "1000,00";
169   $myconfig->{"dateformat"} = "dd.mm.yy";
170
171   &form_header;
172   &form_footer;
173
174 }
175
176 sub edit {
177
178   $form->{title} =
179       "Lx-Office ERP "
180     . $locale->text('Administration') . " / "
181     . $locale->text('Edit User');
182   $form->{edit} = 1;
183
184   &form_header;
185   &form_footer;
186
187 }
188
189 sub form_footer {
190
191   if ($form->{edit}) {
192     $delete =
193       qq|<input type=submit class=submit name=action value="|
194       . $locale->text('Delete') . qq|">
195 <input type=hidden name=edit value=1>|;
196   }
197
198   print qq|
199
200 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&rpw=$form->{rpw}">
201 <input type=hidden name=path value=$form->{path}>
202 <input type=hidden name=rpw value=$form->{rpw}>
203
204 <input type=submit class=submit name=action value="|
205     . $locale->text('Save') . qq|">
206 $delete
207
208 </form>
209
210 </body>
211 </html>
212 |;
213
214 }
215
216 sub list_users {
217
218   $form->error($locale->text('File locked!')) if (-f "${memberfile}.LCK");
219
220   open(FH, "$memberfile") or $form->error("$memberfile : $!");
221
222   $nologin = qq|
223 <input type=submit class=submit name=action value="|
224     . $locale->text('Lock System') . qq|">|;
225
226   if (-e "$userspath/nologin") {
227     $nologin = qq|
228 <input type=submit class=submit name=action value="|
229       . $locale->text('Unlock System') . qq|">|;
230   }
231
232   while (<FH>) {
233     chop;
234
235     if (/^\[.*\]/) {
236       $login = $_;
237       $login =~ s/(\[|\])//g;
238     }
239
240     if (/^(name=|company=|templates=|dbuser=|dbdriver=|dbname=|dbhost=)/) {
241       chop($var = $&);
242       ($null, $member{$login}{$var}) = split(/=/, $_, 2);
243     }
244   }
245
246   close(FH);
247
248   # type=submit $locale->text('Pg Database Administration')
249   # type=submit $locale->text('Oracle Database Administration')
250
251   foreach $item (User->dbdrivers) {
252     $dbdrivers .=
253       qq|<input name=action type=submit class=submit value="|
254       . $locale->text("$item Database Administration") . qq|">|;
255   }
256
257   $column_header{login}     = qq|<th>| . $locale->text('Login') . qq|</th>|;
258   $column_header{name}      = qq|<th>| . $locale->text('Name') . qq|</th>|;
259   $column_header{company}   = qq|<th>| . $locale->text('Company') . qq|</th>|;
260   $column_header{dbdriver}  = qq|<th>| . $locale->text('Driver') . qq|</th>|;
261   $column_header{dbhost}    = qq|<th>| . $locale->text('Host') . qq|</th>|;
262   $column_header{dataset}   = qq|<th>| . $locale->text('Dataset') . qq|</th>|;
263   $column_header{templates} =
264     qq|<th>| . $locale->text('Templates') . qq|</th>|;
265
266   @column_index = qw(login name company dbdriver dbhost dataset templates);
267
268   $form->{title} = "Lx-Office ERP " . $locale->text('Administration');
269
270   $form->header;
271
272   print qq|
273 <body class=admin>
274
275 <form method=post action=$form->{script}>
276
277 <table width=100%>
278   <tr>
279   <tr class=listheading>
280     <th>$form->{title}</th>
281   </tr>
282   <tr size=5></tr>
283   <tr>
284     <td>
285       <table width=100%>
286         <tr class=listheading>|;
287
288   map { print "$column_header{$_}\n" } @column_index;
289
290   print qq|
291         </tr>
292 |;
293
294   foreach $key (sort keys %member) {
295     $href =
296       "$script?action=edit&login=$key&path=$form->{path}&rpw=$form->{rpw}";
297     $href =~ s/ /%20/g;
298
299     $member{$key}{templates} =~ s/^$templates\///;
300     $member{$key}{dbhost} = $locale->text('localhost')
301       unless $member{$key}{dbhost};
302     $member{$key}{dbname} = $member{$key}{dbuser}
303       if ($member{$key}{dbdriver} eq 'Oracle');
304
305     $column_data{login}     = qq|<td><a id="$key" href="$href">$key</a></td>|;
306     $column_data{name}      = qq|<td>$member{$key}{name}</td>|;
307     $column_data{company}   = qq|<td>$member{$key}{company}</td>|;
308     $column_data{dbdriver}  = qq|<td>$member{$key}{dbdriver}</td>|;
309     $column_data{dbhost}    = qq|<td>$member{$key}{dbhost}</td>|;
310     $column_data{dataset}   = qq|<td>$member{$key}{dbname}</td>|;
311     $column_data{templates} = qq|<td>$member{$key}{templates}</td>|;
312
313     $i++;
314     $i %= 2;
315     print qq|
316         <tr class="listrow$i">|;
317
318     map { print "$column_data{$_}\n" } @column_index;
319
320     print qq|
321         </tr>|;
322   }
323
324   print qq|
325       </table>
326     </td>
327   </tr>
328   <tr>
329     <td><hr size=3 noshade></td>
330   </tr>
331 </table>
332
333 <input type=hidden name=path value=$form->{path}>
334 <input type=hidden name=rpw value=$form->{rpw}>
335
336 <br><input type=submit class=submit name=action value="|
337     . $locale->text('Add User') . qq|">
338 <input type=submit class=submit name=action value="|
339     . $locale->text('Change Admin Password') . qq|">
340
341 $dbdrivers
342 $nologin
343
344 </form>
345
346 | . $locale->text('Click on login name to edit!') . qq|
347 <br>
348 |
349     . $locale->text(
350     'To add a user to a group edit a name, change the login name and save.  A new user with the same variables will then be saved under the new login name.'
351     )
352     . qq|
353
354 <p>
355
356 <form method=post action=login.pl>
357
358 <table border=0 width=100%>
359   <tr class=listheading>
360     <th>Lx-Office ERP | . $locale->text('Login') . qq|</th>
361   </tr>
362   <tr>
363     <td>
364       <table>
365         <tr>
366           <th align=right>| . $locale->text('Name') . qq|</th>
367           <td><input class=login name=login></td>
368           <td>&nbsp;</td>
369         </tr>
370         <tr>
371           <th align=right>| . $locale->text('Password') . qq|</th>
372           <td><input class=login type=password name=password></td>
373           <td><input type=submit name=action value="|
374     . $locale->text('Login') . qq|"></td>
375         </tr>
376 <input type=hidden name=path value=$form->{path}>
377       </table>
378     </td>
379   </tr>
380 </table>
381
382 </form>
383
384 <hr size=3 noshade>
385
386 </body>
387 </html>
388 |;
389
390 }
391
392 sub form_header {
393
394   # if there is a login, get user
395   if ($form->{login}) {
396
397     # get user
398     $myconfig = new User "$memberfile", "$form->{login}";
399
400     $myconfig->{signature} =~ s/\\n/\r\n/g;
401     $myconfig->{address}   =~ s/\\n/\r\n/g;
402
403     # strip basedir from templates directory
404     $myconfig->{templates} =~ s/^$templates\///;
405
406     # $myconfig->{dbpasswd} = unpack 'u', $myconfig->{dbpasswd};
407   }
408
409   foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
410     $dateformat .=
411       ($item eq $myconfig->{dateformat})
412       ? "<option selected>$item\n"
413       : "<option>$item\n";
414   }
415
416   foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
417     $numberformat .=
418       ($item eq $myconfig->{numberformat})
419       ? "<option selected>$item\n"
420       : "<option>$item\n";
421   }
422
423   %countrycodes = User->country_codes;
424   $countrycodes = "";
425   foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} }
426                 keys %countrycodes
427     ) {
428     $countrycodes .=
429       ($myconfig->{countrycode} eq $key)
430       ? "<option selected value=$key>$countrycodes{$key}"
431       : "<option value=$key>$countrycodes{$key}";
432   }
433   $countrycodes = qq|<option value="">American English\n$countrycodes|;
434
435   # is there a templates basedir
436   if (!-d "$templates") {
437     $form->error(  $locale->text('Directory')
438                  . ": $templates "
439                  . $locale->text('does not exist'));
440   }
441
442   opendir TEMPLATEDIR, "$templates/." or $form->error("$templates : $!");
443   my @all = readdir(TEMPLATEDIR);
444   my @alldir = sort(grep({ -d "$templates/$_" && !/^\.\.?$/ } @all));
445   my @allhtml = sort(grep({ -f "$templates/$_" && /\.html$/ } @all));
446   closedir TEMPLATEDIR;
447
448   @alldir = grep !/\.(html|tex|sty|odt|xml|txb)$/, @alldir;
449   @alldir = grep !/^(webpages|\.svn)$/, @alldir;
450
451   @allhtml = reverse grep !/Default/, @allhtml;
452   push @allhtml, 'Default';
453   @allhtml = reverse @allhtml;
454
455   foreach $item (@alldir) {
456     if ($item eq $myconfig->{templates}) {
457       $usetemplates .= qq|<option selected>$item\n|;
458     } else {
459       $usetemplates .= qq|<option>$item\n|;
460     }
461   }
462
463   $lastitem = $allhtml[0];
464   $lastitem =~ s/-.*//g;
465   $mastertemplates = qq|<option>$lastitem\n|;
466   foreach $item (@allhtml) {
467     $item =~ s/-.*//g;
468
469     if ($item ne $lastitem) {
470       my $selected = $item eq "German" ? " selected" : "";
471       $mastertemplates .= qq|<option$selected>$item\n|;
472       $lastitem = $item;
473     }
474   }
475
476   opendir CSS, "css/.";
477   @all = sort(grep({ /\.css$/ && ($_ ne "tabcontent.css") } readdir(CSS)));
478   closedir CSS;
479
480   foreach $item (@all) {
481     if ($item eq $myconfig->{stylesheet}) {
482       $selectstylesheet .= qq|<option selected>$item\n|;
483     } else {
484       $selectstylesheet .= qq|<option>$item\n|;
485     }
486   }
487
488   $form->header;
489
490   if ($myconfig->{menustyle} eq "v3") {
491     $menustyle_v3 = "checked";
492   } elsif ($myconfig->{menustyle} eq "neu") {
493     $menustyle_neu = "checked";
494   } else {
495     $menustyle_old = "checked";
496   }
497
498   print qq|
499 <body class=admin>
500
501 <form method=post action=$form->{script}>
502
503 <table width=100%>
504   <tr class=listheading><th colspan=2>$form->{title}</th></tr>
505   <tr size=5></tr>
506   <tr valign=top>
507     <td>
508       <table>
509         <tr>
510           <th align=right>| . $locale->text('Login') . qq|</th>
511           <td><input name=login value="$myconfig->{login}"></td>
512         </tr>
513         <tr>
514           <th align=right>| . $locale->text('Password') . qq|</th>
515           <td><input type=password name=password size=8 value=$myconfig->{password}></td>
516           <input type=hidden name=old_password value=$myconfig->{password}>
517         </tr>
518         <tr>
519           <th align=right>| . $locale->text('Name') . qq|</th>
520           <td><input name=name size=15 value="$myconfig->{name}"></td>
521         </tr>
522         <tr>
523           <th align=right>| . $locale->text('E-mail') . qq|</th>
524           <td><input name=email size=30 value="$myconfig->{email}"></td>
525         </tr>
526         <tr valign=top>
527           <th align=right>| . $locale->text('Signature') . qq|</th>
528           <td><textarea name=signature rows=3 cols=35>$myconfig->{signature}</textarea></td>
529         </tr>
530         <tr>
531           <th align=right>| . $locale->text('Phone') . qq|</th>
532           <td><input name=tel size=14 value="$myconfig->{tel}"></td>
533         </tr>
534         <tr>
535           <th align=right>| . $locale->text('Fax') . qq|</th>
536           <td><input name=fax size=14 value="$myconfig->{fax}"></td>
537         </tr>
538         <tr>
539           <th align=right>| . $locale->text('Company') . qq|</th>
540           <td><input name=company size=35 value="$myconfig->{company}"></td>
541         </tr>
542         <tr valign=top>
543           <th align=right>| . $locale->text('Address') . qq|</th>
544           <td><textarea name=address rows=4 cols=35>$myconfig->{address}</textarea></td>
545         </tr>
546         <tr valign=top>
547           <th align=right>| . $locale->text('Tax number') . qq|</th>
548           <td><input name=taxnumber size=14 value="$myconfig->{taxnumber}"></td>
549         </tr>
550         <tr valign=top>
551           <th align=right>| . $locale->text('Ust-IDNr') . qq|</th>
552           <td><input name=co_ustid size=14 value="$myconfig->{co_ustid}"></td>
553         </tr>
554         <tr valign=top>
555           <th align=right>| . $locale->text('DUNS-Nr') . qq|</th>
556           <td><input name=duns size=14 value="$myconfig->{duns}"></td>
557         </tr>
558       </table>
559     </td>
560     <td>
561       <table>
562         <tr>
563           <th align=right>| . $locale->text('Date Format') . qq|</th>
564           <td><select name=dateformat>$dateformat</select></td>
565         </tr>
566         <tr>
567           <th align=right>| . $locale->text('Number Format') . qq|</th>
568           <td><select name=numberformat>$numberformat</select></td>
569         </tr>
570         <tr>
571           <th align=right>| . $locale->text('Dropdown Limit') . qq|</th>
572           <td><input name=vclimit value="$myconfig->{vclimit}"></td>
573         </tr>
574         <tr>
575           <th align=right>| . $locale->text('Language') . qq|</th>
576           <td><select name=countrycode>$countrycodes</select></td>
577         </tr>
578         <tr>
579           <th align=right>| . $locale->text('Character Set') . qq|</th>
580           <td><input name=charset value="$myconfig->{charset}"></td>
581         </tr>
582         <tr>
583           <th align=right>| . $locale->text('Stylesheet') . qq|</th>
584           <td><select name=userstylesheet>$selectstylesheet</select></td>
585         </tr>
586         <tr>
587           <th align=right>| . $locale->text('Printer') . qq|</th>
588           <td><input name=printer size=20 value="$myconfig->{printer}"></td>
589         </tr>
590         <tr>
591           <th align=right>| . $locale->text('Use Templates') . qq|</th>
592           <td><select name=usetemplates>$usetemplates</select></td>
593         </tr>
594         <tr>
595           <th align=right>| . $locale->text('New Templates') . qq|</th>
596           <td><input name=newtemplates></td>
597         </tr>
598         <tr>
599           <th align=right>| . $locale->text('Setup Templates') . qq|</th>
600           <td><select name=mastertemplates>$mastertemplates</select></td>
601         </tr>
602        <tr>
603            <th align=right>| . $locale->text('Setup Menu') . qq|</th>
604            <td><input name=menustyle type=radio class=radio value=neu $menustyle_neu>&nbsp;| .
605            $locale->text("Top (Javascript)") . qq|
606            <input name=menustyle type=radio class=radio value=old $menustyle_old>&nbsp;| .
607            $locale->text("Old (on the side)") . qq|
608            </td>
609          </tr>
610         <input type=hidden name=templates value=$myconfig->{templates}>
611       </table>
612     </td>
613   </tr>
614   <tr class=listheading>
615     <th colspan=2>| . $locale->text('Database') . qq|</th>
616   </tr>|;
617
618   # list section for database drivers
619   foreach $item (User->dbdrivers) {
620
621     print qq|
622   <tr>
623     <td colspan=2>
624       <table>
625         <tr>|;
626
627     $checked = "";
628     if ($myconfig->{dbdriver} eq $item) {
629       map { $form->{"${item}_$_"} = $myconfig->{$_} }
630         qw(dbhost dbport dbuser dbpasswd dbname sid);
631       $checked = "checked";
632     }
633
634     print qq|
635           <th align=right>| . $locale->text('Driver') . qq|</th>
636           <td><input name=dbdriver type=radio class=radio value=$item $checked>&nbsp;$item</td>
637           <th align=right>| . $locale->text('Host') . qq|</th>
638           <td><input name="${item}_dbhost" size=30 value=$form->{"${item}_dbhost"}></td>
639         </tr>
640         <tr>|;
641
642     if ($item eq 'Pg') {
643       print qq|
644           <th align=right>| . $locale->text('Dataset') . qq|</th>
645           <td><input name=Pg_dbname size=15 value=$form->{Pg_dbname}></td>
646           <th align=right>| . $locale->text('Port') . qq|</th>
647           <td><input name=Pg_dbport size=4 value=$form->{Pg_dbport}></td>
648         </tr>
649         <tr>
650           <th align=right>| . $locale->text('User') . qq|</th>
651           <td><input name="${item}_dbuser" size=15 value=$form->{"${item}_dbuser"}></td>
652           <th align=right>| . $locale->text('Password') . qq|</th>
653           <td><input name="${item}_dbpasswd" type=password size=10 value=$form->{"${item}_dbpasswd"}></td>
654         </tr>|;
655
656     }
657
658     if ($item eq 'Oracle') {
659       print qq|
660           <th align=right>SID</th>
661           <td><input name=Oracle_sid value=$form->{Oracle_sid}></td>
662           <th align=right>| . $locale->text('Port') . qq|</th>
663           <td><input name=Oracle_dbport size=4 value=$form->{Oracle_dbport}></td>
664         </tr>
665         <tr>
666           <th align=right>| . $locale->text('Dataset') . qq|</th>
667           <td><input name="${item}_dbuser" size=15 value=$form->{"${item}_dbuser"}></td>
668           <th align=right>| . $locale->text('Password') . qq|</th>
669           <td><input name="${item}_dbpasswd" type=password size=10 value=$form->{"${item}_dbpasswd"}></td>
670
671         </tr>|;
672     }
673
674     print qq|
675         <input type=hidden name=old_dbpasswd value=$myconfig->{dbpasswd}>
676       </table>
677     </td>
678   </tr>
679   <tr>
680     <td colspan=2><hr size=2 noshade></td>
681   </tr>
682 |;
683
684   }
685
686   # access control
687   open(FH, $menufile) or $form->error("$menufile : $!");
688
689   # scan for first menu level
690   @a = <FH>;
691   close(FH);
692
693   if (open(FH, "custom_$menufile")) {
694     push @a, <FH>;
695   }
696   close(FH);
697
698   foreach $item (@a) {
699     next unless $item =~ /\[/;
700     next if $item =~ /\#/;
701
702     $item =~ s/(\[|\])//g;
703     chop $item;
704
705     if ($item =~ /--/) {
706       ($level, $menuitem) = split /--/, $item, 2;
707     } else {
708       $level    = $item;
709       $menuitem = $item;
710       push @acsorder, $item;
711     }
712
713     push @{ $acs{$level} }, $menuitem;
714
715   }
716
717   %role = ('admin'      => $locale->text('Administrator'),
718            'user'       => $locale->text('User'),
719            'manager'    => $locale->text('Manager'),
720            'supervisor' => $locale->text('Supervisor'));
721
722   $selectrole = "";
723   foreach $item (qw(user supervisor manager admin)) {
724     $selectrole .=
725       ($myconfig->{role} eq $item)
726       ? "<option selected value=$item>$role{$item}\n"
727       : "<option value=$item>$role{$item}\n";
728   }
729
730   print qq|
731   <tr class=listheading>
732     <th colspan=2>| . $locale->text('Access Control') . qq|</th>
733   </tr>
734   <tr>
735     <td><select name=role>$selectrole</select></td>
736   </tr>
737 |;
738
739   foreach $item (split(/;/, $myconfig->{acs})) {
740     ($key, $value) = split /--/, $item, 2;
741     $excl{$key}{$value} = 1;
742   }
743
744   foreach $key (@acsorder) {
745
746     $checked = "checked";
747     if ($form->{login}) {
748       $checked = ($excl{$key}{$key}) ? "" : "checked";
749     }
750
751     # can't have variable names with spaces
752     # the 1 is for apache 2
753     $item = $form->escape("${key}--$key", 1);
754
755     $acsheading = $key;
756     $acsheading =~ s/ /&nbsp;/g;
757
758     $acsheading = qq|
759     <th align=left><input name="$item" class=checkbox type=checkbox value=1 $checked>&nbsp;$acsheading</th>\n|;
760     $menuitems .= "$item;";
761     $acsdata = "
762     <td>";
763
764     foreach $item (@{ $acs{$key} }) {
765       next if ($key eq $item);
766
767       $checked = "checked";
768       if ($form->{login}) {
769         $checked = ($excl{$key}{$item}) ? "" : "checked";
770       }
771
772       $acsitem = $form->escape("${key}--$item", 1);
773
774       $acsdata .= qq|
775     <br><input name="$acsitem" class=checkbox type=checkbox value=1 $checked>&nbsp;$item|;
776       $menuitems .= "$acsitem;";
777     }
778
779     $acsdata .= "
780     </td>";
781
782     print qq|
783   <tr valign=top>$acsheading $acsdata
784   </tr>
785 |;
786   }
787
788   print qq|<input type=hidden name=acs value="$menuitems">
789 |;
790   if ($webdav) {
791     @webdavdirs =
792       qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen);
793     foreach $directory (@webdavdirs) {
794       if ($myconfig->{$directory}) {
795         $webdav{"${directory}c"} = "checked";
796       } else {
797         $webdav{"${directory}c"} = "";
798       }
799     }
800     print qq|
801    <tr>
802     <td colspan=2><hr size=3 noshade></td>
803   </tr>
804   <tr class=listheading>
805     <th colspan=2>| . $locale->text('WEBDAV-Zugriff') . qq|</th>
806   </tr>
807   <table width=100%>
808         <tr>
809         <td><input name=angebote class=checkbox type=checkbox value=1 $webdav{angebotec}>&nbsp;Angebot</td>
810         <td><input name=bestellungen class=checkbox type=checkbox value=1 $webdav{bestellungenc}>&nbsp;Bestellung</td>
811         <td><input name=rechnungen class=checkbox type=checkbox value=1 $webdav{rechnungenc}>&nbsp;Rechnung</td>
812         </tr>
813         <tr>
814         <td><input name=anfragen class=checkbox type=checkbox value=1 $webdav{anfragenc}>&nbsp;Angebot</td>
815         <td><input name=lieferantenbestellungen class=checkbox type=checkbox value=1 $webdav{lieferantenbestellungenc}>&nbsp;Lieferantenbestellung</td>
816         <td><input name=einkaufsrechnungen class=checkbox type=checkbox value=1 $webdav{einkaufsrechnungenc}>&nbsp;Einkaufsrechnung</td>
817         </tr>
818   </table>
819   <tr>
820     <td colspan=2><hr size=3 noshade></td>
821   </tr>
822 |;
823   }
824   print qq|
825 </table>
826 </div>
827 |;
828
829 }
830
831 sub save {
832
833   # no driver checked
834   $form->error($locale->text('Database Driver not checked!'))
835     unless $form->{dbdriver};
836
837   # no spaces allowed in login name
838   ($form->{login}) = split / /, $form->{login};
839
840   $form->isblank("login", $locale->text('Login name missing!'));
841
842   # check for duplicates
843   if (!$form->{edit}) {
844     $temp = new User "$memberfile", "$form->{login}";
845
846     if ($temp->{login}) {
847       $form->error("$form->{login} " . $locale->text('is already a member!'));
848     }
849   }
850
851   # no spaces allowed in directories
852   ($form->{newtemplates}) = split / /, $form->{newtemplates};
853
854   if ($form->{newtemplates}) {
855     $form->{templates} = $form->{newtemplates};
856   } else {
857     $form->{templates} =
858       ($form->{usetemplates}) ? $form->{usetemplates} : $form->{login};
859   }
860
861   # is there a basedir
862   if (!-d "$templates") {
863     $form->error(  $locale->text('Directory')
864                  . ": $templates "
865                  . $locale->text('does not exist'));
866   }
867
868   # add base directory to $form->{templates}
869   $form->{templates} = "$templates/$form->{templates}";
870
871   $myconfig = new User "$memberfile", "$form->{login}";
872
873   # redo acs variable and delete all the acs codes
874   @acs = split(/;/, $form->{acs});
875
876   $form->{acs} = "";
877   foreach $item (@acs) {
878     $item = $form->escape($item, 1);
879
880     if (!$form->{$item}) {
881       $form->{acs} .= $form->unescape($form->unescape($item)) . ";";
882     }
883     delete $form->{$item};
884   }
885
886   # check which database was filled in
887   if ($form->{dbdriver} eq 'Oracle') {
888     $form->{sid}      = $form->{Oracle_sid},;
889     $form->{dbhost}   = $form->{Oracle_dbhost},;
890     $form->{dbport}   = $form->{Oracle_dbport};
891     $form->{dbpasswd} = $form->{Oracle_dbpasswd};
892     $form->{dbuser}   = $form->{Oracle_dbuser};
893     $form->{dbname}   = $form->{Oracle_dbuser};
894
895     $form->isblank("dbhost", $locale->text('Hostname missing!'));
896     $form->isblank("dbport", $locale->text('Port missing!'));
897     $form->isblank("dbuser", $locale->text('Dataset missing!'));
898   }
899   if ($form->{dbdriver} eq 'Pg') {
900     $form->{dbhost}   = $form->{Pg_dbhost};
901     $form->{dbport}   = $form->{Pg_dbport};
902     $form->{dbpasswd} = $form->{Pg_dbpasswd};
903     $form->{dbuser}   = $form->{Pg_dbuser};
904     $form->{dbname}   = $form->{Pg_dbname};
905
906     $form->isblank("dbname", $locale->text('Dataset missing!'));
907     $form->isblank("dbuser", $locale->text('Database User missing!'));
908   }
909
910   if ($webdav) {
911     @webdavdirs =
912       qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen);
913     foreach $directory (@webdavdirs) {
914       if ($form->{$directory}) {
915         $form->{$directory} = $form->{$directory};
916       } else {
917         $form->{$directory} = 0;
918       }
919     }
920   }
921
922   foreach $item (keys %{$form}) {
923     $myconfig->{$item} = $form->{$item};
924   }
925
926   delete $myconfig->{stylesheet};
927   if ($form->{userstylesheet}) {
928     $myconfig->{stylesheet} = $form->{userstylesheet};
929   }
930
931   $myconfig->save_member($memberfile, $userspath);
932
933   if ($webdav) {
934     @webdavdirs =
935       qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen);
936     foreach $directory (@webdavdirs) {
937       $file = "webdav/" . $directory . "/webdav-user";
938       if ($form->{$directory}) {
939         if (open(HTACCESS, "$file")) {
940           while (<HTACCESS>) {
941             ($login, $password) = split(/:/, $_);
942             if ($login ne $form->{login}) {
943               $newfile .= $_;
944             }
945           }
946           close(HTACCESS);
947         }
948         open(HTACCESS, "> $file") or die "cannot open $file $!\n";
949         $newfile .= $myconfig->{login} . ":" . $myconfig->{password} . "\n";
950         print(HTACCESS $newfile);
951         close(HTACCESS);
952       } else {
953         $form->{$directory} = 0;
954         if (open(HTACCESS, "$file")) {
955           while (<HTACCESS>) {
956             ($login, $password) = split(/:/, $_);
957             if ($login ne $form->{login}) {
958               $newfile .= $_;
959             }
960           }
961           close(HTACCESS);
962         }
963         open(HTACCESS, "> $file") or die "cannot open $file $!\n";
964         print(HTACCESS $newfile);
965         close(HTACCESS);
966       }
967     }
968   }
969
970   # create user template directory and copy master files
971   if (!-d "$form->{templates}") {
972     umask(002);
973
974     if (mkdir "$form->{templates}", oct("771")) {
975
976       umask(007);
977
978       # copy templates to the directory
979       opendir TEMPLATEDIR, "$templates/." or $form - error("$templates : $!");
980       @templates = grep /$form->{mastertemplates}.*?\.(html|tex|sty|xml|txb)$/,
981         readdir TEMPLATEDIR;
982       closedir TEMPLATEDIR;
983
984       foreach $file (@templates) {
985         open(TEMP, "$templates/$file")
986           or $form->error("$templates/$file : $!");
987
988         $file =~ s/$form->{mastertemplates}-//;
989         open(NEW, ">$form->{templates}/$file")
990           or $form->error("$form->{templates}/$file : $!");
991
992         while ($line = <TEMP>) {
993           print NEW $line;
994         }
995         close(TEMP);
996         close(NEW);
997       }
998     } else {
999       $form->error("$!: $form->{templates}");
1000     }
1001   }
1002
1003   $form->redirect($locale->text('User saved!'));
1004
1005 }
1006
1007 sub delete {
1008
1009   $form->{templates} =
1010     ($form->{templates})
1011     ? "$templates/$form->{templates}"
1012     : "$templates/$form->{login}";
1013
1014   $form->error($locale->text('File locked!')) if (-f ${memberfile} . LCK);
1015   open(FH, ">${memberfile}.LCK") or $form->error("${memberfile}.LCK : $!");
1016   close(FH);
1017
1018   open(CONF, "+<$memberfile") or $form->error("$memberfile : $!");
1019
1020   @config = <CONF>;
1021
1022   seek(CONF, 0, 0);
1023   truncate(CONF, 0);
1024
1025   while ($line = shift @config) {
1026
1027     if ($line =~ /^\[/) {
1028       last if ($line =~ /\[$form->{login}\]/);
1029       $login = &login_name($line);
1030     }
1031
1032     if ($line =~ /^templates=/) {
1033       $user{$login} = &get_value($line);
1034     }
1035
1036     print CONF $line;
1037   }
1038
1039   # remove everything up to next login or EOF
1040   # and save template variable
1041   while ($line = shift @config) {
1042     if ($line =~ /^templates=/) {
1043       $templatedir = &get_value($line);
1044     }
1045     last if ($line =~ /^\[/);
1046   }
1047
1048   # this one is either the next login or EOF
1049   print CONF $line;
1050
1051   $login = &login_name($line);
1052
1053   while ($line = shift @config) {
1054     if ($line =~ /^\[/) {
1055       $login = &login_name($line);
1056     }
1057
1058     if ($line =~ /^templates=/) {
1059       $user{$login} = &get_value($line);
1060     }
1061
1062     print CONF $line;
1063   }
1064
1065   close(CONF);
1066   unlink "${memberfile}.LCK";
1067
1068   # scan %user for $templatedir
1069   foreach $login (keys %user) {
1070     last if ($found = ($templatedir eq $user{$login}));
1071   }
1072
1073   # if found keep directory otherwise delete
1074   if (!$found) {
1075
1076     # delete it if there is a template directory
1077     $dir = "$form->{templates}";
1078     if (-d "$dir") {
1079       unlink <$dir/*.html>;
1080       unlink <$dir/*.tex>;
1081       unlink <$dir/*.sty>;
1082       rmdir "$dir";
1083     }
1084   }
1085
1086   # delete config file for user
1087   unlink "$userspath/$form->{login}.conf";
1088
1089   $form->redirect($locale->text('User deleted!'));
1090
1091 }
1092
1093 sub login_name {
1094   my $login = shift;
1095
1096   $login =~ s/\[\]//g;
1097   return ($login) ? $login : undef;
1098
1099 }
1100
1101 sub get_value {
1102   my $line = shift;
1103
1104   my ($null, $value) = split(/=/, $line, 2);
1105
1106   # remove comments
1107   $value =~ s/\s#.*//g;
1108
1109   # remove any trailing whitespace
1110   $value =~ s/^\s*(.*?)\s*$/$1/;
1111
1112   $value;
1113 }
1114
1115 sub change_admin_password {
1116
1117   $form->{title} =
1118       qq|Lx-Office ERP |
1119     . $locale->text('Administration') . " / "
1120     . $locale->text('Change Admin Password');
1121
1122   $form->header;
1123
1124   print qq|
1125 <body class=admin>
1126
1127
1128 <h2>| . $locale->text('Change Admin Password') . qq|</h2>
1129
1130 <form method=post action=$form->{script}>
1131
1132 <table>
1133   <tr>
1134     <td><b>| . $locale->text('Password') . qq|</b></td>
1135     <td><input type=password name=password size=8></td>
1136   </tr>
1137   <tr>
1138     <td><b>| . $locale->text('Repeat the password') . qq|</b></td>
1139     <td><input type=password name=password_again size=8></b></td>
1140   </tr>
1141 </table>
1142
1143 <input type=hidden name=path value=$form->{path}>
1144 <input type=hidden name=rpw value=$form->{rpw}>
1145
1146 <p>
1147 <input type=submit class=submit name=action value="|
1148     . $locale->text('Change Password') . qq|">
1149
1150 </form>
1151
1152 </body>
1153 </html>
1154 |;
1155
1156 }
1157
1158 sub change_password {
1159   if ($form->{"password"} ne $form->{"password_again"}) {
1160     $form->{title} =
1161       qq|Lx-Office ERP |
1162       . $locale->text('Administration') . " / "
1163       . $locale->text('Change Admin Password');
1164
1165     $form->header;
1166
1167     print qq|
1168 <body class=admin>
1169
1170
1171 <h2>| . $locale->text('Change Admin Password') . qq|</h2>
1172
1173 <p>| . $locale->text("The passwords do not match.") . qq|<br>
1174 <input type="button" onclick="history.back()" value="| . $locale->text("Back") . qq|">|;
1175     return;
1176   }
1177
1178   $root->{password} = $form->{password};
1179
1180   $root->{'root login'} = 1;
1181   $root->save_member($memberfile);
1182
1183   $form->{callback} =
1184     "$form->{script}?action=list_users&path=$form->{path}&rpw=$root->{password}";
1185
1186   $form->redirect($locale->text('Password changed!'));
1187
1188 }
1189
1190 sub check_password {
1191   $root = new User "$memberfile", $form->{root};
1192
1193   if (!defined($root->{password}) || ($root->{password} ne $form->{rpw})) {
1194     $form->error($locale->text('Incorrect Password!'));
1195   }
1196
1197 }
1198
1199 sub pg_database_administration {
1200
1201   $form->{dbdriver} = 'Pg';
1202   &dbselect_source;
1203
1204 }
1205
1206 sub oracle_database_administration {
1207
1208   $form->{dbdriver} = 'Oracle';
1209   &dbselect_source;
1210
1211 }
1212
1213 sub dbdriver_defaults {
1214
1215   # load some defaults for the selected driver
1216   %driverdefaults = (
1217                      'Pg' => { dbport        => '5432',
1218                                dbuser        => 'postgres',
1219                                dbdefault     => 'template1',
1220                                dbhost        => 'localhost',
1221                                connectstring => $locale->text('Connect to')
1222                      },
1223                      'Oracle' => { dbport        => '1521',
1224                                    dbuser        => 'oralin',
1225                                    dbdefault     => $sid,
1226                                    dbhost        => `hostname`,
1227                                    connectstring => 'SID'
1228                      });
1229
1230   map { $form->{$_} = $driverdefaults{ $form->{dbdriver} }{$_} }
1231     keys %{ $driverdefaults{Pg} };
1232
1233 }
1234
1235 sub dbselect_source {
1236
1237   &dbdriver_defaults;
1238
1239   $msg{Pg} =
1240     $locale->text(
1241     'Leave host and port field empty unless you want to make a remote connection.'
1242     );
1243   $msg{Oracle} =
1244     $locale->text(
1245            'You must enter a host and port for local and remote connections!');
1246
1247   $form->{title} =
1248     "Lx-Office ERP / " . $locale->text('Database Administration');
1249
1250   $form->header;
1251
1252   print qq|
1253 <body class=admin>
1254
1255
1256 <center>
1257 <h2>$form->{title}</h2>
1258
1259 <form method=post action=$form->{script}>
1260
1261 <table>
1262 <tr><td>
1263
1264 <table>
1265
1266   <tr class=listheading>
1267     <th colspan=4>| . $locale->text('Database') . qq|</th>
1268   </tr>
1269
1270 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1271
1272   <tr><td>
1273    <table>
1274
1275   <tr>
1276
1277     <th align=right>| . $locale->text('Host') . qq|</th>
1278     <td><input name=dbhost size=25 value=$form->{dbhost}></td>
1279     <th align=right>| . $locale->text('Port') . qq|</th>
1280     <td><input name=dbport size=5 value=$form->{dbport}></td>
1281
1282   </tr>
1283
1284   <tr>
1285
1286     <th align=right>| . $locale->text('User') . qq|</th>
1287     <td><input name=dbuser size=10 value=$form->{dbuser}></td>
1288     <th align=right>| . $locale->text('Password') . qq|</th>
1289     <td><input type=password name=dbpasswd size=10></td>
1290
1291   </tr>
1292
1293   <tr>
1294
1295     <th align=right>$form->{connectstring}</th>
1296     <td colspan=3><input name=dbdefault size=10 value=$form->{dbdefault}></td>
1297
1298   </tr>
1299
1300 </table>
1301
1302 </td></tr>
1303 </table>
1304
1305 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&rpw=$form->{rpw}">
1306 <input type=hidden name=path value=$form->{path}>
1307 <input type=hidden name=rpw value=$form->{rpw}>
1308
1309 <br>
1310
1311 <input type=submit class=submit name=action value="|
1312     . $locale->text('Create Dataset') . qq|">|;
1313 # Vorübergehend Deaktiviert
1314 # <input type=submit class=submit name=action value="|
1315 #     . $locale->text('Update Dataset') . qq|">
1316 print qq| <input type=submit class=submit name=action value="|
1317     . $locale->text('Delete Dataset') . qq|">
1318
1319 </form>
1320
1321 </td></tr>
1322 </table>
1323
1324 <p>|
1325     . $locale->text(
1326     'This is a preliminary check for existing sources. Nothing will be created or deleted at this stage!'
1327     )
1328
1329     . qq|
1330 <br>$msg{$form->{dbdriver}}
1331
1332
1333 </body>
1334 </html>
1335 |;
1336
1337 }
1338
1339 sub continue {
1340
1341   &{ $form->{nextsub} };
1342
1343 }
1344
1345 sub update_dataset {
1346
1347   %needsupdate = User->dbneedsupdate(\%$form);
1348
1349   $form->{title} =
1350       "Lx-Office ERP "
1351     . $locale->text('Database Administration') . " / "
1352     . $locale->text('Update Dataset');
1353
1354   $form->header;
1355
1356   print qq|
1357 <body class=admin>
1358
1359
1360 <center>
1361 <h2>$form->{title}</h2>
1362 |;
1363   my $field_id = 0;
1364   foreach $key (sort keys %needsupdate) {
1365     if ($needsupdate{$key} ne $form->{dbversion}) {
1366       $upd .= qq|<input id="$field_id" name="db$key" type="checkbox" value="1" checked> $key\n|;
1367       $form->{dbupdate} .= "db$key ";
1368       $field_id++;
1369     }
1370   }
1371
1372   chop $form->{dbupdate};
1373
1374   if ($form->{dbupdate}) {
1375
1376     print qq|
1377 <table width=100%>
1378 <form method=post action=$form->{script}>
1379
1380 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1381 <input type=hidden name=dbhost value=$form->{dbhost}>
1382 <input type=hidden name=dbport value=$form->{dbport}>
1383 <input type=hidden name=dbuser value=$form->{dbuser}>
1384 <input type=hidden name=dbpasswd value=$form->{dbpasswd}>
1385 <input type=hidden name=dbdefault value=$form->{dbdefault}>
1386
1387 <tr class=listheading>
1388   <th>| . $locale->text('The following Datasets need to be updated') . qq|</th>
1389 </tr>
1390 <tr>
1391 <td>
1392
1393 $upd
1394
1395 </td>
1396 </tr>
1397 <tr>
1398 <td>
1399
1400 <input name=dbupdate type=hidden value="$form->{dbupdate}">
1401
1402 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&rpw=$form->{rpw}">
1403
1404 <input type=hidden name=path value=$form->{path}>
1405 <input type=hidden name=rpw value=$form->{rpw}>
1406
1407 <input type=hidden name=nextsub value=dbupdate>
1408
1409 <hr size=3 noshade>
1410
1411 <br>
1412 <input type=submit class=submit name=action value="|
1413       . $locale->text('Continue') . qq|">
1414
1415 </td></tr>
1416 </table>
1417 </form>
1418 |;
1419
1420   } else {
1421
1422     print $locale->text('All Datasets up to date!');
1423
1424   }
1425
1426   print qq|
1427
1428 </body>
1429 </html>
1430 |;
1431
1432 }
1433
1434 sub dbupdate {
1435   $form->{"stylesheet"} = "lx-office-erp.css";
1436   $form->{"title"} = $main::locale->text("Dataset upgrade");
1437   $form->header();
1438   my $dbname =
1439     join(" ",
1440          map({ s/\s//g; s/^db//; $_; }
1441              grep({ $form->{$_} }
1442                   split(/\s+/, $form->{"dbupdate"}))));
1443   print($form->parse_html_template("dbupgrade/header",
1444                                    { "dbname" => $dbname }));
1445
1446   User->dbupdate(\%$form);
1447
1448   print qq|
1449 <hr>
1450
1451 | . $locale->text('Dataset updated!') . qq|
1452
1453 <br>
1454
1455 <a id="enddatasetupdate" href="admin.pl?action=login&| .
1456 join("&", map({ "$_=" . $form->escape($form->{$_}); } qw(path rpw))) .
1457 qq|">| . $locale->text("Continue") . qq|</a>|;
1458
1459 }
1460
1461 sub create_dataset {
1462
1463   foreach $item (sort User->dbsources(\%$form)) {
1464     $dbsources .= "[$item] ";
1465   }
1466
1467   opendir SQLDIR, "sql/." or $form - error($!);
1468   foreach $item (sort grep /-chart\.sql/, readdir SQLDIR) {
1469     next if ($item eq 'Default-chart.sql');
1470     $item =~ s/-chart\.sql//;
1471     push @charts,
1472       qq| <input name=chart class=radio type=radio value="$item">&nbsp;$item|;
1473   }
1474   closedir SQLDIR;
1475
1476   $selectencoding = qq|<option>
1477   <option value=SQL_ASCII>ASCII
1478   <option value=EUC_JP>Japanese Extended UNIX Code
1479   <option value=EUC_CN>Chinese Extended UNIX Code
1480   <option value=EUC_KR>Korean Extended UNIX Code
1481   <option value=EUC_TW>Taiwan Extended UNIX Code
1482   <option value=UNICODE>UTF-8 Unicode
1483   <option value=MULE_INTERNAL>Mule internal type
1484   <option value=LATIN1>ISO 8859-1
1485   <option value=LATIN2>ISO 8859-2
1486   <option value=LATIN3>ISO 8859-3
1487   <option value=LATIN4>ISO 8859-4
1488   <option value=LATIN5>ISO 8859-5
1489   <option value=KOI8>KOI8-R
1490   <option value=WIN>Windows CP1251
1491   <option value=ALT>Windows CP866
1492   |;
1493
1494   $form->{title} =
1495       "Lx-Office ERP "
1496     . $locale->text('Database Administration') . " / "
1497     . $locale->text('Create Dataset');
1498
1499   $form->header;
1500
1501   print qq|
1502 <body class=admin>
1503
1504
1505 <center>
1506 <h2>$form->{title}</h2>
1507
1508 <form method=post action=$form->{script}>
1509
1510 <table width=100%>
1511   <tr class=listheading>
1512     <th colspan=2>&nbsp;</th>
1513   </tr>
1514
1515   <tr>
1516
1517     <th align=right nowrap>| . $locale->text('Existing Datasets') . qq|</th>
1518     <td>$dbsources</td>
1519
1520   </tr>
1521
1522   <tr>
1523
1524     <th align=right nowrap>| . $locale->text('Create Dataset') . qq|</th>
1525     <td><input name=db></td>
1526
1527   </tr>
1528
1529   <tr>
1530
1531     <th align=right nowrap>| . $locale->text('Multibyte Encoding') . qq|</th>
1532     <td><select name=encoding>$selectencoding</select></td>
1533
1534   </tr>
1535
1536   <tr>
1537
1538     <th align=right nowrap>|
1539     . $locale->text('Create Chart of Accounts') . qq|</th>
1540     <td>@charts</td>
1541
1542   </tr>
1543
1544   <tr><td colspan=2>
1545 <p>
1546 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1547 <input type=hidden name=dbuser value=$form->{dbuser}>
1548 <input type=hidden name=dbhost value=$form->{dbhost}>
1549 <input type=hidden name=dbport value=$form->{dbport}>
1550 <input type=hidden name=dbpasswd value=$form->{dbpasswd}>
1551 <input type=hidden name=dbdefault value=$form->{dbdefault}>
1552
1553 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&rpw=$form->{rpw}">
1554
1555 <input type=hidden name=path value=$form->{path}>
1556 <input type=hidden name=rpw value=$form->{rpw}>
1557
1558 <input type=hidden name=nextsub value=dbcreate>
1559
1560 <hr size=3 noshade>
1561
1562 <br>
1563 <input type=submit class=submit name=action value="|
1564     . $locale->text('Continue') . qq|">
1565
1566   </td></tr>
1567 </table>
1568
1569 </form>
1570
1571
1572 </body>
1573 </html>
1574 |;
1575
1576 }
1577
1578 sub dbcreate {
1579
1580   $form->isblank("db", $locale->text('Dataset missing!'));
1581
1582   User->dbcreate(\%$form);
1583
1584   $form->{title} =
1585       "Lx-Office ERP "
1586     . $locale->text('Database Administration') . " / "
1587     . $locale->text('Create Dataset');
1588
1589   $form->header;
1590
1591   print qq|
1592 <body class=admin>
1593
1594
1595 <center>
1596 <h2>$form->{title}</h2>
1597
1598 <form method=post action=$form->{script}>|
1599
1600     . $locale->text('Dataset')
1601     . " $form->{db} "
1602     . $locale->text('successfully created!')
1603
1604     . qq|
1605
1606 <input type=hidden name=path value="$form->{path}">
1607 <input type=hidden name=rpw value="$form->{rpw}">
1608
1609 <input type=hidden name=nextsub value=list_users>
1610
1611 <p><input type=submit class=submit name=action value="|
1612     . $locale->text('Continue') . qq|">
1613 </form>
1614
1615
1616 </body>
1617 </html>
1618 |;
1619
1620 }
1621
1622 sub delete_dataset {
1623
1624   if (@dbsources = User->dbsources_unused(\%$form, $memberfile)) {
1625     foreach $item (sort @dbsources) {
1626       $dbsources .=
1627         qq|<input name=db class=radio type=radio value=$item>&nbsp;$item |;
1628     }
1629   } else {
1630     $form->error($locale->text('Nothing to delete!'));
1631   }
1632
1633   $form->{title} =
1634       "Lx-Office ERP "
1635     . $locale->text('Database Administration') . " / "
1636     . $locale->text('Delete Dataset');
1637
1638   $form->header;
1639
1640   print qq|
1641 <body class=admin>
1642
1643 <h2>$form->{title}</h2>
1644
1645 <form method=post action=$form->{script}>
1646
1647 <table width=100%>
1648   <tr class=listheading>
1649     <th>|
1650     . $locale->text('The following Datasets are not in use and can be deleted')
1651     . qq|</th>
1652   </tr>
1653
1654   <tr>
1655     <td>
1656     $dbsources
1657     </td>
1658   </tr>
1659
1660   <tr><td>
1661 <p>
1662 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1663 <input type=hidden name=dbuser value=$form->{dbuser}>
1664 <input type=hidden name=dbhost value=$form->{dbhost}>
1665 <input type=hidden name=dbport value=$form->{dbport}>
1666 <input type=hidden name=dbpasswd value=$form->{dbpasswd}>
1667 <input type=hidden name=dbdefault value=$form->{dbdefault}>
1668
1669 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&rpw=$form->{rpw}">
1670
1671 <input type=hidden name=path value="$form->{path}">
1672 <input type=hidden name=rpw value="$form->{rpw}">
1673
1674 <input type=hidden name=nextsub value=dbdelete>
1675
1676 <hr size=3 noshade>
1677
1678 <br>
1679 <input type=submit class=submit name=action value="|
1680     . $locale->text('Continue') . qq|">
1681
1682   </td></tr>
1683 </table>
1684
1685 </form>
1686
1687 </body>
1688 </html>
1689 |;
1690
1691 }
1692
1693 sub dbdelete {
1694
1695   if (!$form->{db}) {
1696     $form->error($locale->text('No Dataset selected!'));
1697   }
1698
1699   User->dbdelete(\%$form);
1700
1701   $form->{title} =
1702       "Lx-Office ERP "
1703     . $locale->text('Database Administration') . " / "
1704     . $locale->text('Delete Dataset');
1705
1706   $form->header;
1707
1708   print qq|
1709 <body class=admin>
1710
1711
1712 <center>
1713 <h2>$form->{title}</h2>
1714
1715 <form method=post action=$form->{script}>
1716
1717 $form->{db} | . $locale->text('successfully deleted!')
1718
1719     . qq|
1720
1721 <input type=hidden name=path value="$form->{path}">
1722 <input type=hidden name=rpw value="$form->{rpw}">
1723
1724 <input type=hidden name=nextsub value=list_users>
1725
1726 <p><input type=submit class=submit name=action value="|
1727     . $locale->text('Continue') . qq|">
1728 </form>
1729
1730
1731 </body>
1732 </html>
1733 |;
1734
1735 }
1736
1737 sub unlock_system {
1738
1739   unlink "$userspath/nologin";
1740
1741   $form->{callback} =
1742     "$form->{script}?action=list_users&path=$form->{path}&rpw=$root->{password}";
1743
1744   $form->redirect($locale->text('Lockfile removed!'));
1745
1746 }
1747
1748 sub lock_system {
1749
1750   open(FH, ">$userspath/nologin")
1751     or $form->error($locale->text('Cannot create Lock!'));
1752   close(FH);
1753
1754   $form->{callback} =
1755     "$form->{script}?action=list_users&path=$form->{path}&rpw=$root->{password}";
1756
1757   $form->redirect($locale->text('Lockfile created!'));
1758
1759 }