From a02580dd0483e0fec073a1d64634777f47db71bd Mon Sep 17 00:00:00 2001 From: tetragon Date: Thu, 11 Oct 2007 13:34:46 +0000 Subject: Getting rid of most of the HTML in the bin/LSMB code for the income statement Adding in the links git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1741 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB/RP.pm | 26 ++++++++++----- bin/rp.pl | 62 ++++++++++++++++-------------------- templates/demo/income_statement.html | 46 +++++++++++++++++++------- 3 files changed, 80 insertions(+), 54 deletions(-) diff --git a/LedgerSMB/RP.pm b/LedgerSMB/RP.pm index c46ee788..4854355e 100644 --- a/LedgerSMB/RP.pm +++ b/LedgerSMB/RP.pm @@ -251,13 +251,16 @@ sub income_statement { # push description onto array - $str = ( $form->{l_heading} ) ? $form->{padding} : ""; +## $str = ( $form->{l_heading} ) ? $form->{padding} : ""; + $str = ""; if ( $form->{$category}{$key}{charttype} eq "A" ) { $str .= ( $form->{l_accno} ) ? "$form->{$category}{$key}{accno} - $form->{$category}{$key}{description}" : "$form->{$category}{$key}{description}"; + $str = {account => $form->{$category}{$key}{accno}, text => $str }; + $str->{gifi_account} = 1 if $form->{accounttype} eq 'gifi'; } if ( $form->{$category}{$key}{charttype} eq "H" ) { if ( $account{$category}{subtotal} @@ -266,8 +269,10 @@ sub income_statement { $dash = "- "; push( - @{ $form->{"$account{$category}{label}_account"} }, -"$str$form->{bold}$account{$category}{subdescription}$form->{endbold}" + @{ $form->{"$account{$category}{label}_account"} }, { + text => "$account{$category}{subdescription}", + subtotal => 1, + }, ); push( @@ -304,8 +309,10 @@ sub income_statement { } - $str = -"$form->{br}$form->{bold}$form->{$category}{$key}{description}$form->{endbold}"; + $str = { + text => "$form->{$category}{$key}{description}", + heading => 1, + }; $account{$category}{subthis} = $form->{$category}{$key}{this}; $account{$category}{sublast} = $form->{$category}{$key}{last}; @@ -357,11 +364,14 @@ sub income_statement { } } - $str = ( $form->{l_heading} ) ? $form->{padding} : ""; +## $str = ( $form->{l_heading} ) ? $form->{padding} : ""; + $str = ""; if ( $account{$category}{subtotal} && $form->{l_subtotal} ) { push( - @{ $form->{"$account{$category}{label}_account"} }, -"$str$form->{bold}$account{$category}{subdescription}$form->{endbold}" + @{ $form->{"$account{$category}{label}_account"} }, { + text => "$account{$category}{subdescription}", + subtotal => 1, + }, ); push( @{ $form->{"$account{$category}{labels}_this_period"} }, diff --git a/bin/rp.pl b/bin/rp.pl index b76c610f..1a598387 100644 --- a/bin/rp.pl +++ b/bin/rp.pl @@ -49,6 +49,7 @@ use LedgerSMB::Template; use LedgerSMB::PE; use LedgerSMB::RP; +#$form->{login} = 'test'; 1; # end of main @@ -1019,11 +1020,6 @@ qq|rp.pl?path=$form->{path}&action=continue&accounttype=$form->{accounttype}&log sub generate_income_statement { - $form->{padding} = "  "; - $form->{bold} = ""; - $form->{endbold} = ""; - $form->{br} = "
"; - RP->income_statement( \%myconfig, \%$form ); ( $form->{department} ) = split /--/, $form->{department}; @@ -1034,25 +1030,20 @@ sub generate_income_statement { $form->{todate} = $form->current_date( \%myconfig ) unless $form->{todate}; # if there are any dates construct a where - if ( $form->{fromdate} || $form->{todate} ) { + unless ( $form->{todate} ) { + $form->{todate} = $form->current_date( \%myconfig ); + } - unless ( $form->{todate} ) { - $form->{todate} = $form->current_date( \%myconfig ); - } + $longtodate = $locale->date( \%myconfig, $form->{todate}, 1 ); + $shorttodate = $locale->date( \%myconfig, $form->{todate}, 0 ); - $longtodate = $locale->date( \%myconfig, $form->{todate}, 1 ); - $shorttodate = $locale->date( \%myconfig, $form->{todate}, 0 ); + $longfromdate = $locale->date( \%myconfig, $form->{fromdate}, 1 ); + $shortfromdate = $locale->date( \%myconfig, $form->{fromdate}, 0 ); - $longfromdate = $locale->date( \%myconfig, $form->{fromdate}, 1 ); - $shortfromdate = $locale->date( \%myconfig, $form->{fromdate}, 0 ); - - $form->{this_period} = "$shortfromdate
\n$shorttodate"; - $form->{period} = - $locale->text('for Period') - . qq|
\n$longfromdate | - . $locale->text('To') - . qq| $longtodate|; - } + $form->{this_period_from} = $shortfromdate; + $form->{this_period_to} = $shorttodate; + # example output: 2006-01-01 To 2007-01-01 + $form->{period} = $locale->text('[_1] To [_2]', $longfromdate, $longtodate); if ( $form->{comparefromdate} || $form->{comparetodate} ) { $longcomparefromdate = @@ -1065,24 +1056,27 @@ sub generate_income_statement { $shortcomparetodate = $locale->date( \%myconfig, $form->{comparetodate}, 0 ); - $form->{last_period} = "$shortcomparefromdate
\n$shortcomparetodate"; - $form->{period} .= - "
\n$longcomparefromdate " - . $locale->text('To') - . qq| $longcomparetodate|; + $form->{last_period_from} = $shortcomparefromdate; + $form->{last_period_to} = $shortcomparetodate; + $form->{compare_period} = $locale->text('[_1] To [_2]', + $longcomparefromdate, $longcomparetodate); } # setup variables for the form - @a = qw(company address businessnumber); - for (@a) { $form->{$_} = $myconfig{$_} } + my @vars = qw(company address businessnumber); + for (@vars) { $form->{$_} = $myconfig{$_} } + ##SC: START HTML $form->{address} =~ s/\\n/
/g; + ##SC: END HTML - $form->{templates} = $myconfig{templates}; - - $form->{IN} = "income_statement.html"; - my $template = LedgerSMB::Template->new( user => \%myconfig, - template => $form->{'formname'}, format => uc $form->{format} ); + my $template = LedgerSMB::Template->new( + user => \%myconfig, + locale => $locale, + template => 'income_statement', + format => 'HTML', + #no_escape => '1' + ); try { $template->render($form); $template->output(%{$form}); @@ -1096,7 +1090,6 @@ sub generate_income_statement { sub generate_balance_sheet { - ##SC: START HTML RP->balance_sheet( \%myconfig, \%$form ); $form->{asofdate} = $form->current_date( \%myconfig ) @@ -1122,6 +1115,7 @@ sub generate_balance_sheet { for (qw(company address businessnumber nativecurr login)) { $form->{$_} = $myconfig{$_}; } + ##SC: START HTML $form->{address} =~ s/\\n/
/g; ##SC: END HTML diff --git a/templates/demo/income_statement.html b/templates/demo/income_statement.html index 970769a7..03043ae6 100644 --- a/templates/demo/income_statement.html +++ b/templates/demo/income_statement.html @@ -35,36 +35,58 @@ +") ?> +
     +


-
INCOME STATEMENT +
+

+ +
+

-

Department:

+

-

Project Number:

+

- - - + + + - + @@ -78,20 +100,20 @@ - + - + - + @@ -105,13 +127,13 @@ - + - + -- cgit v1.2.3
INCOME





TOTAL INCOME

EXPENSES



TOTAL EXPENSES



INCOME / (LOSS)