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

(-)a/C4/VirtualShelves/Page.pm (-41 / +64 lines)
Lines 73-79 sub shelfpage { Link Here
73
    my $itemoff     = ( $query->param('itemoff')  ? $query->param('itemoff')  : 1 );
73
    my $itemoff     = ( $query->param('itemoff')  ? $query->param('itemoff')  : 1 );
74
    my $displaymode = ( $query->param('display')  ? $query->param('display')  : 'publicshelves' );
74
    my $displaymode = ( $query->param('display')  ? $query->param('display')  : 'publicshelves' );
75
    my ( $shelflimit, $shelfoffset, $shelveslimit, $shelvesoffset );
75
    my ( $shelflimit, $shelfoffset, $shelveslimit, $shelvesoffset );
76
    my $marcflavour = C4::Context->preference("marcflavour");
77
76
78
    # get biblionumbers stored in the cart
77
    # get biblionumbers stored in the cart
79
    my @cart_list;
78
    my @cart_list;
Lines 250-256 sub shelfpage { Link Here
250
            #check that the user can view the shelf
249
            #check that the user can view the shelf
251
            if ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'view' ) ) {
250
            if ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'view' ) ) {
252
                my $items;
251
                my $items;
253
                my $tag_quantity;
254
                my $sortfield = ( $sorton ? $sorton : 'title' );
252
                my $sortfield = ( $sorton ? $sorton : 'title' );
255
                $sortfield = $query->param('sort') || $sortfield; ## Passed in sorting overrides default sorting
253
                $sortfield = $query->param('sort') || $sortfield; ## Passed in sorting overrides default sorting
256
                my $direction = $query->param('direction') || 'asc';
254
                my $direction = $query->param('direction') || 'asc';
Lines 258-302 sub shelfpage { Link Here
258
                    sort      => $sortfield,
256
                    sort      => $sortfield,
259
                    direction => $direction,
257
                    direction => $direction,
260
                );
258
                );
261
                ( $items, $totitems ) = GetShelfContents( $shelfnumber, $shelflimit, $shelfoffset, $sortfield, $direction );
259
                ( $items, $totitems ) = shelf_contents({
262
                for my $this_item (@$items) {
260
                    shelfnumber => $shelfnumber,
263
                    my $biblionumber = $this_item->{'biblionumber'};
261
                    shelflimit => $shelflimit,
264
                    # Getting items infos for location display
262
                    shelfoffset => $shelfoffset,
265
                    my @items_infos = &GetItemsInfo( $this_item->{'biblionumber'}, "cn_sort" );
263
                    sortfield => $sortfield,
266
                    my $record = GetMarcBiblio($biblionumber);
264
                    direction => $direction,
267
                    if (C4::Context->preference("OPACXSLTResultsDisplay") && $type eq 'opac') {
265
                    type => $type,
268
                        $this_item->{XSLTBloc} = XSLTParse4Display($biblionumber, $record, "OPACXSLTResultsDisplay", \@items_infos);
266
                    cart_list => \@cart_list,
269
                    } elsif (C4::Context->preference("XSLTResultsDisplay") && $type eq 'intranet') {
267
                });
270
                        $this_item->{XSLTBloc} = XSLTParse4Display($biblionumber, $record, "XSLTResultsDisplay", \@items_infos);
271
                    }
272
273
                    # the virtualshelfcontents table does not store these columns nor are they retrieved from the items
274
                    # and itemtypes tables, so I'm commenting them out for now to quiet the log -crn
275
                    #$this_item->{imageurl} = $imgdir."/".$itemtypes->{ $this_item->{itemtype}  }->{'imageurl'};
276
                    #$this_item->{'description'} = $itemtypes->{ $this_item->{itemtype} }->{'description'};
277
                    $this_item->{'dateadded'} = format_date( $this_item->{'dateadded'} );
278
                    $this_item->{'imageurl'}  = getitemtypeinfo( $this_item->{'itemtype'}, $type )->{'imageurl'};
279
                    $this_item->{'coins'}     = GetCOinSBiblio( $record );
280
                    $this_item->{'subtitle'} = GetRecordValue('subtitle', $record, GetFrameworkCode($this_item->{'biblionumber'}));
281
                    $this_item->{'normalized_upc'}  = GetNormalizedUPC(       $record,$marcflavour);
282
                    $this_item->{'normalized_ean'}  = GetNormalizedEAN(       $record,$marcflavour);
283
                    $this_item->{'normalized_oclc'} = GetNormalizedOCLCNumber($record,$marcflavour);
284
                    $this_item->{'normalized_isbn'} = GetNormalizedISBN(undef,$record,$marcflavour);
285
                    if(!defined($this_item->{'size'})) { $this_item->{'size'} = "" }; #TT has problems with size
286
                    $this_item->{'itemsissued'} = CountItemsIssued( $this_item->{'biblionumber'} );
287
                    $this_item->{'ITEM_RESULTS'} = \@items_infos;
288
                    if ( grep {$_ eq $biblionumber} @cart_list) {
289
                        $this_item->{'incart'} = 1;
290
                    }
291
292
                    if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->preference('TagsShowOnList')) {
293
                        $this_item->{'TagLoop'} = get_tags({
294
                            biblionumber=>$this_item->{'biblionumber'}, approved=>1, 'sort'=>'-weight',
295
                            limit=>$tag_quantity
296
                            });
297
                    }
