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

(-)a/C4/VirtualShelves/Page.pm (-45 / +68 lines)
Lines 74-80 sub shelfpage { Link Here
74
    my $itemoff     = ( $query->param('itemoff')  ? $query->param('itemoff')  : 1 );
74
    my $itemoff     = ( $query->param('itemoff')  ? $query->param('itemoff')  : 1 );
75
    my $displaymode = ( $query->param('display')  ? $query->param('display')  : 'publicshelves' );
75
    my $displaymode = ( $query->param('display')  ? $query->param('display')  : 'publicshelves' );
76
    my ( $shelflimit, $shelfoffset, $shelveslimit, $shelvesoffset );
76
    my ( $shelflimit, $shelfoffset, $shelveslimit, $shelvesoffset );
77
    my $marcflavour = C4::Context->preference("marcflavour");
78
77
79
    $shelflimit = ( $type eq 'opac' ? C4::Context->preference('OPACnumSearchResults') : C4::Context->preference('numSearchResults') );
78
    $shelflimit = ( $type eq 'opac' ? C4::Context->preference('OPACnumSearchResults') : C4::Context->preference('numSearchResults') );
80
    $shelflimit = $shelflimit || ShelvesMax('MGRPAGE');
79
    $shelflimit = $shelflimit || ShelvesMax('MGRPAGE');
Lines 240-246 sub shelfpage { Link Here
240
            #check that the user can view the shelf
239
            #check that the user can view the shelf
241
            if ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'view' ) ) {
240
            if ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'view' ) ) {
242
                my $items;
241
                my $items;
243
                my $tag_quantity;
244
                my $sortfield = ( $sorton ? $sorton : 'title' );
242
                my $sortfield = ( $sorton ? $sorton : 'title' );
245
                $sortfield = $query->param('sort') || $sortfield; ## Passed in sorting overrides default sorting
243
                $sortfield = $query->param('sort') || $sortfield; ## Passed in sorting overrides default sorting
246
                my $direction = $query->param('direction') || 'asc';
244
                my $direction = $query->param('direction') || 'asc';
Lines 248-255 sub shelfpage { Link Here
248
                    sort      => $sortfield,
246
                    sort      => $sortfield,
249
                    direction => $direction,
247
                    direction => $direction,
250
                );
248
                );
251
                ( $items, $totitems ) = GetShelfContents( $shelfnumber, $shelflimit, $shelfoffset, $sortfield, $direction );
252
253
                # get biblionumbers stored in the cart
249
                # get biblionumbers stored in the cart
254
                # Note that it's not use at the intranet
250
                # Note that it's not use at the intranet
255
                my @cart_list;
251
                my @cart_list;
