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

(-)a/C4/ILSDI/Services.pm (-22 / +4 lines)
Lines 26-32 use C4::Circulation; Link Here
26
use C4::Branch;
26
use C4::Branch;
27
use C4::Accounts;
27
use C4::Accounts;
28
use C4::Biblio;
28
use C4::Biblio;
29
use C4::Reserves qw(AddReserve CancelReserve GetReservesFromBiblionumber GetReservesFromBorrowernumber CanBookBeReserved CanItemBeReserved GetReserveNextRank);
29
use C4::Reserves qw(AddReserve CancelReserve GetReservesFromBiblionumber GetReservesFromBorrowernumber CanBookBeReserved CanItemBeReserved);
30
use C4::Context;
30
use C4::Context;
31
use C4::AuthoritiesMarc;
31
use C4::AuthoritiesMarc;
32
use C4::ILSDI::Utility;
32
use C4::ILSDI::Utility;
Lines 623-633 sub HoldTitle { Link Here
623
        $branch = $$borrower{branchcode};
623
        $branch = $$borrower{branchcode};
624
    }
624
    }
625
625
626
    my $rank = GetReserveNextRank($biblionumber);
627
628
    # Add the reserve
626
    # Add the reserve
629
    #          $branch, $borrowernumber, $biblionumber, $constraint, $bibitems,  $priority, $notes, $title, $checkitem,  $found
627
    #          $branch, $borrowernumber, $biblionumber, $constraint, $bibitems,  $priority, $notes, $title, $checkitem,  $found
630
    AddReserve( $branch, $borrowernumber, $biblionumber, 'a', undef, $rank, undef, $title, undef, undef );
628
    AddReserve( $branch, $borrowernumber, $biblionumber, 'a', undef, undef, undef, $title, undef, undef );
631
629
632
    # Hashref building
630
    # Hashref building
633
    my $out;
631
    my $out;
Lines 689-697 sub HoldItem { Link Here
689
    my $canbookbereserved = C4::Reserves::CanBookBeReserved( $borrowernumber, $biblionumber );
687
    my $canbookbereserved = C4::Reserves::CanBookBeReserved( $borrowernumber, $biblionumber );
690
    return { code => 'NotHoldable' } unless $canbookbereserved and $canitembereserved;
688
    return { code => 'NotHoldable' } unless $canbookbereserved and $canitembereserved;
691
689
692
    my $branch;
693
694
    # Pickup branch management
690
    # Pickup branch management
691
    my $branch;
695
    if ( $cgi->param('pickup_location') ) {
692
    if ( $cgi->param('pickup_location') ) {
696
        $branch = $cgi->param('pickup_location');
693
        $branch = $cgi->param('pickup_location');
697
        my $branches = GetBranches();
694
        my $branches = GetBranches();
Lines 700-723 sub HoldItem { Link Here
700
        $branch = $$borrower{branchcode};
697
        $branch = $$borrower{branchcode};
701
    }
698
    }
702
699
703
    my $rank;
704
    my $found;
705
706
    # Get rank and found
707
    if (C4::Context->preference('ReservesNeedReturns')) {
708
        $rank = GetReserveNextRank($biblionumber);
709
    } else {
710
        $rank = '0';
711
        if ($item->{'holdingbranch'} eq $branch) {
712
            $found = 'W';
713
        } else {
714
            $found = 'T';
715
        }
716
    }
717
718
    # Add the reserve
700
    # Add the reserve
719
    # $branch,$borrowernumber,$biblionumber,$constraint,$bibitems,$priority,$resdate,$expdate,$notes,$title,$checkitem,$found
701
    # $branch,$borrowernumber,$biblionumber,$constraint,$bibitems,$priority,$resdate,$expdate,$notes,$title,$checkitem,$found
720
    AddReserve( $branch, $borrowernumber, $biblionumber, 'a', undef, $rank, '', '', '', $title, $itemnumber, $found );
702
    AddReserve( $branch, $borrowernumber, $biblionumber, 'a', undef, undef, '', '', '', $title, $itemnumber );
721
703
722
    # Hashref building
704
    # Hashref building
723
    my $out;
705
    my $out;
(-)a/C4/Reserves.pm (-2 / +22 lines)
Lines 164-172 sub AddReserve { Link Here
164
    } else {
164
    } else {
165
        undef $expdate; # make reserves.expirationdate default to null rather than '0000-00-00'
165
        undef $expdate; # make reserves.expirationdate default to null rather than '0000-00-00'
166
    }
166
    }
167
168
    # Calculate priority if not given
169
    if (not defined $priority) {
170
        if ($checkitem and not C4::Context->preference('ReservesNeedReturns')) {
171
            $priority = 0;
172
        } else {
173
            $priority = GetReserveNextRank($biblionumber);
174
        }
175
    }
176
177
    # Calculate found if not given
178
    if ($priority == 0 and not defined $found) {
179
        my $item = GetItem($checkitem);
180
        if ($item->{holdingbranch} eq $branch) {
181
            $found = 'W';
182
        } else {
183
            $found = 'T';
184
        }
185
    }
186
167
    if ( C4::Context->preference( 'AllowHoldDateInFuture' ) ) {
187
    if ( C4::Context->preference( 'AllowHoldDateInFuture' ) ) {
168
	# Make room in reserves for this before those of a later reserve date
188
        # Make room in reserves for this before those of a later reserve date
169
	$priority = _ShiftPriorityByDateAndPriority( $biblionumber, $resdate, $priority );
189
        $priority = _ShiftPriorityByDateAndPriority( $biblionumber, $resdate, $priority );
170
    }
190
    }
171
    my $waitingdate;
191
    my $waitingdate;
172
192
(-)a/opac/opac-reserve.pl (-12 / +2 lines)
Lines 223-229 if ( $query->param('place_reserve') ) { Link Here
223
        }
223
        }
