Lines 34-44
use C4::Debug;
Link Here
|
34 |
use Date::Calc qw/Today Add_Delta_YMD/; |
34 |
use Date::Calc qw/Today Add_Delta_YMD/; |
35 |
|
35 |
|
36 |
my $input = new CGI; |
36 |
my $input = new CGI; |
37 |
my $order = $input->param('order'); |
|
|
38 |
my $startdate=$input->param('from'); |
37 |
my $startdate=$input->param('from'); |
39 |
my $enddate=$input->param('to'); |
38 |
my $enddate=$input->param('to'); |
40 |
my $run_report=$input->param('run_report'); |
39 |
my $run_report=$input->param('run_report'); |
41 |
my $report_page=$input->param('report_page'); |
|
|
42 |
|
40 |
|
43 |
my $theme = $input->param('theme'); # only used if allowthemeoverride is set |
41 |
my $theme = $input->param('theme'); # only used if allowthemeoverride is set |
44 |
|
42 |
|
Lines 69-97
my $author;
Link Here
|
69 |
my ( $year, $month, $day ) = Today(); |
67 |
my ( $year, $month, $day ) = Today(); |
70 |
my $todaysdate = sprintf("%-04.4d-%-02.2d-%02.2d", $year, $month, $day); |
68 |
my $todaysdate = sprintf("%-04.4d-%-02.2d-%02.2d", $year, $month, $day); |
71 |
my $yesterdaysdate = sprintf("%-04.4d-%-02.2d-%02.2d", Add_Delta_YMD($year, $month, $day, 0, 0, -1)); |
69 |
my $yesterdaysdate = sprintf("%-04.4d-%-02.2d-%02.2d", Add_Delta_YMD($year, $month, $day, 0, 0, -1)); |
72 |
#changed from delivered range of 10 years-yesterday to 2 days ago-today |
70 |
# changed from delivered range of 10 years-yesterday to 2 days ago-today |
73 |
# Find two days ago for the default shelf pull start and end dates |
71 |
# Find two days ago for the default shelf pull start and end dates |
74 |
my $pastdate = sprintf("%-04.4d-%-02.2d-%02.2d", Add_Delta_YMD($year, $month, $day, 0, 0, -2)); |
72 |
my $pastdate = sprintf("%-04.4d-%-02.2d-%02.2d", Add_Delta_YMD($year, $month, $day, 0, 0, -2)); |
75 |
|
73 |
|
76 |
# Predefine the start and end dates if they are not already defined |
74 |
# Predefine the start and end dates if they are not already defined |
77 |
$startdate =~ s/^\s+//; |
75 |
$startdate =~ s/^\s+//; |
78 |
$startdate =~ s/\s+$//; |
76 |
$startdate =~ s/\s+$//; |
79 |
$enddate =~ s/^\s+//; |
77 |
$enddate =~ s/^\s+//; |
80 |
$enddate =~ s/\s+$//; |
78 |
$enddate =~ s/\s+$//; |
81 |
# Check if null, should string match, if so set start and end date to yesterday |
79 |
# Check if null, should string match, if so set start and end date to yesterday |
82 |
if (!defined($startdate) or $startdate eq "") { |
80 |
if (!defined($startdate) or $startdate eq "") { |
83 |
$startdate = format_date($pastdate); |
81 |
$startdate = format_date($pastdate); |
84 |
} |
82 |
} |
85 |
if (!defined($enddate) or $enddate eq "") { |
83 |
if (!defined($enddate) or $enddate eq "") { |
86 |
$enddate = format_date($todaysdate); |
84 |
$enddate = format_date($todaysdate); |
87 |
} |
85 |
} |
88 |
|
86 |
|
89 |
|
87 |
|
90 |
my @reservedata; |
88 |
my @reservedata; |
91 |
my ($prev_results, $next_results, $next_or_previous) = (0,0,0); |
|
|
92 |
if ( $run_report ) { |
89 |
if ( $run_report ) { |
93 |
my $dbh = C4::Context->dbh; |
90 |
my $dbh = C4::Context->dbh; |
94 |
my ($sqlorderby, $sqldatewhere, $sqllimitoffset) = ("","",""); |
91 |
my $sqldatewhere = ""; |
95 |
$debug and warn format_date_in_iso($startdate) . "\n" . format_date_in_iso($enddate); |
92 |
$debug and warn format_date_in_iso($startdate) . "\n" . format_date_in_iso($enddate); |
96 |
my @query_params = (); |
93 |
my @query_params = (); |
97 |
if ($startdate) { |
94 |
if ($startdate) { |
Lines 103-129
if ( $run_report ) {
Link Here
|
103 |
push @query_params, format_date_in_iso($enddate); |
100 |
push @query_params, format_date_in_iso($enddate); |
104 |
} |
101 |
} |
105 |
|
102 |
|
106 |
$sqllimitoffset = " LIMIT 251"; |
|
|
107 |
if ($report_page) { |
108 |
$sqllimitoffset .= " OFFSET=?"; |
109 |
push @query_params, ($report_page * 250); |
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 "; |
124 |
} else { |
125 |
$sqlorderby = " ORDER BY biblio.title "; |
126 |
} |
127 |
my $strsth = |
103 |
my $strsth = |
128 |
"SELECT min(reservedate) as l_reservedate, |
104 |
"SELECT min(reservedate) as l_reservedate, |
129 |
reserves.borrowernumber as borrowernumber, |
105 |
reserves.borrowernumber as borrowernumber, |
Lines 176-285
if ( $run_report ) {
Link Here
|
176 |
$strsth .= " AND items.holdingbranch=? "; |
152 |
$strsth .= " AND items.holdingbranch=? "; |
177 |
push @query_params, C4::Context->userenv->{'branch'}; |
153 |
push @query_params, C4::Context->userenv->{'branch'}; |
178 |
} |
154 |
} |
179 |
$strsth .= " GROUP BY reserves.biblionumber " . $sqlorderby; |
155 |
$strsth .= " GROUP BY reserves.biblionumber ORDER BY biblio.title "; |
180 |
|
156 |
|
181 |
my $sth = $dbh->prepare($strsth); |
157 |
my $sth = $dbh->prepare($strsth); |
182 |
$sth->execute(@query_params); |
158 |
$sth->execute(@query_params); |
183 |
|
159 |
|
184 |
my $previous; |
|
|
185 |
my $this; |
186 |
while ( my $data = $sth->fetchrow_hashref ) { |
160 |
while ( my $data = $sth->fetchrow_hashref ) { |
187 |
$this=$data->{biblionumber}.":".$data->{borrowernumber}; |
|
|
188 |
my @itemlist; |
189 |
push( |
161 |
push( |
190 |
@reservedata, |
162 |
@reservedata, |
191 |
{ |
163 |
{ |
192 |
reservedate => format_date( $data->{l_reservedate} ), |
164 |
reservedate => format_date( $data->{l_reservedate} ), |
193 |
priority => $data->{priority}, |
165 |
priority => $data->{priority}, |
194 |
name => $data->{l_patron}, |
166 |
name => $data->{l_patron}, |
195 |
title => $data->{title}, |
167 |
title => $data->{title}, |
196 |
author => $data->{author}, |
168 |
author => $data->{author}, |
197 |
borrowernumber => $data->{borrowernumber}, |
169 |
borrowernumber => $data->{borrowernumber}, |
198 |
itemnum => $data->{itemnumber}, |
170 |
itemnum => $data->{itemnumber}, |
199 |
phone => $data->{phone}, |
171 |
phone => $data->{phone}, |
200 |
email => $data->{email}, |
172 |
email => $data->{email}, |
201 |
biblionumber => $data->{biblionumber}, |
173 |
biblionumber => $data->{biblionumber}, |
202 |
statusw => ( $data->{found} eq "W" ), |
174 |
statusw => ( $data->{found} eq "W" ), |
203 |
statusf => ( $data->{found} eq "F" ), |
175 |
statusf => ( $data->{found} eq "F" ), |
204 |
holdingbranch => $data->{l_holdingbranch}, |
176 |
holdingbranch => $data->{l_holdingbranch}, |
205 |
branch => $data->{l_branch}, |
177 |
branch => $data->{l_branch}, |
206 |
itemcallnumber => $data->{l_itemcallnumber}, |
178 |
itemcallnumber => $data->{l_itemcallnumber}, |
207 |
enumchron => $data->{l_enumchron}, |
179 |
enumchron => $data->{l_enumchron}, |
208 |
copyno => $data->{l_copynumber}, |
180 |
copyno => $data->{l_copynumber}, |
209 |
notes => $data->{notes}, |
181 |
notes => $data->{notes}, |
210 |
notificationdate => $data->{notificationdate}, |
182 |
notificationdate => $data->{notificationdate}, |
211 |
reminderdate => $data->{reminderdate}, |
183 |
reminderdate => $data->{reminderdate}, |
212 |
count => $data->{icount}, |
184 |
count => $data->{icount}, |
213 |
rcount => $data->{rcount}, |
185 |
rcount => $data->{rcount}, |
214 |
pullcount => $data->{icount} <= $data->{rcount} ? $data->{icount} : $data->{rcount}, |
186 |
pullcount => $data->{icount} <= $data->{rcount} ? $data->{icount} : $data->{rcount}, |
215 |
itype => $data->{l_itype}, |
187 |
itype => $data->{l_itype}, |
216 |
location => $data->{l_location} |
188 |
location => $data->{l_location} |
217 |
} |
189 |
} |
218 |
); |
190 |
); |
219 |
$previous=$this; |
|
|
220 |
} |
191 |
} |
221 |
|
|
|
222 |
$sth->finish; |
192 |
$sth->finish; |
223 |
|
|
|
224 |
# Next Page? |
225 |
if ($report_page > 0) { |
226 |
$prev_results = $report_page - 1; |
227 |
} |
228 |
if ( scalar(@reservedata) > 250 ) { |
229 |
$next_results = $report_page + 1; |
230 |
pop(@reservedata); # .. we retrieved 251 results |
231 |
} |
232 |
if ($prev_results || $next_results) { |
233 |
$next_or_previous = 1; |
234 |
} |
235 |
|
236 |
# *** I doubt any of this is needed now with the above fixes *** -d.u. |
237 |
|
238 |
#$strsth=~ s/AND reserves.itemnumber is NULL/AND reserves.itemnumber is NOT NULL/; |
239 |
#$strsth=~ s/LEFT JOIN items ON items.biblionumber=reserves.biblionumber/LEFT JOIN items ON items.biblionumber=reserves.itemnumber/; |
240 |
#$sth = $dbh->prepare($strsth); |
241 |
#if (C4::Context->preference('IndependantBranches')){ |
242 |
# $sth->execute(C4::Context->userenv->{'branch'}); |
243 |
#} |
244 |
#else { |
245 |
# $sth->execute(); |
246 |
#} |
247 |
#while ( my $data = $sth->fetchrow_hashref ) { |
248 |
# $this=$data->{biblionumber}.":".$data->{borrowernumber}; |
249 |
# my @itemlist; |
250 |
# push( |
251 |
# @reservedata, |
252 |
# { |
253 |
# reservedate => format_date( $data->{l_reservedate} ), |
254 |
# priority => $data->{priority}, |
255 |
# name => $data->{l_patron}, |
256 |
# title => $data->{title}, |
257 |
# author => $data->{author}, |
258 |
# borrowernumber => $data->{borrowernumber}, |
259 |
# itemnum => $data->{itemnumber}, |
260 |
# phone => $data->{phone}, |
261 |
# email => $data->{email}, |
262 |
# biblionumber => $data->{biblionumber}, |
263 |
# statusw => ( $data->{found} eq "W" ), |
264 |
# statusf => ( $data->{found} eq "F" ), |
265 |
# holdingbranch => $data->{l_holdingbranch}, |
266 |
# branch => $data->{l_branch}, |
267 |
# itemcallnumber => $data->{l_itemcallnumber}, |
268 |
# notes => $data->{notes}, |
269 |
# notificationdate => $data->{notificationdate}, |
270 |
# reminderdate => $data->{reminderdate}, |
271 |
# count => $data->{icount}, |
272 |
# rcount => $data->{rcount}, |
273 |
# pullcount => $data->{icount} <= $data->{rcount} ? $data->{icount} : $data->{rcount}, |
274 |
# itype => $data->{l_itype}, |
275 |
# location => $data->{l_location}, |
276 |
# thisitemonly => 1, |
277 |
# |
278 |
# } |
279 |
# ); |
280 |
# $previous=$this; |
281 |
#} |
282 |
#$sth->finish; |
283 |
} |
193 |
} |
284 |
|
194 |
|
285 |
$template->param( |
195 |
$template->param( |
Lines 287-300
$template->param(
Link Here
|
287 |
from => $startdate, |
197 |
from => $startdate, |
288 |
to => $enddate, |
198 |
to => $enddate, |
289 |
run_report => $run_report, |
199 |
run_report => $run_report, |
290 |
report_page => $report_page, |
|
|
291 |
prev_results => $prev_results, |
292 |
next_results => $next_results, |
293 |
next_or_previous => $next_or_previous, |
294 |
reserveloop => \@reservedata, |
200 |
reserveloop => \@reservedata, |
295 |
"BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1, |
201 |
"BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1, |
296 |
DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), |
202 |
DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), |
297 |
dateformat => C4::Context->preference("dateformat"), |
203 |
dateformat => C4::Context->preference("dateformat"), |
298 |
); |
204 |
); |
299 |
|
205 |
|
300 |
output_html_with_http_headers $input, $cookie, $template->output; |
206 |
output_html_with_http_headers $input, $cookie, $template->output; |