298
299
                }
300
                if($type eq 'intranet'){
268
                if($type eq 'intranet'){
301
                    # Build drop-down list for 'Add To:' menu...
269
                    # Build drop-down list for 'Add To:' menu...
302
                    my ($totalref, $pubshelves, $barshelves)=
270
                    my ($totalref, $pubshelves, $barshelves)=
Lines 499-504 sub shelfpage { Link Here
499
    output_html_with_http_headers $query, $cookie, $template->output;
467
    output_html_with_http_headers $query, $cookie, $template->output;
500
}
468
}
501
469
470
sub shelf_contents {
471
    my ( $params ) = @_;
472
    my $shelfnumber = $params->{shelfnumber};
473
    my $shelflimit = $params->{shelflimit};
474
    my $shelfoffset = $params->{shelfoffset};
475
    my $sortfield = $params->{sortfield};
476
    my $direction = $params->{direction};
477
    my $type = $params->{type};
478
    my $cart_list = $params->{cart_list};
479
480
    my $marcflavour = C4::Context->preference("marcflavour");
481
    my $tag_quantity = C4::Context->preference('TagsEnabled')
482
      ? C4::Context->preference('TagsShowOnList')
483
      : undef;
484
    my ( $items, $totitems ) = GetShelfContents( $shelfnumber, $shelflimit, $shelfoffset, $sortfield, $direction );
485
    for my $this_item (@$items) {
486
        my $biblionumber = $this_item->{'biblionumber'};
487
        # Getting items infos for location display
488
        my @items_infos = &GetItemsInfo( $this_item->{'biblionumber'}, "cn_sort" );
489
        my $record = GetMarcBiblio($biblionumber);
490
        if (C4::Context->preference("OPACXSLTResultsDisplay") && $type eq 'opac') {
491
            $this_item->{XSLTBloc} = XSLTParse4Display($biblionumber, $record, "OPACXSLTResultsDisplay", \@items_infos);
492
        } elsif (C4::Context->preference("XSLTResultsDisplay") && $type eq 'intranet') {
493
            $this_item->{XSLTBloc} = XSLTParse4Display($biblionumber, $record, "XSLTResultsDisplay", \@items_infos);
494
        }
495
496
        # the virtualshelfcontents table does not store these columns nor are they retrieved from the items
497
        # and itemtypes tables, so I'm commenting them out for now to quiet the log -crn
498
        #$this_item->{imageurl} = $imgdir."/".$itemtypes->{ $this_item->{itemtype}  }->{'imageurl'};
499
        #$this_item->{'description'} = $itemtypes->{ $this_item->{itemtype} }->{'description'};
500
        $this_item->{'dateadded'} = format_date( $this_item->{'dateadded'} );
501
        $this_item->{'imageurl'}  = getitemtypeinfo( $this_item->{'itemtype'}, $type )->{'imageurl'};
502
        $this_item->{'coins'}     = GetCOinSBiblio( $record );
503
        $this_item->{'subtitle'} = GetRecordValue('subtitle', $record, GetFrameworkCode($this_item->{'biblionumber'}));
504
        $this_item->{'normalized_upc'}  = GetNormalizedUPC(       $record,$marcflavour);
505
        $this_item->{'normalized_ean'}  = GetNormalizedEAN(       $record,$marcflavour);
506
        $this_item->{'normalized_oclc'} = GetNormalizedOCLCNumber($record,$marcflavour);
507
        $this_item->{'normalized_isbn'} = GetNormalizedISBN(undef,$record,$marcflavour);
508
        if(!defined($this_item->{'size'})) { $this_item->{'size'} = "" }; #TT has problems with size
509
        $this_item->{'itemsissued'} = CountItemsIssued( $this_item->{'biblionumber'} );
510
        $this_item->{'ITEM_RESULTS'} = \@items_infos;
511
        if ( grep {$_ eq $biblionumber} @$cart_list) {
512
            $this_item->{'incart'} = 1;
513
        }
514
515
        if ($tag_quantity) {
516
            $this_item->{'TagLoop'} = get_tags({
517
                biblionumber=>$this_item->{'biblionumber'}, approved=>1, 'sort'=>'-weight',
518
                limit=>$tag_quantity
519
                });
520
        }
521
    }
522
    return ( $items, $totitems );
523
}
524
502
1;
525
1;
503
__END__
526
__END__
504
527
(-)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