Lines 259-305 sub shelfpage { Link Here
259
                    @cart_list = split(/\//, $cart_list);
255
                    @cart_list = split(/\//, $cart_list);
260
                }
256
                }
261
257
262
                my $borrower = GetMember( 'borrowernumber' => $loggedinuser );
258
                ( $items, $totitems ) = shelf_contents({
263
259
                    borrower => GetMember( 'borrowernumber' => $loggedinuser ),
264
                for my $this_item (@$items) {
260
                    shelfnumber => $shelfnumber,
265
                    my $biblionumber = $this_item->{'biblionumber'};
261
                    shelflimit => $shelflimit,
266
                    # Getting items infos for location display
262
                    shelfoffset => $shelfoffset,
267
                    my @items_infos = &GetItemsInfo( $this_item->{'biblionumber'}, "cn_sort" );
263
                    sortfield => $sortfield,
268
                    my $record = GetMarcBiblio($biblionumber);
264
                    direction => $direction,
269
                    if (C4::Context->preference("OPACXSLTResultsDisplay") && $type eq 'opac') {
265
                    type => $type,
270
                        $this_item->{XSLTBloc} = XSLTParse4Display($biblionumber, $record, "OPACXSLTResultsDisplay", \@items_infos);
266
                    cart_list => \@cart_list,
271
                    } elsif (C4::Context->preference("XSLTResultsDisplay") && $type eq 'intranet') {
267
                });
272
                        $this_item->{XSLTBloc} = XSLTParse4Display($biblionumber, $record, "XSLTResultsDisplay", \@items_infos);
273
                    }
274
275
                    # the virtualshelfcontents table does not store these columns nor are they retrieved from the items
276
                    # and itemtypes tables, so I'm commenting them out for now to quiet the log -crn
277
                    #$this_item->{imageurl} = $imgdir."/".$itemtypes->{ $this_item->{itemtype}  }->{'imageurl'};
278
                    #$this_item->{'description'} = $itemtypes->{ $this_item->{itemtype} }->{'description'};
279
                    $this_item->{'dateadded'} = format_date( $this_item->{'dateadded'} );
280
                    $this_item->{'imageurl'}  = getitemtypeinfo( $this_item->{'itemtype'}, $type )->{'imageurl'};
281
                    $this_item->{'coins'}     = GetCOinSBiblio( $record );
282
                    $this_item->{'subtitle'} = GetRecordValue('subtitle', $record, GetFrameworkCode($this_item->{'biblionumber'}));
283
                    $this_item->{'normalized_upc'}  = GetNormalizedUPC(       $record,$marcflavour);
284
                    $this_item->{'normalized_ean'}  = GetNormalizedEAN(       $record,$marcflavour);
285
                    $this_item->{'normalized_oclc'} = GetNormalizedOCLCNumber($record,$marcflavour);
286
                    $this_item->{'normalized_isbn'} = GetNormalizedISBN(undef,$record,$marcflavour);
287
                    if(!defined($this_item->{'size'})) { $this_item->{'size'} = "" }; #TT has problems with size
288
                    $this_item->{'itemsissued'} = CountItemsIssued( $this_item->{'biblionumber'} );
289
                    $this_item->{'ITEM_RESULTS'} = \@items_infos;
290
                    if ( grep {$_ eq $biblionumber} @cart_list) {
291
                        $this_item->{'incart'} = 1;
292
                    }
293
294
                    if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->preference('TagsShowOnList')) {
295
                        $this_item->{'TagLoop'} = get_tags({
296
                            biblionumber=>$this_item->{'biblionumber'}, approved=>1, 'sort'=>'-weight',
297
                            limit=>$tag_quantity
298
                            });
299
                    }
300
301
                    $this_item->{'allow_onshelf_holds'} = C4::Reserves::OnShelfHoldsAllowed($this_item, $borrower);
302
                }
