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 487-492 sub shelfpage { Link Here
487
    output_html_with_http_headers $query, $cookie, $template->output;
455
    output_html_with_http_headers $query, $cookie, $template->output;
488
}
456
}
489
457
458
sub shelf_contents {
459
    my ( $params ) = @_;
460
    my $shelfnumber = $params->{shelfnumber};
461
    my $shelflimit = $params->{shelflimit};
462
    my $shelfoffset = $params->{shelfoffset};
463
    my $sortfield = $params->{sortfield};
464
    my $direction = $params->{direction};
465
    my $type = $params->{type};
466
    my $cart_list = $params->{cart_list};
467
468
    my $marcflavour = C4::Context->preference("marcflavour");
469
    my $tag_quantity = C4::Context->preference('TagsEnabled')
470
      ? C4::Context->preference('TagsShowOnList')
471
      : undef;
472
    my ( $items, $totitems ) = GetShelfContents( $shelfnumber, $shelflimit, $shelfoffset, $sortfield, $direction );
473
    for my $this_item (@$items) {
474
        my $biblionumber = $this_item->{'biblionumber'};
475
        # Getting items infos for location display
476
        my @items_infos = &GetItemsInfo( $this_item->{'biblionumber'}, "cn_sort" );
477
        my $record = GetMarcBiblio($biblionumber);
478
        if (C4::Context->preference("OPACXSLTResultsDisplay") && $type eq 'opac') {
479
            $this_item->{XSLTBloc} = XSLTParse4Display($biblionumber, $record, "OPACXSLTResultsDisplay", \@items_infos);
480
        } elsif (C4::Context->preference("XSLTResultsDisplay") && $type eq 'intranet') {
481
            $this_item->{XSLTBloc} = XSLTParse4Display($biblionumber, $record, "XSLTResultsDisplay", \@items_infos);
482
        }
483
484
        # the virtualshelfcontents table does not store these columns nor are they retrieved from the items
485
        # and itemtypes tables, so I'm commenting them out for now to quiet the log -crn
486
        #$this_item->{imageurl} = $imgdir."/".$itemtypes->{ $this_item->{itemtype}  }->{'imageurl'};
487
        #$this_item->{'description'} = $itemtypes->{ $this_item->{itemtype} }->{'description'};
488
        $this_item->{'dateadded'} = format_date( $this_item->{'dateadded'} );
489
        $this_item->{'imageurl'}  = getitemtypeinfo( $this_item->{'itemtype'}, $type )->{'imageurl'};
490
        $this_item->{'coins'}     = GetCOinSBiblio( $record );
491
        $this_item->{'subtitle'} = GetRecordValue('subtitle', $record, GetFrameworkCode($this_item->{'biblionumber'}));
492
        $this_item->{'normalized_upc'}  = GetNormalizedUPC(       $record,$marcflavour);
493
        $this_item->{'normalized_ean'}  = GetNormalizedEAN(       $record,$marcflavour);
494
        $this_item->{'normalized_oclc'} = GetNormalizedOCLCNumber($record,$marcflavour);
495
        $this_item->{'normalized_isbn'} = GetNormalizedISBN(undef,$record,$marcflavour);
496
        if(!defined($this_item->{'size'})) { $this_item->{'size'} = "" }; #TT has problems with size
497
        $this_item->{'itemsissued'} = CountItemsIssued( $this_item->{'biblionumber'} );
498
        $this_item->{'ITEM_RESULTS'} = \@items_infos;
499
        if ( grep {$_ eq $biblionumber} @$cart_list) {
500
            $this_item->{'incart'} = 1;
501
        }
502
503
        if ($tag_quantity) {
504
            $this_item->{'TagLoop'} = get_tags({
505
                biblionumber=>$this_item->{'biblionumber'}, approved=>1, 'sort'=>'-weight',
506
                limit=>$tag_quantity
507
                });
508
        }
509
    }
510
    return ( $items, $totitems );
511
}
512
490
1;
513
1;
491
__END__
514
__END__
492
515
(-)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