Bug 13986: Printing a list only prints the results of the page you are viewing
authorKyle M Hall <kyle@bywatersolutions.com>
Mon, 13 Apr 2015 15:23:20 +0000 (11:23 -0400)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Fri, 15 May 2015 19:01:33 +0000 (16:01 -0300)
The print list button only prints the page you are viewing, and not the
entire list.

Test Plan:
1) Apply this patch
2) Create a list with enough items that it will paginate
3) Browse to that list, click the 'print list' button
4) Note the entire list prints, not just the visible items

Tested in staff client, works as expected.
It would be great to have the same for OPAC as well (OPAC still prints first page only).
Signed-off-by: Marc Veron <veron@veron.ch>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
C4/VirtualShelves/Page.pm
koha-tmpl/intranet-tmpl/prog/en/css/print.css
koha-tmpl/intranet-tmpl/prog/en/includes/virtualshelves-toolbar.inc
koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt
virtualshelves/shelves.pl

index beed3e2..f4f09d7 100644 (file)
@@ -76,12 +76,14 @@ sub shelfpage {
     my ( $shelflimit, $shelfoffset, $shelveslimit, $shelvesoffset );
     my $marcflavour = C4::Context->preference("marcflavour");
 
-    $shelflimit = ( $type eq 'opac' ? C4::Context->preference('OPACnumSearchResults') : C4::Context->preference('numSearchResults') );
-    $shelflimit = $shelflimit || ShelvesMax('MGRPAGE');
-    $shelflimit = undef if $query->param('rss');
-    $shelfoffset   = ( $itemoff - 1 ) * $shelflimit;     # Sets the offset to begin retrieving items at
-    $shelveslimit  = $shelflimit;                        # Limits number of shelves returned for a given query (row_count)
-    $shelvesoffset = ( $shelfoff - 1 ) * $shelflimit;    # Sets the offset to begin retrieving shelves at (offset)
+    unless ( $query->param('print') ) {
+        $shelflimit = ( $type eq 'opac' ? C4::Context->preference('OPACnumSearchResults') : C4::Context->preference('numSearchResults') );
+        $shelflimit = $shelflimit || ShelvesMax('MGRPAGE');
+        $shelflimit = undef if $query->param('rss');
+        $shelfoffset   = ( $itemoff - 1 ) * $shelflimit;     # Sets the offset to begin retrieving items at
+        $shelveslimit  = $shelflimit;                        # Limits number of shelves returned for a given query (row_count)
+        $shelvesoffset = ( $shelfoff - 1 ) * $shelflimit;    # Sets the offset to begin retrieving shelves at (offset)
+    }
 
     # getting the Shelves list
     my $category = ( ( $displaymode eq 'privateshelves' ) ? 1 : 2 );
@@ -469,6 +471,7 @@ sub shelfpage {
                  pagination_bar => pagination_bar( $url, ( int( $totshelves / $shelveslimit ) ) + ( ( $totshelves % $shelveslimit ) > 0 ? 1 : 0 ), $shelfoff, "shelfoff" )  );
         }
     }
+
     $template->param(
         shelveslooppriv                                                    => \@shelveslooppriv,
         shelvesloop                                                        => \@shelvesloop,
index 239059c..e0e346e 100644 (file)
@@ -322,4 +322,4 @@ fieldset {
 }
 #cataloguing_additem_itemlist {
        overflow : visible !important;
-}
\ No newline at end of file
+}
index 4de9e19..1e00cc4 100644 (file)
             sendList();
             return false;
         });
-        $("#printlist").click(function(){
-            print();
-            return false;
-        });
         $("#deleteshelf").click(function(e){
             if(confirmDelete(_("Are you sure you want to delete this list?"))){
                 return true;
@@ -60,6 +56,6 @@
                 </ul>
         </div>
         <div class="btn-group"><a class="btn btn-small" href="#" id="sendlist"><i class="icon-envelope"></i> Send list</a></div>
-        <div class="btn-group"><a class="btn btn-small" id="printlist" href="#"><i class="icon-print"></i> Print list</a></div>
+        <div class="btn-group"><a class="btn btn-small" id="printlist" target="_blank" href="/cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=[% shelfnumber %]&amp;print=1"><i class="icon-print"></i> Print list</a></div>
     [% END %]
 </div>
index 0f479a5..30bd124 100644 (file)
@@ -4,6 +4,16 @@
 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
 [% INCLUDE 'datatables.inc' %]
 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.dataTables.columnFilter.js"></script>
+
+[% IF print %]
+<script type="text/javascript">
+    $( document ).ready(function() {
+        window.print();
+        setTimeout('window.close()', 1);
+    });
+</script>
+[% END %]
+
 [% IF ( viewshelf ) %]
     <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
     <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.fixFloat.js"></script>
@@ -356,7 +366,7 @@ function placeHold () {
     [% SET new_direction = 'asc' %]
 [% END %]
 
-<div id="searchheader">
+<div id="searchheader" class="noprint">
     [% IF ( itemsloop ) %]
         <div id="selection_ops"><span class="checkall"></span> |
         <span class="clearall"></span>
@@ -476,7 +486,7 @@ function placeHold () {
 [% IF ( allowaddingitem ) %]
 <div class="yui-g">
 <form action="/cgi-bin/koha/virtualshelves/shelves.pl" method="post">
- <fieldset class="brief">
+ <fieldset class="brief noprint">
     <legend>Add an item to <i>[% shelfname | html %]</i></legend>
         <ol>
             <li>
index 4e224fc..43ae72a 100755 (executable)
@@ -35,4 +35,5 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
         flagsrequired   => { catalogue => 1 },
     }
 );
+$template->param( print => $query->param('print') );
 shelfpage('intranet', $query, $template, $loggedinuser, $cookie);