Lines 127-160
if ($op eq "action") {
Link Here
|
127 |
|
127 |
|
128 |
# Once the job is done |
128 |
# Once the job is done |
129 |
if ($completedJobID) { |
129 |
if ($completedJobID) { |
130 |
# If we have a reasonable amount of items, we display them |
130 |
# If we have a reasonable amount of items, we display them |
131 |
my $max_items = $del ? C4::Context->preference("MaxItemsToDisplayForBatchDel") : C4::Context->preference("MaxItemsToDisplayForBatchMod"); |
131 |
my $max_items = $del ? C4::Context->preference("MaxItemsToDisplayForBatchDel") : C4::Context->preference("MaxItemsToDisplayForBatchMod"); |
132 |
if (scalar(@itemnumbers) <= $max_items ){ |
132 |
if (scalar(@itemnumbers) <= $max_items ){ |
133 |
if (scalar(@itemnumbers) <= 1000 ) { |
133 |
if (scalar(@itemnumbers) <= 1000 ) { |
134 |
$items_display_hashref=BuildItemsData(@itemnumbers); |
134 |
$items_display_hashref=BuildItemsData(@itemnumbers); |
|
|
135 |
} else { |
136 |
# Else, we only display the barcode |
137 |
my @simple_items_display = map { |
138 |
my $itemnumber = $_; |
139 |
my $item = Koha::Items->find($itemnumber); |
140 |
{ |
141 |
itemnumber => $itemnumber, |
142 |
barcode => $item ? ( $item->barcode // q{} ) : q{}, |
143 |
biblionumber => $item ? $item->biblio->biblionumber : q{}, |
144 |
}; |
145 |
} @itemnumbers; |
146 |
$template->param("simple_items_display" => \@simple_items_display); |
147 |
} |
135 |
} else { |
148 |
} else { |
136 |
# Else, we only display the barcode |
149 |
$template->param( "too_many_items_display" => scalar(@itemnumbers) ); |
137 |
my @simple_items_display = map { |
150 |
$template->param( "job_completed" => 1 ); |
138 |
my $itemnumber = $_; |
|
|
139 |
my $item = Koha::Items->find($itemnumber); |
140 |
{ |
141 |
itemnumber => $itemnumber, |
142 |
barcode => $item ? ( $item->barcode // q{} ) : q{}, |
143 |
biblionumber => $item ? $item->biblio->biblionumber : q{}, |
144 |
}; |
145 |
} @itemnumbers; |
146 |
$template->param("simple_items_display" => \@simple_items_display); |
147 |
} |
151 |
} |
148 |
} else { |
|
|
149 |
$template->param( "too_many_items_display" => scalar(@itemnumbers) ); |
150 |
$template->param( "job_completed" => 1 ); |
151 |
} |
152 |
|
152 |
|
153 |
# Setting the job as done |
153 |
# Setting the job as done |
154 |
my $job = C4::BackgroundJob->fetch($sessionID, $completedJobID); |
154 |
my $job = C4::BackgroundJob->fetch($sessionID, $completedJobID); |
155 |
|
155 |
|
156 |
# Calling the template |
156 |
# Calling the template |
157 |
add_saved_job_results_to_template($template, $completedJobID); |
157 |
add_saved_job_results_to_template($template, $completedJobID, $items_display_hashref); |
158 |
|
158 |
|
159 |
} else { |
159 |
} else { |
160 |
# While the job is getting done |
160 |
# While the job is getting done |
Lines 186-197
if ($op eq "action") {
Link Here
|
186 |
} |
186 |
} |
187 |
} |
187 |
} |
188 |
|
188 |
|
|
|
189 |
my $yesno = Koha::AuthorisedValues->search({category => 'YES_NO'}); |
190 |
my $ynhash = {}; |
191 |
|
192 |
while(my $yn = $yesno->next) { |
193 |
$ynhash->{'av'.$yn->authorised_value} = $yn->lib; |
194 |
} |
195 |
|
189 |
try { |
196 |
try { |
190 |
my $schema = Koha::Database->new->schema; |
197 |
my $schema = Koha::Database->new->schema; |
191 |
$schema->txn_do( |
198 |
$schema->txn_do( |
192 |
sub { |
199 |
sub { |
193 |
# For each item |
200 |
# For each item |
194 |
my $i = 1; |
201 |
my $i = 1; |
|
|
202 |
my $extra_headers = {}; |
195 |
foreach my $itemnumber (@itemnumbers) { |
203 |
foreach my $itemnumber (@itemnumbers) { |
196 |
$job->progress($i) if $runinbackground; |
204 |
$job->progress($i) if $runinbackground; |
197 |
my $item = Koha::Items->find($itemnumber); |
205 |
my $item = Koha::Items->find($itemnumber); |
Lines 233-241
if ($op eq "action") {
Link Here
|
233 |
} |
241 |
} |
234 |
else { |
242 |
else { |
235 |
my $modified_holds_priority = 0; |
243 |
my $modified_holds_priority = 0; |
236 |
if (defined $exclude_from_local_holds_priority && $item->exclude_from_local_holds_priority != $exclude_from_local_holds_priority) { |
244 |
if (defined $exclude_from_local_holds_priority) { |
237 |
$item->exclude_from_local_holds_priority($exclude_from_local_holds_priority)->store; |
245 |
if($item->exclude_from_local_holds_priority != $exclude_from_local_holds_priority) { |
238 |
$modified_holds_priority = 1; |
246 |
$item->exclude_from_local_holds_priority($exclude_from_local_holds_priority)->store; |
|
|
247 |
$modified_holds_priority = 1; |
248 |
} |
249 |
$extra_headers->{exclude_from_local_holds_priority} = {name => 'Exclude from local holds priority', items => {}} unless defined $extra_headers->{exclude_from_local_holds_priority}; |
250 |
$extra_headers->{exclude_from_local_holds_priority}->{items}->{$item->itemnumber} = $ynhash->{'av'.$item->exclude_from_local_holds_priority}; |
239 |
} |
251 |
} |
240 |
my $modified = 0; |
252 |
my $modified = 0; |
241 |
if ( $values_to_modify || $values_to_blank ) { |
253 |
if ( $values_to_modify || $values_to_blank ) { |
Lines 305-310
if ($op eq "action") {
Link Here
|
305 |
{ |
317 |
{ |
306 |
modified_items => $modified_items, |
318 |
modified_items => $modified_items, |
307 |
modified_fields => $modified_fields, |
319 |
modified_fields => $modified_fields, |
|
|
320 |
extra_headers => $extra_headers, |
308 |
} |
321 |
} |
309 |
); |
322 |
); |
310 |
} |
323 |
} |
Lines 625-631
exit;
Link Here
|
625 |
|
638 |
|
626 |
# ---------------- Functions |
639 |
# ---------------- Functions |
627 |
|
640 |
|
628 |
sub BuildItemsData{ |
641 |
sub BuildItemsData { |
629 |
my @itemnumbers=@_; |
642 |
my @itemnumbers=@_; |
630 |
# now, build existiing item list |
643 |
# now, build existiing item list |
631 |
my %witness; #---- stores the list of subfields used at least once, with the "meaning" of the code |
644 |
my %witness; #---- stores the list of subfields used at least once, with the "meaning" of the code |
Lines 695-710
sub BuildItemsData{
Link Here
|
695 |
$row_data{itemnumber} = $row->{itemnumber}; |
708 |
$row_data{itemnumber} = $row->{itemnumber}; |
696 |
#reporting this_row values |
709 |
#reporting this_row values |
697 |
$row_data{'nomod'} = $row->{'nomod'}; |
710 |
$row_data{'nomod'} = $row->{'nomod'}; |
698 |
$row_data{bibinfo} = $row->{bibinfo}; |
711 |
$row_data{bibinfo} = $row->{bibinfo}; |
699 |
$row_data{author} = $row->{author}; |
712 |
$row_data{author} = $row->{author}; |
700 |
$row_data{title} = $row->{title}; |
713 |
$row_data{title} = $row->{title}; |
701 |
$row_data{isbn} = $row->{isbn}; |
714 |
$row_data{isbn} = $row->{isbn}; |
702 |
$row_data{biblionumber} = $row->{biblionumber}; |
715 |
$row_data{biblionumber} = $row->{biblionumber}; |
703 |
$row_data{holds} = $row->{holds}; |
716 |
$row_data{holds} = $row->{holds}; |
704 |
$row_data{item_holds} = $row->{item_holds}; |
717 |
$row_data{item_holds} = $row->{item_holds}; |
705 |
$row_data{item} = $row->{item}; |
718 |
$row_data{item} = $row->{item}; |
706 |
my $is_on_loan = C4::Circulation::IsItemIssued( $row->{itemnumber} ); |
719 |
my $is_on_loan = C4::Circulation::IsItemIssued( $row->{itemnumber} ); |
707 |
$row_data{onloan} = $is_on_loan ? 1 : 0; |
720 |
$row_data{onloan} = $is_on_loan ? 1 : 0; |
708 |
push(@item_value_loop,\%row_data); |
721 |
push(@item_value_loop,\%row_data); |
709 |
} |
722 |
} |
710 |
my @header_loop=map { { header_value=> $witness{$_}} } @witnesscodessorted; |
723 |
my @header_loop=map { { header_value=> $witness{$_}} } @witnesscodessorted; |
Lines 772-783
sub add_results_to_template {
Link Here
|
772 |
sub add_saved_job_results_to_template { |
785 |
sub add_saved_job_results_to_template { |
773 |
my $template = shift; |
786 |
my $template = shift; |
774 |
my $completedJobID = shift; |
787 |
my $completedJobID = shift; |
|
|
788 |
my $items_display_hashref= shift; |
775 |
my $job = C4::BackgroundJob->fetch($sessionID, $completedJobID); |
789 |
my $job = C4::BackgroundJob->fetch($sessionID, $completedJobID); |
776 |
my $results = $job->results(); |
790 |
my $results = $job->results(); |
777 |
add_results_to_template($template, $results); |
791 |
add_results_to_template($template, $results); |
778 |
|
792 |
|
779 |
my $fields = $job->get("modified_fields"); |
793 |
my $fields = $job->get("modified_fields"); |
780 |
my $items = $job->get("modified_items"); |
794 |
my $items = $job->get("modified_items"); |
|
|
795 |
my $extra_headers = $job->get("extra_headers"); |
796 |
|
797 |
foreach my $header (keys %{$extra_headers}) { |
798 |
push @{$items_display_hashref->{item_header_loop}}, {header_value => $extra_headers->{$header}->{name}}; |
799 |
foreach my $row (@{$items_display_hashref->{item_loop}}) { |
800 |
push @{$row->{item_value}}, {field => $extra_headers->{$header}->{items}->{$row->{itemnumber}}}; |
801 |
} |
802 |
} |
803 |
|
781 |
$template->param( |
804 |
$template->param( |
782 |
modified_items => $items, |
805 |
modified_items => $items, |
783 |
modified_fields => $fields, |
806 |
modified_fields => $fields, |
784 |
- |
|
|