Koha/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tt
Owen Leonard ba470954fd Bug 9916 - Use DataTables in the OPAC
The OPAC still uses the old tablesorter plugin which isn't being
actively maintained. We use DataTables in the staff client and should in
the OPAC too. The plugin was added a while ago but never implemented on
any pages. This patch upgrades the plugin to the latest version and
places it in opac-tmpl/lib for cross-theme access. The patch implements
DataTables on all pages which previously used the tablesorter plugin.

The old tablesorter plugin is removed.

The customized DataTable configuration script, datatables.js, has been
trimmed-down from the staff client version in order to limit it to only
that functionality required in the OPAC.

Sorting based on date is done based on the data's enclosing <span> title
attribute as it is in the staff client:

<span title=" [% iso date %]">[% date | $KohaDates %]</span>

Slight modifications to Serials.pm and opac-search-history.pl have been
made to accommodate this change.

To test, view each page in the OPAC which uses JS-based table sorting:

- The bibliographic detail page
- The cart
- The search history page
- The suggestions page
- The tags page (logged in as a user who has entered tags)
- The "most popular" page (opac-topissues.pl)
- The logged in user summary page (opac-user.pl)
- The subscription "full history" page (opac-serial-issues.pl?selectview=full)
- The self-checkout main page (with existing checkouts)

Table sorting should work correctly on all pages in both the prog and
ccsr themes. Sorting should work for dates whatever your dateformat
system preference setting. Tables listing titles should exclude articles
("a," "an," and "the" in English) when sorting.

Also test the serial collection page in the staff client, which is
affected by the change to Serials.pm. Confirm that dates are displayed
and sorted correctly.

Signed-off-by: Srdjan <srdjan@catalyst.net.nz>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Passes koha-qa.pl, works as advertised!

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Works really nicely on all pages.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
2013-08-19 14:19:02 +00:00

241 lines
12 KiB
Text

