(MT #1654) followup : Adding jquery.tablesorter and jquery.tablesorter.pager support for auth_tag_structure.pl

This commit is contained in:
Stéphane Delaune 2010-08-31 15:44:11 +02:00 committed by Chris Cormack
parent f1762530d1
commit fbfe0276a0
2 changed files with 33 additions and 16 deletions

View file

@ -39,7 +39,7 @@ my $offset = $input->param('offset') || 0;
my $op = $input->param('op') || ''; my $op = $input->param('op') || '';
$searchfield =~ s/\,//g; $searchfield =~ s/\,//g;
my $pagesize = 20;
my $script_name = "/cgi-bin/koha/admin/auth_tag_structure.pl"; my $script_name = "/cgi-bin/koha/admin/auth_tag_structure.pl";
my $dbh = C4::Context->dbh; my $dbh = C4::Context->dbh;
@ -221,7 +221,7 @@ if ($op eq 'add_form') {
} }
my ($count,$results)=StringSearch($searchfield,$authtypecode); my ($count,$results)=StringSearch($searchfield,$authtypecode);
my @loop_data = (); my @loop_data = ();
for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){ for ( my $i = $offset ; $i < $count ; $i++ ) {
my %row_data; # get a fresh hash for the row data my %row_data; # get a fresh hash for the row data
$row_data{tagfield} = $results->[$i]{'tagfield'}; $row_data{tagfield} = $results->[$i]{'tagfield'};
$row_data{liblibrarian} = $results->[$i]{'liblibrarian'}; $row_data{liblibrarian} = $results->[$i]{'liblibrarian'};
@ -237,15 +237,12 @@ if ($op eq 'add_form') {
authtypecode => $authtypecode, authtypecode => $authtypecode,
); );
if ($offset>0) { if ($offset>0) {
my $prevpage = $offset-$pagesize;
$template->param(isprevpage => $offset, $template->param(isprevpage => $offset,
prevpage=> $prevpage,
searchfield => $searchfield, searchfield => $searchfield,
); );
} }
if ($offset+$pagesize<$count) { if ( $offset < $count ) {
my $nextpage =$offset+$pagesize; $template->param(
$template->param(nextpage =>$nextpage,
searchfield => $searchfield, searchfield => $searchfield,
); );
} }

View file

@ -4,6 +4,14 @@
<!-- TMPL_IF NAME="heading-add-tag-p" -->&rsaquo; <!-- TMPL_IF NAME="authtypecode" --><!-- TMPL_VAR NAME="authtypecode" --> Framework<!-- TMPL_ELSE -->Default Framework<!-- /TMPL_IF --> &rsaquo; New tag<!-- /TMPL_IF --> <!-- TMPL_IF NAME="heading-add-tag-p" -->&rsaquo; <!-- TMPL_IF NAME="authtypecode" --><!-- TMPL_VAR NAME="authtypecode" --> Framework<!-- TMPL_ELSE -->Default Framework<!-- /TMPL_IF --> &rsaquo; New tag<!-- /TMPL_IF -->
<!-- TMPL_ELSE -->&rsaquo; <!-- TMPL_VAR NAME="action" --><!-- /TMPL_IF --><!-- /TMPL_IF --><!-- TMPL_IF NAME="delete_confirm" -->&rsaquo; <!-- TMPL_IF NAME="authtypecode" --><!-- TMPL_VAR NAME="authtypecode" --> Framework<!-- TMPL_ELSE -->Default Framework<!-- /TMPL_IF --> &rsaquo; Confirm Deletion<!-- /TMPL_IF --><!-- TMPL_IF NAME="delete_confirmed" -->&rsaquo; <!-- TMPL_IF NAME="authtypecode" --><!-- TMPL_VAR NAME="authtypecode" --> Framework<!-- TMPL_ELSE -->Default Framework<!-- /TMPL_IF --> &rsaquo; Data Deleted<!-- /TMPL_IF --></title> <!-- TMPL_ELSE -->&rsaquo; <!-- TMPL_VAR NAME="action" --><!-- /TMPL_IF --><!-- /TMPL_IF --><!-- TMPL_IF NAME="delete_confirm" -->&rsaquo; <!-- TMPL_IF NAME="authtypecode" --><!-- TMPL_VAR NAME="authtypecode" --> Framework<!-- TMPL_ELSE -->Default Framework<!-- /TMPL_IF --> &rsaquo; Confirm Deletion<!-- /TMPL_IF --><!-- TMPL_IF NAME="delete_confirmed" -->&rsaquo; <!-- TMPL_IF NAME="authtypecode" --><!-- TMPL_VAR NAME="authtypecode" --> Framework<!-- TMPL_ELSE -->Default Framework<!-- /TMPL_IF --> &rsaquo; Data Deleted<!-- /TMPL_IF --></title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" --> <!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/jquery.tablesorter.pager.js"></script>
<script type="text/javascript" id="js">$(document).ready(function() {
$("#table_authtagstructure").tablesorter({
sortList: [[0,0]],
headers: { 5: { sorter: false},6: { sorter: false},7: { sorter: false}}
}).tablesorterPager({container: $("#pagertable_authtagstructure"),positionFixed: false,size: 20});
}); </script>
<script type="text/javascript"> <script type="text/javascript">
//<![CDATA[ //<![CDATA[
///////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -199,9 +207,27 @@ return false;
</select> </select>
<input type="text" name="searchfield" value="<!-- TMPL_VAR NAME="searchfield" -->" /> <input type="text" name="searchfield" value="<!-- TMPL_VAR NAME="searchfield" -->" />
<input type="submit" value="OK" class="submit" /> <input type="submit" value="OK" class="submit" />
</form><br />
<span id="pagertable_authtagstructure" 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 value="10">10</option>
<option selected="selected" 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> </form>
<table> </span>
<tr> <table id="table_authtagstructure">
<thead>
<th>Tag</th> <th>Tag</th>
<th>Lib</th> <th>Lib</th>
<th>Repeatable</th> <th>Repeatable</th>
@ -210,7 +236,7 @@ return false;
<th>Subfields</th> <th>Subfields</th>
<th>Edit</th> <th>Edit</th>
<th>Delete</th> <th>Delete</th>
</tr> </thead>
<!-- TMPL_LOOP NAME="loop" --> <!-- TMPL_LOOP NAME="loop" -->
<!-- TMPL_UNLESS NAME="__odd__" --> <!-- TMPL_UNLESS NAME="__odd__" -->
<tr class="highlight"> <tr class="highlight">
@ -229,12 +255,6 @@ return false;
<!-- /TMPL_LOOP --> <!-- /TMPL_LOOP -->
</table> </table>
<div class="pages"><!-- TMPL_IF NAME="isprevpage" -->
<a href="<!-- TMPL_VAR NAME="script_name" -->?offset=<!-- TMPL_VAR NAME="prevpage" -->&amp;searchfield=<!-- TMPL_VAR NAME="searchfield" -->&amp;authtypecode=<!-- TMPL_VAR NAME="authtypecode" --> ">&lt;&lt; Previous Page</a>
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="nextpage" -->
<a href="<!-- TMPL_VAR NAME="script_name" -->?offset=<!-- TMPL_VAR NAME="nextpage" -->&amp;searchfield=<!-- TMPL_VAR NAME="searchfield" -->&amp;authtypecode=<!-- TMPL_VAR NAME="authtypecode" --> ">Next Page &gt;&gt;</a>
<!-- /TMPL_IF --></div>
<!-- /TMPL_IF --> <!-- /TMPL_IF -->
</div> </div>