From 9f7148138b01a57d35a9373b15f44432a50cc312 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 6 Jun 2013 14:37:19 +0200 Subject: [PATCH] Bug 7684: QA Followup This followup: - replaces the MySQLism SQL_CALC_FOUND_ROWS - uses Koha::DateUtils instead of C4::Dates - replaces "branch" and "location" with "library" - fixes wrong capitalisation on "Clear all" and "Select all" --- C4/Items.pm | 21 +++++++++++------- .../prog/en/modules/tools/inventory.tt | 23 ++++++++++---------- tools/ajax-inventory.pl | 22 +------------------ tools/inventory.pl | 18 +++++++++------ 4 files changed, 37 insertions(+), 47 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index d53adaa..0b81efb 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -992,12 +992,15 @@ sub GetItemsForInventory { my $dbh = C4::Context->dbh; my ( @bind_params, @where_strings ); - my $query = <<'END_SQL'; -SELECT SQL_CALC_FOUND_ROWS items.itemnumber, barcode, itemcallnumber, title, author, biblio.biblionumber, biblio.frameworkcode, datelastseen, homebranch, location, notforloan, damaged, itemlost, stocknumber -FROM items - LEFT JOIN biblio ON items.biblionumber = biblio.biblionumber - LEFT JOIN biblioitems on items.biblionumber = biblioitems.biblionumber -END_SQL + my $select_columns = q{ + SELECT SQL_CALC_FOUND_ROWS items.itemnumber, barcode, itemcallnumber, title, author, biblio.biblionumber, biblio.frameworkcode, datelastseen, homebranch, location, notforloan, damaged, itemlost, stocknumber + }; + my $select_count = q{SELECT COUNT(*)}; + my $query = q{ + FROM items + LEFT JOIN biblio ON items.biblionumber = biblio.biblionumber + LEFT JOIN biblioitems on items.biblionumber = biblioitems.biblionumber + }; if ($statushash){ for my $authvfield (keys %$statushash){ if ( scalar @{$statushash->{$authvfield}} > 0 ){ @@ -1052,14 +1055,16 @@ END_SQL $query .= join ' AND ', @where_strings; } $query .= ' ORDER BY items.cn_sort, itemcallnumber, title'; + my $count_query = $select_count . $query; $query .= " LIMIT $offset, $size" if ($offset and $size); + $query = $select_columns . $query; my $sth = $dbh->prepare($query); $sth->execute( @bind_params ); my @results; my $tmpresults = $sth->fetchall_arrayref({}); - $sth = $dbh->prepare("SELECT FOUND_ROWS()"); - $sth->execute(); + $sth = $dbh->prepare( $count_query ); + $sth->execute( @bind_params ); my ($iTotalRecords) = $sth->fetchrow_array(); foreach my $row (@$tmpresults) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt index 1052714..77d840b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt @@ -1,3 +1,4 @@ +[% USE KohaDates %] [% INCLUDE 'doc-head-open.inc' %] Koha › Tools › Inventory [% INCLUDE 'doc-head-close.inc' %] @@ -16,8 +17,8 @@ $(document).ready(function(){ } )); - $("#continuewithoutmarkingbutton").click(function(){ - inventorydt.fnPageChange( 'next' ); + $("#continuewithoutmarkingbutton").click(function(){ + inventorydt.fnPageChange( 'next' ); return false; }); @@ -82,7 +83,7 @@ $(document).ready(function(){

Inventory/Stocktaking

- [% IF (moddatecount) %]
[% moddatecount %] items modified : datelastseen set to [% date %]
[% END %] + [% IF (moddatecount) %]
[% moddatecount %] items modified : datelastseen set to [% date | $KohaDates %]
[% END %] [% IF (errorfile) %]
[% errorfile %] can't be opened
[% END %] [% FOREACH error IN errorloop %]
@@ -100,7 +101,7 @@ $(document).ready(function(){ Use a barcode file
  1. -
  2. +
@@ -109,10 +110,10 @@ $(document).ready(function(){
  1. Home library - Current location + Current library
  2. +
  3. [% IF (ignoreissued) %] @@ -206,13 +207,13 @@ $(document).ready(function(){ - + - + @@ -246,7 +247,7 @@ $(document).ready(function(){ [% result.damaged | html %]
    Seen BarcodeLocationLibrary Title Status Lost - [% result.datelastseen | html %] + [% result.datelastseen | html | $KohaDates%] [% IF (result.wrongplace) %]

    Item should not have been scanned

    [% ELSIF (result.missingitem) %]

    Item missing

    [% ELSIF (result.changestatus) %]

    Change item status

    [% END %] @@ -257,7 +258,7 @@ $(document).ready(function(){

    - + diff --git a/tools/ajax-inventory.pl b/tools/ajax-inventory.pl index 24739b9..63f371a 100755 --- a/tools/ajax-inventory.pl +++ b/tools/ajax-inventory.pl @@ -1,27 +1,9 @@ #!/usr/bin/perl -# use Modern::Perl; - use CGI; -use JSON; - use C4::Auth; -use C4::Circulation qw/CanBookBeRenewed/; -use C4::Context; -use C4::Koha qw/getitemtypeimagelocation/; -use C4::Reserves qw/CheckReserves/; -use C4::Utils::DataTables; -use C4::Output; -use C4::Biblio; -use C4::Items; -use C4::Dates qw/format_date format_date_in_iso/; -use C4::Koha; -use C4::Branch; # GetBranches -use C4::Reports::Guided; #_get_column_defs -use C4::Charset; -use List::MoreUtils qw /none/; - +use C4::Items qw( ModDateLastSeen ); my $input = new CGI; @@ -38,6 +20,4 @@ foreach ( @seent ) { /SEEN-(.+)/ and &ModDateLastSeen($1); } - print $input->header('application/json'); - diff --git a/tools/inventory.pl b/tools/inventory.pl index 1518dc9..c1ba03f 100755 --- a/tools/inventory.pl +++ b/tools/inventory.pl @@ -31,12 +31,12 @@ use C4::Context; use C4::Output; use C4::Biblio; use C4::Items; -use C4::Dates qw/format_date format_date_in_iso/; use C4::Koha; use C4::Branch; # GetBranches use C4::Circulation; use C4::Reports::Guided; #_get_column_defs use C4::Charset; +use Koha::DateUtils; use List::MoreUtils qw/none/; @@ -134,7 +134,7 @@ $statussth =~ s, and $,,g; $template->param( branchloop => \@branch_loop, authorised_values => \@authorised_value_list, - today => C4::Dates->today(), + today => dt_from_string, minlocation => $minlocation, maxlocation => $maxlocation, location => $location, @@ -160,7 +160,8 @@ my $barcodelist; my @errorloop; if ( $uploadbarcodes && length($uploadbarcodes) > 0 ) { my $dbh = C4::Context->dbh; - my $date = format_date_in_iso( $input->param('setdate') ) || C4::Dates->today('iso'); + my $date = dt_from_string( $input->param('setdate') ); + $date = output_pref( $date, 'iso' ); my $strsth = "select * from issues, items where items.itemnumber=issues.itemnumber and items.barcode =?"; my $qonloan = $dbh->prepare($strsth); @@ -197,7 +198,7 @@ if ( $uploadbarcodes && length($uploadbarcodes) > 0 ) { } $qonloan->finish; $qwthdrawn->finish; - $template->param( date => format_date($date), Number => $count ); + $template->param( date => $date, Number => $count ); $template->param( errorloop => \@errorloop ) if (@errorloop); @@ -220,7 +221,11 @@ if ( $markseen or $op ) { } # set "missing" flags for all items with a datelastseen before the choosen datelastseen -foreach (@$res) { $_->{missingitem}=1 if C4::Dates->new($_->{datelastseen})->output('iso') lt C4::Dates->new($datelastseen)->output('iso'); } +foreach my $r ( @$res ) { + $r->{missingitem} = 1 + if output_pref( dt_from_string( $_->{datelastseen} ), 'iso' ) + lt output_pref( dt_from_string( $datelastseen ), 'iso' ); +} # removing missing items from loop if "Compare barcodes list to results" has not been checked @$res = grep {!$_->{missingitem} == 1 } @$res if (!$input->param('compareinv2barcd')); @@ -254,7 +259,6 @@ foreach my $temp (@brcditems) { my $biblio = C4::Biblio::GetBiblioData($temp->{biblionumber}); $temp->{title} = $biblio->{title}; $temp->{author} = $biblio->{author}; - $temp->{datelastseen} = format_date($temp->{datelastseen}); push @$res, $temp; } @@ -264,7 +268,7 @@ foreach my $temp (@brcditems) { my $biblio = C4::Biblio::GetBiblioData($temp->{biblionumber}); $temp2->{title} = $biblio->{title}; $temp2->{author} = $biblio->{author}; - $temp2->{datelastseen} = format_date($temp->{datelastseen}); + $temp2->{datelastseen} = $temp->{datelastseen}; push @$res, $temp2; } } -- 1.7.10.4