1 #=====================================================================
2 # SQL-Ledger Accounting
5 # Author: Dieter Simader
6 # Email: dsimader@sql-ledger.org
7 # Web: http://www.sql-ledger.org
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #======================================================================
25 # add/edit/delete users
27 #======================================================================
29 $menufile = "menu.ini";
37 $locale = new Locale $language, "admin";
39 eval { require DBI; };
40 $form->error($locale->text('DBI not installed!')) if ($@);
44 if (-f "$form->{path}/custom_$form->{script}") {
45 eval { require "$form->{path}/custom_$form->{script}"; };
46 $form->error($@) if ($@);
50 if (-f "css/sql-ledger.css") {
51 $form->{stylesheet} = "sql-ledger.css";
55 if ($form->{action}) {
57 $subroutine = $locale->findsub($form->{action});
59 if ($subroutine eq 'login') {
61 $form->{rpw} = crypt $form->{rpw}, "ro";
71 # if there are no drivers bail out
72 $form->error($locale->text('No Database Drivers available!')) unless (User->dbdrivers);
75 if (! -f $memberfile) {
76 open(FH, ">$memberfile") or $form->error("$memberfile : $!");
77 print FH qq|# SQL-Ledger Accounting members
96 $form->{title} = qq|SQL-Ledger $form->{version} |.$locale->text('Administration');
106 <a href="http://www.sql-ledger.org"><img src=sql-ledger.png border=0></a>
107 <h1 class=login>|.$locale->text('Version').qq| $form->{version}<p>|.$locale->text('Administration').qq|</h1>
109 <form method=post action="$form->{script}">
113 <th>|.$locale->text('Password').qq|</th>
114 <td><input type=password name=rpw></td>
115 <td><input type=submit class=submit name=action value="|.$locale->text('Login').qq|"></td>
117 <input type=hidden name=action value=login>
118 <input type=hidden name=root value="root login">
119 <input type=hidden name=path value=$form->{path}>
125 <a href=http://www.sql-ledger.org>SQL-Ledger |.$locale->text('website').qq|</a>
148 $form->{title} = "SQL-Ledger ".$locale->text('Accounting')." ".$locale->text('Administration')." / ".$locale->text('Add User');
150 $form->{Oracle_sid} = $sid;
151 $form->{Oracle_dbport} = '1521';
152 $form->{Oracle_dbhost} = `hostname`;
154 if (-f "css/sql-ledger.css") {
155 $myconfig->{stylesheet} = "sql-ledger.css";
157 $myconfig->{vclimit} = 200;
168 $form->{title} = "SQL-Ledger ".$locale->text('Accounting')." ".$locale->text('Administration')." / ".$locale->text('Edit User');
180 $delete = qq|<input type=submit class=submit name=action value="|.$locale->text('Delete').qq|">
181 <input type=hidden name=edit value=1>|;
186 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$form->{rpw}">
187 <input type=hidden name=root value="$form->{root}">
188 <input type=hidden name=path value=$form->{path}>
189 <input type=hidden name=rpw value=$form->{rpw}>
191 <input type=submit class=submit name=action value="|.$locale->text('Save').qq|">
205 $form->error("$memberfile : ".$locale->text('locked!')) if (-f "${memberfile}.LCK");
207 open(FH, "$memberfile") or $form->error("$memberfile : $!");
214 $login =~ s/(\[|\])//g;
217 if (/^(name=|company=|templates=|dbuser=|dbdriver=|dbname=|dbhost=)/) {
219 ($null, $member{$login}{$var}) = split /=/, $_, 2;
225 # type=submit $locale->text('Pg Database Administration')
226 # type=submit $locale->text('Oracle Database Administration')
228 foreach $item (User->dbdrivers) {
229 $dbdrivers .= qq|<input name=action type=submit class=submit value="|.$locale->text("$item Database Administration").qq|">|;
233 $column_header{login} = qq|<th>|.$locale->text('Login').qq|</th>|;
234 $column_header{name} = qq|<th>|.$locale->text('Name').qq|</th>|;
235 $column_header{company} = qq|<th>|.$locale->text('Company').qq|</th>|;
236 $column_header{dbdriver} = qq|<th>|.$locale->text('Driver').qq|</th>|;
237 $column_header{dbhost} = qq|<th>|.$locale->text('Host').qq|</th>|;
238 $column_header{dataset} = qq|<th>|.$locale->text('Dataset').qq|</th>|;
239 $column_header{templates} = qq|<th>|.$locale->text('Templates').qq|</th>|;
241 @column_index = qw(login name company dbdriver dbhost dataset templates);
243 $form->{title} = "SQL-Ledger ".$locale->text('Accounting')." ".$locale->text('Administration');
250 <form method=post action=$form->{script}>
254 <tr class=listheading>
255 <th>$form->{title}</th>
261 <tr class=listheading>|;
263 map { print "$column_header{$_}\n" } @column_index;
269 foreach $key (sort keys %member) {
270 $href = "$script?action=edit&login=$key&path=$form->{path}&root=$form->{root}&rpw=$form->{rpw}";
273 $member{$key}{templates} =~ s/^$templates\///;
274 $member{$key}{dbhost} = $locale->text('localhost') unless $member{$key}{dbhost};
275 $member{$key}{dbname} = $member{$key}{dbuser} if ($member{$key}{dbdriver} eq 'Oracle');
277 $column_data{login} = qq|<td><a href=$href>$key</a></td>|;
278 $column_data{name} = qq|<td>$member{$key}{name}</td>|;
279 $column_data{company} = qq|<td>$member{$key}{company}</td>|;
280 $column_data{dbdriver} = qq|<td>$member{$key}{dbdriver}</td>|;
281 $column_data{dbhost} = qq|<td>$member{$key}{dbhost}</td>|;
282 $column_data{dataset} = qq|<td>$member{$key}{dbname}</td>|;
283 $column_data{templates} = qq|<td>$member{$key}{templates}</td>|;
287 <tr class=listrow$i>|;
289 map { print "$column_data{$_}\n" } @column_index;
301 <td><hr size=3 noshade></td>
305 <input type=hidden name=path value=$form->{path}>
306 <input type=hidden name=rpw value=$form->{rpw}>
307 <input type=hidden name=root value="$form->{root}">
309 <br><input type=submit class=submit name=action value="|.$locale->text('Add User').qq|">
310 <input type=submit class=submit name=action value="|.$locale->text('Change Admin Password').qq|">
316 |.$locale->text('Click on login name to edit!').qq|
318 |.$locale->text('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.').qq|
322 <form method=post action=login.pl>
324 <table border=0 width=100%>
325 <tr class=listheading>
326 <th>SQL-Ledger |.$locale->text('Accounting')." ".$locale->text('Login').qq|</th>
332 <th align=right>|.$locale->text('Name').qq|</th>
333 <td><input class=login name=login></td>
337 <th align=right>|.$locale->text('Password').qq|</th>
338 <td><input class=login type=password name=password></td>
339 <td><input type=submit name=action value="|.$locale->text('Login').qq|"></td>
341 <input type=hidden name=path value=$form->{path}>
360 # if there is a login, get user
361 if ($form->{login}) {
363 $myconfig = new User "$memberfile", "$form->{login}";
365 $myconfig->{signature} =~ s/\\n/\r\n/g;
366 $myconfig->{address} =~ s/\\n/\r\n/g;
368 # strip basedir from templates directory
369 $myconfig->{templates} =~ s/^$templates\///;
371 $myconfig->{dbpasswd} = unpack 'u', $myconfig->{dbpasswd};
375 foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
376 $dateformat .= ($item eq $myconfig->{dateformat}) ? "<option selected>$item\n" : "<option>$item\n";
379 foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
380 $numberformat .= ($item eq $myconfig->{numberformat}) ? "<option selected>$item\n" : "<option>$item\n";
384 %countrycodes = User->country_codes;
386 foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} } keys %countrycodes) {
387 $countrycodes .= ($myconfig->{countrycode} eq $key) ? "<option selected value=$key>$countrycodes{$key}" : "<option value=$key>$countrycodes{$key}";
389 $countrycodes = qq|<option value="">American English\n$countrycodes|;
391 # is there a templates basedir
392 if (! -d "$templates") {
393 $form->error($locale->text('Directory').": $templates ".$locale->text('does not exist'));
396 opendir TEMPLATEDIR, "$templates/." or $form->error("$templates : $!");
397 @all = grep !/^\.\.?$/, readdir TEMPLATEDIR;
398 closedir TEMPLATEDIR;
400 @allhtml = sort grep /\.html/, @all;
401 @alldir = grep !/\.(html|tex)$/, @all;
403 @allhtml = reverse grep !/Default/, @allhtml;
404 push @allhtml, 'Default';
405 @allhtml = reverse @allhtml;
407 foreach $item (@alldir) {
408 if ($item eq $myconfig->{templates}) {
409 $usetemplates .= qq|<option selected>$item\n|;
411 $usetemplates .= qq|<option>$item\n|;
415 $lastitem = $allhtml[0];
416 $lastitem =~ s/-.*//g;
417 $mastertemplates = qq|<option>$lastitem\n|;
418 foreach $item (@allhtml) {
421 if ($item ne $lastitem) {
422 $mastertemplates .= qq|<option>$item\n|;
433 <form method=post action=$form->{script}>
436 <tr class=listheading><th colspan=2>$form->{title}</th></tr>
442 <th align=right>|.$locale->text('Login').qq|</th>
443 <td><input name=login value="$myconfig->{login}"></td>
446 <th align=right>|.$locale->text('Password').qq|</th>
447 <td><input type=password name=password size=8 value=$myconfig->{password}></td>
448 <input type=hidden name=old_password value=$myconfig->{password}>
451 <th align=right>|.$locale->text('Name').qq|</th>
452 <td><input name=name size=15 value="$myconfig->{name}"></td>
455 <th align=right>|.$locale->text('E-mail').qq|</th>
456 <td><input name=email size=30 value="$myconfig->{email}"></td>
459 <th align=right>|.$locale->text('Signature').qq|</th>
460 <td><textarea name=signature rows=3 cols=35>$myconfig->{signature}</textarea></td>
463 <th align=right>|.$locale->text('Phone').qq|</th>
464 <td><input name=tel size=14 value="$myconfig->{tel}"></td>
467 <th align=right>|.$locale->text('Fax').qq|</th>
468 <td><input name=fax size=14 value="$myconfig->{fax}"></td>
471 <th align=right>|.$locale->text('Company').qq|</th>
472 <td><input name=company size=35 value="$myconfig->{company}"></td>
475 <th align=right>|.$locale->text('Address').qq|</th>
476 <td><textarea name=address rows=4 cols=35>$myconfig->{address}</textarea></td>
483 <th align=right>|.$locale->text('Date Format').qq|</th>
484 <td><select name=dateformat>$dateformat</select></td>
487 <th align=right>|.$locale->text('Number Format').qq|</th>
488 <td><select name=numberformat>$numberformat</select></td>
491 <th align=right>|.$locale->text('Dropdown Limit').qq|</th>
492 <td><input name=vclimit value="$myconfig->{vclimit}"></td>
495 <th align=right>|.$locale->text('Language').qq|</th>
496 <td><select name=countrycode>$countrycodes</select></td>
499 <th align=right>|.$locale->text('Character Set').qq|</th>
500 <td><input name=charset value="$myconfig->{charset}"></td>
503 <th align=right>|.$locale->text('Stylesheet').qq|</th>
504 <td><input name=userstylesheet value="$myconfig->{stylesheet}"></td>
507 <th align=right>|.$locale->text('Printer').qq|</th>
508 <td><input name=printer size=20 value="$myconfig->{printer}"></td>
511 <th align=right>|.$locale->text('Ship via').qq|</th>
512 <td><input name=shippingpoint size=15 value="$myconfig->{shippingpoint}"></td>
515 <th align=right>|.$locale->text('Use Templates').qq|</th>
516 <td><select name=usetemplates>$usetemplates</select></td>
519 <th align=right>|.$locale->text('New Templates').qq|</th>
520 <td><input name=newtemplates></td>
523 <th align=right>|.$locale->text('Setup Templates').qq|</th>
524 <td><select name=mastertemplates>$mastertemplates</select></td>
526 <input type=hidden name=templates value=$myconfig->{templates}>
530 <tr class=listheading>
531 <th colspan=2>|.$locale->text('Database').qq|</th>
534 # list section for database drivers
535 foreach $item (User->dbdrivers) {
544 if ($myconfig->{dbdriver} eq $item) {
545 map { $form->{"${item}_$_"} = $myconfig->{$_} } qw(dbhost dbport dbuser dbpasswd dbname sid);
546 $checked = "checked";
550 <th align=right>|.$locale->text('Driver').qq|</th>
551 <td><input name=dbdriver type=radio class=radio value=$item $checked> $item</td>
552 <th align=right>|.$locale->text('Host').qq|</th>
553 <td><input name="${item}_dbhost" value=$form->{"${item}_dbhost"}></td>
559 <th align=right>|.$locale->text('Dataset').qq|</th>
560 <td><input name=Pg_dbname size=10 value=$form->{Pg_dbname}></td>
561 <th align=right>|.$locale->text('Port').qq|</th>
562 <td><input name=Pg_dbport size=4 value=$form->{Pg_dbport}></td>
565 <th align=right>|.$locale->text('User').qq|</th>
566 <td><input name="${item}_dbuser" size=10 value=$form->{"${item}_dbuser"}></td>
567 <th align=right>|.$locale->text('Password').qq|</th>
568 <td><input name="${item}_dbpasswd" type=password size=10 value=$form->{"${item}_dbpasswd"}></td>
573 if ($item eq 'Oracle') {
575 <th align=right>SID</th>
576 <td><input name=Oracle_sid value=$form->{Oracle_sid}></td>
577 <th align=right>|.$locale->text('Port').qq|</th>
578 <td><input name=Oracle_dbport size=4 value=$form->{Oracle_dbport}></td>
581 <th align=right>|.$locale->text('Dataset').qq|</th>
582 <td><input name="${item}_dbuser" size=10 value=$form->{"${item}_dbuser"}></td>
583 <th align=right>|.$locale->text('Password').qq|</th>
584 <td><input name="${item}_dbpasswd" type=password size=10 value=$form->{"${item}_dbpasswd"}></td>
591 <input type=hidden name=old_dbpasswd value=$myconfig->{dbpasswd}>
596 <td colspan=2><hr size=2 noshade></td>
604 open(FH, $menufile) or $form->error("$menufile : $!");
605 # scan for first menu level
609 if (open(FH, "custom_$menufile")) {
615 next unless $item =~ /\[/;
616 next if $item =~ /\#/;
618 $item =~ s/(\[|\])//g;
622 ($level, $menuitem) = split /--/, $item, 2;
626 push @acsorder, $item;
629 push @{ $acs{$level} }, $menuitem;
633 $admincheck = "checked" if $myconfig->{admin};
636 <tr class=listheading>
637 <th colspan=2>|.$locale->text('Access Control').qq|</th>
640 <td><input name=admin type=checkbox class=checkbox value=1 $admincheck> <b>|.$locale->text('Administrator').qq|</b></td>
644 foreach $item (split /;/, $myconfig->{acs}) {
645 ($key, $value) = split /--/, $item, 2;
646 $excl{$key}{$value} = 1;
649 foreach $key (@acsorder) {
651 $checked = "checked";
652 if ($form->{login}) {
653 $checked = ($excl{$key}{$key}) ? "" : "checked";
656 # can't have variable names with spaces
657 # the 1 is for apache 2
658 $item = $form->escape("${key}--$key", 1);
661 $acsheading =~ s/ / /g;
664 <th align=left><input name="$item" class=checkbox type=checkbox value=1 $checked> $acsheading</th>\n|;
665 $menuitems .= "$item;";
669 foreach $item (@{ $acs{$key} }) {
670 next if ($key eq $item);
672 $checked = "checked";
673 if ($form->{login}) {
674 $checked = ($excl{$key}{$item}) ? "" : "checked";
677 $acsitem = $form->escape("${key}--$item", 1);
680 <br><input name="$acsitem" class=checkbox type=checkbox value=1 $checked> $item|;
681 $menuitems .= "$acsitem;";
688 <tr valign=top>$acsheading $acsdata
693 print qq|<input type=hidden name=acs value="$menuitems">
696 <td colspan=2><hr size=3 noshade></td>
711 $form->error($locale->text('Database Driver not checked!')) unless $form->{dbdriver};
713 # no spaces allowed in login name
714 ($form->{login}) = split / /, $form->{login};
716 # check for duplicates
717 if (!$form->{edit}) {
718 $temp = new User "$memberfile", "$form->{login}";
720 if ($temp->{login}) {
721 $form->error("$form->{login} ".$locale->text('is already a member!'));
725 # does stylesheet exist
726 if ($form->{userstylesheet}) {
727 $form->error($locale->text('Stylesheet').": css/$form->{userstylesheet} ".$locale->text('does not exist')) unless (-f "css/$form->{userstylesheet}");
730 # no spaces allowed in directories
731 ($form->{newtemplates}) = split / /, $form->{newtemplates};
733 if ($form->{newtemplates}) {
734 $form->{templates} = $form->{newtemplates};
736 $form->{templates} = ($form->{usetemplates}) ? $form->{usetemplates} : $form->{login};
741 if (! -d "$templates") {
742 $form->error($locale->text('Directory').": $templates ".$locale->text('does not exist'));
745 # add base directory to $form->{templates}
746 $form->{templates} = "$templates/$form->{templates}";
749 $myconfig = new User "$memberfile", "$form->{login}";
751 # redo acs variable and delete all the acs codes
752 @acs = split /;/, $form->{acs};
755 foreach $item (@acs) {
756 $item = $form->escape($item, 1);
758 if (!$form->{$item}) {
759 $form->{acs} .= $form->unescape($form->unescape($item)).";";
761 delete $form->{$item};
764 # check which database was filled in
765 if ($form->{dbdriver} eq 'Oracle') {
766 $form->{sid} = $form->{Oracle_sid}, ;
767 $form->{dbhost} = $form->{Oracle_dbhost}, ;
768 $form->{dbport} = $form->{Oracle_dbport};
769 $form->{dbpasswd} = $form->{Oracle_dbpasswd};
770 $form->{dbuser} = $form->{Oracle_dbuser};
771 $form->{dbname} = $form->{Oracle_dbuser};
773 $form->isblank("dbhost", $locale->text('Hostname missing!'));
774 $form->isblank("dbport", $locale->text('Port missing!'));
775 $form->isblank("dbuser", $locale->text('Dataset missing!'));
777 if ($form->{dbdriver} eq 'Pg') {
778 $form->{dbhost} = $form->{Pg_dbhost};
779 $form->{dbport} = $form->{Pg_dbport};
780 $form->{dbpasswd} = $form->{Pg_dbpasswd};
781 $form->{dbuser} = $form->{Pg_dbuser};
782 $form->{dbname} = $form->{Pg_dbname};
784 $form->isblank("dbname", $locale->text('Dataset missing!'));
785 $form->isblank("dbuser", $locale->text('Database User missing!'));
789 $form->{admin} = "" unless $form->{admin};
791 foreach $item (keys %{$form}) {
792 $myconfig->{$item} = $form->{$item};
795 delete $myconfig->{stylesheet};
796 if ($form->{userstylesheet}) {
797 $myconfig->{stylesheet} = $form->{userstylesheet};
800 $myconfig->save_member($memberfile, $userspath);
802 # create user template directory and copy master files
803 if (! -d "$form->{templates}") {
806 if (mkdir "$form->{templates}", oct("771")) {
810 # copy templates to the directory
811 opendir TEMPLATEDIR, "$templates/." or $form-error("$templates : $!");
812 @templates = grep /$form->{mastertemplates}.*?\.(html|tex)$/, readdir TEMPLATEDIR;
813 closedir TEMPLATEDIR;
815 foreach $file (@templates) {
816 open(TEMP, "$templates/$file") or $form->error("$templates/$file : $!");
818 $file =~ s/$form->{mastertemplates}-//;
819 open(NEW, ">$form->{templates}/$file") or $form->error("$form->{templates}/$file : $!");
821 while ($line = <TEMP>) {
828 $form->error("$!: $form->{templates}");
832 $form->redirect($locale->text('User saved!'));
839 $form->{templates} = ($form->{templates}) ? "$templates/$form->{templates}" : "$templates/$form->{login}";
841 $form->error("$memberfile : ".$locale->text('locked!')) if (-f ${memberfile}.LCK);
842 open(FH, ">${memberfile}.LCK") or $form->error("${memberfile}.LCK : $!");
845 open(CONF, "+<$memberfile") or $form->error("$memberfile : $!");
852 while ($line = shift @config) {
854 if ($line =~ /^\[/) {
855 last if ($line =~ /\[$form->{login}\]/);
856 $login = &login_name($line);
859 if ($line =~ /^templates=/) {
860 $user{$login} = &get_value($line);
866 # remove everything up to next login or EOF
867 # and save template variable
868 while ($line = shift @config) {
869 if ($line =~ /^templates=/) {
870 $templatedir = &get_value($line);
872 last if ($line =~ /^\[/);
875 # this one is either the next login or EOF
878 $login = &login_name($line);
881 while ($line = shift @config) {
882 if ($line =~ /^\[/) {
883 $login = &login_name($line);
886 if ($line =~ /^templates=/) {
887 $user{$login} = &get_value($line);
894 unlink "${memberfile}.LCK";
896 # scan %user for $templatedir
897 foreach $login (keys %user) {
898 last if ($found = ($templatedir eq $user{$login}));
901 # if found keep directory otherwise delete
903 # delete it if there is a template directory
904 $dir = "$form->{templates}";
906 unlink <$dir/*.html>;
912 # delete config file for user
913 unlink "$userspath/$form->{login}.conf";
915 $form->redirect($locale->text('User deleted!'));
924 return ($login) ? $login : undef;
933 my ($null, $value) = split(/=/, $line, 2);
936 $value =~ s/\s#.*//g;
938 # remove any trailing whitespace
939 $value =~ s/^\s*(.*?)\s*$/$1/;
946 sub change_admin_password {
948 $form->{title} = qq|SQL-Ledger |.$locale->text('Accounting')." ".$locale->text('Administration')." / ".$locale->text('Change Admin Password');
956 <h2>|.$locale->text('Change Admin Password').qq|</h2>
958 <form method=post action=$form->{script}>
960 <b>|.$locale->text('Password').qq|</b> <input type=password name=password size=8>
962 <input type=hidden name=root value="$form->{root}">
963 <input type=hidden name=path value=$form->{path}>
964 <input type=hidden name=rpw value=$form->{rpw}>
967 <input type=submit class=submit name=action value="|.$locale->text('Change Password').qq|">
978 sub change_password {
980 $root->{password} = $form->{password};
982 $root->{'root login'} = 1;
983 $root->save_member($memberfile);
985 $form->{callback} = "$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$root->{password}";
987 $form->redirect($locale->text('Password changed!'));
994 $root = new User "$memberfile", $form->{root};
996 if ($root->{password}) {
997 if ($root->{password} ne $form->{rpw}) {
998 $form->error($locale->text('Incorrect Password!'));
1005 sub pg_database_administration {
1007 $form->{dbdriver} = 'Pg';
1013 sub oracle_database_administration {
1015 $form->{dbdriver} = 'Oracle';
1021 sub dbdriver_defaults {
1023 # load some defaults for the selected driver
1024 %driverdefaults = ( 'Pg' => { dbport => '',
1025 dbuser => 'sql-ledger',
1026 dbdefault => 'template1',
1028 connectstring => $locale->text('Connect to')
1030 'Oracle' => { dbport => '1521',
1033 dbhost => `hostname`,
1034 connectstring => 'SID'
1038 map { $form->{$_} = $driverdefaults{$form->{dbdriver}}{$_} } keys %{ $driverdefaults{Pg} };
1043 sub dbselect_source {
1047 $msg{Pg} = $locale->text('Leave host and port field empty unless you want to make a remote connection.');
1048 $msg{Oracle} = $locale->text('You must enter a host and port for local and remote connections!');
1051 $form->{title} = "SQL-Ledger ".$locale->text('Accounting')." / ".$locale->text('Database Administration');
1061 <h2>$form->{title}</h2>
1063 <form method=post action=$form->{script}>
1070 <tr class=listheading>
1071 <th colspan=4>|.$locale->text('Database').qq|</th>
1074 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1081 <th align=right>|.$locale->text('Host').qq|</th>
1082 <td><input name=dbhost size=25 value=$form->{dbhost}></td>
1083 <th align=right>|.$locale->text('Port').qq|</th>
1084 <td><input name=dbport size=5 value=$form->{dbport}></td>
1090 <th align=right>|.$locale->text('User').qq|</th>
1091 <td><input name=dbuser size=10 value=$form->{dbuser}></td>
1092 <th align=right>|.$locale->text('Password').qq|</th>
1093 <td><input type=password name=dbpasswd size=10></td>
1099 <th align=right>$form->{connectstring}</th>
1100 <td colspan=3><input name=dbdefault size=10 value=$form->{dbdefault}></td>
1109 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$form->{rpw}">
1110 <input type=hidden name=root value="$form->{root}">
1111 <input type=hidden name=path value=$form->{path}>
1112 <input type=hidden name=rpw value=$form->{rpw}>
1117 <input type=submit class=submit name=action value="|.$locale->text('Create Dataset').qq|">
1118 <input type=submit class=submit name=action value="|.$locale->text('Update Dataset').qq|">
1119 <input type=submit class=submit name=action value="|.$locale->text('Delete Dataset').qq|">
1126 <p>|.$locale->text('This is a preliminary check for existing sources. Nothing will be created or deleted at this stage!')
1129 <br>$msg{$form->{dbdriver}}
1141 &{ $form->{nextsub} };
1146 sub update_dataset {
1148 %needsupdate = User->dbneedsupdate(\%$form);
1150 $form->{title} = "SQL-Ledger ".$locale->text('Accounting')." ".$locale->text('Database Administration')." / ".$locale->text('Update Dataset');
1159 <h2>$form->{title}</h2>
1163 foreach $key (sort keys %needsupdate) {
1164 if ($needsupdate{$key} lt $form->{dbversion}) {
1165 $upd .= qq|<br><input name="db$key" type=checkbox value=1 checked> $key\n|;
1166 $form->{dbupdate} .= "db$key ";
1170 chop $form->{dbupdate};
1173 if ($form->{dbupdate}) {
1177 <form method=post action=$form->{script}>
1179 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1180 <input type=hidden name=dbhost value=$form->{dbhost}>
1181 <input type=hidden name=dbport value=$form->{dbport}>
1182 <input type=hidden name=dbuser value=$form->{dbuser}>
1183 <input type=hidden name=dbpasswd value=$form->{dbpasswd}>
1184 <input type=hidden name=dbdefault value=$form->{dbdefault}>
1186 <tr class=listheading>
1187 <th>|.$locale->text('The following Datasets need to be updated').qq|</th>
1197 <input name=dbupdate type=hidden value="$form->{dbupdate}">
1199 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$form->{rpw}">
1201 <input type=hidden name=root value="$form->{root}">
1202 <input type=hidden name=path value=$form->{path}>
1203 <input type=hidden name=rpw value=$form->{rpw}>
1205 <input type=hidden name=nextsub value=dbupdate>
1207 <input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
1216 print $locale->text('All Datasets up to date!');
1231 User->dbupdate(\%$form);
1233 $form->redirect($locale->text('Dataset updated!'));
1238 sub create_dataset {
1240 foreach $item (sort User->dbsources(\%$form)) {
1241 $dbsources .= "[$item] ";
1244 opendir SQLDIR, "sql/." or $form-error($!);
1245 foreach $item (sort grep /-chart\.sql/, readdir SQLDIR) {
1246 next if ($item eq 'Default-chart.sql');
1247 $item =~ s/-chart\.sql//;
1248 push @charts, qq| <input name=chart class=radio type=radio value="$item"> $item|;
1252 # add Default at beginning
1253 @charts = (qq|<input name=chart class=radio type=radio value="Default" checked> Default|, @charts);
1255 $selectencoding = qq|<option>
1256 <option value=SQL_ASCII>ASCII
1257 <option value=EUC_JP>Japanese Extended UNIX Code
1258 <option value=EUC_CN>Chinese Extended UNIX Code
1259 <option value=EUC_KR>Korean Extended UNIX Code
1260 <option value=EUC_TW>Taiwan Extended UNIX Code
1261 <option value=UNICODE>UTF-8 Unicode
1262 <option value=MULE_INTERNAL>Mule internal type
1263 <option value=LATIN1>ISO 8859-1
1264 <option value=LATIN2>ISO 8859-2
1265 <option value=LATIN3>ISO 8859-3
1266 <option value=LATIN4>ISO 8859-4
1267 <option value=LATIN5>ISO 8859-5
1268 <option value=KOI8>KOI8-R
1269 <option value=WIN>Windows CP1251
1270 <option value=ALT>Windows CP866
1273 $form->{title} = "SQL-Ledger ".$locale->text('Accounting')." ".$locale->text('Database Administration')." / ".$locale->text('Create Dataset');
1282 <h2>$form->{title}</h2>
1284 <form method=post action=$form->{script}>
1287 <tr class=listheading>
1288 <th colspan=2> </th>
1293 <th align=right nowrap>|.$locale->text('Existing Datasets').qq|</th>
1300 <th align=right nowrap>|.$locale->text('Create Dataset').qq|</th>
1301 <td><input name=db></td>
1307 <th align=right nowrap>|.$locale->text('Multibyte Encoding').qq|</th>
1308 <td><select name=encoding>$selectencoding</select></td>
1314 <th align=right>|.$locale->text('Create Chart of Accounts').qq|</th>
1322 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1323 <input type=hidden name=dbuser value=$form->{dbuser}>
1324 <input type=hidden name=dbhost value=$form->{dbhost}>
1325 <input type=hidden name=dbport value=$form->{dbport}>
1326 <input type=hidden name=dbpasswd value=$form->{dbpasswd}>
1327 <input type=hidden name=dbdefault value=$form->{dbdefault}>
1329 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$form->{rpw}">
1331 <input type=hidden name=root value="$form->{root}">
1332 <input type=hidden name=path value=$form->{path}>
1333 <input type=hidden name=rpw value=$form->{rpw}>
1335 <input type=hidden name=nextsub value=dbcreate>
1337 <input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
1354 $form->isblank("db", $locale->text('Dataset missing!'));
1356 User->dbcreate(\%$form);
1358 $form->{title} = "SQL-Ledger ".$locale->text('Accounting')." ".$locale->text('Database Administration')." / ".$locale->text('Create Dataset');
1367 <h2>$form->{title}</h2>
1369 <form method=post action=$form->{script}>|
1371 .$locale->text('Dataset')." $form->{db} ".$locale->text('successfully created!')
1375 <input type=hidden name=root value="$form->{root}">
1376 <input type=hidden name=path value="$form->{path}">
1377 <input type=hidden name=rpw value="$form->{rpw}">
1379 <input type=hidden name=nextsub value=list_users>
1381 <p><input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
1392 sub delete_dataset {
1394 if (@dbsources = User->dbsources_unused(\%$form, $memberfile)) {
1395 foreach $item (sort @dbsources) {
1396 $dbsources .= qq|<input name=db class=radio type=radio value=$item> $item\n<br>|;
1399 $form->error($locale->text('Nothing to delete!'));
1402 $form->{title} = "SQL-Ledger ".$locale->text('Accounting')." ".$locale->text('Database Administration')." / ".$locale->text('Delete Dataset');
1411 <h2>$form->{title}</h2>
1413 <form method=post action=$form->{script}>
1416 <tr class=listheading>
1417 <th>|.$locale->text('The following Datasets are not in use and can be deleted').qq|</th>
1430 <input type=hidden name=dbdriver value=$form->{dbdriver}>
1431 <input type=hidden name=dbuser value=$form->{dbuser}>
1432 <input type=hidden name=dbhost value=$form->{dbhost}>
1433 <input type=hidden name=dbport value=$form->{dbport}>
1434 <input type=hidden name=dbpasswd value=$form->{dbpasswd}>
1435 <input type=hidden name=dbdefault value=$form->{dbdefault}>
1437 <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$form->{rpw}">
1439 <input type=hidden name=root value="$form->{root}">
1440 <input type=hidden name=path value="$form->{path}">
1441 <input type=hidden name=rpw value="$form->{rpw}">
1443 <input type=hidden name=nextsub value=dbdelete>
1445 <input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
1452 <p>|.$locale->text('Select a Dataset to delete and press "Continue"')
1467 $form->error($locale->text('No Dataset selected!'));
1470 User->dbdelete(\%$form);
1472 $form->{title} = "SQL-Ledger ".$locale->text('Accounting')." ".$locale->text('Database Administration')." / ".$locale->text('Delete Dataset');
1481 <h2>$form->{title}</h2>
1483 <form method=post action=$form->{script}>
1485 $form->{db} |.$locale->text('successfully deleted!')
1489 <input type=hidden name=root value="$form->{root}">
1490 <input type=hidden name=path value="$form->{path}">
1491 <input type=hidden name=rpw value="$form->{rpw}">
1493 <input type=hidden name=nextsub value=list_users>
1495 <p><input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">