[% USE Koha %]
[% USE KohaAuthorisedValues %]
[% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo;
[% IF ( op_add ) %]Enter a new purchase suggestion[% END %]
[% IF ( op_else ) %]Purchase Suggestions[% END %]
[% INCLUDE 'doc-head-close.inc' %]
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
[% INCLUDE 'datatables.inc' %]
<script type="text/javascript">
//<![CDATA[
[% IF ( loggedinusername ) %]function enableCheckboxActions(){
// Enable/disable controls if checkboxes are checked
var checkedBoxes = $(".checkboxed input:checkbox:checked");
if ($(checkedBoxes).size()) {
$("#selections").html(_("With selected suggestions: "));
$("#selections-toolbar .links a").removeClass("disabled");
} else {
$("#selections").html(_("Select suggestions to: "));
$("#selections-toolbar .links a").addClass("disabled");
}
}[% END %]
$(function() {
$("#suggestt").dataTable($.extend(true, {}, dataTablesDefaults, {
"aaSorting": [[ 1, "asc" ]],
"aoColumnDefs": [
[% IF ( loggedinusername ) %]{ "aTargets": [ 0 ], "bSortable": false, "bSearchable": false }[% END %]
],
"aoColumns": [
[% IF ( loggedinusername ) %]null,[% END %]
{ "sType": "anti-the" },
null,
[% IF ( OPACViewOthersSuggestions ) %]null,[% END %]
null,
null
]
}));
[% IF ( loggedinusername ) %]$("span.clearall").html("<a id=\"CheckNone\" href=\"#\">"+_("Clear all")+"<\/a>");
$("span.checkall").html("<a id=\"CheckAll\" href=\"#\">"+_("Select all")+"<\/a>");
$("#CheckAll").click(function(){
$(".checkboxed").checkCheckboxes();
enableCheckboxActions();
return false;
});
$("#CheckNone").click(function(){
$(".checkboxed").unCheckCheckboxes();
enableCheckboxActions();
return false;
});
$(".cb").click(function(){
enableCheckboxActions();
});
$("#removeitems").html("<a href=\"#\" class=\"removeitems tag_hides disabled\">"+_("Delete")+"</a>")
.click(function(){
$("#myform").submit();
return false;
});
enableCheckboxActions();
[% END %]
});
function Check(f) {
var _alertString="";
var alertString2;
if(f.title.value.length ==0){
_alertString += _("- You must enter a Title") + "\n";
}
if (_alertString.length==0) {
f.submit();
} else {
alertString2 = _("Form not submitted because of the following problem(s)");
alertString2 += "\n------------------------------------------------------------------------------------\n\n";
alertString2 += _alertString;
alert(alertString2);
}
}
//]]>
</script>
</head>
[% IF ( loggedinusername ) %]<body id="opac-usersuggestions">[% ELSE %]<body id="opac-suggestions">[% END %]
<div id="doc3" class="yui-t1">
<div id="bd">
[% INCLUDE 'masthead.inc' %]
<div id="yui-main">
<div class="yui-b"><div class="yui-g">
<div id="usersuggestions" class="container">
[% IF ( op_add ) %]
<h1>Enter a new purchase suggestion</h1>
<p>Please fill out this form to make a purchase suggestion. You will receive an email when the library processes your suggestion</p>
<p>Only the title is required, but the more information you enter the easier it will be for the librarians to find the title you're requesting. The "Notes" field can be used to provide any additional information.</p>
<form action="/cgi-bin/koha/opac-suggestions.pl" method="post">
<fieldset class="rows"> <ol>
<li><label class="required" for="title">Title:</label><input type="text" id="title" name="title" size="80" maxlength="255" /></li>
<li><label for="author">Author:</label><input type="text" id="author" name="author" size="50" maxlength="80" /></li>
<li><label for="copyrightdate">Copyright Date:</label><input type="text" id="copyrightdate" name="copyrightdate" size="4" maxlength="4" /></li>
<li><label for="isbn">Standard Number (ISBN, ISSN or Other):</label><input type="text" id="isbn" name="isbn" size="50" maxlength="80" /></li>
<li><label for="publishercode">Publisher:</label><input type="text" id="publishercode" name="publishercode" size="50" maxlength="80" /></li>
<li><label for="collectiontitle">Collection title:</label><input type="text" id="collectiontitle" name="collectiontitle" size="50" maxlength="80" /></li>
<li><label for="place">Publication place:</label><input type="text" id="place" name="place" size="50" maxlength="80" /></li>
<li><label for="itemtype">Item type:</label><select name="itemtype" id="itemtype">
<option value="">Default</option>
[% FOREACH itemtypeloo IN itemtypeloop %]
[% IF ( itemtypeloo.selected ) %]<option value="[% itemtypeloo.itemtype %]" selected="selected"> [% ELSE %]<option value="[% itemtypeloo.itemtype %]"> [% END %] [% itemtypeloo.description %]</option>
[% END %]
</select> </li>
[% IF ( branchloop ) %]
<li><label for="branch">Library:</label>
<select name="branch" id="branch">
[% FOREACH branchloo IN branchloop %]
[% IF ( branchloo.selected ) %]
<option value="[% branchloo.branchcode %]" selected="selected">[% branchloo.branchname %]</option>
[% ELSE %]
<option value="[% branchloo.branchcode %]">[% branchloo.branchname %]</option>
[% END %]
[% END %]
</select>
</li>
[% END %]
[% IF ( patron_reason_loop ) %]<li><label for="patronreason">Reason for suggestion: </label><select name="patronreason" id="patronreason"><option value="">-- Choose --</option>[% FOREACH patron_reason_loo IN patron_reason_loop %]
<option value="[% patron_reason_loo.authorised_value %]">[% patron_reason_loo.lib %]</option>
[% END %]</select></li>[% END %]
<li><label for="note">Notes:</label><textarea name="note" id="note" rows="5" cols="40"></textarea></li>
</ol></fieldset>
<fieldset class="action"><input type="hidden" name="suggestedby" value="[% suggestedbyme %]" /><input type="hidden" name="op" value="add_confirm" /><input type="submit" onclick="Check(this.form); return false;" value="Submit Your Suggestion" /> <a class="action" href="/cgi-bin/koha/opac-suggestions.pl">Cancel</a></fieldset>
</form>
[% END %]
[% IF ( op_else ) %]
<h1>[% IF ( OPACViewOthersSuggestions ) %]Purchase suggestions[% ELSE %][% IF ( loggedinusername ) %]My purchase suggestions[% ELSE %]Purchase suggestions[% END %][% END %]</h1>
[% IF ( deleted ) %]<div class="dialog message">The selected suggestions have been deleted.</div>[% END %]
[% IF ( submitted ) %]<div class="dialog message">Your suggestion has been submitted.</div>[% END %]
[% IF ( suggestions_loop ) %]
[% IF ( OPACViewOthersSuggestions ) %]
<form action="/cgi-bin/koha/opac-suggestions.pl" method="get">
<table>
<tr>
<th>
Search for:
</th>
<td>
<input type="text" name="title" value="[% title |html %]" />
</td>
<th>
Suggested by:
</th>
<td>
<select name="suggestedby">
<option value="0">Anyone</option>
<option value="1">Me</option>
</select>
</td>
<th>
<input type="submit" value="Search" />
</th>
</tr>
</table>
</form>[% END %]
<form action="/cgi-bin/koha/opac-suggestions.pl" method="post" id="myform">
<input type="hidden" name="op" value="delete_confirm" />
<div id="toolbar" class="list-actions">[% IF ( loggedinusername ) %]<a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a>[% ELSE %][% IF ( AnonSuggestions ) %]<a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a>[% END %][% END %]
</div>
[% IF ( loggedinusername ) %]<div id="selections-toolbar" class="list-actions">
<span class="checkall"></span> <span class="clearall"></span> <span class="sep">|</span>
<span class="links"><span id="selections">Select suggestions to: </span>
<span id="removeitems"></span>
</div>[% END %]
<table id="suggestt" class="checkboxed">
<thead><tr>
[% IF ( loggedinusername ) %]<th>&nbsp;</th>[% END %]
<th>Summary</th>
<th>Note</th>
[% IF ( OPACViewOthersSuggestions ) %]<th>Suggested for</th>[% END %]
<th>Managed by</th>
<th>Status</th>
</tr></thead>
<tbody>[% FOREACH suggestions_loo IN suggestions_loop %]
[% IF ( suggestions_loo.even ) %]<tr>[% ELSE %]<tr class="highlight">[% END %]
[% IF ( loggedinusername ) %]<td>
[% IF ( suggestions_loo.showcheckbox ) %]
<input type="checkbox" class="cb" name="delete_field" value="[% suggestions_loo.suggestionid %]" />
[% END %]
</td>[% END %]
<td>
<p><strong>[% suggestions_loo.title |html %]</strong></p>
<p>[% IF ( suggestions_loo.author ) %][% suggestions_loo.author %],[% END %]
[% IF ( suggestions_loo.copyrightdate ) %] - [% suggestions_loo.copyrightdate %],[% END %]
[% IF ( suggestions_loo.publishercode ) %] - [% suggestions_loo.publishercode %][% END %]
[% IF ( suggestions_loo.place ) %]([% suggestions_loo.place %])[% END %]
[% IF ( suggestions_loo.collectiontitle ) %] , [% suggestions_loo.collectiontitle %][% END %]
[% IF ( suggestions_loo.itemtype ) %] - [% suggestions_loo.itemtype %][% END %]
</p>
</td>
<td>
[% suggestions_loo.note %]
</td>
[% IF ( OPACViewOthersSuggestions ) %]<td>
[% IF ( suggestions_loo.branchcodesuggestedby ) %][% suggestions_loo.branchcodesuggestedby %][% ELSE %]&nbsp;[% END %]
</td>[% END %]
<td>
[% IF ( suggestions_loo.surnamemanagedby ) %][% suggestions_loo.surnamemanagedby %][% IF ( suggestions_loo.firstnamemanagedby ) %],[% END %] [% suggestions_loo.firstnamemanagedby %][% ELSE %]&nbsp;[% END %]
</td>
<td>
[% IF ( suggestions_loo.ASKED ) %]Requested
[% ELSIF ( suggestions_loo.CHECKED ) %]Checked by the library
[% ELSIF ( suggestions_loo.ACCEPTED ) %]Accepted by the library
[% ELSIF ( suggestions_loo.ORDERED ) %]Ordered by the library
[% ELSIF ( suggestions_loo.REJECTED ) %]Suggestion declined
[% ELSIF ( suggestions_loo.AVAILABLE ) %]Available in the library
[% ELSE %] [% KohaAuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS, 1 ) %] [% END %]
[% IF ( suggestions_loo.reason ) %]([% suggestions_loo.reason %])[% END %]
</td>
</tr>
[% END %]
</tbody>
</table> [% IF ( loggedinusername ) %]<fieldset class="action">
<input type="submit" value="Delete selected" />
</fieldset>
[% END %]
</form>
[% ELSE %]<p>There are no pending purchase suggestions.</p> [% IF ( loggedinusername ) %]<p><a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a></p>[% ELSE %][% IF ( AnonSuggestions ) %]<p><a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a></p>[% END %][% END %][% END %]
[% END %]
</div>
</div>
</div>
</div>
<div class="yui-b">
<div id="leftmenus" class="container">
[% INCLUDE 'navigation.inc' IsPatronPage=1 %]
</div>
</div>
</div>
[% INCLUDE 'opac-bottom.inc' %]