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