Bugzilla – Attachment 177452 Details for
Bug 23010
If an item is checked out or in transit it should not be able to be marked withdrawn
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23010: Add ability to block withdrawning of items with certain statuses
Bug-23010-Add-ability-to-block-withdrawning-of-ite.patch (text/plain), 4.19 KB, created by
Roman Dolny
on 2025-02-02 17:29:05 UTC
(
hide
)
Description:
Bug 23010: Add ability to block withdrawning of items with certain statuses
Filename:
MIME Type:
Creator:
Roman Dolny
Created:
2025-02-02 17:29:05 UTC
Size:
4.19 KB
patch
obsolete
>From 1b6c72131e94d738f08201238c3d71b8a80b57c2 Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Tue, 28 Jan 2025 23:04:19 +0000 >Subject: [PATCH] Bug 23010: Add ability to block withdrawning of items with > certain statuses > >Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl> >--- > Koha/Item.pm | 18 ++++++++++++++++++ > cataloguing/additem.pl | 10 +++++++++- > .../prog/en/modules/cataloguing/additem.tt | 3 ++- > 3 files changed, 29 insertions(+), 2 deletions(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 07fc6ad5c8..bbef037248 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -187,6 +187,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} ) > { >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index 3d361ec1e6..dc83c51a45 100755 >--- a/cataloguing/additem.pl >+++ b/cataloguing/additem.pl >@@ -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; > >@@ -644,7 +645,14 @@ 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"; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >index a41569fe99..2f9014c2db 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >@@ -74,7 +74,6 @@ > [% END %] > [% END #/ WRAPPER breadcrumbs %] > [% END #/ WRAPPER sub-header.inc %] >- > <div class="main container-fluid"> > <div class="row"> > <div class="col-sm-12"> >@@ -88,6 +87,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="#additema"><i class="fa fa-arrow-down"></i> Jump to add item 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 %] >-- >2.39.5
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 23010
:
176241
|
177299
|
177402
|
177413
|
177434
|
177435
|
177436
|
177437
|
177451
|
177452
|
177453
|
177454
|
177911
|
177912
|
177913
|
177914
|
178808