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

(-)a/opac/opac-reserve.pl (-45 / +42 lines)
Lines 130-175 $template->param( branch => $branch ); Link Here
130
130
131
#
131
#
132
#
132
#
133
# Build hashes of the requested biblio(item)s and items.
133
# Here we are carrying out the hold request, possibly
134
#
135
#
136
137
my %biblioDataHash; # Hash of biblionumber to biblio/biblioitems record.
138
foreach my $biblioNumber (@biblionumbers) {
139
140
    my $biblioData = GetBiblioData($biblioNumber);
141
    $biblioDataHash{$biblioNumber} = $biblioData;
142
143
    my $biblio = Koha::Biblios->find( $biblioNumber );
144
    next unless $biblio;
145
146
    my $marcrecord = $biblio->metadata->record;
147
148
    my $items = Koha::Items->search_ordered(
149
        [
150
            biblionumber => $biblioNumber,
151
            'me.itemnumber' => {
152
                -in => [
153
                    $biblio->host_items->get_column('itemnumber')
154
                ]
155
            }
156
        ],
157
        { prefetch => [ 'issue', 'homebranch', 'holdingbranch' ] }
158
    )->filter_by_visible_in_opac({ patron => $patron });
159
160
    $biblioData->{items} = [$items->as_list]; # FIXME Potentially a lot in memory here!
161
162
    # Compute the priority rank.
163
    $biblioData->{object} = $biblio;
164
    my $reservecount = $biblio->holds->search({ found => [ {"!=" => "W"},undef] })->count;
165
    $biblioData->{reservecount} = $reservecount;
166
    $biblioData->{rank} = $reservecount + 1;
167
}
168
169
#
170
#
171
# If this is the second time through this script, it
172
# means we are carrying out the hold request, possibly
173
# with a specific item for each biblionumber.
134
# with a specific item for each biblionumber.
174
#
135
#
175
#
136
#
Lines 242-249 if ( $query->param('place_reserve') ) { Link Here
242
            $biblioNum = $item->biblionumber;
203
            $biblioNum = $item->biblionumber;
243
        }
204
        }
244
205
245
        my $biblioData = $biblioDataHash{$biblioNum};
246
247
        # Check for user supplied reserve date
206
        # Check for user supplied reserve date
248
        my $startdate;
207
        my $startdate;
249
        if (   C4::Context->preference('AllowHoldDateInFuture')
208
        if (   C4::Context->preference('AllowHoldDateInFuture')
Lines 257-263 if ( $query->param('place_reserve') ) { Link Here
257
        my $itemtype = $query->param('itemtype') || undef;
216
        my $itemtype = $query->param('itemtype') || undef;
258
        $itemtype = undef if $itemNum;
217
        $itemtype = undef if $itemNum;
259
218
260
        my $rank = $biblioData->{rank};
219
        my $biblio = Koha::Biblios->find($biblioNum);
220
        my $rank = $biblio->holds->search( { found => [ { "!=" => "W" }, undef ] } )->count + 1;
261
        if ( $item ) {
221
        if ( $item ) {
262
            $canreserve = 1 if CanItemBeReserved( $patron, $item, $branch )->{status} eq 'OK';
222
            $canreserve = 1 if CanItemBeReserved( $patron, $item, $branch )->{status} eq 'OK';
263
        }
223
        }
Lines 296-302 if ( $query->param('place_reserve') ) { Link Here
296
                    reservation_date => $startdate,
256
                    reservation_date => $startdate,
297
                    expiration_date  => $patron_expiration_date,
257
                    expiration_date  => $patron_expiration_date,
298
                    notes            => $notes,
258
                    notes            => $notes,
299
                    title            => $biblioData->{title},
259
                    title            => $biblio->title,
300
                    itemnumber       => $itemNum,
260
                    itemnumber       => $itemNum,
301
                    found            => undef,
261
                    found            => undef,
302
                    itemtype         => $itemtype,
262
                    itemtype         => $itemtype,
Lines 311-316 if ( $query->param('place_reserve') ) { Link Here
311
    exit;
271
    exit;
312
}
272
}
313
273
274
#
275
#
276
# Build hashes of the requested biblio(item)s and items.
277
#
278
#
279
280
my %biblioDataHash; # Hash of biblionumber to biblio/biblioitems record.
281
foreach my $biblioNumber (@biblionumbers) {
282
283
    my $biblioData = GetBiblioData($biblioNumber);
284
    $biblioDataHash{$biblioNumber} = $biblioData;
285
286
    my $biblio = Koha::Biblios->find( $biblioNumber );
287
    next unless $biblio;
288
289
    my $marcrecord = $biblio->metadata->record;
290
291
    my $items = Koha::Items->search_ordered(
292
        [
293
            biblionumber => $biblioNumber,
294
            'me.itemnumber' => {
295
                -in => [
296
                    $biblio->host_items->get_column('itemnumber')
297
                ]
298
            }
299
        ],
300
        { prefetch => [ 'issue', 'homebranch', 'holdingbranch' ] }
301
    )->filter_by_visible_in_opac({ patron => $patron });
302
303
    $biblioData->{items} = [$items->as_list]; # FIXME Potentially a lot in memory here!
304
305
    # Compute the priority rank.
306
    $biblioData->{object} = $biblio;
307
    my $reservecount = $biblio->holds->search({ found => [ {"!=" => "W"},undef] })->count;
308
    $biblioData->{reservecount} = $reservecount;
309
    $biblioData->{rank} = $reservecount + 1;
310
}
311
314
#
312
#
315
#
313
#
316
# Here we check that the borrower can actually make reserves Stage 1.
314
# Here we check that the borrower can actually make reserves Stage 1.
317
- 

Return to bug 30847