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
18 # with Koha; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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
24 # The reserve pull lists *works* as long as not for indepencdant branches, I can fix!
27 #use warnings; FIXME - Bug 2505
32 use C4
::Dates qw
/format_date format_date_in_iso/;
34 use Date
::Calc qw
/Today Add_Delta_YMD/;
37 my $startdate=$input->param('from');
38 my $enddate=$input->param('to');
39 my $run_report=$input->param('run_report');
41 my $theme = $input->param('theme'); # only used if allowthemeoverride is set
43 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
45 template_name
=> "circ/pendingreserves.tmpl",
49 flagsrequired
=> { circulate
=> "circulate_remaining_permissions" },
67 my ( $year, $month, $day ) = Today
();
68 my $todaysdate = sprintf("%-04.4d-%-02.2d-%02.2d", $year, $month, $day);
69 my $yesterdaysdate = sprintf("%-04.4d-%-02.2d-%02.2d", Add_Delta_YMD
($year, $month, $day, 0, 0, -1));
70 # changed from delivered range of 10 years-yesterday to 2 days ago-today
71 # Find two days ago for the default shelf pull start and end dates
72 my $pastdate = sprintf("%-04.4d-%-02.2d-%02.2d", Add_Delta_YMD
($year, $month, $day, 0, 0, -2));
74 # Predefine the start and end dates if they are not already defined
75 $startdate =~ s/^\s+//;
76 $startdate =~ s/\s+$//;
79 # Check if null, should string match, if so set start and end date to yesterday
80 if (!defined($startdate) or $startdate eq "") {
81 $startdate = format_date
($pastdate);
83 if (!defined($enddate) or $enddate eq "") {
84 $enddate = format_date
($todaysdate);
90 my $dbh = C4
::Context
->dbh;
91 my $sqldatewhere = "";
92 $debug and warn format_date_in_iso
($startdate) . "\n" . format_date_in_iso
($enddate);
93 my @query_params = ();
95 $sqldatewhere .= " AND reservedate >= ?";
96 push @query_params, format_date_in_iso
($startdate);
99 $sqldatewhere .= " AND reservedate <= ?";
100 push @query_params, format_date_in_iso
($enddate);
104 "SELECT min(reservedate) as l_reservedate,
105 reserves.borrowernumber as borrowernumber,
106 GROUP_CONCAT(DISTINCT items.holdingbranch
107 ORDER BY items.itemnumber SEPARATOR '<br/>') l_holdingbranch,
108 reserves.biblionumber,
110 GROUP_CONCAT(DISTINCT reserves.branchcode
111 ORDER BY items.itemnumber SEPARATOR ', ') l_branch,
112 items.holdingbranch as branch,
113 GROUP_CONCAT(DISTINCT items.itype
114 ORDER BY items.itemnumber SEPARATOR '<br/>') l_itype,
115 GROUP_CONCAT(DISTINCT items.location
116 ORDER BY items.itemnumber SEPARATOR '<br/>') l_location,
117 GROUP_CONCAT(DISTINCT items.itemcallnumber
118 ORDER BY items.itemnumber SEPARATOR '<br/>') l_itemcallnumber,
119 GROUP_CONCAT(DISTINCT items.enumchron
120 ORDER BY items.itemnumber SEPARATOR '<br/>') l_enumchron,
121 GROUP_CONCAT(DISTINCT items.copynumber
122 ORDER BY items.itemnumber SEPARATOR '<br/>') l_copynumber,
127 max(priority) as priority,
131 count(DISTINCT items.itemnumber) as icount,
132 count(DISTINCT reserves.borrowernumber) as rcount
134 LEFT JOIN items ON items.biblionumber=reserves.biblionumber
135 LEFT JOIN biblio ON reserves.biblionumber=biblio.biblionumber
136 LEFT JOIN branchtransfers ON items.itemnumber=branchtransfers.itemnumber
137 LEFT JOIN issues ON items.itemnumber=issues.itemnumber
139 reserves.found IS NULL
141 AND (reserves.itemnumber IS NULL OR reserves.itemnumber = items.itemnumber)
142 AND items.itemnumber NOT IN (SELECT itemnumber FROM branchtransfers where datearrived IS NULL)
143 AND issues.itemnumber IS NULL
144 AND reserves.priority <> 0
145 AND notforloan = 0 AND damaged = 0 AND itemlost = 0 AND wthdrawn = 0
147 # GROUP BY reserves.biblionumber allows only items that are not checked out, else multiples occur when
148 # multiple patrons have a hold on an item
151 if (C4
::Context
->preference('IndependantBranches')){
152 $strsth .= " AND items.holdingbranch=? ";
153 push @query_params, C4
::Context
->userenv->{'branch'};
155 $strsth .= " GROUP BY reserves.biblionumber ORDER BY biblio.title ";
157 my $sth = $dbh->prepare($strsth);
158 $sth->execute(@query_params);
160 while ( my $data = $sth->fetchrow_hashref ) {
164 reservedate
=> format_date
( $data->{l_reservedate
} ),
165 priority
=> $data->{priority
},
166 name
=> $data->{l_patron
},
167 title
=> $data->{title
},
168 author
=> $data->{author
},
169 borrowernumber
=> $data->{borrowernumber
},
170 itemnum
=> $data->{itemnumber
},
171 phone
=> $data->{phone
},
172 email
=> $data->{email
},
173 biblionumber
=> $data->{biblionumber
},
174 statusw
=> ( $data->{found
} eq "W" ),
175 statusf
=> ( $data->{found
} eq "F" ),
176 holdingbranch
=> $data->{l_holdingbranch
},
177 branch
=> $data->{l_branch
},
178 itemcallnumber
=> $data->{l_itemcallnumber
},
179 enumchron
=> $data->{l_enumchron
},
180 copyno
=> $data->{l_copynumber
},
181 notes
=> $data->{notes
},
182 notificationdate
=> $data->{notificationdate
},
183 reminderdate
=> $data->{reminderdate
},
184 count
=> $data->{icount
},
185 rcount
=> $data->{rcount
},
186 pullcount
=> $data->{icount
} <= $data->{rcount
} ?
$data->{icount
} : $data->{rcount
},
187 itype
=> $data->{l_itype
},
188 location
=> $data->{l_location
}
196 todaysdate
=> format_date
($todaysdate),
199 run_report
=> $run_report,
200 reserveloop
=> \
@reservedata,
201 "BiblioDefaultView".C4
::Context
->preference("BiblioDefaultView") => 1,
202 DHTMLcalendar_dateformat
=> C4
::Dates
->DHTMLcalendar(),
203 dateformat
=> C4
::Context
->preference("dateformat"),
206 output_html_with_http_headers
$input, $cookie, $template->output;