View | Details | Raw Unified | Return to bug 10993
Collapse All | Expand All

(-)a/C4/Reserves.pm (-6 / +16 lines)
Lines 409-430 sub GetReservesFromBorrowernumber { Link Here
409
#-------------------------------------------------------------------------------------
409
#-------------------------------------------------------------------------------------
410
=head2 CanBookBeReserved
410
=head2 CanBookBeReserved
411
411
412
  $error = &CanBookBeReserved($borrowernumber, $biblionumber)
412
  $error = &CanBookBeReserved($borrowernumber, $biblionumber, $pickupLibrary)
413
413
414
C<$pickupLibrary> OPTIONAL, undef OR the branchcode of the item transfer destination.
415
  
414
=cut
416
=cut
415
417
416
sub CanBookBeReserved{
418
sub CanBookBeReserved{
417
    my ($borrowernumber, $biblionumber) = @_;
419
    my ($borrowernumber, $biblionumber, $pickupLibrary) = @_;
418
420
419
    my $items = GetItemnumbersForBiblio($biblionumber);
421
    my $items = GetItemnumbersForBiblio($biblionumber);
420
    #get items linked via host records
422
    #get items linked via host records
421
    my @hostitems = get_hostitemnumbers_of($biblionumber);
423
    my @hostitems = get_hostitemnumbers_of($biblionumber);
422
    if (@hostitems){
424
    if (@hostitems){
423
    push (@$items,@hostitems);
425
		push (@$items,@hostitems);
424
    }
426
    }
425
427
426
    foreach my $item (@$items){
428
    foreach my $item (@$items){
427
        return 1 if CanItemBeReserved($borrowernumber, $item);
429
		
430
		if (defined $pickupLibrary) {
431
			return 1 if ( CanItemBeReserved($borrowernumber, $item) and
432
					  CheckBranchTransferLimits($pickupLibrary, $item->{holdingbranch}, $item, undef)
433
					);
434
		}
435
		else {
436
			return 1 if ( CanItemBeReserved($borrowernumber, $item) );
437
		}
428
    }
438
    }
429
    return 0;
439
    return 0;
430
}
440
}
Lines 432-438 sub CanBookBeReserved{ Link Here
432
=head2 CanItemBeReserved
442
=head2 CanItemBeReserved
433
443
434
  $error = &CanItemBeReserved($borrowernumber, $itemnumber)
444
  $error = &CanItemBeReserved($borrowernumber, $itemnumber)
435
445
  
436
This function return 1 if an item can be issued by this borrower.
446
This function return 1 if an item can be issued by this borrower.
437
447
438
=cut
448
=cut
Lines 527-533 sub CanItemBeReserved{ Link Here
527
            return 0;
537
            return 0;
528
        }
538
        }
529
    }
539
    }
530
540
    
531
    return 1;
541
    return 1;
532
}
542
}
533
#--------------------------------------------------------------------------------
543
#--------------------------------------------------------------------------------
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt (-23 / +56 lines)
Lines 5-10 Link Here
5
<script type="text/javascript">
5
<script type="text/javascript">
6
// <![CDATA[
6
// <![CDATA[
7
 var MSG_NO_COPY_SELECTED = _("Expecting a specific copy selection.");
7
 var MSG_NO_COPY_SELECTED = _("Expecting a specific copy selection.");
8
 var MSG_NO_TRANSFERRABLE_ITEMS = _("No item can be transferred to your pickup location. Please try another pickup location for ");
8
 var ForceHoldNotesReasons=new Array(
9
 var ForceHoldNotesReasons=new Array(
9
    _("This title consists of multiple volumes/parts. Please indicate which part you need. Clicking on specific copy information may be helpful."),
10
    _("This title consists of multiple volumes/parts. Please indicate which part you need. Clicking on specific copy information may be helpful."),
10
    "*** Add a new reason above this line ***" ); // NOTE: Do not renumber reasons; this will affect use of existing ones.
11
    "*** Add a new reason above this line ***" ); // NOTE: Do not renumber reasons; this will affect use of existing ones.
