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

(-)a/C4/Biblio.pm (-1 / +1 lines)
Lines 443-449 sub DelBiblio { Link Here
443
443
444
    # We delete any existing holds
444
    # We delete any existing holds
445
    require C4::Reserves;
445
    require C4::Reserves;
446
    my ($count, $reserves) = C4::Reserves::GetReservesFromBiblionumber($biblionumber);
446
    my $reserves = C4::Reserves::GetReservesFromBiblionumber({ biblionumber => $biblionumber });
447
    foreach my $res ( @$reserves ) {
447
    foreach my $res ( @$reserves ) {
448
        C4::Reserves::CancelReserve({ reserve_id => $res->{'reserve_id'} });
448
        C4::Reserves::CancelReserve({ reserve_id => $res->{'reserve_id'} });
449
    }
449
    }
(-)a/C4/ILSDI/Services.pm (-2 / +2 lines)
Lines 208-214 sub GetRecords { Link Here
208
208
209
        # Get most of the needed data
209
        # Get most of the needed data
210
        my $biblioitemnumber = $biblioitem->{'biblioitemnumber'};
210
        my $biblioitemnumber = $biblioitem->{'biblioitemnumber'};
211
        my @reserves         = GetReservesFromBiblionumber( $biblionumber, undef, undef );
211
        my $reserves         = GetReservesFromBiblionumber({ biblionumber => $biblionumber });
212
        my $issues           = GetBiblioIssues($biblionumber);
212
        my $issues           = GetBiblioIssues($biblionumber);
213
        my $items            = GetItemsByBiblioitemnumber($biblioitemnumber);
213
        my $items            = GetItemsByBiblioitemnumber($biblioitemnumber);
214
214
Lines 225-231 sub GetRecords { Link Here
225
225
226
        # Hashref building...
226
        # Hashref building...
227
        $biblioitem->{'items'}->{'item'}       = $items;
227
        $biblioitem->{'items'}->{'item'}       = $items;
228
        $biblioitem->{'reserves'}->{'reserve'} = $reserves[1];
228
        $biblioitem->{'reserves'}->{'reserve'} = $reserves;
229
        $biblioitem->{'issues'}->{'issue'}     = $issues;
229
        $biblioitem->{'issues'}->{'issue'}     = $issues;
230
230
231
        push @records, $biblioitem;
231
        push @records, $biblioitem;
(-)a/C4/Reserves.pm (-7 / +12 lines)
Lines 268-284 sub GetReserve { Link Here
268
268
269
=head2 GetReservesFromBiblionumber
269
=head2 GetReservesFromBiblionumber
270
270
271
  ($count, $title_reserves) = GetReservesFromBiblionumber($biblionumber);
271
  my $reserves = GetReservesFromBiblionumber({
272
    biblionumber => $biblionumber,
273
    itemnumber => $itemnumber,
274
    all_dates => 1|0
275
  });
272
276
273
This function gets the list of reservations for one C<$biblionumber>, returning a count
277
This function gets the list of reservations for one C<$biblionumber>,
274
of the reserves and an arrayref pointing to the reserves for C<$biblionumber>.
278
returning an arrayref pointing to the reserves for C<$biblionumber>.
275
279
276
=cut
280
=cut
277
281
278
sub GetReservesFromBiblionumber {
282
sub GetReservesFromBiblionumber {
279
    my ($biblionumber) = shift or return (0, []);
283
    my ( $params ) = @_;
280
    my ($all_dates) = shift;
284
    my $biblionumber = $params->{biblionumber} or return [];
281
    my ($itemnumber) = shift;
285
    my $itemnumber = $params->{itemnumber};
286
    my $all_dates = $params->{all_dates} // 0;
282
    my $dbh   = C4::Context->dbh;
287
    my $dbh   = C4::Context->dbh;
283
288
284
    # Find the desired items in the reserves
289
    # Find the desired items in the reserves
Lines 353-359 sub GetReservesFromBiblionumber { Link Here
353
        }
358
        }
354
        push @results, $data;
359
        push @results, $data;
355
    }
360
    }
356
    return ( $#results + 1, \@results );
361
    return \@results;
357
}
362
}
358
363
359
=head2 GetReservesFromItemnumber
364
=head2 GetReservesFromItemnumber
(-)a/C4/SIP/ILS/Item.pm (-2 / +2 lines)
Lines 95-102 sub new { Link Here
95
    }
95
    }
96
	my $borrower = GetMember(borrowernumber=>$issue->{'borrowernumber'});
96
	my $borrower = GetMember(borrowernumber=>$issue->{'borrowernumber'});
97
	$item->{patron} = $borrower->{'cardnumber'};
97
	$item->{patron} = $borrower->{'cardnumber'};
98
    my ($whatever, $arrayref) = GetReservesFromBiblionumber($item->{biblionumber});
98
    my $reserves = GetReservesFromBiblionumber({ biblionumber => $item->{biblionumber} });
99
	$item->{hold_queue} = [ sort priority_sort @$arrayref ];
99
    $item->{hold_queue} = [ sort priority_sort @$reserves ];
100
	$item->{hold_shelf}    = [( grep {   defined $_->{found}  and $_->{found} eq 'W' } @{$item->{hold_queue}} )];
100
	$item->{hold_shelf}    = [( grep {   defined $_->{found}  and $_->{found} eq 'W' } @{$item->{hold_queue}} )];
101
	$item->{pending_queue} = [( grep {(! defined $_->{found}) or  $_->{found} ne 'W' } @{$item->{hold_queue}} )];
101
	$item->{pending_queue} = [( grep {(! defined $_->{found}) or  $_->{found} ne 'W' } @{$item->{hold_queue}} )];
102
	$self = $item;
102
	$self = $item;
(-)a/acqui/parcel.pl (-2 / +2 lines)
Lines 175-182 for my $order ( @orders ) { Link Here
175
    $line{holds} = 0;
175
    $line{holds} = 0;
176
    my @itemnumbers = GetItemnumbersFromOrder( $order->{ordernumber} );
176
    my @itemnumbers = GetItemnumbersFromOrder( $order->{ordernumber} );
177
    for my $itemnumber ( @itemnumbers ) {
177
    for my $itemnumber ( @itemnumbers ) {
178
        my ( $count ) = &GetReservesFromBiblionumber($line{biblionumber}, undef, $itemnumber);
178
        my $holds = GetReservesFromBiblionumber({ biblionumber => $line{biblionumber}, itemnumber => $itemnumber });
179
        $line{holds} += $count;
179
        $line{holds} += scalar( @$holds );
180
    }
180
    }
181
    $line{budget} = GetBudgetByOrderNumber( $line{ordernumber} );
181
    $line{budget} = GetBudgetByOrderNumber( $line{ordernumber} );
182
    $totalprice += $order->{unitprice};
182
    $totalprice += $order->{unitprice};
(-)a/catalogue/ISBDdetail.pl (-1 / +2 lines)
Lines 113-119 $template->param ( Link Here
113
);
113
);
114
114
115
115
116
my ( $holdcount, $holds ) = C4::Reserves::GetReservesFromBiblionumber($biblionumber,1);
116
my $holds = C4::Reserves::GetReservesFromBiblionumber({ biblionumber => $biblionumber, all_dates => 1 });
117
my $holdcount = scalar( @$holds );
117
$template->param( holdcount => $holdcount, holds => $holds );
118
$template->param( holdcount => $holdcount, holds => $holds );
118
119
119
output_html_with_http_headers $query, $cookie, $template->output;
120
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/catalogue/MARCdetail.pl (-1 / +2 lines)
Lines 336-342 $template->param ( Link Here
336
    searchid            => $query->param('searchid'),
336
    searchid            => $query->param('searchid'),
337
);
337
);
338
338
339
my ( $holdcount, $holds ) = C4::Reserves::GetReservesFromBiblionumber($biblionumber,1);
339
my $holds = C4::Reserves::GetReservesFromBiblionumber({ biblionumber => $biblionumber, all_dates => 1 });
340
my $holdcount = scalar( @$holds );
340
$template->param( holdcount => $holdcount, holds => $holds );
341
$template->param( holdcount => $holdcount, holds => $holds );
341
342
342
output_html_with_http_headers $query, $cookie, $template->output;
343
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/catalogue/detail.pl (-1 / +2 lines)
Lines 414-420 if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->pref Link Here
414
                                'sort'=>'-weight', limit=>$tag_quantity}));
