Bug 10853: All existing routing to get a CSV should return a MARC csv
[srvgit] / C4 / VirtualShelves / Page.pm
index 586384d..259e12d 100644 (file)
@@ -237,7 +237,10 @@ sub shelfpage {
             # explicitly fetch this shelf
             my ($shelfnumber2,$shelfname,$owner,$category,$sorton) = GetShelf($shelfnumber);
 
-            $template->param( 'AllowOnShelfHolds' => C4::Context->preference('AllowOnShelfHolds') );
+            $template->param(
+                'AllowOnShelfHolds'     => C4::Context->preference('AllowOnShelfHolds'),
+                'DisplayMultiPlaceHold' => C4::Context->preference('DisplayMultiPlaceHold'),
+            );
             if (C4::Context->preference('TagsEnabled')) {
                 $template->param(TagsEnabled => 1);
                     foreach (qw(TagsShowOnList TagsInputOnList)) {
@@ -249,13 +252,21 @@ sub shelfpage {
                 my $items;
                 my $tag_quantity;
                 my $sortfield = ( $sorton ? $sorton : 'title' );
-                ( $items, $totitems ) = GetShelfContents( $shelfnumber, $shelflimit, $shelfoffset, $sortfield );
+                $sortfield = $query->param('sort') || $sortfield; ## Passed in sorting overrides default sorting
+                my $direction = $query->param('direction') || 'asc';
+                $template->param(
+                    sort      => $sortfield,
+                    direction => $direction,
+                );
+                ( $items, $totitems ) = GetShelfContents( $shelfnumber, $shelflimit, $shelfoffset, $sortfield, $direction );
                 for my $this_item (@$items) {
                     my $biblionumber = $this_item->{'biblionumber'};
                     my $record = GetMarcBiblio($biblionumber);
-                    $this_item->{XSLTBloc} =
-                        XSLTParse4Display($biblionumber, $record, "OPACXSLTResultsDisplay")
-                            if C4::Context->preference("OPACXSLTResultsDisplay") && $type eq 'opac';
+                    if (C4::Context->preference("OPACXSLTResultsDisplay") && $type eq 'opac') {
+                        $this_item->{XSLTBloc} = XSLTParse4Display($biblionumber, $record, "OPACXSLTResultsDisplay");
+                    } elsif (C4::Context->preference("XSLTResultsDisplay") && $type eq 'intranet') {
+                        $this_item->{XSLTBloc} = XSLTParse4Display($biblionumber, $record, "XSLTResultsDisplay");
+                    }
 
                     # the virtualshelfcontents table does not store these columns nor are they retrieved from the items
                     # and itemtypes tables, so I'm commenting them out for now to quiet the log -crn
@@ -269,6 +280,7 @@ sub shelfpage {
                     $this_item->{'normalized_ean'}  = GetNormalizedEAN(       $record,$marcflavour);
                     $this_item->{'normalized_oclc'} = GetNormalizedOCLCNumber($record,$marcflavour);
                     $this_item->{'normalized_isbn'} = GetNormalizedISBN(undef,$record,$marcflavour);
+                    if(!defined($this_item->{'size'})) { $this_item->{'size'} = "" }; #TT has problems with size
                     # Getting items infos for location display
                     my @items_infos = &GetItemsLocationInfo( $this_item->{'biblionumber'});
                     $this_item->{'itemsissued'} = CountItemsIssued( $this_item->{'biblionumber'} );
@@ -285,6 +297,17 @@ sub shelfpage {
                     }
 
                 }
+                if($type eq 'intranet'){
+                    # Build drop-down list for 'Add To:' menu...
+                    my ($totalref, $pubshelves, $barshelves)=
+                    C4::VirtualShelves::GetSomeShelfNames($loggedinuser,'COMBO',1);
+                    $template->param(
+                        addbarshelves     => $totalref->{bartotal},
+                        addbarshelvesloop => $barshelves,
+                        addpubshelves     => $totalref->{pubtotal},
+                        addpubshelvesloop => $pubshelves,
+                    );
+                }
                 push @paramsloop, { display => 'privateshelves' } if $category == 1;
                 $showadd = 1;
                 my $i = 0;
@@ -419,7 +442,7 @@ sub shelfpage {
 
     my $url = $type eq 'opac' ? "/cgi-bin/koha/opac-shelves.pl" : "/cgi-bin/koha/virtualshelves/shelves.pl";
     my %qhash = ();
-    foreach (qw(display viewshelf sortfield)) {
+    foreach (qw(display viewshelf sortfield sort direction)) {
         $qhash{$_} = $query->param($_) if $query->param($_);
     }
     ( scalar keys %qhash ) and $url .= '?' . join '&', map { "$_=$qhash{$_}" } keys %qhash;
@@ -435,7 +458,7 @@ sub shelfpage {
         shelvesloopall                                                     => [ ( @shelvesloop, @shelveslooppriv ) ],
         numberCanManage                                                    => $numberCanManage,
         "BiblioDefaultView" . C4::Context->preference("BiblioDefaultView") => 1,
-        csv_profiles                                                       => GetCsvProfilesLoop()
+        csv_profiles                                                       => GetCsvProfilesLoop('marc')
     );
     if (   $shelfnumber
         or $shelves