Bug 6934: Fix code in CashRegisterStats (dataTables pagination, more accurate descrip...
authorgenevieve <genevieve.plantin@inlibro.com>
Tue, 15 Sep 2015 15:18:49 +0000 (11:18 -0400)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 28 Oct 2016 11:50:24 +0000 (11:50 +0000)
I cleaned up the code according to comment #23. I got rid of DHTMLcalendar_dateformat,
beacause it wasn't use in cash_register_stats.tt. C4::Dates is deprecated,
Koha::DateUtils is now used.
Some column names are changed and the pagination for the dataTables is fixed.

Signed-off-by: Hector Castro <hector.hecaxmmx@gmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

koha-tmpl/intranet-tmpl/prog/en/includes/reports-menu.inc
koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt
reports/cash_register_stats.pl

index 41dd0d2..03b4b64 100644 (file)
@@ -10,7 +10,7 @@
                <li><a href="/cgi-bin/koha/reports/catalogue_stats.pl">Catalog</a></li>
                <li><a href="/cgi-bin/koha/reports/issues_stats.pl">Circulation</a></li>
         <li><a href="/cgi-bin/koha/reports/serials_stats.pl">Serials</a></li>
-        <li><a href="/cgi-bin/koha/reports/cash_register_stats.pl">Cash Register</a></li>
+        <li><a href="/cgi-bin/koha/reports/cash_register_stats.pl">Cash register</a></li>
         <li><a href="/cgi-bin/koha/reports/reserves_stats.pl">Holds</a></li>        
        </ul>
 
index 4a5c10e..4ec7fe1 100644 (file)
@@ -1,17 +1,19 @@
+[% USE KohaDates %]
 [% INCLUDE 'doc-head-open.inc' %]
-<title>Koha &rsaquo; Reports [% IF ( do_it ) %]&rsaquo; Cash Register Statistics &rsaquo; Results[% ELSE %]&rsaquo; Cash Register Statistics[% END %]</title>
+<title>Koha &rsaquo; Reports [% IF ( do_it ) %]&rsaquo; Cash register statistics &rsaquo; Results[% ELSE %]&rsaquo; Cash register statistics[% END %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
 [% INCLUDE 'datatables.inc' %]
 [% INCLUDE 'datatables-strings.inc' %]
 <script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
-<script type="text/javascript" id="js">$(document).ready(function() {
+<script type="text/javascript" id="js">
  $(document).ready(function() {
     $("#tbl_cash_register_stats").dataTable($.extend(true, {}, dataTablesDefaults, {
-        "iDisplayLength": 50
+        "iDisplayLength": 50,
+        "sPaginationType": "full_numbers"
     }));
  });
-}); </script>
+</script>
 [% INCLUDE 'calendar.inc' %]
 <script type="text/javascript">
 //<![CDATA[
@@ -25,7 +27,6 @@ function isNull(f,noalert) {
 }
 
 $(document).ready(function() {
-
     // http://jqueryui.com/demos/datepicker/#date-range
     var dates = $( "#filter_date_begin, #filter_date_end" ).datepicker({
         changeMonth: true,
@@ -56,8 +57,6 @@ $(document).ready(function() {
            alert(alertString);
            return false;
         }
-
-        $(this).submit();
     });
 });
 
@@ -73,9 +72,9 @@ $(document).ready(function() {
     <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a>
     &rsaquo;
     [% IF ( do_it ) %]
-        <a href="/cgi-bin/koha/reports/cash_register_stats.pl">Cash Register Statistics</a> &rsaquo; Results
+        <a href="/cgi-bin/koha/reports/cash_register_stats.pl">Cash register statistics</a> &rsaquo; Results
     [% ELSE %]
-        Cash Register Statistics
+        Cash register statistics
     [% END %]
 </div>
 
@@ -88,7 +87,7 @@ $(document).ready(function() {
     <h1>Cash register statistics</h1>
     <form method="post" action="/cgi-bin/koha/reports/cash_register_stats.pl" id="frmCashRegister">
         <fieldset class="rows">
-        <legend>Cash Register statistics [% beginDate %] to [% endDate %]</legend>
+        <legend>Cash register statistics [% beginDate | $KohaDates %] to [% endDate | $KohaDates %]</legend>
         <table>
             <thead>
                 <tr>
@@ -99,9 +98,9 @@ $(document).ready(function() {
                 <tr>
                     <td>
                         <label for="filter_date_begin">From</label>
-                        <input type="text" size="10" id="filter_date_begin" name="filter_date_begin" value="[% beginDate %]" />
+                        <input type="text" size="10" id="filter_date_begin" name="filter_date_begin" value="[% beginDate | $KohaDates %]" />
                         <label for="filter_date_end">To</label>
-                        <input type="text" size="10" id="filter_date_end" name="filter_date_end" value="[% endDate %]" />
+                        <input type="text" size="10" id="filter_date_end" name="filter_date_end" value="[% endDate | $KohaDates %]" />
                     </td>
                 </tr>
             </tbody>
@@ -144,9 +143,9 @@ $(document).ready(function() {
                         [% END %]
 
                         [% IF transaction_type == "FU" %]
-                        <option value="FU" selected="selected">Fine - long period</option>
+                        <option value="FU" selected="selected">Accruing fine</option>
                         [% ELSE %]
-                        <option value="FU">Fine - long period</option>
+                        <option value="FU">Accruing fine</option>
                         [% END %]
 
                         [% IF transaction_type == "PAY" %]
@@ -156,7 +155,7 @@ $(document).ready(function() {
                         [% END %]
 
                         [% IF transaction_type == "A" %]
-                        <option value="A" selected="selected">Account Management Fee</option>
+                        <option value="A" selected="selected">Account management fee</option>
                         [% ELSE %]
                         <option value="A">Account Management Fee</option>
                         [% END %]
@@ -218,6 +217,17 @@ $(document).ready(function() {
                     <label for="outputfile">To a file:</label>
                     <input type="radio" name="output" value="file" id="outputfile" />
                     <label class="inline" for="basename">Named: </label><input type="text" name="basename" id="basename" value="Export" />
+                    <label class="inline" for="sep">Delimiter: </label>
+                    <select name="sep" id="sep" size="1">
+                        [% FOREACH value IN CGIsepChoice.values.sort() %]
+                           [% IF ( value == CGIsepChoice.default ) %]
+                               <option value="[% value %]" selected="selected">[% value %]</option>
+                           [% ELSE %]
+                              <option value="[% value %]">[% value %]</option>
+                           [% END %]
+                        [% END %]
+                    </select>
+
                 </li>
             </ol>
         </fieldset>
@@ -233,15 +243,15 @@ $(document).ready(function() {
         <thead>
         <tr>
             <th>Manager name</th>
-            <th>Borrower cardnumber</th>
-            <th>Borrower name</th>
-            <th>Branch</th>
+            <th>Patron cardnumber</th>
+            <th>Patron name</th>
+            <th>Library</th>
             <th>Transaction date</th>
             <th>Transaction type</th>
             <th>Amount</th>
             <th>Biblio title</th>
             <th>Barcode</th>
-            <th>Document type</th>
+            <th>Item type</th>
         </tr>
         </thead>
         [% FOREACH loopresul IN loopresult %]
@@ -250,7 +260,7 @@ $(document).ready(function() {
                 <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% loopresul.borrowernumber %]">[% loopresul.cardnumber %]</a></td>
                 <td>[% loopresul.bfirstname %] [% loopresul.bsurname %]</td>
                 <td>[% loopresul.branchname %]</td>
-                <td>[% loopresul.date %]</td>
+                <td>[% loopresul.date | $KohaDates %]</td>
                 <td>
                     [% IF loopresul.accounttype == "ACT" %]
                         <span>Active transactions</span>
@@ -261,7 +271,7 @@ $(document).ready(function() {
                     [% ELSIF loopresul.accounttype == "F" %]
                         <span>Fine</span>
                     [% ELSIF loopresul.accounttype == "FU" %]
-                        <span>Fine - long period</span>
+                        <span>Accruing fine</span>
                     [% ELSIF loopresul.accounttype == "Pay" %]
                         <span>Payment</span>
                     [% ELSIF loopresul.accounttype == "A" %]
index 883b008..bd9aa0f 100755 (executable)
@@ -14,8 +14,7 @@
 # with Koha; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
-use strict;
-use warnings;
+use Modern::Perl;
 use C4::Auth;
 use CGI;
 use C4::Context;
@@ -23,7 +22,8 @@ use C4::Reports;
 use C4::Output;
 use C4::Koha;
 use C4::Circulation;
-use C4::Dates qw/format_date format_date_in_iso/;
+use DateTime;
+use Koha::DateUtils;
 use C4::Budgets qw/GetCurrency GetCurrencies/;
 #use Data::Dumper;
 #use Smart::Comments;
@@ -46,18 +46,17 @@ my $output           = $input->param("output");
 my $basename         = $input->param("basename");
 my $transaction_type = $input->param("transaction_type") || 'ACT';
 my $branchcode       = $input->param("branch") || C4::Context->userenv->{'branch'};
-our $sep = ",";
+our $sep = $input->param("sep") // ',';
+$sep = "\t" if ($sep eq 'tabulation');
 
 $template->param(
     do_it => $do_it,
-    DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
+    CGIsepChoice => GetDelimiterChoices,
 );
 
 #Initialize date pickers to today
-my $today = C4::Dates->today('iso');
-my $fromDate = $today;
-my $toDate   = $today;
-
+my $fromDate = dt_from_string;
+my $toDate   = dt_from_string;
 ### fromdate today: $fromDate
 
 my $query_manualinv = "SELECT id, authorised_value FROM authorised_values WHERE category = 'MANUAL_INV'";
@@ -69,8 +68,10 @@ my $manualinv_types = $sth_manualinv->fetchall_arrayref({});
 
 if ($do_it) {
 
-    $fromDate = format_date_in_iso($input->param("filter_date_begin"));
-    $toDate   = format_date_in_iso($input->param("filter_date_end"));
+    $fromDate = output_pref({ dt => eval { dt_from_string($input->param("filter_date_begin")) } || dt_from_string,
+            dateformat => 'sql', dateonly => 1 }); #for sql query
+    $toDate   = output_pref({ dt => eval { dt_from_string($input->param("filter_date_end")) } || dt_from_string,
+            dateformat => 'sql', dateonly => 1 }); #for sql query
 
     my $whereTType = '';
 
@@ -119,7 +120,7 @@ if ($do_it) {
         $row->{amountoutstanding} = 0 if (!$row->{amountoutstanding});
         #if ((abs($row->{amount}) - $row->{amountoutstanding}) > 0) {
             $row->{amount} = sprintf("%.2f", abs ($row->{amount}));
-            $row->{date} = format_date($row->{date});
+            $row->{date} = dt_from_string($row->{date}, 'sql');
             ### date : $row->{date}
 
             push (@loopresult, $row);
@@ -178,12 +179,14 @@ if ($do_it) {
 ### fromdate final: $fromDate
 ### toDate final: $toDate
 $template->param(
-    beginDate        => format_date($fromDate),
-    endDate          => format_date($toDate),
+    beginDate        => dt_from_string($fromDate),
+    endDate          => dt_from_string($toDate),
     transaction_type => $transaction_type,
     branchloop       => C4::Branch::GetBranchesLoop($branchcode),
     manualinv_types  => $manualinv_types,
+    CGIsepChoice => GetDelimiterChoices,
 );
+
 output_html_with_http_headers $input, $cookie, $template->output;
 
 1;