5 # Copyright 2000-2002 Katipo Communications
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License along with
19 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 # Suite 330, Boston, MA 02111-1307 USA
28 use C4::Interface::CGI::Output;
31 my $order = $input->param('order');
32 my $startdate=$input->param('from');
33 my $enddate=$input->param('to');
35 my $theme = $input->param('theme'); # only used if allowthemeoverride is set
37 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
39 template_name => "circ/pendingreserves.tmpl",
43 flagsrequired => { circulate => 1 },
61 my @datearr = localtime( time() );
63 ( 1900 + $datearr[5] ) . '-'
64 . sprintf( "%0.2d", ( $datearr[4] + 1 ) ) . '-'
65 . sprintf( "%0.2d", $datearr[3] );
67 my $dbh = C4::Context->dbh;
68 my ($sqlorderby, $sqldatewhere) = ("","");
70 $sqldatewhere .= " && reservedate >= " . $dbh->quote($startdate) if ($startdate) ;
71 $sqldatewhere .= " && reservedate <= " . $dbh->quote($enddate) if ($enddate) ;
73 if ($order eq "borrower") {
74 $sqlorderby = " order by borrower, reservedate";
75 } elsif ($order eq "biblio") {
76 $sqlorderby = " order by biblio.title, priority,reservedate";
77 } elsif ($order eq "priority") {
78 $sqlorderby = "order by priority DESC";
80 $sqlorderby = " order by reservedate, borrower";
84 reserves.borrowernumber as borrowernumber,
85 concat(firstname,' ',surname) as borrower,
88 reserves.biblionumber,
89 reserves.branchcode as branch,
101 LEFT JOIN items ON items.biblionumber=reserves.biblionumber,
103 WHERE isnull(cancellationdate)
104 && reserves.borrowernumber=borrowers.borrowernumber
105 && reserves.biblionumber=biblio.biblionumber
106 && reserves.found is NULL
107 && items.holdingbranch=?
110 $strsth .= $sqlorderby;
112 my $sth = $dbh->prepare($strsth);
114 $sth->execute(C4::Context->userenv->{'branch'});
119 while ( my $data = $sth->fetchrow_hashref ) {
120 $this=$data->{biblionumber}.":".$data->{borrowernumber};
125 reservedate => $previous eq $this?"":format_date( $data->{reservedate} ),
126 priority => $previous eq $this?"":$data->{priority},
127 name => $previous eq $this?"":$data->{borrower},
128 title => $previous eq $this?"":$data->{title},
129 author => $previous eq $this?"":$data->{author},
130 borrowernumber => $previous eq $this?"":$data->{borrowernumber},
131 itemnum => $previous eq $this?"":$data->{itemnumber},
132 phone => $previous eq $this?"":$data->{phone},
133 email => $previous eq $this?"":$data->{email},
134 biblionumber => $previous eq $this?"":$data->{biblionumber},
135 statusw => ( $data->{found} eq "w" ),
136 statusf => ( $data->{found} eq "f" ),
137 holdingbranch => $data->{holdingbranch},
138 branch => $previous eq $this?"":$data->{branch},
139 itemcallnumber => $data->{itemcallnumber},
140 notes => $previous eq $this?"":$data->{notes},
141 notificationdate => $previous eq $this?"":$data->{notificationdate},
142 reminderdate => $previous eq $this?"":$data->{reminderdate}
151 todaysdate => format_date($todaysdate),
154 reserveloop => \@reservedata,
155 intranetcolorstylesheet =>
156 C4::Context->preference("intranetcolorstylesheet"),
157 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
158 IntranetNav => C4::Context->preference("IntranetNav"),
159 "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1,
162 output_html_with_http_headers $input, $cookie, $template->output;