1 #=====================================================================
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
7 #=====================================================================
8 # SQL-Ledger Accounting
11 # Author: Dieter Simader
12 # Email: dsimader@sql-ledger.org
13 # Web: http://www.sql-ledger.org
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.
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 #======================================================================
31 # add/edit/delete users
33 #======================================================================
35 $menufile = "menu.ini";
44 require "bin/mozilla/common.pl";
46 our $cgi = new CGI('');
49 $form->{"root"} = "root login";
51 $locale = new Locale $language, "admin";
54 if (-f "bin/mozilla/custom_$form->{script}") {
55 eval { require "bin/mozilla/custom_$form->{script}"; };
56 $form->error($@) if ($@);
59 $form->{stylesheet} = "lx-office-erp.css";
60 $form->{favicon} = "favicon.ico";
62 if ($form->{action}) {
65 $subroutine = $locale->findsub($form->{action});
67 if ($subroutine eq 'login') {
69 $form->{rpw} = crypt $form->{rpw}, "ro";
75 call_sub($subroutine);
79 # if there are no drivers bail out
80 $form->error($locale->text('No Database Drivers available!'))
81 unless (User->dbdrivers);
84 if (!-f $memberfile) {
85 open(FH, ">$memberfile") or $form->error("$memberfile : $!");
86 print FH qq|# SQL-Ledger Accounting members
106 qq|Lx-Office ERP $form->{version} | . $locale->text('Administration');
109 print $form->parse_html_template('admin/adminlogin');
118 $form->error($locale->text('File locked!')) if (-f "${memberfile}.LCK");
120 open(FH, "$memberfile") or $form->error("$memberfile : $!");
129 $login =~ s/(\[|\])//g;
131 $members{$login} = { "login" => $login };
134 if (/^([a-z]+)=(.*)/) {
135 $members{$login}->{$1} = $2;
141 delete $members{"root login"};
142 map { $_->{templates} =~ s|.*/||; } values %members;
144 $form->{title} = "Lx-Office ERP " . $locale->text('Administration');
145 $form->{LOCKED} = -e "$userspath/nologin";
146 $form->{MEMBERS} = [ @members{sort { lc $a cmp lc $b } keys %members} ];
149 print $form->parse_html_template("admin/list_users");
156 . $locale->text('Administration') . " / "
157 . $locale->text('Add User');
159 $form->{Oracle_sid} = $sid;
160 $form->{Oracle_dbport} = '1521';
161 $form->{Oracle_dbhost} = `hostname`;
163 if (-f "css/lx-office-erp.css") {
164 $myconfig->{stylesheet} = "lx-office-erp.css";
167 $myconfig->{vclimit} = 200;
168 $myconfig->{countrycode} = "de";
169 $myconfig->{numberformat} = "1000,00";
170 $myconfig->{dateformat} = "dd.mm.yy";
181 . $locale->text('Administration') . " / "
182 . $locale->text('Edit User');
194 qq|<input type=submit class=submit name=action value="|
195 . $locale->text('Delete') . qq|">
196 <input type=hidden name=edit value=1>|;
201 <input name=callback type=hidden value="$form->{script}?action=list_users&rpw=$form->{rpw}">
202 <input type=hidden name=rpw value=$form->{rpw}>
204 <input type=submit class=submit name=action value="|
205 . $locale->text('Save') . qq|">
218 # if there is a login, get user
219 if ($form->{login}) {
222 $myconfig = new User "$memberfile", "$form->{login}";
224 $myconfig->{signature} =~ s/\\n/\r\n/g;
225 $myconfig->{address} =~ s/\\n/\r\n/g;
227 # strip basedir from templates directory
228 $myconfig->{templates} =~ s/^$templates\///;
230 # $myconfig->{dbpasswd} = unpack 'u', $myconfig->{dbpasswd};
233 foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
235 ($item eq $myconfig->{dateformat})
236 ? "<option selected>$item\n"
240 foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
242 ($item eq $myconfig->{numberformat})
243 ? "<option selected>$item\n"
247 %countrycodes = User->country_codes;
249 foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} }
253 ($myconfig->{countrycode} eq $key)
254 ? "<option selected value=$key>$countrycodes{$key}"
255 : "<option value=$key>$countrycodes{$key}";
257 $countrycodes = qq|<option value="">American English\n$countrycodes|;
259 # is there a templates basedir
260 if (!-d "$templates") {
261 $form->error( $locale->text('Directory')
263 . $locale->text('does not exist'));
266 opendir TEMPLATEDIR, "$templates/." or $form->error("$templates : $!");
267 my @all = readdir(TEMPLATEDIR);
268 my @alldir = sort(grep({ -d "$templates/$_" && !/^\.\.?$/ } @all));
269 my @allhtml = sort(grep({ -f "$templates/$_" && /\.html$/ } @all));
270 closedir TEMPLATEDIR;
272 @alldir = grep !/\.(html|tex|sty|odt|xml|txb)$/, @alldir;
273 @alldir = grep !/^(webpages|\.svn)$/, @alldir;
275 @allhtml = reverse grep !/Default/, @allhtml;
276 push @allhtml, 'Default';
277 @allhtml = reverse @allhtml;
279 foreach $item (@alldir) {
280 if ($item eq $myconfig->{templates}) {
281 $usetemplates .= qq|<option selected>$item\n|;
283 $usetemplates .= qq|<option>$item\n|;
287 $lastitem = $allhtml[0];
288 $lastitem =~ s/-.*//g;
289 $mastertemplates = qq|<option>$lastitem\n|;
290 foreach $item (@allhtml) {
293 if ($item ne $lastitem) {
294 my $selected = $item eq "German" ? " selected" : "";
295 $mastertemplates .= qq|<option$selected>$item\n|;
300 # opendir CSS, "css/.";
301 # @all = grep /.*\.css$/, readdir CSS;
304 # css dir has styles that are not intended as general layouts.
305 # reverting to hardcoded list
306 @all = qw(lx-office-erp.css Win2000.css);
308 foreach $item (@all) {
309 if ($item eq $myconfig->{stylesheet}) {
310 $selectstylesheet .= qq|<option selected>$item\n|;
312 $selectstylesheet .= qq|<option>$item\n|;
318 if ($myconfig->{menustyle} eq "v3") {
319 $menustyle_v3 = "checked";
320 } elsif ($myconfig->{menustyle} eq "neu") {
321 $menustyle_neu = "checked";
323 $menustyle_old = "checked";
329 <form method=post action=$form->{script}>
332 <tr class=listheading><th colspan=2>$form->{title}</th></tr>
338 <th align=right>| . $locale->text('Login') . qq|</th>
339 <td><input name="login" value="$myconfig->{login}"></td>
342 <th align=right>| . $locale->text('Password') . qq|</th>
343 <td><input type="password" name="password" size="8" value="$myconfig->{password}"></td>
344 <input type="hidden" name="old_password" value="$myconfig->{password}">
347 <th align=right>| . $locale->text('Name') . qq|</th>
348 <td><input name="name" size="15" value="$myconfig->{name}"></td>
351 <th align=right>| . $locale->text('E-mail') . qq|</th>
352 <td><input name=email size=30 value="$myconfig->{email}"></td>
355 <th align=right>| . $locale->text('Signature') . qq|</th>
356 <td><textarea name=signature rows=3 cols=35>$myconfig->{signature}</textarea></td>
359 <th align=right>| . $locale->text('Phone') . qq|</th>
360 <td><input name=tel size=14 value="$myconfig->{tel}"></td>
363 <th align=right>| . $locale->text('Fax') . qq|</th>
364 <td><input name=fax size=14 value="$myconfig->{fax}"></td>
367 <th align=right>| . $locale->text('Company') . qq|</th>
368 <td><input name=company size=35 value="$myconfig->{company}"></td>
371 <th align=right>| . $locale->text('Address') . qq|</th>
372 <td><textarea name=address rows=4 cols=35>$myconfig->{address}</textarea></td>
375 <th align=right>| . $locale->text('Tax number') . qq|</th>
376 <td><input name=taxnumber size=14 value="$myconfig->{taxnumber}"></td>
379 <th align=right>| . $locale->text('Ust-IDNr') . qq|</th>
380 <td><input name=co_ustid size=14 value="$myconfig->{co_ustid}"></td>
383 <th align=right>| . $locale->text('DUNS-Nr') . qq|</th>
384 <td><input name=duns size=14 value="$myconfig->{duns}"></td>
391 <th align=right>| . $locale->text('Date Format') . qq|</th>
392 <td><select name=dateformat>$dateformat</select></td>
395 <th align=right>| . $locale->text('Number Format') . qq|</th>
396 <td><select name=numberformat>$numberformat</select></td>
399 <th align=right>| . $locale->text('Dropdown Limit') . qq|</th>
400 <td><input name=vclimit value="$myconfig->{vclimit}"></td>
403 <th align=right>| . $locale->text('Language') . qq|</th>
404 <td><select name=countrycode>$countrycodes</select></td>
407 <th align=right>| . $locale->text('Stylesheet') . qq|</th>
408 <td><select name=userstylesheet>$selectstylesheet</select></td>
411 <th align=right>| . $locale->text('Printer') . qq|</th>
412 <td><input name=printer size=20 value="$myconfig->{printer}"></td>
415 <th align=right>| . $locale->text('Use Templates') . qq|</th>
416 <td><select name=usetemplates>$usetemplates</select></td>
419 <th align=right>| . $locale->text('New Templates') . qq|</th>
420 <td><input name=newtemplates></td>
423 <th align=right>| . $locale->text('Setup Templates') . qq|</th>
424 <td><select name=mastertemplates>$mastertemplates</select></td>
427 <th align=right>| . $locale->text('Setup Menu') . qq|</th>
428 <td><input name=menustyle type=radio class=radio value=v3 $menustyle_v3> | .
429 $locale->text("Top (CSS)") . qq|
430 <input name=menustyle type=radio class=radio value=neu $menustyle_neu> | .
431 $locale->text("Top (Javascript)") . qq|
432 <input name=menustyle type=radio class=radio value=old $menustyle_old> | .
433 $locale->text("Old (on the side)") . qq|
436 <input type=hidden name=templates value=$myconfig->{templates}>
440 <tr class=listheading>
441 <th colspan=2>| . $locale->text('Database') . qq|</th>
444 # list section for database drivers
445 foreach $item (User->dbdrivers) {
454 if ($myconfig->{dbdriver} eq $item) {
455 map { $form->{"${item}_$_"} = $myconfig->{$_} }
456 qw(dbhost dbport dbuser dbpasswd dbname sid);
457 $checked = "checked";
461 <th align=right>| . $locale->text('Driver') . qq|</th>
462 <td><input name="dbdriver" type="radio" class="radio" value="$item" $checked> $item</td>
463 <th align=right>| . $locale->text('Host') . qq|</th>
464 <td><input name="${item}_dbhost" size=30 value="$form->{"${item}_dbhost"}"></td>
471 <th align=right>| . $locale->text('Dataset') . qq|</th>
472 <td><input name="Pg_dbname" size="15" value="$form->{Pg_dbname}"></td>
473 <th align=right>| . $locale->text('Port') . qq|</th>
474 <td><input name="Pg_dbport" size="4" value="$form->{Pg_dbport}"></td>
477 <th align=right>| . $locale->text('User') . qq|</th>
478 <td><input name="${item}_dbuser" size=15 value="$form->{"${item}_dbuser"}"></td>
479 <th align=right>| . $locale->text('Password') . qq|</th>
480 <td><input name="${item}_dbpasswd" type=password size=10 value="$form->{"${item}_dbpasswd"}"></td>
485 if ($item eq 'Oracle') {
487 <th align=right>SID</th>
488 <td><input name=Oracle_sid value=$form->{Oracle_sid}></td>
489 <th align=right>| . $locale->text('Port') . qq|</th>
490 <td><input name=Oracle_dbport size=4 value=$form->{Oracle_dbport}></td>
493 <th align=right>| . $locale->text('Dataset') . qq|</th>
494 <td><input name="${item}_dbuser" size=15 value=$form->{"${item}_dbuser"}></td>
495 <th align=right>| . $locale->text('Password') . qq|</th>
496 <td><input name="${item}_dbpasswd" type=password size=10 value="$form->{"${item}_dbpasswd"}"></td>
502 <input type="hidden" name="old_dbpasswd" value="$myconfig->{dbpasswd}">
507 <td colspan=2><hr size=2 noshade></td>
514 open(FH, $menufile) or $form->error("$menufile : $!");
516 # scan for first menu level
521 next unless $item =~ /\[/;
522 next if $item =~ /\#/;
524 $item =~ s/(\[|\])//g;
528 ($level, $menuitem) = split /--/, $item, 2;
532 push @acsorder, $item;
535 push @{ $acs{$level} }, $menuitem;
539 %role = ('admin' => $locale->text('Administrator'),
540 'user' => $locale->text('User'),
541 'manager' => $locale->text('Manager'),
542 'supervisor' => $locale->text('Supervisor'));
545 foreach $item (qw(user supervisor manager admin)) {
547 ($myconfig->{role} eq $item)
548 ? "<option selected value=$item>$role{$item}\n"
549 : "<option value=$item>$role{$item}\n";
553 <tr class=listheading>
554 <th colspan=2>| . $locale->text('Access Control') . qq|</th>
557 <td><select name=role>$selectrole</select></td>
561 foreach $item (split(/;/, $myconfig->{acs})) {
562 ($key, $value) = split /--/, $item, 2;
563 $excl{$key}{$value} = 1;
566 foreach $key (@acsorder) {
568 $checked = "checked";
569 if ($form->{login}) {
570 $checked = ($excl{$key}{$key}) ? "" : "checked";
573 # can't have variable names with spaces
574 # the 1 is for apache 2
575 $item = $form->escape("${key}--$key", 1);
578 $acsheading =~ s/ / /g;
581 <th align=left><input name="$item" class=checkbox type=checkbox value=1 $checked> $acsheading</th>\n|;
582 $menuitems .= "$item;";
586 foreach $item (@{ $acs{$key} }) {
587 next if ($key eq $item);
589 $checked = "checked";
590 if ($form->{login}) {
591 $checked = ($excl{$key}{$item}) ? "" : "checked";
594 $acsitem = $form->escape("${key}--$item", 1);
597 <br><input name="$acsitem" class=checkbox type=checkbox value=1 $checked> $item|;
598 $menuitems .= "$acsitem;";
605 <tr valign=top>$acsheading $acsdata
610 print qq|<input type=hidden name=acs value="$menuitems">
614 qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen);
615 foreach $directory (@webdavdirs) {
616 if ($myconfig->{$directory}) {
617 $webdav{"${directory}c"} = "checked";
619 $webdav{"${directory}c"} = "";
624 <td colspan=2><hr size=3 noshade></td>
626 <tr class=listheading>
627 <th colspan=2>| . $locale->text('WEBDAV-Zugriff') . qq|</th>
631 <td><input name=angebote class=checkbox type=checkbox value=1 $webdav{angebotec}> Angebot</td>
632 <td><input name=bestellungen class=checkbox type=checkbox value=1 $webdav{bestellungenc}> Bestellung</td>
633 <td><input name=rechnungen class=checkbox type=checkbox value=1 $webdav{rechnungenc}> Rechnung</td>
636 <td><input name=anfragen class=checkbox type=checkbox value=1 $webdav{anfragenc}> Angebot</td>
637 <td><input name=lieferantenbestellungen class=checkbox type=checkbox value=1 $webdav{lieferantenbestellungenc}> Lieferantenbestellung</td>
638 <td><input name=einkaufsrechnungen class=checkbox type=checkbox value=1 $webdav{einkaufsrechnungenc}> Einkaufsrechnung</td>
642 <td colspan=2><hr size=3 noshade></td>
656 $form->error($locale->text('Database Driver not checked!'))
657 unless $form->{dbdriver};
659 # no spaces allowed in login name
660 ($form->{login}) = split / /, $form->{login};
662 $form->isblank("login", $locale->text('Login name missing!'));
664 # check for duplicates
665 if (!$form->{edit}) {
666 $temp = new User "$memberfile", "$form->{login}";
668 if ($temp->{login}) {
669 $form->error("$form->{login} " . $locale->text('is already a member!'));
673 # no spaces allowed in directories
674 ($form->{newtemplates}) = split / /, $form->{newtemplates};
676 if ($form->{newtemplates}) {
677 $form->{templates} = $form->{newtemplates};
680 ($form->{usetemplates}) ? $form->{usetemplates} : $form->{login};
684 if (!-d "$templates") {
685 $form->error( $locale->text('Directory')
687 . $locale->text('does not exist'));
690 # add base directory to $form->{templates}
691 $form->{templates} = "$templates/$form->{templates}";
693 $myconfig = new User "$memberfile", "$form->{login}";
695 # redo acs variable and delete all the acs codes
696 @acs = split(/;/, $form->{acs});
699 foreach $item (@acs) {
700 $item = $form->escape($item, 1);
702 if (!$form->{$item}) {
703 $form->{acs} .= $form->unescape($form->unescape($item)) . ";";
705 delete $form->{$item};
708 # check which database was filled in
709 if ($form->{dbdriver} eq 'Oracle') {
710 $form->{sid} = $form->{Oracle_sid},;
711 $form->{dbhost} = $form->{Oracle_dbhost},;
712 $form->{dbport} = $form->{Oracle_dbport};
713 $form->{dbpasswd} = $form->{Oracle_dbpasswd};
714 $form->{dbuser} = $form->{Oracle_dbuser};
715 $form->{dbname} = $form->{Oracle_dbuser};
717 $form->isblank("dbhost", $locale->text('Hostname missing!'));
718 $form->isblank("dbport", $locale->text('Port missing!'));
719 $form->isblank("dbuser", $locale->text('Dataset missing!'));
721 if ($form->{dbdriver} eq 'Pg') {
722 $form->{dbhost} = $form->{Pg_dbhost};
723 $form->{dbport} = $form->{Pg_dbport};
724 $form->{dbpasswd} = $form->{Pg_dbpasswd};
725 $form->{dbuser} = $form->{Pg_dbuser};
726 $form->{dbname} = $form->{Pg_dbname};
728 $form->isblank("dbname", $locale->text('Dataset missing!'));
729 $form->isblank("dbuser", $locale->text('Database User missing!'));
734 qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen);
735 foreach $directory (@webdavdirs) {
736 if ($form->{$directory}) {
737 $form->{$directory} = $form->{$directory};
739 $form->{$directory} = 0;
744 foreach $item (keys %{$form}) {
745 $myconfig->{$item} = $form->{$item};
748 delete $myconfig->{stylesheet};
749 if ($form->{userstylesheet}) {
750 $myconfig->{stylesheet} = $form->{userstylesheet};
753 $myconfig->save_member($memberfile, $userspath);
757 qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen);
758 foreach $directory (@webdavdirs) {
759 $file = "webdav/" . $directory . "/webdav-user";
760 if ($form->{$directory}) {
761 if (open(HTACCESS, "$file")) {
763 ($login, $password) = split(/:/, $_);
764 if ($login ne $form->{login}) {
770 open(HTACCESS, "> $file") or die "cannot open $file $!\n";
771 $newfile .= $myconfig->{login} . ":" . $myconfig->{password} . "\n";
772 print(HTACCESS $newfile);
775 $form->{$directory} = 0;
776 if (open(HTACCESS, "$file")) {
778 ($login, $password) = split(/:/, $_);
779 if ($login ne $form->{login}) {
785 open(HTACCESS, "> $file") or die "cannot open $file $!\n";
786 print(HTACCESS $newfile);
792 $form->{templates} =~ s|.*/||;
793 $form->{templates} = "${templates}/$form->{templates}";
794 $form->{mastertemplates} =~ s|.*/||;
796 # create user template directory and copy master files
797 if (!-d "$form->{templates}") {
800 if (mkdir "$form->{templates}", oct("771")) {
804 # copy templates to the directory
805 opendir TEMPLATEDIR, "$templates/." or $form - error("$templates : $!");
806 @templates = grep /$form->{mastertemplates}.*?\.(html|tex|sty|xml|txb)$/,
808 closedir TEMPLATEDIR;
810 foreach $file (@templates) {
811 open(TEMP, "$templates/$file")
812 or $form->error("$templates/$file : $!");
814 $file =~ s/$form->{mastertemplates}-//;
815 open(NEW, ">$form->{templates}/$file")
816 or $form->error("$form->{templates}/$file : $!");
818 while ($line = <TEMP>) {
825 $form->error("$!: $form->{templates}");
829 $form->redirect($locale->text('User saved!'));
837 ? "$templates/$form->{templates}"
838 : "$templates/$form->{login}";
840 $form->error($locale->text('File locked!')) if (-f ${memberfile} . LCK);
841 open(FH, ">${memberfile}.LCK") or $form->error("${memberfile}.LCK : $!");
844 open(CONF, "+<$memberfile") or $form->error("$memberfile : $!");
851 while ($line = shift @config) {
853 if ($line =~ /^\[/) {
854 last if ($line =~ /\[$form->{login}\]/);
855 $login = login_name($line);
858 if ($line =~ /^templates=/) {
859 $user{$login} = get_value($line);
865 # remove everything up to next login or EOF
866 # and save template variable
867 while ($line = shift @config) {
868 if ($line =~ /^templates=/) {
869 $templatedir = get_value($line);
871 last if ($line =~ /^\[/);
874 # this one is either the next login or EOF
877 $login = login_name($line);
879 while ($line = shift @config) {
880 if ($line =~ /^\[/) {
881 $login = login_name($line);
884 if ($line =~ /^templates=/) {
885 $user{$login} = get_value($line);
892 unlink "${memberfile}.LCK";
894 # scan %user for $templatedir
895 foreach $login (keys %user) {
896 last if ($found = ($templatedir eq $user{$login}));
899 # if found keep directory otherwise delete
902 # delete it if there is a template directory
903 $dir = "$form->{templates}";
905 unlink <$dir/*.html>;
912 # delete config file for user
913 unlink "$userspath/$form->{login}.conf";
915 $form->redirect($locale->text('User deleted!'));
923 return ($login) ? $login : undef;
930 my ($null, $value) = split(/=/, $line, 2);
933 $value =~ s/\s#.*//g;
935 # remove any trailing whitespace
936 $value =~ s/^\s*(.*?)\s*$/$1/;
941 sub change_admin_password {
945 . $locale->text('Administration') . " / "
946 . $locale->text('Change Admin Password');
949 print $form->parse_html_template("admin/change_admin_password");
952 sub change_password {
953 if ($form->{"password"} ne $form->{"password_again"}) {
956 . $locale->text('Administration') . " / "
957 . $locale->text('Change Admin Password');
960 $form->error($locale->text("The passwords do not match."));
963 $root->{password} = $form->{password};
965 $root->{'root login'} = 1;
966 $root->save_member($memberfile);
969 "$form->{script}?action=list_users&rpw=$root->{password}";
971 $form->redirect($locale->text('Password changed!'));
975 $root = new User "$memberfile", $form->{root};
977 if (!defined($root->{password}) || ($root->{password} ne $form->{rpw})) {
978 $form->error($locale->text('Incorrect Password!'));
983 sub pg_database_administration {
985 $form->{dbdriver} = 'Pg';
990 sub oracle_database_administration {
992 $form->{dbdriver} = 'Oracle';
997 sub dbdriver_defaults {
999 # load some defaults for the selected driver
1001 'Pg' => { dbport => '5432',
1002 dbuser => 'postgres',
1003 dbdefault => 'template1',
1004 dbhost => 'localhost',
1005 connectstring => $locale->text('Connect to')
1007 'Oracle' => { dbport => '1521',
1010 dbhost => `hostname`,
1011 connectstring => 'SID'
1014 map { $form->{$_} = $driverdefaults{ $form->{dbdriver} }{$_} }
1015 keys %{ $driverdefaults{Pg} };
1019 sub dbselect_source {
1021 dbdriver_defaults();
1025 'Leave host and port field empty unless you want to make a remote connection.'
1029 'You must enter a host and port for local and remote connections!');
1032 "Lx-Office ERP / " . $locale->text('Database Administration');
1041 <h2>$form->{title}</h2>
1043 <form method=post action=$form->{script}>
1050 <tr class=listheading>
1051 <th colspan=4>| . $locale->text('Database') . qq|</th>
1054 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1061 <th align=right>| . $locale->text('Host') . qq|</th>
1062 <td><input name=dbhost size=25 value=$form->{dbhost}></td>
1063 <th align=right>| . $locale->text('Port') . qq|</th>
1064 <td><input name=dbport size=5 value=$form->{dbport}></td>
1070 <th align=right>| . $locale->text('User') . qq|</th>
1071 <td><input name="dbuser" size="10" value="$form->{dbuser}"></td>
1072 <th align=right>| . $locale->text('Password') . qq|</th>
1073 <td><input type="password" name="dbpasswd" size="10"></td>
1079 <th align=right>$form->{connectstring}</th>
1080 <td colspan=3><input name=dbdefault size=10 value=$form->{dbdefault}></td>
1089 <input name=callback type=hidden value="$form->{script}?action=list_users&rpw=$form->{rpw}">
1090 <input type=hidden name=rpw value=$form->{rpw}>
1094 <input type=submit class=submit name=action value="|
1095 . $locale->text('Create Dataset') . qq|">|;
1096 # Vorübergehend Deaktiviert
1097 # <input type=submit class=submit name=action value="|
1098 # . $locale->text('Update Dataset') . qq|">
1099 print qq| <input type=submit class=submit name=action value="|
1100 . $locale->text('Delete Dataset') . qq|">
1109 'This is a preliminary check for existing sources. Nothing will be created or deleted at this stage!'
1113 <br>$msg{$form->{dbdriver}}
1123 call_sub($form->{"nextsub"});
1126 sub update_dataset {
1128 %needsupdate = User->dbneedsupdate(\%$form);
1132 . $locale->text('Database Administration') . " / "
1133 . $locale->text('Update Dataset');
1142 <h2>$form->{title}</h2>
1145 foreach $key (sort keys %needsupdate) {
1146 if ($needsupdate{$key} ne $form->{dbversion}) {
1147 $upd .= qq|<input id="$field_id" name="db$key" type="checkbox" value="1" checked> $key\n|;
1148 $form->{dbupdate} .= "db$key ";
1153 chop $form->{dbupdate};
1155 if ($form->{dbupdate}) {
1159 <form method=post action=$form->{script}>
1161 <input type=hidden name="dbdriver" value="$form->{dbdriver}">
1162 <input type=hidden name="dbhost" value="$form->{dbhost}">
1163 <input type=hidden name="dbport" value="$form->{dbport}">
1164 <input type=hidden name="dbuser" value="$form->{dbuser}">
1165 <input type=hidden name="dbpasswd" value="$form->{dbpasswd}">
1166 <input type=hidden name="dbdefault" value="$form->{dbdefault}">
1168 <tr class=listheading>
1169 <th>| . $locale->text('The following Datasets need to be updated') . qq|</th>
1181 <input name=dbupdate type=hidden value="$form->{dbupdate}">
1183 <input name=callback type=hidden value="$form->{script}?action=list_users&rpw=$form->{rpw}">
1185 <input type=hidden name=rpw value=$form->{rpw}>
1187 <input type=hidden name=nextsub value=dbupdate>
1192 <input type=submit class=submit name=action value="|
1193 . $locale->text('Continue') . qq|">
1202 print $locale->text('All Datasets up to date!');
1215 $form->{"stylesheet"} = "lx-office-erp.css";
1216 $form->{"title"} = $main::locale->text("Dataset upgrade");
1220 map({ s/\s//g; s/^db//; $_; }
1221 grep({ $form->{$_} }
1222 split(/\s+/, $form->{"dbupdate"}))));
1223 print($form->parse_html_template("dbupgrade/header",
1224 { "dbname" => $dbname }));
1226 User->dbupdate(\%$form);
1231 | . $locale->text('Dataset updated!') . qq|
1235 <a id="enddatasetupdate" href="admin.pl?action=login&| .
1236 join("&", map({ "$_=" . $form->escape($form->{$_}); } qw(rpw))) .
1237 qq|">| . $locale->text("Continue") . qq|</a>|;
1241 sub create_dataset {
1242 $form->{dbsources} = join " ", map { "[${_}]" } sort User->dbsources(\%$form);
1244 $form->{CHARTS} = [];
1246 opendir SQLDIR, "sql/." or $form - error($!);
1247 foreach $item (sort grep /-chart\.sql\z/, readdir SQLDIR) {
1248 next if ($item eq 'Default-chart.sql');
1249 $item =~ s/-chart\.sql//;
1250 push @{ $form->{CHARTS} }, { "name" => $item,
1251 "selected" => $item eq "Germany-DATEV-SKR03EU" };
1255 my $default_charset = $dbcharset;
1256 $default_charset ||= Common::DEFAULT_CHARSET;
1258 $form->{DBENCODINGS} = [];
1260 foreach my $encoding (@Common::db_encodings) {
1261 push @{ $form->{DBENCODINGS} }, { "dbencoding" => $encoding->{dbencoding},
1262 "label" => $encoding->{label},
1263 "selected" => $encoding->{charset} eq $default_charset };
1268 . $locale->text('Database Administration') . " / "
1269 . $locale->text('Create Dataset');
1272 print $form->parse_html_template("admin/create_dataset");
1276 $form->isblank("db", $locale->text('Dataset missing!'));
1278 User->dbcreate(\%$form);
1282 . $locale->text('Database Administration') . " / "
1283 . $locale->text('Create Dataset');
1286 print $form->parse_html_template("admin/dbcreate");
1289 sub delete_dataset {
1290 @dbsources = User->dbsources_unused(\%$form, $memberfile);
1291 $form->error($locale->text('Nothing to delete!')) unless @dbsources;
1295 . $locale->text('Database Administration') . " / "
1296 . $locale->text('Delete Dataset');
1297 $form->{DBSOURCES} = [ map { { "name", $_ } } sort @dbsources ];
1300 print $form->parse_html_template("admin/delete_dataset");
1306 $form->error($locale->text('No Dataset selected!'));
1309 User->dbdelete(\%$form);
1313 . $locale->text('Database Administration') . " / "
1314 . $locale->text('Delete Dataset');
1317 print $form->parse_html_template("admin/dbdelete");
1322 unlink "$userspath/nologin";
1325 "$form->{script}?action=list_users&rpw=$root->{password}";
1327 $form->redirect($locale->text('Lockfile removed!'));
1333 open(FH, ">$userspath/nologin")
1334 or $form->error($locale->text('Cannot create Lock!'));
1338 "$form->{script}?action=list_users&rpw=$root->{password}";
1340 $form->redirect($locale->text('Lockfile created!'));