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 626-636 sub HoldTitle { Link Here
626
        $branch = $$borrower{branchcode};
626
        $branch = $$borrower{branchcode};
627
    }
627
    }
628
628
629
    my $rank = GetReserveNextRank($biblionumber);
630
631
    # Add the reserve
629
    # Add the reserve
632
    #          $branch, $borrowernumber, $biblionumber, $constraint, $bibitems,  $priority, $notes, $title, $checkitem,  $found
630
    #          $branch, $borrowernumber, $biblionumber, $constraint, $bibitems,  $priority, $notes, $title, $checkitem,  $found
633
    AddReserve( $branch, $borrowernumber, $biblionumber, 'a', undef, $rank, undef, $title, undef, undef );
631
    AddReserve( $branch, $borrowernumber, $biblionumber, 'a', undef, undef, undef, $title, undef, undef );
634
632
635
    # Hashref building
633
    # Hashref building
636
    my $out;
634
    my $out;
Lines 692-700 sub HoldItem { Link Here
692
    my $canbookbereserved = C4::Reserves::CanBookBeReserved( $borrowernumber, $biblionumber );
690
    my $canbookbereserved = C4::Reserves::CanBookBeReserved( $borrowernumber, $biblionumber );
693
    return { code => 'NotHoldable' } unless $canbookbereserved and $canitembereserved;
691
    return { code => 'NotHoldable' } unless $canbookbereserved and $canitembereserved;
694
692
695
    my $branch;
696
697
    # Pickup branch management
693
    # Pickup branch management
694
    my $branch;
698
    if ( $cgi->param('pickup_location') ) {
695
    if ( $cgi->param('pickup_location') ) {
699
        $branch = $cgi->param('pickup_location');
696
        $branch = $cgi->param('pickup_location');
700
        my $branches = GetBranches();
697
        my $branches = GetBranches();
Lines 703-726 sub HoldItem { Link Here
703
        $branch = $$borrower{branchcode};
700
        $branch = $$borrower{branchcode};
704
    }
701
    }
705
702
706
    my $rank;
707
    my $found;
708
709
    # Get rank and found
710
    if (C4::Context->preference('ReservesNeedReturns')) {
711
        $rank = GetReserveNextRank($biblionumber);
712
    } else {
713
        $rank = '0';
714
        if ($item->{'holdingbranch'} eq $branch) {
715
            $found = 'W';
716
        } else {
717
            $found = 'T';
718
        }
719
    }
720
721
    # Add the reserve
703
    # Add the reserve
722
    # $branch,$borrowernumber,$biblionumber,$constraint,$bibitems,$priority,$resdate,$expdate,$notes,$title,$checkitem,$found
704
    # $branch,$borrowernumber,$biblionumber,$constraint,$bibitems,$priority,$resdate,$expdate,$notes,$title,$checkitem,$found
723
    AddReserve( $branch, $borrowernumber, $biblionumber, 'a', undef, $rank, '', '', '', $title, $itemnumber, $found );
705
    AddReserve( $branch, $borrowernumber, $biblionumber, 'a', undef, undef, '', '', '', $title, $itemnumber );
724
706
725
    # Hashref building
707
    # Hashref building
726
    my $out;
708
    my $out;
(-)a/C4/Reserves.pm (-2 / +22 lines)
Lines 162-170 sub AddReserve { Link Here
162
    } else {
162
    } else {
163
        undef $expdate; # make reserves.expirationdate default to null rather than '0000-00-00'
163
        undef $expdate; # make reserves.expirationdate default to null rather than '0000-00-00'
164
    }
164
    }
165
166
    # Calculate priority if not given
167
    if (not defined $priority) {
168
        if ($checkitem and not C4::Context->preference('ReservesNeedReturns')) {
169
            $priority = 0;
170
        } else {
171
            $priority = GetReserveNextRank($biblionumber);
172
        }
173
    }
174
175
    # Calculate found if not given
176
    if ($priority == 0 and not defined $found) {
177
        my $item = GetItem($checkitem);
178
        if ($item->{holdingbranch} eq $branch) {
179
            $found = 'W';
180
        } else {
181
            $found = 'T';
182
        }
183
    }
184
165
    if ( C4::Context->preference( 'AllowHoldDateInFuture' ) ) {
185
    if ( C4::Context->preference( 'AllowHoldDateInFuture' ) ) {
166
	# Make room in reserves for this before those of a later reserve date
186
        # Make room in reserves for this before those of a later reserve date
167
	$priority = _ShiftPriorityByDateAndPriority( $biblionumber, $resdate, $priority );
187
        $priority = _ShiftPriorityByDateAndPriority( $biblionumber, $resdate, $priority );
168
    }
188
    }
169
    my $waitingdate;
189
    my $waitingdate;
170
190
(-)a/opac/opac-reserve.pl (-12 / +2 lines)
Lines 224-230 if ( $query->param('place_reserve') ) { Link Here
224
        }
224
        }
225
225
226
        my $biblioData = $biblioDataHash{$biblioNum};
226
        my $biblioData = $biblioDataHash{$biblioNum};
227
        my $found;
228
227
229
        # Check for user supplied reserve date
228
        # Check for user supplied reserve date
230
        my $startdate;
229
        my $startdate;
Lines 236-252 if ( $query->param('place_reserve') ) { Link Here
236
235
237
        my $expiration_date = $query->param("expiration_date_$biblioNum");
236
        my $expiration_date = $query->param("expiration_date_$biblioNum");
238
237
239
      # If a specific item was selected and the pickup branch is the same as the
240
      # holdingbranch, force the value $rank and $found.
241
        my $rank = $biblioData->{rank};
242
        if ( $itemNum ne '' ) {
238
        if ( $itemNum ne '' ) {
243
            $canreserve = 1 if CanItemBeReserved( $borrowernumber, $itemNum );
239
            $canreserve = 1 if CanItemBeReserved( $borrowernumber, $itemNum );
244
            $rank = '0' unless C4::Context->preference('ReservesNeedReturns');
245
            my $item = GetItem($itemNum);
246
            if ( $item->{'holdingbranch'} eq $branch ) {
247
                $found = 'W'
248
                  unless C4::Context->preference('ReservesNeedReturns');
249
            }
250
        }
240
        }
251
        else {
241
        else {
252
            $canreserve = 1 if CanBookBeReserved( $borrowernumber, $biblioNum );
242
            $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