From c18fd98bc7209bdc56b223469d3394b157548086 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 26 Mar 2019 20:20:29 +0000 Subject: [PATCH] Bug 19722: Don't show items at job completion if over pref To test: 1 - Set MaxItemsToDisplayForBatchMod to some number 2 - Modify less items than that 3 - Note they show a - Note if over 1000 they show in a simple display 4 - Modify more items 5 - Note they do not show and you see a note Signed-off-by: Josef Moravec Signed-off-by: Nick Clemens --- .../prog/en/modules/tools/batchMod-edit.tt | 20 ++++++----- tools/batchMod.pl | 36 +++++++++++-------- 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt index e96dda3d0d..968770d323 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt @@ -211,15 +211,19 @@ $(document).ready(function(){ [% END %] -[% IF ( simple_items_display ) %] -

The following items were modified:

-
    - [% FOREACH simple_items_displa IN simple_items_display %] -
  • - [% IF ( CAN_user_editcatalogue_edit_items ) %][% simple_items_displa.barcode | html %][% ELSE %][% simple_items_displa.barcode | html %][% END %] -
  • +[% IF ( simple_items_display || job_completed ) %] + [% IF ( too_many_items_display ) %] +

    Too many items ([% too_many_items_display | html %]): You have edited more than [% Koha.Preference('MaxItemsToDisplayForBatchMod') | html %] items in a batch, items will not be shown.

    + [% ELSE %] +

    The following items were modified:

    +
      + [% FOREACH simple_items_displa IN simple_items_display %] +
    • + [% IF ( CAN_user_editcatalogue_edit_items ) %][% simple_items_displa.barcode | html %][% ELSE %][% simple_items_displa.barcode | html %][% END %] +
    • + [% END %] +
    [% END %] -
[% END %] [% IF ( show ) %] diff --git a/tools/batchMod.pl b/tools/batchMod.pl index 8e1e854ab0..85077ab33c 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -119,21 +119,27 @@ if ($op eq "action") { # Once the job is done if ($completedJobID) { # If we have a reasonable amount of items, we display them - if (scalar(@itemnumbers) <= ( C4::Context->preference("MaxItemsToDisplayForBatchDel") // 1000 ) ) { - $items_display_hashref=BuildItemsData(@itemnumbers); - } else { - # Else, we only display the barcode - my @simple_items_display = map { - my $itemnumber = $_; - my $item = Koha::Items->find($itemnumber); - { - itemnumber => $itemnumber, - barcode => $item ? ( $item->barcode // q{} ) : q{}, - biblionumber => $item ? $item->biblio->biblionumber : q{}, - }; - } @itemnumbers; - $template->param("simple_items_display" => \@simple_items_display); - } + my $max_items = $del ? C4::Context->preference("MaxItemsToDisplayForBatchDel") : C4::Context->preference("MaxItemsToDisplayForBatchMod"); + if (scalar(@itemnumbers) <= $max_items ){ + if (scalar(@itemnumbers) <= 1000 ) { + $items_display_hashref=BuildItemsData(@itemnumbers); + } else { + # Else, we only display the barcode + my @simple_items_display = map { + my $itemnumber = $_; + my $item = Koha::Items->find($itemnumber); + { + itemnumber => $itemnumber, + barcode => $item ? ( $item->barcode // q{} ) : q{}, + biblionumber => $item ? $item->biblio->biblionumber : q{}, + }; + } @itemnumbers; + $template->param("simple_items_display" => \@simple_items_display); + } + } else { + $template->param( "too_many_items_display" => scalar(@itemnumbers) ); + $template->param( "job_completed" => 1 ); + } # Setting the job as done my $job = C4::BackgroundJob->fetch($sessionID, $completedJobID); -- 2.39.5