From c1be2b8817c27c767f9f2ca2939f6b8f3013d7e2 Mon Sep 17 00:00:00 2001 From: Agustin Moyano Date: Thu, 13 Aug 2020 10:04:32 -0300 Subject: [PATCH] Bug 19889: (follow-up) Fix few minor things Signed-off-by: Nick Clemens JD amended patch: remove unecessary indentation changes Signed-off-by: Jonathan Druart --- C4/HoldsQueue.pm | 4 +-- catalogue/moredetail.pl | 2 +- catalogue/updateitem.pl | 6 ++--- .../prog/en/modules/admin/categories.tt | 8 ++++++ .../prog/en/modules/catalogue/moredetail.tt | 6 ++++- .../prog/en/modules/tools/batchMod-edit.tt | 2 +- tools/batchMod.pl | 27 +++++++++++++++++-- 7 files changed, 45 insertions(+), 10 deletions(-) diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm index cc3e540ef3..4950522726 100755 --- a/C4/HoldsQueue.pm +++ b/C4/HoldsQueue.pm @@ -409,8 +409,8 @@ sub MapItemsToHoldRequests { next if ( !$item->{holdallowed} ) || ( $item->{holdallowed} == 1 - && $item->{homebranch} ne $request->{borrowerbranch} - || $item->{_object}->exclude_from_local_holds_priority ); + && $item->{homebranch} ne $request->{borrowerbranch} ) + || $item->{_object}->exclude_from_local_holds_priority; next if $request->{itemnumber} && $request->{itemnumber} != $item->{itemnumber}; diff --git a/catalogue/moredetail.pl b/catalogue/moredetail.pl index f1d7f3d35b..763e1c0487 100755 --- a/catalogue/moredetail.pl +++ b/catalogue/moredetail.pl @@ -51,7 +51,7 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user( ); $template->param( - updated_exclude_from_local_holds_priority => $query->param('updated_exclude_from_local_holds_priority') + updated_exclude_from_local_holds_priority => scalar($query->param('updated_exclude_from_local_holds_priority')) ); if($query->cookie("holdfor")){ diff --git a/catalogue/updateitem.pl b/catalogue/updateitem.pl index f8df6a2623..d8c280e261 100755 --- a/catalogue/updateitem.pl +++ b/catalogue/updateitem.pl @@ -56,7 +56,7 @@ for ($damaged,$itemlost,$withdrawn) { } } -my $alerts = q{}; +my $messages = q{}; # modify MARC item if input differs from items table. if ( $op eq "set_non_public_note" ) { @@ -76,7 +76,7 @@ elsif ( $op eq "set_public_note" ) { # i.e., itemnotes parameter passed from for $item->withdrawn($withdrawn); } elsif ( $op eq "set_exclude_priority" && $exclude_from_local_holds_priority ne $item_data_hashref->{'exclude_from_local_holds_priority'}) { $item->exclude_from_local_holds_priority($exclude_from_local_holds_priority); - $alerts = "updated_exclude_from_local_holds_priority=$exclude_from_local_holds_priority&"; + $messages = "updated_exclude_from_local_holds_priority=$exclude_from_local_holds_priority&"; } elsif ( $op eq "set_damaged" && $damaged ne $item_data_hashref->{'damaged'}) { $item->damaged($damaged); } else { @@ -89,4 +89,4 @@ $item->store; LostItem($itemnumber, 'moredetail') if $op eq "set_lost"; -print $cgi->redirect("moredetail.pl?" . $alerts . "biblionumber=$biblionumber&itemnumber=$itemnumber#item$itemnumber"); +print $cgi->redirect("moredetail.pl?" . $messages . "biblionumber=$biblionumber&itemnumber=$itemnumber#item$itemnumber"); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt index b1f7a06c86..12de84c771 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt @@ -436,6 +436,7 @@ Check previous checkout? [% END %] Default privacy + Exclude from local holds priority Actions @@ -549,6 +550,13 @@ Forever [% END %] + + [% IF category.exclude_from_local_holds_priority %] + Yes + [% ELSE %] + No + [% END %] + Edit Delete diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt index 1f1786ea0e..ea1a2d5f9d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt @@ -61,7 +61,11 @@ [% IF updated_exclude_from_local_holds_priority.defined %]
Exclude from local holds priority updated to - [% IF updated_exclude_from_local_holds_priority %]Yes[% ELSE %]No[% END %] + [% IF updated_exclude_from_local_holds_priority %] + Yes + [% ELSE %] + No + [% END %]
[% END %] 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 d605368d7f..d182c78b6e 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 @@ -336,7 +336,7 @@ $(document).ready(function(){
- Priority + Other attributes
  1. diff --git a/tools/batchMod.pl b/tools/batchMod.pl index 18214ac2fb..127cead266 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -154,7 +154,7 @@ if ($op eq "action") { my $job = C4::BackgroundJob->fetch($sessionID, $completedJobID); # Calling the template - add_saved_job_results_to_template($template, $completedJobID); + add_saved_job_results_to_template($template, $completedJobID, $items_display_hashref); } else { # While the job is getting done @@ -186,12 +186,20 @@ if ($op eq "action") { } } + my $yesno = Koha::AuthorisedValues->search({category => 'YES_NO'}); + my $ynhash = {}; + + while(my $yn = $yesno->next) { + $ynhash->{'av'.$yn->authorised_value} = $yn->lib; + } + try { my $schema = Koha::Database->new->schema; $schema->txn_do( sub { # For each item my $i = 1; + my $extra_headers = {}; foreach my $itemnumber (@itemnumbers) { $job->progress($i) if $runinbackground; my $item = Koha::Items->find($itemnumber); @@ -233,9 +241,13 @@ if ($op eq "action") { } else { my $modified_holds_priority = 0; - if (defined $exclude_from_local_holds_priority && $item->exclude_from_local_holds_priority != $exclude_from_local_holds_priority) { + if (defined $exclude_from_local_holds_priority) { + if($item->exclude_from_local_holds_priority != $exclude_from_local_holds_priority) { $item->exclude_from_local_holds_priority($exclude_from_local_holds_priority)->store; $modified_holds_priority = 1; + } + $extra_headers->{exclude_from_local_holds_priority} = {name => 'Exclude from local holds priority', items => {}} unless defined $extra_headers->{exclude_from_local_holds_priority}; + $extra_headers->{exclude_from_local_holds_priority}->{items}->{$item->itemnumber} = $ynhash->{'av'.$item->exclude_from_local_holds_priority}; } my $modified = 0; if ( $values_to_modify || $values_to_blank ) { @@ -305,6 +317,7 @@ if ($op eq "action") { { modified_items => $modified_items, modified_fields => $modified_fields, + extra_headers => $extra_headers, } ); } @@ -772,12 +785,22 @@ sub add_results_to_template { sub add_saved_job_results_to_template { my $template = shift; my $completedJobID = shift; + my $items_display_hashref= shift; my $job = C4::BackgroundJob->fetch($sessionID, $completedJobID); my $results = $job->results(); add_results_to_template($template, $results); my $fields = $job->get("modified_fields"); my $items = $job->get("modified_items"); + my $extra_headers = $job->get("extra_headers"); + + foreach my $header (keys %{$extra_headers}) { + push @{$items_display_hashref->{item_header_loop}}, {header_value => $extra_headers->{$header}->{name}}; + foreach my $row (@{$items_display_hashref->{item_loop}}) { + push @{$row->{item_value}}, {field => $extra_headers->{$header}->{items}->{$row->{itemnumber}}}; + } + } + $template->param( modified_items => $items, modified_fields => $fields, -- 2.39.5