From 666fd833584fe2e3618a397fe9d9a9bdf4c5b94b Mon Sep 17 00:00:00 2001 From: einhverfr Date: Thu, 26 Apr 2007 18:00:56 +0000 Subject: Doing a simple Perltidy commit so that I can evaluate differences between the branches and make sure patches are up to date git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1103 4979c152-3d1c-0410-bac9-87ea11338e46 --- bin/aa.pl | 3779 +++++++++++++++++++++----------------- bin/admin.pl | 1398 ++++++++------- bin/am.pl | 3861 +++++++++++++++++++++------------------ bin/ap.pl | 9 +- bin/ar.pl | 9 +- bin/arap.pl | 1160 ++++++------ bin/arapprn.pl | 1535 ++++++++-------- bin/bp.pl | 1164 ++++++------ bin/ca.pl | 638 ++++--- bin/cp.pl | 3088 ++++++++++++++++--------------- bin/ct.pl | 3613 +++++++++++++++++++++---------------- bin/gl.pl | 1661 +++++++++-------- bin/hr.pl | 1520 +++++++++------- bin/ic.pl | 4883 ++++++++++++++++++++++++++++--------------------- bin/io.pl | 3695 ++++++++++++++++++++------------------ bin/ir.pl | 1438 ++++++++------- bin/is.pl | 1499 +++++++++------- bin/jc.pl | 4179 ++++++++++++++++++++++-------------------- bin/login.pl | 256 +-- bin/menu.pl | 373 ++-- bin/oe.pl | 4618 ++++++++++++++++++++++++++--------------------- bin/pe.pl | 3151 ++++++++++++++++++-------------- bin/pos.pl | 2341 +++++++++++++----------- bin/ps.pl | 21 +- bin/pw.pl | 41 +- bin/rc.pl | 985 +++++----- bin/rp.pl | 5488 ++++++++++++++++++++++++++++++-------------------------- 27 files changed, 31008 insertions(+), 25395 deletions(-) (limited to 'bin') diff --git a/bin/aa.pl b/bin/aa.pl index e1f346f3..08a766f2 100644 --- a/bin/aa.pl +++ b/bin/aa.pl @@ -1,1652 +1,2127 @@ -#===================================================================== -# LedgerSMB Small Medium Business Accounting -# http://www.ledgersmb.org/ -# -# Copyright (C) 2006 -# This work contains copyrighted information from a number of sources all used -# with permission. -# -# This file contains source code included with or based on SQL-Ledger which -# is Copyright Dieter Simader and DWS Systems Inc. 2000-2005 and licensed -# under the GNU General Public License version 2 or, at your option, any later -# version. For a full list including contact information of contributors, -# maintainers, and copyright holders, see the CONTRIBUTORS file. -# -# Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork): -# Copyright (c) 2005 -# -# Author: DWS Systems Inc. -# Web: http://www.sql-ledger.org -# -# Contributors: -# -# -# Author: DWS Systems Inc. -# Web: http://www.ledgersmb.org/ -# -# Contributors: -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -#====================================================================== -# -# AR / AP -# -#====================================================================== - -use LedgerSMB::Tax; - -# any custom scripts for this one -if (-f "bin/custom/aa.pl") { - eval { require "bin/custom/aa.pl"; }; -} -if (-f "bin/custom/$form->{login}_aa.pl") { - eval { require "bin/custom/$form->{login}_aa.pl"; }; -} - - -1; -# end of main - - -# this is for our long dates -# $locale->text('January') -# $locale->text('February') -# $locale->text('March') -# $locale->text('April') -# $locale->text('May ') -# $locale->text('June') -# $locale->text('July') -# $locale->text('August') -# $locale->text('September') -# $locale->text('October') -# $locale->text('November') -# $locale->text('December') - -# this is for our short month -# $locale->text('Jan') -# $locale->text('Feb') -# $locale->text('Mar') -# $locale->text('Apr') -# $locale->text('May') -# $locale->text('Jun') -# $locale->text('Jul') -# $locale->text('Aug') -# $locale->text('Sep') -# $locale->text('Oct') -# $locale->text('Nov') -# $locale->text('Dec') - - -sub add { - - $form->{title} = "Add"; - $form->{callback} = "$form->{script}?action=add&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback}; - - &create_links; - - $form->{focus} = "amount_1"; - &display_form; - -} - - -sub edit { - - $form->{title} = "Edit"; - - &create_links; - &display_form; - -} - - -sub display_form { - - &form_header; - &form_footer; - -} - - -sub create_links { - - $form->create_links($form->{ARAP}, \%myconfig, $form->{vc}); - - $duedate = $form->{duedate}; - $taxincluded = $form->{taxincluded}; - - $form->{formname} = "transaction"; - $form->{format} = "postscript" if $myconfig{printer}; - $form->{media} = $myconfig{printer}; - - $form->{selectformname} = qq|\n" : "\n"; - } - - my @formats = qw(1,000.00 1000.00 1.000,00 1000,00 1'000.00); - push @formats, '1 000.00'; - foreach $item (@formats) { - $numberformat .= ($item eq $myconfig->{numberformat}) ? "\n" : "\n"; - } - - - %countrycodes = LedgerSMB::User->country_codes; - $countrycodes = ""; - my $selectedcode = ($myconfig->{countrycode}) ? - $myconfig->{countrycode} : 'en'; - - foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} } keys %countrycodes) { - $countrycodes .= ($selectedcode eq $key) ? qq|| - : qq||; - } - - # is there a templates basedir - if (! -d "${LedgerSMB::Sysconfig::templates}") { - $form->error(__FILE__.':'.__LINE__.': '.$locale->text('Directory [_1] does not exist', ${LedgerSMB::Sysconfig::templates})); - } - - opendir TEMPLATEDIR, "${LedgerSMB::Sysconfig::templates}/." or $form->error(__FILE__.':'.__LINE__.': '."$templates : $!"); - @all = grep !/(^\.\.?|^\.svn)/, readdir TEMPLATEDIR; - closedir TEMPLATEDIR; - - @allhtml = sort grep /\.html/, @all; - - @alldir = (); - for (@all) { - - if (-d "${LedgerSMB::Sysconfig::templates}/$_") { - push @alldir, $_; - } - } - - @allhtml = reverse grep !/Default/, @allhtml; - push @allhtml, 'Default'; - @allhtml = reverse @allhtml; - - foreach $item (sort @alldir) { - - if ($item eq $myconfig->{templates}) { - $usetemplates .= qq|\n|; - } else { - $usetemplates .= qq|\n|; - } - } - - $lastitem = $allhtml[0]; - $lastitem =~ s/-.*//g; - $mastertemplates = qq|\n|; - - foreach $item (@allhtml) { - - $item =~ s/-.*//g; - - if ($item ne $lastitem) { - $mastertemplates .= qq|\n|; - $lastitem = $item; - } - } - - opendir CSS, "css/."; - @all = grep /.*\.css$/, readdir CSS; - closedir CSS; - - foreach $item (@all) { - - if ($item eq $myconfig->{stylesheet}) { - $selectstylesheet .= qq|\n|; - } else { - $selectstylesheet .= qq|\n|; - } - } - - $selectstylesheet .= "\n"; - - if (%{LedgerSMB::Sysconfig::printer} && ${LedgerSMB::Sysconfig::latex}) { - - $selectprinter = "\n"; - - foreach $item (sort keys %{LedgerSMB::Sysconfig::printer}) { - - if ($myconfig->{printer} eq $item) { - $selectprinter .= qq|\n|; - } else { - $selectprinter .= qq|\n|; - } - } - - $printer = qq| + # if there is a login, get user + if ( $form->{login} ) { + + # get user + %{$myconfig} = %{ LedgerSMB::User->fetch_config( $form->{login} ) }; + + for (qw(company address signature)) { + $myconfig->{$_} = $form->quote( $myconfig->{$_} ); + } + for (qw(address signature)) { $myconfig->{$_} =~ s/\\n/\n/g } + + # strip basedir from templates directory + $myconfig->{templates} =~ s/^${LedgerSMB::Sysconfig::templates}\///; + } + + 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} ) + ? "\n" + : "\n"; + } + + my @formats = qw(1,000.00 1000.00 1.000,00 1000,00 1'000.00); + push @formats, '1 000.00'; + foreach $item (@formats) { + $numberformat .= + ( $item eq $myconfig->{numberformat} ) + ? "\n" + : "\n"; + } + + %countrycodes = LedgerSMB::User->country_codes; + $countrycodes = ""; + my $selectedcode = + ( $myconfig->{countrycode} ) ? $myconfig->{countrycode} : 'en'; + + foreach $key ( sort { $countrycodes{$a} cmp $countrycodes{$b} } + keys %countrycodes ) + { + $countrycodes .= + ( $selectedcode eq $key ) + ? qq|| + : qq||; + } + + # is there a templates basedir + if ( !-d "${LedgerSMB::Sysconfig::templates}" ) { + $form->error( + __FILE__ . ':' . __LINE__ . ': ' + . $locale->text( + 'Directory [_1] does not exist', + ${LedgerSMB::Sysconfig::templates} + ) + ); + } + + opendir TEMPLATEDIR, "${LedgerSMB::Sysconfig::templates}/." + or $form->error( __FILE__ . ':' . __LINE__ . ': ' . "$templates : $!" ); + @all = grep !/(^\.\.?|^\.svn)/, readdir TEMPLATEDIR; + closedir TEMPLATEDIR; + + @allhtml = sort grep /\.html/, @all; + + @alldir = (); + for (@all) { + + if ( -d "${LedgerSMB::Sysconfig::templates}/$_" ) { + push @alldir, $_; + } + } + + @allhtml = reverse grep !/Default/, @allhtml; + push @allhtml, 'Default'; + @allhtml = reverse @allhtml; + + foreach $item ( sort @alldir ) { + + if ( $item eq $myconfig->{templates} ) { + $usetemplates .= + qq|\n|; + } + else { + $usetemplates .= qq|\n|; + } + } + + $lastitem = $allhtml[0]; + $lastitem =~ s/-.*//g; + $mastertemplates = qq|\n|; + + foreach $item (@allhtml) { + + $item =~ s/-.*//g; + + if ( $item ne $lastitem ) { + $mastertemplates .= qq|\n|; + $lastitem = $item; + } + } + + opendir CSS, "css/."; + @all = grep /.*\.css$/, readdir CSS; + closedir CSS; + + foreach $item (@all) { + + if ( $item eq $myconfig->{stylesheet} ) { + $selectstylesheet .= + qq|\n|; + } + else { + $selectstylesheet .= qq|\n|; + } + } + + $selectstylesheet .= "\n"; + + if ( %{LedgerSMB::Sysconfig::printer} && ${LedgerSMB::Sysconfig::latex} ) { + + $selectprinter = "\n"; + + foreach $item ( sort keys %{LedgerSMB::Sysconfig::printer} ) { + + if ( $myconfig->{printer} eq $item ) { + $selectprinter .= + qq|\n|; + } + else { + $selectprinter .= qq|\n|; + } + } + + $printer = qq| - |.$locale->text('Printer').qq| + | . $locale->text('Printer') . qq| |; - } + } - $user = $form->{login}; - $form->{login} = "admin"; - $form->header; - $form->{login} = $user; + $user = $form->{login}; + $form->{login} = "admin"; + $form->header; + $form->{login} = $user; - print qq| + print qq|
@@ -441,39 +505,39 @@ sub form_header { - + |; - # list section for database drivers - foreach $item (LedgerSMB::User->dbdrivers) { + # list section for database drivers + foreach $item ( LedgerSMB::User->dbdrivers ) { - print qq| + print qq| @@ -577,115 +643,122 @@ sub form_header { |; - } + } + # access control + open( FH, '<', $menufile ) + or $form->error( __FILE__ . ':' . __LINE__ . ': ' . "$menufile : $!" ); - # access control - open(FH, '<', $menufile) or $form->error(__FILE__.':'.__LINE__.': '."$menufile : $!"); - # scan for first menu level - @a = ; - close(FH); + # scan for first menu level + @a = ; + close(FH); - if (open(FH, '<', "custom_$menufile")) { - push @a, ; - } + if ( open( FH, '<', "custom_$menufile" ) ) { + push @a, ; + } - close(FH); + close(FH); - foreach $item (@a) { + foreach $item (@a) { - next unless $item =~ /\[\w+/; - next if $item =~ /\#/; + next unless $item =~ /\[\w+/; + next if $item =~ /\#/; - $item =~ s/(\[|\])//g; - chop $item; + $item =~ s/(\[|\])//g; + chop $item; - if ($item =~ /--/) { + if ( $item =~ /--/ ) { - ($level, $menuitem) = split /--/, $item, 2; - } else { + ( $level, $menuitem ) = split /--/, $item, 2; + } + else { - $level = $item; - $menuitem = $item; - push @acsorder, $item; - } + $level = $item; + $menuitem = $item; + push @acsorder, $item; + } - push @{ $acs{$level} }, $menuitem; + push @{ $acs{$level} }, $menuitem; - } + } - %role = ( 'admin' => $locale->text('Administrator'), - 'user' => $locale->text('User'), - 'supervisor' => $locale->text('Supervisor'), - 'manager' => $locale->text('Manager')); + %role = ( + 'admin' => $locale->text('Administrator'), + 'user' => $locale->text('User'), + 'supervisor' => $locale->text('Supervisor'), + 'manager' => $locale->text('Manager') + ); - $selectrole = ""; + $selectrole = ""; - foreach $item (qw(user admin supervisor manager)) { - $selectrole .= ($myconfig->{role} eq $item) ? "\n" - : "\n"; - } + foreach $item (qw(user admin supervisor manager)) { + $selectrole .= + ( $myconfig->{role} eq $item ) + ? "\n" + : "\n"; + } - print qq| + print qq| - + |; - foreach $item (split /;/, $myconfig->{acs}) { - ($key, $value) = split /--/, $item, 2; - $excl{$key}{$value} = 1; - } + foreach $item ( split /;/, $myconfig->{acs} ) { + ( $key, $value ) = split /--/, $item, 2; + $excl{$key}{$value} = 1; + } - foreach $key (@acsorder) { + foreach $key (@acsorder) { - $checked = "checked"; + $checked = "checked"; - if ($form->{login}) { - $checked = ($excl{$key}{$key}) ? "" : "checked"; - } + if ( $form->{login} ) { + $checked = ( $excl{$key}{$key} ) ? "" : "checked"; + } - # can't have variable names with & and spaces - $item = $form->escape("${key}--$key",1); + # can't have variable names with & and spaces + $item = $form->escape( "${key}--$key", 1 ); - $acsheading = $key; - $acsheading =~ s/ / /g; + $acsheading = $key; + $acsheading =~ s/ / /g; - $acsheading = qq| + $acsheading = qq| "; - print qq| + print qq| $acsheading $acsdata |; - } + } - print qq| + print qq| @@ -695,193 +768,224 @@ sub form_header { } - sub save { - $form->{callback} = "admin.pl?action=list_users"; - # no driver checked - $form->error(__FILE__.':'.__LINE__.': '.$locale->text('Database Driver not checked!')) unless $form->{dbdriver}; + $form->{callback} = "admin.pl?action=list_users"; - # no spaces allowed in login name - $form->{login} =~ s/ //g; + # no driver checked + $form->error( __FILE__ . ':' . __LINE__ . ': ' + . $locale->text('Database Driver not checked!') ) + unless $form->{dbdriver}; - $form->isblank("login", $locale->text('Login name missing!')); + # no spaces allowed in login name + $form->{login} =~ s/ //g; - # check for duplicates - if (!$form->{edit}) { + $form->isblank( "login", $locale->text('Login name missing!') ); - $temp = LedgerSMB::User->new($form->{login}); + # check for duplicates + if ( !$form->{edit} ) { - if ($temp->{login}) { - $form->error(__FILE__.':'.__LINE__.': '.$locale->text('[_1] is already a member!', $form->{login})); - } - } + $temp = LedgerSMB::User->new( $form->{login} ); - # no spaces allowed in directories - $form->{newtemplates} =~ s/( |\.\.|\*)//g; + if ( $temp->{login} ) { + $form->error( __FILE__ . ':' . __LINE__ . ': ' + . $locale->text( '[_1] is already a member!', $form->{login} ) + ); + } + } - if ($form->{newtemplates} ne "") { - $form->{templates} = $form->{newtemplates}; - } else { - $form->{templates} = ($form->{usetemplates}) ? $form->{usetemplates} : $form->{login}; - } + # no spaces allowed in directories + $form->{newtemplates} =~ s/( |\.\.|\*)//g; - # is there a basedir - if (! -d "${LedgerSMB::Sysconfig::templates}") { - $form->error(__FILE__.':'.__LINE__.': '.$locale->text('Directory [_1] does not exist', ${LedgerSMB::Sysconfig::templates})); - } + if ( $form->{newtemplates} ne "" ) { + $form->{templates} = $form->{newtemplates}; + } + else { + $form->{templates} = + ( $form->{usetemplates} ) ? $form->{usetemplates} : $form->{login}; + } - # add base directory to $form->{templates} - $form->{templates} = "${LedgerSMB::Sysconfig::templates}/$form->{templates}"; + # is there a basedir + if ( !-d "${LedgerSMB::Sysconfig::templates}" ) { + $form->error( + __FILE__ . ':' . __LINE__ . ': ' + . $locale->text( + 'Directory [_1] does not exist', + ${LedgerSMB::Sysconfig::templates} + ) + ); + } - $myconfig = LedgerSMB::User->new("${LedgerSMB::Sysconfig::memberfile}", "$form->{login}"); + # add base directory to $form->{templates} + $form->{templates} = + "${LedgerSMB::Sysconfig::templates}/$form->{templates}"; - # redo acs variable and delete all the acs codes - @acs = split /;/, $form->{acs}; - $form->{acs} = ""; + $myconfig = LedgerSMB::User->new( "${LedgerSMB::Sysconfig::memberfile}", + "$form->{login}" ); - foreach $item (@acs) { + # redo acs variable and delete all the acs codes + @acs = split /;/, $form->{acs}; + $form->{acs} = ""; - $item = $form->escape($item,1); + foreach $item (@acs) { - if (!$form->{$item}) { - $form->{acs} .= $form->unescape($form->unescape("$item")).";"; - } + $item = $form->escape( $item, 1 ); - delete $form->{$item}; - } + if ( !$form->{$item} ) { + $form->{acs} .= $form->unescape( $form->unescape("$item") ) . ";"; + } - # check which database was filled in + delete $form->{$item}; + } - $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"}; - $form->isblank("dbname", $locale->text('Dataset missing!')); - $form->isblank("dbuser", $locale->text('Database User missing!')); + # check which database was filled in - foreach $item (keys %{$form}) { - $myconfig->{$item} = $form->{$item}; - } + $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"}; + $form->isblank( "dbname", $locale->text('Dataset missing!') ); + $form->isblank( "dbuser", $locale->text('Database User missing!') ); - $myconfig->{password} = $form->{new_password}; - $myconfig->{timeout} = $form->{newtimeout}; + foreach $item ( keys %{$form} ) { + $myconfig->{$item} = $form->{$item}; + } - delete $myconfig->{stylesheet}; + $myconfig->{password} = $form->{new_password}; + $myconfig->{timeout} = $form->{newtimeout}; - if ($form->{userstylesheet}) { - $myconfig->{stylesheet} = $form->{userstylesheet}; - } + delete $myconfig->{stylesheet}; - $myconfig->{packpw} = 1; + if ( $form->{userstylesheet} ) { + $myconfig->{stylesheet} = $form->{userstylesheet}; + } - $myconfig->save_member($form); - # create user template directory and copy master files - if (! -d "$form->{templates}") { + $myconfig->{packpw} = 1; - umask(002); + $myconfig->save_member($form); - if (mkdir "$form->{templates}", oct("771")) { + # create user template directory and copy master files + if ( !-d "$form->{templates}" ) { - umask(007); + umask(002); - # copy templates to the directory - opendir TEMPLATEDIR, "${LedgerSMB::Sysconfig::templates}/." or $form->error(__FILE__.':'.__LINE__.': '."$templates : $!"); - @templates = grep /$form->{mastertemplates}-/, readdir TEMPLATEDIR; - closedir TEMPLATEDIR; + if ( mkdir "$form->{templates}", oct("771") ) { - foreach $file (@templates) { + umask(007); - open(TEMP, '<', "${LedgerSMB::Sysconfig::templates}/$file") or $form->error(__FILE__.':'.__LINE__.': '."$templates/$file : $!"); + # copy templates to the directory + opendir TEMPLATEDIR, "${LedgerSMB::Sysconfig::templates}/." + or $form->error( + __FILE__ . ':' . __LINE__ . ': ' . "$templates : $!" ); + @templates = grep /$form->{mastertemplates}-/, readdir TEMPLATEDIR; + closedir TEMPLATEDIR; - $file =~ s/$form->{mastertemplates}-//; - open(NEW, '>', "$form->{templates}/$file") or $form->error(__FILE__.':'.__LINE__.': '."$form->{templates}/$file : $!"); + foreach $file (@templates) { - while ($line = ) { - print NEW $line; - } + open( TEMP, '<', "${LedgerSMB::Sysconfig::templates}/$file" ) + or $form->error( __FILE__ . ':' . __LINE__ . ': ' + . "$templates/$file : $!" ); - close(TEMP); - close(NEW); - } + $file =~ s/$form->{mastertemplates}-//; + open( NEW, '>', "$form->{templates}/$file" ) + or $form->error( __FILE__ . ':' . __LINE__ . ': ' + . "$form->{templates}/$file : $!" ); - } else { - $form->error(__FILE__.':'.__LINE__.': '."$form->{templates} : $!"); - } - } + while ( $line = ) { + print NEW $line; + } - $form->redirect($locale->text('User saved!')); -} + close(TEMP); + close(NEW); + } + } + else { + $form->error( + __FILE__ . ':' . __LINE__ . ': ' . "$form->{templates} : $!" ); + } + } + + $form->redirect( $locale->text('User saved!') ); +} sub delete { - $form->{callback} = "admin.pl?action=list_users"; + $form->{callback} = "admin.pl?action=list_users"; - $form->{templates} = ($form->{templates}) ? "${LedgerSMB::Sysconfig::templates}/$form->{templates}" : "$templates/$form->{login}"; + $form->{templates} = + ( $form->{templates} ) + ? "${LedgerSMB::Sysconfig::templates}/$form->{templates}" + : "$templates/$form->{login}"; - # scan %user for $templatedir - foreach $login (keys %user) { - last if ($found = ($form->{templates} eq $user{$login})); - } + # scan %user for $templatedir + foreach $login ( keys %user ) { + last if ( $found = ( $form->{templates} eq $user{$login} ) ); + } - # if found keep directory otherwise delete - if (!$found) { - # delete it if there is a template directory - $dir = "$form->{templates}"; - if (-d "$dir") { - unlink <$dir/*>; - rmdir "$dir"; - } - } + # if found keep directory otherwise delete + if ( !$found ) { - my $dbh = ${LedgerSMB::Sysconfig::GLOBALDBH}; + # delete it if there is a template directory + $dir = "$form->{templates}"; + if ( -d "$dir" ) { + unlink <$dir/*>; + rmdir "$dir"; + } + } - #users_conf - my $deleteUser = $dbh->prepare("DELETE FROM users_conf USING users WHERE users.username = ? and users.id = users_conf.id;"); - $deleteUser->execute($form->{login}); + my $dbh = ${LedgerSMB::Sysconfig::GLOBALDBH}; - #and now users - $deleteUser = $dbh->prepare("DELETE FROM users WHERE username = ?;"); - $deleteUser->execute($form->{login}); + #users_conf + my $deleteUser = + $dbh->prepare( +"DELETE FROM users_conf USING users WHERE users.username = ? and users.id = users_conf.id;" + ); + $deleteUser->execute( $form->{login} ); - $form->redirect($locale->text('User deleted!')); -} + #and now users + $deleteUser = $dbh->prepare("DELETE FROM users WHERE username = ?;"); + $deleteUser->execute( $form->{login} ); + $form->redirect( $locale->text('User deleted!') ); +} sub login_name { - my $login = shift; - $login =~ s/\[\]//g; - return ($login) ? $login : undef; + my $login = shift; + $login =~ s/\[\]//g; + return ($login) ? $login : undef; } - sub change_admin_password { - $form->{title} = qq|LedgerSMB |.$locale->text('Accounting')." ".$locale->text('Administration')." / ".$locale->text('Change Admin Password'); + $form->{title} = + qq|LedgerSMB | + . $locale->text('Accounting') . " " + . $locale->text('Administration') . " / " + . $locale->text('Change Admin Password'); - $form->{login} = "admin"; - $form->header; + $form->{login} = "admin"; + $form->header; - print qq| + print qq|
- + - + - + - + - + - + - + - + - +
|.$locale->text('Login').qq|| . $locale->text('Login') . qq|
|.$locale->text('Password').qq|| . $locale->text('Password') . qq|
|.$locale->text('Name').qq|| . $locale->text('Name') . qq|
|.$locale->text('E-mail').qq|| . $locale->text('E-mail') . qq|
|.$locale->text('Signature').qq|| . $locale->text('Signature') . qq|
|.$locale->text('Phone').qq|| . $locale->text('Phone') . qq|
|.$locale->text('Fax').qq|| . $locale->text('Fax') . qq|
|.$locale->text('Company').qq|| . $locale->text('Company') . qq|
|.$locale->text('Address').qq|| . $locale->text('Address') . qq|
@@ -481,44 +545,44 @@ sub form_header {
- + - + - + - + - + - + - + $printer - + - + - +
|.$locale->text('Date Format').qq|| . $locale->text('Date Format') . qq|
|.$locale->text('Number Format').qq|| . $locale->text('Number Format') . qq|
|.$locale->text('Dropdown Limit').qq|| . $locale->text('Dropdown Limit') . qq|
|.$locale->text('Menu Width').qq|| . $locale->text('Menu Width') . qq|
|.$locale->text('Language').qq|| . $locale->text('Language') . qq|
|.$locale->text('Session Timeout').qq|| . $locale->text('Session Timeout') . qq|
|.$locale->text('Stylesheet').qq|| . $locale->text('Stylesheet') . qq|
|.$locale->text('Use Templates').qq|| . $locale->text('Use Templates') . qq|
|.$locale->text('New Templates').qq|| . $locale->text('New Templates') . qq|
|.$locale->text('Setup Templates').qq|| . $locale->text('Setup Templates') . qq|
@@ -526,48 +590,50 @@ sub form_header {
|.$locale->text('Database').qq|| . $locale->text('Database') . qq|
|; - $checked = "checked"; + $checked = "checked"; - if ($myconfig->{dbdriver} eq $item) { + if ( $myconfig->{dbdriver} eq $item ) { - for (qw(dbhost dbport dbuser dbpasswd dbname sid)) { $form->{"${item}_$_"} = $myconfig->{$_} } - $checked = "checked"; - } + for (qw(dbhost dbport dbuser dbpasswd dbname sid)) { + $form->{"${item}_$_"} = $myconfig->{$_}; + } + $checked = "checked"; + } - print qq| - + print qq| + - + |; - print qq| - + print qq| + - + - + - + |; - print qq| + print qq|
|.$locale->text('Driver').qq|| . $locale->text('Driver') . qq|  $item|.$locale->text('Host').qq|| . $locale->text('Host') . qq|
|.$locale->text('Dataset').qq|| . $locale->text('Dataset') . qq| |.$locale->text('Port').qq|| . $locale->text('Port') . qq|
|.$locale->text('User').qq|| . $locale->text('User') . qq| |.$locale->text('Password').qq|| . $locale->text('Password') . qq|
|.$locale->text('Access Control').qq|| . $locale->text('Access Control') . qq|
 $acsheading
\n|; - $menuitems .= "$item;"; - $acsdata = ""; + $menuitems .= "$item;"; + $acsdata = ""; - foreach $item (@{ $acs{$key} }) { + foreach $item ( @{ $acs{$key} } ) { - next if ($key eq $item); + next if ( $key eq $item ); - $checked = "checked"; + $checked = "checked"; - if ($form->{login}) { - $checked = ($excl{$key}{$item}) ? "" : "checked"; - } + if ( $form->{login} ) { + $checked = ( $excl{$key}{$item} ) ? "" : "checked"; + } - $acsitem = $form->escape("${key}--$item",1); + $acsitem = $form->escape( "${key}--$item", 1 ); - $acsdata .= qq|
 $item|; - $menuitems .= "$acsitem;"; - } + $acsdata .= +qq|
 $item|; + $menuitems .= "$acsitem;"; + } - $acsdata .= " + $acsdata .= "

- + @@ -1142,13 +1272,17 @@ sub create_dataset {
|.$locale->text('Change Password').qq|| . $locale->text('Change Password') . qq|
- + - +
|.$locale->text('Password').qq|| . $locale->text('Password') . qq|
|.$locale->text('Confirm').qq|| . $locale->text('Confirm') . qq|
@@ -891,7 +995,9 @@ sub change_admin_password {

-

+

@@ -899,103 +1005,112 @@ sub change_admin_password { } - sub change_password { - # Do we want to force a login after changing the password? - $form->{callback} = "admin.pl?"; + # Do we want to force a login after changing the password? + $form->{callback} = "admin.pl?"; - $form->error(__FILE__.':'.__LINE__.': '.$locale->text('Passwords do not match!')) if $form->{new_password} ne $form->{confirm_password}; + $form->error( __FILE__ . ':' . __LINE__ . ': ' + . $locale->text('Passwords do not match!') ) + if $form->{new_password} ne $form->{confirm_password}; - # use the central database handle - my $dbh = ${LedgerSMB::Sysconfig::GLOBALDBH}; + # use the central database handle + my $dbh = ${LedgerSMB::Sysconfig::GLOBALDBH}; - my $updateAdminPassword = $dbh->prepare("UPDATE users_conf + my $updateAdminPassword = $dbh->prepare( + "UPDATE users_conf SET password = md5(?) - WHERE id = 1"); + WHERE id = 1" + ); - $updateAdminPassword->execute($form->{new_password}); + $updateAdminPassword->execute( $form->{new_password} ); - $form->{callback} = "$form->{script}?action=list_users&path=$form->{path}"; - $form->redirect($locale->text('Password changed!')); + $form->{callback} = + "$form->{script}?action=list_users&path=$form->{path}"; + $form->redirect( $locale->text('Password changed!') ); } sub check_password { - $root = LedgerSMB::User->new('admin'); - - if ($form->{password}) { - - $form->{callback} .= "&password=$form->{password}" if $form->{callback}; - - if ($root->{password} ne (Digest::MD5::md5_hex $form->{password}) ) { - &adminlogin($locale->text('Access Denied!')); - exit; - } - else{ - Session::session_create($root); - } - } - else { - - $ENV{HTTP_COOKIE} =~ s/;\s*/;/g; - @cookies = split /;/, $ENV{HTTP_COOKIE}; - foreach (@cookies) { - ($name,$value) = split /=/, $_, 2; - $cookie{$name} = $value; - } - - if(!Session::session_check($cookie{"LedgerSMB"}, $root)){ - &adminlogin($locale->text('Session expired!')); - exit; - } - } + $root = LedgerSMB::User->new('admin'); + + if ( $form->{password} ) { + + $form->{callback} .= "&password=$form->{password}" + if $form->{callback}; + + if ( $root->{password} ne ( Digest::MD5::md5_hex $form->{password} ) ) { + &adminlogin( $locale->text('Access Denied!') ); + exit; + } + else { + Session::session_create($root); + } + } + else { + + $ENV{HTTP_COOKIE} =~ s/;\s*/;/g; + @cookies = split /;/, $ENV{HTTP_COOKIE}; + foreach (@cookies) { + ( $name, $value ) = split /=/, $_, 2; + $cookie{$name} = $value; + } + + if ( !Session::session_check( $cookie{"LedgerSMB"}, $root ) ) { + &adminlogin( $locale->text('Session expired!') ); + exit; + } + } } - sub pg_database_administration { - $form->{dbdriver} = 'Pg'; - &dbselect_source; + $form->{dbdriver} = 'Pg'; + &dbselect_source; } - sub pgpp_database_administration { - $form->{dbdriver} = 'PgPP'; - &dbselect_source; + $form->{dbdriver} = 'PgPP'; + &dbselect_source; } - sub dbdriver_defaults { - # load some defaults for the selected driver - %driverdefaults = ( 'Pg' => { dbport => '5432', - dbuser => '', - dbdefault => 'template1', - dbhost => 'localhost', - connectstring => $locale->text('Connect to') - } ); + # load some defaults for the selected driver + %driverdefaults = ( + 'Pg' => { + dbport => '5432', + dbuser => '', + dbdefault => 'template1', + dbhost => 'localhost', + connectstring => $locale->text('Connect to') + } + ); - $driverdefaults{PgPP} = $driverdefaults{Pg}; + $driverdefaults{PgPP} = $driverdefaults{Pg}; - for (keys %{ $driverdefaults{Pg} }) { $form->{$_} = $driverdefaults{$form->{dbdriver}}{$_} } + for ( keys %{ $driverdefaults{Pg} } ) { + $form->{$_} = $driverdefaults{ $form->{dbdriver} }{$_}; + } } - sub dbselect_source { - &dbdriver_defaults; + &dbdriver_defaults; - $form->{title} = "LedgerSMB ".$locale->text('Accounting')." / ".$locale->text('Database Administration'); + $form->{title} = + "LedgerSMB " + . $locale->text('Accounting') . " / " + . $locale->text('Database Administration'); - $form->{login} = "admin"; - $form->header; + $form->{login} = "admin"; + $form->header; - #an insane amount of table nesting here, this should be cleaned up. - print qq| + #an insane amount of table nesting here, this should be cleaned up. + print qq|

$form->{title}

@@ -1005,21 +1120,21 @@ sub dbselect_source {
- + - + - + - +
|.$locale->text('Database').qq|| . $locale->text('Database') . qq|
- + - + - + - + @@ -1027,9 +1142,9 @@ sub dbselect_source { - + - +
|.$locale->text('Host').qq|| . $locale->text('Host') . qq| |.$locale->text('Port').qq|| . $locale->text('Port') . qq|
|.$locale->text('User').qq|| . $locale->text('User') . qq| |.$locale->text('Password').qq|| . $locale->text('Password') . qq|
|.$locale->text("Superuser").qq|| . $locale->text("Superuser") . qq| |.$locale->text('Password').qq|| . $locale->text('Password') . qq|
@@ -1043,56 +1158,65 @@ sub dbselect_source {
- - + + -

|.$locale->text('This is a preliminary check for existing sources. Nothing will be created or deleted at this stage!') - .qq|

+

| + . $locale->text( +'This is a preliminary check for existing sources. Nothing will be created or deleted at this stage!' + ) + . qq|

|; } - sub continue { - &{ $form->{nextsub} }; + &{ $form->{nextsub} }; } - sub dbupdate { - $form->{callback} = "admin.pl?action=list_users"; + $form->{callback} = "admin.pl?action=list_users"; - LedgerSMB::User->dbupdate(\%$form); - $form->redirect($locale->text('Dataset updated!')); + LedgerSMB::User->dbupdate( \%$form ); + $form->redirect( $locale->text('Dataset updated!') ); } - sub create_dataset { - @dbsources = sort LedgerSMB::User->dbsources(\%$form); + @dbsources = sort LedgerSMB::User->dbsources( \%$form ); - opendir SQLDIR, "sql/." or $form->error(__FILE__.':'.__LINE__.': '.$!); + opendir SQLDIR, "sql/." + or $form->error( __FILE__ . ':' . __LINE__ . ': ' . $! ); - foreach $item (sort grep /-chart\.sql/, readdir SQLDIR) { - next if ($item eq 'Default-chart.sql'); - $item =~ s/-chart\.sql//; - push @charts, qq|$item|; - } + foreach $item ( sort grep /-chart\.sql/, readdir SQLDIR ) { + next if ( $item eq 'Default-chart.sql' ); + $item =~ s/-chart\.sql//; + push @charts, +qq|$item|; + } - closedir SQLDIR; + closedir SQLDIR; - # add Default at beginning - unshift @charts, qq|Default|; + # add Default at beginning + unshift @charts, +qq|Default|; - $form->{title} = "LedgerSMB ".$locale->text('Accounting') - ." ".$locale->text('Database Administration') - ." / ".$locale->text('Create Dataset'); - $form->{login} = "admin"; - $form->header; + $form->{title} = + "LedgerSMB " + . $locale->text('Accounting') . " " + . $locale->text('Database Administration') . " / " + . $locale->text('Create Dataset'); + $form->{login} = "admin"; + $form->header; - print qq| + print qq|

$form->{title}

@@ -1102,36 +1226,42 @@ sub create_dataset {
 
|.$locale->text('Existing Datasets').qq|| + . $locale->text('Existing Datasets') + . qq| |; - for (@dbsources) { print "[ $_ ] " } + for (@dbsources) { print "[ $_ ] " } - print qq| + print qq|
|.$locale->text('Create Dataset').qq|| + . $locale->text('Create Dataset') + . qq|
|.$locale->text('Create Chart of Accounts').qq|| + . $locale->text('Create Chart of Accounts') + . qq| |; - while (@charts) { - print qq| |; + while (@charts) { + print qq| |; - for (0 .. 2) { print "\n" } + for ( 0 .. 2 ) { print "\n" } - print qq| |; + print qq| |; - splice @charts, 0, 3; - } + splice @charts, 0, 3; + } - print qq|
$charts[$_]$charts[$_]
+ print qq|
|; - $form->hide_form(qw(dbdriver dbsuperuser dbsuperpasswd dbuser dbhost dbport dbpasswd dbdefault path)); + $form->hide_form( + qw(dbdriver dbsuperuser dbsuperpasswd dbuser dbhost dbport dbpasswd dbdefault path) + ); - print qq| + print qq|
- + @@ -1156,30 +1290,32 @@ sub create_dataset { } - sub dbcreate { - $form->isblank("db", $locale->text('Dataset missing!')); + $form->isblank( "db", $locale->text('Dataset missing!') ); - LedgerSMB::User->dbcreate(\%$form); + LedgerSMB::User->dbcreate( \%$form ); - $form->{title} = "LedgerSMB ".$locale->text('Accounting') - ." ".$locale->text('Database Administration') - ." / ".$locale->text('Create Dataset'); + $form->{title} = + "LedgerSMB " + . $locale->text('Accounting') . " " + . $locale->text('Database Administration') . " / " + . $locale->text('Create Dataset'); - $form->{login} = "admin"; - $form->header; + $form->{login} = "admin"; + $form->header; - print qq| + print qq|

$form->{title}

| - .$locale->text('Dataset [_1] successfully created!', $form->{db}) - .qq| + . $locale->text( 'Dataset [_1] successfully created!', $form->{db} ) . qq| -

+

@@ -1187,27 +1323,31 @@ sub dbcreate { |; } - sub delete_dataset { - if (@dbsources = LedgerSMB::User->dbsources_unused(\%$form)) { + if ( @dbsources = LedgerSMB::User->dbsources_unused( \%$form ) ) { - foreach $item (sort @dbsources) { - $dbsources .= qq| $item |; - } + foreach $item ( sort @dbsources ) { + $dbsources .= +qq| $item |; + } - } else { - $form->error(__FILE__.':'.__LINE__.': '.$locale->text('Nothing to delete!')); - } + } + else { + $form->error( __FILE__ . ':' . __LINE__ . ': ' + . $locale->text('Nothing to delete!') ); + } - $form->{title} = "LedgerSMB ".$locale->text('Accounting') - ." ".$locale->text('Database Administration') - ." / ".$locale->text('Delete Dataset'); + $form->{title} = + "LedgerSMB " + . $locale->text('Accounting') . " " + . $locale->text('Database Administration') . " / " + . $locale->text('Delete Dataset'); - $form->{login} = "admin"; - $form->header; + $form->{login} = "admin"; + $form->header; - print qq| + print qq|

$form->{title}

@@ -1222,7 +1362,10 @@ sub delete_dataset { - +
|.$locale->text('The following Datasets are not in use and can be deleted').qq|| + . $locale->text( + 'The following Datasets are not in use and can be deleted') + . qq|
@@ -1233,7 +1376,9 @@ sub delete_dataset {

- +
@@ -1244,53 +1389,56 @@ sub delete_dataset { } - sub dbdelete { - if (!$form->{db}) { - $form->error(__FILE__.':'.__LINE__.': '.$locale->text('No Dataset selected!')); - } + if ( !$form->{db} ) { + $form->error( __FILE__ . ':' . __LINE__ . ': ' + . $locale->text('No Dataset selected!') ); + } - LedgerSMB::User->dbdelete(\%$form); + LedgerSMB::User->dbdelete( \%$form ); - $form->{title} = "LedgerSMB ".$locale->text('Accounting') - ." ".$locale->text('Database Administration') - ." / ".$locale->text('Delete Dataset'); + $form->{title} = + "LedgerSMB " + . $locale->text('Accounting') . " " + . $locale->text('Database Administration') . " / " + . $locale->text('Delete Dataset'); - $form->{login} = "admin"; - $form->header; + $form->{login} = "admin"; + $form->header; - print qq| + print qq|

$form->{title}

- $form->{db} |.$locale->text('successfully deleted!') - .qq| + $form->{db} | . $locale->text('successfully deleted!') . qq| -

+

|; } - sub unlock_system { - # This needs to be done with a db tool - # unlink "${LedgerSMB::Sysconfig::userspath}/nologin"; - $form->{callback} = "$form->{script}?action=list_users&path=$form->{path}"; - $form->redirect($locale->text('Lockfile removed!')); + # This needs to be done with a db tool + # unlink "${LedgerSMB::Sysconfig::userspath}/nologin"; + $form->{callback} = + "$form->{script}?action=list_users&path=$form->{path}"; + $form->redirect( $locale->text('Lockfile removed!') ); } - sub lock_system { - # This needs to be done with a db tool - #open(FH, '>', "${LedgerSMB::Sysconfig::userspath}/nologin") or $form->error($locale->text('Cannot create Lock!')); - #close(FH); - $form->{callback} = "$form->{script}?action=list_users&path=$form->{path}"; - $form->redirect($locale->text('Lockfile created!')); +# This needs to be done with a db tool +#open(FH, '>', "${LedgerSMB::Sysconfig::userspath}/nologin") or $form->error($locale->text('Cannot create Lock!')); +#close(FH); + $form->{callback} = + "$form->{script}?action=list_users&path=$form->{path}"; + $form->redirect( $locale->text('Lockfile created!') ); } diff --git a/bin/am.pl b/bin/am.pl index 4dc4bab6..1764384d 100644 --- a/bin/am.pl +++ b/bin/am.pl @@ -1,9 +1,9 @@ #===================================================================== -# LedgerSMB +# LedgerSMB # Small Medium Business Accounting software # http://www.ledgersmb.org/ # -# +# # Copyright (C) 2006 # This work contains copyrighted information from a number of sources all used # with permission. @@ -32,7 +32,6 @@ # #====================================================================== - use LedgerSMB::AM; use LedgerSMB::CA; use LedgerSMB::Form; @@ -40,76 +39,72 @@ use LedgerSMB::User; use LedgerSMB::RP; use LedgerSMB::GL; - 1; + # end of main +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}; -sub add { &{ "add_$form->{type}" } }; -sub edit { &{ "edit_$form->{type}" } }; -sub save { &{ "save_$form->{type}" } }; -sub delete { &{ "delete_$form->{type}" } }; + &save; +} -sub save_as_new { +sub add_account { + + $form->{title} = "Add"; + $form->{charttype} = "A"; - delete $form->{id}; + $form->{callback} = +"$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" + unless $form->{callback}; - &save; + &account_header; + &form_footer; } +sub edit_account { -sub add_account { - - $form->{title} = "Add"; - $form->{charttype} = "A"; - - $form->{callback} = "$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback}; + $form->{title} = "Edit"; - &account_header; - &form_footer; - -} + $form->{accno} =~ s/\\'/'/g; + $form->{accno} =~ s/\\\\/\\/g; + AM->get_account( \%myconfig, \%$form ); -sub edit_account { - - $form->{title} = "Edit"; - - $form->{accno} =~ s/\\'/'/g; - $form->{accno} =~ s/\\\\/\\/g; - - AM->get_account(\%myconfig, \%$form); - - foreach my $item (split(/:/, $form->{link})) { - $form->{$item} = "checked"; - } + foreach my $item ( split( /:/, $form->{link} ) ) { + $form->{$item} = "checked"; + } - &account_header; - &form_footer; + &account_header; + &form_footer; } - sub account_header { - $form->{title} = $locale->text("$form->{title} Account"); - - $checked{$form->{charttype}} = "checked"; - $checked{contra} = "checked" if $form->{contra}; - $checked{"$form->{category}_"} = "checked"; - - for (qw(accno description)) { $form->{$_} = $form->quote($form->{$_}) } + $form->{title} = $locale->text("$form->{title} Account"); -# this is for our parser only! -# type=submit $locale->text('Add Account') -# type=submit $locale->text('Edit Account') + $checked{ $form->{charttype} } = "checked"; + $checked{contra} = "checked" if $form->{contra}; + $checked{"$form->{category}_"} = "checked"; - $form->header; + for (qw(accno description)) { $form->{$_} = $form->quote( $form->{$_} ) } - print qq| + # this is for our parser only! + # type=submit $locale->text('Add Account') + # type=submit $locale->text('Edit Account') + + $form->header; + + print qq|
{script}> @@ -132,86 +127,122 @@ sub account_header { - + - + - + |; - -if ($form->{charttype} eq "A") { - print qq| + if ( $form->{charttype} eq "A" ) { + print qq| - + |; -} + } -print qq| + print qq| - +
|.$locale->text('Account Number').qq|| . $locale->text('Account Number') . qq|
|.$locale->text('Description').qq|| . $locale->text('Description') . qq|
|.$locale->text('Account Type').qq|| . $locale->text('Account Type') . qq| - + +  | + . $locale->text('Heading') . qq|
+  | + . $locale->text('Account') + . qq|
 |.$locale->text('Asset').qq|\n
-  |.$locale->text('Liability').qq|\n
-  |.$locale->text('Equity').qq|\n
-  |.$locale->text('Income').qq|\n
-  |.$locale->text('Expense') - .qq|
 | + . $locale->text('Asset') + . qq|\n
+  | + . $locale->text('Liability') + . qq|\n
+  | + . $locale->text('Equity') + . qq|\n
+  | + . $locale->text('Income') + . qq|\n
+  | + . $locale->text('Expense') + . qq|
-  |.$locale->text('Contra').qq| +  | + . $locale->text('Contra') . qq| -  |.$locale->text('Heading').qq|
-  |.$locale->text('Account') - .qq|
- + + {AR}> | + . $locale->text('AR') + . qq| {AP}> | + . $locale->text('AP') + . qq| {IC}> | + . $locale->text('Inventory') + . qq|
|.$locale->text('Is this a summary account to record').qq|| + . $locale->text('Is this a summary account to record') + . qq| - {AR}> |.$locale->text('AR') - .qq| {AP}> |.$locale->text('AP') - .qq| {IC}> |.$locale->text('Inventory') - .qq|
|.$locale->text('Include in drop-down menus').qq|| . $locale->text('Include in drop-down menus') . qq|
- - - - + + + +
|.$locale->text('Receivables').qq||.$locale->text('Payables').qq||.$locale->text('Tracking Items').qq||.$locale->text('Non-tracking Items').qq|| . $locale->text('Receivables') . qq|| . $locale->text('Payables') . qq|| . $locale->text('Tracking Items') . qq|| . $locale->text('Non-tracking Items') . qq|
- {AR_amount}> |.$locale->text('Income').qq|\n
- {AR_paid}> |.$locale->text('Payment').qq|\n
- {AR_tax}> |.$locale->text('Tax') .qq| + {AR_amount}> | + . $locale->text('Income') + . qq|\n
+ {AR_paid}> | + . $locale->text('Payment') + . qq|\n
+ {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_amount}> | + . $locale->text('Expense/Asset') + . qq|\n
+ {AP_paid}> | + . $locale->text('Payment') + . qq|\n
+ {AP_tax}> | + . $locale->text('Tax') . qq|
- {IC_sale}> |.$locale->text('Income').qq|\n
- {IC_cogs}> |.$locale->text('COGS').qq|\n
- {IC_taxpart}> |.$locale->text('Tax') .qq| + {IC_sale}> | + . $locale->text('Income') + . qq|\n
+ {IC_cogs}> | + . $locale->text('COGS') + . qq|\n
+ {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_income}> | + . $locale->text('Income') + . qq|\n
+ {IC_expense}> | + . $locale->text('Expense') + . qq|\n
+ {IC_taxservice}> | + . $locale->text('Tax') . qq|
@@ -220,11 +251,11 @@ if ($form->{charttype} eq "A") {
|.$locale->text('GIFI').qq|| . $locale->text('GIFI') . qq|
@@ -238,36 +269,42 @@ print qq| } - sub form_footer { - $form->hide_form(qw(callback path login sessionid)); + $form->hide_form(qw(callback path login sessionid)); -# type=submit $locale->text('Save') -# type=submit $locale->text('Save as new') -# type=submit $locale->text('Delete') + # type=submit $locale->text('Save') + # type=submit $locale->text('Save as new') + # type=submit $locale->text('Delete') - %button = (); - - if ($form->{id}) { - $button{'save'} = { ndx => 3, key => 'S', value => $locale->text('Save') }; - $button{'save_as_new'} = { ndx => 7, key => 'N', value => $locale->text('Save as new') }; - - if ($form->{orphaned}) { - $button{'delete'} = { ndx => 16, key => 'D', value => $locale->text('Delete') }; + %button = (); + + if ( $form->{id} ) { + $button{'save'} = + { ndx => 3, key => 'S', value => $locale->text('Save') }; + $button{'save_as_new'} = + { ndx => 7, key => 'N', value => $locale->text('Save as new') }; + + if ( $form->{orphaned} ) { + $button{'delete'} = + { ndx => 16, key => 'D', value => $locale->text('Delete') }; + } + } + else { + $button{'save'} = + { ndx => 3, key => 'S', value => $locale->text('Save') }; } - } else { - $button{'save'} = { ndx => 3, key => 'S', value => $locale->text('Save') }; - } - for (sort { $button{$a}->{ndx} <=> $button{$b}->{ndx} } keys %button) { $form->print_button(\%button, $_) } + for ( sort { $button{$a}->{ndx} <=> $button{$b}->{ndx} } keys %button ) { + $form->print_button( \%button, $_ ); + } - if ($form->{lynx}) { - require "bin/menu.pl"; - &menubar; - } - - print qq| + if ( $form->{lynx} ) { + require "bin/menu.pl"; + &menubar; + } + + print qq|
@@ -276,59 +313,80 @@ sub form_footer { } - 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}) { - $a = ""; - for (qw(AR AP IC)) { $a .= $form->{$_} } - $form->error($locale->text('Cannot set account for more than one of AR, AP or IC')) if length $a > 2; + $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} ) { + $a = ""; + for (qw(AR AP IC)) { $a .= $form->{$_} } + $form->error( + $locale->text( + 'Cannot set account for more than one of AR, AP or IC') + ) if length $a > 2; + + for ( + qw(AR_amount AR_tax AR_paid AP_amount AP_tax AP_paid IC_taxpart IC_taxservice IC_sale IC_cogs IC_income IC_expense) + ) + { + $form->error( + "$form->{AR}$form->{AP}$form->{IC} " + . $locale->text( + 'account cannot be set to any other type of account') + ) if $form->{$_}; + } + } - for (qw(AR_amount AR_tax AR_paid AP_amount AP_tax AP_paid IC_taxpart IC_taxservice IC_sale IC_cogs IC_income IC_expense)) { $form->error("$form->{AR}$form->{AP}$form->{IC} ". $locale->text('account cannot be set to any other type of account')) if $form->{$_} } - } + foreach $item ( "AR", "AP" ) { + $i = 0; + for ( "${item}_amount", "${item}_paid", "${item}_tax" ) { + $i++ if $form->{$_}; + } + $form->error( + $locale->text( 'Cannot set multiple options for [_1]', $item ) ) + if $i > 1; + } - foreach $item ("AR", "AP") { - $i = 0; - for ("${item}_amount", "${item}_paid", "${item}_tax") { $i++ if $form->{$_} } - $form->error($locale->text('Cannot set multiple options for [_1]', $item)) if $i > 1; - } - - if (AM->save_account(\%myconfig, \%$form)) { - $form->redirect($locale->text('Account saved!')); - } else { - $form->error($locale->text('Cannot save account!')); - } + if ( AM->save_account( \%myconfig, \%$form ) ) { + $form->redirect( $locale->text('Account saved!') ); + } + else { + $form->error( $locale->text('Cannot save account!') ); + } } - sub list_account { - CA->all_accounts(\%myconfig, \%$form); + CA->all_accounts( \%myconfig, \%$form ); - $form->{title} = $locale->text('Chart of Accounts'); - - # construct callback - $callback = "$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; + $form->{title} = $locale->text('Chart of Accounts'); - @column_index = qw(accno gifi_accno description debit credit link); + # construct callback + $callback = +"$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; - $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_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||; - $form->header; - $colspan = $#column_index + 1; + $form->header; + $colspan = $#column_index + 1; - print qq| + print qq| @@ -339,60 +397,69 @@ sub list_account { |; - for (@column_index) { print "$column_header{$_}\n" } - - print qq| + for (@column_index) { print "$column_header{$_}\n" } + + print qq| |; - # escape callback - $callback = $form->escape($callback); - - foreach $ca (@{ $form->{CA} }) { - - $ca->{debit} = " "; - $ca->{credit} = " "; + # escape callback + $callback = $form->escape($callback); - if ($ca->{amount} > 0) { - $ca->{credit} = $form->format_amount(\%myconfig, $ca->{amount}, 2, " "); - } - if ($ca->{amount} < 0) { - $ca->{debit} = $form->format_amount(\%myconfig, -$ca->{amount}, 2, " "); - } + foreach $ca ( @{ $form->{CA} } ) { + + $ca->{debit} = " "; + $ca->{credit} = " "; + + if ( $ca->{amount} > 0 ) { + $ca->{credit} = + $form->format_amount( \%myconfig, $ca->{amount}, 2, " " ); + } + if ( $ca->{amount} < 0 ) { + $ca->{debit} = + $form->format_amount( \%myconfig, -$ca->{amount}, 2, " " ); + } - $ca->{link} =~ s/:/
/og; + $ca->{link} =~ s/:/
/og; - $gifi_accno = $form->escape($ca->{gifi_accno}); - - if ($ca->{charttype} eq "H") { - print qq||; + $gifi_accno = $form->escape( $ca->{gifi_accno} ); - $column_data{accno} = qq||; - $column_data{gifi_accno} = qq||; - $column_data{description} = qq||; - $column_data{debit} = qq||; - $column_data{credit} = qq| |; - $column_data{link} = qq||; + if ( $ca->{charttype} eq "H" ) { + print qq||; - } else { - $i++; $i %= 2; - print qq| + $column_data{accno} = +qq||; + $column_data{gifi_accno} = +qq||; + $column_data{description} = + qq||; + $column_data{debit} = qq||; + $column_data{credit} = qq| |; + $column_data{link} = qq||; + + } + else { + $i++; + $i %= 2; + print qq| |; - $column_data{accno} = qq||; - $column_data{gifi_accno} = qq||; - $column_data{description} = qq||; - $column_data{debit} = qq||; - $column_data{credit} = qq||; - $column_data{link} = qq||; - - } - - for (@column_index) { print "$column_data{$_}\n" } - - print "\n"; - } - - print qq| + $column_data{accno} = +qq||; + $column_data{gifi_accno} = +qq||; + $column_data{description} = qq||; + $column_data{debit} = qq||; + $column_data{credit} = qq||; + $column_data{link} = qq||; + + } + + for (@column_index) { print "$column_data{$_}\n" } + + print "\n"; + } + + print qq|
$ca->{accno}$ca->{gifi_accno} $ca->{description}    
$ca->{accno}$ca->{gifi_accno} $ca->{description}    
$ca->{accno}$ca->{gifi_accno} $ca->{description} $ca->{debit}$ca->{credit}$ca->{link} 
$ca->{accno}$ca->{gifi_accno} $ca->{description} $ca->{debit}$ca->{credit}$ca->{link} 

@@ -402,48 +469,54 @@ sub list_account { } - sub delete_account { - $form->{title} = $locale->text('Delete Account'); + $form->{title} = $locale->text('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!')); + 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!') ); + } } - } - if (AM->delete_account(\%myconfig, \%$form)) { - $form->redirect($locale->text('Account deleted!')); - } else { - $form->error($locale->text('Cannot delete account!')); - } + if ( AM->delete_account( \%myconfig, \%$form ) ) { + $form->redirect( $locale->text('Account deleted!') ); + } + else { + $form->error( $locale->text('Cannot delete account!') ); + } } - sub list_gifi { - @{ $form->{fields} } = qw(accno description); - $form->{table} = "gifi"; - - AM->gifi_accounts(\%myconfig, \%$form); + @{ $form->{fields} } = qw(accno description); + $form->{table} = "gifi"; - $form->{title} = $locale->text('GIFI'); - - # construct callback - $callback = "$form->{script}?action=list_gifi&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; + AM->gifi_accounts( \%myconfig, \%$form ); + + $form->{title} = $locale->text('GIFI'); - @column_index = qw(accno description); + # construct callback + $callback = +"$form->{script}?action=list_gifi&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; - $column_header{accno} = qq||.$locale->text('GIFI').qq||; - $column_header{description} = qq||.$locale->text('Description').qq||; + @column_index = qw(accno description); + $column_header{accno} = + qq|| . $locale->text('GIFI') . qq||; + $column_header{description} = + qq|| + . $locale->text('Description') + . qq||; - $form->header; - $colspan = $#column_index + 1; + $form->header; + $colspan = $#column_index + 1; - print qq| + print qq| @@ -454,32 +527,34 @@ sub list_gifi { |; - for (@column_index) { print "$column_header{$_}\n" } - - print qq| + for (@column_index) { print "$column_header{$_}\n" } + + print qq| |; - # escape callback - $callback = $form->escape($callback); - - foreach $ca (@{ $form->{ALL} }) { - - $i++; $i %= 2; - - print qq| + # escape callback + $callback = $form->escape($callback); + + foreach $ca ( @{ $form->{ALL} } ) { + + $i++; + $i %= 2; + + print qq| |; - - $accno = $form->escape($ca->{accno}); - $column_data{accno} = qq||; - $column_data{description} = qq||; - - for (@column_index) { print "$column_data{$_}\n" } - - print "\n"; - } - - print qq| + + $accno = $form->escape( $ca->{accno} ); + $column_data{accno} = +qq||; + $column_data{description} = qq||; + + for (@column_index) { print "$column_data{$_}\n" } + + print "\n"; + } + + print qq| @@ -491,47 +566,46 @@ sub list_gifi { } - sub add_gifi { - $form->{title} = "Add"; - - # construct callback - $form->{callback} = "$form->{script}?action=list_gifi&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; + $form->{title} = "Add"; - $form->{coa} = 1; - - &gifi_header; - &gifi_footer; - -} + # construct callback + $form->{callback} = +"$form->{script}?action=list_gifi&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; + $form->{coa} = 1; -sub edit_gifi { - - $form->{title} = "Edit"; - - AM->get_gifi(\%myconfig, \%$form); + &gifi_header; + &gifi_footer; - $form->error($locale->text('Account does not exist!')) unless $form->{accno}; - - &gifi_header; - &gifi_footer; - } +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; + +} sub gifi_header { - $form->{title} = $locale->text("$form->{title} GIFI"); - -# $locale->text('Add GIFI') -# $locale->text('Edit GIFI') + $form->{title} = $locale->text("$form->{title} GIFI"); + + # $locale->text('Add GIFI') + # $locale->text('Edit GIFI') - for (qw(accno description)) { $form->{$_} = $form->quote($form->{$_}) } + for (qw(accno description)) { $form->{$_} = $form->quote( $form->{$_} ) } - $form->header; + $form->header; - print qq| + print qq| {script}> @@ -548,11 +622,11 @@ sub gifi_header { |; - $column_header{cost} = qq||; - $column_header{profit} = qq||; + @column_index = qw(description cost profit); - $form->header; + $column_header{description} = + qq||; + $column_header{cost} = + qq||; + $column_header{profit} = + qq||; - print qq| + $form->header; + + print qq|
{script}?action=edit_gifi&coa=1&accno=$accno&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ca->{accno}$ca->{description} 
{script}?action=edit_gifi&coa=1&accno=$accno&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ca->{accno}$ca->{description} 

- + - +
|.$locale->text('GIFI').qq|| . $locale->text('GIFI') . qq|
|.$locale->text('Description').qq|| . $locale->text('Description') . qq|
@@ -566,37 +640,40 @@ sub gifi_header { } - sub gifi_footer { - $form->hide_form(qw(callback path login sessionid)); - -# type=submit $locale->text('Save') -# type=submit $locale->text('Copy to COA') -# type=submit $locale->text('Delete') + $form->hide_form(qw(callback path login sessionid)); - %button = (); - - $button{'save'} = { ndx => 3, key => 'S', value => $locale->text('Save') }; - - if ($form->{accno}) { - if ($form->{orphaned}) { - $button{'delete'} = { ndx => 16, key => 'D', value => $locale->text('Delete') }; + # type=submit $locale->text('Save') + # type=submit $locale->text('Copy to COA') + # type=submit $locale->text('Delete') + + %button = (); + + $button{'save'} = { ndx => 3, key => 'S', value => $locale->text('Save') }; + + if ( $form->{accno} ) { + if ( $form->{orphaned} ) { + $button{'delete'} = + { ndx => 16, key => 'D', value => $locale->text('Delete') }; + } } - } - - if ($form->{coa}) { - $button{'copy_to_coa'} = { ndx => 7, key => 'C', value => $locale->text('Copy to COA') }; - } - for (sort { $button{$a}->{ndx} <=> $button{$b}->{ndx} } keys %button) { $form->print_button(\%button, $_) } + if ( $form->{coa} ) { + $button{'copy_to_coa'} = + { ndx => 7, key => 'C', value => $locale->text('Copy to COA') }; + } - if ($form->{lynx}) { - require "bin/menu.pl"; - &menubar; - } + for ( sort { $button{$a}->{ndx} <=> $button{$b}->{ndx} } keys %button ) { + $form->print_button( \%button, $_ ); + } + + if ( $form->{lynx} ) { + require "bin/menu.pl"; + &menubar; + } - print qq| + print qq| @@ -605,90 +682,97 @@ sub gifi_footer { } - sub save_gifi { - $form->isblank("accno", $locale->text('GIFI missing!')); - AM->save_gifi(\%myconfig, \%$form); - $form->redirect($locale->text('GIFI saved!')); + $form->isblank( "accno", $locale->text('GIFI missing!') ); + AM->save_gifi( \%myconfig, \%$form ); + $form->redirect( $locale->text('GIFI saved!') ); } - sub copy_to_coa { - $form->isblank("accno", $locale->text('GIFI missing!')); + $form->isblank( "accno", $locale->text('GIFI missing!') ); - AM->save_gifi(\%myconfig, \%$form); + AM->save_gifi( \%myconfig, \%$form ); - delete $form->{id}; - $form->{gifi_accno} = $form->{accno}; - - $form->{title} = "Add"; - $form->{charttype} = "A"; - - &account_header; - &form_footer; - -} + delete $form->{id}; + $form->{gifi_accno} = $form->{accno}; + + $form->{title} = "Add"; + $form->{charttype} = "A"; + &account_header; + &form_footer; + +} sub delete_gifi { - AM->delete_gifi(\%myconfig, \%$form); - $form->redirect($locale->text('GIFI deleted!')); + AM->delete_gifi( \%myconfig, \%$form ); + $form->redirect( $locale->text('GIFI deleted!') ); } - 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}; + $form->{title} = "Add"; + $form->{role} = "P"; - &department_header; - &form_footer; + $form->{callback} = +"$form->{script}?action=add_department&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" + unless $form->{callback}; -} + &department_header; + &form_footer; +} sub edit_department { - $form->{title} = "Edit"; + $form->{title} = "Edit"; - AM->get_department(\%myconfig, \%$form); + AM->get_department( \%myconfig, \%$form ); - &department_header; - &form_footer; + &department_header; + &form_footer; } - sub list_department { - AM->departments(\%myconfig, \%$form); + AM->departments( \%myconfig, \%$form ); - $href = "$form->{script}?action=list_department&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; + $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'); + $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} ); - @column_index = qw(description cost profit); + $form->{title} = $locale->text('Departments'); - $column_header{description} = qq|
|.$locale->text('Description').qq||.$locale->text('Cost Center').qq||.$locale->text('Profit Center').qq|| + . $locale->text('Description') + . qq|| + . $locale->text('Cost Center') + . qq|| + . $locale->text('Profit Center') + . qq|
@@ -702,35 +786,37 @@ sub list_department { |; - for (@column_index) { print "$column_header{$_}\n" } + for (@column_index) { print "$column_header{$_}\n" } - print qq| + print qq| |; - foreach $ref (@{ $form->{ALL} }) { - - $i++; $i %= 2; - - 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||; + $costcenter = ( $ref->{role} eq "C" ) ? "*" : " "; + $profitcenter = ( $ref->{role} eq "P" ) ? "*" : " "; + + $column_data{description} = +qq||; + $column_data{cost} = qq||; + $column_data{profit} = qq||; - for (@column_index) { print "$column_data{$_}\n" } + for (@column_index) { print "$column_data{$_}\n" } - print qq| + print qq| |; - } + } - 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}?action=edit_department&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{description}$costcenter$profitcenter
@@ -743,49 +829,53 @@ sub list_department {
{script}> |; - $form->{type} = "department"; - - $form->hide_form(qw(type callback path login sessionid)); - - print qq| -|; + $form->{type} = "department"; - if ($form->{lynx}) { - require "bin/menu.pl"; - &menubar; - } + $form->hide_form(qw(type callback path login sessionid)); - print qq| + print qq| +|; + + if ( $form->{lynx} ) { + require "bin/menu.pl"; + &menubar; + } + + print qq|
|; - -} +} sub department_header { - $form->{title} = $locale->text("$form->{title} Department"); + $form->{title} = $locale->text("$form->{title} Department"); -# $locale->text('Add Department') -# $locale->text('Edit Department') + # $locale->text('Add Department') + # $locale->text('Edit Department') - $form->{description} = $form->quote($form->{description}); + $form->{description} = $form->quote( $form->{description} ); - if (($rows = $form->numtextrows($form->{description}, 60)) > 1) { - $description = qq||; - } else { - $description = qq||; - } + 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; + $costcenter = "checked" if $form->{role} eq "C"; + $profitcenter = "checked" if $form->{role} eq "P"; + + $form->header; - print qq| + print qq|
{script}> @@ -799,13 +889,15 @@ sub department_header { - |.$locale->text('Description').qq| + | . $locale->text('Description') . qq| $description - |.$locale->text('Cost Center').qq| - |.$locale->text('Profit Center').qq| + | + . $locale->text('Cost Center') . qq| + | + . $locale->text('Profit Center') . qq|
@@ -815,72 +907,75 @@ sub department_header { } - sub save_department { - $form->isblank("description", $locale->text('Description missing!')); - AM->save_department(\%myconfig, \%$form); - $form->redirect($locale->text('Department saved!')); + $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!')); + AM->delete_department( \%myconfig, \%$form ); + $form->redirect( $locale->text('Department deleted!') ); } - sub add_business { - $form->{title} = "Add"; - - $form->{callback} = "$form->{script}?action=add_business&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback}; + $form->{title} = "Add"; - &business_header; - &form_footer; + $form->{callback} = +"$form->{script}?action=add_business&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" + unless $form->{callback}; -} + &business_header; + &form_footer; +} sub edit_business { - $form->{title} = "Edit"; + $form->{title} = "Edit"; - AM->get_business(\%myconfig, \%$form); + AM->get_business( \%myconfig, \%$form ); - &business_header; + &business_header; - $form->{orphaned} = 1; - &form_footer; + $form->{orphaned} = 1; + &form_footer; } - sub list_business { - AM->business(\%myconfig, \%$form); + AM->business( \%myconfig, \%$form ); - $href = "$form->{script}?action=list_business&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; + $href = +"$form->{script}?action=list_business&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; - $form->sort_order(); - - $form->{callback} = "$form->{script}?action=list_business&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; - - $callback = $form->escape($form->{callback}); - - $form->{title} = $locale->text('Type of Business'); + $form->sort_order(); + + $form->{callback} = +"$form->{script}?action=list_business&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; + + $callback = $form->escape( $form->{callback} ); + + $form->{title} = $locale->text('Type of Business'); - @column_index = qw(description discount); + @column_index = qw(description discount); - $column_header{description} = qq||.$locale->text('Description').qq||; - $column_header{discount} = qq||.$locale->text('Discount').qq| %|; + $column_header{description} = + qq|| + . $locale->text('Description') + . qq||; + $column_header{discount} = + qq|| . $locale->text('Discount') . qq| %|; - $form->header; + $form->header; - print qq| + print qq| @@ -894,33 +989,37 @@ sub list_business { |; - for (@column_index) { print "$column_header{$_}\n" } + for (@column_index) { print "$column_header{$_}\n" } - print qq| + print qq| |; - foreach $ref (@{ $form->{ALL} }) { - - $i++; $i %= 2; - - print qq| + foreach $ref ( @{ $form->{ALL} } ) { + + $i++; + $i %= 2; + + print qq| |; - $discount = $form->format_amount(\%myconfig, $ref->{discount} * 100, 2, " "); - - $column_data{description} = qq||; - $column_data{discount} = qq||; - - for (@column_index) { print "$column_data{$_}\n" } + $discount = + $form->format_amount( \%myconfig, $ref->{discount} * 100, 2, + " " ); + + $column_data{description} = +qq||; + $column_data{discount} = qq||; + + for (@column_index) { print "$column_data{$_}\n" } - print qq| + print qq| |; - } + } - print qq| + print qq|
{script}?action=edit_business&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{description}$discount{script}?action=edit_business&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{description}$discount
@@ -933,42 +1032,44 @@ sub list_business { {script}> |; - $form->{type} = "business"; - - $form->hide_form(qw(type callback path login sessionid)); + $form->{type} = "business"; - print qq| -|; + $form->hide_form(qw(type callback path login sessionid)); - if ($form->{lynx}) { - require "bin/menu.pl"; - &menubar; - } + print qq| +|; - print qq| + if ( $form->{lynx} ) { + require "bin/menu.pl"; + &menubar; + } + + print qq|
|; - -} +} sub business_header { - $form->{title} = $locale->text("$form->{title} Business"); + $form->{title} = $locale->text("$form->{title} Business"); -# $locale->text('Add Business') -# $locale->text('Edit Business') + # $locale->text('Add Business') + # $locale->text('Edit Business') - $form->{description} = $form->quote($form->{description}); - $form->{discount} = $form->format_amount(\%myconfig, $form->{discount} * 100); + $form->{description} = $form->quote( $form->{description} ); + $form->{discount} = + $form->format_amount( \%myconfig, $form->{discount} * 100 ); - $form->header; + $form->header; - print qq| + print qq|
{script}> @@ -985,11 +1086,11 @@ sub business_header { - + - +
|.$locale->text('Type of Business').qq|| . $locale->text('Type of Business') . qq|
|.$locale->text('Discount').qq| %| . $locale->text('Discount') . qq| % {discount}>
@@ -1003,77 +1104,81 @@ sub business_header { } - sub save_business { - $form->isblank("description", $locale->text('Description missing!')); - AM->save_business(\%myconfig, \%$form); - $form->redirect($locale->text('Business saved!')); + $form->isblank( "description", $locale->text('Description missing!') ); + AM->save_business( \%myconfig, \%$form ); + $form->redirect( $locale->text('Business saved!') ); } - sub delete_business { - AM->delete_business(\%myconfig, \%$form); - $form->redirect($locale->text('Business deleted!')); + AM->delete_business( \%myconfig, \%$form ); + $form->redirect( $locale->text('Business deleted!') ); } - - sub add_sic { - $form->{title} = "Add"; - - $form->{callback} = "$form->{script}?action=add_sic&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback}; + $form->{title} = "Add"; - &sic_header; - &form_footer; + $form->{callback} = +"$form->{script}?action=add_sic&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" + unless $form->{callback}; -} + &sic_header; + &form_footer; +} sub edit_sic { - $form->{title} = "Edit"; + $form->{title} = "Edit"; - $form->{code} =~ s/\\'/'/g; - $form->{code} =~ s/\\\\/\\/g; - - AM->get_sic(\%myconfig, \%$form); - $form->{id} = $form->{code}; + $form->{code} =~ s/\\'/'/g; + $form->{code} =~ s/\\\\/\\/g; - &sic_header; + AM->get_sic( \%myconfig, \%$form ); + $form->{id} = $form->{code}; - $form->{orphaned} = 1; - &form_footer; + &sic_header; -} + $form->{orphaned} = 1; + &form_footer; +} sub list_sic { - AM->sic(\%myconfig, \%$form); + AM->sic( \%myconfig, \%$form ); - $href = "$form->{script}?action=list_sic&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; - - $form->sort_order(); + $href = +"$form->{script}?action=list_sic&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; - $form->{callback} = "$form->{script}?action=list_sic&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; - - $callback = $form->escape($form->{callback}); - - $form->{title} = $locale->text('Standard Industrial Codes'); + $form->sort_order(); + + $form->{callback} = +"$form->{script}?action=list_sic&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; - @column_index = $form->sort_columns(qw(code description)); + $callback = $form->escape( $form->{callback} ); - $column_header{code} = qq||.$locale->text('Code').qq||; - $column_header{description} = qq||.$locale->text('Description').qq||; + $form->{title} = $locale->text('Standard Industrial Codes'); - $form->header; + @column_index = $form->sort_columns(qw(code description)); - print qq| + $column_header{code} = + qq|| + . $locale->text('Code') + . qq||; + $column_header{description} = + qq|| + . $locale->text('Description') + . qq||; + + $form->header; + + print qq| @@ -1087,41 +1192,45 @@ sub list_sic { |; - for (@column_index) { print "$column_header{$_}\n" } + for (@column_index) { print "$column_header{$_}\n" } - print qq| + print qq| |; - foreach $ref (@{ $form->{ALL} }) { - - $i++; $i %= 2; - - if ($ref->{sictype} eq 'H') { - print qq| + foreach $ref ( @{ $form->{ALL} } ) { + + $i++; + $i %= 2; + + if ( $ref->{sictype} eq 'H' ) { + print qq| |; - $column_data{code} = qq||; - $column_data{description} = qq||; - - } else { - print qq| + $column_data{code} = +qq||; + $column_data{description} = qq||; + + } + else { + print qq| |; - $column_data{code} = qq||; - $column_data{description} = qq||; + $column_data{code} = +qq||; + $column_data{description} = qq||; - } - - for (@column_index) { print "$column_data{$_}\n" } + } - print qq| + for (@column_index) { print "$column_data{$_}\n" } + + print qq| |; - } + } - print qq| + print qq|
{script}?action=edit_sic&code=$ref->{code}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{code}$ref->{description}{script}?action=edit_sic&code=$ref->{code}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{code}$ref->{description}
{script}?action=edit_sic&code=$ref->{code}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{code}$ref->{description}{script}?action=edit_sic&code=$ref->{code}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{code}$ref->{description}
@@ -1134,42 +1243,43 @@ sub list_sic { {script}> |; - $form->{type} = "sic"; - - $form->hide_form(qw(type callback path login sessionid)); - - print qq| -|; + $form->{type} = "sic"; + + $form->hide_form(qw(type callback path login sessionid)); + + print qq| +|; - if ($form->{lynx}) { - require "bin/menu.pl"; - &menubar; - } + if ( $form->{lynx} ) { + require "bin/menu.pl"; + &menubar; + } - print qq| + print qq|
|; - -} +} sub sic_header { - $form->{title} = $locale->text("$form->{title} SIC"); + $form->{title} = $locale->text("$form->{title} SIC"); -# $locale->text('Add SIC') -# $locale->text('Edit SIC') + # $locale->text('Add SIC') + # $locale->text('Edit SIC') - for (qw(code description)) { $form->{$_} = $form->quote($form->{$_}) } + for (qw(code description)) { $form->{$_} = $form->quote( $form->{$_} ) } - $checked = ($form->{sictype} eq 'H') ? "checked" : ""; + $checked = ( $form->{sictype} eq 'H' ) ? "checked" : ""; - $form->header; + $form->header; - print qq| + print qq|
{script}> @@ -1183,15 +1293,17 @@ sub sic_header { - |.$locale->text('Code').qq| + | . $locale->text('Code') . qq| - |.$locale->text('Heading').qq| + | + . $locale->text('Heading') + . qq| - |.$locale->text('Description').qq| + | . $locale->text('Description') . qq|
@@ -1201,77 +1313,82 @@ sub sic_header { } - sub save_sic { - $form->isblank("code", $locale->text('Code missing!')); - $form->isblank("description", $locale->text('Description missing!')); - AM->save_sic(\%myconfig, \%$form); - $form->redirect($locale->text('SIC saved!')); + $form->isblank( "code", $locale->text('Code missing!') ); + $form->isblank( "description", $locale->text('Description missing!') ); + AM->save_sic( \%myconfig, \%$form ); + $form->redirect( $locale->text('SIC saved!') ); } - sub delete_sic { - AM->delete_sic(\%myconfig, \%$form); - $form->redirect($locale->text('SIC deleted!')); + AM->delete_sic( \%myconfig, \%$form ); + $form->redirect( $locale->text('SIC deleted!') ); } - sub add_language { - $form->{title} = "Add"; - - $form->{callback} = "$form->{script}?action=add_language&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback}; + $form->{title} = "Add"; - &language_header; - &form_footer; + $form->{callback} = +"$form->{script}?action=add_language&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" + unless $form->{callback}; -} + &language_header; + &form_footer; +} sub edit_language { - $form->{title} = "Edit"; + $form->{title} = "Edit"; - $form->{code} =~ s/\\'/'/g; - $form->{code} =~ s/\\\\/\\/g; - - AM->get_language(\%myconfig, \%$form); - $form->{id} = $form->{code}; + $form->{code} =~ s/\\'/'/g; + $form->{code} =~ s/\\\\/\\/g; - &language_header; + AM->get_language( \%myconfig, \%$form ); + $form->{id} = $form->{code}; - $form->{orphaned} = 1; - &form_footer; + &language_header; -} + $form->{orphaned} = 1; + &form_footer; +} sub list_language { - AM->language(\%myconfig, \%$form); + AM->language( \%myconfig, \%$form ); - $href = "$form->{script}?action=list_language&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; - - $form->sort_order(); + $href = +"$form->{script}?action=list_language&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; - $form->{callback} = "$form->{script}?action=list_language&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; - - $callback = $form->escape($form->{callback}); - - $form->{title} = $locale->text('Languages'); + $form->sort_order(); - @column_index = $form->sort_columns(qw(code description)); + $form->{callback} = +"$form->{script}?action=list_language&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; - $column_header{code} = qq||.$locale->text('Code').qq||; - $column_header{description} = qq||.$locale->text('Description').qq||; + $callback = $form->escape( $form->{callback} ); - $form->header; + $form->{title} = $locale->text('Languages'); - print qq| + @column_index = $form->sort_columns(qw(code description)); + + $column_header{code} = + qq|| + . $locale->text('Code') + . qq||; + $column_header{description} = + qq|| + . $locale->text('Description') + . qq||; + + $form->header; + + print qq| @@ -1285,31 +1402,33 @@ sub list_language { |; - for (@column_index) { print "$column_header{$_}\n" } + for (@column_index) { print "$column_header{$_}\n" } - print qq| + print qq| |; - foreach $ref (@{ $form->{ALL} }) { - - $i++; $i %= 2; + foreach $ref ( @{ $form->{ALL} } ) { - print qq| + $i++; + $i %= 2; + + print qq| |; - $column_data{code} = qq||; - $column_data{description} = qq||; - - for (@column_index) { print "$column_data{$_}\n" } + $column_data{code} = +qq||; + $column_data{description} = qq||; - print qq| + for (@column_index) { print "$column_data{$_}\n" } + + print qq| |; - } + } - print qq| + print qq|
{script}?action=edit_language&code=$ref->{code}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{code}$ref->{description}{script}?action=edit_language&code=$ref->{code}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{code}$ref->{description}
@@ -1322,40 +1441,41 @@ sub list_language { {script}> |; - $form->{type} = "language"; + $form->{type} = "language"; - $form->hide_form(qw(type callback path login sessionid)); - - print qq| -|; + $form->hide_form(qw(type callback path login sessionid)); + + print qq| +|; - if ($form->{lynx}) { - require "bin/menu.pl"; - &menubar; - } + if ( $form->{lynx} ) { + require "bin/menu.pl"; + &menubar; + } - print qq| + print qq|
|; - -} +} sub language_header { - $form->{title} = $locale->text("$form->{title} Language"); + $form->{title} = $locale->text("$form->{title} Language"); -# $locale->text('Add Language') -# $locale->text('Edit Language') + # $locale->text('Add Language') + # $locale->text('Edit Language') - for (qw(code description)) { $form->{$_} = $form->quote($form->{$_}) } + for (qw(code description)) { $form->{$_} = $form->quote( $form->{$_} ) } - $form->header; + $form->header; - print qq| + print qq|
{script}> @@ -1369,11 +1489,11 @@ sub language_header { - |.$locale->text('Code').qq| + | . $locale->text('Code') . qq| - |.$locale->text('Description').qq| + | . $locale->text('Description') . qq|
@@ -1383,75 +1503,85 @@ sub language_header { } - sub save_language { - $form->isblank("code", $locale->text('Code missing!')); - $form->isblank("description", $locale->text('Description missing!')); + $form->isblank( "code", $locale->text('Code missing!') ); + $form->isblank( "description", $locale->text('Description missing!') ); - $form->{code} =~ s/(\.\.|\*)//g; - - AM->save_language(\%myconfig, \%$form); + $form->{code} =~ s/(\.\.|\*)//g; + + AM->save_language( \%myconfig, \%$form ); + + if ( !-d "$myconfig{templates}/$form->{code}" ) { - if (! -d "$myconfig{templates}/$form->{code}") { - - umask(002); - - if (mkdir "$myconfig{templates}/$form->{code}", oct("771")) { - - umask(007); + umask(002); - opendir TEMPLATEDIR, "$myconfig{templates}" or $form->error("$myconfig{templates} : $!"); - @templates = grep !/^(\.|\.\.)/, readdir TEMPLATEDIR; - closedir TEMPLATEDIR; + if ( mkdir "$myconfig{templates}/$form->{code}", oct("771") ) { - foreach $file (@templates) { - if (-f "$myconfig{templates}/$file") { - open(TEMP, '<', "$myconfig{templates}/$file") or $form->error("$myconfig{templates}/$file : $!"); + umask(007); - open(NEW, '>', "$myconfig{templates}/$form->{code}/$file") or $form->error("$myconfig{templates}/$form->{code}/$file : $!"); + opendir TEMPLATEDIR, "$myconfig{templates}" + or $form->error("$myconfig{templates} : $!"); + @templates = grep !/^(\.|\.\.)/, readdir TEMPLATEDIR; + closedir TEMPLATEDIR; - while ($line = ) { - print NEW $line; - } - close(TEMP); - close(NEW); - } - } - } else { - $form->error("${templates}/$form->{code} : $!"); + foreach $file (@templates) { + if ( -f "$myconfig{templates}/$file" ) { + open( TEMP, '<', "$myconfig{templates}/$file" ) + or $form->error("$myconfig{templates}/$file : $!"); + + open( NEW, '>', "$myconfig{templates}/$form->{code}/$file" ) + or $form->error( + "$myconfig{templates}/$form->{code}/$file : $!"); + + while ( $line = ) { + print NEW $line; + } + close(TEMP); + close(NEW); + } + } + } + else { + $form->error("${templates}/$form->{code} : $!"); + } } - } - - $form->redirect($locale->text('Language saved!')); -} + $form->redirect( $locale->text('Language saved!') ); +} sub delete_language { - $form->{title} = $locale->text('Confirm!'); + $form->{title} = $locale->text('Confirm!'); - $form->header; + $form->header; - print qq| + print qq| {script}> |; - for (qw(action nextsub)) { delete $form->{$_} } - - $form->hide_form; + for (qw(action nextsub)) { delete $form->{$_} } + + $form->hide_form; - print qq| + print qq|

$form->{title}

-

|.$locale->text('Deleting a language will also delete the templates for the language [_1]', $form->{invnumber}).qq|

+

| + . $locale->text( +'Deleting a language will also delete the templates for the language [_1]', + $form->{invnumber} + ) + . qq|

- + @@ -1460,62 +1590,68 @@ sub delete_language { } - sub yes_delete_language { - - AM->delete_language(\%myconfig, \%$form); - # delete templates - $dir = "$myconfig{templates}/$form->{code}"; - if (-d $dir) { - unlink <$dir/*>; - rmdir "$myconfig{templates}/$form->{code}"; - } - $form->redirect($locale->text('Language deleted!')); + AM->delete_language( \%myconfig, \%$form ); -} + # delete templates + $dir = "$myconfig{templates}/$form->{code}"; + if ( -d $dir ) { + unlink <$dir/*>; + rmdir "$myconfig{templates}/$form->{code}"; + } + $form->redirect( $locale->text('Language deleted!') ); +} sub display_stylesheet { - - $form->{file} = "css/$myconfig{stylesheet}"; - &display_form; - -} + $form->{file} = "css/$myconfig{stylesheet}"; + &display_form; + +} sub list_templates { - AM->language(\%myconfig, \%$form); - - if (! @{ $form->{ALL} }) { - &display_form; - exit; - } + AM->language( \%myconfig, \%$form ); - unshift @{ $form->{ALL} }, { code => '.', description => $locale->text('Default Template') }; - - $href = "$form->{script}?action=list_templates&direction=$form->{direction}&oldsort=$form->{oldsort}&file=$form->{file}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; - - $form->sort_order(); + if ( !@{ $form->{ALL} } ) { + &display_form; + exit; + } + + unshift @{ $form->{ALL} }, + { code => '.', description => $locale->text('Default Template') }; + + $href = +"$form->{script}?action=list_templates&direction=$form->{direction}&oldsort=$form->{oldsort}&file=$form->{file}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; + + $form->sort_order(); - $form->{callback} = "$form->{script}?action=list_templates&direction=$form->{direction}&oldsort=$form->{oldsort}&file=$form->{file}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; - - $callback = $form->escape($form->{callback}); + $form->{callback} = +"$form->{script}?action=list_templates&direction=$form->{direction}&oldsort=$form->{oldsort}&file=$form->{file}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; + + $callback = $form->escape( $form->{callback} ); - chomp $myconfig{templates}; - $form->{file} =~ s/$myconfig{templates}//; - $form->{file} =~ s/\///; - $form->{title} = $form->{file}; + chomp $myconfig{templates}; + $form->{file} =~ s/$myconfig{templates}//; + $form->{file} =~ s/\///; + $form->{title} = $form->{file}; - @column_index = $form->sort_columns(qw(code description)); + @column_index = $form->sort_columns(qw(code description)); - $column_header{code} = qq||.$locale->text('Code').qq||; - $column_header{description} = qq||.$locale->text('Description').qq||; + $column_header{code} = + qq|| + . $locale->text('Code') + . qq||; + $column_header{description} = + qq|| + . $locale->text('Description') + . qq||; - $form->header; + $form->header; - print qq| + print qq| @@ -1529,31 +1665,33 @@ sub list_templates { |; - for (@column_index) { print "$column_header{$_}\n" } + for (@column_index) { print "$column_header{$_}\n" } - print qq| + print qq| |; - foreach $ref (@{ $form->{ALL} }) { - - $i++; $i %= 2; + foreach $ref ( @{ $form->{ALL} } ) { - print qq| + $i++; + $i %= 2; + + print qq| |; - $column_data{code} = qq||; - $column_data{description} = qq||; - - for (@column_index) { print "$column_data{$_}\n" } + $column_data{code} = +qq||; + $column_data{description} = qq||; - print qq| + for (@column_index) { print "$column_data{$_}\n" } + + print qq| |; - } + } - print qq| + print qq|
{script}?action=display_form&file=$myconfig{templates}/$ref->{code}/$form->{file}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&code=$ref->{code}&callback=$callback>$ref->{code}$ref->{description}{script}?action=display_form&file=$myconfig{templates}/$ref->{code}/$form->{file}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&code=$ref->{code}&callback=$callback>$ref->{code}$ref->{description}
@@ -1574,37 +1712,37 @@ sub list_templates { {sessionid}> |; - if ($form->{lynx}) { - require "bin/menu.pl"; - &menubar; - } + if ( $form->{lynx} ) { + require "bin/menu.pl"; + &menubar; + } - print qq| + print qq| |; - -} +} sub display_form { - AM->load_template(\%myconfig, \%$form); + AM->load_template( \%myconfig, \%$form ); - $form->{title} = $form->{file}; + $form->{title} = $form->{file}; - $form->{body} =~ s/<%include (.*?)%>/{script}\?action=display_form&file=$myconfig{templates}\/$form->{code}\/$1&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}>$1<\/a>/g; + $form->{body} =~ +s/<%include (.*?)%>/{script}\?action=display_form&file=$myconfig{templates}\/$form->{code}\/$1&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}>$1<\/a>/g; + + # if it is anything but html + if ( $form->{file} !~ /\.html$/ ) { + $form->{body} = "
\n$form->{body}\n
"; + } - # if it is anything but html - if ($form->{file} !~ /\.html$/) { - $form->{body} = "
\n$form->{body}\n
"; - } - - $form->header; + $form->header; - print qq| + print qq| $form->{body} @@ -1612,19 +1750,21 @@ $form->{body}
{script}> |; - $form->{type} = "template"; + $form->{type} = "template"; - $form->hide_form(qw(file type path login sessionid)); - - print qq| -|; + $form->hide_form(qw(file type path login sessionid)); + + print qq| +|; - if ($form->{lynx}) { - require "bin/menu.pl"; - &menubar; - } + if ( $form->{lynx} ) { + require "bin/menu.pl"; + &menubar; + } - print qq| + print qq|
@@ -1633,19 +1773,18 @@ $form->{body} } - sub edit_template { - AM->load_template(\%myconfig, \%$form); + AM->load_template( \%myconfig, \%$form ); - $form->{title} = $locale->text('Edit Template'); - # convert   to &nbsp; - $form->{body} =~ s/ /&nbsp;/gi; - + $form->{title} = $locale->text('Edit Template'); - $form->header; - - print qq| + # convert   to &nbsp; + $form->{body} =~ s/ /&nbsp;/gi; + + $form->header; + + print qq|
{script}> @@ -1664,14 +1803,16 @@ $form->{body}
-|; +|; - if ($form->{lynx}) { - require "bin/menu.pl"; - &menubar; - } + if ( $form->{lynx} ) { + require "bin/menu.pl"; + &menubar; + } - print q| + print q|
@@ -1681,36 +1822,38 @@ $form->{body} } - sub save_template { - AM->save_template(\%myconfig, \%$form); - $form->redirect($locale->text('Template saved!')); - -} + AM->save_template( \%myconfig, \%$form ); + $form->redirect( $locale->text('Template saved!') ); +} sub defaults { - - # get defaults for account numbers and last numbers - AM->get_all_defaults(\%$form); - foreach $key (keys %{ $form->{accno} }) { - foreach $accno (sort keys %{ $form->{accno}{$key} }) { - $form->{account}{$key} .= "

"; + if ( $form->{removeaudittrail} ) { + $msg .= + $locale->text('Audit trail removed up to') . " " + . $locale->date( \%myconfig, $form->{removeaudittrail}, 1 ); + } - &warehouse_header; - &form_footer; + $form->redirect($msg); } +sub add_warehouse { + + $form->{title} = "Add"; + + $form->{callback} = +"$form->{script}?action=add_warehouse&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" + unless $form->{callback}; + + &warehouse_header; + &form_footer; + +} sub edit_warehouse { - $form->{title} = "Edit"; + $form->{title} = "Edit"; - AM->get_warehouse(\%myconfig, \%$form); + AM->get_warehouse( \%myconfig, \%$form ); - &warehouse_header; - &form_footer; + &warehouse_header; + &form_footer; } - sub list_warehouse { - AM->warehouses(\%myconfig, \%$form); + AM->warehouses( \%myconfig, \%$form ); - $href = "$form->{script}?action=list_warehouse&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; + $href = +"$form->{script}?action=list_warehouse&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; - $form->sort_order(); - - $form->{callback} = "$form->{script}?action=list_warehouse&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; + $form->sort_order(); - $callback = $form->escape($form->{callback}); - - $form->{title} = $locale->text('Warehouses'); + $form->{callback} = +"$form->{script}?action=list_warehouse&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; + + $callback = $form->escape( $form->{callback} ); - @column_index = qw(description); + $form->{title} = $locale->text('Warehouses'); - $column_header{description} = qq||.$locale->text('Description').qq||; + @column_index = qw(description); - $form->header; + $column_header{description} = + qq|| + . $locale->text('Description') + . qq||; - print qq| + $form->header; + + print qq| @@ -2424,30 +2652,32 @@ sub list_warehouse { |; - for (@column_index) { print "$column_header{$_}\n" } + for (@column_index) { print "$column_header{$_}\n" } - print qq| + print qq| |; - foreach $ref (@{ $form->{ALL} }) { - - $i++; $i %= 2; - - print qq| + foreach $ref ( @{ $form->{ALL} } ) { + + $i++; + $i %= 2; + + print qq| |; - $column_data{description} = qq||; + $column_data{description} = +qq||; - for (@column_index) { print "$column_data{$_}\n" } + for (@column_index) { print "$column_data{$_}\n" } - print qq| + print qq| |; - } + } - print qq| + print qq|
{script}?action=edit_warehouse&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{description}{script}?action=edit_warehouse&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{description}
@@ -2460,48 +2690,50 @@ sub list_warehouse {

{script}> |; - $form->{type} = "warehouse"; + $form->{type} = "warehouse"; - $form->hide_form(qw(type callback path login sessionid)); - - print qq| -|; + $form->hide_form(qw(type callback path login sessionid)); + + print qq| +|; - if ($form->{lynx}) { - require "bin/menu.pl"; - &menubar; - } + if ( $form->{lynx} ) { + require "bin/menu.pl"; + &menubar; + } - print qq| + print qq|
|; - -} - +} sub warehouse_header { - $form->{title} = $locale->text("$form->{title} Warehouse"); + $form->{title} = $locale->text("$form->{title} Warehouse"); -# $locale->text('Add Warehouse') -# $locale->text('Edit Warehouse') + # $locale->text('Add Warehouse') + # $locale->text('Edit Warehouse') - $form->{description} = $form->quote($form->{description}); + $form->{description} = $form->quote( $form->{description} ); - if (($rows = $form->numtextrows($form->{description}, 60)) > 1) { - $description = qq||; - } else { - $description = qq||; - } + if ( ( $rows = $form->numtextrows( $form->{description}, 60 ) ) > 1 ) { + $description = +qq||; + } + else { + $description = + qq||; + } - - $form->header; + $form->header; - print qq| + print qq|
{script}> @@ -2515,7 +2747,7 @@ sub warehouse_header { - |.$locale->text('Description').qq| + | . $locale->text('Description') . qq| $description @@ -2526,34 +2758,33 @@ sub warehouse_header { } - sub save_warehouse { - $form->isblank("description", $locale->text('Description missing!')); - AM->save_warehouse(\%myconfig, \%$form); - $form->redirect($locale->text('Warehouse saved!')); + $form->isblank( "description", $locale->text('Description missing!') ); + AM->save_warehouse( \%myconfig, \%$form ); + $form->redirect( $locale->text('Warehouse saved!') ); } - sub delete_warehouse { - AM->delete_warehouse(\%myconfig, \%$form); - $form->redirect($locale->text('Warehouse deleted!')); + AM->delete_warehouse( \%myconfig, \%$form ); + $form->redirect( $locale->text('Warehouse deleted!') ); } - sub yearend { - AM->earningsaccounts(\%myconfig, \%$form); - $chart = ""; - for (@{ $form->{chart} }) { $chart .= "