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