Lines 20-25 Link Here
20
21
21
 $(document).ready(function() {
22
 $(document).ready(function() {
22
    $('#hold-request-form').preventDoubleFormSubmit();
23
    $('#hold-request-form').preventDoubleFormSubmit();
24
	
25
	$("#hold-request-form").find("select[name='branch']").change( function() {
26
			var newSelection = $(this).val();
27
			
28
			//Make sure that when changing the pickup location by resubmitting the form,
29
			// user doesn't accidentally confirm his reservations.
30
			var place_reserveInput = $("#hold-request-form").find('[name="place_reserve"]');
31
			place_reserveInput.attr("value", 0);
32
			
33
			//Make sure the pickup location is changed to the first select as well.
34
			// The branch selection uses only the first given pickuplocations branch value.
35
			$("#hold-request-form").find("select[name='branch']").val(newSelection);
36
			
37
			$("#hold-request-form").submit();
38
	});
23
39
24
    var copiesRowId = null;
40
    var copiesRowId = null;
25
    var wasSpecific = false;
41
    var wasSpecific = false;
Lines 137-142 Link Here
137
            alert(MSG_NO_RECORD_SELECTED);
153
            alert(MSG_NO_RECORD_SELECTED);
138
            return false;
154
            return false;
139
        }
155
        }
156
		
157
		//Check for each biblio if there are no available Items that can be transferred to the pickup location,
158
		// fail the hold request and alert the user.
159
		var anotherPickupLocationSuggesters = $('#hold-request-form').find('div[id^="suggestAnotherPickupLocation_"]');
160
		if ( $(anotherPickupLocationSuggesters).size() > 0 ) {
161
			anotherPickupLocationSuggesters.each( function() {
162
					//Extract the biblionumber from the id and fetch the Biblio title
163
					var idString = $(this).attr('id');
164
					var bibnumber = idString.replace('suggestAnotherPickupLocation_', '');
165
					var title = $('#title_'+bibnumber).text();
166
					
167
					alert(MSG_NO_TRANSFERRABLE_ITEMS + title);
168
			});
169
			return false;
170
		}
140
171
141
        // Find the items with the 'Hold' box checked
172
        // Find the items with the 'Hold' box checked
142
        var badBib = null;
173
        var badBib = null;
Lines 189-195 Link Here
189
220
190
221
191
222
192
193
[% FOREACH bibitemloo IN bibitemloop %]
223
[% FOREACH bibitemloo IN bibitemloop %]
194
    [% IF ( bibitemloo.holdable ) %]
224
    [% IF ( bibitemloo.holdable ) %]
195
        // http://jqueryui.com/demos/datepicker/#date-range
225
        // http://jqueryui.com/demos/datepicker/#date-range
Lines 210-216 Link Here
210
    [% END %]
240
    [% END %]
211
[% END %]
241
[% END %]
212
242
213
 });
243
 }); 
214
// ]]>
244
// ]]>
215
</script>
245
</script>
216
<style type="text/css">td ul { padding : 0; } td li { white-space: nowrap; font-size: 90%; list-style-type:none; padding : .3em 0; }</style>
246
<style type="text/css">td ul { padding : 0; } td li { white-space: nowrap; font-size: 90%; list-style-type:none; padding : .3em 0; }</style>
Lines 270-297 Link Here
270
              <div id="bad_data" class="dialog alert">ERROR: Internal error: incomplete hold request.</div>
300
              <div id="bad_data" class="dialog alert">ERROR: Internal error: incomplete hold request.</div>
271
            [% END %]
301
            [% END %]
272
          [% ELSE %]
302
          [% ELSE %]
273
            [% IF ( none_available ) %]
303
		    [% IF ( none_available ) %]
274
                <div id="none_available" class="dialog alert"><strong>Sorry</strong>, none of these items can be placed on hold.
304
                <div id="none_available" class="dialog alert"><strong>Sorry</strong>, none of these items can be placed on hold.
275
                </div>
305
                </div>
276
              [% END %]
306
            [% END %]
277
          [% END %]<!-- NAME="message" -->
307
          [% END %]<!-- NAME="message" -->
278
308
279
      [% UNLESS ( message ) %][% UNLESS ( none_available ) %]<h3>Confirm holds for:
309
		[% UNLESS ( message ) %][% IF ( 1 ) %]
280
                      [% FOREACH USER_INF IN USER_INFO %]
310
			<h3>Confirm holds for:
281
                        [% USER_INF.firstname %] [% USER_INF.surname %] ([% USER_INF.cardnumber %])
311
                [% FOREACH USER_INF IN USER_INFO %]
282
                      [% END %]
