From 547e6b5f1273da8fa7ad04883cd44e061c8bd975 Mon Sep 17 00:00:00 2001 From: einhverfr Date: Fri, 16 Mar 2007 05:07:02 +0000 Subject: Adding completed LedgerSMB::redo_rows git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@915 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB.pm | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/LedgerSMB.pm b/LedgerSMB.pm index 6a11706d..2b02c052 100755 --- a/LedgerSMB.pm +++ b/LedgerSMB.pm @@ -69,8 +69,10 @@ This function redirects to the script and argument set determined by $self->{callback}, and if this is not set, goes to an info screen and prints $msg. -=item redo_rows (fields => \@list, count => $integer); -This function is undergoing serious redesign at the moment. +=item redo_rows (fields => \@list, count => $integer, [index => $string); +This function is undergoing serious redesign at the moment. If index is +defined, that field is used for ordering the rows. If not, runningnumber is +used. =head1 Copyright (C) 2006, The LedgerSMB core team. @@ -569,7 +571,24 @@ sub redo_rows { my %args = @_; my @flds = @{$args{fields}}; my $count = $args{count}; - + my $index = ($args{index}) ? $args{index} : 'runningnumber'; + + my @rows; + my $i; # incriment counter use only + for $i (1 .. $count){ + my $temphash = {_inc => $i}; + for my $fld (@flds){ + $temphash->{$fld} = $self->{"$fld"."_$i"} + } + push @rows, $temphash; + } + $i = 1; + for my $row (sort {$a->{index} <=> $b->{index}} @rows){ + for my $fld (@flds){ + $self->{"$fld"."_$i"} = $row->{$fld}; + } + ++$i; + } } -- cgit v1.2.3