-
-$form = new Form;
-$form->{"root"} = "root login";
-
-$locale = new Locale $language, "admin";
-
-eval { require DBI; };
-$form->error($locale->text('DBI not installed!')) if ($@);
-
-# customization
-if (-f "$form->{path}/custom_$form->{script}") {
- eval { require "$form->{path}/custom_$form->{script}"; };
- $form->error($@) if ($@);
-}
-
-$form->{stylesheet} = "lx-office-erp.css";
-$form->{favicon} = "favicon.ico";
-
-if ($form->{action}) {
-
-
- $subroutine = $locale->findsub($form->{action});
-
- if ($subroutine eq 'login') {
- if ($form->{rpw}) {
- $form->{rpw} = crypt $form->{rpw}, "ro";
- }
- }
-
- &check_password;
-
- &$subroutine;
-
-} else {
-
- # if there are no drivers bail out
- $form->error($locale->text('No Database Drivers available!'))
- unless (User->dbdrivers);
-
- # create memberfile
- if (!-f $memberfile) {
- open(FH, ">$memberfile") or $form->error("$memberfile : $!");
- print FH qq|# SQL-Ledger Accounting members
-
-[root login]
-password=
-
-|;
- close FH;
- }
-
- &adminlogin;
-
-}
-
-1;
-
-# end
-
-sub adminlogin {
-
- $form->{title} =
- qq|Lx-Office ERP $form->{version} | . $locale->text('Administration');
-
- $form->header;
-
- print qq|
-<body class=admin>
-
-
-<div align=center>
-
-<a href="http://www.lx-office.org"><img src="image/lx-office-erp.png" border=0></a>
-<h1 class=login>|
- . $locale->text('Version')
- . qq| $form->{version}<p>|
- . $locale->text('Administration')
- . qq|</h1>
-
-<form method=post action="$form->{script}">
-
-<table>
- <tr>
- <th>| . $locale->text('Password') . qq|</th>
- <td><input type=password name=rpw></td>
- <td><input type=submit class=submit name=action value="|
- . $locale->text('Login') . qq|"></td>
- </tr>
-<input type=hidden name=action value=login>
-<input type=hidden name=path value=$form->{path}>
-</table>
-
-
-</form>
-
-<a href=http://www.lx-office.org>Lx-Office |
- . $locale->text('website') . qq|</a>
-
-</div>
-
-</body>
-</html>
-|;
-
-}
-
-sub login {
-
- &list_users;
-
-}
-
-sub add_user {
-
- $form->{title} =
- "Lx-Office ERP "
- . $locale->text('Administration') . " / "
- . $locale->text('Add User');
-
- $form->{Oracle_sid} = $sid;
- $form->{Oracle_dbport} = '1521';
- $form->{Oracle_dbhost} = `hostname`;
-
- if (-f "css/lx-office-erp.css") {
- $myconfig->{stylesheet} = "lx-office-erp.css";
- }
- $myconfig->{vclimit} = 200;
-
- $myconfig->{"countrycode"} = "de";
- $myconfig->{"numberformat"} = "1000,00";
- $myconfig->{"dateformat"} = "dd.mm.yy";
-
- &form_header;
- &form_footer;
-
-}
-
-sub edit {
-
- $form->{title} =
- "Lx-Office ERP "
- . $locale->text('Administration') . " / "
- . $locale->text('Edit User');
- $form->{edit} = 1;
-
- &form_header;
- &form_footer;
-
-}
-
-sub form_footer {
-
- if ($form->{edit}) {
- $delete =
- qq|<input type=submit class=submit name=action value="|
- . $locale->text('Delete') . qq|">
-<input type=hidden name=edit value=1>|;
- }
-
- print qq|
-
-<input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&rpw=$form->{rpw}">
-<input type=hidden name=path value=$form->{path}>
-<input type=hidden name=rpw value=$form->{rpw}>
-
-<input type=submit class=submit name=action value="|
- . $locale->text('Save') . qq|">
-$delete
-
-</form>
-
-</body>
-</html>
-|;
-
-}
-
-sub list_users {
-
- $form->error($locale->text('File locked!')) if (-f "${memberfile}.LCK");
-
- open(FH, "$memberfile") or $form->error("$memberfile : $!");
-
- $nologin = qq|
-<input type=submit class=submit name=action value="|
- . $locale->text('Lock System') . qq|">|;
-
- if (-e "$userspath/nologin") {
- $nologin = qq|
-<input type=submit class=submit name=action value="|
- . $locale->text('Unlock System') . qq|">|;
- }
-
- while (<FH>) {
- chop;
-
- if (/^\[.*\]/) {
- $login = $_;
- $login =~ s/(\[|\])//g;
- }
-
- if (/^(name=|company=|templates=|dbuser=|dbdriver=|dbname=|dbhost=)/) {
- chop($var = $&);
- ($null, $member{$login}{$var}) = split(/=/, $_, 2);
- }
- }
-
- close(FH);
-
- # type=submit $locale->text('Pg Database Administration')
- # type=submit $locale->text('Oracle Database Administration')
-
- foreach $item (User->dbdrivers) {
- $dbdrivers .=
- qq|<input name=action type=submit class=submit value="|
- . $locale->text("$item Database Administration") . qq|">|;
- }
-
- $column_header{login} = qq|<th>| . $locale->text('Login') . qq|</th>|;
- $column_header{name} = qq|<th>| . $locale->text('Name') . qq|</th>|;
- $column_header{company} = qq|<th>| . $locale->text('Company') . qq|</th>|;
- $column_header{dbdriver} = qq|<th>| . $locale->text('Driver') . qq|</th>|;
- $column_header{dbhost} = qq|<th>| . $locale->text('Host') . qq|</th>|;
- $column_header{dataset} = qq|<th>| . $locale->text('Dataset') . qq|</th>|;
- $column_header{templates} =
- qq|<th>| . $locale->text('Templates') . qq|</th>|;
-
- @column_index = qw(login name company dbdriver dbhost dataset templates);
-
- $form->{title} = "Lx-Office ERP " . $locale->text('Administration');
-
- $form->header;
-
- print qq|
-<body class=admin>
-
-<form method=post action=$form->{script}>
-
-<table width=100%>
- <tr>
- <tr class=listheading>
- <th>$form->{title}</th>
- </tr>
- <tr size=5></tr>
- <tr>
- <td>
- <table width=100%>
- <tr class=listheading>|;
-
- map { print "$column_header{$_}\n" } @column_index;
-
- print qq|
- </tr>
-|;
-
- foreach $key (sort keys %member) {
- $href =
- "$script?action=edit&login=$key&path=$form->{path}&rpw=$form->{rpw}";
- $href =~ s/ /%20/g;
-
- $member{$key}{templates} =~ s/^$templates\///;
- $member{$key}{dbhost} = $locale->text('localhost')
- unless $member{$key}{dbhost};
- $member{$key}{dbname} = $member{$key}{dbuser}
- if ($member{$key}{dbdriver} eq 'Oracle');
-
- $column_data{login} = qq|<td><a id="$key" href="$href">$key</a></td>|;
- $column_data{name} = qq|<td>$member{$key}{name}</td>|;
- $column_data{company} = qq|<td>$member{$key}{company}</td>|;
- $column_data{dbdriver} = qq|<td>$member{$key}{dbdriver}</td>|;
- $column_data{dbhost} = qq|<td>$member{$key}{dbhost}</td>|;
- $column_data{dataset} = qq|<td>$member{$key}{dbname}</td>|;
- $column_data{templates} = qq|<td>$member{$key}{templates}</td>|;
-
- $i++;
- $i %= 2;
- print qq|
- <tr class="listrow$i">|;
-
- map { print "$column_data{$_}\n" } @column_index;
-
- print qq|
- </tr>|;
- }
-
- print qq|
- </table>
- </td>
- </tr>
- <tr>
- <td><hr size=3 noshade></td>
- </tr>
-</table>
-
-<input type=hidden name=path value=$form->{path}>
-<input type=hidden name=rpw value=$form->{rpw}>
-
-<br><input type=submit class=submit name=action value="|
- . $locale->text('Add User') . qq|">
-<input type=submit class=submit name=action value="|
- . $locale->text('Change Admin Password') . qq|">
-
-$dbdrivers
-$nologin
-
-</form>
-
-| . $locale->text('Click on login name to edit!') . qq|
-<br>
-|
- . $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|
-
-<p>
-
-<form method=post action=login.pl>
-
-<table border=0 width=100%>
- <tr class=listheading>
- <th>Lx-Office ERP | . $locale->text('Login') . qq|</th>
- </tr>
- <tr>
- <td>
- <table>
- <tr>
- <th align=right>| . $locale->text('Name') . qq|</th>
- <td><input class=login name=login></td>
- <td> </td>
- </tr>
- <tr>
- <th align=right>| . $locale->text('Password') . qq|</th>
- <td><input class=login type=password name=password></td>
- <td><input type=submit name=action value="|
- . $locale->text('Login') . qq|"></td>
- </tr>
-<input type=hidden name=path value=$form->{path}>
- </table>
- </td>
- </tr>
-</table>
-
-</form>
-
-<hr size=3 noshade>
-
-</body>
-</html>
-|;
-
-}
-
-sub form_header {
-
- # if there is a login, get user
- if ($form->{login}) {
-
- # get user
- $myconfig = new User "$memberfile", "$form->{login}";
-
- $myconfig->{signature} =~ s/\\n/\r\n/g;
- $myconfig->{address} =~ s/\\n/\r\n/g;
-
- # strip basedir from templates directory
- $myconfig->{templates} =~ s/^$templates\///;
-
- # $myconfig->{dbpasswd} = unpack 'u', $myconfig->{dbpasswd};
- }
-
- foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
- $dateformat .=
- ($item eq $myconfig->{dateformat})
- ? "<option selected>$item\n"
- : "<option>$item\n";
- }
-
- foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
- $numberformat .=
- ($item eq $myconfig->{numberformat})
- ? "<option selected>$item\n"
- : "<option>$item\n";
- }
-
- %countrycodes = User->country_codes;
- $countrycodes = "";
- foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} }
- keys %countrycodes
- ) {
- $countrycodes .=
- ($myconfig->{countrycode} eq $key)
- ? "<option selected value=$key>$countrycodes{$key}"
- : "<option value=$key>$countrycodes{$key}";
- }
- $countrycodes = qq|<option value="">American English\n$countrycodes|;
-
- # is there a templates basedir
- if (!-d "$templates") {
- $form->error( $locale->text('Directory')
- . ": $templates "
- . $locale->text('does not exist'));
- }
-
- opendir TEMPLATEDIR, "$templates/." or $form->error("$templates : $!");
- @all = grep({ !/^\.\.?$/ && -d "$templates/$_" } readdir(TEMPLATEDIR));
- closedir TEMPLATEDIR;
-
- @allhtml = sort grep /\.html/, @all;
- @alldir = grep !/\.(html|tex|sty|odt|xml|txb)$/, @all;
- @alldir = grep !/^(webpages|\.svn)$/, @alldir;
-
- @allhtml = reverse grep !/Default/, @allhtml;
- push @allhtml, 'Default';
- @allhtml = reverse @allhtml;
-
- foreach $item (@alldir) {
- if ($item eq $myconfig->{templates}) {
- $usetemplates .= qq|<option selected>$item\n|;
- } else {
- $usetemplates .= qq|<option>$item\n|;
- }
- }
-
- $lastitem = $allhtml[0];
- $lastitem =~ s/-.*//g;
- $mastertemplates = qq|<option>$lastitem\n|;
- foreach $item (@allhtml) {
- $item =~ s/-.*//g;
-
- if ($item ne $lastitem) {
- my $selected = $item eq "German" ? " selected" : "";
- $mastertemplates .= qq|<option$selected>$item\n|;
- $lastitem = $item;
- }
- }
-
- opendir CSS, "css/.";
- @all = grep /.*\.css$/, readdir CSS;
- closedir CSS;
-
- foreach $item (@all) {
- if ($item eq $myconfig->{stylesheet}) {
- $selectstylesheet .= qq|<option selected>$item\n|;
- } else {
- $selectstylesheet .= qq|<option>$item\n|;
- }
- }
- $selectstylesheet .= "<option>\n";
-
- $form->header;
-
- if ($myconfig->{menustyle} eq "neu") { $neu = "checked"; }
- else { $old = "checked"; }
-
- print qq|
-<body class=admin>
-
-<form method=post action=$form->{script}>
-
-<table width=100%>
- <tr class=listheading><th colspan=2>$form->{title}</th></tr>
- <tr size=5></tr>
- <tr valign=top>
- <td>
- <table>
- <tr>
- <th align=right>| . $locale->text('Login') . qq|</th>
- <td><input name=login value="$myconfig->{login}"></td>
- </tr>
- <tr>
- <th align=right>| . $locale->text('Password') . qq|</th>
- <td><input type=password name=password size=8 value=$myconfig->{password}></td>
- <input type=hidden name=old_password value=$myconfig->{password}>
- </tr>
- <tr>
- <th align=right>| . $locale->text('Name') . qq|</th>
- <td><input name=name size=15 value="$myconfig->{name}"></td>
- </tr>
- <tr>
- <th align=right>| . $locale->text('E-mail') . qq|</th>
- <td><input name=email size=30 value="$myconfig->{email}"></td>
- </tr>
- <tr valign=top>
- <th align=right>| . $locale->text('Signature') . qq|</th>
- <td><textarea name=signature rows=3 cols=35>$myconfig->{signature}</textarea></td>
- </tr>
- <tr>
- <th align=right>| . $locale->text('Phone') . qq|</th>
- <td><input name=tel size=14 value="$myconfig->{tel}"></td>
- </tr>
- <tr>
- <th align=right>| . $locale->text('Fax') . qq|</th>
- <td><input name=fax size=14 value="$myconfig->{fax}"></td>
- </tr>
- <tr>
- <th align=right>| . $locale->text('Company') . qq|</th>
- <td><input name=company size=35 value="$myconfig->{company}"></td>
- </tr>
- <tr valign=top>
- <th align=right>| . $locale->text('Address') . qq|</th>
- <td><textarea name=address rows=4 cols=35>$myconfig->{address}</textarea></td>
- </tr>
- <tr valign=top>
- <th align=right>| . $locale->text('Steuernummer') . qq|</th>
- <td><input name=steuernummer size=14 value="$myconfig->{steuernummer}"></td>
- </tr>
- <tr valign=top>
- <th align=right>| . $locale->text('Ust-IDNr') . qq|</th>
- <td><input name=co_ustid size=14 value="$myconfig->{co_ustid}"></td>
- </tr>
- <tr valign=top>
- <th align=right>| . $locale->text('DUNS-Nr') . qq|</th>
- <td><input name=duns size=14 value="$myconfig->{duns}"></td>
- </tr>
- </table>
- </td>
- <td>
- <table>
- <tr>
- <th align=right>| . $locale->text('Date Format') . qq|</th>
- <td><select name=dateformat>$dateformat</select></td>
- </tr>
- <tr>
- <th align=right>| . $locale->text('Number Format') . qq|</th>
- <td><select name=numberformat>$numberformat</select></td>
- </tr>
- <tr>
- <th align=right>| . $locale->text('Dropdown Limit') . qq|</th>
- <td><input name=vclimit value="$myconfig->{vclimit}"></td>
- </tr>
- <tr>
- <th align=right>| . $locale->text('Language') . qq|</th>
- <td><select name=countrycode>$countrycodes</select></td>
- </tr>
- <tr>
- <th align=right>| . $locale->text('Character Set') . qq|</th>
- <td><input name=charset value="$myconfig->{charset}"></td>
- </tr>
- <tr>
- <th align=right>| . $locale->text('Stylesheet') . qq|</th>
- <td><select name=userstylesheet>$selectstylesheet</select></td>
- </tr>
- <tr>
- <th align=right>| . $locale->text('Printer') . qq|</th>
- <td><input name=printer size=20 value="$myconfig->{printer}"></td>
- </tr>
- <tr>
- <th align=right>| . $locale->text('Use Templates') . qq|</th>
- <td><select name=usetemplates>$usetemplates</select></td>
- </tr>
- <tr>
- <th align=right>| . $locale->text('New Templates') . qq|</th>
- <td><input name=newtemplates></td>
- </tr>
- <tr>
- <th align=right>| . $locale->text('Setup Templates') . qq|</th>
- <td><select name=mastertemplates>$mastertemplates</select></td>
- </tr>
- <tr>
- <th align=right>| . $locale->text('Setup Menu') . qq|</th>
- <td><input name=menustyle type=radio class=radio value=neu $neu> New
- <input name=menustyle type=radio class=radio value=old $old> Old</td>
- </tr>
- <input type=hidden name=templates value=$myconfig->{templates}>
- </table>
- </td>
- </tr>
- <tr class=listheading>
- <th colspan=2>| . $locale->text('Database') . qq|</th>
- </tr>|;
-
- # list section for database drivers
- foreach $item (User->dbdrivers) {
-
- print qq|
- <tr>
- <td colspan=2>
- <table>
- <tr>|;
-
- $checked = "";
- if ($myconfig->{dbdriver} eq $item) {
- map { $form->{"${item}_$_"} = $myconfig->{$_} }
- qw(dbhost dbport dbuser dbpasswd dbname sid);
- $checked = "checked";
- }
-
- print qq|
- <th align=right>| . $locale->text('Driver') . qq|</th>
- <td><input name=dbdriver type=radio class=radio value=$item $checked> $item</td>
- <th align=right>| . $locale->text('Host') . qq|</th>
- <td><input name="${item}_dbhost" size=30 value=$form->{"${item}_dbhost"}></td>
- </tr>
- <tr>|;
-
- if ($item eq 'Pg') {
- print qq|
- <th align=right>| . $locale->text('Dataset') . qq|</th>
- <td><input name=Pg_dbname size=15 value=$form->{Pg_dbname}></td>
- <th align=right>| . $locale->text('Port') . qq|</th>
- <td><input name=Pg_dbport size=4 value=$form->{Pg_dbport}></td>
- </tr>
- <tr>
- <th align=right>| . $locale->text('User') . qq|</th>
- <td><input name="${item}_dbuser" size=15 value=$form->{"${item}_dbuser"}></td>
- <th align=right>| . $locale->text('Password') . qq|</th>
- <td><input name="${item}_dbpasswd" type=password size=10 value=$form->{"${item}_dbpasswd"}></td>
- </tr>|;
-
- }
-
- if ($item eq 'Oracle') {
- print qq|
- <th align=right>SID</th>
- <td><input name=Oracle_sid value=$form->{Oracle_sid}></td>
- <th align=right>| . $locale->text('Port') . qq|</th>
- <td><input name=Oracle_dbport size=4 value=$form->{Oracle_dbport}></td>
- </tr>
- <tr>
- <th align=right>| . $locale->text('Dataset') . qq|</th>
- <td><input name="${item}_dbuser" size=15 value=$form->{"${item}_dbuser"}></td>
- <th align=right>| . $locale->text('Password') . qq|</th>
- <td><input name="${item}_dbpasswd" type=password size=10 value=$form->{"${item}_dbpasswd"}></td>
-
- </tr>|;
- }
-
- print qq|
- <input type=hidden name=old_dbpasswd value=$myconfig->{dbpasswd}>
- </table>
- </td>
- </tr>
- <tr>
- <td colspan=2><hr size=2 noshade></td>
- </tr>
-|;
-
- }
-
- # access control
- open(FH, $menufile) or $form->error("$menufile : $!");
-
- # scan for first menu level
- @a = <FH>;
- close(FH);
-
- if (open(FH, "custom_$menufile")) {
- push @a, <FH>;
- }
- close(FH);
-
- foreach $item (@a) {
- next unless $item =~ /\[/;
- next if $item =~ /\#/;
-
- $item =~ s/(\[|\])//g;
- chop $item;
-
- if ($item =~ /--/) {
- ($level, $menuitem) = split /--/, $item, 2;