[Koha-patches] [PATCH] All patches to Koha 3 beta to date. All work with branches.

Galen Charlton galen.charlton at liblime.com
Tue Apr 1 19:01:00 CEST 2008


From: Darrell Ulm <darrellulm at smfpl.org>

 Billing.pl     -- new, gives bills that occur in a range, works
 pendingreserves.pl  -- fixed, works now, with branches also
 reserveratios.pl  -- indicates distressed reserves
 itemslost.pl  -- Fix to this to make it more useful and fix bugs
 Itmes.pm -- small change to work for itemslost, should not affect
             anything else
 and all tmpl files.

Signed-off-by: Galen Charlton <galen.charlton at liblime.com>
---
 C4/Items.pm                                        |   13 +-
 circ/billing.pl                                    |  216 ++++++++++++++++
 circ/pendingreserves.pl                            |  264 ++++++++++++--------
 circ/reserveratios.pl                              |  206 +++++++++++++++
 .../prog/en/modules/circ/billing.tmpl              |  175 +++++++++++++
 .../prog/en/modules/circ/circulation-home.tmpl     |    2 +
 .../prog/en/modules/circ/pendingreserves.tmpl      |   71 ++++--
 .../prog/en/modules/circ/reserveratios.tmpl        |  186 ++++++++++++++
 .../prog/en/modules/reports/itemslost.tmpl         |   22 ++-
 reports/itemslost.pl                               |   14 +-
 10 files changed, 1031 insertions(+), 138 deletions(-)
 create mode 100755 circ/billing.pl
 create mode 100755 circ/reserveratios.pl
 create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/circ/billing.tmpl
 create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tmpl

diff --git a/C4/Items.pm b/C4/Items.pm
index a315e94..eccc5ae 100644
--- a/C4/Items.pm
+++ b/C4/Items.pm
@@ -876,14 +876,19 @@ sub GetLostItems {
 
     my $query   = "
         SELECT *
-        FROM   items
-        WHERE  itemlost IS NOT NULL
-          AND  itemlost <> 0
+        FROM   items, biblio, authorised_values
+        WHERE
+        		items.biblionumber = biblio.biblionumber
+        		AND items.itemlost = authorised_values.authorised_value
+        		AND authorised_values.category = 'LOST'
+          	AND itemlost IS NOT NULL
+         	AND itemlost <> 0
+          
     ";
     foreach my $key (keys %$where) {
         $query .= " AND " . $key . " LIKE '%" . $where->{$key} . "%'";
     }
-    $query .= " ORDER BY ".$orderby if defined $orderby;
+    $query .= " ORDER BY ".$orderby." " if defined $orderby;
 
     my $sth = $dbh->prepare($query);
     $sth->execute;
diff --git a/circ/billing.pl b/circ/billing.pl
new file mode 100755
index 0000000..f73962d
--- /dev/null
+++ b/circ/billing.pl
@@ -0,0 +1,216 @@
+#!/usr/bin/perl
+
+
+# Copyright 2000-2002 Katipo Communications
+#
+# This file is part of Koha.
+#
+# Koha 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.
+#
+# Koha 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
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
+use strict;
+use C4::Context;
+use C4::Output;
+use CGI;
+use C4::Auth;
+use C4::Dates qw/format_date format_date_in_iso/;
+
+use vars qw($debug);
+
+BEGIN {
+    $debug = $ENV{DEBUG} || 0;
+}
+
+my $input = new CGI;
+my $order = $input->param('order');
+my $startdate=$input->param('from');
+my $enddate=$input->param('to');
+my $max_bill=$input->param('ratio');
+
+my $theme = $input->param('theme');    # only used if allowthemeoverride is set
+
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {
+        template_name   => "circ/billing.tmpl",
+        query           => $input,
+        type            => "intranet",
+        authnotrequired => 0,
+        flagsrequired   => { circulate => 1 },
+        debug           => 1,
+    }
+);
+
+my $duedate;
+my $borrowernumber;
+my $itemnum;
+my $data1;
+my $data2;
+my $data3;
+my $name;
+my $phone;
+my $email;
+my $biblionumber;
+my $title;
+my $author;
+
+my @datearr    = localtime( time() );
+my 
+$todaysdate =
+    ( 1900 + $datearr[5] ) . '-'
+  . sprintf( "%0.2d", ( $datearr[4] + 1 ) ) . '-'
+  . sprintf( "%0.2d", $datearr[3] );
+
+# Find yesterday for the default shelf pull start and end dates
+#    A defualt of the prior years's holds is a reasonable way to pull holds 
+my @datearr_yesterday    = localtime( time() - 86400*365 );
+my $yesterdaysdate =
+    ( 1900 + $datearr_yesterday[5] ) . '-'
+  . sprintf( "%0.2d", ( $datearr_yesterday[4] + 1 ) ) . '-'
+  . sprintf( "%0.2d", $datearr_yesterday[3] );
+
+#		Predefine the start and end dates if they are not already defined
+$startdate =~ s/^\s+//;
+$startdate =~ s/\s+$//;
+$enddate =~ s/^\s+//;
+$enddate =~ s/\s+$//;
+#		Check if null, should string match, if so set start and end date to yesterday
+if (!defined($startdate) or $startdate eq "") {
+	$startdate = format_date($yesterdaysdate);
+}
+if (!defined($enddate) or $enddate eq "") {
+	$enddate = format_date($todaysdate);
+}
+if (!defined($max_bill) or $max_bill eq "") {
+	$max_bill = C4::Context->preference('noissuescharge');
+	if ($max_bill <= 0) {
+		$max_bill = 20.00;
+	}
+}
+
+my $dbh    = C4::Context->dbh;
+my ($sqlorderby, $sqldatewhere, $presqldatewhere) = ("","","");
+$debug and warn format_date_in_iso($startdate) . "\n" . format_date_in_iso($enddate);
+# the dates below is to check for compliance of the current date range
+#$sqldatewhere .= " AND date >= " . $dbh->quote(format_date_in_iso($startdate))  if ($startdate) ;
+$sqldatewhere .= " AND date <= " . $dbh->quote(format_date_in_iso($enddate))  if ($enddate) ;
+# the date below is to check for compliance of all fees prior
+$presqldatewhere .= " AND date < " . $dbh->quote(format_date_in_iso($startdate))  if ($startdate) ;
+
+if ($order eq "patron") {
+	$sqlorderby = " order by surname, firstname ";
+} elsif ($order eq "fee") {
+    $sqlorderby = " order by l_amountoutstanding DESC ";
+} elsif ($order eq "desc") {
+    $sqlorderby = " order by l_description ";
+} elsif ($order eq "type") {
+    $sqlorderby = " order by l_accounttype ";
+} elsif ($order eq "date") {
+    $sqlorderby = " order by l_date DESC ";
+} elsif ($order eq "total") {
+    $sqlorderby = " order by sum_amount DESC ";
+} else {
+	$sqlorderby = " order by surname, firstname ";
+}
+my $strsth =
+	"SELECT 
+		GROUP_CONCAT(accountlines.accounttype ORDER BY accountlines.date DESC SEPARATOR '<br>') as l_accounttype,
+		GROUP_CONCAT(description ORDER BY accountlines.date DESC SEPARATOR '<br>') as l_description,
+		GROUP_CONCAT(round(amountoutstanding,2) ORDER BY accountlines.date DESC SEPARATOR '<br>') as l_amountoutstanding, 
+		GROUP_CONCAT(accountlines.date ORDER BY accountlines.date DESC SEPARATOR '<br>') as l_date, 
+		GROUP_CONCAT(accountlines.itemnumber ORDER BY accountlines.date DESC SEPARATOR '<br>') as l_itemnumber, 
+		count(*) as cnt, 
+		max(accountlines.date) as maxdate,
+		round(sum(amountoutstanding),2) as sum_amount, 
+		borrowers.borrowernumber as borrowernumber, 
+		borrowers.surname as surname, 
+		borrowers.firstname as firstname, 
+		borrowers.email as email,
+		borrowers.phone as phone,
+		accountlines.itemnumber,
+		description, 
+		accountlines.date as accountdate
+		FROM 
+			borrowers, accountlines
+		WHERE 
+			accountlines.borrowernumber = borrowers.borrowernumber
+		AND accountlines.amountoutstanding <> 0 
+		AND accountlines.borrowernumber 
+			IN (SELECT borrowernumber FROM accountlines 
+				where borrowernumber >= 0
+				$sqldatewhere 
+				GROUP BY accountlines.borrowernumber HAVING sum(amountoutstanding) >= $max_bill ) 
+		AND accountlines.borrowernumber 
+			NOT IN (SELECT borrowernumber FROM accountlines 
+				where borrowernumber >= 0
+				$presqldatewhere 
+				GROUP BY accountlines.borrowernumber HAVING sum(amountoutstanding) >= $max_bill ) 
+";
+
+
+if (C4::Context->preference('IndependantBranches')){
+	$strsth .= " AND borrowers.branchcode=? ";
+}
+$strsth .= " GROUP BY accountlines.borrowernumber HAVING sum(amountoutstanding) >= $max_bill " . $sqlorderby;
+my $sth = $dbh->prepare($strsth);
+
+if (C4::Context->preference('IndependantBranches')){
+	$sth->execute(C4::Context->userenv->{'branch'});
+}
+else {
+	$sth->execute();
+}	
+my @reservedata;
+my $previous;
+my $this;
+while ( my $data = $sth->fetchrow_hashref ) {   
+    my @itemlist;
+    push(
+        @reservedata,
+        {
+				l_accountype			=>		$data->{l_accounttype},
+				l_description			=>		$data->{l_description},
+				l_amountoutstanding	=>		$data->{l_amountoutstanding}, 
+				l_date					=>		$data->{l_date}, 
+				l_itemnumber			=>		$data->{l_itemnumber}, 
+				l_accounttype			=>		$data->{l_accounttype}, 
+				l_title					=>		$data->{l_title},
+				cnt						=>		$data->{cnt},
+				maxdate					=>		$data->{maxdate},
+				sum_amount				=>		$data->{sum_amount}, 
+				borrowernumber			=>		$data->{borrowernumber}, 
+				surname					=>		$data->{surname}, 
+				firstname				=>		$data->{firstname},
+				phone						=>		$data->{phone},
+				email						=>		$data->{email},
+				patronname				=>		$data->{surname} . ", " . $data->{firstname} ,
+				description				=>		$data->{description}, 
+				amountoutstanding		=>		$data->{amountoutstanding},
+				accountdata				=>		$data->{accountdata}
+        }
+    );
+}
+
+
+$sth->finish;
+
+$template->param(
+    todaysdate      => format_date($todaysdate),
+    from            => $startdate,
+    to              => $enddate,
+    ratio           => $max_bill,
+    reserveloop     => \@reservedata,
+    "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1,
+    DHTMLcalendar_dateformat =>  C4::Dates->DHTMLcalendar(),
+);
+
+output_html_with_http_headers $input, $cookie, $template->output;
diff --git a/circ/pendingreserves.pl b/circ/pendingreserves.pl
index 7ce7015..326fb30 100755
--- a/circ/pendingreserves.pl
+++ b/circ/pendingreserves.pl
@@ -18,6 +18,11 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
+# Modification by D.Ulm, actually works (as long as indep. branches not turned on)
+#		Someone let me know what indep. branches is supposed to do and I'll make that part work too
+#
+# 		The reserve pull lists *works* as long as not for indepencdant branches, I can fix!
+
 use strict;
 use C4::Context;
 use C4::Output;