312
                    [% USER_INF.firstname %] [% USER_INF.surname %] ([% USER_INF.cardnumber %])
283
                    </h3>[% END %]
313
                [% END %]
284
	      [% IF (RESERVE_CHARGE) %]
314
            </h3>[% END %]
285
	      <div class="dialog alert" id="reserve_fee">
315
			[% IF (RESERVE_CHARGE) %]
286
	        There is a charge of [% RESERVE_CHARGE %] for placing this hold
316
				<div class="dialog alert" id="reserve_fee">
287
	      </div>
317
					There is a charge of [% RESERVE_CHARGE %] for placing this hold
288
	      [% END %]
318
				</div>
319
			[% END %]
289
320
290
            <form action="/cgi-bin/koha/opac-reserve.pl" method="post" id="hold-request-form">
321
            <form action="/cgi-bin/koha/opac-reserve.pl" method="post" id="hold-request-form">
291
            <input type="hidden" name="place_reserve" value="1"/>
322
            <input type="hidden" name="place_reserve" value="1"/>
292
323
293
            <!-- These values are set dynamically by js -->
324
            <!-- These values are set dynamically by js. Biblionumbers is needed for the page reload when changing pickup branch -->
294
            <input type="hidden" name="biblionumbers" id="biblionumbers"/>
325
            <input type="hidden" name="biblionumbers" id="biblionumbers" value="[% biblionumbers %]"/>
295
            <input type="hidden" name="selecteditems" id="selections"/>
326
            <input type="hidden" name="selecteditems" id="selections"/>
296
            <div id="bigloop">
327
            <div id="bigloop">
297
328
Lines 314-320 Link Here
314
                        [% ELSE %]
345
                        [% ELSE %]
315
                        [% END %]
346
                        [% END %]
316
347
317
                            <a class="title" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% bibitemloo.biblionumber %]">[% bibitemloo.title |html %][% IF ( bibitemloo.subtitle ) %] [% FOREACH subtitl IN bibitemloo.subtitle %][% subtitl.subfield %][% END %][% END %]</a>
348
                            <a class="title" id="title_[% bibitemloo.biblionumber %]" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% bibitemloo.biblionumber %]">[% bibitemloo.title |html %][% IF ( bibitemloo.subtitle ) %] [% FOREACH subtitl IN bibitemloo.subtitle %][% subtitl.subfield %][% END %][% END %]</a>
318
                                            [% IF ( bibitemloo.author ) %],  by [% bibitemloo.author %][% END %]</p>
349
                                            [% IF ( bibitemloo.author ) %],  by [% bibitemloo.author %][% END %]</p>
319
350
320
351
Lines 359-370 Link Here
359
390
360
391
361
                            [% UNLESS ( singleBranchMode ) %]
392
                            [% UNLESS ( singleBranchMode ) %]
393
								[% IF ( bibitemloo.suggestAnotherPickupLocation ) %]
394
									<div id="suggestAnotherPickupLocation_[% bibitemloo.biblionumber %]" class="dialog alert">None of the available items can be transferred to your pickup location. You could try another pickup location.
395
									</div>
396
								[% END %]
362
                                [% IF ( bibitemloo.holdable ) %]
397
                                [% IF ( bibitemloo.holdable ) %]
363
                                    [% IF ( choose_branch ) %]
398
                                    [% IF ( choose_branch ) %]
364
                                        <li class="branch">
399
                                        <li class="branch">
365
                                            <label for="branch_[% bibitemloo.biblionumber %]">Pick up location:</label>
400
                                            <label for="branch_[% bibitemloo.biblionumber %]">Pick up location:</label>
366
                                            [% UNLESS ( bibitemloo.holdable ) %]
401
                                            [% UNLESS ( bibitemloo.holdable ) %]
367
                                                <select name="branch" id="branch_[% bibitemloo.biblionumber %]" disabled="disabled">
402
                                                <select onClick="alert('digg')" name="branch" id="branch_[% bibitemloo.biblionumber %]" disabled="disabled">
368
                                                    [% FOREACH branchloo IN bibitemloo.branchloop %]
403
                                                    [% FOREACH branchloo IN bibitemloo.branchloop %]
369
                                                        [% IF ( branchloo.selected ) %]
404
                                                        [% IF ( branchloo.selected ) %]
