Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 280 lines (254 sloc) 10.277 kb
0c020dd renaming reserves & branchreserves to pendingreserves and waitingreserve...
tipaul authored
1 #!/usr/bin/perl
2
3
4 # Copyright 2000-2002 Katipo Communications
5 #
6 # This file is part of Koha.
7 #
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
11 # version.
12 #
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.
16 #
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
20
8cafcef All patches to Koha 3 beta to date. All work with branches.
Darrell Ulm authored
21 # Modification by D.Ulm, actually works (as long as indep. branches not turned on)
22 # Someone let me know what indep. branches is supposed to do and I'll make that part work too
23 #
24 # The reserve pull lists *works* as long as not for indepencdant branches, I can fix!
25
0c020dd renaming reserves & branchreserves to pendingreserves and waitingreserve...
tipaul authored
26 use strict;
27 use C4::Context;
28 use C4::Output;
29 use CGI;
30 use C4::Auth;
687c833 fixes to date handling
Joshua Ferraro authored
31 use C4::Dates qw/format_date format_date_in_iso/;
0c020dd renaming reserves & branchreserves to pendingreserves and waitingreserve...
tipaul authored
32
ee1a241 pendingreserves.pl - debugify warn
Joe Atzberger authored
33 use vars qw($debug);
34
35 BEGIN {
36 $debug = $ENV{DEBUG} || 0;
37 }
38
0c020dd renaming reserves & branchreserves to pendingreserves and waitingreserve...
tipaul authored
39 my $input = new CGI;
40 my $order = $input->param('order');
8cafcef All patches to Koha 3 beta to date. All work with branches.
Darrell Ulm authored
41 my $startdate=$input->param('from');
42 my $enddate=$input->param('to');
86ee8ee Add print slip to hold confirmation dialog.
Ryan Higgins authored
43
8cafcef All patches to Koha 3 beta to date. All work with branches.
Darrell Ulm authored
44 my $theme = $input->param('theme'); # only used if allowthemeoverride is set
0c020dd renaming reserves & branchreserves to pendingreserves and waitingreserve...
tipaul authored
45
46 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
47 {
8cafcef All patches to Koha 3 beta to date. All work with branches.
Darrell Ulm authored
48 template_name => "circ/pendingreserves.tmpl",
0c020dd renaming reserves & branchreserves to pendingreserves and waitingreserve...
tipaul authored
49 query => $input,
50 type => "intranet",
51 authnotrequired => 0,
52 flagsrequired => { circulate => 1 },
53 debug => 1,
54 }
55 );
56
57 my $duedate;
8cafcef All patches to Koha 3 beta to date. All work with branches.
Darrell Ulm authored
58 my $borrowernumber;
0c020dd renaming reserves & branchreserves to pendingreserves and waitingreserve...
tipaul authored
59 my $itemnum;
60 my $data1;
61 my $data2;
62 my $data3;
63 my $name;
64 my $phone;
65 my $email;
8cafcef All patches to Koha 3 beta to date. All work with branches.
Darrell Ulm authored
66 my $biblionumber;
0c020dd renaming reserves & branchreserves to pendingreserves and waitingreserve...
tipaul authored
67 my $title;
68 my $author;
8cafcef All patches to Koha 3 beta to date. All work with branches.
Darrell Ulm authored
69
0c020dd renaming reserves & branchreserves to pendingreserves and waitingreserve...
tipaul authored
70 my @datearr = localtime( time() );
71 my $todaysdate =
72 ( 1900 + $datearr[5] ) . '-'
73 . sprintf( "%0.2d", ( $datearr[4] + 1 ) ) . '-'
74 . sprintf( "%0.2d", $datearr[3] );
75
8cafcef All patches to Koha 3 beta to date. All work with branches.
Darrell Ulm authored
76 # Find yesterday for the default shelf pull end dates
77 # A defualt of the prior day's holds is a reasonable way to pull holds
78 my @datearr_yesterday = localtime( time() - 86400 );
79 my $yesterdaysdate =
80 ( 1900 + $datearr_yesterday[5] ) . '-'
81 . sprintf( "%0.2d", ( $datearr_yesterday[4] + 1 ) ) . '-'
82 . sprintf( "%0.2d", $datearr_yesterday[3] );
83 # Find 10 years ago for the default shelf pull start and end dates
84 # A defualt of the prior day's holds is a reasonable way to pull holds
85 my @datearr_past = localtime( time() - 86400*365*10 );
86 my $pastdate =
87 ( 1900 + $datearr_past[5] ) . '-'
88 . sprintf( "%0.2d", ( $datearr_past[4] + 1 ) ) . '-'
89 . sprintf( "%0.2d", $datearr_past[3] );
90
91 # Predefine the start and end dates if they are not already defined
92 $startdate =~ s/^\s+//;
93 $startdate =~ s/\s+$//;
94 $enddate =~ s/^\s+//;
95 $enddate =~ s/\s+$//;
96 # Check if null, should string match, if so set start and end date to yesterday
97 if (!defined($startdate) or $startdate eq "") {
98 $startdate = format_date($pastdate);
99 }
100 if (!defined($enddate) or $enddate eq "") {
101 $enddate = format_date($yesterdaysdate);
102 }
103
104
0c020dd renaming reserves & branchreserves to pendingreserves and waitingreserve...
tipaul authored
105 my $dbh = C4::Context->dbh;
8cafcef All patches to Koha 3 beta to date. All work with branches.
Darrell Ulm authored
106 my ($sqlorderby, $sqldatewhere) = ("","");
ee1a241 pendingreserves.pl - debugify warn
Joe Atzberger authored
107 $debug and warn format_date_in_iso($startdate) . "\n" . format_date_in_iso($enddate);
8cafcef All patches to Koha 3 beta to date. All work with branches.
Darrell Ulm authored
108 $sqldatewhere .= " AND reservedate >= " . $dbh->quote(format_date_in_iso($startdate)) if ($startdate) ;
109 $sqldatewhere .= " AND reservedate <= " . $dbh->quote(format_date_in_iso($enddate)) if ($enddate) ;
110
111
112 if ($order eq "biblio") {
113 $sqlorderby = " order by biblio.title ";
114 } elsif ($order eq "itype") {
115 $sqlorderby = " order by l_itype, location, l_itemcallnumber ";
116 } elsif ($order eq "location") {
117 $sqlorderby = " order by location, l_itemcallnumber, holdingbranch ";
118 } elsif ($order eq "date") {
119 $sqlorderby = " order by l_reservedate, location, l_itemcallnumber ";
120 } elsif ($order eq "library") {
121 $sqlorderby = " order by holdingbranch, l_itemcallnumber, location ";
122 } elsif ($order eq "call") {
123 $sqlorderby = " order by l_itemcallnumber, holdingbranch, location ";
0c020dd renaming reserves & branchreserves to pendingreserves and waitingreserve...
tipaul authored
124 } else {
8cafcef All patches to Koha 3 beta to date. All work with branches.
Darrell Ulm authored
125 $sqlorderby = " order by biblio.title ";
0c020dd renaming reserves & branchreserves to pendingreserves and waitingreserve...
tipaul authored
126 }
127 my $strsth =
8cafcef All patches to Koha 3 beta to date. All work with branches.
Darrell Ulm authored
128 "SELECT min(reservedate) as l_reservedate,
0c020dd renaming reserves & branchreserves to pendingreserves and waitingreserve...
tipaul authored
129 reserves.borrowernumber as borrowernumber,
8cafcef All patches to Koha 3 beta to date. All work with branches.
Darrell Ulm authored
130 GROUP_CONCAT(DISTINCT items.holdingbranch
131 ORDER BY items.itemnumber SEPARATOR '<br>') l_holdingbranch,
0c020dd renaming reserves & branchreserves to pendingreserves and waitingreserve...
tipaul authored
132 reserves.biblionumber,
8cafcef All patches to Koha 3 beta to date. All work with branches.
Darrell Ulm authored
133 reserves.branchcode,
134 GROUP_CONCAT(DISTINCT reserves.branchcode
135 ORDER BY items.itemnumber SEPARATOR ', ') l_branch,
136 items.holdingbranch as branch,
0c020dd renaming reserves & branchreserves to pendingreserves and waitingreserve...
tipaul authored
137 items.itemcallnumber,
8cafcef All patches to Koha 3 beta to date. All work with branches.
Darrell Ulm authored
138 GROUP_CONCAT(DISTINCT items.itype
139 ORDER BY items.itemnumber SEPARATOR '<br>') l_itype,
140 GROUP_CONCAT(DISTINCT items.location
141 ORDER BY items.itemnumber SEPARATOR '<br>') l_location,
142 GROUP_CONCAT(DISTINCT items.itemcallnumber
143 ORDER BY items.itemnumber SEPARATOR '<br>') l_itemcallnumber,
0c020dd renaming reserves & branchreserves to pendingreserves and waitingreserve...
tipaul authored
144 items.itemnumber,
145 notes,
146 notificationdate,
147 reminderdate,
8cafcef All patches to Koha 3 beta to date. All work with branches.
Darrell Ulm authored
148 max(priority) as priority,
0c020dd renaming reserves & branchreserves to pendingreserves and waitingreserve...
tipaul authored
149 reserves.found,
150 biblio.title,
8cafcef All patches to Koha 3 beta to date. All work with branches.
Darrell Ulm authored
151 biblio.author,
152 count(DISTINCT items.itemnumber) as icount,
153 count(DISTINCT reserves.borrowernumber) as rcount
0c020dd renaming reserves & branchreserves to pendingreserves and waitingreserve...
tipaul authored
154 FROM reserves
8cafcef All patches to Koha 3 beta to date. All work with branches.
Darrell Ulm authored
155 LEFT JOIN items ON items.biblionumber=reserves.biblionumber
156 LEFT JOIN biblio ON reserves.biblionumber=biblio.biblionumber
157 LEFT JOIN branchtransfers ON items.itemnumber=branchtransfers.itemnumber
158 WHERE
159 reserves.found IS NULL
88e9130 fixing pending reserves to use dates specified
Ryan Higgins authored
160 $sqldatewhere
8cafcef All patches to Koha 3 beta to date. All work with branches.
Darrell Ulm authored
161 AND items.itemnumber NOT IN (SELECT itemnumber FROM branchtransfers where datearrived IS NULL)
162 AND items.itemnumber NOT IN (SELECT itemnumber FROM issues)
163 AND reserves.priority <> 0
164 AND reserves.itemnumber is NULL
165 AND notforloan = 0 AND damaged = 0 AND itemlost = 0 AND wthdrawn = 0
166 ";
167 # GROUP BY reserves.biblionumber allows only items that are not checked out, else multiples occur when
168 # multiple patrons have a hold on an item
169
0c020dd renaming reserves & branchreserves to pendingreserves and waitingreserve...
tipaul authored
170
c3c520b Working on a fix for bug 1456
Chris Cormack authored
171 if (C4::Context->preference('IndependantBranches')){
d8d27ab Missing AND in the SQL in pendingreserves.pl only if independentbranches...
Chris Cormack authored
172 $strsth .= " AND items.holdingbranch=? ";
c3c520b Working on a fix for bug 1456
Chris Cormack authored
173 }
8cafcef All patches to Koha 3 beta to date. All work with branches.
Darrell Ulm authored
174 $strsth .= " GROUP BY reserves.biblionumber " . $sqlorderby;
0c020dd renaming reserves & branchreserves to pendingreserves and waitingreserve...
tipaul authored
175 my $sth = $dbh->prepare($strsth);
176
c3c520b Working on a fix for bug 1456
Chris Cormack authored
177 if (C4::Context->preference('IndependantBranches')){
178 $sth->execute(C4::Context->userenv->{'branch'});
179 }
180 else {
181 $sth->execute();
182 }
0c020dd renaming reserves & branchreserves to pendingreserves and waitingreserve...
tipaul authored
183 my @reservedata;
184 my $previous;
185 my $this;
186 while ( my $data = $sth->fetchrow_hashref ) {
187 $this=$data->{biblionumber}.":".$data->{borrowernumber};
188 my @itemlist;
189 push(
190 @reservedata,
191 {
8cafcef All patches to Koha 3 beta to date. All work with branches.
Darrell Ulm authored
192 reservedate => format_date( $data->{l_reservedate} ),
193 priority => $data->{priority},
194 name => $data->{l_patron},
195 title => $data->{title},
196 author => $data->{author},
197 borrowernumber => $data->{borrowernumber},
198 itemnum => $data->{itemnumber},
199 phone => $data->{phone},
200 email => $data->{email},
201 biblionumber => $data->{biblionumber},
86e4cdf use 'F' or 'W', not 'f' or 'w' when using reserves.found
Galen Charlton authored
202 statusw => ( $data->{found} eq "W" ),
203 statusf => ( $data->{found} eq "F" ),
8cafcef All patches to Koha 3 beta to date. All work with branches.
Darrell Ulm authored
204 holdingbranch => $data->{l_holdingbranch},
205 branch => $data->{l_branch},
206 itemcallnumber => $data->{l_itemcallnumber},
207 notes => $data->{notes},
208 notificationdate => $data->{notificationdate},
209 reminderdate => $data->{reminderdate},
210 count => $data->{icount},
211 rcount => $data->{rcount},
212 pullcount => $data->{icount} <= $data->{rcount} ? $data->{icount} : $data->{rcount},
213 itype => $data->{l_itype},
214 location => $data->{l_location}
0c020dd renaming reserves & branchreserves to pendingreserves and waitingreserve...
tipaul authored
215 }
216 );
217 $previous=$this;
218 }
219
220 $sth->finish;
b9b77bc Still a work in progress, pendingreserves.pl is quite broken
Chris Cormack authored
221
8cafcef All patches to Koha 3 beta to date. All work with branches.
Darrell Ulm authored
222 # *** I doubt any of this is needed now with the above fixes *** -d.u.
223
224 #$strsth=~ s/AND reserves.itemnumber is NULL/AND reserves.itemnumber is NOT NULL/;
225 #$strsth=~ s/LEFT JOIN items ON items.biblionumber=reserves.biblionumber/LEFT JOIN items ON items.biblionumber=reserves.itemnumber/;
226 #$sth = $dbh->prepare($strsth);
227 #if (C4::Context->preference('IndependantBranches')){
228 # $sth->execute(C4::Context->userenv->{'branch'});
229 #}
230 #else {
231 # $sth->execute();
232 #}
233 #while ( my $data = $sth->fetchrow_hashref ) {
234 # $this=$data->{biblionumber}.":".$data->{borrowernumber};
235 # my @itemlist;
236 # push(
237 # @reservedata,
238 # {
239 # reservedate => format_date( $data->{l_reservedate} ),
240 # priority => $data->{priority},
241 # name => $data->{l_patron},
242 # title => $data->{title},
243 # author => $data->{author},
244 # borrowernumber => $data->{borrowernumber},
245 # itemnum => $data->{itemnumber},
246 # phone => $data->{phone},
247 # email => $data->{email},
248 # biblionumber => $data->{biblionumber},
249 # statusw => ( $data->{found} eq "W" ),
250 # statusf => ( $data->{found} eq "F" ),
251 # holdingbranch => $data->{l_holdingbranch},
252 # branch => $data->{l_branch},
253 # itemcallnumber => $data->{l_itemcallnumber},
254 # notes => $data->{notes},
255 # notificationdate => $data->{notificationdate},
256 # reminderdate => $data->{reminderdate},
257 # count => $data->{icount},
258 # rcount => $data->{rcount},
259 # pullcount => $data->{icount} <= $data->{rcount} ? $data->{icount} : $data->{rcount},
260 # itype => $data->{l_itype},
261 # location => $data->{l_location},
262 # thisitemonly => 1,
263 #
264 # }
265 # );
266 # $previous=$this;
267 #}
268 #$sth->finish;
0c020dd renaming reserves & branchreserves to pendingreserves and waitingreserve...
tipaul authored
269
270 $template->param(
8cafcef All patches to Koha 3 beta to date. All work with branches.
Darrell Ulm authored
271 todaysdate => format_date($todaysdate),
687c833 fixes to date handling
Joshua Ferraro authored
272 from => $startdate,
8cafcef All patches to Koha 3 beta to date. All work with branches.
Darrell Ulm authored
273 to => $enddate,
274 reserveloop => \@reservedata,
0c020dd renaming reserves & branchreserves to pendingreserves and waitingreserve...
tipaul authored
275 "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1,
687c833 fixes to date handling
Joshua Ferraro authored
276 DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
0c020dd renaming reserves & branchreserves to pendingreserves and waitingreserve...
tipaul authored
277 );
278
279 output_html_with_http_headers $input, $cookie, $template->output;
Something went wrong with that request. Please try again.