[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb: [1802] trunk/bin/rp.pl
- Subject: SF.net SVN: ledger-smb: [1802] trunk/bin/rp.pl
- From: ..hidden..
- Date: Sun, 21 Oct 2007 19:33:18 -0700
Revision: 1802
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1802&view=rev
Author: tetragon
Date: 2007-10-21 19:33:18 -0700 (Sun, 21 Oct 2007)
Log Message:
-----------
Switch the inventory activity report to the dynatable
Modified Paths:
--------------
trunk/bin/rp.pl
Modified: trunk/bin/rp.pl
===================================================================
--- trunk/bin/rp.pl 2007-10-21 00:18:13 UTC (rev 1801)
+++ trunk/bin/rp.pl 2007-10-22 02:33:18 UTC (rev 1802)
@@ -865,12 +865,13 @@
sub continue { &{ $form->{nextsub} } }
sub generate_inv_activity {
- $form->header;
+
+ my %hiddens;
+ my @options;
+ my $title = $form->{title};
RP->inventory_activity( \%myconfig, \%$form );
- $title = $form->escape( $form->{title} );
-
# if ($form->{department}) {
# ($department) = split /--/, $form->{department};
# $options = $locale->text('Department')." : $department<br>";
@@ -892,68 +893,52 @@
}
$form->{period} = "$fromdate - $todate";
- }
- else {
+ } else {
$form->{period} =
$locale->date( \%myconfig, $form->current_date( \%myconfig ), 1 );
}
- $options .= $form->{period};
+ push @options, $form->{period};
- @column_index = qw(partnumber description sold revenue received expense);
+ my @column_index = qw(partnumber description sold revenue received expense);
- $href =
+ my $href =
qq|rp.pl?path=$form->{path}&action=continue&accounttype=$form->{accounttype}&login=$form->{login}&sessionid=$form->{sessionid}&fromdate=$form->{fromdate}&todate=$form->{todate}&l_heading=$form->{l_heading}&l_subtotal=$form->{l_subtotal}&department=$department&projectnumber=$projectnumber&project_id=$form->{project_id}&title=$title&nextsub=$form->{nextsub}|;
- $column_header{partnumber} = qq|
- <th class=listheading><a class=listheading href="$href&sort_col=partnumber">|
- . $locale->text('Part Number') . qq|</a></th>|;
- $column_header{description} = qq|
- <th class=listheading><a class=listheading href="$href&sort_col=description">|
- . $locale->text('Description') . qq|</a></th>|;
- $column_header{sold} = qq|
- <th class=listheading><a class=listheading href="$href&sort_col=sold">|
- . $locale->text('Sold') . qq|</a></th>|;
- $column_header{revenue} = qq|
- <th class=listheading><a class=listheading href="$href&sort_col=revenue">|
- . $locale->text('Revenue') . qq|</a></th>|;
- $column_header{received} = qq|
- <th class=listheading><a class=listheading href="$href&sort_col=received">|
- . $locale->text('Received') . qq|</a></th>|;
- $column_header{expense} = qq|
- <th class=listheading><a class=listheading href="$href&sort_col=expense">|
- . $locale->text('Expense') . qq|</a></th>|;
+ my %column_header;
+ $column_header{partnumber} = {
+ text => $locale->text('Part Number'),
+ href => "$href&sort_col=partnumber",
+ };
+ $column_header{description} = {
+ text => $locale->text('Description'),
+ href => "$href&sort_col=description",
+ };
+ $column_header{sold} = {
+ text => $locale->text('Sold'),
+ href => "$href&sort_col=sold",
+ };
+ $column_header{revenue} = {
+ text => $locale->text('Revenue'),
+ href => "$href&sort_col=revenue",
+ };
+ $column_header{received} = {
+ text => $locale->text('Received'),
+ href => "$href&sort_col=received",
+ };
+ $column_header{expense} = {
+ text => $locale->text('Expense'),
+ href => "$href&sort_col=expense",
+ };
- print qq|
-<body>
-
-<table width=100%>
- <tr>
- <th class=listtop>$form->{title}</th>
- </tr>
- <tr height="5"></tr>
- <tr>
- <td>$options</td>
- </tr>
- <tr>
- <td>
- <table width=100%>
- <tr>|;
-
- map { print "$column_header{$_}\n" } @column_index;
-
- print qq|
- </tr>
-|;
-
if ( $form->{sort_col} eq 'qty' || $form->{sort_col} eq 'revenue' ) {
$form->{sort_type} = 'numeric';
}
- $i = 0;
- $cols = "l_transdate=Y&l_name=Y&l_invnumber=Y&summary=1";
- $dates =
+ my $i = 0;
+ my $cols = "l_transdate=Y&l_name=Y&l_invnumber=Y&summary=1";
+ my $dates =
"transdatefrom=$form->{fromdate}&transdateto=$form->{todate}&year=$form->{fromyear}&month=$form->{frommonth}&interval=$form->{interval}";
- $base =
+ my $base =
"path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
$form->{callback} = "rp.pl?action=continue&$base";
@@ -961,9 +946,12 @@
$callback = "callback=$form->{callback}";
# sort the whole thing by account numbers and display
- foreach $ref ( @{ $form->{TB} } ) {
- $description = $form->escape( $ref->{description} );
- $i = $i % 2;
+ my @rows;
+ foreach my $ref ( @{ $form->{TB} } ) {
+ my $description = $form->escape( $ref->{description} );
+ my %column_data;
+ $i = $i % 2;
+ $column_data{i} = $i;
$pnumhref =
"ic.pl?action=edit&id=$ref->{id}&$base&callback=$form->{callback}";
@@ -974,47 +962,52 @@
$ml = ( $ref->{category} =~ /(A|E)/ ) ? -1 : 1;
- $debit = $form->format_amount( \%myconfig, $ref->{debit}, 2, " " );
+ $debit = $form->format_amount( \%myconfig, $ref->{debit}, 2, " " );
$credit =
- $form->format_amount( \%myconfig, $ref->{credit}, 2, " " );
+ $form->format_amount( \%myconfig, $ref->{credit}, 2, " " );
$begbalance =
- $form->format_amount( \%myconfig, $ref->{balance} * $ml, 2,
- " " );
+ $form->format_amount( \%myconfig, $ref->{balance} * $ml, 2, " " );
$endbalance =
$form->format_amount( \%myconfig,
( $ref->{balance} + $ref->{amount} ) * $ml,
- 2, " " );
+ 2, " " );
- $ref->{partnumber} = qq|<a href="$pnumhref">$ref->{partnumber}</a>|;
- $ref->{sold} = qq|<a href="$soldhref">$ref->{sold}</a>|;
- $ref->{received} = qq|<a href="$rechref">$ref->{received}<a/>|;
- map { $column_data{$_} = "<td> </td>" } @column_index;
+ $column_data{partnumber} = {
+ text => $ref->{partnumber},
+ href => $pnumhref,
+ };
+ $column_data{sold} = {
+ text => $ref->{sold},
+ href => $soldhref,
+ };
+ $column_data{received} = {
+ text => $ref->{received},
+ href => $rechref,
+ };
- print qq|
- <tr class=listrow$i>
- |;
- map { print "<td>$ref->{$_}</td>\n" } @column_index;
-
- print qq|
- </tr>
-|;
+ push @rows, \%column_data;
++$i;
}
- print qq|
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td><hr size=3 noshade></td>
- </tr>
-</table>
-
-</body>
-</html>
-|;
-
+ my $template = LedgerSMB::Template->new_UI(
+ user => \%myconfig,
+ locale => $locale,
+ template => 'form-dynatable',
+ );
+ $template->render({
+ form => $form,
+ hiddens => \%hiddens,
+ options => ..hidden..,
+ columns => ..hidden..,
+ heading => \%column_header,
+ rows => ..hidden..,
+ row_alignment => {
+ sold => 'right',
+ revenue => 'right',
+ received => 'right',
+ expense => 'right',
+ },
+ });
}
sub generate_income_statement {
@@ -2080,29 +2073,18 @@
$form->{templates} = "$myconfig{templates}";
# setup variables for the form
- @a = qw(company address businessnumber tel fax);
- for (@a) { $form->{$_} = $myconfig{$_} }
+ my @vars = qw(company address businessnumber tel fax);
+ for (@vars) { $form->{$_} = $myconfig{$_} }
$form->{address} =~ s/\\n/\n/g;
- $form->format_string(@a);
+ @vars = qw(name address1 address2 city state zipcode country contact);
+ push @vars, "$form->{ct}phone", "$form->{ct}fax", "$form->{ct}taxnumber";
+ push @vars, 'email' if !$form->{media} eq 'email';
- $form->{IN} = "$form->{type}.html";
-
- if ( $form->{format} eq 'postscript' ) {
- $form->{IN} =~ s/html$/tex/;
- }
- if ( $form->{format} eq 'pdf' ) {
- $form->{IN} =~ s/html$/tex/;
- }
-
- @a = qw(name address1 address2 city state zipcode country contact);
- push @a, "$form->{ct}phone", "$form->{ct}fax", "$form->{ct}taxnumber";
- push @a, 'email' if !$form->{media} eq 'email';
-
- $i = 0;
+ my $i = 0;
while ( @{ $form->{AG} } ) {
- $ref = shift @{ $form->{AG} };
+ my $ref = shift @{ $form->{AG} };
if ( $ctid != $ref->{ctid} ) {
@@ -2111,8 +2093,7 @@
if ( $form->{"statement_$i"} ) {
- for (@a) { $form->{$_} = $ref->{$_} }
- $form->format_string(@a);
+ for (@vars) { $form->{$_} = $ref->{$_} }
$form->{ $form->{ct} } = $form->{name};
$form->{"$form->{ct}_id"} = $ref->{ctid};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.