224
224
225
        my $biblioData = $biblioDataHash{$biblioNum};
225
        my $biblioData = $biblioDataHash{$biblioNum};
226
        my $found;
227
226
228
        # Check for user supplied reserve date
227
        # Check for user supplied reserve date
229
        my $startdate;
228
        my $startdate;
Lines 235-251 if ( $query->param('place_reserve') ) { Link Here
235
234
236
        my $expiration_date = $query->param("expiration_date_$biblioNum");
235
        my $expiration_date = $query->param("expiration_date_$biblioNum");
237
236
238
      # If a specific item was selected and the pickup branch is the same as the
239
      # holdingbranch, force the value $rank and $found.
240
        my $rank = $biblioData->{rank};
241
        if ( $itemNum ne '' ) {
237
        if ( $itemNum ne '' ) {
242
            $canreserve = 1 if CanItemBeReserved( $borrowernumber, $itemNum );
238
            $canreserve = 1 if CanItemBeReserved( $borrowernumber, $itemNum );
243
            $rank = '0' unless C4::Context->preference('ReservesNeedReturns');
244
            my $item = GetItem($itemNum);
245
            if ( $item->{'holdingbranch'} eq $branch ) {
246
                $found = 'W'
247
                  unless C4::Context->preference('ReservesNeedReturns');
248
            }
249
        }
239
        }
250
        else {
240
        else {
251
            $canreserve = 1 if CanBookBeReserved( $borrowernumber, $biblioNum );
241
            $canreserve = 1 if CanBookBeReserved( $borrowernumber, $biblioNum );
Lines 266-275 if ( $query->param('place_reserve') ) { Link Here
266
            AddReserve(
256
            AddReserve(
267
                $branch,      $borrowernumber,
257
                $branch,      $borrowernumber,
268
                $biblioNum,   'a',
258
                $biblioNum,   'a',
269
                [$biblioNum], $rank,
259
                [$biblioNum], undef,
270
                $startdate,   $expiration_date,
260
                $startdate,   $expiration_date,
271
                $notes,       $biblioData->{title},
261
                $notes,       $biblioData->{title},
272
                $itemNum,     $found
262
                $itemNum,     undef
273
            );
263
            );
274
            ++$reserve_cnt;
264
            ++$reserve_cnt;
275
        }
265
        }
(-)a/reserve/placerequest.pl (-18 / +4 lines)
Lines 68-86 foreach my $bibnum (@biblionumbers) { Link Here
68
    $bibinfos{$bibnum} = \%bibinfo;
68
    $bibinfos{$bibnum} = \%bibinfo;
69
}
69
}
70
70
71
my $found;
72
73
# if we have an item selectionned, and the pickup branch is the same as the holdingbranch
74
# of the document, we force the value $rank and $found .
75
if ($checkitem ne ''){
76
    $rank[0] = '0' unless C4::Context->preference('ReservesNeedReturns');
77
    my $item = $checkitem;
78
    $item = GetItem($item);
79
    if ( $item->{'holdingbranch'} eq $branch ){
80
        $found = 'W' unless C4::Context->preference('ReservesNeedReturns');
81
    }
82
}
83
84
if ($type eq 'str8' && $borrower){
71
if ($type eq 'str8' && $borrower){
85
72
86
    foreach my $biblionumber (keys %bibinfos) {
73
    foreach my $biblionumber (keys %bibinfos) {
Lines 110-126 if ($type eq 'str8' && $borrower){ Link Here
110
        if ($multi_hold) {
97
        if ($multi_hold) {
111
            my $bibinfo = $bibinfos{$biblionumber};
98
            my $bibinfo = $bibinfos{$biblionumber};
112
            AddReserve($branch,$borrower->{'borrowernumber'},$biblionumber,'a',[$biblionumber],
99
            AddReserve($branch,$borrower->{'borrowernumber'},$biblionumber,'a',[$biblionumber],
113
                       $bibinfo->{rank},$startdate,$expirationdate,$notes,$bibinfo->{title},$checkitem,$found);
100
                       $bibinfo->{rank},$startdate,$expirationdate,$notes,$bibinfo->{title},$checkitem, undef);
114
        } else {
101
        } else {
115
            if ($input->param('request') eq 'any'){
102
            if ($input->param('request') eq 'any'){
116
                # place a request on 1st available
103
                # place a request on 1st available
117
                AddReserve($branch,$borrower->{'borrowernumber'},$biblionumber,'a',\@realbi,$rank[0],$startdate,$expirationdate,$notes,$title,$checkitem,$found);
104
                AddReserve($branch,$borrower->{'borrowernumber'},$biblionumber,'a',\@realbi,undef,$startdate,$expirationdate,$notes,$title,$checkitem,undef);
118
            } elsif ($reqbib[0] ne ''){
105
            } elsif ($reqbib[0] ne ''){
119
                # FIXME : elsif probably never reached, (see top of the script)
106
                # FIXME : elsif probably never reached, (see top of the script)
120
                # place a request on a given item
107
                # place a request on a given item
121
                AddReserve($branch,$borrower->{'borrowernumber'},$biblionumber,'o',\@reqbib,$rank[0],$startdate,$expirationdate,$notes,$title,$checkitem, $found);
108
                AddReserve($branch,$borrower->{'borrowernumber'},$biblionumber,'o',\@reqbib,undef,$startdate,$expirationdate,$notes,$title,$checkitem,undef);
122
            } else {
109
            } else {
123
                AddReserve($branch,$borrower->{'borrowernumber'},$biblionumber,'a',\@realbi,$rank[0],$startdate,$expirationdate,$notes,$title,$checkitem, $found);
110
                AddReserve($branch,$borrower->{'borrowernumber'},$biblionumber,'a',\@realbi,undef,$startdate,$expirationdate,$notes,$title,$checkitem,undef);
124
            }
111
            }
125
        }
112
        }
126
    }
113
    }
127
- 

Return to bug 8918