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 238-244 sub shelfpage { Link Here
238
            #check that the user can view the shelf
237
            #check that the user can view the shelf
239
            if ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'view' ) ) {
238
            if ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'view' ) ) {
240
                my $items;
239
                my $items;
241
                my $tag_quantity;
242
                my $sortfield = ( $sorton ? $sorton : 'title' );
240
                my $sortfield = ( $sorton ? $sorton : 'title' );
243
                $sortfield = $query->param('sort') || $sortfield; ## Passed in sorting overrides default sorting
241
                $sortfield = $query->param('sort') || $sortfield; ## Passed in sorting overrides default sorting
244
                my $direction = $query->param('direction') || 'asc';
242
                my $direction = $query->param('direction') || 'asc';
Lines 246-253 sub shelfpage { Link Here
246
                    sort      => $sortfield,
244
                    sort      => $sortfield,
247
                    direction => $direction,
245
                    direction => $direction,
248
                );
246
                );
249
                ( $items, $totitems ) = GetShelfContents( $shelfnumber, $shelflimit, $shelfoffset, $sortfield, $direction );
250
251
                # get biblionumbers stored in the cart
247
                # get biblionumbers stored in the cart
252
                # Note that it's not use at the intranet
248
                # Note that it's not use at the intranet
253
                my @cart_list;
249
                my @cart_list;
Lines 257-303 sub shelfpage { Link Here
257
                    @cart_list = split(/\//, $cart_list);
253
                    @cart_list = split(/\//, $cart_list);
258
                }
254
                }
259
255
260
                my $borrower = GetMember( 'borrowernumber' => $loggedinuser );
256
                ( $items, $totitems ) = shelf_contents({
261
257
                    borrower => GetMember( 'borrowernumber' => $loggedinuser ),
262
                for my $this_item (@$items) {
258
                    shelfnumber => $shelfnumber,
263
                    my $biblionumber = $this_item->{'biblionumber'};
259
                    shelflimit => $shelflimit,
264
                    # Getting items infos for location display
260
                    shelfoffset => $shelfoffset,
265
                    my @items_infos = &GetItemsInfo( $this_item->{'biblionumber'}, "cn_sort" );
261
                    sortfield => $sortfield,
266
                    my $record = GetMarcBiblio($biblionumber);
262
                    direction => $direction,
267
                    if (C4::Context->preference("OPACXSLTResultsDisplay") && $type eq 'opac') {
263
                    type => $type,
268
                        $this_item->{XSLTBloc} = XSLTParse4Display($biblionumber, $record, "OPACXSLTResultsDisplay", \@items_infos);
264
                    cart_list => \@cart_list,
269
                    } elsif (C4::Context->preference("XSLTResultsDisplay") && $type eq 'intranet') {
265
                });
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
                    $this_item->{'allow_onshelf_holds'} = C4::Reserves::OnShelfHoldsAllowed($this_item, $borrower);
300
                }
301
                if($type eq 'intranet'){
266
                if($type eq 'intranet'){
302
                    # Build drop-down list for 'Add To:' menu...
267
                    # Build drop-down list for 'Add To:' menu...
303
                    my ($totalref, $pubshelves, $barshelves)=
268
                    my ($totalref, $pubshelves, $barshelves)=
Lines 501-506 sub shelfpage { Link Here
501
    output_html_with_http_headers $query, $cookie, $template->output;
466
    output_html_with_http_headers $query, $cookie, $template->output;
502
}
467
}
503
468
469
sub shelf_contents {
470
    my ( $params ) = @_;
471
    my $borrower = $params->{borrower};
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 ( $cart_list && 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
        $this_item->{'allow_onshelf_holds'} = C4::Reserves::OnShelfHoldsAllowed($this_item, $borrower);
523
    }
524
    return ( $items, $totitems );
525
}
526
504
1;
527
1;
505
__END__
528
__END__
506
529
(-)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