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
30 my $order = $input->param('order');
31 my $startdate=$input->param('from');
32 my $enddate=$input->param('to');
34 my $theme = $input->param('theme'); # only used if allowthemeoverride is set
36 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
38 template_name => "circ/pendingreserves.tmpl",
42 flagsrequired => { circulate => 1 },
60 my @datearr = localtime( time() );
62 ( 1900 + $datearr[5] ) . '-'
63 . sprintf( "%0.2d", ( $datearr[4] + 1 ) ) . '-'
64 . sprintf( "%0.2d", $datearr[3] );
66 my $dbh = C4::Context->dbh;
67 my ($sqlorderby, $sqldatewhere) = ("","");
69 $sqldatewhere .= " && reservedate >= " . $dbh->quote($startdate) if ($startdate) ;
70 $sqldatewhere .= " && reservedate <= " . $dbh->quote($enddate) if ($enddate) ;
72 if ($order eq "borrower") {
73 $sqlorderby = " order by borrower, reservedate";
74 } elsif ($order eq "biblio") {
75 $sqlorderby = " order by biblio.title, priority,reservedate";
76 } elsif ($order eq "priority") {
77 $sqlorderby = "order by priority DESC";
79 $sqlorderby = " order by reservedate, borrower";
83 reserves.borrowernumber as borrowernumber,
84 concat(firstname,' ',surname) as borrower,
87 reserves.biblionumber,
88 reserves.branchcode as branch,
100 LEFT JOIN items ON items.biblionumber=reserves.biblionumber,
102 WHERE isnull(cancellationdate)
103 && reserves.borrowernumber=borrowers.borrowernumber
104 && reserves.biblionumber=biblio.biblionumber
105 && reserves.found is NULL
106 && items.holdingbranch=?
109 $strsth .= $sqlorderby;
111 my $sth = $dbh->prepare($strsth);
113 $sth->execute(C4::Context->userenv->{'branch'});
118 while ( my $data = $sth->fetchrow_hashref ) {
119 $this=$data->{biblionumber}.":".$data->{borrowernumber};
124 reservedate => $previous eq $this?"":format_date( $data->{reservedate} ),
125 priority => $previous eq $this?"":$data->{priority},
126 name => $previous eq $this?"":$data->{borrower},
127 title => $previous eq $this?"":$data->{title},
128 author => $previous eq $this?"":$data->{author},
129 borrowernumber => $previous eq $this?"":$data->{borrowernumber},
130 itemnum => $previous eq $this?"":$data->{itemnumber},
131 phone => $previous eq $this?"":$data->{phone},
132 email => $previous eq $this?"":$data->{email},
133 biblionumber => $previous eq $this?"":$data->{biblionumber},
134 statusw => ( $data->{found} eq "w" ),
135 statusf => ( $data->{found} eq "f" ),
136 holdingbranch => $data->{holdingbranch},
137 branch => $previous eq $this?"":$data->{branch},
138 itemcallnumber => $data->{itemcallnumber},
139 notes => $previous eq $this?"":$data->{notes},
140 notificationdate => $previous eq $this?"":$data->{notificationdate},
141 reminderdate => $previous eq $this?"":$data->{reminderdate}
150 todaysdate => format_date($todaysdate),
153 reserveloop => \@reservedata,
154 intranetcolorstylesheet =>
155 C4::Context->preference("intranetcolorstylesheet"),
156 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
157 IntranetNav => C4::Context->preference("IntranetNav"),
158 "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1,
161 output_html_with_http_headers $input, $cookie, $template->output;