303
                if($type eq 'intranet'){
268
                if($type eq 'intranet'){
304
                    # Build drop-down list for 'Add To:' menu...
269
                    # Build drop-down list for 'Add To:' menu...
305
                    my ($totalref, $pubshelves, $barshelves)=
270
                    my ($totalref, $pubshelves, $barshelves)=
Lines 505-510 sub shelfpage { Link Here
505
    output_html_with_http_headers $query, $cookie, $template->output;
470
    output_html_with_http_headers $query, $cookie, $template->output;
506
}
471
}
507
472
473
sub shelf_contents {
474
    my ( $params ) = @_;
475
    my $borrower = $params->{borrower};
476
    my $shelfnumber = $params->{shelfnumber};
477
    my $shelflimit = $params->{shelflimit};
478
    my $shelfoffset = $params->{shelfoffset};
479
    my $sortfield = $params->{sortfield};
480
    my $direction = $params->{direction};
481
    my $type = $params->{type};
482
    my $cart_list = $params->{cart_list};
483
484
    my $marcflavour = C4::Context->preference("marcflavour");
485
    my $tag_quantity = C4::Context->preference('TagsEnabled')
486
      ? C4::Context->preference('TagsShowOnList')
487
      : undef;
488
    my ( $items, $totitems ) = GetShelfContents( $shelfnumber, $shelflimit, $shelfoffset, $sortfield, $direction );
489
    for my $this_item (@$items) {
490
        my $biblionumber = $this_item->{'biblionumber'};
491
        # Getting items infos for location display
492
        my @items_infos = &GetItemsInfo( $this_item->{'biblionumber'}, "cn_sort" );
493
        my $record = GetMarcBiblio($biblionumber);
494
        if (C4::Context->preference("OPACXSLTResultsDisplay") && $type eq 'opac') {
495
            $this_item->{XSLTBloc} = XSLTParse4Display($biblionumber, $record, "OPACXSLTResultsDisplay", \@items_infos);
496
        } elsif (C4::Context->preference("XSLTResultsDisplay") && $type eq 'intranet') {
497
            $this_item->{XSLTBloc} = XSLTParse4Display($biblionumber, $record, "XSLTResultsDisplay", \@items_infos);
498
        }
499
500
        # the virtualshelfcontents table does not store these columns nor are they retrieved from the items
501
        # and itemtypes tables, so I'm commenting them out for now to quiet the log -crn
502
        #$this_item->{imageurl} = $imgdir."/".$itemtypes->{ $this_item->{itemtype}  }->{'imageurl'};
503
        #$this_item->{'description'} = $itemtypes->{ $this_item->{itemtype} }->{'description'};
504
        $this_item->{'dateadded'} = format_date( $this_item->{'dateadded'} );
505
        $this_item->{'imageurl'}  = getitemtypeinfo( $this_item->{'itemtype'}, $type )->{'imageurl'};
506
        $this_item->{'coins'}     = GetCOinSBiblio( $record );
507
        $this_item->{'subtitle'} = GetRecordValue('subtitle', $record, GetFrameworkCode($this_item->{'biblionumber'}));
508
        $this_item->{'normalized_upc'}  = GetNormalizedUPC(       $record,$marcflavour);
509
        $this_item->{'normalized_ean'}  = GetNormalizedEAN(       $record,$marcflavour);
510
        $this_item->{'normalized_oclc'} = GetNormalizedOCLCNumber($record,$marcflavour);
511
        $this_item->{'normalized_isbn'} = GetNormalizedISBN(undef,$record,$marcflavour);
512
        if(!defined($this_item->{'size'})) { $this_item->{'size'} = "" }; #TT has problems with size
513
        $this_item->{'itemsissued'} = CountItemsIssued( $this_item->{'biblionumber'} );
514
        $this_item->{'ITEM_RESULTS'} = \@items_infos;
515
        if ( $cart_list && grep {$_ eq $biblionumber} @$cart_list) {
516
            $this_item->{'incart'} = 1;
517
        }
518
519
        if ($tag_quantity) {
520
            $this_item->{'TagLoop'} = get_tags({
521
                biblionumber=>$this_item->{'biblionumber'}, approved=>1, 'sort'=>'-weight',
522
                limit=>$tag_quantity
523
                });
524
        }
525
526
        $this_item->{'allow_onshelf_holds'} = C4::Reserves::OnShelfHoldsAllowed($this_item, $borrower);
527
    }
528
    return ( $items, $totitems );
529
}
530
508
1;
531
1;
509
__END__
532
__END__
510
533
(-)a/t/db_dependent/VirtualShelves_Page.t (-2 / +42 lines)
Lines 6-14 Link Here
6
use strict;
6
use strict;
7
use warnings;
7
use warnings;
8
8
9
use Test::More tests => 1;
9
use Test::More tests => 3;
10
11
use C4::Context;
10
12
11
BEGIN {
13
BEGIN {
12
        use_ok('C4::VirtualShelves::Page');
14
        use_ok('C4::VirtualShelves::Page');
13
}
15
}
14
16
15
- 
17
my $dbh = C4::Context->dbh;
18
# Start transaction
19
$dbh->{AutoCommit} = 0;
20
$dbh->{RaiseError} = 1;
21
22
C4::Context->set_preference('XSLTResultsDisplay', 'default');
23
C4::Context->set_preference('OPACXSLTResultsDisplay', 'default');
24
C4::Context->clear_syspref_cache();
25
26
my $query = qq{
27
    SELECT vs.shelfnumber, vs.shelfname,vs.owner,
28
    bo.surname,bo.firstname,vs.category,vs.sortfield,
29
    count(vc.biblionumber) as count
30
    FROM virtualshelves vs
31
    JOIN borrowers bo ON vs.owner=bo.borrowernumber
32
    JOIN virtualshelfcontents vc USING (shelfnumber)
33
    GROUP BY vs.shelfnumber
34
    LIMIT 1
35
};
36
my $shelf = $dbh->selectrow_hashref($query);
37
38
my %params = (
39
    shelfnumber => $shelf->{shelfnumber},
40
    shelflimit => 1,
41
    shelfoffset => 0,
42
    sortfield => $shelf->{sortfield},
43
    direction => 'asc',
44
    type => 'opac',
45
    cart_list => [],
46
);
47
my ( $items, $totitems ) = C4::VirtualShelves::Page::shelf_contents(\%params);
48
ok( $items->[0]{XSLTBloc}, "opac items XSLT");
49
50
$params{type} = 'intranet';
51
( $items, $totitems ) = C4::VirtualShelves::Page::shelf_contents(\%params);
52
ok( $items->[0]{XSLTBloc}, "intranet items XSLT");
53
54
# Cleanup
55
$dbh->rollback;

Return to bug 11213