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