Bug 23010: Add ability to block withdrawning of items with certain statuses
Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl> Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
4e920be91f
commit
b74dbf3d59
18
Koha/Item.pm
18
Koha/Item.pm
|
|
@ -188,6 +188,24 @@ sub store {
|
|||
}
|
||||
}
|
||||
|
||||
my $prevent_withdrawing_of = C4::Context->preference('PreventWithDrawingItemsStatus');
|
||||
my @statuses_to_prevent = defined $prevent_withdrawing_of ? split( ',', $prevent_withdrawing_of ) : ();
|
||||
my $prevent_onloan = grep { $_ eq 'checkedout' } @statuses_to_prevent;
|
||||
my $prevent_intransit = grep { $_ eq 'intransit' } @statuses_to_prevent;
|
||||
|
||||
if ( exists $updated_columns{withdrawn} && $updated_columns{withdrawn} ) {
|
||||
my $transfer = $pre_mod_item->get_transfer;
|
||||
if ( $pre_mod_item->onloan && $prevent_onloan ) {
|
||||
Koha::Exceptions::Item::Transfer::OnLoan->throw( error => "onloan_cannot_withdraw" );
|
||||
return $self->SUPER::store;
|
||||
}
|
||||
|
||||
if ( defined $transfer && $transfer->in_transit && $prevent_intransit ) {
|
||||
Koha::Exceptions::Item::Transfer::InTransit->throw( error => "intransit_cannot_withdraw" );
|
||||
return $self->SUPER::store;
|
||||
}
|
||||
}
|
||||
|
||||
if ( exists $updated_columns{itemcallnumber}
|
||||
or exists $updated_columns{cn_source} )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ use MARC::File::XML;
|
|||
use MIME::Base64 qw( decode_base64url encode_base64url );
|
||||
use Storable qw( freeze thaw );
|
||||
use URI::Escape qw( uri_escape_utf8 );
|
||||
use Try::Tiny qw( catch try );
|
||||
|
||||
our $dbh = C4::Context->dbh;
|
||||
|
||||
|
|
@ -641,7 +642,13 @@ if ( $op eq "cud-additem" ) {
|
|||
if ( $newitemlost && $newitemlost ge '1' && !$olditemlost ) {
|
||||
LostItem( $item->itemnumber, 'additem' );
|
||||
}
|
||||
$item->store;
|
||||
try {
|
||||
$item->store;
|
||||
} catch {
|
||||
if ( ref $_ && $_->can('error') ) {
|
||||
push @errors, $_->error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$nextop = "cud-additem";
|
||||
|
|
|
|||
|
|
@ -88,6 +88,8 @@
|
|||
<h1>Items for [% biblio.title | html %] [% IF ( biblio.author ) %]by [% biblio.author | html %][% END %] (Record #[% biblio.biblionumber | html %])</h1>
|
||||
<a id="newitem_jump" href="#f"><i class="fa fa-arrow-down"></i> Jump to form</a>
|
||||
|
||||
[% IF ( onloan_cannot_withdraw ) %]<div class="alert alert-warning"><strong>Error saving item</strong>: Onloan item cannot be withdrawn.</div>[% END %]
|
||||
[% IF ( intransit_cannot_withdraw ) %]<div class="alert alert-warning"><strong>Error saving item</strong>: In transit item cannot be withdrawn.</div>[% END %]
|
||||
[% IF ( barcode_not_unique ) %]<div class="alert alert-warning"><strong>Error saving item</strong>: Barcode must be unique.</div>[% END %]
|
||||
[% IF ( no_next_barcode ) %]<div class="alert alert-warning"><strong>Error saving items</strong>: Unable to automatically determine values for barcodes. No item has been inserted.</div>[% END %]
|
||||
[% IF ( book_on_loan ) %]<div class="alert alert-warning"><strong>Cannot delete</strong>: item is checked out.</div>[% END %]
|
||||
|
|
|
|||
Loading…
Reference in New Issue