From de83a9fccbb6c53a6516ccf82fb49d25984e5a44 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Andr=C3=A9=20Santoni?= Date: Thu, 9 Jul 2009 12:17:11 +0200 Subject: [PATCH] This adds pagination on pending orders in acquisitions --- acqui/parcel.pl | 41 ++++++++++++++++++- .../prog/en/modules/acqui/parcel.tmpl | 16 ++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/acqui/parcel.pl b/acqui/parcel.pl index 685ded33f6..d2296ece20 100755 --- a/acqui/parcel.pl +++ b/acqui/parcel.pl @@ -76,6 +76,11 @@ my $code = $input->param('code'); my @rcv_err = $input->param('error'); my @rcv_err_barcode = $input->param('error_bc'); +my $startfrom=$input->param('startfrom'); +my $resultsperpage = $input->param('resultsperpage'); +$resultsperpage = 20 unless ($resultsperpage); +$startfrom=0 unless ($startfrom); + my ($template, $loggedinuser, $cookie) = get_template_and_user({template_name => "acqui/parcel.tmpl", query => $input, @@ -160,10 +165,43 @@ for (my $i = 0 ; $i < $countpendings ; $i++) { $line{total} = $total; $line{supplierid} = $supplierid; $ordergrandtotal += $line{ecost} * $line{quantity}; - push @loop_orders, \%line; + push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage); } $freight = $totalfreight unless $freight; +my $count = $countpendings; + +if ($count>$resultsperpage){ + my $displaynext=0; + my $displayprev=$startfrom; + if(($count - ($startfrom+$resultsperpage)) > 0 ) { + $displaynext = 1; + } + + my @numbers = (); + for (my $i=1; $i<$count/$resultsperpage+1; $i++) { + my $highlight=0; + ($startfrom/$resultsperpage==($i-1)) && ($highlight=1); + push @numbers, { number => $i, + highlight => $highlight , + startfrom => ($i-1)*$resultsperpage}; + } + + my $from = $startfrom*$resultsperpage+1; + my $to; + if($count < (($startfrom+1)*$resultsperpage)){ + $to = $count; + } else { + $to = (($startfrom+1)*$resultsperpage); + } + $template->param(numbers=>\@numbers, + displaynext=>$displaynext, + displayprev=>$displayprev, + nextstartfrom=>(($startfrom+$resultsperpage<$count)?$startfrom+$resultsperpage:$count), + prevstartfrom=>(($startfrom-$resultsperpage>0)?$startfrom-$resultsperpage:0) + ); +} + #$totalfreight=$freight; $tototal = $tototal + $freight; @@ -192,5 +230,6 @@ $template->param( totalPquantity => $totalPquantity, totalPqtyrcvd => $totalPqtyrcvd, totalPecost => sprintf("%.2f", $totalPecost), + resultsperpage => $resultsperpage, ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tmpl index 97429e348e..5b562e97e6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tmpl @@ -118,6 +118,22 @@ " />

+
+ + + &startfrom=&datereceived=&invoice=&resultsperpage=#resultnumber"><< Previous + + + + + + &startfrom=&datereceived=&invoice=&resultsperpage=#resultnumber"> + + + + &startfrom=&datereceived=&invoice=&resultsperpage=#resultnumber">Next >> + +
-- 2.39.5
or select a pending orders
BASKET