From a1e490b9ba9efdfba2856217278c95c518229b76 Mon Sep 17 00:00:00 2001 From: genevieve Date: Tue, 15 Sep 2015 11:18:49 -0400 Subject: [PATCH] Bug 6934 - Fix code in CashRegisterStats (dataTables pagination, more accurate descriptions, add a delimiter pull down, change C4::Dates to Koha::DateUtils) 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. --- .../prog/en/includes/reports-menu.inc | 2 +- .../prog/en/modules/reports/cash_register_stats.tt | 24 +++++++++++---- reports/cash_register_stats.pl | 32 +++++++++++--------- 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/reports-menu.inc index 41dd0d2..03b4b64 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/reports-menu.inc @@ -10,7 +10,7 @@
  • Catalog
  • Circulation
  • Serials
  • -
  • Cash Register
  • +
  • Cash register
  • Holds
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt index 4a5c10e..5e228ac 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt @@ -8,7 +8,8 @@ @@ -218,6 +219,17 @@ $(document).ready(function() { + + + @@ -233,15 +245,15 @@ $(document).ready(function() { Manager name - Borrower cardnumber - Borrower name - Branch + Patron cardnumber + Patron name + Library Transaction date Transaction type Amount Biblio title Barcode - Document type + Item type [% FOREACH loopresul IN loopresult %] @@ -261,7 +273,7 @@ $(document).ready(function() { [% ELSIF loopresul.accounttype == "F" %] Fine [% ELSIF loopresul.accounttype == "FU" %] - Fine - long period + Accruing fine [% ELSIF loopresul.accounttype == "Pay" %] Payment [% ELSIF loopresul.accounttype == "A" %] diff --git a/reports/cash_register_stats.pl b/reports/cash_register_stats.pl index 883b008..625f4a8 100755 --- a/reports/cash_register_stats.pl +++ b/reports/cash_register_stats.pl @@ -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 qw/output_pref dt_from_string/; use C4::Budgets qw/GetCurrency GetCurrencies/; #use Data::Dumper; #use Smart::Comments; @@ -46,18 +46,20 @@ 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(), + #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 $now = DateTime->today; +my $today = $now->strftime('%d/%m/%Y'); +my $fromDate = dt_from_string($today, 'metric'); +my $toDate = dt_from_string($today, 'metric'); ### fromdate today: $fromDate my $query_manualinv = "SELECT id, authorised_value FROM authorised_values WHERE category = 'MANUAL_INV'"; @@ -69,8 +71,8 @@ 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 = dt_from_string($input->param("filter_date_begin"), 'metric'); + $toDate = dt_from_string($input->param("filter_date_end"), 'metric'); my $whereTType = ''; @@ -119,7 +121,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} = output_pref({ dt => dt_from_string($row->{date}, 'sql'), date_format => 'metric', dateonly => 1 }); ### date : $row->{date} push (@loopresult, $row); @@ -178,12 +180,14 @@ if ($do_it) { ### fromdate final: $fromDate ### toDate final: $toDate $template->param( - beginDate => format_date($fromDate), - endDate => format_date($toDate), + beginDate => output_pref({dt => $fromDate, date_format => 'metric', dateonly => 1}), + endDate => output_pref({dt => $toDate, date_format => 'metric', dateonly => 1}), 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; -- 1.7.9.5