414
                                'sort'=>'-weight', limit=>$tag_quantity}));
415
}
415
}
416
416
417
my ( $holdcount, $holds ) = C4::Reserves::GetReservesFromBiblionumber($biblionumber,1);
417
my $holds = C4::Reserves::GetReservesFromBiblionumber({ biblionumber => $biblionumber, all_dates => 1 });
418
my $holdcount = scalar ( @$holds );
418
$template->param( holdcount => $holdcount, holds => $holds );
419
$template->param( holdcount => $holdcount, holds => $holds );
419
my $StaffDetailItemSelection = C4::Context->preference('StaffDetailItemSelection');
420
my $StaffDetailItemSelection = C4::Context->preference('StaffDetailItemSelection');
420
if ($StaffDetailItemSelection) {
421
if ($StaffDetailItemSelection) {
(-)a/catalogue/imageviewer.pl (-1 / +2 lines)
Lines 78-84 $template->{VARS}->{'norequests'} = $norequests; Link Here
78
$template->param(C4::Search::enabled_staff_search_views);
78
$template->param(C4::Search::enabled_staff_search_views);
79
$template->{VARS}->{'biblio'} = $biblio;
79
$template->{VARS}->{'biblio'} = $biblio;
80
80
81
my ( $holdcount, $holds ) = C4::Reserves::GetReservesFromBiblionumber($biblionumber,1);
81
my $holds = C4::Reserves::GetReservesFromBiblionumber({ biblionumber => $biblionumber, all_dates => 1 });
82
my $holdcount = scalar( @$holds );
82
$template->param( holdcount => $holdcount, holds => $holds );
83
$template->param( holdcount => $holdcount, holds => $holds );
83
84
84
output_html_with_http_headers $query, $cookie, $template->output;
85
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/catalogue/labeledMARCdetail.pl (-1 / +2 lines)
Lines 137-143 $template->param ( Link Here
137
    searchid            => $query->param('searchid'),
137
    searchid            => $query->param('searchid'),
138
);
138
);
139
139
140
my ( $holdcount, $holds ) = C4::Reserves::GetReservesFromBiblionumber($biblionumber,1);
140
my $holds= C4::Reserves::GetReservesFromBiblionumber({ biblionumber => $biblionumber, all_dates => 1 });
141
my $holdcount = scalar( @$holds );
141
$template->param( holdcount => $holdcount, holds => $holds );
142
$template->param( holdcount => $holdcount, holds => $holds );
142
143
143
output_html_with_http_headers $query, $cookie, $template->output;
144
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/catalogue/moredetail.pl (-1 / +2 lines)
Lines 217-223 $template->param(ONLY_ONE => 1) if ( $itemnumber && $showncount != @items ); Link Here
217
$template->{'VARS'}->{'searchid'} = $query->param('searchid');
217
$template->{'VARS'}->{'searchid'} = $query->param('searchid');
218
218
219
219
220
my ( $holdcount, $holds ) = GetReservesFromBiblionumber($biblionumber,1);
220
my $holds = GetReservesFromBiblionumber({ biblionumber => $biblionumber, all_dates => 1 });
221
my $holdcount = scalar( @$holds );
221
$template->param( holdcount => $holdcount, holds => $holds );
222
$template->param( holdcount => $holdcount, holds => $holds );
222
223
223
output_html_with_http_headers $query, $cookie, $template->output;
224
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/opac/opac-detail.pl (-2 / +2 lines)
Lines 539-546 for ( C4::Context->preference("OPACShowHoldQueueDetails") ) { Link Here
539
}
539
}
540
my $has_hold;
540
my $has_hold;
541
if ( $show_holds_count || $show_priority) {
541
if ( $show_holds_count || $show_priority) {
542
    my ($reserve_count,$reserves) = GetReservesFromBiblionumber($biblionumber);
542
    my $reserves = GetReservesFromBiblionumber({ biblionumber => $biblionumber });
543
    $template->param( holds_count  => $reserve_count ) if $show_holds_count;
543
    $template->param( holds_count  => scalar( @$reserves ) ) if $show_holds_count;
544
    foreach (@$reserves) {
544
    foreach (@$reserves) {
545
        $item_reserves{ $_->{itemnumber} }++ if $_->{itemnumber};
545
        $item_reserves{ $_->{itemnumber} }++ if $_->{itemnumber};
546
        if ($show_priority && $_->{borrowernumber} == $borrowernumber) {
546
        if ($show_priority && $_->{borrowernumber} == $borrowernumber) {
(-)a/opac/opac-reserve.pl (-2 / +2 lines)
Lines 147-154 foreach my $biblioNumber (@biblionumbers) { Link Here
147
    }
147
    }
148
148
149
    # Compute the priority rank.
149
    # Compute the priority rank.
150
    my ( $rank, $reserves ) =
150
    my $reserves = GetReservesFromBiblionumber({ biblionumber => $biblioNumber, all_dates => 1 });
151
      GetReservesFromBiblionumber( $biblioNumber, 1 );
151
    my $rank = scalar( @$reserves );
152
    $biblioData->{reservecount} = 1;    # new reserve
152
    $biblioData->{reservecount} = 1;    # new reserve
153
    foreach my $res (@{$reserves}) {
153
    foreach my $res (@{$reserves}) {
154
        my $found = $res->{found};
154
        my $found = $res->{found};
(-)a/reserve/request.pl (-2 / +3 lines)
Lines 196-202 foreach my $biblionumber (@biblionumbers) { Link Here
196
    }
196
    }
197
197
198
    # get existing reserves .....
198
    # get existing reserves .....
199
    my ( $count, $reserves ) = GetReservesFromBiblionumber($biblionumber,1);
199
    my $reserves = GetReservesFromBiblionumber({ biblionumber => $biblionumber, all_dates => 1 });
200
    my $count = scalar( @$reserves );
200
    my $totalcount = $count;
201
    my $totalcount = $count;
201
    my $holds_count = 0;
202
    my $holds_count = 0;
202
    my $alreadyreserved = 0;
203
    my $alreadyreserved = 0;
Lines 446-452 foreach my $biblionumber (@biblionumbers) { Link Here
446
447
447
    # existingreserves building
448
    # existingreserves building
448
    my @reserveloop;
449
    my @reserveloop;
449
    ( $count, $reserves ) = GetReservesFromBiblionumber($biblionumber,1);
450
    $reserves = GetReservesFromBiblionumber({ biblionumber => $biblionumber, all_dates => 1 });
450
    foreach my $res ( sort {
451
    foreach my $res ( sort {
451
            my $a_found = $a->{found} || '';
452
            my $a_found = $a->{found} || '';
452
            my $b_found = $a->{found} || '';
453
            my $b_found = $a->{found} || '';
(-)a/serials/routing-preview.pl (-2 / +3 lines)
Lines 71-78 if($ok){ Link Here
71
71
72
	if (C4::Context->preference('RoutingListAddReserves')){
72
	if (C4::Context->preference('RoutingListAddReserves')){
73
		# get existing reserves .....
73
		# get existing reserves .....
74
		my ($count,$reserves) = GetReservesFromBiblionumber($biblio);
74
        my $reserves = GetReservesFromBiblionumber({ biblionumber => $biblio });
75
		my $totalcount = $count;
75
        my $count = scalar( @$reserves );
76
        my $totalcount = $count;
76
		foreach my $res (@$reserves) {
77
		foreach my $res (@$reserves) {
77
			if ($res->{'found'} eq 'W') {
78
			if ($res->{'found'} eq 'W') {
78
				$count--;
79
				$count--;
(-)a/t/db_dependent/Holds.t (-6 / +5 lines)
Lines 71-78 foreach my $borrowernumber ( @borrowernumbers ) { Link Here
71
}
71
}
72
72
73
73
74
my ($count, $reserves) = GetReservesFromBiblionumber($biblionumber);
74
my $reserves = GetReservesFromBiblionumber({ biblionumber => $biblionumber });
75
is( $count, $borrowers_count, "Test GetReserves()" );
75
is( scalar(@$reserves), $borrowers_count, "Test GetReserves()" );
76
76
77
77
78
my ( $reservedate, $borrowernumber, $branchcode, $reserve_id ) = GetReservesFromItemnumber($itemnumber);
78
my ( $reservedate, $borrowernumber, $branchcode, $reserve_id ) = GetReservesFromItemnumber($itemnumber);
Lines 87-94 ok( GetReserveCount( $borrowernumbers[0] ), "Test GetReserveCount()" ); Link Here
87
87
88
88
89
CancelReserve({ 'reserve_id' => $reserve_id });
89
CancelReserve({ 'reserve_id' => $reserve_id });
90
($count, $reserves) = GetReservesFromBiblionumber($biblionumber);
90
$reserves = GetReservesFromBiblionumber({ biblionumber => $biblionumber });
91
ok( $count == $borrowers_count - 1, "Test CancelReserve()" );
91
is( scalar(@$reserves), $borrowers_count - 1, "Test CancelReserve()" );
92
92
93
93
94
( $reservedate, $borrowernumber, $branchcode, $reserve_id ) = GetReservesFromItemnumber($itemnumber);
94
( $reservedate, $borrowernumber, $branchcode, $reserve_id ) = GetReservesFromItemnumber($itemnumber);
Lines 148-154 my $reserve2 = GetReserveInfo( $reserve->{'reserve_id'} ); Link Here
148
ok( $reserve->{'reserve_id'} eq $reserve2->{'reserve_id'}, "Test GetReserveInfo()" );
148
ok( $reserve->{'reserve_id'} eq $reserve2->{'reserve_id'}, "Test GetReserveInfo()" );
149
149
150
150
151
($count, $reserves) = GetReservesFromBiblionumber($biblionumber,1);
151
$reserves = GetReservesFromBiblionumber({ biblionumber => $biblionumber, all_dates => 1 });
152
$reserve = $reserves->[1];
152
$reserve = $reserves->[1];
153
AlterPriority( 'top', $reserve->{'reserve_id'} );
153
AlterPriority( 'top', $reserve->{'reserve_id'} );
154
$reserve = GetReserve( $reserve->{'reserve_id'} );
154
$reserve = GetReserve( $reserve->{'reserve_id'} );
155
- 

Return to bug 7683