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