Bug 27893: Optionally skip biblio with open orders in batch delete
If the user unchecks the skip checkbox (on by default), we must make sure that order cancellation is done in background job. Test plan: Pick two biblios. One has linked open orders, the other not. Go to batch delete records. Select 'Enter list of numbers'. Enter both biblio numbers and check that only one is used on the follow-up form. Run the deletion without the skip open orders and verify that linked order line is cancelled. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
82a5b673e1
commit
98a500d120
3 changed files with 26 additions and 3 deletions
|
@ -7,6 +7,7 @@ use C4::Biblio;
|
|||
use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
|
||||
use Koha::SearchEngine;
|
||||
use Koha::SearchEngine::Indexer;
|
||||
use Koha::Acquisition::Orders;
|
||||
|
||||
use base 'Koha::BackgroundJob';
|
||||
|
||||
|
@ -123,6 +124,13 @@ sub process {
|
|||
}
|
||||
}
|
||||
|
||||
# Cancel acq order lines
|
||||
my @result = Koha::Acquisition::Orders->search( { biblionumber => $biblionumber } )->cancel;
|
||||
my $warns = @{ $result[1] };
|
||||
if ( $result[0] && $warns ) { # warnings about order lines not removed
|
||||
warn sprintf( "%d order lines were deleted, but %d lines gave a warning\n", $result[0], $warns );
|
||||
}
|
||||
|
||||
# Finally, delete the biblio
|
||||
my $error = eval {
|
||||
C4::Biblio::DelBiblio( $biblionumber, { skip_record_index => 1, skip_holds_queue => 1 } );
|
||||
|
|
|
@ -89,6 +89,10 @@
|
|||
<ol>
|
||||
<li><label for="biblio_type">Bibliographic: </label><input type="radio" name="recordtype" value="biblio" id="biblio_type" checked="checked" /></li>
|
||||
<li><label for="authority_type">Authorities: </label><input type="radio" name="recordtype" value="authority" id="authority_type" /></li>
|
||||
<li class="skip_open_orders">
|
||||
<input type="checkbox" name="skip_open_orders" checked />
|
||||
<label for="skip_open_orders">Skip biblio records with open acquisition orders</label>
|
||||
</li>
|
||||
</ol>
|
||||
</fieldset>
|
||||
|
||||
|
@ -260,8 +264,10 @@
|
|||
$("input[type='radio']").click(function() {
|
||||
if ($(this).attr('id') == 'authority_type') {
|
||||
$("a[href='#shelves_tab_panel']").parent().hide();
|
||||
$("li.skip_open_orders").hide();
|
||||
} else if ($(this).attr('id') == 'biblio_type') {
|
||||
$("a[href='#shelves_tab_panel']").parent().show();
|
||||
$("li.skip_open_orders").show();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ use C4::Output qw( output_html_with_http_headers );
|
|||
use C4::Auth qw( get_template_and_user );
|
||||
use C4::Biblio;
|
||||
use C4::AuthoritiesMarc;
|
||||
use Koha::Acquisition::Orders;
|
||||
use Koha::Virtualshelves;
|
||||
|
||||
use Koha::Authorities;
|
||||
|
@ -37,9 +38,10 @@ use Koha::Items;
|
|||
use Koha::BackgroundJob::BatchDeleteBiblio;
|
||||
use Koha::BackgroundJob::BatchDeleteAuthority;
|
||||
|
||||
my $input = CGI->new;
|
||||
my $op = $input->param('op') // q|form|;
|
||||
my $recordtype = $input->param('recordtype') // 'biblio';
|
||||
my $input = CGI->new;
|
||||
my $op = $input->param('op') // q|form|;
|
||||
my $recordtype = $input->param('recordtype') // 'biblio';
|
||||
my $skip_open_orders = $input->param('skip_open_orders') // 0;
|
||||
|
||||
my ($template, $loggedinuser, $cookie) = get_template_and_user({
|
||||
template_name => 'tools/batch_delete_records.tt',
|
||||
|
@ -106,6 +108,13 @@ if ( $op eq 'form' ) {
|
|||
$biblio->{holds_count} = $biblio_object->holds->count;
|
||||
$biblio->{issues_count} = C4::Biblio::CountItemsIssued( $record_id );
|
||||
$biblio->{subscriptions_count} = $biblio_object->subscriptions->count;
|
||||
|
||||
# Respect skip_open_orders
|
||||
next
|
||||
if $skip_open_orders
|
||||
&& Koha::Acquisition::Orders->search(
|
||||
{ biblionumber => $record_id, orderstatus => [ 'new', 'ordered', 'partial' ] } )->count;
|
||||
|
||||
push @records, $biblio;
|
||||
} else {
|
||||
# Retrieve authority information
|
||||
|
|
Loading…
Reference in a new issue