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

(-)a/C4/Circulation.pm (-1 / +9 lines)
Lines 1398-1403 sub AddIssue { Link Here
1398
               }
1398
               }
1399
            }
1399
            }
1400
1400
1401
            if ( C4::Context->preference('BlankShelvingLocationOnIssue') ) {
1402
            # BlankShelvingLocationInIssue is on, set the value of Shelving location items.location to blank
1403
                BlankShelvingLocation( $item->{itemnumber});
1404
            }
1405
1401
            if ( C4::Context->preference('ReturnToShelvingCart') ) {
1406
            if ( C4::Context->preference('ReturnToShelvingCart') ) {
1402
                # ReturnToShelvingCart is on, anything issued should be taken off the cart.
1407
                # ReturnToShelvingCart is on, anything issued should be taken off the cart.
1403
                CartToShelf( $item->{'itemnumber'} );
1408
                CartToShelf( $item->{'itemnumber'} );
Lines 1859-1865 sub AddReturn { Link Here
1859
        }
1864
        }
1860
    }
1865
    }
1861
1866
1862
    if ( $item->{'location'} eq 'PROC' ) {
1867
    if (C4::Context->preference('BlankShelvingLocationOnReturn')) {
1868
	# BlankShelvingLocationInReturn is on, set the value of Shelving location items.location to blank
1869
        BlankShelvingLocation( $item->{itemnumber});
1870
    } elsif ( $item->{'location'} eq 'PROC' ) {
1863
        if ( C4::Context->preference("InProcessingToShelvingCart") ) {
1871
        if ( C4::Context->preference("InProcessingToShelvingCart") ) {
1864
            $item->{'location'} = 'CART';
1872
            $item->{'location'} = 'CART';
1865
        }
1873
        }
(-)a/C4/Items.pm (-1 / +21 lines)
Lines 85-91 BEGIN { Link Here
85
85
86
        CartToShelf
86
        CartToShelf
87
        ShelfToCart
87
        ShelfToCart
88
88
        BlankShelvingLocation
89
	GetAnalyticsCount
89
	GetAnalyticsCount
90
90
91
        SearchItemsByField
91
        SearchItemsByField
Lines 220-225 sub ShelfToCart { Link Here
220
    ModItem($item, undef, $itemnumber);
220
    ModItem($item, undef, $itemnumber);
221
}
221
}
222
222
223
=head2 BlankShelvingLocation
224
225
   BlankShelvingLocation($itemnumber);
226
227
Set the value of the shelving location to blank when an item is issued or returned.
228
229
This is called by C4::Circulation->AddIssue if the BlankShelvingLocationOnIssue syspref is enabled
230
231
=cut
232
233
sub BlankShelvingLocation {
234
   my ($itemnumber) = @_;
235
   unless ($itemnumber ) {
236
       croak "Failed BlankShelvingLocation() - no itemnumber supplied";
237
   }
238
   my $item = GetItem($itemnumber);
239
   $item->{'location'} ='';
240
   ModItem($item, undef, $itemnumber);
241
}
242
223
=head2 AddItemFromMarc
243
=head2 AddItemFromMarc
224
244
225
  my ($biblionumber, $biblioitemnumber, $itemnumber) 
245
  my ($biblionumber, $biblioitemnumber, $itemnumber) 
(-)a/installer/data/mysql/atomicupdate/blank_shelving_locations_on_circulation.sql (+2 lines)
Line 0 Link Here
1
INSERT INTO systempreferences (variable, value, explanation, type) VALUES ('BlankShelvingLocationOnIssue', 0, 'Blank the 952$c (Shelving Location) field of item when it is issued', 'YesNo');
2
INSERT INTO systempreferences (variable, value, explanation, type) VALUES ('BlankShelvingLocationOnReturn', 0, 'Blank the 952$c (Shelving Location) field of item when it is returned', 'YesNo');
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+12 lines)
Lines 220-225 Circulation: Link Here
220
                  no: "Don't move"
220
                  no: "Don't move"
221
            - all items to the location CART when they are checked in.
221
            - all items to the location CART when they are checked in.
222
        -
222
        -
223
            - pref: BlankShelvingLocationOnIssue
224
              choices:
225
                  yes: Blank
226
                  no: "Don't blank"
227
            - Blank the 952$c (Shelving Location) field of item when it is issued.
228
        -
229
            - pref: BlankShelvingLocationOnReturn
230
              choices:
231
                  yes: Blank
232
                  no: "Don't blank"
233
            - Blank the 952$c (Shelving Location) field of item when it is returned
234
        -
223
            - pref: AutomaticItemReturn
235
            - pref: AutomaticItemReturn
224
              choices:
236
              choices:
225
                  yes: Do
237
                  yes: Do
(-)a/t/db_dependent/Circulation/Returns.t (-1 / +84 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 5;
20
use Test::More tests => 6;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Warn;
22
use Test::Warn;
23
23
Lines 101-106 subtest "InProcessingToShelvingCart tests" => sub { Link Here
101
        "InProcessingToShelvingCart functions as intended" );
101
        "InProcessingToShelvingCart functions as intended" );
102
};
102
};
103
103
104
subtest "BlankShelvingLocationOnReturn tests" => sub {
105
106
    plan tests => 2;
107
108
    $branch = $builder->build({ source => 'Branch' })->{ branchcode };
109
    my $permanent_location = 'TEST';
110
    my $location           = 'PROC';
111
112
    # Create a biblio record with biblio-level itemtype
113
    my $record = MARC::Record->new();
114
    my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, '' );
