[Koha-patches] [PATCH] Bug 11718 - Use new DataTables include in reports templates

Owen Leonard oleonard at myacpl.org
Mon Feb 10 16:10:39 CET 2014


Bug 10649 introduced a new include file for adding DataTables-related
JavaScript assets. This patch adds use of this include file to all
circ-related pages which use DataTables.

Apply the patch and test the following pages to confirm that table
sorting works correctly:

- Reports -> Guided reports -> Use saved
  (reports/guided_reports.pl?phase=Use saved):
  "Creation date" sorting has been reconfigured to use the title-string
  method for sorting on an unformatted date. C4:Reports::Guided.pm has
  been modified to pass an unformatted date to the template. Sorting
  should work correctly for all settings of the dateformat system pref.

- Reports -> Catalog by item type
  (reports/manager.pl?report_name=itemtypes)

- Reports -> Serials statistics wizard (reports/serials_stats.pl):
  The subscription begin and subscription end columns have been modified
  to use the title-string filter for sorting. An unformatted date is now
  passed from reports/serials_stats.pl to the template, where the
  KohaDates filter is used for formatting. Sorting is based on the
  unformatted date. Sorting should work correctly for all settings of
  the dateformat system pref.

  - Sorting of titles should now exclude article from sorting.
  - Minor template improvements:
    - Vendor name now links to vendor details.
    - Subscription title now links to subscription details.
    - Library name is now shown instead of branchcode.
---
 C4/Reports/Guided.pm                               |    1 -
 .../en/modules/reports/guided_reports_start.tt     |   18 ++++++--------
 .../prog/en/modules/reports/itemtypes.tt           |    6 ++---
 .../prog/en/modules/reports/serials_stats.tt       |   26 +++++++++++---------
 reports/serials_stats.pl                           |    3 +--
 5 files changed, 24 insertions(+), 30 deletions(-)