370
                                                            <option value="[% branchloo.branchcode %]" selected="selected">[% branchloo.branchname %]</option>
405
                                                            <option value="[% branchloo.branchcode %]" selected="selected">[% branchloo.branchname %]</option>
Lines 398-405 Link Here
398
                                    <span class="date-format from" data-biblionumber="[% bibitemloo.biblionumber %]">[% INCLUDE 'date-format.inc' %]</span>
433
                                    <span class="date-format from" data-biblionumber="[% bibitemloo.biblionumber %]">[% INCLUDE 'date-format.inc' %]</span>
399
                                </li>
434
                                </li>
400
                            [% END %]
435
                            [% END %]
401
436
                        [% END %][%#End of IF ( bibitemloo.holdable ) %]
402
                        [% END %]
437
						
403
                        [% IF ( bibitemloo.holdable ) %]
438
                        [% IF ( bibitemloo.holdable ) %]
404
                            <li>
439
                            <li>
405
                                <label for="to[% bibitemloo.biblionumber %]">Hold not needed after:</label>
440
                                <label for="to[% bibitemloo.biblionumber %]">Hold not needed after:</label>
Lines 440-447 Link Here
440
                                           checked="checked"
475
                                           checked="checked"
441
                                    />
476
                                    />
442
                                  [% END %]
477
                                  [% END %]
443
444
                                  <label for="reqany_[% bibitemloo.biblionumber %]">Next available copy</label>
478
                                  <label for="reqany_[% bibitemloo.biblionumber %]">Next available copy</label>
479
								  
445
                                  [% UNLESS ( bibitemloo.holdable ) %]
480
                                  [% UNLESS ( bibitemloo.holdable ) %]
446
                                    <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
481
                                    <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
447
                                           id="reqspecific_[% bibitemloo.biblionumber %]"
482
                                           id="reqspecific_[% bibitemloo.biblionumber %]"
Lines 551-560 Link Here
551
            </div><!-- bigloop -->
586
            </div><!-- bigloop -->
552
587
553
            [% UNLESS ( message ) %]
588
            [% UNLESS ( message ) %]
554
            [% UNLESS ( none_available ) %]
555
            <input type="submit" value="Place hold" class="placehold" />
589
            <input type="submit" value="Place hold" class="placehold" />
556
            [% END %]
590
            [% END %]
557
            [% END %]
558
591
559
            </form>
592
            </form>
560
593
(-)a/opac/opac-reserve.pl (-32 / +60 lines)
Lines 91-97 if ((! $biblionumbers) && (! $query->param('place_reserve'))) { Link Here
91
}
91
}
92
92
93
# Pass the numbers to the page so they can be fed back
93
# Pass the numbers to the page so they can be fed back
94
# when the hold is confirmed. TODO: Not necessary?
94
# when the hold is confirmed. Biblionumbers are also needed if the
95
# pickup branch changes and the page needs to be reloaded.
95
$template->param( biblionumbers => $biblionumbers );
96
$template->param( biblionumbers => $biblionumbers );
96
97
97
# Each biblio number is suffixed with '/', e.g. "1/2/3/"
98
# Each biblio number is suffixed with '/', e.g. "1/2/3/"
Lines 103-114 if (($#biblionumbers < 0) && (! $query->param('place_reserve'))) { Link Here
103
}
104
}
104
105
105
# pass the pickup branch along....
106
# pass the pickup branch along....
106
my $branch = $query->param('branch') || $borr->{'branchcode'} || C4::Context->userenv->{branch} || '' ;
107
my $pickupBranch = $query->param('branch') || $borr->{'branchcode'} || C4::Context->userenv->{branch} || '' ;
107
($branches->{$branch}) or $branch = "";     # Confirm branch is real
108
($branches->{$pickupBranch}) or $pickupBranch = "";     # Confirm branch is real
108
$template->param( branch => $branch );
109
$template->param( branch => $pickupBranch );
109
110
110
# make branch selection options...
111
# make branch selection options...
111
my $branchloop = GetBranchesLoop($branch);
112
my $branchloop = GetBranchesLoop($pickupBranch);
112
113
113
# Is the person allowed to choose their branch
114
# Is the person allowed to choose their branch
114
my $OPACChooseBranch = (C4::Context->preference("OPACAllowUserToChooseBranch")) ? 1 : 0;
115
my $OPACChooseBranch = (C4::Context->preference("OPACAllowUserToChooseBranch")) ? 1 : 0;
Lines 202-220 if ( $query->param('place_reserve') ) { Link Here
202
    }