115
    my $built_item = $builder->build({
116
        source => 'Item',
117
        value  => {
118
            biblionumber  => $biblionumber,
119
            homebranch    => $branch,
120
            holdingbranch => $branch,
121
            location      => $location,
122
            permanent_location => $permanent_location
123
        }
124
    });
125
    my $barcode = $built_item->{ barcode };
126
    my $itemnumber = $built_item->{ itemnumber };
127
    my $item;
128
129
    t::lib::Mocks::mock_preference( "BlankShelvingLocationOnReturn", 1 );
130
    AddReturn( $barcode, $branch );
131
    $item = GetItem( $itemnumber );
132
    is( $item->{location}, '',
133
        "BlankShelvingLocationOnReturn functions as intended" );
134
135
    $item->{location} = $location;
136
    ModItem( $item, undef, $itemnumber );
137
138
    t::lib::Mocks::mock_preference( "BlankShelvingLocationOnReturn", 0 );
139
    AddReturn( $barcode, $branch );
140
    $item = GetItem( $itemnumber );
141
    is( $item->{location}, $permanent_location,
142
        "BlankShelvingLocationOnReturn functions as intended" );
143
};
144
145
subtest "BlankShelvingLocationOnIssue tests" => sub {
146
147
    plan tests => 2;
148
149
    $branch = $builder->build({ source => 'Branch' })->{ branchcode };
150
    my $permanent_location = 'TEST';
151
    my $location           = 'PROC';
152
153
    # Create a biblio record with biblio-level itemtype
154
    my $record = MARC::Record->new();
155
    my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, '' );
156
    my $built_item = $builder->build({
157
        source => 'Item',
158
        value  => {
159
            biblionumber  => $biblionumber,
160
            homebranch    => $branch,
161
            holdingbranch => $branch,
162
            location      => $location,
163
            permanent_location => $permanent_location
164
        }
165
    });
166
    my $barcode = $built_item->{ barcode };
167
    my $itemnumber = $built_item->{ itemnumber };
168
    my $item;
169
170
    t::lib::Mocks::mock_preference( "BlankShelvingLocationOnIssue", 1 );
171
    my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed;
172
    $item = GetItem( $itemnumber );
173
    AddIssue( $borrower, $item->{barcode});
174
    $item = GetItem( $itemnumber );
175
    is( $item->{location}, '',
176
        "BlankShelvingLocationOnIssue functions as intended" );
177
178
    $item->{location} = $location;
179
    ModItem( $item, undef, $itemnumber );
180
181
    t::lib::Mocks::mock_preference( "BlankShelvingLocationOnReturn", 0 );
182
    AddIssue( $borrower, $item->{barcode} );
183
    $item = GetItem( $itemnumber );
184
    is( $item->{location}, $permanent_location,
185
        "BlankShelvingLocationOnReturn functions as intended" );
186
};
104
187
105
subtest "AddReturn logging on statistics table (item-level_itypes=1)" => sub {
188
subtest "AddReturn logging on statistics table (item-level_itypes=1)" => sub {
106
189
(-)a/t/db_dependent/Circulation/issue.t (-1 / +24 lines)
Lines 371-376 AddReturn( 'barcode_3', $branchcode_1 ); Link Here
371
$item = GetItem( $itemnumber );
371
$item = GetItem( $itemnumber );
372
ok( $item->{notforloan} eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 9 with setting "1: 9"} );
372
ok( $item->{notforloan} eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 9 with setting "1: 9"} );
373
373
374
my $itemnumber2;
375
($biblionumber, $biblioitemnumber, $itemnumber2) = C4::Items::AddItem(
376
    {
377
        barcode        => 'barcode_4',
378
        itemcallnumber => 'callnumber4',
379
        homebranch     => $branchcode_1,
380
        holdingbranch  => $branchcode_1,
381
        location       => 'CART',
382
	itype          => $itemtype
383
    },
384
    $biblionumber
385
);
386
387
#Test BlankShelvingLocationOnIssue
388
t::lib::Mocks::Mock_preference('BlankShelvingLocationOnIssue', 0);
389
AddIssue($borrower_1, 'barcode_4', $daysago10, 0, $today, 0);
390
$item2 = GetItem($itemnumber2);
391
ok($item2->{location} eq 'CART', q{BlankShelvingLocationOnIssue does not update shelving location value from 'CART' to '' when not enabled} );
392
393
t::lib::Mocks::mock_preference('BlankShelvingLocationOnIssue', 1);
394
AddIssue($borrower_1, 'barcode_4', $daysago10, 0, $today, '');
395
$item2 = GetItem($itemnumber2);
396
ok($item2->{location} eq '', q{BlankShelvingLocationOnIssue updates shelving location value from 'CART' to '' when enabled} );
397
374
# Bug 14640 - Cancel the hold on checking out if asked
398
# Bug 14640 - Cancel the hold on checking out if asked
375
my $reserve_id = AddReserve($branchcode_1, $borrower_id1, $biblionumber,
399
my $reserve_id = AddReserve($branchcode_1, $borrower_id1, $biblionumber,
376
    undef,  1, undef, undef, "a note", "a title", undef, '');
400
    undef,  1, undef, undef, "a note", "a title", undef, '');
377
- 

Return to bug 21159