Bugzilla – Attachment 177912 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.01 KB, created by
Jonathan Druart
on 2025-02-12 14:02:18 UTC
(
hide
)
Description:
Bug 23010: Add ability to block withdrawning of items with certain statuses
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2025-02-12 14:02:18 UTC
Size:
4.01 KB
patch
obsolete
>From 16ac60111166d34e02402873d6db74651eb623a9 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 | 9 ++++++++- > .../prog/en/modules/cataloguing/additem.tt | 2 ++ > 3 files changed, 28 insertions(+), 1 deletion(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index e9501183363..833bb2cebe9 100644 >--- a/Koha/Item.pm >+++ b/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} ) > { >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index 3d361ec1e63..97d9eabe415 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,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"; >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 72ec98529ea..ea9dcd80791 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >@@ -90,6 +90,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.34.1
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
|
181322
|
181323
|
181324
|
181325
|
181326
|
181327
|
181400
|
182124
|
182129
|
182130
|
182131