203
    }
203
204
204
    while (@selectedItems) {
205
    while (@selectedItems) {
205
        my $biblioNum = shift(@selectedItems);
206
        my $biblioNum 		= shift(@selectedItems);
206
        my $itemNum   = shift(@selectedItems);
207
        my $itemNum   		= shift(@selectedItems);
207
        my $branch    = shift(@selectedItems);    # i.e., branch code, not name
208
        my $pickupLocation  = shift(@selectedItems);    # i.e., branch code, not name,
208
209
209
        my $canreserve = 0;
210
        my $canreserve = 0;
210
211
211
        my $singleBranchMode = C4::Context->preference("singleBranchMode");
212
        my $singleBranchMode = C4::Context->preference("singleBranchMode");
212
        if ( $singleBranchMode || !$OPACChooseBranch )
213
        if ( $singleBranchMode || !$OPACChooseBranch )
213
        {    # single branch mode or disabled user choosing
214
        {    # single branch mode or disabled user choosing
214
            $branch = $borr->{'branchcode'};
215
            $pickupLocation = $borr->{'branchcode'};
215
        }
216
        }
216
217
217
#item may belong to a host biblio, if yes change biblioNum to hosts bilbionumber
218
		#item may belong to a host biblio, if yes change biblioNum to hosts bilbionumber
218
        if ( $itemNum ne '' ) {
219
        if ( $itemNum ne '' ) {
219
            my $hostbiblioNum = GetBiblionumberFromItemnumber($itemNum);
220
            my $hostbiblioNum = GetBiblionumberFromItemnumber($itemNum);
220
            if ( $hostbiblioNum ne $biblioNum ) {
221
            if ( $hostbiblioNum ne $biblioNum ) {
Lines 235-254 if ( $query->param('place_reserve') ) { Link Here
235
236
236
        my $expiration_date = $query->param("expiration_date_$biblioNum");
237
        my $expiration_date = $query->param("expiration_date_$biblioNum");
237
238
238
      # If a specific item was selected and the pickup branch is the same as the
239
		# If a specific item was selected and the pickup branch is the same as the
239
      # holdingbranch, force the value $rank and $found.
240
		# holdingbranch, force the value $rank and $found.
240
        my $rank = $biblioData->{rank};
241
        my $rank = $biblioData->{rank};
241
        if ( $itemNum ne '' ) {
242
        if ( $itemNum ne '' ) {
243
			my $item = GetItem($itemNum);
242
            $canreserve = 1 if CanItemBeReserved( $borrowernumber, $itemNum );
244
            $canreserve = 1 if CanItemBeReserved( $borrowernumber, $itemNum );
243
            $rank = '0' unless C4::Context->preference('ReservesNeedReturns');
245
            $rank = '0' unless C4::Context->preference('ReservesNeedReturns');
244
            my $item = GetItem($itemNum);
246
            if ( $item->{'holdingbranch'} eq $pickupLocation ) {
245
            if ( $item->{'holdingbranch'} eq $branch ) {
246
                $found = 'W'
247
                $found = 'W'
247
                  unless C4::Context->preference('ReservesNeedReturns');
248
                  unless C4::Context->preference('ReservesNeedReturns');
248
            }
249
            }
250
			
251
			# UseBranchTransferLimits checking.
252
			my ($transferOk, $message) = CheckBranchTransferAllowed( $pickupLocation, $item->{'holdingbranch'}, $item, undef );
253
			if (! $transferOk) {
254
				$canreserve = 0;
255
			}	
249
        }
256
        }
250
        else {
257
        else {
251
            $canreserve = 1 if CanBookBeReserved( $borrowernumber, $biblioNum );
258
            $canreserve = 1 if CanBookBeReserved( $borrowernumber, $biblioNum, $pickupLocation );
252
259
253
            # Inserts a null into the 'itemnumber' field of 'reserves' table.
260
            # Inserts a null into the 'itemnumber' field of 'reserves' table.
254
            $itemNum = undef;
261
            $itemNum = undef;
Lines 264-270 if ( $query->param('place_reserve') ) { Link Here
264
        # Here we actually do the reserveration. Stage 3.
271
        # Here we actually do the reserveration. Stage 3.
265
        if ($canreserve) {
272
        if ($canreserve) {
266
            AddReserve(
273
            AddReserve(
267
                $branch,      $borrowernumber,
274
                $pickupLocation,      $borrowernumber,
268
                $biblioNum,   'a',
275
                $biblioNum,   'a',
269
                [$biblioNum], $rank,
276
                [$biblioNum], $rank,
270
                $startdate,   $expiration_date,
277
                $startdate,   $expiration_date,
Lines 398-403 foreach my $biblioNum (@biblionumbers) { Link Here
398
        }
405
        }
399
    }
406
    }
400
407
408
	#Collect the amout of items that pass the CheckBranchTransferAllowed-check. This is needed to tell
409
	#  the Borrower if some or all Items cannot be transferred to the pickup location.
410
	my $branchTransferableItemsCount = 0;	
411
	
401
    $biblioLoopIter{itemLoop} = [];
412
    $biblioLoopIter{itemLoop} = [];
402
    my $numCopiesAvailable = 0;
413
    my $numCopiesAvailable = 0;
403
    foreach my $itemInfo (@{$biblioData->{itemInfos}}) {
414
    foreach my $itemInfo (@{$biblioData->{itemInfos}}) {
Lines 434-443 foreach my $biblioNum (@biblionumbers) { Link Here
434
        my ($reservedate,$reservedfor,$expectedAt) = GetReservesFromItemnumber($itemNum);
445
        my ($reservedate,$reservedfor,$expectedAt) = GetReservesFromItemnumber($itemNum);
435
        my $ItemBorrowerReserveInfo = GetMemberDetails( $reservedfor, 0);
446
        my $ItemBorrowerReserveInfo = GetMemberDetails( $reservedfor, 0);
436
447
437
	# the item could be reserved for this borrower vi a host record, flag this
448
		# the item could be reserved for this borrower vi a host record, flag this
438
	if ($reservedfor eq $borrowernumber){
449
		if ($reservedfor eq $borrowernumber){
439
		$itemLoopIter->{already_reserved} = 1;
450
			$itemLoopIter->{already_reserved} = 1;
440
	}
451
		}
441
452
442
        if ( defined $reservedate ) {
453
        if ( defined $reservedate ) {
443
            $itemLoopIter->{backgroundcolor} = 'reserved';
454
            $itemLoopIter->{backgroundcolor} = 'reserved';
Lines 480-491 foreach my $biblioNum (@biblionumbers) { Link Here
480
            $itemLoopIter->{nocancel} = 1;
491
            $itemLoopIter->{nocancel} = 1;
481
        }
492
        }
482
493
483
	# if the items belongs to a host record, show link to host record
494
		# if the items belongs to a host record, show link to host record
484
	if ($itemInfo->{biblionumber} ne $biblioNum){
495
		if ($itemInfo->{biblionumber} ne $biblioNum){
485
		$biblioLoopIter{hostitemsflag} = 1;
496
			$biblioLoopIter{hostitemsflag} = 1;
486
		$itemLoopIter->{hostbiblionumber} = $itemInfo->{biblionumber};
497
			$itemLoopIter->{hostbiblionumber} = $itemInfo->{biblionumber};
487
		$itemLoopIter->{hosttitle} = GetBiblioData($itemInfo->{biblionumber})->{title};
498
			$itemLoopIter->{hosttitle} = GetBiblioData($itemInfo->{biblionumber})->{title};
488
	}
499
		}
489
500
490
        # If there is no loan, return and transfer, we show a checkbox.
501
        # If there is no loan, return and transfer, we show a checkbox.
491
        $itemLoopIter->{notforloan} = $itemLoopIter->{notforloan} || 0;
502
        $itemLoopIter->{notforloan} = $itemLoopIter->{notforloan} || 0;
Lines 501-520 foreach my $biblioNum (@biblionumbers) { Link Here
501
        }
512
        }
502
513
503
        if (IsAvailableForItemLevelRequest($itemNum) and $policy_holdallowed and CanItemBeReserved($borrowernumber,$itemNum) and ($itemLoopIter->{already_reserved} ne 1)) {
514
        if (IsAvailableForItemLevelRequest($itemNum) and $policy_holdallowed and CanItemBeReserved($borrowernumber,$itemNum) and ($itemLoopIter->{already_reserved} ne 1)) {
504
            $itemLoopIter->{available} = 1;
515
            
516
			$itemLoopIter->{available} = 1;
505
            $numCopiesAvailable++;
517
            $numCopiesAvailable++;
518
			
519
			#Check for UseBranchTransferLimit. $numCopiesAvailable is incremented because this Item
520
			#  could still be available from another pickup location
521
			my ($transferOk, $errorMsg) = CheckBranchTransferAllowed( $pickupBranch, undef, GetItem($itemNum), undef );
522
			if (! $transferOk) {
523
				$itemLoopIter->{available} = 0;
524
				$itemLoopIter->{branchTransferBlocked} = 1;
525
			}
526
			else {
527
				$branchTransferableItemsCount++;
528
			}
506
        }
529
        }
507
530
508
	# FIXME: move this to a pm
531
		# FIXME: move this to a pm
509
        my $dbh = C4::Context->dbh;
532
        my $dbh = C4::Context->dbh;
510
        my $sth2 = $dbh->prepare("SELECT * FROM reserves WHERE borrowernumber=? AND itemnumber=? AND found='W'");
533
        my $sth2 = $dbh->prepare("SELECT * FROM reserves WHERE borrowernumber=? AND itemnumber=? AND found='W'");
511
        $sth2->execute($itemLoopIter->{ReservedForBorrowernumber}, $itemNum);
534
        $sth2->execute($itemLoopIter->{ReservedForBorrowernumber}, $itemNum);
512
        while (my $wait_hashref = $sth2->fetchrow_hashref) {
535
        while (my $wait_hashref = $sth2->fetchrow_hashref) {
513
            $itemLoopIter->{waitingdate} = format_date($wait_hashref->{waitingdate});
536
            $itemLoopIter->{waitingdate} = format_date($wait_hashref->{waitingdate});
514
        }
537
        }
515
	$itemLoopIter->{imageurl} = getitemtypeimagelocation( 'opac', $itemTypes->{ $itemInfo->{itype} }{imageurl} );
538
		$itemLoopIter->{imageurl} = getitemtypeimagelocation( 'opac', $itemTypes->{ $itemInfo->{itype} }{imageurl} );
516
539
517
    # Show serial enumeration when needed
540
		# Show serial enumeration when needed
518
        if ($itemLoopIter->{enumchron}) {
541
        if ($itemLoopIter->{enumchron}) {
519
            $itemdata_enumchron = 1;
542
            $itemdata_enumchron = 1;
520
        }
543
        }
Lines 523-528 foreach my $biblioNum (@biblionumbers) { Link Here
523
    }
546
    }
524
    $template->param( itemdata_enumchron => $itemdata_enumchron );
547
    $template->param( itemdata_enumchron => $itemdata_enumchron );
525
548
549
	## Set the behaviour flags for the template
526
    if ($numCopiesAvailable > 0) {
550
    if ($numCopiesAvailable > 0) {
527
        $numBibsAvailable++;
551
        $numBibsAvailable++;
528
        $biblioLoopIter{bib_available} = 1;
552
        $biblioLoopIter{bib_available} = 1;
Lines 538-550 foreach my $biblioNum (@biblionumbers) { Link Here
538
        $biblioLoopIter{holdable} = undef;
562
        $biblioLoopIter{holdable} = undef;
539
        $biblioLoopIter{already_patron_possession} = 1;
563
        $biblioLoopIter{already_patron_possession} = 1;
540
    }
564
    }
565
	if ($branchTransferableItemsCount == 0) {
566
		#We can tell our Borrowers that they can try another pickup location if they don't find what they need.
567
		$biblioLoopIter{suggestAnotherPickupLocation} = 1 ;
568
	}
569
	
541
570
542
    if( $biblioLoopIter{holdable} ){ $anyholdable++; }
571
    if( $biblioLoopIter{holdable} ){ $anyholdable++; }
543
572
544
    push @$biblioLoop, \%biblioLoopIter;
573
    push @$biblioLoop, \%biblioLoopIter;
545
}
574
}
546
575
547
if ( $numBibsAvailable == 0 || $anyholdable == 0) {
576
if ( $numBibsAvailable == 0 || $anyholdable == 0 ) {
548
    $template->param( none_available => 1 );
577
    $template->param( none_available => 1 );
549
}
578
}
550
579
551
- 

Return to bug 10993