Bug 11718 - Use new DataTables include in reports templates
authorOwen Leonard <oleonard@myacpl.org>
Mon, 10 Feb 2014 14:29:13 +0000 (09:29 -0500)
committerGalen Charlton <gmc@esilibrary.com>
Wed, 12 Mar 2014 17:33:25 +0000 (17:33 +0000)
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.

Signed-off-by: Aleisha <aleishaamohia@hotmail.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes all tests and QA script.
Checked all pages, no regressions or Javascript errors detected.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
C4/Reports/Guided.pm
koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt
koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemtypes.tt
koha-tmpl/intranet-tmpl/prog/en/modules/reports/serials_stats.tt
reports/serials_stats.pl

index 22a23dd..f827090 100644 (file)
@@ -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;
 }
index 6f8bfbe..63608f7 100644 (file)
@@ -1,3 +1,4 @@
+[% USE KohaDates %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Reports &rsaquo; Guided reports wizard
 [% IF ( saved1 ) %]&rsaquo; Saved Reports
 </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,19 +57,19 @@ 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>',
         'sPaginationType': 'four_button',
         'aaSorting': [[ 1, "asc" ]],
         'aoColumnDefs': [
-            { 'bSortable': false, 'bSearchable':false, 'aTargets': [0, -1, -2, -3, -4] },
+            { 'bSortable': false, 'bSearchable':false, 'aTargets': [0, -1] },
             { '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")
         }
@@ -324,7 +320,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 %]
index acbba9d..689f262 100644 (file)
@@ -2,10 +2,8 @@
 <title>Koha &rsaquo; Reports &rsaquo; 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(){
index a53c984..cd8bf70 100644 (file)
@@ -1,20 +1,22 @@
+[% USE KohaDates %]
+[% USE Branches %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Reports &rsaquo; 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
+                ],
             }));
        });
        //]]>
                <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 %]
index 36f7cc5..d86c5b9 100755 (executable)
@@ -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