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
26 use C4::Dates qw/format_date format_date_in_iso/;
31 $debug = $ENV{DEBUG} || 0;
35 my $order = $input->param('order');
36 my $startdate=$input->param('from');
37 my $enddate=$input->param('to');
39 my $theme = $input->param('theme'); # only used if allowthemeoverride is set
41 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
43 template_name => "circ/pendingreserves.tmpl",
47 flagsrequired => { circulate => 1 },
65 my @datearr = localtime( time() );
67 ( 1900 + $datearr[5] ) . '-'
68 . sprintf( "%0.2d", ( $datearr[4] + 1 ) ) . '-'
69 . sprintf( "%0.2d", $datearr[3] );
71 my $dbh = C4::Context->dbh;
72 my ($sqlorderby, $sqldatewhere) = ("","");
73 $debug and warn format_date_in_iso($startdate) . "\n" . format_date_in_iso($enddate);
74 $sqldatewhere .= " AND reservedate >= " . $dbh->quote(format_date_in_iso($startdate)) if ($startdate) ;
75 $sqldatewhere .= " AND reservedate <= " . $dbh->quote(format_date_in_iso($enddate)) if ($enddate) ;
77 if ($order eq "borrower") {
78 $sqlorderby = " order by borrower, reservedate";
79 } elsif ($order eq "biblio") {
80 $sqlorderby = " order by biblio.title, priority,reservedate";
81 } elsif ($order eq "priority") {
82 $sqlorderby = "order by priority DESC";
84 $sqlorderby = " order by reservedate, borrower";
88 reserves.borrowernumber as borrowernumber,
89 concat(firstname,' ',surname) as borrower,
92 reserves.biblionumber,
93 reserves.branchcode as branch,
105 LEFT JOIN items ON items.biblionumber=reserves.biblionumber
106 LEFT JOIN borrowers ON reserves.borrowernumber=borrowers.borrowernumber
107 LEFT JOIN biblio ON reserves.biblionumber=biblio.biblionumber
108 WHERE isnull(cancellationdate)
110 AND reserves.found is NULL ";
112 if (C4::Context->preference('IndependantBranches')){
113 $strsth .= " AND items.holdingbranch=? ";
115 $strsth .= $sqlorderby;
116 my $sth = $dbh->prepare($strsth);
118 if (C4::Context->preference('IndependantBranches')){
119 $sth->execute(C4::Context->userenv->{'branch'});
127 while ( my $data = $sth->fetchrow_hashref ) {
128 $this=$data->{biblionumber}.":".$data->{borrowernumber};
133 reservedate => $previous eq $this?"":format_date( $data->{reservedate} ),
134 priority => $previous eq $this?"":$data->{priority},
135 name => $previous eq $this?"":$data->{borrower},
136 title => $previous eq $this?"":$data->{title},
137 author => $previous eq $this?"":$data->{author},
138 borrowernumber => $previous eq $this?"":$data->{borrowernumber},
139 itemnum => $previous eq $this?"":$data->{itemnumber},
140 phone => $previous eq $this?"":$data->{phone},
141 email => $previous eq $this?"":$data->{email},
142 biblionumber => $previous eq $this?"":$data->{biblionumber},
143 statusw => ( $data->{found} eq "w" ),
144 statusf => ( $data->{found} eq "f" ),
145 holdingbranch => $data->{holdingbranch},
146 branch => $previous eq $this?"":$data->{branch},
147 itemcallnumber => $data->{itemcallnumber},
148 notes => $previous eq $this?"":$data->{notes},
149 notificationdate => $previous eq $this?"":$data->{notificationdate},
150 reminderdate => $previous eq $this?"":$data->{reminderdate}
159 todaysdate => format_date($todaysdate),
162 reserveloop => \@reservedata,
163 "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1,
164 DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
167 output_html_with_http_headers $input, $cookie, $template->output;