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

(-)a/Koha/Item.pm (-1 / +1 lines)
Lines 188-194 sub store { Link Here
188
            }
188
            }
189
        }
189
        }
190
190
191
        my $prevent_withdrawing_of = C4::Context->preference('PreventWithDrawingItemsStatus');
191
        my $prevent_withdrawing_of = C4::Context->preference('PreventWithdrawingItemsStatus');
192
        my @statuses_to_prevent    = defined $prevent_withdrawing_of ? split( ',', $prevent_withdrawing_of ) : ();
192
        my @statuses_to_prevent    = defined $prevent_withdrawing_of ? split( ',', $prevent_withdrawing_of ) : ();
193
        my $prevent_onloan         = grep { $_ eq 'checkedout' } @statuses_to_prevent;
193
        my $prevent_onloan         = grep { $_ eq 'checkedout' } @statuses_to_prevent;
194
        my $prevent_intransit      = grep { $_ eq 'intransit' } @statuses_to_prevent;
194
        my $prevent_intransit      = grep { $_ eq 'intransit' } @statuses_to_prevent;
(-)a/installer/data/mysql/atomicupdate/bug_23010_add_PreventWithdrawingItemsStatus.pl (-3 / +3 lines)
Lines 3-9 use Koha::Installer::Output qw(say_warning say_success say_info); Link Here
3
3
4
return {
4
return {
5
    bug_number  => "23010",
5
    bug_number  => "23010",
6
    description => "Add new PreventWithDrawingItemsStatus system preference",
6
    description => "Add new PreventWithdrawingItemsStatus system preference",
7
    up          => sub {
7
    up          => sub {
8
        my ($args) = @_;
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
Lines 11-20 return { Link Here
11
        $dbh->do(
11
        $dbh->do(
12
            q{
12
            q{
13
            INSERT IGNORE INTO systempreferences (`variable`,`value`,`options`,`explanation`,`type`)
13
            INSERT IGNORE INTO systempreferences (`variable`,`value`,`options`,`explanation`,`type`)
14
            VALUES ('PreventWithDrawingItemsStatus',NULL,'','Prevent the withdrawing of items based on statuses','Choice')
14
            VALUES ('PreventWithdrawingItemsStatus',NULL,'','Prevent the withdrawing of items based on statuses','Choice')
15
        }
15
        }
16
        );
16
        );
17
17
18
        say $out "Added new system preference 'PreventWithDrawingItemsStatus'";
18
        say $out "Added new system preference 'PreventWithdrawingItemsStatus'";
19
    },
19
    },
20
};
20
};
(-)a/t/db_dependent/Koha/Item.t (-4 / +3 lines)
Lines 183-193 subtest '_status' => sub { Link Here
183
    $schema->storage->txn_rollback;
183
    $schema->storage->txn_rollback;
184
};
184
};
185
185
186
subtest 'store PreventWithDrawingItemsStatus' => sub {
186
subtest 'store PreventWithdrawingItemsStatus' => sub {
187
    plan tests => 2;
187
    plan tests => 2;
188
    $schema->storage->txn_begin;
188
    $schema->storage->txn_begin;
189
189
190
    t::lib::Mocks::mock_preference( 'PreventWithDrawingItemsStatus', 'intransit,checkedout' );
190
    t::lib::Mocks::mock_preference( 'PreventWithdrawingItemsStatus', 'intransit,checkedout' );
191
    my $library_1 = $builder->build( { source => 'Branch' } );
191
    my $library_1 = $builder->build( { source => 'Branch' } );
192
    my $library_2 = $builder->build( { source => 'Branch' } );
192
    my $library_2 = $builder->build( { source => 'Branch' } );
193
193
Lines 230-236 subtest 'store PreventWithDrawingItemsStatus' => sub { Link Here
230
    'Koha::Exceptions::Item::Transfer::InTransit',
230
    'Koha::Exceptions::Item::Transfer::InTransit',
231
        'Exception thrown when trying to withdraw item in transit';
231
        'Exception thrown when trying to withdraw item in transit';
232
232
233
    t::lib::Mocks::mock_preference( 'PreventWithDrawingItemsStatus', '' );
233
    t::lib::Mocks::mock_preference( 'PreventWithdrawingItemsStatus', '' );
234
234
235
    $schema->storage->txn_rollback;
235
    $schema->storage->txn_rollback;
236
};
236
};
237
- 

Return to bug 23010