|
Lines 31-40
use C4::Output;
Link Here
|
| 31 |
use C4::Dates qw/format_date/; |
31 |
use C4::Dates qw/format_date/; |
| 32 |
use C4::Context; |
32 |
use C4::Context; |
| 33 |
use C4::Members; |
33 |
use C4::Members; |
| 34 |
use C4::Branch; # GetBranches |
34 |
use C4::Branch; # GetBranches |
| 35 |
use C4::Overdues; |
35 |
use C4::Overdues; |
| 36 |
use C4::Debug; |
36 |
use C4::Debug; |
| 37 |
use Koha::DateUtils; |
37 |
use Koha::DateUtils; |
|
|
38 |
|
| 38 |
# use Data::Dumper; |
39 |
# use Data::Dumper; |
| 39 |
|
40 |
|
| 40 |
my $MAXIMUM_NUMBER_OF_RESERVES = C4::Context->preference("maxreserves"); |
41 |
my $MAXIMUM_NUMBER_OF_RESERVES = C4::Context->preference("maxreserves"); |
|
Lines 51-93
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
Link Here
|
| 51 |
} |
52 |
} |
| 52 |
); |
53 |
); |
| 53 |
|
54 |
|
| 54 |
my ($show_holds_count, $show_priority); |
55 |
my ( $show_holds_count, $show_priority ); |
| 55 |
for ( C4::Context->preference("OPACShowHoldQueueDetails") ) { |
56 |
for ( C4::Context->preference("OPACShowHoldQueueDetails") ) { |
| 56 |
m/holds/o and $show_holds_count = 1; |
57 |
m/holds/o and $show_holds_count = 1; |
| 57 |
m/priority/ and $show_priority = 1; |
58 |
m/priority/ and $show_priority = 1; |
| 58 |
} |
59 |
} |
| 59 |
|
60 |
|
| 60 |
sub get_out { |
61 |
sub get_out { |
| 61 |
output_html_with_http_headers(shift,shift,shift); # $query, $cookie, $template->output; |
62 |
output_html_with_http_headers( shift, shift, shift ) |
|
|
63 |
; # $query, $cookie, $template->output; |
| 62 |
exit; |
64 |
exit; |
| 63 |
} |
65 |
} |
| 64 |
|
66 |
|
| 65 |
# get borrower information .... |
67 |
# get borrower information .... |
| 66 |
my ( $borr ) = GetMemberDetails( $borrowernumber ); |
68 |
my ($borr) = GetMemberDetails($borrowernumber); |
| 67 |
|
69 |
|
| 68 |
# Pass through any reserve charge |
70 |
# Pass through any reserve charge |
| 69 |
if ($borr->{reservefee} > 0){ |
71 |
if ( $borr->{reservefee} > 0 ) { |
| 70 |
$template->param( RESERVE_CHARGE => sprintf("%.2f",$borr->{reservefee})); |
72 |
$template->param( |
|
|
73 |
RESERVE_CHARGE => sprintf( "%.2f", $borr->{reservefee} ) ); |
| 71 |
} |
74 |
} |
|
|
75 |
|
| 72 |
# get branches and itemtypes |
76 |
# get branches and itemtypes |
| 73 |
my $branches = GetBranches(); |
77 |
my $branches = GetBranches(); |
| 74 |
my $itemTypes = GetItemTypes(); |
78 |
my $itemTypes = GetItemTypes(); |
| 75 |
|
79 |
|
| 76 |
# There are two ways of calling this script, with a single biblio num |
80 |
# There are two ways of calling this script, with a single biblio num |
| 77 |
# or multiple biblio nums. |
81 |
# or multiple biblio nums. |
| 78 |
my $biblionumbers = $query->param('biblionumbers'); |
82 |
my $biblionumbers = $query->param('biblionumbers'); |
| 79 |
my $reserveMode = $query->param('reserve_mode'); |
83 |
my $reserveMode = $query->param('reserve_mode'); |
| 80 |
if ($reserveMode && ($reserveMode eq 'single')) { |
84 |
if ( $reserveMode && ( $reserveMode eq 'single' ) ) { |
| 81 |
my $bib = $query->param('single_bib'); |
85 |
my $bib = $query->param('single_bib'); |
| 82 |
$biblionumbers = "$bib/"; |
86 |
$biblionumbers = "$bib/"; |
| 83 |
} |
87 |
} |
| 84 |
if (! $biblionumbers) { |
88 |
if ( !$biblionumbers ) { |
| 85 |
$biblionumbers = $query->param('biblionumber'); |
89 |
$biblionumbers = $query->param('biblionumber'); |
| 86 |
} |
90 |
} |
| 87 |
|
91 |
|
| 88 |
if ((! $biblionumbers) && (! $query->param('place_reserve'))) { |
92 |
if ( ( !$biblionumbers ) && ( !$query->param('place_reserve') ) ) { |
| 89 |
$template->param(message=>1, no_biblionumber=>1); |
93 |
$template->param( message => 1, no_biblionumber => 1 ); |
| 90 |
&get_out($query, $cookie, $template->output); |
94 |
&get_out( $query, $cookie, $template->output ); |
| 91 |
} |
95 |
} |
| 92 |
|
96 |
|
| 93 |
# Pass the numbers to the page so they can be fed back |
97 |
# Pass the numbers to the page so they can be fed back |
|
Lines 97-120
$template->param( biblionumbers => $biblionumbers );
Link Here
|
| 97 |
|
101 |
|
| 98 |
# Each biblio number is suffixed with '/', e.g. "1/2/3/" |
102 |
# Each biblio number is suffixed with '/', e.g. "1/2/3/" |
| 99 |
my @biblionumbers = split /\//, $biblionumbers; |
103 |
my @biblionumbers = split /\//, $biblionumbers; |
| 100 |
if (($#biblionumbers < 0) && (! $query->param('place_reserve'))) { |
104 |
if ( ( $#biblionumbers < 0 ) && ( !$query->param('place_reserve') ) ) { |
|
|
105 |
|
| 101 |
# TODO: New message? |
106 |
# TODO: New message? |
| 102 |
$template->param(message=>1, no_biblionumber=>1); |
107 |
$template->param( message => 1, no_biblionumber => 1 ); |
| 103 |
&get_out($query, $cookie, $template->output); |
108 |
&get_out( $query, $cookie, $template->output ); |
| 104 |
} |
109 |
} |
| 105 |
|
110 |
|
| 106 |
# pass the pickup branch along.... |
111 |
# pass the pickup branch along.... |
| 107 |
my $pickupBranch = $query->param('branch') || $borr->{'branchcode'} || C4::Context->userenv->{branch} || '' ; |
112 |
my $pickupBranch = |
| 108 |
($branches->{$pickupBranch}) or $pickupBranch = ""; # Confirm branch is real |
113 |
$query->param('branch') |
|
|
114 |
|| $borr->{'branchcode'} |
| 115 |
|| C4::Context->userenv->{branch} |
| 116 |
|| ''; |
| 117 |
( $branches->{$pickupBranch} ) or $pickupBranch = ""; # Confirm branch is real |
| 109 |
$template->param( branch => $pickupBranch ); |
118 |
$template->param( branch => $pickupBranch ); |
| 110 |
|
119 |
|
| 111 |
# make branch selection options... |
120 |
# make branch selection options... |
| 112 |
my $branchloop = GetBranchesLoop($pickupBranch); |
121 |
my $branchloop = GetBranchesLoop($pickupBranch); |
| 113 |
|
122 |
|
| 114 |
# Is the person allowed to choose their branch |
123 |
# Is the person allowed to choose their branch |
| 115 |
my $OPACChooseBranch = (C4::Context->preference("OPACAllowUserToChooseBranch")) ? 1 : 0; |
124 |
my $OPACChooseBranch = |
|
|
125 |
( C4::Context->preference("OPACAllowUserToChooseBranch") ) ? 1 : 0; |
| 116 |
|
126 |
|
| 117 |
$template->param( choose_branch => $OPACChooseBranch); |
127 |
$template->param( choose_branch => $OPACChooseBranch ); |
| 118 |
|
128 |
|
| 119 |
# |
129 |
# |
| 120 |
# |
130 |
# |
|
Lines 122-129
$template->param( choose_branch => $OPACChooseBranch);
Link Here
|
| 122 |
# |
132 |
# |
| 123 |
# |
133 |
# |
| 124 |
|
134 |
|
| 125 |
my %biblioDataHash; # Hash of biblionumber to biblio/biblioitems record. |
135 |
my %biblioDataHash; # Hash of biblionumber to biblio/biblioitems record. |
| 126 |
my %itemInfoHash; # Hash of itemnumber to item info. |
136 |
my %itemInfoHash; # Hash of itemnumber to item info. |
| 127 |
foreach my $biblioNumber (@biblionumbers) { |
137 |
foreach my $biblioNumber (@biblionumbers) { |
| 128 |
|
138 |
|
| 129 |
my $biblioData = GetBiblioData($biblioNumber); |
139 |
my $biblioData = GetBiblioData($biblioNumber); |
|
Lines 131-157
foreach my $biblioNumber (@biblionumbers) {
Link Here
|
| 131 |
|
141 |
|
| 132 |
my @itemInfos = GetItemsInfo($biblioNumber); |
142 |
my @itemInfos = GetItemsInfo($biblioNumber); |
| 133 |
|
143 |
|
| 134 |
my $marcrecord= GetMarcBiblio($biblioNumber); |
144 |
my $marcrecord = GetMarcBiblio($biblioNumber); |
| 135 |
|
145 |
|
| 136 |
# flag indicating existence of at least one item linked via a host record |
146 |
# flag indicating existence of at least one item linked via a host record |
| 137 |
my $hostitemsflag; |
147 |
my $hostitemsflag; |
|
|
148 |
|
| 138 |
# adding items linked via host biblios |
149 |
# adding items linked via host biblios |
| 139 |
my @hostitemInfos = GetHostItemsInfo($marcrecord); |
150 |
my @hostitemInfos = GetHostItemsInfo($marcrecord); |
| 140 |
if (@hostitemInfos){ |
151 |
if (@hostitemInfos) { |
| 141 |
$hostitemsflag =1; |
152 |
$hostitemsflag = 1; |
| 142 |
push (@itemInfos,@hostitemInfos); |
153 |
push( @itemInfos, @hostitemInfos ); |
| 143 |
} |
154 |
} |
| 144 |
|
155 |
|
| 145 |
$biblioData->{itemInfos} = \@itemInfos; |
156 |
$biblioData->{itemInfos} = \@itemInfos; |
| 146 |
foreach my $itemInfo (@itemInfos) { |
157 |
foreach my $itemInfo (@itemInfos) { |
| 147 |
$itemInfoHash{$itemInfo->{itemnumber}} = $itemInfo; |
158 |
$itemInfoHash{ $itemInfo->{itemnumber} } = $itemInfo; |
| 148 |
} |
159 |
} |
| 149 |
|
160 |
|
| 150 |
# Compute the priority rank. |
161 |
# Compute the priority rank. |
| 151 |
my ( $rank, $reserves ) = |
162 |
my ( $rank, $reserves ) = GetReservesFromBiblionumber( $biblioNumber, 1 ); |
| 152 |
GetReservesFromBiblionumber( $biblioNumber, 1 ); |
|
|
| 153 |
$biblioData->{reservecount} = 1; # new reserve |
163 |
$biblioData->{reservecount} = 1; # new reserve |
| 154 |
foreach my $res (@{$reserves}) { |
164 |
foreach my $res ( @{$reserves} ) { |
| 155 |
my $found = $res->{found}; |
165 |
my $found = $res->{found}; |
| 156 |
if ( $found && $found eq 'W' ) { |
166 |
if ( $found && $found eq 'W' ) { |
| 157 |
$rank--; |
167 |
$rank--; |
|
Lines 173-190
foreach my $biblioNumber (@biblionumbers) {
Link Here
|
| 173 |
if ( $query->param('place_reserve') ) { |
183 |
if ( $query->param('place_reserve') ) { |
| 174 |
my $reserve_cnt = 0; |
184 |
my $reserve_cnt = 0; |
| 175 |
if ($MAXIMUM_NUMBER_OF_RESERVES) { |
185 |
if ($MAXIMUM_NUMBER_OF_RESERVES) { |
| 176 |
$reserve_cnt = GetReservesFromBorrowernumber( $borrowernumber ); |
186 |
$reserve_cnt = GetReservesFromBorrowernumber($borrowernumber); |
| 177 |
} |
187 |
} |
| 178 |
|
188 |
|
| 179 |
# List is composed of alternating biblio/item/branch |
189 |
# List is composed of alternating biblio/item/branch |
| 180 |
my $selectedItems = $query->param('selecteditems'); |
190 |
my $selectedItems = $query->param('selecteditems'); |
| 181 |
|
191 |
|
| 182 |
if ($query->param('reserve_mode') eq 'single') { |
192 |
if ( $query->param('reserve_mode') eq 'single' ) { |
|
|
193 |
|
| 183 |
# This indicates non-JavaScript mode, so there was |
194 |
# This indicates non-JavaScript mode, so there was |
| 184 |
# only a single biblio number selected. |
195 |
# only a single biblio number selected. |
| 185 |
my $bib = $query->param('single_bib'); |
196 |
my $bib = $query->param('single_bib'); |
| 186 |
my $item = $query->param("checkitem_$bib"); |
197 |
my $item = $query->param("checkitem_$bib"); |
| 187 |
if ($item eq 'any') { |
198 |
if ( $item eq 'any' ) { |
| 188 |
$item = ''; |
199 |
$item = ''; |
| 189 |
} |
200 |
} |
| 190 |
my $branch = $query->param('branch'); |
201 |
my $branch = $query->param('branch'); |
|
Lines 197-211
if ( $query->param('place_reserve') ) {
Link Here
|
| 197 |
# Make sure there is a biblionum/itemnum/branch triplet for each item. |
208 |
# Make sure there is a biblionum/itemnum/branch triplet for each item. |
| 198 |
# The itemnum can be 'any', meaning next available. |
209 |
# The itemnum can be 'any', meaning next available. |
| 199 |
my $selectionCount = @selectedItems; |
210 |
my $selectionCount = @selectedItems; |
| 200 |
if (($selectionCount == 0) || (($selectionCount % 3) != 0)) { |
211 |
if ( ( $selectionCount == 0 ) || ( ( $selectionCount % 3 ) != 0 ) ) { |
| 201 |
$template->param(message=>1, bad_data=>1); |
212 |
$template->param( message => 1, bad_data => 1 ); |
| 202 |
&get_out($query, $cookie, $template->output); |
213 |
&get_out( $query, $cookie, $template->output ); |
| 203 |
} |
214 |
} |
| 204 |
|
215 |
|
| 205 |
while (@selectedItems) { |
216 |
while (@selectedItems) { |
| 206 |
my $biblioNum = shift(@selectedItems); |
217 |
my $biblioNum = shift(@selectedItems); |
| 207 |
my $itemNum = shift(@selectedItems); |
218 |
my $itemNum = shift(@selectedItems); |
| 208 |
my $pickupLocation = shift(@selectedItems); # i.e., branch code, not name, |
219 |
my $pickupLocation = |
|
|
220 |
shift(@selectedItems); # i.e., branch code, not name, |
| 209 |
|
221 |
|
| 210 |
my $canreserve = 0; |
222 |
my $canreserve = 0; |
| 211 |
|
223 |
|
|
Lines 215-221
if ( $query->param('place_reserve') ) {
Link Here
|
| 215 |
$pickupLocation = $borr->{'branchcode'}; |
227 |
$pickupLocation = $borr->{'branchcode'}; |
| 216 |
} |
228 |
} |
| 217 |
|
229 |
|
| 218 |
#item may belong to a host biblio, if yes change biblioNum to hosts bilbionumber |
230 |
#item may belong to a host biblio, if yes change biblioNum to hosts bilbionumber |
| 219 |
if ( $itemNum ne '' ) { |
231 |
if ( $itemNum ne '' ) { |
| 220 |
my $hostbiblioNum = GetBiblionumberFromItemnumber($itemNum); |
232 |
my $hostbiblioNum = GetBiblionumberFromItemnumber($itemNum); |
| 221 |
if ( $hostbiblioNum ne $biblioNum ) { |
233 |
if ( $hostbiblioNum ne $biblioNum ) { |
|
Lines 236-243
if ( $query->param('place_reserve') ) {
Link Here
|
| 236 |
|
248 |
|
| 237 |
my $expiration_date = $query->param("expiration_date_$biblioNum"); |
249 |
my $expiration_date = $query->param("expiration_date_$biblioNum"); |
| 238 |
|
250 |
|
| 239 |
# If a specific item was selected and the pickup branch is the same as the |
251 |
# If a specific item was selected and the pickup branch is the same as the |
| 240 |
# holdingbranch, force the value $rank and $found. |
252 |
# holdingbranch, force the value $rank and $found. |
| 241 |
my $rank = $biblioData->{rank}; |
253 |
my $rank = $biblioData->{rank}; |
| 242 |
if ( $itemNum ne '' ) { |
254 |
if ( $itemNum ne '' ) { |
| 243 |
my $item = GetItem($itemNum); |
255 |
my $item = GetItem($itemNum); |
|
Lines 249-255
if ( $query->param('place_reserve') ) {
Link Here
|
| 249 |
} |
261 |
} |
| 250 |
|
262 |
|
| 251 |
# UseBranchTransferLimits checking. |
263 |
# UseBranchTransferLimits checking. |
|
|
264 |
<<<< <<< HEAD |
| 252 |
my ($transferOk, $message) = CheckBranchTransferAllowed( $pickupLocation, $item->{'holdingbranch'}, $item, undef ); |
265 |
my ($transferOk, $message) = CheckBranchTransferAllowed( $pickupLocation, $item->{'holdingbranch'}, $item, undef ); |
|
|
266 |
======= |
| 267 |
my ($transferOk, $message) = CanItemBeTransferred( $pickupLocation, $item->{'holdingbranch'}, $item, undef ); |
| 268 |
>>>>>>> Bug 7376 - Transfer limits should be checked at check-in |
| 253 |
if (! $transferOk) { |
269 |
if (! $transferOk) { |
| 254 |
$canreserve = 0; |
270 |
$canreserve = 0; |
| 255 |
} |
271 |
} |
|
Lines 262-608
if ( $query->param('place_reserve') ) {
Link Here
|
| 262 |
} |
278 |
} |
| 263 |
my $notes = $query->param('notes_'.$biblioNum)||''; |
279 |
my $notes = $query->param('notes_'.$biblioNum)||''; |
| 264 |
|
280 |
|
| 265 |
if ( $MAXIMUM_NUMBER_OF_RESERVES |
281 |
if ( $MAXIMUM_NUMBER_OF_RESERVES |
| 266 |
&& $reserve_cnt >= $MAXIMUM_NUMBER_OF_RESERVES ) |
282 |
&& $reserve_cnt >= $MAXIMUM_NUMBER_OF_RESERVES ) |
| 267 |
{ |
283 |
{ |
| 268 |
$canreserve = 0; |
284 |
$canreserve = 0; |
| 269 |
} |
285 |
} |
| 270 |
|
286 |
|
| 271 |
# Here we actually do the reserveration. Stage 3. |
287 |
# Here we actually do the reserveration. Stage 3. |
| 272 |
if ($canreserve) { |
288 |
if ($canreserve) { |
| 273 |
AddReserve( |
289 |
AddReserve( |
| 274 |
$pickupLocation, $borrowernumber, |
290 |
$pickupLocation, $borrowernumber, |
| 275 |
$biblioNum, 'a', |
291 |
$biblioNum, 'a', |
| 276 |
[$biblioNum], $rank, |
292 |
[$biblioNum], $rank, |
| 277 |
$startdate, $expiration_date, |
293 |
$startdate, $expiration_date, |
| 278 |
$notes, $biblioData->{title}, |
294 |
$notes, $biblioData->{title}, |
| 279 |
$itemNum, $found |
295 |
$itemNum, $found |
| 280 |
); |
296 |
); |
| 281 |
++$reserve_cnt; |
297 |
++$reserve_cnt; |
|
|
298 |
} |
| 282 |
} |
299 |
} |
| 283 |
} |
|
|
| 284 |
|
300 |
|
| 285 |
print $query->redirect("/cgi-bin/koha/opac-user.pl#opac-user-holds"); |
301 |
print $query->redirect("/cgi-bin/koha/opac-user.pl#opac-user-holds"); |
| 286 |
exit; |
302 |
exit; |
| 287 |
} |
303 |
} |
| 288 |
|
304 |
|
| 289 |
# |
305 |
# |
| 290 |
# |
306 |
# |
| 291 |
# Here we check that the borrower can actually make reserves Stage 1. |
307 |
# Here we check that the borrower can actually make reserves Stage 1. |
| 292 |
# |
308 |
# |
| 293 |
# |
309 |
# |
| 294 |
my $noreserves = 0; |
310 |
my $noreserves = 0; |
| 295 |
my $maxoutstanding = C4::Context->preference("maxoutstanding"); |
311 |
my $maxoutstanding = C4::Context->preference("maxoutstanding"); |
| 296 |
$template->param( noreserve => 1 ) unless $maxoutstanding; |
312 |
$template->param( noreserve => 1 ) unless $maxoutstanding; |
| 297 |
if ( $borr->{'amountoutstanding'} && ($borr->{'amountoutstanding'} > $maxoutstanding) ) { |
313 |
if ( $borr->{'amountoutstanding'} |
| 298 |
my $amount = sprintf "\$%.02f", $borr->{'amountoutstanding'}; |
314 |
&& ( $borr->{'amountoutstanding'} > $maxoutstanding ) ) |
| 299 |
$template->param( message => 1 ); |
315 |
{ |
| 300 |
$noreserves = 1; |
316 |
my $amount = sprintf "\$%.02f", $borr->{'amountoutstanding'}; |
| 301 |
$template->param( too_much_oweing => $amount ); |
317 |
$template->param( message => 1 ); |
| 302 |
} |
318 |
$noreserves = 1; |
| 303 |
if ( $borr->{gonenoaddress} && ($borr->{gonenoaddress} == 1) ) { |
319 |
$template->param( too_much_oweing => $amount ); |
| 304 |
$noreserves = 1; |
320 |
} |
| 305 |
$template->param( |
321 |
if ( $borr->{gonenoaddress} && ( $borr->{gonenoaddress} == 1 ) ) { |
| 306 |
message => 1, |
322 |
$noreserves = 1; |
| 307 |
GNA => 1 |
323 |
$template->param( |
| 308 |
); |
324 |
message => 1, |
| 309 |
} |
325 |
GNA => 1 |
| 310 |
if ( $borr->{lost} && ($borr->{lost} == 1) ) { |
326 |
); |
| 311 |
$noreserves = 1; |
327 |
} |
| 312 |
$template->param( |
328 |
if ( $borr->{lost} && ( $borr->{lost} == 1 ) ) { |
| 313 |
message => 1, |
329 |
$noreserves = 1; |
| 314 |
lost => 1 |
330 |
$template->param( |
| 315 |
); |
331 |
message => 1, |
| 316 |
} |
332 |
lost => 1 |
| 317 |
if ( $borr->{'debarred'} ) { |
333 |
); |
| 318 |
$noreserves = 1; |
334 |
} |
| 319 |
$template->param( |
335 |
if ( $borr->{'debarred'} ) { |
| 320 |
message => 1, |
336 |
$noreserves = 1; |
| 321 |
debarred => 1 |
337 |
$template->param( |
| 322 |
); |
338 |
message => 1, |
| 323 |
} |
339 |
debarred => 1 |
|
|
340 |
); |
| 341 |
} |
| 324 |
|
342 |
|
| 325 |
my @reserves = GetReservesFromBorrowernumber( $borrowernumber ); |
343 |
my @reserves = GetReservesFromBorrowernumber($borrowernumber); |
| 326 |
$template->param( RESERVES => \@reserves ); |
344 |
$template->param( RESERVES => \@reserves ); |
| 327 |
if ( $MAXIMUM_NUMBER_OF_RESERVES && (scalar(@reserves) >= $MAXIMUM_NUMBER_OF_RESERVES) ) { |
345 |
if ( $MAXIMUM_NUMBER_OF_RESERVES |
| 328 |
$template->param( message => 1 ); |
346 |
&& ( scalar(@reserves) >= $MAXIMUM_NUMBER_OF_RESERVES ) ) |
| 329 |
$noreserves = 1; |
347 |
{ |
| 330 |
$template->param( too_many_reserves => scalar(@reserves)); |
348 |
$template->param( message => 1 ); |
| 331 |
} |
349 |
$noreserves = 1; |
| 332 |
foreach my $res (@reserves) { |
350 |
$template->param( too_many_reserves => scalar(@reserves) ); |
| 333 |
foreach my $biblionumber (@biblionumbers) { |
351 |
} |
| 334 |
if ( $res->{'biblionumber'} == $biblionumber && $res->{'borrowernumber'} == $borrowernumber) { |
352 |
foreach my $res (@reserves) { |
| 335 |
# $template->param( message => 1 ); |
353 |
foreach my $biblionumber (@biblionumbers) { |
| 336 |
# $noreserves = 1; |
354 |
if ( $res->{'biblionumber'} == $biblionumber |
| 337 |
# $template->param( already_reserved => 1 ); |
355 |
&& $res->{'borrowernumber'} == $borrowernumber ) |
| 338 |
$biblioDataHash{$biblionumber}->{already_reserved} = 1; |
356 |
{ |
|
|
357 |
# $template->param( message => 1 ); |
| 358 |
# $noreserves = 1; |
| 359 |
# $template->param( already_reserved => 1 ); |
| 360 |
$biblioDataHash{$biblionumber}->{already_reserved} = 1; |
| 361 |
} |
| 339 |
} |
362 |
} |
| 340 |
} |
363 |
} |
| 341 |
} |
|
|
| 342 |
|
364 |
|
| 343 |
unless ($noreserves) { |
365 |
unless ($noreserves) { |
| 344 |
$template->param( select_item_types => 1 ); |
366 |
$template->param( select_item_types => 1 ); |
| 345 |
} |
367 |
} |
| 346 |
|
368 |
|
|
|
369 |
# |
| 370 |
# |
| 371 |
# Build the template parameters that will show the info |
| 372 |
# and items for each biblionumber. |
| 373 |
# |
| 374 |
# |
| 375 |
my $notforloan_label_of = get_notforloan_label_of(); |
| 347 |
|
376 |
|
| 348 |
# |
377 |
my $biblioLoop = []; |
| 349 |
# |
378 |
my $numBibsAvailable = 0; |
| 350 |
# Build the template parameters that will show the info |
379 |
my $itemdata_enumchron = 0; |
| 351 |
# and items for each biblionumber. |
380 |
my $anyholdable = 0; |
| 352 |
# |
381 |
my $itemLevelTypes = C4::Context->preference('item-level_itypes'); |
| 353 |
# |
382 |
$template->param( 'item_level_itypes' => $itemLevelTypes ); |
| 354 |
my $notforloan_label_of = get_notforloan_label_of(); |
|
|
| 355 |
|
| 356 |
my $biblioLoop = []; |
| 357 |
my $numBibsAvailable = 0; |
| 358 |
my $itemdata_enumchron = 0; |
| 359 |
my $anyholdable = 0; |
| 360 |
my $itemLevelTypes = C4::Context->preference('item-level_itypes'); |
| 361 |
$template->param('item_level_itypes' => $itemLevelTypes); |
| 362 |
|
| 363 |
foreach my $biblioNum (@biblionumbers) { |
| 364 |
|
| 365 |
my $record = GetMarcBiblio($biblioNum); |
| 366 |
# Init the bib item with the choices for branch pickup |
| 367 |
my %biblioLoopIter = ( branchloop => $branchloop ); |
| 368 |
|
| 369 |
# Get relevant biblio data. |
| 370 |
my $biblioData = $biblioDataHash{$biblioNum}; |
| 371 |
if (! $biblioData) { |
| 372 |
$template->param(message=>1, bad_biblionumber=>$biblioNum); |
| 373 |
&get_out($query, $cookie, $template->output); |
| 374 |
} |
| 375 |
|
383 |
|
| 376 |
$biblioLoopIter{biblionumber} = $biblioData->{biblionumber}; |
384 |
foreach my $biblioNum (@biblionumbers) { |
| 377 |
$biblioLoopIter{title} = $biblioData->{title}; |
|
|
| 378 |
$biblioLoopIter{subtitle} = GetRecordValue('subtitle', $record, GetFrameworkCode($biblioData->{biblionumber})); |
| 379 |
$biblioLoopIter{author} = $biblioData->{author}; |
| 380 |
$biblioLoopIter{rank} = $biblioData->{rank}; |
| 381 |
$biblioLoopIter{reservecount} = $biblioData->{reservecount}; |
| 382 |
$biblioLoopIter{already_reserved} = $biblioData->{already_reserved}; |
| 383 |
$biblioLoopIter{mandatorynotes}=0; #FIXME: For future use |
| 384 |
|
| 385 |
if (!$itemLevelTypes && $biblioData->{itemtype}) { |
| 386 |
$biblioLoopIter{description} = $itemTypes->{$biblioData->{itemtype}}{description}; |
| 387 |
$biblioLoopIter{imageurl} = getitemtypeimagesrc() . "/". $itemTypes->{$biblioData->{itemtype}}{imageurl}; |
| 388 |
} |
| 389 |
|
385 |
|
| 390 |
foreach my $itemInfo (@{$biblioData->{itemInfos}}) { |
386 |
my $record = GetMarcBiblio($biblioNum); |
| 391 |
$debug and warn $itemInfo->{'notforloan'}; |
|
|
| 392 |
|
387 |
|
| 393 |
# Get reserve fee. |
388 |
# Init the bib item with the choices for branch pickup |
| 394 |
my $fee = GetReserveFee(undef, $borrowernumber, $itemInfo->{'biblionumber'}, 'a', |
389 |
my %biblioLoopIter = ( branchloop => $branchloop ); |
| 395 |
( $itemInfo->{'biblioitemnumber'} ) ); |
|
|
| 396 |
$itemInfo->{'reservefee'} = sprintf "%.02f", ($fee ? $fee : 0.0); |
| 397 |
|
390 |
|
| 398 |
if ($itemLevelTypes && $itemInfo->{itype}) { |
391 |
# Get relevant biblio data. |
| 399 |
$itemInfo->{description} = $itemTypes->{$itemInfo->{itype}}{description}; |
392 |
my $biblioData = $biblioDataHash{$biblioNum}; |
| 400 |
$itemInfo->{imageurl} = getitemtypeimagesrc() . "/". $itemTypes->{$itemInfo->{itype}}{imageurl}; |
393 |
if ( !$biblioData ) { |
|
|
394 |
$template->param( message => 1, bad_biblionumber => $biblioNum ); |
| 395 |
&get_out( $query, $cookie, $template->output ); |
| 401 |
} |
396 |
} |
| 402 |
|
397 |
|
| 403 |
if (!$itemInfo->{'notforloan'} && !($itemInfo->{'itemnotforloan'} > 0)) { |
398 |
$biblioLoopIter{biblionumber} = $biblioData->{biblionumber}; |
| 404 |
$biblioLoopIter{forloan} = 1; |
399 |
$biblioLoopIter{title} = $biblioData->{title}; |
|
|
400 |
$biblioLoopIter{subtitle} = |
| 401 |
GetRecordValue( 'subtitle', $record, |
| 402 |
GetFrameworkCode( $biblioData->{biblionumber} ) ); |
| 403 |
$biblioLoopIter{author} = $biblioData->{author}; |
| 404 |
$biblioLoopIter{rank} = $biblioData->{rank}; |
| 405 |
$biblioLoopIter{reservecount} = $biblioData->{reservecount}; |
| 406 |
$biblioLoopIter{already_reserved} = $biblioData->{already_reserved}; |
| 407 |
$biblioLoopIter{mandatorynotes} = 0; #FIXME: For future use |
| 408 |
|
| 409 |
if ( !$itemLevelTypes && $biblioData->{itemtype} ) { |
| 410 |
$biblioLoopIter{description} = |
| 411 |
$itemTypes->{ $biblioData->{itemtype} }{description}; |
| 412 |
$biblioLoopIter{imageurl} = getitemtypeimagesrc() . "/" |
| 413 |
. $itemTypes->{ $biblioData->{itemtype} }{imageurl}; |
| 405 |
} |
414 |
} |
| 406 |
} |
|
|
| 407 |
|
415 |
|
| 408 |
#Collect the amout of items that pass the CheckBranchTransferAllowed-check. This is needed to tell |
416 |
foreach my $itemInfo ( @{ $biblioData->{itemInfos} } ) { |
| 409 |
# the user if some or all Items cannot be transferred to the pickup location. |
417 |
$debug and warn $itemInfo->{'notforloan'}; |
| 410 |
my $branchTransferableItemsCount = 0; |
418 |
|
| 411 |
|
419 |
# Get reserve fee. |
| 412 |
$biblioLoopIter{itemLoop} = []; |
420 |
my $fee = |
| 413 |
my $numCopiesAvailable = 0; |
421 |
GetReserveFee( undef, $borrowernumber, |
| 414 |
foreach my $itemInfo (@{$biblioData->{itemInfos}}) { |
422 |
$itemInfo->{'biblionumber'}, |
| 415 |
my $itemNum = $itemInfo->{itemnumber}; |
423 |
'a', ( $itemInfo->{'biblioitemnumber'} ) ); |
| 416 |
my $itemLoopIter = {}; |
424 |
$itemInfo->{'reservefee'} = sprintf "%.02f", ( $fee ? $fee : 0.0 ); |
| 417 |
|
425 |
|
| 418 |
$itemLoopIter->{itemnumber} = $itemNum; |
426 |
if ( $itemLevelTypes && $itemInfo->{itype} ) { |
| 419 |
$itemLoopIter->{barcode} = $itemInfo->{barcode}; |
427 |
$itemInfo->{description} = |
| 420 |
$itemLoopIter->{homeBranchName} = $branches->{$itemInfo->{homebranch}}{branchname}; |
428 |
$itemTypes->{ $itemInfo->{itype} }{description}; |
| 421 |
$itemLoopIter->{callNumber} = $itemInfo->{itemcallnumber}; |
429 |
$itemInfo->{imageurl} = getitemtypeimagesrc() . "/" |
| 422 |
$itemLoopIter->{enumchron} = $itemInfo->{enumchron}; |
430 |
. $itemTypes->{ $itemInfo->{itype} }{imageurl}; |
| 423 |
$itemLoopIter->{copynumber} = $itemInfo->{copynumber}; |
431 |
} |
| 424 |
if ($itemLevelTypes) { |
|
|
| 425 |
$itemLoopIter->{description} = $itemInfo->{description}; |
| 426 |
$itemLoopIter->{imageurl} = $itemInfo->{imageurl}; |
| 427 |
} |
| 428 |
|
432 |
|
| 429 |
# If the holdingbranch is different than the homebranch, we show the |
433 |
if ( !$itemInfo->{'notforloan'} |
| 430 |
# holdingbranch of the document too. |
434 |
&& !( $itemInfo->{'itemnotforloan'} > 0 ) ) |
| 431 |
if ( $itemInfo->{homebranch} ne $itemInfo->{holdingbranch} ) { |
435 |
{ |
| 432 |
$itemLoopIter->{holdingBranchName} = |
436 |
$biblioLoopIter{forloan} = 1; |
| 433 |
$branches->{ $itemInfo->{holdingbranch} }{branchname}; |
437 |
} |
| 434 |
} |
438 |
} |
| 435 |
|
439 |
|
| 436 |
# If the item is currently on loan, we display its return date and |
440 |
#Collect the amout of items that pass the CanItemBeTransferred-check. This is needed to tell |
| 437 |
# change the background color. |
441 |
# the user if some or all Items cannot be transferred to the pickup location. |
| 438 |
my $issues= GetItemIssue($itemNum); |
442 |
my $branchTransferableItemsCount = 0; |
| 439 |
if ( $issues->{'date_due'} ) { |
443 |
|
| 440 |
$itemLoopIter->{dateDue} = format_sqlduedatetime($issues->{date_due}); |
444 |
$biblioLoopIter{itemLoop} = []; |
| 441 |
$itemLoopIter->{backgroundcolor} = 'onloan'; |
445 |
my $numCopiesAvailable = 0; |
| 442 |
} |
446 |
foreach my $itemInfo ( @{ $biblioData->{itemInfos} } ) { |
|
|
447 |
my $itemNum = $itemInfo->{itemnumber}; |
| 448 |
my $itemLoopIter = {}; |
| 449 |
|
| 450 |
$itemLoopIter->{itemnumber} = $itemNum; |
| 451 |
$itemLoopIter->{barcode} = $itemInfo->{barcode}; |
| 452 |
$itemLoopIter->{homeBranchName} = |
| 453 |
$branches->{ $itemInfo->{homebranch} }{branchname}; |
| 454 |
$itemLoopIter->{callNumber} = $itemInfo->{itemcallnumber}; |
| 455 |
$itemLoopIter->{enumchron} = $itemInfo->{enumchron}; |
| 456 |
$itemLoopIter->{copynumber} = $itemInfo->{copynumber}; |
| 457 |
if ($itemLevelTypes) { |
| 458 |
$itemLoopIter->{description} = $itemInfo->{description}; |
| 459 |
$itemLoopIter->{imageurl} = $itemInfo->{imageurl}; |
| 460 |
} |
| 443 |
|
461 |
|
| 444 |
# checking reserve |
462 |
# If the holdingbranch is different than the homebranch, we show the |
| 445 |
my ($reservedate,$reservedfor,$expectedAt) = GetReservesFromItemnumber($itemNum); |
463 |
# holdingbranch of the document too. |
| 446 |
my $ItemBorrowerReserveInfo = GetMemberDetails( $reservedfor, 0); |
464 |
if ( $itemInfo->{homebranch} ne $itemInfo->{holdingbranch} ) { |
|
|
465 |
$itemLoopIter->{holdingBranchName} = |
| 466 |
$branches->{ $itemInfo->{holdingbranch} }{branchname}; |
| 467 |
} |
| 447 |
|
468 |
|
| 448 |
# the item could be reserved for this borrower vi a host record, flag this |
469 |
# If the item is currently on loan, we display its return date and |
| 449 |
if ($reservedfor eq $borrowernumber){ |
470 |
# change the background color. |
| 450 |
$itemLoopIter->{already_reserved} = 1; |
471 |
my $issues = GetItemIssue($itemNum); |
| 451 |
} |
472 |
if ( $issues->{'date_due'} ) { |
|
|
473 |
$itemLoopIter->{dateDue} = |
| 474 |
format_sqlduedatetime( $issues->{date_due} ); |
| 475 |
$itemLoopIter->{backgroundcolor} = 'onloan'; |
| 476 |
} |
| 452 |
|
477 |
|
| 453 |
if ( defined $reservedate ) { |
478 |
# checking reserve |
| 454 |
$itemLoopIter->{backgroundcolor} = 'reserved'; |
479 |
my ( $reservedate, $reservedfor, $expectedAt ) = |
| 455 |
$itemLoopIter->{reservedate} = format_date($reservedate); |
480 |
GetReservesFromItemnumber($itemNum); |
| 456 |
$itemLoopIter->{ReservedForBorrowernumber} = $reservedfor; |
481 |
my $ItemBorrowerReserveInfo = GetMemberDetails( $reservedfor, 0 ); |
| 457 |
$itemLoopIter->{ReservedForSurname} = $ItemBorrowerReserveInfo->{'surname'}; |
|
|
| 458 |
$itemLoopIter->{ReservedForFirstname} = $ItemBorrowerReserveInfo->{'firstname'}; |
| 459 |
$itemLoopIter->{ExpectedAtLibrary} = $expectedAt; |
| 460 |
} |
| 461 |
|
482 |
|
| 462 |
$itemLoopIter->{notforloan} = $itemInfo->{notforloan}; |
483 |
# the item could be reserved for this borrower vi a host record, flag this |
| 463 |
$itemLoopIter->{itemnotforloan} = $itemInfo->{itemnotforloan}; |
484 |
if ( $reservedfor eq $borrowernumber ) { |
|
|
485 |
$itemLoopIter->{already_reserved} = 1; |
| 486 |
} |
| 464 |
|
487 |
|
| 465 |
# Management of the notforloan document |
488 |
if ( defined $reservedate ) { |
| 466 |
if ( $itemLoopIter->{notforloan} || $itemLoopIter->{itemnotforloan}) { |
489 |
$itemLoopIter->{backgroundcolor} = 'reserved'; |
| 467 |
$itemLoopIter->{backgroundcolor} = 'other'; |
490 |
$itemLoopIter->{reservedate} = format_date($reservedate); |
| 468 |
$itemLoopIter->{notforloanvalue} = |
491 |
$itemLoopIter->{ReservedForBorrowernumber} = $reservedfor; |
| 469 |
$notforloan_label_of->{ $itemLoopIter->{notforloan} }; |
492 |
$itemLoopIter->{ReservedForSurname} = |
| 470 |
} |
493 |
$ItemBorrowerReserveInfo->{'surname'}; |
|
|
494 |
$itemLoopIter->{ReservedForFirstname} = |
| 495 |
$ItemBorrowerReserveInfo->{'firstname'}; |
| 496 |
$itemLoopIter->{ExpectedAtLibrary} = $expectedAt; |
| 497 |
} |
| 471 |
|
498 |
|
| 472 |
# Management of lost or long overdue items |
499 |
$itemLoopIter->{notforloan} = $itemInfo->{notforloan}; |
| 473 |
if ( $itemInfo->{itemlost} ) { |
500 |
$itemLoopIter->{itemnotforloan} = $itemInfo->{itemnotforloan}; |
| 474 |
|
501 |
|
| 475 |
# FIXME localized strings should never be in Perl code |
502 |
# Management of the notforloan document |
| 476 |
$itemLoopIter->{message} = |
503 |
if ( $itemLoopIter->{notforloan} |
| 477 |
$itemInfo->{itemlost} == 1 ? "(lost)" |
504 |
|| $itemLoopIter->{itemnotforloan} ) |
| 478 |
: $itemInfo->{itemlost} == 2 ? "(long overdue)" |
505 |
{ |
| 479 |
: ""; |
506 |
$itemLoopIter->{backgroundcolor} = 'other'; |
| 480 |
$itemInfo->{backgroundcolor} = 'other'; |
507 |
$itemLoopIter->{notforloanvalue} = |
| 481 |
} |
508 |
$notforloan_label_of->{ $itemLoopIter->{notforloan} }; |
|
|
509 |
} |
| 482 |
|
510 |
|
| 483 |
# Check of the transfered documents |
511 |
# Management of lost or long overdue items |
| 484 |
my ( $transfertwhen, $transfertfrom, $transfertto ) = |
512 |
if ( $itemInfo->{itemlost} ) { |
| 485 |
GetTransfers($itemNum); |
|
|
| 486 |
if ( $transfertwhen && ($transfertwhen ne '') ) { |
| 487 |
$itemLoopIter->{transfertwhen} = format_date($transfertwhen); |
| 488 |
$itemLoopIter->{transfertfrom} = |
| 489 |
$branches->{$transfertfrom}{branchname}; |
| 490 |
$itemLoopIter->{transfertto} = $branches->{$transfertto}{branchname}; |
| 491 |
$itemLoopIter->{nocancel} = 1; |
| 492 |
} |
| 493 |
|
513 |
|
| 494 |
# if the items belongs to a host record, show link to host record |
514 |
# FIXME localized strings should never be in Perl code |
| 495 |
if ($itemInfo->{biblionumber} ne $biblioNum){ |
515 |
$itemLoopIter->{message} = |
| 496 |
$biblioLoopIter{hostitemsflag} = 1; |
516 |
$itemInfo->{itemlost} == 1 ? "(lost)" |
| 497 |
$itemLoopIter->{hostbiblionumber} = $itemInfo->{biblionumber}; |
517 |
: $itemInfo->{itemlost} == 2 ? "(long overdue)" |
| 498 |
$itemLoopIter->{hosttitle} = GetBiblioData($itemInfo->{biblionumber})->{title}; |
518 |
: ""; |
| 499 |
} |
519 |
$itemInfo->{backgroundcolor} = 'other'; |
|
|
520 |
} |
| 500 |
|
521 |
|
| 501 |
# If there is no loan, return and transfer, we show a checkbox. |
522 |
# Check of the transfered documents |
| 502 |
$itemLoopIter->{notforloan} = $itemLoopIter->{notforloan} || 0; |
523 |
my ( $transfertwhen, $transfertfrom, $transfertto ) = |
|
|
524 |
GetTransfers($itemNum); |
| 525 |
if ( $transfertwhen && ( $transfertwhen ne '' ) ) { |
| 526 |
$itemLoopIter->{transfertwhen} = format_date($transfertwhen); |
| 527 |
$itemLoopIter->{transfertfrom} = |
| 528 |
$branches->{$transfertfrom}{branchname}; |
| 529 |
$itemLoopIter->{transfertto} = |
| 530 |
$branches->{$transfertto}{branchname}; |
| 531 |
$itemLoopIter->{nocancel} = 1; |
| 532 |
} |
| 503 |
|
533 |
|
| 504 |
my $branch = GetReservesControlBranch( $itemInfo, $borr ); |
534 |
# if the items belongs to a host record, show link to host record |
|
|
535 |
if ( $itemInfo->{biblionumber} ne $biblioNum ) { |
| 536 |
$biblioLoopIter{hostitemsflag} = 1; |
| 537 |
$itemLoopIter->{hostbiblionumber} = $itemInfo->{biblionumber}; |
| 538 |
$itemLoopIter->{hosttitle} = |
| 539 |
GetBiblioData( $itemInfo->{biblionumber} )->{title}; |
| 540 |
} |
| 505 |
|
541 |
|
| 506 |
my $branchitemrule = GetBranchItemRule( $branch, $itemInfo->{'itype'} ); |
542 |
# If there is no loan, return and transfer, we show a checkbox. |
| 507 |
my $policy_holdallowed = 1; |
543 |
$itemLoopIter->{notforloan} = $itemLoopIter->{notforloan} || 0; |
| 508 |
|
544 |
|
| 509 |
if ( $branchitemrule->{'holdallowed'} == 0 || |
545 |
my $branch = GetReservesControlBranch( $itemInfo, $borr ); |
| 510 |
( $branchitemrule->{'holdallowed'} == 1 && $borr->{'branchcode'} ne $itemInfo->{'homebranch'} ) ) { |
|
|
| 511 |
$policy_holdallowed = 0; |
| 512 |
} |
| 513 |
|
546 |
|
| 514 |
if (IsAvailableForItemLevelRequest($itemNum) and $policy_holdallowed and CanItemBeReserved($borrowernumber,$itemNum) and ($itemLoopIter->{already_reserved} ne 1)) { |
547 |
my $branchitemrule = |
|
|
548 |
GetBranchItemRule( $branch, $itemInfo->{'itype'} ); |
| 549 |
my $policy_holdallowed = 1; |
| 515 |
|
550 |
|
| 516 |
$itemLoopIter->{available} = 1; |
551 |
if ( |
| 517 |
$numCopiesAvailable++; |
552 |
$branchitemrule->{'holdallowed'} == 0 |
|
|
553 |
|| ( $branchitemrule->{'holdallowed'} == 1 |
| 554 |
&& $borr->{'branchcode'} ne $itemInfo->{'homebranch'} ) |
| 555 |
) |
| 556 |
{ |
| 557 |
$policy_holdallowed = 0; |
| 558 |
} |
| 518 |
|
559 |
|
| 519 |
#Check for UseBranchTransferLimit. $numCopiesAvailable is incremented because this Item |
560 |
if ( IsAvailableForItemLevelRequest($itemNum) |
| 520 |
# could still be available from another pickup location |
561 |
and $policy_holdallowed |
| 521 |
my ($transferOk, $errorMsg) = CheckBranchTransferAllowed( $pickupBranch, undef, GetItem($itemNum), undef ); |
562 |
and CanItemBeReserved( $borrowernumber, $itemNum ) |
| 522 |
if (! $transferOk) { |
563 |
and ( $itemLoopIter->{already_reserved} ne 1 ) ) |
| 523 |
$itemLoopIter->{available} = 0; |
564 |
{ |
| 524 |
$itemLoopIter->{branchTransferBlocked} = 1; |
565 |
|
|
|
566 |
$itemLoopIter->{available} = 1; |
| 567 |
$numCopiesAvailable++; |
| 568 |
|
| 569 |
#Check for UseBranchTransferLimit. $numCopiesAvailable is incremented because this Item |
| 570 |
# could still be available from another pickup location |
| 571 |
my ( $transferOk, $errorMsg ) = |
| 572 |
CanItemBeTransferred( $pickupBranch, undef, |
| 573 |
GetItem($itemNum), undef ); |
| 574 |
if ( !$transferOk ) { |
| 575 |
$itemLoopIter->{available} = 0; |
| 576 |
$itemLoopIter->{branchTransferBlocked} = 1; |
| 577 |
} |
| 578 |
else { |
| 579 |
$branchTransferableItemsCount++; |
| 580 |
} |
| 581 |
} |
| 582 |
|
| 583 |
# FIXME: move this to a pm |
| 584 |
my $dbh = C4::Context->dbh; |
| 585 |
my $sth2 = $dbh->prepare( |
| 586 |
"SELECT * FROM reserves WHERE borrowernumber=? AND itemnumber=? AND found='W'" |
| 587 |
); |
| 588 |
$sth2->execute( $itemLoopIter->{ReservedForBorrowernumber}, |
| 589 |
$itemNum ); |
| 590 |
while ( my $wait_hashref = $sth2->fetchrow_hashref ) { |
| 591 |
$itemLoopIter->{waitingdate} = |
| 592 |
format_date( $wait_hashref->{waitingdate} ); |
| 525 |
} |
593 |
} |
| 526 |
else { |
594 |
$itemLoopIter->{imageurl} = getitemtypeimagelocation( 'opac', |
| 527 |
$branchTransferableItemsCount++; |
595 |
$itemTypes->{ $itemInfo->{itype} }{imageurl} ); |
|
|
596 |
|
| 597 |
# Show serial enumeration when needed |
| 598 |
if ( $itemLoopIter->{enumchron} ) { |
| 599 |
$itemdata_enumchron = 1; |
| 528 |
} |
600 |
} |
|
|
601 |
|
| 602 |
push @{ $biblioLoopIter{itemLoop} }, $itemLoopIter; |
| 529 |
} |
603 |
} |
|
|
604 |
$template->param( itemdata_enumchron => $itemdata_enumchron ); |
| 530 |
|
605 |
|
| 531 |
# FIXME: move this to a pm |
606 |
## Set the behaviour flags for the template |
| 532 |
my $dbh = C4::Context->dbh; |
607 |
if ( $numCopiesAvailable > 0 ) { |
| 533 |
my $sth2 = $dbh->prepare("SELECT * FROM reserves WHERE borrowernumber=? AND itemnumber=? AND found='W'"); |
608 |
$numBibsAvailable++; |
| 534 |
$sth2->execute($itemLoopIter->{ReservedForBorrowernumber}, $itemNum); |
609 |
$biblioLoopIter{bib_available} = 1; |
| 535 |
while (my $wait_hashref = $sth2->fetchrow_hashref) { |
610 |
$biblioLoopIter{holdable} = 1; |
| 536 |
$itemLoopIter->{waitingdate} = format_date($wait_hashref->{waitingdate}); |
611 |
} |
|
|
612 |
if ( $biblioLoopIter{already_reserved} ) { |
| 613 |
$biblioLoopIter{holdable} = undef; |
| 614 |
} |
| 615 |
if ( not CanBookBeReserved( $borrowernumber, $biblioNum ) ) { |
| 616 |
$biblioLoopIter{holdable} = undef; |
| 537 |
} |
617 |
} |
| 538 |
$itemLoopIter->{imageurl} = getitemtypeimagelocation( 'opac', $itemTypes->{ $itemInfo->{itype} }{imageurl} ); |
618 |
if ( not C4::Context->preference('AllowHoldsOnPatronsPossessions') |
|
|
619 |
and CheckIfIssuedToPatron( $borrowernumber, $biblioNum ) ) |
| 620 |
{ |
| 621 |
$biblioLoopIter{holdable} = undef; |
| 622 |
$biblioLoopIter{already_patron_possession} = 1; |
| 623 |
} |
| 624 |
if ( $branchTransferableItemsCount == 0 ) { |
| 539 |
|
625 |
|
| 540 |
# Show serial enumeration when needed |
626 |
#We can tell our Borrowers that they can try another pickup location if they don't find what they need. |
| 541 |
if ($itemLoopIter->{enumchron}) { |
627 |
$biblioLoopIter{suggestAnotherPickupLocation} = 1; |
| 542 |
$itemdata_enumchron = 1; |
|
|
| 543 |
} |
628 |
} |
| 544 |
|
629 |
|
| 545 |
push @{$biblioLoopIter{itemLoop}}, $itemLoopIter; |
630 |
if ( $biblioLoopIter{holdable} ) { $anyholdable++; } |
| 546 |
} |
|
|
| 547 |
$template->param( itemdata_enumchron => $itemdata_enumchron ); |
| 548 |
|
631 |
|
| 549 |
## Set the behaviour flags for the template |
632 |
push @$biblioLoop, \%biblioLoopIter; |
| 550 |
if ($numCopiesAvailable > 0) { |
|
|
| 551 |
$numBibsAvailable++; |
| 552 |
$biblioLoopIter{bib_available} = 1; |
| 553 |
$biblioLoopIter{holdable} = 1; |
| 554 |
} |
633 |
} |
| 555 |
if ($biblioLoopIter{already_reserved}) { |
634 |
|
| 556 |
$biblioLoopIter{holdable} = undef; |
635 |
if ( $numBibsAvailable == 0 || $anyholdable == 0 ) { |
|
|
636 |
$template->param( none_available => 1 ); |
| 557 |
} |
637 |
} |
| 558 |
if(not CanBookBeReserved($borrowernumber,$biblioNum)){ |
638 |
|
| 559 |
$biblioLoopIter{holdable} = undef; |
639 |
my $itemTableColspan = 9; |
|
|
640 |
if ( !$template->{VARS}->{'OPACItemHolds'} ) { |
| 641 |
$itemTableColspan--; |
| 560 |
} |
642 |
} |
| 561 |
if(not C4::Context->preference('AllowHoldsOnPatronsPossessions') and CheckIfIssuedToPatron($borrowernumber,$biblioNum)) { |
643 |
if ( !$template->{VARS}->{'singleBranchMode'} ) { |
| 562 |
$biblioLoopIter{holdable} = undef; |
644 |
$itemTableColspan--; |
| 563 |
$biblioLoopIter{already_patron_possession} = 1; |
|
|
| 564 |
} |
645 |
} |
| 565 |
if ($branchTransferableItemsCount == 0) { |
646 |
$itemTableColspan-- if !$show_holds_count && !$show_priority; |
| 566 |
#We can tell our Borrowers that they can try another pickup location if they don't find what they need. |
647 |
my $show_notes = C4::Context->preference('OpacHoldNotes'); |
| 567 |
$biblioLoopIter{suggestAnotherPickupLocation} = 1 ; |
648 |
$template->param( OpacHoldNotes => $show_notes ); |
|
|
649 |
$itemTableColspan-- if !$show_notes; |
| 650 |
$template->param( itemtable_colspan => $itemTableColspan ); |
| 651 |
|
| 652 |
# display infos |
| 653 |
$template->param( bibitemloop => $biblioLoop ); |
| 654 |
$template->param( showholds => $show_holds_count ); |
| 655 |
$template->param( showpriority => $show_priority ); |
| 656 |
|
| 657 |
# can set reserve date in future |
| 658 |
if ( C4::Context->preference('AllowHoldDateInFuture') |
| 659 |
&& C4::Context->preference('OPACAllowHoldDateInFuture') ) |
| 660 |
{ |
| 661 |
$template->param( reserve_in_future => 1, ); |
| 568 |
} |
662 |
} |
| 569 |
|
663 |
|
| 570 |
|
664 |
output_html_with_http_headers $query, $cookie, $template->output; |
| 571 |
if( $biblioLoopIter{holdable} ){ $anyholdable++; } |
|
|
| 572 |
|
| 573 |
push @$biblioLoop, \%biblioLoopIter; |
| 574 |
} |
| 575 |
|
| 576 |
if ( $numBibsAvailable == 0 || $anyholdable == 0 ) { |
| 577 |
$template->param( none_available => 1 ); |
| 578 |
} |
| 579 |
|
| 580 |
my $itemTableColspan = 9; |
| 581 |
if (! $template->{VARS}->{'OPACItemHolds'}) { |
| 582 |
$itemTableColspan--; |
| 583 |
} |
| 584 |
if (! $template->{VARS}->{'singleBranchMode'}) { |
| 585 |
$itemTableColspan--; |
| 586 |
} |
| 587 |
$itemTableColspan-- if !$show_holds_count && !$show_priority; |
| 588 |
my $show_notes=C4::Context->preference('OpacHoldNotes'); |
| 589 |
$template->param(OpacHoldNotes=>$show_notes); |
| 590 |
$itemTableColspan-- if !$show_notes; |
| 591 |
$template->param(itemtable_colspan => $itemTableColspan); |
| 592 |
|
| 593 |
# display infos |
| 594 |
$template->param(bibitemloop => $biblioLoop); |
| 595 |
$template->param( showholds=>$show_holds_count); |
| 596 |
$template->param( showpriority=>$show_priority); |
| 597 |
# can set reserve date in future |
| 598 |
if ( |
| 599 |
C4::Context->preference( 'AllowHoldDateInFuture' ) && |
| 600 |
C4::Context->preference( 'OPACAllowHoldDateInFuture' ) |
| 601 |
) { |
| 602 |
$template->param( |
| 603 |
reserve_in_future => 1, |
| 604 |
); |
| 605 |
} |
| 606 |
|
| 607 |
output_html_with_http_headers $query, $cookie, $template->output; |
| 608 |
|
665 |
|