From 32306b5f8ffe4ce594409aa6e89626740b225a39 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 15 Nov 2004 10:35:56 +0000 Subject: import sql-ledger 2.4.4 --- sql-ledger/bin/mozilla/admin.pl | 626 +++++++---- sql-ledger/bin/mozilla/am.pl | 1911 ++++++++++++++++++++++++++----- sql-ledger/bin/mozilla/ap.pl | 660 ++++++++--- sql-ledger/bin/mozilla/ar.pl | 665 ++++++++--- sql-ledger/bin/mozilla/arap.pl | 75 +- sql-ledger/bin/mozilla/arapprn.pl | 660 +++++++++++ sql-ledger/bin/mozilla/bp.pl | 567 ++++++++++ sql-ledger/bin/mozilla/ca.pl | 127 ++- sql-ledger/bin/mozilla/cp.pl | 430 +++++-- sql-ledger/bin/mozilla/ct.pl | 2244 ++++++++++++++++++++++++++++++++----- sql-ledger/bin/mozilla/gl.pl | 504 +++++++-- sql-ledger/bin/mozilla/hr.pl | 1217 ++++++++++++++++++++ sql-ledger/bin/mozilla/ic.pl | 1768 +++++++++++++++++++++++------ sql-ledger/bin/mozilla/io.pl | 1078 +++++++++++++----- sql-ledger/bin/mozilla/ir.pl | 307 +++-- sql-ledger/bin/mozilla/is.pl | 439 ++++++-- sql-ledger/bin/mozilla/login.pl | 246 ++-- sql-ledger/bin/mozilla/menu.pl | 52 +- sql-ledger/bin/mozilla/oe.pl | 1925 ++++++++++++++++++++++++++----- sql-ledger/bin/mozilla/pe.pl | 781 ++++++++++++- sql-ledger/bin/mozilla/pos.pl | 878 +++++++++++++++ sql-ledger/bin/mozilla/ps.pl | 42 + sql-ledger/bin/mozilla/pw.pl | 73 ++ sql-ledger/bin/mozilla/rc.pl | 292 +++-- sql-ledger/bin/mozilla/rp.pl | 1047 ++++++++++++----- 25 files changed, 15535 insertions(+), 3079 deletions(-) create mode 100644 sql-ledger/bin/mozilla/arapprn.pl create mode 100644 sql-ledger/bin/mozilla/bp.pl create mode 100644 sql-ledger/bin/mozilla/hr.pl create mode 100644 sql-ledger/bin/mozilla/pos.pl create mode 100644 sql-ledger/bin/mozilla/ps.pl create mode 100644 sql-ledger/bin/mozilla/pw.pl (limited to 'sql-ledger/bin/mozilla') diff --git a/sql-ledger/bin/mozilla/admin.pl b/sql-ledger/bin/mozilla/admin.pl index 39247b541..8a4daba78 100644 --- a/sql-ledger/bin/mozilla/admin.pl +++ b/sql-ledger/bin/mozilla/admin.pl @@ -39,6 +39,11 @@ $locale = new Locale $language, "admin"; eval { require DBI; }; $form->error($locale->text('DBI not installed!')) if ($@); +$form->{stylesheet} = "sql-ledger.css"; +$form->{favicon} = "favicon.ico"; +$form->{timeout} = 600; + +require "$form->{path}/pw.pl"; # customization if (-f "$form->{path}/custom_$form->{script}") { @@ -47,22 +52,11 @@ if (-f "$form->{path}/custom_$form->{script}") { } -if (-f "css/sql-ledger.css") { - $form->{stylesheet} = "sql-ledger.css"; -} - - if ($form->{action}) { $subroutine = $locale->findsub($form->{action}); - - if ($subroutine eq 'login') { - if ($form->{rpw}) { - $form->{rpw} = crypt $form->{rpw}, "ro"; - } - } - - &check_password; + + &check_password unless $form->{action} eq 'logout'; &$subroutine; @@ -80,7 +74,7 @@ if ($form->{action}) { password= |; - close(FH); + close FH; } &adminlogin; @@ -94,32 +88,39 @@ password= sub adminlogin { $form->{title} = qq|SQL-Ledger $form->{version} |.$locale->text('Administration'); - - $form->header; - print qq| - + $form->{login} = "root login"; + $form->header(1); + + print qq| + +

|.$locale->text('Version').qq| $form->{version}

|.$locale->text('Administration').qq|

