[Koha-patches] [PATCH] [SIGNED-OFF] Fix for Bug 5650, item type page key wrong

Ian Walls ian.walls at bywatersolutions.com
Mon Jan 24 20:38:48 CET 2011


From: Owen Leonard <oleonard at myacpl.org>

- Fixes for authorised_values.pl and itemtypes.pl
- Hiding table when there are no values to prevent js error
- Hiding table pager when there are no values
- Removing paging code from the script

Signed-off-by: Ian Walls <ian.walls at bywatersolutions.com>
---
 admin/authorised_values.pl                         |   17 +--------
 admin/itemtypes.pl                                 |   13 +------
 .../prog/en/modules/admin/authorised_values.tmpl   |   12 +++--
 .../prog/en/modules/admin/itemtypes.tmpl           |   40 ++++++++++---------
 4 files changed, 30 insertions(+), 52 deletions(-)

diff --git a/admin/authorised_values.pl b/admin/authorised_values.pl
index de05512..77ab6f1 100755
--- a/admin/authorised_values.pl
+++ b/admin/authorised_values.pl
@@ -60,7 +60,6 @@ my ($template, $borrowernumber, $cookie)= get_template_and_user({
     type => "intranet",
     debug => 1,
 });
-my $pagesize = 20;
 
 $template->param(  script_name => $script_name,
                  ($op||'else') => 1 );