diff --git a/C4/Reports/Guided.pm b/C4/Reports/Guided.pm
index 22a23dd..f827090 100644
--- a/C4/Reports/Guided.pm
+++ b/C4/Reports/Guided.pm
@@ -673,7 +673,6 @@ sub get_saved_reports {
     $query .= " ORDER by date_created";
     
     my $result = $dbh->selectall_arrayref($query, {Slice => {}}, @args);
-    $_->{date_created} = format_date($_->{date_created}) foreach @$result;
 
     return $result;
 }
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt
index 2ac91d6..64522a8 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt
@@ -1,3 +1,4 @@
+[% USE KohaDates %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha › Reports › Guided reports wizard
 [% IF ( saved1 ) %]› Saved Reports
@@ -21,16 +22,11 @@
 </style>
 [% IF ( saved1 ) %]
 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
-<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
-[% INCLUDE 'datatables-strings.inc' %]
-<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
+[% INCLUDE 'datatables.inc' %]
 [% END %]
 
 <script type="text/javascript">
 //<![CDATA[
-[% IF (dateformat == 'metric' && saved1) %]
-dt_add_type_uk_date();
-[% END %]
 var group_subgroups = {};
 [% FOREACH group IN groups_with_subgroups %]
     var gid = "[% group.id %]"
@@ -61,9 +57,6 @@ function load_group_subgroups () {
 $(document).ready(function(){
 
 [% IF (saved1) %]
-    [% IF (dateformat == "metric") %]
-        dt_add_type_uk_date();
-    [% END %]
     var rtable = $("#table_reports").dataTable($.extend(true, {}, dataTablesDefaults, {
         'bAutoWidth': false,
         'sDom': 't<"bottom pager"ilpf>',
@@ -72,10 +65,13 @@ $(document).ready(function(){
         'iDisplayLength': 20,
         'aaSorting': [[ 1, "asc" ]],
         'aoColumnDefs': [
-            { 'bSortable': false, 'bSearchable':false, 'aTargets': [0, -1, -2, -3, -4] },
+            { 'bSortable': false, 'bSearchable':false, 'aTargets': [0, -1, -2, -3] },
             { 'bSearchable': false, 'aTargets': [3, 4] },
             { "aTargets": [ 1, 2 ], "sType": "natural"  }
         ],
+        "aoColumns": [
+            null,null,null,null,null,null,null,null,{ "sType": "title-string" },null,[% IF (usecache) %]null,[% END %]null,null
+        ],
         'oLanguage': {
             'sZeroRecords': _("No matching reports found")
         }
@@ -326,7 +322,7 @@ canned reports and writing custom SQL reports.</p>
                         <td>[% savedreport.subgroupname %]</td>
                         <td>[% savedreport.notes %]</td>
                         <td>[% savedreport.borrowersurname %][% IF ( savedreport.borrowerfirstname ) %], [% savedreport.borrowerfirstname %][% END %] ([% savedreport.borrowernumber %])</td>
-                        <td>[% savedreport.date_created %]</td>
+                        <td><span title="[% savedreport.date_created %]">[% savedreport.date_created | $KohaDates %]</span></td>
                         [% IF (savedreport.public) %]
                         <td>Yes</td>
                         [% ELSE %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemtypes.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemtypes.tt
index acbba9d..689f262 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemtypes.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemtypes.tt
@@ -2,10 +2,8 @@
 <title>Koha › Reports › Catalog by item types</title>
 [% INCLUDE 'doc-head-close.inc' %]
 [% IF ( do_it ) %]
-<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/en/css/datatables.css" />
-<script type="text/javascript" src="[% interface %]/[% theme %]/en/lib/jquery/plugins/jquery.dataTables.min.js"></script>
-[% INCLUDE 'datatables-strings.inc' %]
-<script type="text/javascript" src="[% interface %]/[% theme %]/en/js/datatables.js"></script>
+<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
+[% INCLUDE 'datatables.inc' %]
 <script type="text/javascript">
 //<![CDATA[
 $(document).ready(function(){
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/serials_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/serials_stats.tt
index a53c984..cd8bf70 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/serials_stats.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/serials_stats.tt
@@ -1,20 +1,22 @@
+[% USE KohaDates %]
+[% USE Branches %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha › Reports › Serials subscriptions stats</title>
 [% INCLUDE 'doc-head-close.inc' %]
 <style type="text/css">
 	.sql {display: none;}
 </style>
-<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/en/css/datatables.css" />
-<script type="text/javascript" src="[% interface %]/[% theme %]/en/lib/jquery/plugins/jquery.dataTables.min.js"></script>
-[% INCLUDE 'datatables-strings.inc' %]
-<script type="text/javascript" src="[% interface %]/[% theme %]/en/js/datatables.js"></script>
+<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
+[% INCLUDE 'datatables.inc' %]
 <script type="text/javascript">
 	//<![CDATA[
-        [% IF (dateformat == 'metric') %]dt_add_type_uk_date();[% END %]
 		$(document).ready(function() {
             $("#resulttable").dataTable($.extend(true, {}, dataTablesDefaults, {
                 "sDom": 't',
-                "bPaginate": false
+                "bPaginate": false,
+                "aoColumns": [
+                    null,{ "sType": "anti-the" },null,null,null,{ "sType": "title-string" },{ "sType": "title-string" },null
+                ],
             }));
     	});
 	//]]>
@@ -49,13 +51,13 @@
 		<tbody>
 			<tr>
 				[% FOREACH data IN datas %]
-					<td>[% data.name %]</td>
-					<td>[% data.title |html %]</td>
+                    <td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% data.aqbooksellerid %]">[% data.name %]</a></td>
+                    <td><a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% data.subscriptionid %]">[% data.title |html %]</a></td>
 					<td>[% data.subscriptionid %]</td>
-					<td>[% data.branchcode %]</td>
+                    <td>[% Branches.GetName( data.branchcode ) %]</td>
 					<td>[% data.callnumber %]</td>
-					<td>[% data.startdate %]</td>
-					<td>[% data.enddate %]</td>
+                    <td><span title="[% data.startdate %]">[% data.startdate | $KohaDates %]</span></td>
+                    <td><span title="[% data.enddate %]">[% data.enddate | $KohaDates %]</span></td>
                     <td>
                         [% IF data.closed %]
                             Closed
@@ -80,7 +82,7 @@
 					Vendor:
 			    </label>
 				<select name="bookseller" id="bookseller">
-					<option value="">Any Vendor</option>
+                    <option value="">Any vendor</option>
     				[% FOREACH bookseller IN booksellers %]
 						<option value="[% bookseller.aqbooksellerid %]">[% bookseller.name %]</option>
 					[% END %]
diff --git a/reports/serials_stats.pl b/reports/serials_stats.pl
index 36f7cc5..d86c5b9 100755
--- a/reports/serials_stats.pl
+++ b/reports/serials_stats.pl
@@ -94,8 +94,7 @@ if($do_it){
     my @datas;
 
     while(my $row = $sth->fetchrow_hashref){
-        $row->{'enddate'} = format_date(GetExpirationDate($row->{'subscriptionid'}));
-        $row->{'startdate'} = format_date($row->{'startdate'});
+        $row->{'enddate'} = GetExpirationDate($row->{'subscriptionid'});
         $row->{expired} = HasSubscriptionExpired($row->{subscriptionid});
         push @datas, $row if (
             $expired
-- 
1.7.9.5


More information about the Koha-patches mailing list