4 # Copyright 2000-2002 Katipo Communications
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along with
18 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19 # Suite 330, Boston, MA 02111-1307 USA
29 my $order = $input->param('order');
30 my $startdate=$input->param('from');
31 my $enddate=format_date_in_iso($input->param('to'));
33 my $theme = $input->param('theme'); # only used if allowthemeoverride is set
35 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
37 template_name => "circ/pendingreserves.tmpl",
41 flagsrequired => { circulate => 1 },
59 my @datearr = localtime( time() );
61 ( 1900 + $datearr[5] ) . '-'
62 . sprintf( "%0.2d", ( $datearr[4] + 1 ) ) . '-'
63 . sprintf( "%0.2d", $datearr[3] );
65 my $dbh = C4::Context->dbh;
66 my ($sqlorderby, $sqldatewhere) = ("","");
68 $sqldatewhere .= " && reservedate >= " . $dbh->quote($startdate) if ($startdate) ;
69 $sqldatewhere .= " && reservedate <= " . $dbh->quote($enddate) if ($enddate) ;
71 if ($order eq "borrower") {
72 $sqlorderby = " order by borrower, reservedate";
73 } elsif ($order eq "biblio") {
74 $sqlorderby = " order by biblio.title, priority,reservedate";
75 } elsif ($order eq "priority") {
76 $sqlorderby = "order by priority DESC";
78 $sqlorderby = " order by reservedate, borrower";
82 reserves.borrowernumber as borrowernumber,
83 concat(firstname,' ',surname) as borrower,
86 reserves.biblionumber,
87 reserves.branchcode as branch,
99 LEFT JOIN items ON items.biblionumber=reserves.biblionumber
100 LEFT JOIN borrowers ON reserves.borrowernumber=borrowers.borrowernumber
101 LEFT JOIN biblio ON reserves.biblionumber=biblio.biblionumber
102 WHERE isnull(cancellationdate)
103 && reserves.found is NULL
104 && items.holdingbranch=?
107 $strsth .= $sqlorderby;
109 my $sth = $dbh->prepare($strsth);
111 $sth->execute(C4::Context->userenv->{'branch'});
116 while ( my $data = $sth->fetchrow_hashref ) {
117 $this=$data->{biblionumber}.":".$data->{borrowernumber};
122 reservedate => $previous eq $this?"":format_date( $data->{reservedate} ),
123 priority => $previous eq $this?"":$data->{priority},
124 name => $previous eq $this?"":$data->{borrower},
125 title => $previous eq $this?"":$data->{title},
126 author => $previous eq $this?"":$data->{author},
127 borrowernumber => $previous eq $this?"":$data->{borrowernumber},
128 itemnum => $previous eq $this?"":$data->{itemnumber},
129 phone => $previous eq $this?"":$data->{phone},
130 email => $previous eq $this?"":$data->{email},
131 biblionumber => $previous eq $this?"":$data->{biblionumber},
132 statusw => ( $data->{found} eq "w" ),
133 statusf => ( $data->{found} eq "f" ),
134 holdingbranch => $data->{holdingbranch},
135 branch => $previous eq $this?"":$data->{branch},
136 itemcallnumber => $data->{itemcallnumber},
137 notes => $previous eq $this?"":$data->{notes},
138 notificationdate => $previous eq $this?"":$data->{notificationdate},
139 reminderdate => $previous eq $this?"":$data->{reminderdate}
148 todaysdate => format_date($todaysdate),
151 reserveloop => \@reservedata,
152 "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1,
153 DHTMLcalendar_dateformat => get_date_format_string_for_DHTMLcalendar(),
156 output_html_with_http_headers $input, $cookie, $template->output;