@@ -220,7 +219,7 @@ sub default_form {
     my $count = scalar(@$results);
 	my @loop_data = ();
 	# builds value list
-	for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
+	for (my $i=0; $i < $count; $i++){
 		my %row_data;  # get a fresh hash for the row data
 		$row_data{category}              = $results->[$i]{'category'};
 		$row_data{authorised_value}      = $results->[$i]{'authorised_value'};
@@ -235,19 +234,5 @@ sub default_form {
 	$template->param( loop     => \@loop_data,
                           tab_list => $tab_list,
                           category => $searchfield );
-
-	if ($offset>0) {
-		my $prevpage = $offset-$pagesize;
-		$template->param(isprevpage => $offset,
-						prevpage=> $prevpage,
-						searchfield => $searchfield,
-		 );
-	}
-	if ($offset+$pagesize<$count) {
-		my $nextpage =$offset+$pagesize;
-		$template->param(nextpage =>$nextpage,
-						searchfield => $searchfield,
-		);
-	}
 }
 
diff --git a/admin/itemtypes.pl b/admin/itemtypes.pl
index 9876852..1a33a21 100755
--- a/admin/itemtypes.pl
+++ b/admin/itemtypes.pl
@@ -69,7 +69,6 @@ my $input       = new CGI;
 my $searchfield = $input->param('description');
 my $script_name = "/cgi-bin/koha/admin/itemtypes.pl";
 my $itemtype    = $input->param('itemtype');
-my $pagesize    = 10;
 my $op          = $input->param('op');
 $searchfield =~ s/\,//g;
 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
@@ -230,14 +229,8 @@ elsif ( $op eq 'delete_confirmed' ) {
 }
 else {    # DEFAULT
     my ($results) = StringSearch( $searchfield, 'web' );
-    my $page = $input->param('page') || 1;
-    my $first = ( $page - 1 ) * $pagesize;
-
-    # if we are on the last page, the number of the last word to display
-    # must not exceed the length of the results array
-    my $last = min( $first + $pagesize - 1, scalar @{$results} - 1, );
     my @loop;
-    foreach my $itemtype ( @{$results}[ $first .. $last ] ) {
+    foreach my $itemtype ( @{$results} ) {
         $itemtype->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtype->{imageurl} );
         $itemtype->{rentalcharge} = sprintf( '%.2f', $itemtype->{rentalcharge} );
         push( @loop, $itemtype );
@@ -245,10 +238,6 @@ else {    # DEFAULT
 
     $template->param(
         loop           => \@loop,
-        pagination_bar => pagination_bar(
-            $script_name, getnbpages( scalar @{$results}, $pagesize ),
-            $page,        'page'
-        )
     );
 }    #---- END $OP eq DEFAULT
 
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tmpl
index 1aeab0d..b4f6954 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tmpl
@@ -221,9 +221,9 @@
  <!-- TMPL_IF EXPR="category eq 'NOT_LOAN'" -->
     <p>Statuses to describe why an item is not for loan</p>
  <!-- /TMPL_IF -->
-<h3>Authorized values for category <!-- TMPL_VAR name="category" --> :</h3>
+<h3>Authorized values for category <!-- TMPL_VAR name="category" -->:</h3>
 
-<span id="pagertable_authorized_values" class="pager">
+<!-- TMPL_IF NAME="loop" --><span id="pagertable_authorized_values" class="pager">
 	<form class="formpager">&nbsp;<strong>page(s)</strong>&nbsp;:
 		<img src="<!-- TMPL_VAR name="interface" -->/prog/img/first.png" class="first"/>
 		<img src="<!-- TMPL_VAR name="interface" -->/prog/img/prev.png" class="prev"/>
@@ -241,9 +241,9 @@
 			<option value="200">200</option>
 		</select>
 	</form>
-</span>
+</span><!-- /TMPL_IF -->
 
-<table id="table_authorized_values" cellspacing="1" class="tablesorter">
+<!-- TMPL_IF NAME="loop" --><table id="table_authorized_values" class="tablesorter">
 <thead><tr>
 	<th>Authorized value</th>
 	<th>Description</th>
@@ -267,7 +267,9 @@
 	<td><a href="<!-- TMPL_VAR name="delete" -->">Delete</a></td>
 </tr>
 <!-- /TMPL_LOOP -->
-</tbody></table>
+</tbody></table><!-- TMPL_ELSE -->
+<div class="dialog message">There are no authorized values defined for <!-- TMPL_VAR NAME="category" --></div>
+<!-- /TMPL_IF -->
 
 <!-- TMPL_IF NAME="isprevpage" -->
 <form class="inline" action="<!-- TMPL_VAR NAME="script_name" -->" method="post">
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tmpl
index e24a545..2d9aafc 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tmpl
@@ -173,7 +173,7 @@ Item Types Administration
       <li>
           <label for="description">Description</label><input type="text" id="description" name="description" size="48" maxlength="80" value="<!-- TMPL_VAR name="description" escape="HTML" -->" />      </li>
      <!-- TMPL_IF NAME="noItemTypeImages" -->
-	 <li><span class="label">Image: </span>Item type images are disabled. To enable them, turn off the <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=noItemTypeImages">noItemTypeImages system preference</a></li></ol>
+	 <li><span class="label">Image: </span>Item type images are disabled. To enable them, turn off the <a href="/cgi-bin/koha/admin/preferences.pl?op=search&amp;searchfield=noItemTypeImages">noItemTypeImages system preference</a></li></ol>
 	 <!-- TMPL_ELSE --></ol>
 		<div id="icons" class="toptabs">
 		<h5 style="margin-left:10px;">Choose an Icon:</h5>
@@ -285,23 +285,23 @@ Item Types Administration
 
 <!-- TMPL_IF name="else" -->
 <h2>Item Types Administration</h2>
-<span id="pagertable_item_type" class="pager">
-	<form class="formpager">&nbsp;<strong>page(s)</strong>&nbsp;:
-		<img src="<!-- TMPL_VAR name="interface" -->/prog/img/first.png" class="first"/>
-		<img src="<!-- TMPL_VAR name="interface" -->/prog/img/prev.png" class="prev"/>
-		<input type="text" size="5" class="pagedisplay"/>
-		<img src="<!-- TMPL_VAR name="interface" -->/prog/img/next.png" class="next"/>
-		<img src="<!-- TMPL_VAR name="interface" -->/prog/img/last.png" class="last"/>
-		, entries/page : 
-		<select class="pagesize">
-        	<option selected="selected" value="10">10</option>
-			<option value="20">20</option>
-			<option value="30">30</option>
-			<option value="40">40</option>
-			<option value="50">50</option>
-			<option value="100">100</option>
-		</select>
-	</form>
+<!-- TMPL_IF NAME="loop" --><span id="pagertable_item_type" class="pager">
+  <form class="formpager">&nbsp;<strong>page(s)</strong>:&nbsp;
+    <img src="<!-- TMPL_VAR name="interface" -->/prog/img/first.png" class="first"/>
+    <img src="<!-- TMPL_VAR name="interface" -->/prog/img/prev.png" class="prev"/>
+    <input type="text" size="5" class="pagedisplay"/>
+    <img src="<!-- TMPL_VAR name="interface" -->/prog/img/next.png" class="next"/>
+    <img src="<!-- TMPL_VAR name="interface" -->/prog/img/last.png" class="last"/>
+    , entries/page:
+    <select class="pagesize">
+          <option selected="selected" value="10">10</option>
+      <option value="20">20</option>
+      <option value="30">30</option>
+      <option value="40">40</option>
+      <option value="50">50</option>
+      <option value="100">100</option>
+    </select>
+  </form>
 </span>
 <table id="table_item_type">
   <thead>
@@ -337,7 +337,9 @@ Item Types Administration
     </td>
   </tr>
   <!-- /TMPL_LOOP -->
-</table>
+</table><!-- TMPL_ELSE -->
+<div class="dialog message">There are no itemtypes defined</div>
+<!-- /TMPL_IF -->
 
 <div class="paginationBar"><!-- TMPL_VAR NAME="pagination_bar" --></div>
 
-- 
1.5.6.5



More information about the Koha-patches mailing list