@@ -33,18 +38,14 @@ BEGIN {
 
 my $input = new CGI;
 my $order = $input->param('order');
-my $startdate = $input->param('from');
-my $enddate = $input->param('to');
-my $theme = $input->param('theme');    # only used if allowthemeoverride is set
-my $op = $input->param('op');
-my $biblionumber = $input->param('biblionumber');
-my $borrowernumber = $input->param('borrowernumber');
+my $startdate=$input->param('from');
+my $enddate=$input->param('to');
 
-my $tmpl_name = ($op eq 'slip') ? "circ/hold-transfer-slip.tmpl" : "circ/pendingreserves.tmpl" ;
+my $theme = $input->param('theme');    # only used if allowthemeoverride is set
 
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     {
-        template_name   => $tmpl_name,
+        template_name   => "circ/pendingreserves.tmpl",
         query           => $input,
         type            => "intranet",
         authnotrequired => 0,
@@ -54,6 +55,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
 );
 
 my $duedate;
+my $borrowernumber;
 my $itemnum;
 my $data1;
 my $data2;
@@ -61,70 +63,115 @@ my $data3;
 my $name;
 my $phone;
 my $email;
+my $biblionumber;
 my $title;
 my $author;
-warn $op;
-warn $biblionumber;
-warn $borrowernumber;
+
 my @datearr    = localtime( time() );
 my $todaysdate =
     ( 1900 + $datearr[5] ) . '-'
   . sprintf( "%0.2d", ( $datearr[4] + 1 ) ) . '-'
   . sprintf( "%0.2d", $datearr[3] );
 
+# Find yesterday for the default shelf pull end dates
+#    A defualt of the prior day's holds is a reasonable way to pull holds 
+my @datearr_yesterday    = localtime( time() - 86400 );
+my $yesterdaysdate =
+    ( 1900 + $datearr_yesterday[5] ) . '-'
+  . sprintf( "%0.2d", ( $datearr_yesterday[4] + 1 ) ) . '-'
+  . sprintf( "%0.2d", $datearr_yesterday[3] );
+# Find 10 years ago for the default shelf pull start and end dates
+#    A defualt of the prior day's holds is a reasonable way to pull holds 
+my @datearr_past    = localtime( time() - 86400*365*10 );
+my $pastdate =
+    ( 1900 + $datearr_past[5] ) . '-'
+  . sprintf( "%0.2d", ( $datearr_past[4] + 1 ) ) . '-'
+  . sprintf( "%0.2d", $datearr_past[3] );
+
+#		Predefine the start and end dates if they are not already defined
+$startdate =~ s/^\s+//;
+$startdate =~ s/\s+$//;
+$enddate =~ s/^\s+//;
+$enddate =~ s/\s+$//;
+#		Check if null, should string match, if so set start and end date to yesterday
+if (!defined($startdate) or $startdate eq "") {
+	$startdate = format_date($pastdate);
+}
+if (!defined($enddate) or $enddate eq "") {
+	$enddate = format_date($yesterdaysdate);
+}
+
+
 my $dbh    = C4::Context->dbh;
-my ($sqlorderby, $sqldatewhere, $sqlwhowhere) = ("","","");
+my ($sqlorderby, $sqldatewhere) = ("","");
 $debug and warn format_date_in_iso($startdate) . "\n" . format_date_in_iso($enddate);
-if ($op eq 'slip') {        
-	$sqlwhowhere .= " && reserves.borrowernumber = " . $dbh->quote($borrowernumber) ;
-    $sqlwhowhere .= " && reserves.biblionumber = " . $dbh->quote($biblionumber) ;
-} else {
-	$sqldatewhere .= " AND reservedate >= " . $dbh->quote(format_date_in_iso($startdate))  if ($startdate) ;
-	$sqldatewhere .= " AND reservedate <= " . $dbh->quote(format_date_in_iso($enddate))  if ($enddate) ;
-}
-if ($order eq "borrower") {
-	$sqlorderby = " order by  borrower, reservedate";
-} elsif ($order eq "biblio") {
-	$sqlorderby = " order by biblio.title, priority,reservedate";
-} elsif ($order eq "priority") {
-    $sqlorderby = "order by priority DESC";
+$sqldatewhere .= " AND reservedate >= " . $dbh->quote(format_date_in_iso($startdate))  if ($startdate) ;
+$sqldatewhere .= " AND reservedate <= " . $dbh->quote(format_date_in_iso($enddate))  if ($enddate) ;
+
+
+if ($order eq "biblio") {
+	$sqlorderby = " order by biblio.title ";
+} elsif ($order eq "itype") {
+	$sqlorderby = " order by l_itype, location, l_itemcallnumber ";
+} elsif ($order eq "location") {
+	$sqlorderby = " order by location, l_itemcallnumber, holdingbranch ";
+} elsif ($order eq "date") {
+    $sqlorderby = " order by l_reservedate, location, l_itemcallnumber ";
+} elsif ($order eq "library") {
+    $sqlorderby = " order by holdingbranch, l_itemcallnumber, location ";
+} elsif ($order eq "call") {
+    $sqlorderby = " order by l_itemcallnumber, holdingbranch, location ";    
 } else {
-	$sqlorderby = " order by reservedate, borrower";
+	$sqlorderby = " order by biblio.title ";
 }
 my $strsth =
-"SELECT reservedate,
+"SELECT min(reservedate) as l_reservedate,
         reserves.borrowernumber as borrowernumber,
-        concat(firstname,' ',surname) as borrower,
-        borrowers.phone,
-        borrowers.email,
+        GROUP_CONCAT(DISTINCT items.holdingbranch 
+        		ORDER BY items.itemnumber SEPARATOR '<br>') l_holdingbranch,
         reserves.biblionumber,
-        reserves.branchcode as branch,
-        items.holdingbranch,
+        reserves.branchcode,
+        GROUP_CONCAT(DISTINCT reserves.branchcode 
+        		ORDER BY items.itemnumber SEPARATOR ', ') l_branch,
+        items.holdingbranch as branch,
         items.itemcallnumber,
+        GROUP_CONCAT(DISTINCT items.itype 
+        		ORDER BY items.itemnumber SEPARATOR '<br>') l_itype,
+        GROUP_CONCAT(DISTINCT items.location 
+        		ORDER BY items.itemnumber SEPARATOR '<br>') l_location,
+        GROUP_CONCAT(DISTINCT items.itemcallnumber 
+        		ORDER BY items.itemnumber SEPARATOR '<br>') l_itemcallnumber,
         items.itemnumber,
         notes,
         notificationdate,
         reminderdate,
-        priority,
+        max(priority) as priority,
         reserves.found,
         biblio.title,
-        biblio.author
+        biblio.author,
+        count(DISTINCT items.itemnumber) as icount,
+        count(DISTINCT reserves.borrowernumber) as rcount
  FROM  reserves
- LEFT JOIN items ON items.biblionumber=reserves.biblionumber 
- LEFT JOIN borrowers ON reserves.borrowernumber=borrowers.borrowernumber
- LEFT JOIN biblio ON reserves.biblionumber=biblio.biblionumber
- WHERE reserves.found is NULL 
- $sqlwhowhere
+	LEFT JOIN items ON items.biblionumber=reserves.biblionumber 
+	LEFT JOIN biblio ON reserves.biblionumber=biblio.biblionumber
+	LEFT JOIN branchtransfers ON items.itemnumber=branchtransfers.itemnumber
+ WHERE
+reserves.found IS NULL
  $sqldatewhere
- AND items.itemnumber NOT IN (SELECT itemnumber FROM issues)
- AND reserves.itemnumber is NULL";
+AND items.itemnumber NOT IN (SELECT itemnumber FROM branchtransfers where datearrived IS NULL)
+AND items.itemnumber NOT IN (SELECT itemnumber FROM issues)
+AND reserves.priority <> 0 
+AND reserves.itemnumber is NULL
+AND notforloan = 0 AND damaged = 0 AND itemlost = 0 AND wthdrawn = 0
+";
+# GROUP BY reserves.biblionumber allows only items that are not checked out, else multiples occur when 
+#    multiple patrons have a hold on an item
+
 
 if (C4::Context->preference('IndependantBranches')){
 	$strsth .= " AND items.holdingbranch=? ";
 }
-$strsth .= $sqlorderby;
-warn $strsth;
-
+$strsth .= " GROUP BY reserves.biblionumber " . $sqlorderby;
 my $sth = $dbh->prepare($strsth);
 
 if (C4::Context->preference('IndependantBranches')){
@@ -142,76 +189,89 @@ while ( my $data = $sth->fetchrow_hashref ) {
     push(
         @reservedata,
         {
-            reservedate      => $previous eq $this?"":format_date( $data->{reservedate} ),
-            priority         => $previous eq $this?"":$data->{priority},
-            name             => $previous eq $this?"":$data->{borrower},
-            title            => $previous eq $this?"":$data->{title},
-            author           => $previous eq $this?"":$data->{author},
-            borrowernumber   => $previous eq $this?"":$data->{borrowernumber},
-            itemnum          => $previous eq $this?"":$data->{itemnumber},
-            phone            => $previous eq $this?"":$data->{phone},
-            email            => $previous eq $this?"":$data->{email},
-            biblionumber     => $previous eq $this?"":$data->{biblionumber},
+            reservedate      => format_date( $data->{l_reservedate} ),
+            priority         => $data->{priority},
+            name             => $data->{l_patron},
+            title            => $data->{title},
+            author           => $data->{author},
+            borrowernumber   => $data->{borrowernumber},
+            itemnum          => $data->{itemnumber},
+            phone            => $data->{phone},
+            email            => $data->{email},
+            biblionumber     => $data->{biblionumber},
             statusw          => ( $data->{found} eq "W" ),
             statusf          => ( $data->{found} eq "F" ),
-            holdingbranch    => $data->{holdingbranch},
-            branch           => $previous eq $this?"":$data->{branch},
-            itemcallnumber   => $data->{itemcallnumber},
-            notes            => $previous eq $this?"":$data->{notes},
-            notificationdate => $previous eq $this?"":$data->{notificationdate},
-            reminderdate     => $previous eq $this?"":$data->{reminderdate}
+            holdingbranch    => $data->{l_holdingbranch},
+            branch           => $data->{l_branch},
+            itemcallnumber   => $data->{l_itemcallnumber},
+            notes            => $data->{notes},
+            notificationdate => $data->{notificationdate},
+            reminderdate     => $data->{reminderdate},
+            count				  => $data->{icount},
+            rcount			  => $data->{rcount},
+            pullcount		  => $data->{icount} <= $data->{rcount} ? $data->{icount} : $data->{rcount},
+            itype				  => $data->{l_itype},
+            location			  => $data->{l_location}
         }
     );
     $previous=$this;
 }
 
 $sth->finish;
-$strsth=~ s/AND reserves.itemnumber is NULL/AND reserves.itemnumber is NOT NULL/;
-$strsth=~ s/LEFT JOIN items ON items.biblionumber=reserves.biblionumber/LEFT JOIN items ON items.biblionumber=reserves.itemnumber/;
-$sth = $dbh->prepare($strsth);                                                                                                                          
-if (C4::Context->preference('IndependantBranches')){
-	$sth->execute(C4::Context->userenv->{'branch'});
-}     
-else {
-	$sth->execute(); 
-}              
-while ( my $data = $sth->fetchrow_hashref ) {
-    $this=$data->{biblionumber}.":".$data->{borrowernumber};
-    my @itemlist;
-    push(
-        @reservedata,
-        {
-            reservedate      => $previous eq $this?"":format_date( $data->{reservedate} ),
-            priority         => $previous eq $this?"":$data->{priority},
-            name             => $previous eq $this?"":$data->{borrower},
-            title            => $previous eq $this?"":$data->{title},
-            author           => $previous eq $this?"":$data->{author},
-            borrowernumber   => $previous eq $this?"":$data->{borrowernumber},
-            itemnum          => $previous eq $this?"":$data->{itemnumber},
-            phone            => $previous eq $this?"":$data->{phone},
-            email            => $previous eq $this?"":$data->{email},
-            biblionumber     => $previous eq $this?"":$data->{biblionumber},
-            statusw          => ( $data->{found} eq "W" ),
-            statusf          => ( $data->{found} eq "F" ),
-            holdingbranch    => $data->{holdingbranch},
-            branch           => $previous eq $this?"":$data->{branch},
-            itemcallnumber   => $data->{itemcallnumber},
-            notes            => $previous eq $this?"":$data->{notes},
-            notificationdate => $previous eq $this?"":$data->{notificationdate},
-            reminderdate     => $previous eq $this?"":$data->{reminderdate},
-			thisitemonly     => 1,
-        }
-    );
-    $previous=$this;
-}
 
-$sth->finish;
+# *** I doubt any of this is needed now with the above fixes *** -d.u.
+
+#$strsth=~ s/AND reserves.itemnumber is NULL/AND reserves.itemnumber is NOT NULL/;
+#$strsth=~ s/LEFT JOIN items ON items.biblionumber=reserves.biblionumber/LEFT JOIN items ON items.biblionumber=reserves.itemnumber/;
+#$sth = $dbh->prepare($strsth);
+#if (C4::Context->preference('IndependantBranches')){
+#       $sth->execute(C4::Context->userenv->{'branch'});
+#}
+#else {
+#       $sth->execute();
+#}
+#while ( my $data = $sth->fetchrow_hashref ) {
+#    $this=$data->{biblionumber}.":".$data->{borrowernumber};
+#    my @itemlist;
+#    push(
+#        @reservedata,
+#        {
+#            reservedate      => format_date( $data->{l_reservedate} ),
+#            priority         => $data->{priority},
+#            name             => $data->{l_patron},
+#            title            => $data->{title},
+#            author           => $data->{author},
+#            borrowernumber   => $data->{borrowernumber},
+#            itemnum          => $data->{itemnumber},
+#            phone            => $data->{phone},
+#            email            => $data->{email},
+#            biblionumber     => $data->{biblionumber},
+#            statusw          => ( $data->{found} eq "W" ),
+#            statusf          => ( $data->{found} eq "F" ),
+#            holdingbranch    => $data->{l_holdingbranch},
+#            branch           => $data->{l_branch},
+#            itemcallnumber   => $data->{l_itemcallnumber},
+#            notes            => $data->{notes},
+#            notificationdate => $data->{notificationdate},
+#            reminderdate     => $data->{reminderdate},
+#            count				  => $data->{icount},
+#            rcount			  => $data->{rcount},
+#            pullcount		  => $data->{icount} <= $data->{rcount} ? $data->{icount} : $data->{rcount},
+#            itype				  => $data->{l_itype},
+#            location			  => $data->{l_location},
+#            thisitemonly     => 1,
+# 
+#        }
+#    );
+#    $previous=$this;
+#}
+#$sth->finish;
 
 $template->param(
-    todaysdate      => format_date($todaysdate),
+    todaysdate      	=> format_date($todaysdate),
     from             => $startdate,
-    to              => $enddate,
-    reserveloop     => \@reservedata,
+    to              	=> $enddate,
+    reserveloop     	=> \@reservedata,
     "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1,
     DHTMLcalendar_dateformat =>  C4::Dates->DHTMLcalendar(),
 );
diff --git a/circ/reserveratios.pl b/circ/reserveratios.pl
new file mode 100755
index 0000000..2ec48eb
--- /dev/null
+++ b/circ/reserveratios.pl
@@ -0,0 +1,206 @@
+#!/usr/bin/perl
+
+
+# Copyright 2000-2002 Katipo Communications
+#
+# This file is part of Koha.
+#
+# Koha 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.
+#
+# Koha 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
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
+use strict;
+use C4::Context;
+use C4::Output;
+use CGI;
+use C4::Auth;
+use C4::Dates qw/format_date format_date_in_iso/;
+
+use vars qw($debug);
+
+BEGIN {
+    $debug = $ENV{DEBUG} || 0;
+}
+
+my $input = new CGI;
+my $order = $input->param('order');
+my $startdate=$input->param('from');
+my $enddate=$input->param('to');
+my $ratio=$input->param('ratio');
+
+my $theme = $input->param('theme');    # only used if allowthemeoverride is set
+
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {
+        template_name   => "circ/reserveratios.tmpl",
+        query           => $input,
+        type            => "intranet",
+        authnotrequired => 0,
+        flagsrequired   => { circulate => 1 },
+        debug           => 1,
+    }
+);
+
+my $duedate;
+my $borrowernumber;
+my $itemnum;
+my $data1;
+my $data2;
+my $data3;
+my $name;
+my $phone;
+my $email;
+my $biblionumber;
+my $title;
+my $author;
+
+my @datearr    = localtime( time() );
+my 
+$todaysdate =
+    ( 1900 + $datearr[5] ) . '-'
+  . sprintf( "%0.2d", ( $datearr[4] + 1 ) ) . '-'
+  . sprintf( "%0.2d", $datearr[3] );
+
+# Find yesterday for the default shelf pull start and end dates
+#    A defualt of the prior years's holds is a reasonable way to pull holds 
+my @datearr_yesterday    = localtime( time() - 86400*365 );
+my $yesterdaysdate =
+    ( 1900 + $datearr_yesterday[5] ) . '-'
+  . sprintf( "%0.2d", ( $datearr_yesterday[4] + 1 ) ) . '-'
+  . sprintf( "%0.2d", $datearr_yesterday[3] );
+
+#		Predefine the start and end dates if they are not already defined
+$startdate =~ s/^\s+//;
+$startdate =~ s/\s+$//;
+$enddate =~ s/^\s+//;
+$enddate =~ s/\s+$//;
+#		Check if null, should string match, if so set start and end date to yesterday
+if (!defined($startdate) or $startdate eq "") {
+	$startdate = format_date($yesterdaysdate);
+}
+if (!defined($enddate) or $enddate eq "") {
+	$enddate = format_date($todaysdate);
+}
+if (!defined($ratio)  or $ratio eq "") {
+	$ratio = 3;
+}
+
+my $dbh    = C4::Context->dbh;
+my ($sqlorderby, $sqldatewhere) = ("","");
+$debug and warn format_date_in_iso($startdate) . "\n" . format_date_in_iso($enddate);
+$sqldatewhere .= " AND reservedate >= " . $dbh->quote(format_date_in_iso($startdate))  if ($startdate) ;
+$sqldatewhere .= " AND reservedate <= " . $dbh->quote(format_date_in_iso($enddate))  if ($enddate) ;
+
+if ($order eq "biblio") {
+	$sqlorderby = " order by biblio.title, holdingbranch, listcall, l_location ";
+} elsif ($order eq "callnumber") {
+    $sqlorderby = " order by listcall, holdingbranch, l_location ";
+} elsif ($order eq "itemcount") {
+    $sqlorderby = " order by itemcount, reservecount ";
+} elsif ($order eq "itype") {
+    $sqlorderby = " order by l_itype, holdingbranch, listcall ";
+} elsif ($order eq "location") {
+    $sqlorderby = " order by l_location, holdingbranch, listcall ";
+} elsif ($order eq "reservecount") {
+    $sqlorderby = " order by reservecount DESC ";
+} elsif ($order eq "branch") {
+    $sqlorderby = " order by holdingbranch, l_location, listcall ";
+} else {
+	$sqlorderby = " order by reservecount DESC ";
+}
+my $strsth =
+"SELECT reservedate,
+        reserves.borrowernumber as borrowernumber,
+        reserves.biblionumber,
+        reserves.branchcode as branch,
+        items.holdingbranch,
+        items.itemcallnumber,
+        items.itemnumber,
+        GROUP_CONCAT(DISTINCT items.itemcallnumber 
+        		ORDER BY items.itemnumber SEPARATOR '<br>') as listcall,
+        GROUP_CONCAT(DISTINCT holdingbranch 
+        		ORDER BY items.itemnumber SEPARATOR '<br>') as listbranch,
+        GROUP_CONCAT(DISTINCT items.location 
+        		ORDER BY items.itemnumber SEPARATOR '<br>') as l_location,
+        GROUP_CONCAT(DISTINCT items.itype 
+        		ORDER BY items.itemnumber SEPARATOR '<br>') as l_itype,
+        notes,
+        reserves.found,
+        biblio.title,
+        biblio.author,
+        count(DISTINCT reserves.borrowernumber) as reservecount, 
+        count(DISTINCT items.itemnumber) as itemcount 
+ FROM  reserves
+ LEFT JOIN items ON items.biblionumber=reserves.biblionumber 
+ LEFT JOIN biblio ON reserves.biblionumber=biblio.biblionumber
+ WHERE 
+notforloan = 0 AND damaged = 0 AND itemlost = 0 AND wthdrawn = 0
+ $sqldatewhere
+";
+
+
+if (C4::Context->preference('IndependantBranches')){
+	$strsth .= " AND items.holdingbranch=? ";
+}
+$strsth .= " GROUP BY reserves.biblionumber " . $sqlorderby;
+my $sth = $dbh->prepare($strsth);
+
+if (C4::Context->preference('IndependantBranches')){
+	$sth->execute(C4::Context->userenv->{'branch'});
+}
+else {
+	$sth->execute();
+}	
+my @reservedata;
+while ( my $data = $sth->fetchrow_hashref ) {
+    my @itemlist;
+    my $ratiocalc =  int(10 * $data->{reservecount} / $data->{itemcount} / $ratio )/10;
+    push(
+        @reservedata,
+        {
+            reservedate      => format_date( $data->{reservedate} ),
+            priority         => $data->{priority},
+            name             => $data->{borrower},
+            title            => $data->{title},
+            author           => $data->{author},
+            notes				  => $data->{notes},
+            itemnum          => $data->{itemnumber},
+            biblionumber     => $data->{biblionumber},
+            holdingbranch    => $data->{holdingbranch},
+            listbranch		  => $data->{listbranch},
+            branch           => $data->{branch},
+            itemcallnumber   => $data->{itemcallnumber},
+            location			  => $data->{l_location},
+            itype			     => $data->{l_itype},
+            reservecount     => $data->{reservecount},
+            itemcount    	  => $data->{itemcount},
+            ratiocalc		  => $ratiocalc,
+            ratio_ge_one	  => $ratiocalc ge 1.0 ? 1 : "",
+            listcall   		  => $data->{listcall}    
+        }
+    );
+}
+
+
+$sth->finish;
+
+$template->param(
+    todaysdate      => format_date($todaysdate),
+    from            => $startdate,
+    to              => $enddate,
+    ratio           => $ratio,
+    reserveloop     => \@reservedata,
+    "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1,
+    DHTMLcalendar_dateformat =>  C4::Dates->DHTMLcalendar(),
+);
+
+output_html_with_http_headers $input, $cookie, $template->output;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/billing.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/billing.tmpl
new file mode 100644
index 0000000..26463ac
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/billing.tmpl
@@ -0,0 +1,175 @@
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
+<title>Koha &rsaquo; Circulation &rsaquo; Billing</title>
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+<!-- Additions to enable Calendar system -->
+<link rel="stylesheet" type="text/css" href="<!-- TMPL_VAR name="themelang" -->/lib/calendar/calendar-system.css" />
+<!-- End of additions --><!-- Additions to enable Calendar system -->
+<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/calendar/calendar.js"></script>
+<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/calendar/calendar-en.js"></script>
+<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/calendar/calendar-setup.js"></script>
+<!-- End of additions -->
+</head>
+<body>
+<!-- TMPL_INCLUDE NAME="header.inc" -->
+<!-- TMPL_INCLUDE NAME="circ-search.inc" -->
+
+
+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a> &rsaquo; Billing</div>
+
+<div id="doc3" class="yui-t2">
+   
+   <div id="bd">
+	<div id="yui-main">
+	<div class="yui-b">
+
+<h1>Billing on 
+   <!-- TMPL_VAR NAME="todaysdate" --> <br>From <!-- TMPL_VAR NAME="from" -->
+	to <!-- TMPL_VAR NAME="to" --></h1>
+<div id="filters">
+<br />
+
+<form method="post" >
+<p>
+<label for "ratio">
+    Currency Cutoff:
+</label>
+<input type="text" size="5" id="ratio" name="ratio" value="<!-- TMPL_VAR NAME="ratio" -->" />
+<label for "from">
+    Start date:
+</label>
+<input type="text" size="10" id="from" name="from" value="<!-- TMPL_VAR NAME="from" -->" />
+<img src="<!-- TMPL_VAR Name="themelang" -->/lib/calendar/cal.gif"  border="0" id="openCalendarFrom" style="cursor: pointer;" alt="" />
+<script language="JavaScript" type="text/javascript">
+function validate1(date) {
+    var day = date.getDate();
+    var month = date.getMonth() + 1;
+    var year = date.getFullYear();
+    var weekDay = date.getDay();
+    var dayMonth = month + '-' + day;
+    var dateString = year + '-' + month + '-' + day;
+    var dateTo = document.getElementById('to').value.split("-");
+    var limitDate = new Date(dateTo[0], (dateTo[1] - 1), dateTo[2]);
+    if (date > limitDate) {
+            return true;
+    } else {
+            return false;
+    }
+}
+Calendar.setup(
+        {
+        inputField : "from",
+        ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
+        button : "openCalendarFrom",
+        disableFunc : validate1,
+        dateStatusFunc : validate1
+        }
+);
+</script>
+<label for "to" >
+    End date:
+</label>
+<input size="10" id="to" name="to" value="<!-- TMPL_VAR NAME="to" -->" type="text" />
+<img src="<!-- TMPL_VAR Name="themelang" -->/lib/calendar/cal.gif" alt="" id="openCalendarTo" style="cursor: pointer;" valign="top" border="0" />
+<script type="text/javascript">
+        function validate2(date) {
+            var day = date.getDate();
+            var month = date.getMonth() + 1;
+            var year = date.getFullYear();
+            var weekDay = date.getDay();
+            var dayMonth = month + '-' + day;
+            var dateString = year + '-' + month + '-' + day;
+            var dateFrom = document.getElementById('from').value.split("-");
+            var limitDate = new Date(dateFrom[0], (dateFrom[1] - 1), dateFrom[2]);
+            if (limitDate > date) {
+                    return true;
+            } else {
+                    return false;
+            }
+        }
+
+        Calendar.setup(
+                {
+                    inputField : "to",
+                    ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
+                    button : "openCalendarTo",
+                    disableFunc : validate2,
+                    dateStatusFunc : validate2
+                }
+        );
+</script>
+(inclusive)
+
+<input type="submit" value="Go" class="submit">
+</p>
+</form>
+<p>The following patrons have bills.</p>
+</div>
+
+
+<div class="searchresults">
+    <!-- TMPL_IF NAME="reserveloop" -->
+    <table>
+    <tr>
+        <th >Patron
+        <a href="/cgi-bin/koha/circ/billing.pl?order=patron&from=<!-- TMPL_VAR NAME="from" -->&to=<!-- TMPL_VAR NAME="to" -->">Sort</a>
+        </th>
+        <th >Fee Item
+        <a href="/cgi-bin/koha/circ/billing.pl?order=fee&from=<!-- TMPL_VAR NAME="from" -->&to=<!-- TMPL_VAR NAME="to" -->">Sort</a>
+        </th>
+        <th>Description
+        <a href="/cgi-bin/koha/circ/billing.pl?order=desc&from=<!-- TMPL_VAR NAME="from" -->&to=<!-- TMPL_VAR NAME="to" -->">Sort</a>
+        </th>
+        <th>Type
+        <a href="/cgi-bin/koha/circ/billing.pl?order=type&from=<!-- TMPL_VAR NAME="from" -->&to=<!-- TMPL_VAR NAME="to" -->">Sort</a>
+        </th>
+        <th >Date
+        <a href="/cgi-bin/koha/circ/billing.pl?order=date&from=<!-- TMPL_VAR NAME="from" -->&to=<!-- TMPL_VAR NAME="to" -->">Sort</a>
+        </th>
+        <th>Total Amount
+        <a href="/cgi-bin/koha/circ/billing.pl?order=total&from=<!-- TMPL_VAR NAME="from" -->&to=<!-- TMPL_VAR NAME="to" -->">Sort</a>
+        </th>
+    </tr>
+    
+                    <!-- TMPL_IF name="BiblioDefaultViewmarc" -->
+                    <!-- /TMPL_IF -->
+                    <!-- TMPL_IF name="BiblioDefaultViewisbd" -->
+                    <!-- /TMPL_IF -->    
+    
+    <!-- TMPL_LOOP NAME="reserveloop" -->
+        <tr>
+            <!-- TMPL_IF name="surname" -->
+            	 <td>
+					 <p><a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=<!--TMPL_VAR Name="borrowernumber"-->"><!-- TMPL_VAR NAME="patronname" --></a><br /><!-- TMPL_VAR NAME="phone" --><br />
+                <!-- TMPL_IF NAME="email" --><a href="mailto:<!-- TMPL_VAR NAME="email" -->?subject=Account: <!-- TMPL_VAR NAME="title" -->">
+    				 <!-- TMPL_VAR NAME="email" --></a><!--/TMPL_IF-->
+                </p>
+            	 </td>
+                <td align="right">
+                    <p><!-- TMPL_VAR NAME="l_amountoutstanding" --></p>
+                </td>
+                <td>
+                    <p><!-- TMPL_VAR NAME="l_description" --></p>
+                </td>
+                <td>
+                    <p><!-- TMPL_VAR NAME="l_accounttype" --></p>
+                </td>
+                <td>
+                    <p><!-- TMPL_VAR NAME="l_date" --></p>
+                </td>                
+                <td align="right">
+                    <p><!-- TMPL_VAR NAME="sum_amount" --></p>
+                </td>
+        </tr>
+    <!-- /TMPL_LOOP -->
+    </table>
+    <!-- TMPL_ELSE -->
+        <b>No items found.</b>
+    <!-- /TMPL_IF -->
+</div>
+</div>
+</div>
+<div class="yui-b">
+<!-- TMPL_INCLUDE NAME="circ-menu.inc" -->
+</div>
+</div>
+<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tmpl
index bd8b310..229f4cd 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tmpl
@@ -35,6 +35,8 @@
 	<li>    <a href="/cgi-bin/koha/circ/overdue.pl">Overdues</a></li>
 	<li>    <a href="/cgi-bin/koha/circ/branchoverdues.pl">Fines</a></li>
 	<li>    <a href="/cgi-bin/koha/circ/stats.pl?time=yesterday">Daily reconciliation</a></li>
+	<li>    <a href="/cgi-bin/koha/circ/reserveratios.pl">Reserve Ratios</a></li>
+	<li>    <a href="/cgi-bin/koha/circ/billing.pl">Billing</a></li>
 </ul>
 	
 	</div>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tmpl
index 33b19d5..5c32764 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tmpl
@@ -22,12 +22,14 @@
 	<div id="yui-main">
 	<div class="yui-b">
 
-
-<h1>Pending holds as of <!-- TMPL_VAR NAME="todaysdate" --></h1>
+<h1>Reserve Pull List</h1>
+<h1>Pending holds on <!-- TMPL_VAR NAME="todaysdate" --> (from <!-- TMPL_VAR NAME="from" -->
+	to <!-- TMPL_VAR NAME="to" -->)</h1>
 <div id="filters">
 <br />
 <form method="post" >
 <p>
+
 <label for "from">
     Start date:
 </label>
@@ -91,7 +93,8 @@ Calendar.setup(
                 }
         );
 </script>
-(inclusive)
+<br>
+<i>(Inclusive, default is (10yr/ago to yesterday), set"to" to today as needed. )</i>
 <input type="submit" value="Go" class="submit">
 </p>
 </form>
@@ -103,39 +106,46 @@ Calendar.setup(
     <!-- TMPL_IF NAME="reserveloop" -->
     <table>
     <tr>
-        <th >
-            Priority
-            <a href="/cgi-bin/koha/circ/pendingreserves.pl?order=priority&from=<!-- TMPL_VAR NAME="from" -->&to=<!-- TMPL_VAR NAME="to" -->">Sort</a>
-        </th>
-        <th >Hold Date
-            <a href="/cgi-bin/koha/circ/pendingreserves.pl?order=date&from=<!-- TMPL_VAR NAME="from" -->&to=<!-- TMPL_VAR NAME="to" -->">Sort</a>
+        <th>
+				Pull This Many Items
+        </th>        
+        <th>
+				Items Available
         </th>
-        <th >Patron
-        <a href="/cgi-bin/koha/circ/pendingreserves.pl?order=borrower&from=<!-- TMPL_VAR NAME="from" -->&to=<!-- TMPL_VAR NAME="to" -->">Sort</a>
+        <th>
+				Patrons with Reserves
         </th>
         <th >Title
         <a href="/cgi-bin/koha/circ/pendingreserves.pl?order=biblio&from=<!-- TMPL_VAR NAME="from" -->&to=<!-- TMPL_VAR NAME="to" -->">Sort</a>
         </th>
         <th>
-            Library
+            Libraries
+				<a href="/cgi-bin/koha/circ/pendingreserves.pl?order=library&from=<!-- TMPL_VAR NAME="from" -->&to=<!-- TMPL_VAR NAME="to" -->">Sort</a>
+        </th>
+        <th>
+            Available Call Numbers
+				<a href="/cgi-bin/koha/circ/pendingreserves.pl?order=call&from=<!-- TMPL_VAR NAME="from" -->&to=<!-- TMPL_VAR NAME="to" -->">Sort</a>
+        </th>
+        <th>
+            Available Itypes
+				<a href="/cgi-bin/koha/circ/pendingreserves.pl?order=itype&from=<!-- TMPL_VAR NAME="from" -->&to=<!-- TMPL_VAR NAME="to" -->">Sort</a>
         </th>
+        <th>
+            Available Locations
+				<a href="/cgi-bin/koha/circ/pendingreserves.pl?order=location&from=<!-- TMPL_VAR NAME="from" -->&to=<!-- TMPL_VAR NAME="to" -->">Sort</a>
+        </th>
+        <th >Earliest Hold Date
+            <a href="/cgi-bin/koha/circ/pendingreserves.pl?order=date&from=<!-- TMPL_VAR NAME="from" -->&to=<!-- TMPL_VAR NAME="to" -->">Sort</a>
+        </th>
+
     </tr>
     
     <!-- TMPL_LOOP NAME="reserveloop" -->
         <tr>
             <!-- TMPL_IF name="borrowernumber" -->
-                <td><p><!-- TMPL_VAR NAME="priority" --></p></td>
-                <td width="15%">
-                    <p><!-- TMPL_VAR NAME="reservedate" --></p>
-                    <p>in <!-- TMPL_VAR NAME="branch" --></p>
-                    <!-- TMPL_IF NAME="statusw" --><p>Waiting</p><!-- /TMPL_IF --><!-- TMPL_IF NAME="statusf" --><p>Fullfilled</p><!-- /TMPL_IF -->
-                </td>
-                <td>
-                    <p><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!--TMPL_VAR Name="borrowernumber"-->"><!-- TMPL_VAR NAME="name" --></a><br /><!-- TMPL_VAR NAME="phone" --><br />
-                <!-- TMPL_IF NAME="email" --><a href="mailto:<!-- TMPL_VAR NAME="email" -->?subject=Reservation: <!-- TMPL_VAR NAME="title" -->">
-    <!-- TMPL_VAR NAME="email" --></a><!--/TMPL_IF-->
-                    </p>
-                </td>
+                <td><p><center><b><!-- TMPL_VAR NAME="pullcount" --></b></center></p></td>
+                <td><!-- TMPL_VAR NAME="count" --></td>  
+                <td><!-- TMPL_VAR NAME="rcount" --></td> 
                 <td>
                     <p>
                     <!-- TMPL_IF name="BiblioDefaultViewmarc" -->
@@ -157,13 +167,20 @@ Calendar.setup(
                     <p><!-- TMPL_VAR NAME="notes" --></p>
                 </td>
             <!-- TMPL_ELSE -->
-                <td colspan="2">
+                <td colspan="3">
                     &nbsp;
                 </td>
                 <td>"</td>
-                <td>"</td>
             <!-- /TMPL_IF -->
-            <td><p><!-- TMPL_VAR NAME="holdingbranch" --> <!-- TMPL_VAR NAME="itemcallnumber" --></p></td>
+            <td><p><!-- TMPL_VAR NAME="holdingbranch" --></p></td>
+            <td><p><!-- TMPL_VAR NAME="itemcallnumber" --></p></td>
+				<td><p><!-- TMPL_VAR NAME="itype" --></p></td> 
+				<td><p><!-- TMPL_VAR NAME="location" --></p></td>
+            <td width="15%">
+                <p><!-- TMPL_VAR NAME="reservedate" --></p>
+                <p>in <!-- TMPL_VAR NAME="branch" --></p>
+                <!-- TMPL_IF NAME="statusw" --><p>Waiting</p><!-- /TMPL_IF --><!-- TMPL_IF NAME="statusf" --><p>Fullfilled</p><!-- /TMPL_IF -->
+            </td>
         </tr>
     <!-- /TMPL_LOOP -->
     </table>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tmpl
new file mode 100644
index 0000000..7791da1
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tmpl
@@ -0,0 +1,186 @@
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
+<title>Koha &rsaquo; Circulation &rsaquo; Reserve Ratios</title>
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+<!-- Additions to enable Calendar system -->
+<link rel="stylesheet" type="text/css" href="<!-- TMPL_VAR name="themelang" -->/lib/calendar/calendar-system.css" />
+<!-- End of additions --><!-- Additions to enable Calendar system -->
+<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/calendar/calendar.js"></script>
+<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/calendar/calendar-en.js"></script>
+<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/calendar/calendar-setup.js"></script>
+<!-- End of additions -->
+</head>
+<body>
+<!-- TMPL_INCLUDE NAME="header.inc" -->
+<!-- TMPL_INCLUDE NAME="circ-search.inc" -->
+
+
+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a> &rsaquo; Reserve Ratios</div>
+
+<div id="doc3" class="yui-t2">
+   
+   <div id="bd">
+	<div id="yui-main">
+	<div class="yui-b">
+
+<h1>Reserve Ratios to Calculate Items Needed<br>
+    Calculated on <!-- TMPL_VAR NAME="todaysdate" --> <br>From <!-- TMPL_VAR NAME="from" -->
+	to <!-- TMPL_VAR NAME="to" --></h1>
+<div id="filters">
+<br />
+
+<form method="post" >
+<p>
+<label for "ratio">
+    Reserves Ratio:
+</label>
+<input type="text" size="5" id="ratio" name="ratio" value="<!-- TMPL_VAR NAME="ratio" -->" />
+<label for "from">
+    Start date:
+</label>
+<input type="text" size="10" id="from" name="from" value="<!-- TMPL_VAR NAME="from" -->" />
+<img src="<!-- TMPL_VAR Name="themelang" -->/lib/calendar/cal.gif"  border="0" id="openCalendarFrom" style="cursor: pointer;" alt="" />
+<script language="JavaScript" type="text/javascript">
+function validate1(date) {
+    var day = date.getDate();
+    var month = date.getMonth() + 1;
+    var year = date.getFullYear();
+    var weekDay = date.getDay();
+    var dayMonth = month + '-' + day;
+    var dateString = year + '-' + month + '-' + day;
+    var dateTo = document.getElementById('to').value.split("-");
+    var limitDate = new Date(dateTo[0], (dateTo[1] - 1), dateTo[2]);
+    if (date > limitDate) {
+            return true;
+    } else {
+            return false;
+    }
+}
+Calendar.setup(
+        {
+        inputField : "from",
+        ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
+        button : "openCalendarFrom",
+        disableFunc : validate1,
+        dateStatusFunc : validate1
+        }
+);
+</script>
+<label for "to" >
+    End date:
+</label>
+<input size="10" id="to" name="to" value="<!-- TMPL_VAR NAME="to" -->" type="text" />
+<img src="<!-- TMPL_VAR Name="themelang" -->/lib/calendar/cal.gif" alt="" id="openCalendarTo" style="cursor: pointer;" valign="top" border="0" />
+<script type="text/javascript">
+        function validate2(date) {
+            var day = date.getDate();
+            var month = date.getMonth() + 1;
+            var year = date.getFullYear();
+            var weekDay = date.getDay();
+            var dayMonth = month + '-' + day;
+            var dateString = year + '-' + month + '-' + day;
+            var dateFrom = document.getElementById('from').value.split("-");
+            var limitDate = new Date(dateFrom[0], (dateFrom[1] - 1), dateFrom[2]);
+            if (limitDate > date) {
+                    return true;
+            } else {
+                    return false;
+            }
+        }
+
+        Calendar.setup(
+                {
+                    inputField : "to",
+                    ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
+                    button : "openCalendarTo",
+                    disableFunc : validate2,
+                    dateStatusFunc : validate2
+                }
+        );
+</script>
+(inclusive)
+
+<input type="submit" value="Go" class="submit">
+</p>
+</form>
+<p>These items have a large number of holds.</p>
+</div>
+
+<div class="searchresults">
+    <!-- TMPL_IF NAME="reserveloop" -->
+    <table>
+    <tr>
+        <th >Reserves
+        <a href="/cgi-bin/koha/circ/reserveratios.pl?ratio=<!-- TMPL_VAR NAME="ratio" -->&order=reservecount&from=<!-- TMPL_VAR NAME="from" -->&to=<!-- TMPL_VAR NAME="to" -->">Sort</a>
+        </th>
+        <th >Items
+        <a href="/cgi-bin/koha/circ/reserveratios.pl?ratio=<!-- TMPL_VAR NAME="ratio" -->&order=itemcount&from=<!-- TMPL_VAR NAME="from" -->&to=<!-- TMPL_VAR NAME="to" -->">Sort</a>
+        </th>
+        <th >Title
+        <a href="/cgi-bin/koha/circ/reserveratios.pl?ratio=<!-- TMPL_VAR NAME="ratio" -->&order=biblio&from=<!-- TMPL_VAR NAME="from" -->&to=<!-- TMPL_VAR NAME="to" -->">Sort</a>
+        </th>
+        <th>Holding Branches
+        <a href="/cgi-bin/koha/circ/reserveratios.pl?ratio=<!-- TMPL_VAR NAME="ratio" -->&order=branch&from=<!-- TMPL_VAR NAME="from" -->&to=<!-- TMPL_VAR NAME="to" -->">Sort</a>
+        </th>
+        <th>Location
+        <a href="/cgi-bin/koha/circ/reserveratios.pl?ratio=<!-- TMPL_VAR NAME="ratio" -->&order=location&from=<!-- TMPL_VAR NAME="from" -->&to=<!-- TMPL_VAR NAME="to" -->">Sort</a>
+        </th>
+        <th>Itype
+        <a href="/cgi-bin/koha/circ/reserveratios.pl?ratio=<!-- TMPL_VAR NAME="ratio" -->&order=itype&from=<!-- TMPL_VAR NAME="from" -->&to=<!-- TMPL_VAR NAME="to" -->">Sort</a>
+        </th>
+        <th>Call Numbers
+        <a href="/cgi-bin/koha/circ/reserveratios.pl?ratio=<!-- TMPL_VAR NAME="ratio" -->&order=callnumber&from=<!-- TMPL_VAR NAME="from" -->&to=<!-- TMPL_VAR NAME="to" -->">Sort</a>
+        </th>
+        <th >Items Needed
+        </th>
+    </tr>
+    
+    <!-- TMPL_LOOP NAME="reserveloop" -->
+        <tr>
+            <!-- TMPL_IF name="ratio_ge_one" -->
+            	 <td>
+            	 	  <p><!-- TMPL_VAR NAME="reservecount" --></p>
+            	 </td>
+            	 <td>
+            	 	  <p><!-- TMPL_VAR NAME="itemcount" --></p>
+            	 </td>
+                <td>
+                    <p>
+                    <!-- TMPL_IF name="BiblioDefaultViewmarc" -->
+                    <a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->">
+                        <!-- TMPL_VAR NAME="title" --> <!-- TMPL_VAR NAME="subtitle" -->
+                    </a>
+                    <!-- TMPL_ELSE -->
+                        <!-- TMPL_IF name="BiblioDefaultViewisbd" -->
+                        <a href="/cgi-bin/koha/catalogue/ISBDdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->">
+                            <!-- TMPL_VAR NAME="title" --> <!-- TMPL_VAR NAME="subtitle" -->
+                        </a>
+                        <!-- TMPL_ELSE -->
+                            <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->">
+                                <!-- TMPL_VAR NAME="title" --> <!-- TMPL_VAR NAME="subtitle" -->
+                            </a>
+                        <!-- /TMPL_IF -->
+                    <!-- /TMPL_IF -->
+                    </p>
+                    <p><!-- TMPL_VAR NAME="notes" --></p>
+                </td>
+
+            	<td><p><!-- TMPL_VAR NAME="listbranch" --></p></td>
+            	<td><p><!-- TMPL_VAR NAME="location" --></p></td>
+            	<td><p><!-- TMPL_VAR NAME="itype" --></p></td>
+            	<td><p><!-- TMPL_VAR NAME="listcall" --></p></td>
+            	<td><p><b>Order: <!-- TMPL_VAR NAME="ratiocalc" --></b></p></td>
+            <!-- /TMPL_IF -->
+        </tr>
+    <!-- /TMPL_LOOP -->
+    </table>
+    <!-- TMPL_ELSE -->
+        <b>No items found.</b>
+    <!-- /TMPL_IF -->
+</div>
+</div>
+</div>
+<div class="yui-b">
+<!-- TMPL_INCLUDE NAME="circ-menu.inc" -->
+</div>
+</div>
+<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tmpl
index b907e8f..4d958cd 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tmpl
@@ -28,9 +28,13 @@
 
     <!-- TMPL_IF NAME="itemsloop" --><table>
     <tr>
+        <th>Title</th>
+        <th>Author</th>
+        <th>Lost Code</th>
         <th>Barcode</th>
         <th>Date last seen</th>
         <th>Price</th>
+        <th>Rep.Price</th>
         <th>Branch</th>
         <th>Itemtype</th>
         <th>Holdingbranch</th>
@@ -39,12 +43,18 @@
      <!-- TMPL_LOOP NAME="itemsloop"-->
         <tr>
             <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber"-->" title="<!-- TMPL_VAR NAME="itemnotes"-->">
+						  <!-- TMPL_VAR NAME="title"--></td>
+					 </a></td>
+            <td><!-- TMPL_VAR NAME="author"--></td>
+            <td><!-- TMPL_VAR NAME="lib"--></td>
+            <td><a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber"-->" title="<!-- TMPL_VAR NAME="itemnotes"-->">
                     <!-- TMPL_VAR NAME="barcode"-->
                 </a></td>
             <td><!-- TMPL_VAR NAME="datelastseen"--></td>
             <td><!-- TMPL_VAR NAME="price" --></td>
+            <td><!-- TMPL_VAR NAME="replacementprice" --></td>
             <td><!-- TMPL_VAR NAME="homebranch" --></td>
-            <td><!-- TMPL_VAR NAME="itemtype" --></td>
+            <td><!-- TMPL_VAR NAME="itype" --></td>
             <td><!-- TMPL_VAR NAME="holdingbranch"--></td>
             <td><!-- TMPL_VAR NAME="location"--></td>
         </tr>
@@ -57,10 +67,16 @@
 <fieldset class="rows"><ol>    <li><label for="orderbyfilter">Order by: </label>
     <select id="orderbyfilter" name="orderbyfilter">
         <option value=""> --- </option>
+        <option value="title">Title</option>
+        <option value="author">Author</option>
         <option value="homebranch">Branch</option>
-        <option value="itemtype">Itemtypes</option>
+        <option value="itype">Itemtypes</option>
         <option value="barcode">Barcode</option>
-        <option value="price">price</option>
+        <option value="price">Price</option>
+        <option value="replacementprice">Replacement Price</option>
+        <option value="lib">Lost Code</option>
+        <option value="datelastseen">Date Last Seen</option>
+        <option value="location">Location</option>
     </select></li>
 	
 	<li><label for="barcodefilter">Barcode: </label><input type="text" name="barcodefilter" id="barcodefilter" size="6" /></li>
diff --git a/reports/itemslost.pl b/reports/itemslost.pl
index 33fbfef..52ff1f9 100755
--- a/reports/itemslost.pl
+++ b/reports/itemslost.pl
@@ -57,14 +57,24 @@ if ( $get_items ) {
     $where{barcode}    = $barcodefilter   if defined $barcodefilter;
     $where{itemtype}   = $itemtypesfilter if defined $itemtypesfilter;
 
-    my $items = GetLostItems( \%where, $orderbyfilter );
+    my $items = GetLostItems( \%where, $orderbyfilter ); 
     $template->param(
         total     => scalar @$items,
         itemsloop => $items,
-		get_items => $get_items
+		  get_items => $get_items
     );
 }
 
+# Get the Lost colletion codes
+#my $fw = GetFrameworkCode($biblionumber);
+#$item = GetAuthorisedValues(GetAuthValCode('items.itemlost',$fw),$item->{itemlost}) if GetAuthValCode('items.itemlost',$fw);
+#if ($item->{damaged}) {
+#    $item->{itemdamagedloop}= GetAuthorisedValues(GetAuthValCode('items.damaged',$fw),$item->{damaged}) if GetAuthValCode('items.damaged',$fw);
+#}
+#get collection code description, too
+#my $ccodes = GetAuthorisedValueDesc('','',   'ccode' ,'','','ccode');
+
+
 # getting all branches.
 my $branches = GetBranches;
 my $branch   = C4::Context->userenv->{"branchname"};
-- 
1.5.5.rc0.16.g02b00




More information about the Koha-patches mailing list