Bugzilla – Attachment 108220 Details for
Bug 19889
LocalHoldsPriority needs exclusions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19889: (follow-up) Fix few minor things
Bug-19889-follow-up-Fix-few-minor-things.patch (text/plain), 13.97 KB, created by
Agustín Moyano
on 2020-08-13 19:42:15 UTC
(
hide
)
Description:
Bug 19889: (follow-up) Fix few minor things
Filename:
MIME Type:
Creator:
Agustín Moyano
Created:
2020-08-13 19:42:15 UTC
Size:
13.97 KB
patch
obsolete
>From 007685a67876cfc4e7f4ed1297b018004173a78a Mon Sep 17 00:00:00 2001 >From: Agustin Moyano <agustinmoyano@theke.io> >Date: Thu, 13 Aug 2020 10:04:32 -0300 >Subject: [PATCH] Bug 19889: (follow-up) Fix few minor things > >--- > 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 | 99 ++++++++++++------- > 7 files changed, 81 insertions(+), 46 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 88d80cd348..ea63c23acf 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 8f39dbfe82..9575d6543f 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 @@ > <th scope="col">Check previous checkout?</th> > [% END %] > <th scope="col">Default privacy</th> >+ <th scope="col">Exclude from local holds priority</th> > <th scope="col">Actions</th> > </tr> > </thead> >@@ -549,6 +550,13 @@ > Forever > [% END %] > </td> >+ <td> >+ [% IF category.exclude_from_local_holds_priority %] >+ Yes >+ [% ELSE %] >+ No >+ [% END %] >+ </td> > <td class="actions"> > <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/categories.pl?op=add_form&categorycode=[% category.categorycode |uri %]"><i class="fa fa-pencil"></i> Edit</a> > <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/categories.pl?op=delete_confirm&categorycode=[% category.categorycode |uri %]"><i class="fa fa-trash"></i> Delete</a> >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 3a93d93ae8..4944408e88 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 %] > <div class="dialog message"> > <i>Exclude from local holds priority</i> updated to >- [% IF updated_exclude_from_local_holds_priority %]<i>Yes</i>[% ELSE %]<i>No</i>[% END %] >+ [% IF updated_exclude_from_local_holds_priority %] >+ <i>Yes</i> >+ [% ELSE %] >+ <i>No</i> >+ [% END %] > </div> > [% 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 cacaf71cc4..c95d042ded 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 >@@ -341,7 +341,7 @@ $(document).ready(function(){ > </ol> > </fieldset> > <fieldset class="rows"> >- <legend>Priority</legend> >+ <legend>Other attributes</legend> > <ol> > <li> > <div class="subfield_line"> >diff --git a/tools/batchMod.pl b/tools/batchMod.pl >index 18214ac2fb..719848f418 100755 >--- a/tools/batchMod.pl >+++ b/tools/batchMod.pl >@@ -127,34 +127,34 @@ if ($op eq "action") { > > # Once the job is done > if ($completedJobID) { >- # If we have a reasonable amount of items, we display them >- 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); >+ # If we have a reasonable amount of items, we display them >+ 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 { >- # 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); >+ $template->param( "too_many_items_display" => scalar(@itemnumbers) ); >+ $template->param( "job_completed" => 1 ); > } >- } 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); >+ # Setting the job as done >+ my $job = C4::BackgroundJob->fetch($sessionID, $completedJobID); > >- # Calling the template >- add_saved_job_results_to_template($template, $completedJobID); >+ # Calling the template >+ 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) { >- $item->exclude_from_local_holds_priority($exclude_from_local_holds_priority)->store; >- $modified_holds_priority = 1; >+ 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, > } > ); > } >@@ -625,7 +638,7 @@ exit; > > # ---------------- Functions > >-sub BuildItemsData{ >+sub BuildItemsData { > my @itemnumbers=@_; > # now, build existiing item list > my %witness; #---- stores the list of subfields used at least once, with the "meaning" of the code >@@ -695,16 +708,16 @@ sub BuildItemsData{ > $row_data{itemnumber} = $row->{itemnumber}; > #reporting this_row values > $row_data{'nomod'} = $row->{'nomod'}; >- $row_data{bibinfo} = $row->{bibinfo}; >- $row_data{author} = $row->{author}; >- $row_data{title} = $row->{title}; >- $row_data{isbn} = $row->{isbn}; >- $row_data{biblionumber} = $row->{biblionumber}; >- $row_data{holds} = $row->{holds}; >- $row_data{item_holds} = $row->{item_holds}; >- $row_data{item} = $row->{item}; >- my $is_on_loan = C4::Circulation::IsItemIssued( $row->{itemnumber} ); >- $row_data{onloan} = $is_on_loan ? 1 : 0; >+ $row_data{bibinfo} = $row->{bibinfo}; >+ $row_data{author} = $row->{author}; >+ $row_data{title} = $row->{title}; >+ $row_data{isbn} = $row->{isbn}; >+ $row_data{biblionumber} = $row->{biblionumber}; >+ $row_data{holds} = $row->{holds}; >+ $row_data{item_holds} = $row->{item_holds}; >+ $row_data{item} = $row->{item}; >+ my $is_on_loan = C4::Circulation::IsItemIssued( $row->{itemnumber} ); >+ $row_data{onloan} = $is_on_loan ? 1 : 0; > push(@item_value_loop,\%row_data); > } > my @header_loop=map { { header_value=> $witness{$_}} } @witnesscodessorted; >@@ -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.25.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 19889
:
105715
|
105716
|
105717
|
105718
|
106435
|
106436
|
106437
|
106438
|
106439
|
106440
|
106441
|
106442
|
107180
|
107187
|
107188
|
107189
|
107190
|
107191
|
107192
|
107193
|
107194
|
107195
|
107196
|
107908
|
107909
|
107910
|
107911
|
107912
|
107913
|
107926
|
107927
|
107928
|
107929
|
107930
|
107931
|
107948
|
108213
|
108214
|
108215
|
108216
|
108217
|
108218
|
108219
|
108220
|
108593
|
108594
|
108595
|
108725
|
108726
|
108728
|
109131
|
109132
|
109285
|
109364
|
109419