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