View | Details | Raw Unified | Return to bug 23010
Collapse All | Expand All

(-)a/Koha/Item.pm (+18 lines)
Lines 188-193 sub store { Link Here
188
            }
188
            }
189
        }
189
        }
190
190
191
        my $prevent_withdrawing_of = C4::Context->preference('PreventWithDrawingItemsStatus');
192
        my @statuses_to_prevent    = defined $prevent_withdrawing_of ? split( ',', $prevent_withdrawing_of ) : ();
193
        my $prevent_onloan         = grep { $_ eq 'checkedout' } @statuses_to_prevent;
194
        my $prevent_intransit      = grep { $_ eq 'intransit' } @statuses_to_prevent;
195
196
        if ( exists $updated_columns{withdrawn} && $updated_columns{withdrawn} ) {
197
            my $transfer = $pre_mod_item->get_transfer;
198
            if ( $pre_mod_item->onloan && $prevent_onloan ) {
199
                Koha::Exceptions::Item::Transfer::OnLoan->throw( error => "onloan_cannot_withdraw" );
200
                return $self->SUPER::store;
201
            }
202
203
            if ( defined $transfer && $transfer->in_transit && $prevent_intransit ) {
204
                Koha::Exceptions::Item::Transfer::InTransit->throw( error => "intransit_cannot_withdraw" );
205
                return $self->SUPER::store;
206
            }
207
        }
208
191
        if (   exists $updated_columns{itemcallnumber}
209
        if (   exists $updated_columns{itemcallnumber}
192
            or exists $updated_columns{cn_source} )
210
            or exists $updated_columns{cn_source} )
193
        {
211
        {
(-)a/cataloguing/additem.pl (-1 / +8 lines)
Lines 50-55 use MARC::File::XML; Link Here
50
use MIME::Base64 qw( decode_base64url encode_base64url );
50
use MIME::Base64 qw( decode_base64url encode_base64url );
51
use Storable     qw( freeze thaw );
51
use Storable     qw( freeze thaw );
52
use URI::Escape  qw( uri_escape_utf8 );
52
use URI::Escape  qw( uri_escape_utf8 );
53
use Try::Tiny    qw( catch try );
53
54
54
our $dbh = C4::Context->dbh;
55
our $dbh = C4::Context->dbh;
55
56
Lines 644-650 if ( $op eq "cud-additem" ) { Link Here
644
        if ( $newitemlost && $newitemlost ge '1' && !$olditemlost ) {
645
        if ( $newitemlost && $newitemlost ge '1' && !$olditemlost ) {
645
            LostItem( $item->itemnumber, 'additem' );
646
            LostItem( $item->itemnumber, 'additem' );
646
        }
647
        }
647
        $item->store;
648
        try {
649
            $item->store;
650
        } catch {
651
            if ( ref $_ && $_->can('error') ) {
652
                push @errors, $_->error;
653
            }
654
        }
648
    }
655
    }
649
656
650
    $nextop = "cud-additem";
657
    $nextop = "cud-additem";
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt (-1 / +2 lines)
Lines 90-95 Link Here
90
    <h1>Items for [% biblio.title | html %] [% IF ( biblio.author ) %]by [% biblio.author | html %][% END %] (Record #[% biblio.biblionumber | html %])</h1>
90
    <h1>Items for [% biblio.title | html %] [% IF ( biblio.author ) %]by [% biblio.author | html %][% END %] (Record #[% biblio.biblionumber | html %])</h1>
91
    <a id="newitem_jump" href="#additema"><i class="fa fa-arrow-down"></i> Jump to add item form</a>
91
    <a id="newitem_jump" href="#additema"><i class="fa fa-arrow-down"></i> Jump to add item form</a>
92
92
93
    [% IF ( onloan_cannot_withdraw ) %]<div class="alert alert-warning"><strong>Error saving item</strong>: Onloan item cannot be withdrawn.</div>[% END %]
94
    [% IF ( intransit_cannot_withdraw ) %]<div class="alert alert-warning"><strong>Error saving item</strong>: In transit item cannot be withdrawn.</div>[% END %]
93
    [% IF ( barcode_not_unique ) %]<div class="alert alert-warning"><strong>Error saving item</strong>: Barcode must be unique.</div>[% END %]
95
    [% IF ( barcode_not_unique ) %]<div class="alert alert-warning"><strong>Error saving item</strong>: Barcode must be unique.</div>[% END %]
94
    [% 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 %]
96
    [% 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 %]
95
    [% IF ( book_on_loan ) %]<div class="alert alert-warning"><strong>Cannot delete</strong>: item is checked out.</div>[% END %]
97
    [% IF ( book_on_loan ) %]<div class="alert alert-warning"><strong>Cannot delete</strong>: item is checked out.</div>[% END %]
96
- 

Return to bug 23010