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

(-)a/C4/XSLT.pm (-12 / +24 lines)
Lines 190-196 sub get_xslt_sysprefs { Link Here
190
}
190
}
191
191
192
sub XSLTParse4Display {
192
sub XSLTParse4Display {
193
    my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items, $sysxml, $xslfilename, $lang, $variables ) = @_;
193
    my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items, $sysxml, $xslfilename, $lang, $variables, $items_rs ) = @_;
194
194
195
    $sysxml ||= C4::Context->preference($xslsyspref);
195
    $sysxml ||= C4::Context->preference($xslsyspref);
196
    $xslfilename ||= C4::Context->preference($xslsyspref);
196
    $xslfilename ||= C4::Context->preference($xslsyspref);
Lines 246-252 sub XSLTParse4Display { Link Here
246
    if ( $xslsyspref eq "OPACXSLTDetailsDisplay" || $xslsyspref eq "XSLTDetailsDisplay" || $xslsyspref eq "XSLTResultsDisplay" ) {
246
    if ( $xslsyspref eq "OPACXSLTDetailsDisplay" || $xslsyspref eq "XSLTDetailsDisplay" || $xslsyspref eq "XSLTResultsDisplay" ) {
247
        $itemsxml = ""; #We don't use XSLT for items display on these pages
247
        $itemsxml = ""; #We don't use XSLT for items display on these pages
248
    } else {
248
    } else {
249
        $itemsxml = buildKohaItemsNamespace($biblionumber, $hidden_items);
249
        $itemsxml = buildKohaItemsNamespace($biblionumber, $hidden_items, $items_rs);
250
    }
250
    }
251
    my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour'));
251
    my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour'));
252
252
Lines 289-310 sub XSLTParse4Display { Link Here
289
289
290
=head2 buildKohaItemsNamespace
290
=head2 buildKohaItemsNamespace
291
291
292
Returns XML for items.
292
    my $items_xml = buildKohaItemsNamespace( $biblionumber, [ $hidden_items, $items ] );
293
294
Returns XML for items. It accepts two optional parameters:
295
- I<$hidden_items>: An arrayref of itemnumber values, for items that should be hidden
296
- I<$items>: A Koha::Items resultset, for the items to be returned
297
298
If both parameters are passed, I<$items> is used as the basis resultset, and I<$hidden_items>
299
are filtered out of it.
300
293
Is only used in this module currently.
301
Is only used in this module currently.
294
302
295
=cut
303
=cut
296
304
297
sub buildKohaItemsNamespace {
305
sub buildKohaItemsNamespace {
298
    my ($biblionumber, $hidden_items) = @_;
306
    my ($biblionumber, $hidden_items, $items_rs) = @_;
299
307
300
    $hidden_items ||= [];
308
    $hidden_items ||= [];
301
    my @items = Koha::Items->search(
309
302
        {
310
    my $query = {};
303
            'me.biblionumber' => $biblionumber,
311
    $query = { 'me.itemnumber' => { not_in => $hidden_items } }
304
            'me.itemnumber'   => { not_in => $hidden_items }
312
      if $hidden_items;
305
        },
313
306
        { prefetch => [ 'branchtransfers', 'reserves' ] }
314
    unless ( $items_rs && ref($items_rs) eq 'Koha::Items' ) {
307
    );
315
        $query->{'me.biblionumber'} = $biblionumber;
316
        $items_rs = Koha::Items->new;
317
    }
318
319
    my $items = $items_rs->search( $query, { prefetch => [ 'branchtransfers', 'reserves' ] } );
308
320
309
    my $shelflocations =
321
    my $shelflocations =
310
      { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => "", kohafield => 'items.location' } ) };
322
      { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => "", kohafield => 'items.location' } ) };
Lines 318-324 sub buildKohaItemsNamespace { Link Here
318
    my %descs = map { $_->{authorised_value} => $_ } Koha::AuthorisedValues->get_descriptions_by_koha_field( { kohafield => 'items.notforloan' } );
330
    my %descs = map { $_->{authorised_value} => $_ } Koha::AuthorisedValues->get_descriptions_by_koha_field( { kohafield => 'items.notforloan' } );
319
    my $ref_status = C4::Context->preference('Reference_NFL_Statuses') || '1|2';
331
    my $ref_status = C4::Context->preference('Reference_NFL_Statuses') || '1|2';
320
332
321
    for my $item (@items) {
333
    while ( my $item = $items->next ) {
322
        my $status;
334
        my $status;
323
        my $substatus = '';
335
        my $substatus = '';
324
336
(-)a/opac/opac-shelves.pl (-13 / +7 lines)
Lines 346-368 if ( $op eq 'view' ) { Link Here
346
                    });
346
                    });
347
                }
347
                }
348
348
349
                my @items;
349
                my $items = $biblio->items->filter_by_visible_in_opac({ patron => $patron });
350
                my $items = $biblio->items;
351
                my $allow_onshelf_holds;
350
                my $allow_onshelf_holds;
352
                my @hidden_items;
353
                while ( my $item = $items->next ) {
351
                while ( my $item = $items->next ) {
354
                    if ( $item->hidden_in_opac({rules => C4::Context->yaml_preference('OpacHiddenItems')} ) ) {
355
                        push @hidden_items, $item->itemnumber;
356
                        next;
357
                    }
358
352
353
                    # This method must take a Koha::Items rs
359
                    $allow_onshelf_holds ||= Koha::CirculationRules->get_onshelfholds_policy(
354
                    $allow_onshelf_holds ||= Koha::CirculationRules->get_onshelfholds_policy(
360
                        { item => $item, patron => $patron } );
355
                        { item => $item, patron => $patron } );
361
356
362
                    push @items, $item; # This is for non-xslt only
363
                }
357
                }
358
364
                $this_item->{allow_onshelf_holds} = $allow_onshelf_holds;
359
                $this_item->{allow_onshelf_holds} = $allow_onshelf_holds;
365
                $this_item->{'ITEM_RESULTS'} = \@items;
360
                $this_item->{'ITEM_RESULTS'} = $items;
366
361
367
                if ($xslfile) {
362
                if ($xslfile) {
368
                    my $variables = {
363
                    my $variables = {
Lines 371-379 if ( $op eq 'view' ) { Link Here
371
                    $this_item->{XSLTBloc} = XSLTParse4Display(
366
                    $this_item->{XSLTBloc} = XSLTParse4Display(
372
                        $biblionumber,          $record,
367
                        $biblionumber,          $record,
373
                        "OPACXSLTListsDisplay", 1,
368
                        "OPACXSLTListsDisplay", 1,
374
                        \@hidden_items,         $sysxml,
369
                        undef,                 $sysxml,
375
                        $xslfile,               $lang,
370
                        $xslfile,              $lang,
376
                        $variables
371
                        $variables,            $items->reset
377
                    );
372
                    );
378
                }
373
                }
379
374
380
- 

Return to bug 28299