Uebernahme der kompletten Version, so wie sie Philip als "Demo-Version" gezeigt hat...
[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 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   @all = grep !/^\.\.?$/, readdir TEMPLATEDIR;
444   closedir TEMPLATEDIR;
445
446   @allhtml = sort grep /\.html/, @all;
447   @alldir = grep !/\.(html|tex|sty|odt)$/, @all;
448   @alldir = grep !/^(webpages|\.svn)$/, @alldir;
449
450   @allhtml = reverse grep !/Default/, @allhtml;
451   push @allhtml, 'Default';
452   @allhtml = reverse @allhtml;
453
454   foreach $item (@alldir) {
455     if ($item eq $myconfig->{templates}) {
456       $usetemplates .= qq|<option selected>$item\n|;
457     } else {
458       $usetemplates .= qq|<option>$item\n|;
459     }
460   }
461
462   $lastitem = $allhtml[0];
463   $lastitem =~ s/-.*//g;
464   $mastertemplates = qq|<option>$lastitem\n|;
465   foreach $item (@allhtml) {
466     $item =~ s/-.*//g;
467
468     if ($item ne $lastitem) {
469       my $selected = $item eq "German" ? " selected" : "";
470       $mastertemplates .= qq|<option$selected>$item\n|;
471       $lastitem = $item;
472     }
473   }
474
475   opendir CSS, "css/.";
476   @all = grep /.*\.css$/, readdir CSS;
477   closedir CSS;
478
479   foreach $item (@all) {
480     if ($item eq $myconfig->{stylesheet}) {
481       $selectstylesheet .= qq|<option selected>$item\n|;
482     } else {
483       $selectstylesheet .= qq|<option>$item\n|;
484     }
485   }
486   $selectstylesheet .= "<option>\n";
487
488   $form->header;
489
490   if ($myconfig->{menustyle} eq "neu") { $neu = "checked"; }
491   else { $old = "checked"; }
492
493   print qq|
494 <body class=admin>
495
496 <form method=post action=$form->{script}>
497
498 <table width=100%>
499   <tr class=listheading><th colspan=2>$form->{title}</th></tr>
500   <tr size=5></tr>
501   <tr valign=top>
502     <td>
503       <table>
504         <tr>
505           <th align=right>| . $locale->text('Login') . qq|</th>
506           <td><input name=login value="$myconfig->{login}"></td>
507         </tr>
508         <tr>
509           <th align=right>| . $locale->text('Password') . qq|</th>
510           <td><input type=password name=password size=8 value=$myconfig->{password}></td>
511           <input type=hidden name=old_password value=$myconfig->{password}>
512         </tr>
513         <tr>
514           <th align=right>| . $locale->text('Name') . qq|</th>
515           <td><input name=name size=15 value="$myconfig->{name}"></td>
516         </tr>
517         <tr>
518           <th align=right>| . $locale->text('E-mail') . qq|</th>
519           <td><input name=email size=30 value="$myconfig->{email}"></td>
520         </tr>
521         <tr valign=top>
522           <th align=right>| . $locale->text('Signature') . qq|</th>
523           <td><textarea name=signature rows=3 cols=35>$myconfig->{signature}</textarea></td>
524         </tr>
525         <tr>
526           <th align=right>| . $locale->text('Phone') . qq|</th>
527           <td><input name=tel size=14 value="$myconfig->{tel}"></td>
528         </tr>
529         <tr>
530           <th align=right>| . $locale->text('Fax') . qq|</th>
531           <td><input name=fax size=14 value="$myconfig->{fax}"></td>
532         </tr>
533         <tr>
534           <th align=right>| . $locale->text('Company') . qq|</th>
535           <td><input name=company size=35 value="$myconfig->{company}"></td>
536         </tr>
537         <tr valign=top>
538           <th align=right>| . $locale->text('Address') . qq|</th>
539           <td><textarea name=address rows=4 cols=35>$myconfig->{address}</textarea></td>
540         </tr>
541         <tr valign=top>
542           <th align=right>| . $locale->text('Steuernummer') . qq|</th>
543           <td><input name=steuernummer size=14 value="$myconfig->{steuernummer}"></td>
544         </tr>
545         <tr valign=top>
546           <th align=right>| . $locale->text('Ust-IDNr') . qq|</th>
547           <td><input name=co_ustid size=14 value="$myconfig->{co_ustid}"></td>
548         </tr>
549         <tr valign=top>
550           <th align=right>| . $locale->text('DUNS-Nr') . qq|</th>
551           <td><input name=duns size=14 value="$myconfig->{duns}"></td>
552         </tr>
553       </table>
554     </td>
555     <td>
556       <table>
557         <tr>
558           <th align=right>| . $locale->text('Date Format') . qq|</th>
559           <td><select name=dateformat>$dateformat</select></td>
560         </tr>
561         <tr>
562           <th align=right>| . $locale->text('Number Format') . qq|</th>
563           <td><select name=numberformat>$numberformat</select></td>
564         </tr>
565         <tr>
566           <th align=right>| . $locale->text('Dropdown Limit') . qq|</th>
567           <td><input name=vclimit value="$myconfig->{vclimit}"></td>
568         </tr>
569         <tr>
570           <th align=right>| . $locale->text('Language') . qq|</th>
571           <td><select name=countrycode>$countrycodes</select></td>
572         </tr>
573         <tr>
574           <th align=right>| . $locale->text('Character Set') . qq|</th>
575           <td><input name=charset value="$myconfig->{charset}"></td>
576         </tr>
577         <tr>
578           <th align=right>| . $locale->text('Stylesheet') . qq|</th>
579           <td><select name=userstylesheet>$selectstylesheet</select></td>
580         </tr>
581         <tr>
582           <th align=right>| . $locale->text('Printer') . qq|</th>
583           <td><input name=printer size=20 value="$myconfig->{printer}"></td>
584         </tr>
585         <tr>
586           <th align=right>| . $locale->text('Use Templates') . qq|</th>
587           <td><select name=usetemplates>$usetemplates</select></td>
588         </tr>
589         <tr>
590           <th align=right>| . $locale->text('New Templates') . qq|</th>
591           <td><input name=newtemplates></td>
592         </tr>
593         <tr>
594           <th align=right>| . $locale->text('Setup Templates') . qq|</th>
595           <td><select name=mastertemplates>$mastertemplates</select></td>
596         </tr>
597        <tr>
598            <th align=right>| . $locale->text('Setup Menu') . qq|</th>
599            <td><input name=menustyle type=radio class=radio value=neu $neu>&nbsp;New
600                  <input name=menustyle type=radio class=radio value=old $old>&nbsp;Old</td>
601          </tr>
602         <input type=hidden name=templates value=$myconfig->{templates}>
603       </table>
604     </td>
605   </tr>
606   <tr class=listheading>
607     <th colspan=2>| . $locale->text('Database') . qq|</th>
608   </tr>|;
609
610   # list section for database drivers
611   foreach $item (User->dbdrivers) {
612
613     print qq|
614   <tr>
615     <td colspan=2>
616       <table>
617         <tr>|;
618
619     $checked = "";
620     if ($myconfig->{dbdriver} eq $item) {
621       map { $form->{"${item}_$_"} = $myconfig->{$_} }
622         qw(dbhost dbport dbuser dbpasswd dbname sid);
623       $checked = "checked";
624     }
625
626     print qq|
627           <th align=right>| . $locale->text('Driver') . qq|</th>
628           <td><input name=dbdriver type=radio class=radio value=$item $checked>&nbsp;$item</td>
629           <th align=right>| . $locale->text('Host') . qq|</th>
630           <td><input name="${item}_dbhost" size=30 value=$form->{"${item}_dbhost"}></td>
631         </tr>
632         <tr>|;
633
634     if ($item eq 'Pg') {
635       print qq|
636           <th align=right>| . $locale->text('Dataset') . qq|</th>
637           <td><input name=Pg_dbname size=15 value=$form->{Pg_dbname}></td>
638           <th align=right>| . $locale->text('Port') . qq|</th>
639           <td><input name=Pg_dbport size=4 value=$form->{Pg_dbport}></td>
640         </tr>
641         <tr>
642           <th align=right>| . $locale->text('User') . qq|</th>
643           <td><input name="${item}_dbuser" size=15 value=$form->{"${item}_dbuser"}></td>
644           <th align=right>| . $locale->text('Password') . qq|</th>
645           <td><input name="${item}_dbpasswd" type=password size=10 value=$form->{"${item}_dbpasswd"}></td>
646         </tr>|;
647
648     }
649
650     if ($item eq 'Oracle') {
651       print qq|
652           <th align=right>SID</th>
653           <td><input name=Oracle_sid value=$form->{Oracle_sid}></td>
654           <th align=right>| . $locale->text('Port') . qq|</th>
655           <td><input name=Oracle_dbport size=4 value=$form->{Oracle_dbport}></td>
656         </tr>
657         <tr>
658           <th align=right>| . $locale->text('Dataset') . qq|</th>
659           <td><input name="${item}_dbuser" size=15 value=$form->{"${item}_dbuser"}></td>
660           <th align=right>| . $locale->text('Password') . qq|</th>
661           <td><input name="${item}_dbpasswd" type=password size=10 value=$form->{"${item}_dbpasswd"}></td>
662
663         </tr>|;
664     }
665
666     print qq|
667         <input type=hidden name=old_dbpasswd value=$myconfig->{dbpasswd}>
668       </table>
669     </td>
670   </tr>
671   <tr>
672     <td colspan=2><hr size=2 noshade></td>
673   </tr>
674 |;
675
676   }
677
678   # access control
679   open(FH, $menufile) or $form->error("$menufile : $!");
680
681   # scan for first menu level
682   @a = <FH>;
683   close(FH);
684
685   if (open(FH, "custom_$menufile")) {
686     push @a, <FH>;
687   }
688   close(FH);
689
690   foreach $item (@a) {
691     next unless $item =~ /\[/;
692     next if $item =~ /\#/;
693
694     $item =~ s/(\[|\])//g;
695     chop $item;
696
697     if ($item =~ /--/) {
698       ($level, $menuitem) = split /--/, $item, 2;
699     } else {
700       $level    = $item;
701       $menuitem = $item;
702       push @acsorder, $item;
703     }
704
705     push @{ $acs{$level} }, $menuitem;
706
707   }
708
709   %role = ('admin'      => $locale->text('Administrator'),
710            'user'       => $locale->text('User'),
711            'manager'    => $locale->text('Manager'),
712            'supervisor' => $locale->text('Supervisor'));
713
714   $selectrole = "";
715   foreach $item (qw(user supervisor manager admin)) {
716     $selectrole .=
717       ($myconfig->{role} eq $item)
718       ? "<option selected value=$item>$role{$item}\n"
719       : "<option value=$item>$role{$item}\n";
720   }
721
722   print qq|
723   <tr class=listheading>
724     <th colspan=2>| . $locale->text('Access Control') . qq|</th>
725   </tr>
726   <tr>
727     <td><select name=role>$selectrole</select></td>
728   </tr>
729 |;
730
731   foreach $item (split /;/, $myconfig->{acs}) {
732     ($key, $value) = split /--/, $item, 2;
733     $excl{$key}{$value} = 1;
734   }
735
736   foreach $key (@acsorder) {
737
738     $checked = "checked";
739     if ($form->{login}) {
740       $checked = ($excl{$key}{$key}) ? "" : "checked";
741     }
742
743     # can't have variable names with spaces
744     # the 1 is for apache 2
745     $item = $form->escape("${key}--$key", 1);
746
747     $acsheading = $key;
748     $acsheading =~ s/ /&nbsp;/g;
749
750     $acsheading = qq|
751     <th align=left><input name="$item" class=checkbox type=checkbox value=1 $checked>&nbsp;$acsheading</th>\n|;
752     $menuitems .= "$item;";
753     $acsdata = "
754     <td>";
755
756     foreach $item (@{ $acs{$key} }) {
757       next if ($key eq $item);
758
759       $checked = "checked";
760       if ($form->{login}) {
761         $checked = ($excl{$key}{$item}) ? "" : "checked";
762       }
763
764       $acsitem = $form->escape("${key}--$item", 1);
765
766       $acsdata .= qq|
767     <br><input name="$acsitem" class=checkbox type=checkbox value=1 $checked>&nbsp;$item|;
768       $menuitems .= "$acsitem;";
769     }
770
771     $acsdata .= "
772     </td>";
773
774     print qq|
775   <tr valign=top>$acsheading $acsdata
776   </tr>
777 |;
778   }
779
780   print qq|<input type=hidden name=acs value="$menuitems">
781 |;
782   if ($webdav) {
783     @webdavdirs =
784       qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen);
785     foreach $directory (@webdavdirs) {
786       if ($myconfig->{$directory}) {
787         $webdav{"${directory}c"} = "checked";
788       } else {
789         $webdav{"${directory}c"} = "";
790       }
791     }
792     print qq|
793    <tr>
794     <td colspan=2><hr size=3 noshade></td>
795   </tr>
796   <tr class=listheading>
797     <th colspan=2>| . $locale->text('WEBDAV-Zugriff') . qq|</th>
798   </tr>
799   <table width=100%>
800         <tr>
801         <td><input name=angebote class=checkbox type=checkbox value=1 $webdav{angebotec}>&nbsp;Angebot</td>
802         <td><input name=bestellungen class=checkbox type=checkbox value=1 $webdav{bestellungenc}>&nbsp;Bestellung</td>
803         <td><input name=rechnungen class=checkbox type=checkbox value=1 $webdav{rechnungenc}>&nbsp;Rechnung</td>
804         </tr>
805         <tr>
806         <td><input name=anfragen class=checkbox type=checkbox value=1 $webdav{anfragenc}>&nbsp;Angebot</td>
807         <td><input name=lieferantenbestellungen class=checkbox type=checkbox value=1 $webdav{lieferantenbestellungenc}>&nbsp;Lieferantenbestellung</td>
808         <td><input name=einkaufsrechnungen class=checkbox type=checkbox value=1 $webdav{einkaufsrechnungenc}>&nbsp;Einkaufsrechnung</td>
809         </tr>
810   </table>
811   <tr>
812     <td colspan=2><hr size=3 noshade></td>
813   </tr>
814 |;
815   }
816   print qq|
817 </table>
818 </div>
819 |;
820
821 }
822
823 sub save {
824
825   # no driver checked
826   $form->error($locale->text('Database Driver not checked!'))
827     unless $form->{dbdriver};
828
829   # no spaces allowed in login name
830   ($form->{login}) = split / /, $form->{login};
831
832   $form->isblank("login", $locale->text('Login name missing!'));
833
834   # check for duplicates
835   if (!$form->{edit}) {
836     $temp = new User "$memberfile", "$form->{login}";
837
838     if ($temp->{login}) {
839       $form->error("$form->{login} " . $locale->text('is already a member!'));
840     }
841   }
842
843   # no spaces allowed in directories
844   ($form->{newtemplates}) = split / /, $form->{newtemplates};
845
846   if ($form->{newtemplates}) {
847     $form->{templates} = $form->{newtemplates};
848   } else {
849     $form->{templates} =
850       ($form->{usetemplates}) ? $form->{usetemplates} : $form->{login};
851   }
852
853   # is there a basedir
854   if (!-d "$templates") {
855     $form->error(  $locale->text('Directory')
856                  . ": $templates "
857                  . $locale->text('does not exist'));
858   }
859
860   # add base directory to $form->{templates}
861   $form->{templates} = "$templates/$form->{templates}";
862
863   $myconfig = new User "$memberfile", "$form->{login}";
864
865   # redo acs variable and delete all the acs codes
866   @acs = split /;/, $form->{acs};
867
868   $form->{acs} = "";
869   foreach $item (@acs) {
870     $item = $form->escape($item, 1);
871
872     if (!$form->{$item}) {
873       $form->{acs} .= $form->unescape($form->unescape($item)) . ";";
874     }
875     delete $form->{$item};
876   }
877
878   # check which database was filled in
879   if ($form->{dbdriver} eq 'Oracle') {
880     $form->{sid}      = $form->{Oracle_sid},;
881     $form->{dbhost}   = $form->{Oracle_dbhost},;
882     $form->{dbport}   = $form->{Oracle_dbport};
883     $form->{dbpasswd} = $form->{Oracle_dbpasswd};
884     $form->{dbuser}   = $form->{Oracle_dbuser};
885     $form->{dbname}   = $form->{Oracle_dbuser};
886
887     $form->isblank("dbhost", $locale->text('Hostname missing!'));
888     $form->isblank("dbport", $locale->text('Port missing!'));
889     $form->isblank("dbuser", $locale->text('Dataset missing!'));
890   }
891   if ($form->{dbdriver} eq 'Pg') {
892     $form->{dbhost}   = $form->{Pg_dbhost};
893     $form->{dbport}   = $form->{Pg_dbport};
894     $form->{dbpasswd} = $form->{Pg_dbpasswd};
895     $form->{dbuser}   = $form->{Pg_dbuser};
896     $form->{dbname}   = $form->{Pg_dbname};
897
898     $form->isblank("dbname", $locale->text('Dataset missing!'));
899     $form->isblank("dbuser", $locale->text('Database User missing!'));
900   }
901
902   if ($webdav) {
903     @webdavdirs =
904       qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen);
905     foreach $directory (@webdavdirs) {
906       if ($form->{$directory}) {
907         $form->{$directory} = $form->{$directory};
908       } else {
909         $form->{$directory} = 0;
910       }
911     }
912   }
913
914   foreach $item (keys %{$form}) {
915     $myconfig->{$item} = $form->{$item};
916   }
917
918   delete $myconfig->{stylesheet};
919   if ($form->{userstylesheet}) {
920     $myconfig->{stylesheet} = $form->{userstylesheet};
921   }
922
923   $myconfig->save_member($memberfile, $userspath);
924
925   if ($webdav) {
926     @webdavdirs =
927       qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen);
928     foreach $directory (@webdavdirs) {
929       $file = "webdav/" . $directory . "/webdav-user";
930       if ($form->{$directory}) {
931         if (open(HTACCESS, "$file")) {
932           while (<HTACCESS>) {
933             ($login, $password) = split(/:/, $_);
934             if ($login ne $form->{login}) {
935               $newfile .= $_;
936             }
937           }
938           close(HTACCESS);
939         }
940         open(HTACCESS, "> $file") or die "cannot open $file $!\n";
941         $newfile .= $myconfig->{login} . ":" . $myconfig->{password} . "\n";
942         print(HTACCESS $newfile);
943         close(HTACCESS);
944       } else {
945         $form->{$directory} = 0;
946         if (open(HTACCESS, "$file")) {
947           while (<HTACCESS>) {
948             ($login, $password) = split(/:/, $_);
949             if ($login ne $form->{login}) {
950               $newfile .= $_;
951             }
952           }
953           close(HTACCESS);
954         }
955         open(HTACCESS, "> $file") or die "cannot open $file $!\n";
956         print(HTACCESS $newfile);
957         close(HTACCESS);
958       }
959     }
960   }
961
962   # create user template directory and copy master files
963   if (!-d "$form->{templates}") {
964     umask(002);
965
966     if (mkdir "$form->{templates}", oct("771")) {
967
968       umask(007);
969
970       # copy templates to the directory
971       opendir TEMPLATEDIR, "$templates/." or $form - error("$templates : $!");
972       @templates = grep /$form->{mastertemplates}.*?\.(html|tex|sty)$/,
973         readdir TEMPLATEDIR;
974       closedir TEMPLATEDIR;
975
976       foreach $file (@templates) {
977         open(TEMP, "$templates/$file")
978           or $form->error("$templates/$file : $!");
979
980         $file =~ s/$form->{mastertemplates}-//;
981         open(NEW, ">$form->{templates}/$file")
982           or $form->error("$form->{templates}/$file : $!");
983
984         while ($line = <TEMP>) {
985           print NEW $line;
986         }
987         close(TEMP);
988         close(NEW);
989       }
990     } else {
991       $form->error("$!: $form->{templates}");
992     }
993   }
994
995   $form->redirect($locale->text('User saved!'));
996
997 }
998
999 sub delete {
1000
1001   $form->{templates} =
1002     ($form->{templates})
1003     ? "$templates/$form->{templates}"
1004     : "$templates/$form->{login}";
1005
1006   $form->error($locale->text('File locked!')) if (-f ${memberfile} . LCK);
1007   open(FH, ">${memberfile}.LCK") or $form->error("${memberfile}.LCK : $!");
1008   close(FH);
1009
1010   open(CONF, "+<$memberfile") or $form->error("$memberfile : $!");
1011
1012   @config = <CONF>;
1013
1014   seek(CONF, 0, 0);
1015   truncate(CONF, 0);
1016
1017   while ($line = shift @config) {
1018
1019     if ($line =~ /^\[/) {
1020       last if ($line =~ /\[$form->{login}\]/);
1021       $login = &login_name($line);
1022     }
1023
1024     if ($line =~ /^templates=/) {
1025       $user{$login} = &get_value($line);
1026     }
1027
1028     print CONF $line;
1029   }
1030
1031   # remove everything up to next login or EOF
1032   # and save template variable
1033   while ($line = shift @config) {
1034     if ($line =~ /^templates=/) {
1035       $templatedir = &get_value($line);
1036     }
1037     last if ($line =~ /^\[/);
1038   }
1039
1040   # this one is either the next login or EOF
1041   print CONF $line;
1042
1043   $login = &login_name($line);
1044
1045   while ($line = shift @config) {
1046     if ($line =~ /^\[/) {
1047       $login = &login_name($line);
1048     }
1049
1050     if ($line =~ /^templates=/) {
1051       $user{$login} = &get_value($line);
1052     }
1053
1054     print CONF $line;
1055   }
1056
1057   close(CONF);
1058   unlink "${memberfile}.LCK";
1059
1060   # scan %user for $templatedir
1061   foreach $login (keys %user) {
1062     last if ($found = ($templatedir eq $user{$login}));
1063   }
1064
1065   # if found keep directory otherwise delete
1066   if (!$found) {
1067
1068     # delete it if there is a template directory
1069     $dir = "$form->{templates}";
1070     if (-d "$dir") {
1071       unlink <$dir/*.html>;
1072       unlink <$dir/*.tex>;
1073       unlink <$dir/*.sty>;
1074       rmdir "$dir";
1075     }
1076   }
1077
1078   # delete config file for user
1079   unlink "$userspath/$form->{login}.conf";
1080
1081   $form->redirect($locale->text('User deleted!'));
1082
1083 }
1084
1085 sub login_name {
1086   my $login = shift;
1087
1088   $login =~ s/\[\]//g;
1089   return ($login) ? $login : undef;
1090
1091 }
1092
1093 sub get_value {
1094   my $line = shift;
1095
1096   my ($null, $value) = split(/=/, $line, 2);
1097
1098   # remove comments
1099   $value =~ s/\s#.*//g;
1100
1101   # remove any trailing whitespace
1102   $value =~ s/^\s*(.*?)\s*$/$1/;
1103
1104   $value;
1105 }
1106
1107 sub change_admin_password {
1108
1109   $form->{title} =
1110       qq|Lx-Office ERP |
1111     . $locale->text('Administration') . " / "
1112     . $locale->text('Change Admin Password');
1113
1114   $form->header;
1115
1116   print qq|
1117 <body class=admin>
1118
1119
1120 <h2>| . $locale->text('Change Admin Password') . qq|</h2>
1121
1122 <form method=post action=$form->{script}>
1123
1124 <b>|
1125     . $locale->text('Password')
1126     . qq|</b> <input type=password name=password size=8>
1127
1128 <input type=hidden name=path value=$form->{path}>
1129 <input type=hidden name=rpw value=$form->{rpw}>
1130
1131 <p>
1132 <input type=submit class=submit name=action value="|
1133     . $locale->text('Change Password') . qq|">
1134
1135 </form>
1136
1137 </body>
1138 </html>
1139 |;
1140
1141 }
1142
1143 sub change_password {
1144
1145   $root->{password} = $form->{password};
1146
1147   $root->{'root login'} = 1;
1148   $root->save_member($memberfile);
1149
1150   $form->{callback} =
1151     "$form->{script}?action=list_users&path=$form->{path}&rpw=$root->{password}";
1152
1153   $form->redirect($locale->text('Password changed!'));
1154
1155 }
1156
1157 sub check_password {
1158   $root = new User "$memberfile", $form->{root};
1159
1160   if (!defined($root->{password}) || ($root->{password} ne $form->{rpw})) {
1161     $form->error($locale->text('Incorrect Password!'));
1162   }
1163
1164 }
1165
1166 sub pg_database_administration {
1167
1168   $form->{dbdriver} = 'Pg';
1169   &dbselect_source;
1170
1171 }
1172
1173 sub oracle_database_administration {
1174
1175   $form->{dbdriver} = 'Oracle';
1176   &dbselect_source;
1177
1178 }
1179
1180 sub dbdriver_defaults {
1181
1182   # load some defaults for the selected driver
1183   %driverdefaults = (
1184                      'Pg' => { dbport        => '5432',
1185                                dbuser        => 'postgres',
1186                                dbdefault     => 'template1',
1187                                dbhost        => 'localhost',
1188                                connectstring => $locale->text('Connect to')
1189                      },
1190                      'Oracle' => { dbport        => '1521',
1191                                    dbuser        => 'oralin',
1192                                    dbdefault     => $sid,
1193                                    dbhost        => `hostname`,
1194                                    connectstring => 'SID'
1195                      });
1196
1197   map { $form->{$_} = $driverdefaults{ $form->{dbdriver} }{$_} }
1198     keys %{ $driverdefaults{Pg} };
1199
1200 }
1201
1202 sub dbselect_source {
1203
1204   &dbdriver_defaults;
1205
1206   $msg{Pg} =
1207     $locale->text(
1208     'Leave host and port field empty unless you want to make a remote connection.'
1209     );
1210   $msg{Oracle} =
1211     $locale->text(
1212            'You must enter a host and port for local and remote connections!');
1213
1214   $form->{title} =
1215     "Lx-Office ERP / " . $locale->text('Database Administration');
1216
1217   $form->header;
1218
1219   print qq|
1220 <body class=admin>
1221
1222
1223 <center>
1224 <h2>$form->{title}</h2>
1225
1226 <form method=post action=$form->{script}>
1227
1228 <table>
1229 <tr><td>
1230
1231 <table>
1232
1233   <tr class=listheading>
1234     <th colspan=4>| . $locale->text('Database') . qq|</th>
1235   </tr>
1236
1237 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1238
1239   <tr><td>
1240    <table>
1241
1242   <tr>
1243
1244     <th align=right>| . $locale->text('Host') . qq|</th>
1245     <td><input name=dbhost size=25 value=$form->{dbhost}></td>
1246     <th align=right>| . $locale->text('Port') . qq|</th>
1247     <td><input name=dbport size=5 value=$form->{dbport}></td>
1248
1249   </tr>
1250
1251   <tr>
1252
1253     <th align=right>| . $locale->text('User') . qq|</th>
1254     <td><input name=dbuser size=10 value=$form->{dbuser}></td>
1255     <th align=right>| . $locale->text('Password') . qq|</th>
1256     <td><input type=password name=dbpasswd size=10></td>
1257
1258   </tr>
1259
1260   <tr>
1261
1262     <th align=right>$form->{connectstring}</th>
1263     <td colspan=3><input name=dbdefault size=10 value=$form->{dbdefault}></td>
1264
1265   </tr>
1266
1267 </table>
1268
1269 </td></tr>
1270 </table>
1271
1272 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&rpw=$form->{rpw}">
1273 <input type=hidden name=path value=$form->{path}>
1274 <input type=hidden name=rpw value=$form->{rpw}>
1275
1276 <br>
1277
1278 <input type=submit class=submit name=action value="|
1279     . $locale->text('Create Dataset') . qq|">
1280 <input type=submit class=submit name=action value="|
1281     . $locale->text('Update Dataset') . qq|">
1282 <input type=submit class=submit name=action value="|
1283     . $locale->text('Delete Dataset') . qq|">
1284
1285 </form>
1286
1287 </td></tr>
1288 </table>
1289
1290 <p>|
1291     . $locale->text(
1292     'This is a preliminary check for existing sources. Nothing will be created or deleted at this stage!'
1293     )
1294
1295     . qq|
1296 <br>$msg{$form->{dbdriver}}
1297
1298
1299 </body>
1300 </html>
1301 |;
1302
1303 }
1304
1305 sub continue {
1306
1307   &{ $form->{nextsub} };
1308
1309 }
1310
1311 sub update_dataset {
1312
1313   %needsupdate = User->dbneedsupdate(\%$form);
1314
1315   $form->{title} =
1316       "Lx-Office ERP "
1317     . $locale->text('Database Administration') . " / "
1318     . $locale->text('Update Dataset');
1319
1320   $form->header;
1321
1322   print qq|
1323 <body class=admin>
1324
1325
1326 <center>
1327 <h2>$form->{title}</h2>
1328 |;
1329
1330   foreach $key (sort keys %needsupdate) {
1331     if ($needsupdate{$key} ne $form->{dbversion}) {
1332       $upd .= qq|<input name="db$key" type=checkbox value=1 checked> $key\n|;
1333       $form->{dbupdate} .= "db$key ";
1334     }
1335   }
1336
1337   chop $form->{dbupdate};
1338
1339   if ($form->{dbupdate}) {
1340
1341     print qq|
1342 <table width=100%>
1343 <form method=post action=$form->{script}>
1344
1345 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1346 <input type=hidden name=dbhost value=$form->{dbhost}>
1347 <input type=hidden name=dbport value=$form->{dbport}>
1348 <input type=hidden name=dbuser value=$form->{dbuser}>
1349 <input type=hidden name=dbpasswd value=$form->{dbpasswd}>
1350 <input type=hidden name=dbdefault value=$form->{dbdefault}>
1351
1352 <tr class=listheading>
1353   <th>| . $locale->text('The following Datasets need to be updated') . qq|</th>
1354 </tr>
1355 <tr>
1356 <td>
1357
1358 $upd
1359
1360 </td>
1361 </tr>
1362 <tr>
1363 <td>
1364
1365 <input name=dbupdate type=hidden value="$form->{dbupdate}">
1366
1367 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&rpw=$form->{rpw}">
1368
1369 <input type=hidden name=path value=$form->{path}>
1370 <input type=hidden name=rpw value=$form->{rpw}>
1371
1372 <input type=hidden name=nextsub value=dbupdate>
1373
1374 <hr size=3 noshade>
1375
1376 <br>
1377 <input type=submit class=submit name=action value="|
1378       . $locale->text('Continue') . qq|">
1379
1380 </td></tr>
1381 </table>
1382 </form>
1383 |;
1384
1385   } else {
1386
1387     print $locale->text('All Datasets up to date!');
1388
1389   }
1390
1391   print qq|
1392
1393 </body>
1394 </html>
1395 |;
1396
1397 }
1398
1399 sub dbupdate {
1400
1401   User->dbupdate(\%$form);
1402
1403   $form->redirect($locale->text('Dataset updated!'));
1404
1405 }
1406
1407 sub create_dataset {
1408
1409   foreach $item (sort User->dbsources(\%$form)) {
1410     $dbsources .= "[$item] ";
1411   }
1412
1413   opendir SQLDIR, "sql/." or $form - error($!);
1414   foreach $item (sort grep /-chart\.sql/, readdir SQLDIR) {
1415     next if ($item eq 'Default-chart.sql');
1416     $item =~ s/-chart\.sql//;
1417     push @charts,
1418       qq| <input name=chart class=radio type=radio value="$item">&nbsp;$item|;
1419   }
1420   closedir SQLDIR;
1421
1422   $selectencoding = qq|<option>
1423   <option value=SQL_ASCII>ASCII
1424   <option value=EUC_JP>Japanese Extended UNIX Code
1425   <option value=EUC_CN>Chinese Extended UNIX Code
1426   <option value=EUC_KR>Korean Extended UNIX Code
1427   <option value=EUC_TW>Taiwan Extended UNIX Code
1428   <option value=UNICODE>UTF-8 Unicode
1429   <option value=MULE_INTERNAL>Mule internal type
1430   <option value=LATIN1>ISO 8859-1
1431   <option value=LATIN2>ISO 8859-2
1432   <option value=LATIN3>ISO 8859-3
1433   <option value=LATIN4>ISO 8859-4
1434   <option value=LATIN5>ISO 8859-5
1435   <option value=KOI8>KOI8-R
1436   <option value=WIN>Windows CP1251
1437   <option value=ALT>Windows CP866
1438   |;
1439
1440   $form->{title} =
1441       "Lx-Office ERP "
1442     . $locale->text('Database Administration') . " / "
1443     . $locale->text('Create Dataset');
1444
1445   $form->header;
1446
1447   print qq|
1448 <body class=admin>
1449
1450
1451 <center>
1452 <h2>$form->{title}</h2>
1453
1454 <form method=post action=$form->{script}>
1455
1456 <table width=100%>
1457   <tr class=listheading>
1458     <th colspan=2>&nbsp;</th>
1459   </tr>
1460
1461   <tr>
1462
1463     <th align=right nowrap>| . $locale->text('Existing Datasets') . qq|</th>
1464     <td>$dbsources</td>
1465
1466   </tr>
1467
1468   <tr>
1469
1470     <th align=right nowrap>| . $locale->text('Create Dataset') . qq|</th>
1471     <td><input name=db></td>
1472
1473   </tr>
1474
1475   <tr>
1476
1477     <th align=right nowrap>| . $locale->text('Multibyte Encoding') . qq|</th>
1478     <td><select name=encoding>$selectencoding</select></td>
1479
1480   </tr>
1481
1482   <tr>
1483
1484     <th align=right nowrap>|
1485     . $locale->text('Create Chart of Accounts') . qq|</th>
1486     <td>@charts</td>
1487
1488   </tr>
1489
1490   <tr><td colspan=2>
1491 <p>
1492 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1493 <input type=hidden name=dbuser value=$form->{dbuser}>
1494 <input type=hidden name=dbhost value=$form->{dbhost}>
1495 <input type=hidden name=dbport value=$form->{dbport}>
1496 <input type=hidden name=dbpasswd value=$form->{dbpasswd}>
1497 <input type=hidden name=dbdefault value=$form->{dbdefault}>
1498
1499 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&rpw=$form->{rpw}">
1500
1501 <input type=hidden name=path value=$form->{path}>
1502 <input type=hidden name=rpw value=$form->{rpw}>
1503
1504 <input type=hidden name=nextsub value=dbcreate>
1505
1506 <hr size=3 noshade>
1507
1508 <br>
1509 <input type=submit class=submit name=action value="|
1510     . $locale->text('Continue') . qq|">
1511
1512   </td></tr>
1513 </table>
1514
1515 </form>
1516
1517
1518 </body>
1519 </html>
1520 |;
1521
1522 }
1523
1524 sub dbcreate {
1525
1526   $form->isblank("db", $locale->text('Dataset missing!'));
1527
1528   User->dbcreate(\%$form);
1529
1530   $form->{title} =
1531       "Lx-Office ERP "
1532     . $locale->text('Database Administration') . " / "
1533     . $locale->text('Create Dataset');
1534
1535   $form->header;
1536
1537   print qq|
1538 <body class=admin>
1539
1540
1541 <center>
1542 <h2>$form->{title}</h2>
1543
1544 <form method=post action=$form->{script}>|
1545
1546     . $locale->text('Dataset')
1547     . " $form->{db} "
1548     . $locale->text('successfully created!')
1549
1550     . qq|
1551
1552 <input type=hidden name=path value="$form->{path}">
1553 <input type=hidden name=rpw value="$form->{rpw}">
1554
1555 <input type=hidden name=nextsub value=list_users>
1556
1557 <p><input type=submit class=submit name=action value="|
1558     . $locale->text('Continue') . qq|">
1559 </form>
1560
1561
1562 </body>
1563 </html>
1564 |;
1565
1566 }
1567
1568 sub delete_dataset {
1569
1570   if (@dbsources = User->dbsources_unused(\%$form, $memberfile)) {
1571     foreach $item (sort @dbsources) {
1572       $dbsources .=
1573         qq|<input name=db class=radio type=radio value=$item>&nbsp;$item |;
1574     }
1575   } else {
1576     $form->error($locale->text('Nothing to delete!'));
1577   }
1578
1579   $form->{title} =
1580       "Lx-Office ERP "
1581     . $locale->text('Database Administration') . " / "
1582     . $locale->text('Delete Dataset');
1583
1584   $form->header;
1585
1586   print qq|
1587 <body class=admin>
1588
1589 <h2>$form->{title}</h2>
1590
1591 <form method=post action=$form->{script}>
1592
1593 <table width=100%>
1594   <tr class=listheading>
1595     <th>|
1596     . $locale->text('The following Datasets are not in use and can be deleted')
1597     . qq|</th>
1598   </tr>
1599
1600   <tr>
1601     <td>
1602     $dbsources
1603     </td>
1604   </tr>
1605
1606   <tr><td>
1607 <p>
1608 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1609 <input type=hidden name=dbuser value=$form->{dbuser}>
1610 <input type=hidden name=dbhost value=$form->{dbhost}>
1611 <input type=hidden name=dbport value=$form->{dbport}>
1612 <input type=hidden name=dbpasswd value=$form->{dbpasswd}>
1613 <input type=hidden name=dbdefault value=$form->{dbdefault}>
1614
1615 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&rpw=$form->{rpw}">
1616
1617 <input type=hidden name=path value="$form->{path}">
1618 <input type=hidden name=rpw value="$form->{rpw}">
1619
1620 <input type=hidden name=nextsub value=dbdelete>
1621
1622 <hr size=3 noshade>
1623
1624 <br>
1625 <input type=submit class=submit name=action value="|
1626     . $locale->text('Continue') . qq|">
1627
1628   </td></tr>
1629 </table>
1630
1631 </form>
1632
1633 </body>
1634 </html>
1635 |;
1636
1637 }
1638
1639 sub dbdelete {
1640
1641   if (!$form->{db}) {
1642     $form->error($locale->text('No Dataset selected!'));
1643   }
1644
1645   User->dbdelete(\%$form);
1646
1647   $form->{title} =
1648       "Lx-Office ERP "
1649     . $locale->text('Database Administration') . " / "
1650     . $locale->text('Delete Dataset');
1651
1652   $form->header;
1653
1654   print qq|
1655 <body class=admin>
1656
1657
1658 <center>
1659 <h2>$form->{title}</h2>
1660
1661 <form method=post action=$form->{script}>
1662
1663 $form->{db} | . $locale->text('successfully deleted!')
1664
1665     . qq|
1666
1667 <input type=hidden name=path value="$form->{path}">
1668 <input type=hidden name=rpw value="$form->{rpw}">
1669
1670 <input type=hidden name=nextsub value=list_users>
1671
1672 <p><input type=submit class=submit name=action value="|
1673     . $locale->text('Continue') . qq|">
1674 </form>
1675
1676
1677 </body>
1678 </html>
1679 |;
1680
1681 }
1682
1683 sub unlock_system {
1684
1685   unlink "$userspath/nologin";
1686
1687   $form->{callback} =
1688     "$form->{script}?action=list_users&path=$form->{path}&rpw=$root->{password}";
1689
1690   $form->redirect($locale->text('Lockfile removed!'));
1691
1692 }
1693
1694 sub lock_system {
1695
1696   open(FH, ">$userspath/nologin")
1697     or $form->error($locale->text('Cannot create Lock!'));
1698   close(FH);
1699
1700   $form->{callback} =
1701     "$form->{script}?action=list_users&path=$form->{path}&rpw=$root->{password}";
1702
1703   $form->redirect($locale->text('Lockfile created!'));
1704
1705 }