-
+ - + -{path}> +{sessionid}>
|.$locale->text('Password').qq|
-
SQL-Ledger |.$locale->text('website').qq| @@ -133,8 +134,6 @@ sub adminlogin { } - - sub login { &list_users; @@ -142,6 +141,13 @@ sub login { } +sub logout { + + $form->{callback} = "$form->{script}?path=$form->{path}&endsession=1"; + $form->redirect($locale->text('You are logged out')); + +} + sub add_user { @@ -154,7 +160,9 @@ sub add_user { if (-f "css/sql-ledger.css") { $myconfig->{stylesheet} = "sql-ledger.css"; } - $myconfig->{vclimit} = 200; + $myconfig->{vclimit} = 1000; + $myconfig->{menuwidth} = 155; + $myconfig->{timeout} = 3600; &form_header; &form_footer; @@ -183,10 +191,10 @@ sub form_footer { print qq| - - + + {path}> -{rpw}> +{sessionid}> $delete @@ -202,10 +210,17 @@ $delete sub list_users { - $form->error("$memberfile : ".$locale->text('locked!')) if (-f "${memberfile}.LCK"); - open(FH, "$memberfile") or $form->error("$memberfile : $!"); - + + $nologin = qq| +|; + + if (-e "$userspath/nologin") { + $nologin = qq| +|; + } + + while () { chop; @@ -223,6 +238,7 @@ sub list_users { close(FH); # type=submit $locale->text('Pg Database Administration') +# type=submit $locale->text('PgPP Database Administration') # type=submit $locale->text('Oracle Database Administration') foreach $item (User->dbdrivers) { @@ -242,6 +258,7 @@ sub list_users { $form->{title} = "SQL-Ledger ".$locale->text('Accounting')." ".$locale->text('Administration'); + $form->{login} = "root login"; $form->header; print qq| @@ -267,7 +284,7 @@ sub list_users { |; foreach $key (sort keys %member) { - $href = "$script?action=edit&login=$key&path=$form->{path}&root=$form->{root}&rpw=$form->{rpw}"; + $href = "$script?action=edit&login=$key&path=$form->{path}&sessionid=$form->{sessionid}"; $href =~ s/ /%20/g; $member{$key}{templates} =~ s/^$templates\///; @@ -303,13 +320,15 @@ print qq| {path}> -{rpw}> - +{sessionid}>
$dbdrivers +$nologin + + @@ -317,35 +336,6 @@ $dbdrivers
|.$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| -

- -

- - - - - - - - -
SQL-Ledger |.$locale->text('Accounting')." ".$locale->text('Login').qq|
- - - - - - - - - - - -{path}> -
|.$locale->text('Name').qq| 
|.$locale->text('Password').qq|
-
- -
- |; @@ -354,7 +344,6 @@ $dbdrivers - sub form_header { # if there is a login, get user @@ -376,17 +365,18 @@ sub form_header { $dateformat .= ($item eq $myconfig->{dateformat}) ? "
|; } @@ -712,6 +744,8 @@ sub save { # no spaces allowed in login name ($form->{login}) = split / /, $form->{login}; + + $form->isblank("login", $locale->text('Login name missing!')); # check for duplicates if (!$form->{edit}) { @@ -722,11 +756,6 @@ sub save { } } - # does stylesheet exist - if ($form->{userstylesheet}) { - $form->error($locale->text('Stylesheet').": css/$form->{userstylesheet} ".$locale->text('does not exist')) unless (-f "css/$form->{userstylesheet}"); - } - # no spaces allowed in directories ($form->{newtemplates}) = split / /, $form->{newtemplates}; @@ -736,7 +765,6 @@ sub save { $form->{templates} = ($form->{usetemplates}) ? $form->{usetemplates} : $form->{login}; } - # is there a basedir if (! -d "$templates") { $form->error($locale->text('Directory').": $templates ".$locale->text('does not exist')); @@ -760,38 +788,33 @@ sub save { } delete $form->{$item}; } - + # check which database was filled in + + $form->{dbhost} = $form->{"$form->{dbdriver}_dbhost"}; + $form->{dbport} = $form->{"$form->{dbdriver}_dbport"}; + $form->{dbpasswd} = $form->{"$form->{dbdriver}_dbpasswd"}; + $form->{dbuser} = $form->{"$form->{dbdriver}_dbuser"}; + $form->{dbname} = $form->{"$form->{dbdriver}_dbname"}; + if ($form->{dbdriver} eq 'Oracle') { $form->{sid} = $form->{Oracle_sid}, ; - $form->{dbhost} = $form->{Oracle_dbhost}, ; - $form->{dbport} = $form->{Oracle_dbport}; - $form->{dbpasswd} = $form->{Oracle_dbpasswd}; - $form->{dbuser} = $form->{Oracle_dbuser}; - $form->{dbname} = $form->{Oracle_dbuser}; $form->isblank("dbhost", $locale->text('Hostname missing!')); $form->isblank("dbport", $locale->text('Port missing!')); $form->isblank("dbuser", $locale->text('Dataset missing!')); } - if ($form->{dbdriver} eq 'Pg') { - $form->{dbhost} = $form->{Pg_dbhost}; - $form->{dbport} = $form->{Pg_dbport}; - $form->{dbpasswd} = $form->{Pg_dbpasswd}; - $form->{dbuser} = $form->{Pg_dbuser}; - $form->{dbname} = $form->{Pg_dbname}; - + if ($form->{dbdriver} =~ /Pg/) { $form->isblank("dbname", $locale->text('Dataset missing!')); $form->isblank("dbuser", $locale->text('Database User missing!')); } - # set admin - $form->{admin} = "" unless $form->{admin}; - foreach $item (keys %{$form}) { $myconfig->{$item} = $form->{$item}; } + $myconfig->{password} = $form->{new_password} if $form->{new_password} ne $form->{old_password}; + delete $myconfig->{stylesheet}; if ($form->{userstylesheet}) { $myconfig->{stylesheet} = $form->{userstylesheet}; @@ -808,8 +831,8 @@ sub save { umask(007); # copy templates to the directory - opendir TEMPLATEDIR, "$templates/." or $form-error("$templates : $!"); - @templates = grep /$form->{mastertemplates}.*?\.(html|tex)$/, readdir TEMPLATEDIR; + opendir TEMPLATEDIR, "$templates/." or $form->error("$templates : $!"); + @templates = grep /$form->{mastertemplates}.*?\.(html|tex|txt)$/, readdir TEMPLATEDIR; closedir TEMPLATEDIR; foreach $file (@templates) { @@ -838,11 +861,14 @@ sub delete { $form->{templates} = ($form->{templates}) ? "$templates/$form->{templates}" : "$templates/$form->{login}"; - $form->error("$memberfile : ".$locale->text('locked!')) if (-f ${memberfile}.LCK); + $form->error("$memberfile ".$locale->text('locked!')) if (-f ${memberfile}.LCK); open(FH, ">${memberfile}.LCK") or $form->error("${memberfile}.LCK : $!"); close(FH); - open(CONF, "+<$memberfile") or $form->error("$memberfile : $!"); + if (! open(CONF, "+<$memberfile")) { + unlink "${memberfile}.LCK"; + $form->error("$memberfile : $!"); + } @config = ; @@ -851,6 +877,8 @@ sub delete { while ($line = shift @config) { + chop $line; + if ($line =~ /^\[/) { last if ($line =~ /\[$form->{login}\]/); $login = &login_name($line); @@ -860,25 +888,31 @@ sub delete { $user{$login} = &get_value($line); } - print CONF $line; + print CONF "$line\n"; } # remove everything up to next login or EOF # and save template variable while ($line = shift @config) { - if ($line =~ /^templates=/) { - $templatedir = &get_value($line); - } + + chop $line; + + ($key, $value) = split /=/, $line, 2; + $myconfig{$key} = $value; + last if ($line =~ /^\[/); } # this one is either the next login or EOF - print CONF $line; + print CONF "$line\n"; $login = &login_name($line); while ($line = shift @config) { + + chop $line; + if ($line =~ /^\[/) { $login = &login_name($line); } @@ -887,7 +921,7 @@ sub delete { $user{$login} = &get_value($line); } - print CONF $line; + print CONF "$line\n"; } close(CONF); @@ -895,9 +929,11 @@ sub delete { # scan %user for $templatedir foreach $login (keys %user) { - last if ($found = ($templatedir eq $user{$login})); + last if ($found = ($myconfig{templates} eq $user{$login})); } + map { $form->{$_} = $myconfig{$_} } keys %myconfig; + # if found keep directory otherwise delete if (!$found) { # delete it if there is a template directory @@ -905,13 +941,16 @@ sub delete { if (-d "$dir") { unlink <$dir/*.html>; unlink <$dir/*.tex>; + unlink <$dir/*.txt>; rmdir "$dir"; } } # delete config file for user unlink "$userspath/$form->{login}.conf"; - + + User::delete_login("", \%$form); + $form->redirect($locale->text('User deleted!')); } @@ -930,10 +969,10 @@ sub login_name { sub get_value { my $line = shift; - my ($null, $value) = split(/=/, $line, 2); + my ($null, $value) = split /=/, $line, 2; # remove comments - $value =~ s/\s#.*//g; + $value =~ s/^\s*#.*//g; # remove any trailing whitespace $value =~ s/^\s*(.*?)\s*$/$1/; @@ -946,22 +985,42 @@ sub get_value { sub change_admin_password { $form->{title} = qq|SQL-Ledger |.$locale->text('Accounting')." ".$locale->text('Administration')." / ".$locale->text('Change Admin Password'); - + + $form->{login} = "root login"; $form->header; print qq| - -

|.$locale->text('Change Admin Password').qq|

-
{script}> -|.$locale->text('Password').qq| + + + + + + + + + - +
|.$locale->text('Change Password').qq|
+ + + + + + + + + +
|.$locale->text('Password').qq|
|.$locale->text('Confirm').qq|
+
+ +
+
{path}> -{rpw}> +{sessionid}>

@@ -977,12 +1036,14 @@ sub change_admin_password { sub change_password { - $root->{password} = $form->{password}; + $form->error($locale->text('Passwords do not match!')) if $form->{new_password} ne $form->{confirm_password}; + + $root->{password} = $form->{new_password}; $root->{'root login'} = 1; $root->save_member($memberfile); - $form->{callback} = "$form->{script}?action=list_users&path=$form->{path}&root=$form->{root}&rpw=$root->{password}"; + $form->{callback} = "$form->{script}?action=list_users&path=$form->{path}&sessionid=$form->{sessionid}"; $form->redirect($locale->text('Password changed!')); @@ -991,11 +1052,26 @@ sub change_password { sub check_password { - $root = new User "$memberfile", $form->{root}; + $root = new User "$memberfile", "root login"; if ($root->{password}) { - if ($root->{password} ne $form->{rpw}) { - $form->error($locale->text('Incorrect Password!')); + + if ($form->{password}) { + $form->{callback} .= "&password=$form->{password}" if $form->{callback}; + $form->{sessionid} = time; + if ($root->{password} ne crypt $form->{password}, 'ro') { + &getpassword; + exit; + } + } else { + if ($ENV{HTTP_USER_AGENT}) { + $ENV{HTTP_COOKIE} =~ s/;\s*/;/g; + %cookie = split /[=;]/, $ENV{HTTP_COOKIE}; + if ((! $cookie{"SQL-Ledger-root login"}) || $cookie{"SQL-Ledger-root login"} ne $form->{sessionid}) { + &getpassword(1); + exit; + } + } } } @@ -1010,6 +1086,14 @@ sub pg_database_administration { } +sub pgpp_database_administration { + + $form->{dbdriver} = 'PgPP'; + &dbselect_source; + +} + + sub oracle_database_administration { $form->{dbdriver} = 'Oracle'; @@ -1035,6 +1119,8 @@ sub dbdriver_defaults { } ); + $driverdefaults{PgPP} = $driverdefaults{Pg}; + map { $form->{$_} = $driverdefaults{$form->{dbdriver}}{$_} } keys %{ $driverdefaults{Pg} }; } @@ -1045,73 +1131,61 @@ sub dbselect_source { &dbdriver_defaults; $msg{Pg} = $locale->text('Leave host and port field empty unless you want to make a remote connection.'); + $msg{PgPP} = $msg{Pg}; $msg{Oracle} = $locale->text('You must enter a host and port for local and remote connections!'); $form->{title} = "SQL-Ledger ".$locale->text('Accounting')." / ".$locale->text('Database Administration'); - + $form->{login} = "root login"; $form->header; print qq| -

$form->{title}

{script}> - + +
- - - - - - - -{dbdriver}> - - -
|.$locale->text('Database').qq|
- - - - - - - - - - - - - - - - - - - - + - - - - -
|.$locale->text('Host').qq|{dbhost}>|.$locale->text('Port').qq|{dbport}>
|.$locale->text('User').qq|{dbuser}>|.$locale->text('Password').qq|
+ + + + + {dbdriver}> + + + +
|.$locale->text('Database').qq|
+ + + + + + + + + + + + + + + + + + + +
|.$locale->text('Host').qq|{dbhost}>|.$locale->text('Port').qq|{dbport}>
|.$locale->text('User').qq|{dbuser}>|.$locale->text('Password').qq|
$form->{connectstring}{dbdefault}>
+
-
$form->{connectstring}{dbdefault}>
- -
- - - + {path}> -{rpw}> +{sessionid}> -

@@ -1120,7 +1194,8 @@ sub dbselect_source { -

|.$locale->text('This is a preliminary check for existing sources. Nothing will be created or deleted at this stage!') @@ -1149,6 +1224,7 @@ sub update_dataset { $form->{title} = "SQL-Ledger ".$locale->text('Accounting')." ".$locale->text('Database Administration')." / ".$locale->text('Update Dataset'); + $form->{login} = "root login"; $form->header; print qq| @@ -1161,8 +1237,8 @@ sub update_dataset { foreach $key (sort keys %needsupdate) { - if ($needsupdate{$key} lt $form->{dbversion}) { - $upd .= qq|
$key\n|; + if ($needsupdate{$key} ne $form->{dbversion}) { + $upd .= qq| $key\n|; $form->{dbupdate} .= "db$key "; } } @@ -1173,7 +1249,7 @@ sub update_dataset { if ($form->{dbupdate}) { print qq| - +
{script}> {dbdriver}> @@ -1191,19 +1267,23 @@ sub update_dataset { $upd - - + + + @@ -1237,41 +1317,53 @@ sub dbupdate { sub create_dataset { - foreach $item (sort User->dbsources(\%$form)) { - $dbsources .= "[$item] "; - } + @dbsources = sort User->dbsources(\%$form); - opendir SQLDIR, "sql/." or $form-error($!); + opendir SQLDIR, "sql/." or $form->error($!); foreach $item (sort grep /-chart\.sql/, readdir SQLDIR) { next if ($item eq 'Default-chart.sql'); $item =~ s/-chart\.sql//; - push @charts, qq|  $item|; + push @charts, qq|$item|; } closedir SQLDIR; # add Default at beginning - @charts = (qq| Default|, @charts); + unshift @charts, qq|Default|; - $selectencoding = qq|
+
- + - {path}> -{rpw}> +{sessionid}> +
+ +
+
@@ -1291,8 +1383,13 @@ sub create_dataset { - + @@ -1301,7 +1398,7 @@ sub create_dataset { - + @@ -1311,14 +1408,36 @@ sub create_dataset { - - + + + + + +
 
|.$locale->text('Existing Datasets').qq|$dbsources +|; + map { print "[ $_ ] " } @dbsources; + + print qq| +
|.$locale->text('Multibyte Encoding').qq|
|.$locale->text('Create Chart of Accounts').qq|@charts|.$locale->text('Create Chart of Accounts').qq| + +|; + while (@charts) { + print qq| + +|; + + map { print "\n" } (0 .. 2); + + print qq| + +|; + + splice @charts, 0, 3; + } + + print qq| +
$charts[$_]
+
+
+
- -


-
{dbdriver}> {dbuser}> {dbhost}> @@ -1326,22 +1445,19 @@ sub create_dataset { {dbpasswd}> {dbdefault}> - + - {path}> -{rpw}> +{sessionid}> +
- - - |; @@ -1357,6 +1473,7 @@ sub dbcreate { $form->{title} = "SQL-Ledger ".$locale->text('Accounting')." ".$locale->text('Database Administration')." / ".$locale->text('Create Dataset'); + $form->{login} = "root login"; $form->header; print qq| @@ -1372,9 +1489,8 @@ sub dbcreate { .qq| - - +{sessionid}> @@ -1393,7 +1509,7 @@ sub delete_dataset { if (@dbsources = User->dbsources_unused(\%$form, $memberfile)) { foreach $item (sort @dbsources) { - $dbsources .= qq| $item\n
|; + $dbsources .= qq| $item |; } } else { $form->error($locale->text('Nothing to delete!')); @@ -1401,18 +1517,17 @@ sub delete_dataset { $form->{title} = "SQL-Ledger ".$locale->text('Accounting')." ".$locale->text('Database Administration')." / ".$locale->text('Delete Dataset'); + $form->{login} = "root login"; $form->header; print qq| - -

$form->{title}

{script}> - +
@@ -1424,9 +1539,7 @@ sub delete_dataset { @@ -1449,11 +1564,6 @@ sub delete_dataset { -

|.$locale->text('Select a Dataset to delete and press "Continue"') - -.qq| - - |; @@ -1471,6 +1581,7 @@ sub dbdelete { $form->{title} = "SQL-Ledger ".$locale->text('Accounting')." ".$locale->text('Database Administration')." / ".$locale->text('Delete Dataset'); + $form->{login} = "root login"; $form->header; print qq| @@ -1486,9 +1597,8 @@ $form->{db} |.$locale->text('successfully deleted!') .qq| - - +{sessionid}> @@ -1502,3 +1612,27 @@ $form->{db} |.$locale->text('successfully deleted!') } + +sub unlock_system { + + unlink "$userspath/nologin"; + + $form->{callback} = "$form->{script}?action=list_users&path=$form->{path}&sessionid=$form->{sessionid}"; + + $form->redirect($locale->text('Lockfile removed!')); + +} + + +sub lock_system { + + open(FH, ">$userspath/nologin") or $form->error($locale->text('Cannot create Lock!')); + close(FH); + + $form->{callback} = "$form->{script}?action=list_users&path=$form->{path}&sessionid=$form->{sessionid}"; + + $form->redirect($locale->text('Lockfile created!')); + +} + + diff --git a/sql-ledger/bin/mozilla/am.pl b/sql-ledger/bin/mozilla/am.pl index 7e36cfdc9..834290343 100644 --- a/sql-ledger/bin/mozilla/am.pl +++ b/sql-ledger/bin/mozilla/am.pl @@ -1,6 +1,6 @@ #===================================================================== # SQL-Ledger Accounting -# Copyright (c) 1998-2002 +# Copyright (c) 2001 # # Author: Dieter Simader # Email: dsimader@sql-ledger.org @@ -30,6 +30,8 @@ use SL::AM; use SL::CA; use SL::Form; use SL::User; +use SL::RP; +use SL::GL; 1; @@ -37,42 +39,54 @@ use SL::User; -sub add { +sub add { &{ "add_$form->{type}" } }; +sub edit { &{ "edit_$form->{type}" } }; +sub save { &{ "save_$form->{type}" } }; +sub delete { &{ "delete_$form->{type}" } }; + + +sub save_as_new { + + delete $form->{id}; + + &save; + +} + +sub add_account { + $form->{title} = "Add"; $form->{charttype} = "A"; - $form->{callback} = "$form->{script}?action=list&path=$form->{path}&login=$form->{login}&password=$form->{password}" unless $form->{callback}; + $form->{callback} = "$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback}; - &form_header; + &account_header; &form_footer; } -sub edit { +sub edit_account { + $form->{title} = "Edit"; - - # if it is a template - if ($form->{file}) { - $form->{type} = "template"; - &edit_template; - exit; - } - + + $form->{accno} =~ s/\\'/'/g; + $form->{accno} =~ s/\\\\/\\/g; + AM->get_account(\%myconfig, \%$form); foreach my $item (split(/:/, $form->{link})) { $form->{$item} = "checked"; } - &form_header; + &account_header; &form_footer; } -sub form_header { +sub account_header { $form->{title} = $locale->text("$form->{title} Account"); @@ -80,7 +94,7 @@ sub form_header { $checked{"$form->{category}_"} = "checked"; $checked{CT_tax} = ($form->{CT_tax}) ? "" : "checked"; - $form->{description} =~ s/"/"/g; + map { $form->{$_} = $form->quote($form->{$_}) } qw(accno description); # this is for our parser only! # type=submit $locale->text('Add Account') @@ -102,8 +116,6 @@ sub form_header { {fxgain_accno_id}> {fxloss_accno_id}> -{amount}> -

|.$locale->text('The following Datasets are not in use and can be deleted').qq|
- -
-
+

{dbdriver}> {dbuser}> {dbhost}> @@ -1434,14 +1547,16 @@ sub delete_dataset { {dbpasswd}> {dbdefault}> - + - - +{sessionid}> +


+ +
@@ -114,7 +126,7 @@ sub form_header {
$form->{title}
- + @@ -126,11 +138,13 @@ sub form_header {
|.$locale->text('Account Number').qq|{accno}>
|.$locale->text('Description').qq|
+ + +
 |.$locale->text('Asset').qq|\n
+  |.$locale->text('Contra').qq|\n
 |.$locale->text('Liability').qq|\n
 |.$locale->text('Equity').qq|\n
 |.$locale->text('Income').qq|\n
 |.$locale->text('Expense') .qq|
   |.$locale->text('Heading').qq|
 |.$locale->text('Account') @@ -169,31 +183,32 @@ if ($form->{charttype} eq "A") {
|.$locale->text('Payables').qq| |.$locale->text('Parts Inventory').qq| |.$locale->text('Service Items').qq||.$locale->text('Labor/Overhead').qq|
{AR_amount}> |.$locale->text('Income').qq|\n
{AR_paid}> |.$locale->text('Payment').qq|\n
- {AR_tax}> |.$locale->text('Tax') - .qq| + {AR_tax}> |.$locale->text('Tax') .qq|
{AP_amount}> |.$locale->text('Expense/Asset').qq|\n
{AP_paid}> |.$locale->text('Payment').qq|\n
- {AP_tax}> |.$locale->text('Tax') - .qq| + {AP_tax}> |.$locale->text('Tax') .qq|
- {IC_sale}> |.$locale->text('Sales').qq|\n
+ {IC_sale}> |.$locale->text('Income').qq|\n
{IC_cogs}> |.$locale->text('COGS').qq|\n
- {IC_taxpart}> |.$locale->text('Tax') - .qq| + {IC_taxpart}> |.$locale->text('Tax') .qq|
{IC_income}> |.$locale->text('Income').qq|\n
{IC_expense}> |.$locale->text('Expense').qq|\n
- {IC_taxservice}> |.$locale->text('Tax') - .qq| + {IC_taxservice}> |.$locale->text('Tax') .qq| +
+
+ {IC_cogs}> |.$locale->text('COGS').qq|\n
@@ -241,16 +256,27 @@ sub form_footer { {path}> {login}> -{password}> +{sessionid}>
|; if ($form->{id}) { + print qq| + +|; + } + + if ($form->{id} && $form->{orphaned}) { print qq||; } + if ($form->{menubar}) { + require "$form->{path}/menu.pl"; + &menubar; + } + print qq| @@ -260,37 +286,57 @@ sub form_footer { } - -sub save { &{ "save_$form->{type}" } }; sub save_account { $form->isblank("accno", $locale->text('Account Number missing!')); $form->isblank("category", $locale->text('Account Type missing!')); + # check for conflicting accounts + if ($form->{AR} || $form->{AP} || $form->{IC}) { + map { $a .= $form->{$_} } qw(AR AP IC); + $form->error($locale->text('Cannot set account for more than one of AR, AP or IC')) if length $a > 2; + + map { $form->error("$form->{AR}$form->{AP}$form->{IC} ". $locale->text('account cannot be set to any other type of account')) if $form->{$_} } qw(AR_amount AR_tax AR_paid AP_amount AP_tax AP_paid IC_sale IC_cogs IC_taxpart IC_income IC_expense IC_taxservice); + } + + foreach $item ("AR", "AP") { + $i = 0; + map { $i++ if $form->{$_} } ("${item}_amount", "${item}_paid", "${item}_tax"); + $form->error($locale->text('Cannot set multiple options for')." $item") if $i > 1; + } + + $i = 0; + map { $i++ if $form->{$_} } qw(IC_sale IC_cogs IC_taxpart); + $form->error($locale->text('Cannot set multiple options for Parts Inventory')) if $i > 1; + + $i = 0; + map { $i++ if $form->{$_} } qw(IC_income IC_expense IC_taxservice); + $form->error($locale->text('Cannot set multiple options for Service Items')) if $i > 1; + $form->redirect($locale->text('Account saved!')) if (AM->save_account(\%myconfig, \%$form)); $form->error($locale->text('Cannot save account!')); } -sub list { +sub list_account { CA->all_accounts(\%myconfig, \%$form); $form->{title} = $locale->text('Chart of Accounts'); # construct callback - $callback = "$form->{script}?action=list&path=$form->{path}&login=$form->{login}&password=$form->{password}"; + $callback = "$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; @column_index = qw(accno gifi_accno description debit credit link); - $column_header{accno} = qq||.$locale->text('Account').qq||; - $column_header{gifi_accno} = qq||.$locale->text('GIFI').qq||; - $column_header{description} = qq||.$locale->text('Description').qq||; - $column_header{debit} = qq||.$locale->text('Debit').qq||; - $column_header{credit} = qq||.$locale->text('Credit').qq||; - $column_header{link} = qq||.$locale->text('Link').qq||; + $column_header{accno} = qq||.$locale->text('Account').qq||; + $column_header{gifi_accno} = qq||.$locale->text('GIFI').qq||; + $column_header{description} = qq||.$locale->text('Description').qq||; + $column_header{debit} = qq||.$locale->text('Debit').qq||; + $column_header{credit} = qq||.$locale->text('Credit').qq||; + $column_header{link} = qq||.$locale->text('Link').qq||; $form->header; @@ -299,8 +345,10 @@ sub list { print qq| - - +
$form->{title}
+ + + |; @@ -319,15 +367,10 @@ sub list { $ca->{debit} = " "; $ca->{credit} = " "; - # needed if we can delete an account - $amount = 0; - if ($ca->{amount} > 0) { - $amount = $ca->{amount}; $ca->{credit} = $form->format_amount(\%myconfig, $ca->{amount}, 2, " "); } if ($ca->{amount} < 0) { - $amount = -$ca->{amount}; $ca->{debit} = $form->format_amount(\%myconfig, -$ca->{amount}, 2, " "); } @@ -336,8 +379,8 @@ sub list { if ($ca->{charttype} eq "H") { print qq||; - $column_data{accno} = qq||; - $column_data{gifi_accno} = qq||; + $column_data{accno} = qq||; + $column_data{gifi_accno} = qq||; $column_data{description} = qq||; $column_data{debit} = qq||; $column_data{credit} = qq| |; @@ -347,8 +390,8 @@ sub list { $i++; $i %= 2; print qq| |; - $column_data{accno} = qq||; - $column_data{gifi_accno} = qq||; + $column_data{accno} = qq||; + $column_data{gifi_accno} = qq||; $column_data{description} = qq||; $column_data{debit} = qq||; $column_data{credit} = qq||; @@ -372,16 +415,10 @@ sub list { } -sub delete { &{ "delete_$form->{type}" } }; - sub delete_account { $form->{title} = $locale->text('Delete Account'); - if ($form->{amount} != 0) { - $form->error($locale->text('Transactions exist; cannot delete account!')); - } - foreach $id (qw(inventory_accno_id income_accno_id expense_accno_id fxgain_accno_id fxloss_accno_id)) { if ($form->{id} == $form->{$id}) { $form->error($locale->text('Cannot delete default account!')); @@ -396,16 +433,15 @@ sub delete_account { sub list_gifi { - @{ $form->{fields} } = (accno, description); + @{ $form->{fields} } = qw(accno description); $form->{table} = "gifi"; - $form->{sortorder} = "accno"; AM->gifi_accounts(\%myconfig, \%$form); $form->{title} = $locale->text('GIFI'); # construct callback - $callback = "$form->{script}?action=list_gifi&path=$form->{path}&login=$form->{login}&password=$form->{password}"; + $callback = "$form->{script}?action=list_gifi&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; @column_index = qw(accno description); @@ -419,8 +455,10 @@ sub list_gifi { print qq| -
$form->{title}
{script}?action=edit&id=$ca->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ca->{accno}{script}?action=edit_gifi&accno=$ca->{gifi_accno}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ca->{gifi_accno} {script}?action=edit_account&id=$ca->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ca->{accno}{script}?action=edit_gifi&accno=$ca->{gifi_accno}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ca->{gifi_accno} $ca->{description}   
{script}?action=edit&id=$ca->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback&amount=$amount>$ca->{accno}{script}?action=edit_gifi&accno=$ca->{gifi_accno}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback&amount=$amount>$ca->{gifi_accno} {script}?action=edit_account&id=$ca->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ca->{accno}{script}?action=edit_gifi&accno=$ca->{gifi_accno}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ca->{gifi_accno} $ca->{description} $ca->{debit}$ca->{credit}
- +
$form->{title}
+ + + |; @@ -441,7 +479,7 @@ sub list_gifi { print qq| |; - $column_data{accno} = qq||; + $column_data{accno} = qq||; $column_data{description} = qq||; map { print "$column_data{$_}\n" } @column_index; @@ -466,7 +504,7 @@ sub add_gifi { $form->{title} = "Add"; # construct callback - $form->{callback} = "$form->{script}?action=list_gifi&path=$form->{path}&login=$form->{login}&password=$form->{password}"; + $form->{callback} = "$form->{script}?action=list_gifi&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; $form->{coa} = 1; @@ -479,8 +517,10 @@ sub add_gifi { sub edit_gifi { $form->{title} = "Edit"; - + AM->get_gifi(\%myconfig, \%$form); + + $form->error($locale->text('Account does not exist!')) unless $form->{accno}; &gifi_header; &gifi_footer; @@ -495,7 +535,7 @@ sub gifi_header { # $locale->text('Add GIFI') # $locale->text('Edit GIFI') - $form->{description} =~ s/"/"/g; + map { $form->{$_} = $form->quote($form->{$_}) } qw(accno description); $form->header; @@ -504,7 +544,7 @@ sub gifi_header { {script}> -{accno}> +
$form->{title}
{script}?action=edit_gifi&coa=1&accno=$ca->{accno}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ca->{accno}{script}?action=edit_gifi&coa=1&accno=$ca->{accno}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ca->{accno}$ca->{description} 
@@ -517,7 +557,7 @@ sub gifi_header {
- + @@ -543,23 +583,27 @@ sub gifi_footer { {path}> {login}> -{password}> +{sessionid}> -
-|; +
|; if ($form->{coa}) { print qq| |; - if ($form->{accno}) { + if ($form->{accno} && $form->{orphaned}) { print qq||; } } + if ($form->{menubar}) { + require "$form->{path}/menu.pl"; + &menubar; + } + print qq| - + @@ -585,10 +629,11 @@ sub copy_to_coa { delete $form->{id}; $form->{gifi_accno} = $form->{accno}; + $form->{title} = "Add"; $form->{charttype} = "A"; - &form_header; + &account_header; &form_footer; } @@ -602,317 +647,1222 @@ sub delete_gifi { } -sub display_stylesheet { - - $form->{file} = "css/$myconfig{stylesheet}"; - &display_form; +sub add_department { + + $form->{title} = "Add"; + $form->{role} = "P"; + $form->{callback} = "$form->{script}?action=add_department&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback}; + + &department_header; + &form_footer; + } -sub display_form { +sub edit_department { - $form->{file} =~ s/^(.:)*?\/|\.\.\///g; - $form->{file} =~ s/^\/*//g; - $form->{file} =~ s/$userspath//; + $form->{title} = "Edit"; - $form->error("$!: $form->{file}") unless -f $form->{file}; + AM->get_department(\%myconfig, \%$form); - AM->load_template(\%$form); + &department_header; + &form_footer; - $form->{title} = $form->{file}; +} + + +sub list_department { + + AM->departments(\%myconfig, \%$form); + + $href = "$form->{script}?action=list_department&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; + + $form->sort_order(); + + $form->{callback} = "$form->{script}?action=list_department&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; + + $callback = $form->escape($form->{callback}); + + $form->{title} = $locale->text('Departments'); + + @column_index = qw(description cost profit); + + $column_header{description} = qq||; + $column_header{cost} = qq||; + $column_header{profit} = qq||; - # if it is anything but html - if ($form->{file} !~ /\.html$/) { - $form->{body} = "
\n$form->{body}\n
"; - } - $form->header; print qq| -$form->{body} +
|.$locale->text('GIFI').qq|{accno}>
|.$locale->text('Description').qq| |.$locale->text('Description').qq||.$locale->text('Cost Center').qq||.$locale->text('Profit Center').qq|
+ + + + + + + + + + +
$form->{title}
+ + +|; + + map { print "$column_header{$_}\n" } @column_index; + + print qq| + +|; + + foreach $ref (@{ $form->{ALL} }) { + + $i++; $i %= 2; + + print qq| + +|; + + $costcenter = ($ref->{role} eq "C") ? "*" : " "; + $profitcenter = ($ref->{role} eq "P") ? "*" : " "; + + $column_data{description} = qq||; + $column_data{cost} = qq||; + $column_data{profit} = qq||; + + map { print "$column_data{$_}\n" } @column_index; + + print qq| + +|; + } + + print qq| +
{script}?action=edit_department&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{description}$costcenter$profitcenter
+

+
{script}> -{file}> + + + {path}> {login}> -{password}> +{sessionid}> - -
+|; + if ($form->{menubar}) { + require "$form->{path}/menu.pl"; + &menubar; + } - - + print qq| + + + + |; - + } -sub edit_template { +sub department_header { - AM->load_template(\%$form); + $form->{title} = $locale->text("$form->{title} Department"); - $form->{title} = $locale->text('Edit Template'); - # convert   to &nbsp; - $form->{body} =~ s/ /&nbsp;/gi; - +# $locale->text('Add Department') +# $locale->text('Edit Department') - $form->header; + $form->{description} = $form->quote($form->{description}); + + if (($rows = $form->numtextrows($form->{description}, 60)) > 1) { + $description = qq||; + } else { + $description = qq||; + } + + $costcenter = "checked" if $form->{role} eq "C"; + $profitcenter = "checked" if $form->{role} eq "P"; + $form->header; + print qq|
{script}> -{file}> - +{id}> + -{path}> -{login}> -{password}> + + + + + + + + + + + + + + + +
$form->{title}
|.$locale->text('Description').qq|$description
|.$locale->text('Cost Center').qq| + |.$locale->text('Profit Center').qq| +

+|; - +} - -
- +sub save_department { -
+ $form->isblank("description", $locale->text('Description missing!')); + AM->save_department(\%myconfig, \%$form); + $form->redirect($locale->text('Department saved!')); +} - - -|; + +sub delete_department { + + AM->delete_department(\%myconfig, \%$form); + $form->redirect($locale->text('Department deleted!')); } -sub save_template { +sub add_business { - AM->save_template(\%$form); - $form->redirect($locale->text('Template saved!')); + $form->{title} = "Add"; + $form->{callback} = "$form->{script}?action=add_business&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback}; + + &business_header; + &form_footer; + } -sub config { +sub edit_business { - # get defaults for account numbers and last numbers - AM->defaultaccounts(\%myconfig, \%$form); + $form->{title} = "Edit"; - 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}) ? "