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

(-)a/opac/opac-reserve.pl (-48 / +45 lines)
Lines 130-178 $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 =
149
      $biblio->items->filter_by_visible_in_opac( { patron => $patron } );
150
    my $host_items =
151
      $biblio->host_items->filter_by_visible_in_opac( { patron => $patron } );
152
    $items = $biblio->items->search_ordered(
153
        {
154
            itemnumber => {
155
                -in => [
156
                    $items->get_column('itemnumber'),
157
                    $host_items->get_column('itemnumber')
158
                ]
159
            }
160
        }
161
    );
162
163
    $biblioData->{items} = [$items->as_list]; # FIXME Potentially a lot in memory here!
164
165
    # Compute the priority rank.
166
    $biblioData->{object} = $biblio;
167
    my $reservecount = $biblio->holds->search({ found => [ {"!=" => "W"},undef] })->count;
168
    $biblioData->{reservecount} = $reservecount;
169
    $biblioData->{rank} = $reservecount + 1;
170
}
171
172
#
173
#
174
# If this is the second time through this script, it
175
# means we are carrying out the hold request, possibly
176
# with a specific item for each biblionumber.
134
# with a specific item for each biblionumber.
177
#
135
#
178
#
136
#
Lines 245-252 if ( $query->param('place_reserve') ) { Link Here
245
            $biblioNum = $item->biblionumber;
203
            $biblioNum = $item->biblionumber;
246
        }
204
        }
247
205
248
        my $biblioData = $biblioDataHash{$biblioNum};
249
250
        # Check for user supplied reserve date
206
        # Check for user supplied reserve date
251
        my $startdate;
207
        my $startdate;
252
        if (   C4::Context->preference('AllowHoldDateInFuture')
208
        if (   C4::Context->preference('AllowHoldDateInFuture')
Lines 260-266 if ( $query->param('place_reserve') ) { Link Here
260
        my $itemtype = $query->param('itemtype') || undef;
216
        my $itemtype = $query->param('itemtype') || undef;
261
        $itemtype = undef if $itemNum;
217
        $itemtype = undef if $itemNum;
262
218
263
        my $rank = $biblioData->{rank};
219
        my $biblio = Koha::Biblios->find($biblioNum);
220
        my $rank = $biblio->holds->search( { found => [ { "!=" => "W" }, undef ] } )->count + 1;
264
        if ( $item ) {
221
        if ( $item ) {
265
            $canreserve = 1 if CanItemBeReserved( $patron, $item, $branch )->{status} eq 'OK';
222
            $canreserve = 1 if CanItemBeReserved( $patron, $item, $branch )->{status} eq 'OK';
266
        }
223
        }
Lines 299-305 if ( $query->param('place_reserve') ) { Link Here
299
                    reservation_date => $startdate,
256
                    reservation_date => $startdate,
300
                    expiration_date  => $patron_expiration_date,
257
                    expiration_date  => $patron_expiration_date,
301
                    notes            => $notes,
258
                    notes            => $notes,
302
                    title            => $biblioData->{title},
259
                    title            => $biblio->title,
303
                    itemnumber       => $itemNum,
260
                    itemnumber       => $itemNum,
304
                    found            => undef,
261
                    found            => undef,
305
                    itemtype         => $itemtype,
262
                    itemtype         => $itemtype,
Lines 314-319 if ( $query->param('place_reserve') ) { Link Here
314
    exit;
271
    exit;
315
}
272
}
316
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 =
292
      $biblio->items->filter_by_visible_in_opac( { patron => $patron } );
293
    my $host_items =
294
      $biblio->host_items->filter_by_visible_in_opac( { patron => $patron } );
295
    $items = $biblio->items->search_ordered(
296
        {
297
            itemnumber => {
298
                -in => [
299
                    $items->get_column('itemnumber'),
300
                    $host_items->get_column('itemnumber')
301
                ]
302
            }
303
        }
304
    );
305
306
    $biblioData->{items} = [$items->as_list]; # FIXME Potentially a lot in memory here!
307
308
    # Compute the priority rank.
309
    $biblioData->{object} = $biblio;
310
    my $reservecount = $biblio->holds->search({ found => [ {"!=" => "W"},undef] })->count;
311
    $biblioData->{reservecount} = $reservecount;
312
    $biblioData->{rank} = $reservecount + 1;
313
}
314
317
#
315
#
318
#
316
#
319
# Here we check that the borrower can actually make reserves Stage 1.
317
# Here we check that the borrower can actually make reserves Stage 1.
320
- 

Return to bug 30847