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

(-)a/C4/Reserves.pm (-25 lines)
Lines 106-112 BEGIN { Link Here
106
106
107
        &GetReserve
107
        &GetReserve
108
        &GetReservesForBranch
108
        &GetReservesForBranch
109
        &GetReserveCount
110
        &GetReserveStatus
109
        &GetReserveStatus
111
110
112
        &GetOtherReserves
111
        &GetOtherReserves
Lines 475-504 sub CanReserveBeCanceledFromOpac { Link Here
475
474
476
}
475
}
477
476
478
=head2 GetReserveCount
479
480
  $number = &GetReserveCount($borrowernumber);
481
482
this function returns the number of reservation for a borrower given on input arg.
483
484
=cut
485
486
sub GetReserveCount {
487
    my ($borrowernumber) = @_;
488
489
    my $dbh = C4::Context->dbh;
490
491
    my $query = "
492
        SELECT COUNT(*) AS counter
493
        FROM reserves
494
        WHERE borrowernumber = ?
495
    ";
496
    my $sth = $dbh->prepare($query);
497
    $sth->execute($borrowernumber);
498
    my $row = $sth->fetchrow_hashref;
499
    return $row->{counter};
500
}
501
502
=head2 GetOtherReserves
477
=head2 GetOtherReserves
503
478
504
  ($messages,$nextreservinfo)=$GetOtherReserves(itemnumber);
479
  ($messages,$nextreservinfo)=$GetOtherReserves(itemnumber);
(-)a/reserve/request.pl (-2 / +1 lines)
Lines 142-149 if ($borrowernumber_hold && !$action) { Link Here
142
    # we check the reserves of the user, and if they can reserve a document
142
    # we check the reserves of the user, and if they can reserve a document
143
    # FIXME At this time we have a simple count of reservs, but, later, we could improve the infos "title" ...
143
    # FIXME At this time we have a simple count of reservs, but, later, we could improve the infos "title" ...
144
144
145
    my $reserves_count =
145
    my $reserves_count = $patron->holds->count;
146
      GetReserveCount( $patron->borrowernumber );
147
146
148
    my $new_reserves_count = scalar( @biblionumbers );
147
    my $new_reserves_count = scalar( @biblionumbers );
149
148
(-)a/t/db_dependent/Holds.t (-5 / +1 lines)
Lines 7-13 use t::lib::TestBuilder; Link Here
7
7
8
use C4::Context;
8
use C4::Context;
9
9
10
use Test::More tests => 57;
10
use Test::More tests => 56;
11
use MARC::Record;
11
use MARC::Record;
12
use C4::Biblio;
12
use C4::Biblio;
13
use C4::Items;
13
use C4::Items;
Lines 127-135 $holds = $patron->holds; Link Here
127
is( $holds->next->borrowernumber, $borrowernumbers[0], "Test Koha::Patron->holds");
127
is( $holds->next->borrowernumber, $borrowernumbers[0], "Test Koha::Patron->holds");
128
128
129
129
130
ok( GetReserveCount( $borrowernumbers[0] ), "Test GetReserveCount()" );
131
132
133
CancelReserve({ 'reserve_id' => $reserve_id });
130
CancelReserve({ 'reserve_id' => $reserve_id });
134
$holds = $biblio->holds;
131
$holds = $biblio->holds;
135
is( $holds->count, $borrowers_count - 1, "Test CancelReserve()" );
132
is( $holds->count, $borrowers_count - 1, "Test CancelReserve()" );
136
- 

Return to bug 19056