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

(-)a/Koha/Items.pm (+15 lines)
Lines 671-687 sub search { Link Here
671
        if ( $status eq 'lost' ) {
671
        if ( $status eq 'lost' ) {
672
            $self = $self->search( { itemlost => { '!=' => 0 } } );
672
            $self = $self->search( { itemlost => { '!=' => 0 } } );
673
        }
673
        }
674
        if ( $status =~ '^lost-(.*)' ) {
675
            $self = $self->search( { itemlost => $1 } );
676
        }
674
        if ( $status eq 'withdrawn' ) {
677
        if ( $status eq 'withdrawn' ) {
675
            $self = $self->search( { withdrawn => { '!=' => 0 } } );
678
            $self = $self->search( { withdrawn => { '!=' => 0 } } );
676
        }
679
        }
680
        if ( $status =~ '^withdrawn-(.*)' ) {
681
            $self = $self->search( { withdrawn => $1 } );
682
        }
677
        if ( $status eq 'damaged' ) {
683
        if ( $status eq 'damaged' ) {
678
            $self = $self->search( { damaged => { '!=' => 0 } } );
684
            $self = $self->search( { damaged => { '!=' => 0 } } );
679
        }
685
        }
686
        if ( $status =~ '^damaged-(.*)' ) {
687
            $self = $self->search( { damaged => $1 } );
688
        }
680
        if ( $status eq 'not_for_loan' ) {
689
        if ( $status eq 'not_for_loan' ) {
681
            my @item_types_notforloan =
690
            my @item_types_notforloan =
682
                Koha::ItemTypes->search( { notforloan => { '!=' => 0 } } )->get_column('itemtype');
691
                Koha::ItemTypes->search( { notforloan => { '!=' => 0 } } )->get_column('itemtype');
683
            $self = $self->search( [ { notforloan => { '!=' => 0 } }, { 'me.itype' => \@item_types_notforloan } ] );
692
            $self = $self->search( [ { notforloan => { '!=' => 0 } }, { 'me.itype' => \@item_types_notforloan } ] );
684
        }
693
        }
694
        if ( $status =~ '^not_for_loan-(.*)' ) {
695
            my $av_not_for_loan = $1;
696
            my @item_types_notforloan =
697
                Koha::ItemTypes->search( { notforloan => $av_not_for_loan } )->get_column('itemtype');
698
            $self = $self->search( [ { notforloan => $av_not_for_loan }, { 'me.itype' => \@item_types_notforloan } ] );
699
        }
685
        if ( $status eq 'on_hold' ) {
700
        if ( $status eq 'on_hold' ) {
686
            $self = $self->filter_by_has_holds;
701
            $self = $self->filter_by_has_holds;
687
        }
702
        }
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc (-3 / +28 lines)
Lines 220-228 Link Here
220
                });
220
                });
221
        const item_types_notforloan = new Map(all_item_types.map( it => [it.itemtype, it.notforloan] ));
221
        const item_types_notforloan = new Map(all_item_types.map( it => [it.itemtype, it.notforloan] ));
222
222
223
        const statuses = {checked_out: _("Checked out"), local_use: _("On-site checkout"), in_transit: _("In transit"), lost: _("Lost"), withdrawn: _("Withdrawn"), damaged:_("Damaged"), not_for_loan: _("Not for loan"), on_hold: _("On hold"), recalled: _("Recalled"), available: _("Available"), restricted: _("Restricted"), in_bundle: _("In bundle")};
224
        const all_statuses = Object.keys(statuses).map(k => {return {_id: k, _str: statuses[k]}});
225
226
        const can_edit_items_from = [% To.json(can_edit_items_from || []) | $raw %];
223
        const can_edit_items_from = [% To.json(can_edit_items_from || []) | $raw %];
227
        const item_type_image_locations = [% To.json(item_type_image_locations) | $raw %];
224
        const item_type_image_locations = [% To.json(item_type_image_locations) | $raw %];
228
        const av_loc = new Map([% To.json(AuthorisedValues.Get('LOC')) | $raw %].map( av => [av.authorised_value, av.lib]));
225
        const av_loc = new Map([% To.json(AuthorisedValues.Get('LOC')) | $raw %].map( av => [av.authorised_value, av.lib]));
Lines 242-247 Link Here
242
            location: new Map([% To.json(AuthorisedValues.GetDescriptionsByKohaField({ kohafield => 'items.location' })) | $raw %].map( av => [av.lib, av.authorised_value])),
239
            location: new Map([% To.json(AuthorisedValues.GetDescriptionsByKohaField({ kohafield => 'items.location' })) | $raw %].map( av => [av.lib, av.authorised_value])),
243
        };
240
        };
244
241
242
        const statuses = {
243
            checked_out: _("Checked out"),
244
            local_use: _("On-site checkout"),
245
            in_transit: _("In transit"),
246
            lost: _("Lost"),
247
            ...Object.fromEntries(
248
                [...av_lost].map(([k, v]) => [`lost-${k}`, `* ${v}`])
249
            ),
250
            withdrawn: _("Withdrawn"),
251
            ...Object.fromEntries(
252
                [...av_withdrawn].map(([k, v]) => [`withdrawn-${k}`, `* ${v}`])
253
            ),
254
            damaged:_("Damaged"),
255
            ...Object.fromEntries(
256
                [...av_damaged].map(([k, v]) => [`damaged-${k}`, `* ${v}`])
257
            ),
258
            not_for_loan: _("Not for loan"),
259
            ...Object.fromEntries(
260
                [...av_not_for_loan].map(([k, v]) => [`not_for_loan-${k}`, `* ${v}`])
261
            ),
262
            on_hold: _("On hold"),
263
            recalled: _("Recalled"),
264
            available: _("Available"),
265
            restricted: _("Restricted"),
266
            in_bundle: _("In bundle"),
267
        };
268
        const all_statuses = Object.keys(statuses).map(k => {return {_id: k, _str: statuses[k]}});
269
245
        [% IF Koha.Preference('URLLinkText') %]
270
        [% IF Koha.Preference('URLLinkText') %]
246
            const url_link_text = "[% Koha.Preference('URLLinkText') | html %]";
271
            const url_link_text = "[% Koha.Preference('URLLinkText') | html %]";
247
        [% ELSE %]
272
        [% ELSE %]
(-)a/t/db_dependent/Koha/Items.t (-2 / +70 lines)
Lines 75-81 is( $retrieved_item_1->barcode, $new_item_1->barcode, 'Find a item by id should Link Here
75
75
76
subtest 'search' => sub {
76
subtest 'search' => sub {
77
77
78
    plan tests => 9;
78
    plan tests => 15;
79
    $schema->storage->txn_begin;
79
    $schema->storage->txn_begin;
80
80
81
    my $patron   = $builder->build_object( { class => 'Koha::Patrons' } );
81
    my $patron   = $builder->build_object( { class => 'Koha::Patrons' } );
Lines 160-165 subtest 'search' => sub { Link Here
160
    ok( $withdrawn_items->count == 1,  "Filtered to 1 withdrawn item" );
160
    ok( $withdrawn_items->count == 1,  "Filtered to 1 withdrawn item" );
161
    ok( $notforloan_items->count == 1, "Filtered to 1 notforloan item" );
161
    ok( $notforloan_items->count == 1, "Filtered to 1 notforloan item" );
162
162
163
    $item_6->notforloan(-1)->store;
164
    is_deeply(
165
        [
166
            Koha::Items->search(
167
                {
168
                    _status      => 'not_for_loan',
169
                    biblionumber => $biblio->biblionumber,
170
                }
171
            )->get_column('itemnumber')
172
        ],
173
        [ $item_6->itemnumber ]
174
    );
175
    is_deeply(
176
        [
177
            Koha::Items->search(
178
                {
179
                    _status      => 'not_for_loan-1',
180
                    biblionumber => $biblio->biblionumber,
181
                }
182
            )->get_column('itemnumber')
183
        ],
184
        []
185
    );
186
    is_deeply(
187
        [
188
            Koha::Items->search(
189
                {
190
                    _status      => 'not_for_loan--1',
191
                    biblionumber => $biblio->biblionumber,
192
                }
193
            )->get_column('itemnumber')
194
        ],
195
        [ $item_6->itemnumber ]
196
    );
197
    $item_6->notforloan(2)->store;
198
    is_deeply(
199
        [
200
            Koha::Items->search(
201
                {
202
                    _status      => 'not_for_loan',
203
                    biblionumber => $biblio->biblionumber,
204
                }
205
            )->get_column('itemnumber')
206
        ],
207
        [ $item_6->itemnumber ]
208
    );
209
    is_deeply(
210
        [
211
            Koha::Items->search(
212
                {
213
                    _status      => 'not_for_loan-1',
214
                    biblionumber => $biblio->biblionumber,
215
                }
216
            )->get_column('itemnumber')
217
        ],
218
        []
219
    );
220
    is_deeply(
221
        [
222
            Koha::Items->search(
223
                {
224
                    _status      => 'not_for_loan-2',
225
                    biblionumber => $biblio->biblionumber,
226
                }
227
            )->get_column('itemnumber')
228
        ],
229
        [ $item_6->itemnumber ]
230
    );
231
163
    C4::Circulation::AddIssue( $patron, $item_1->barcode );
232
    C4::Circulation::AddIssue( $patron, $item_1->barcode );
164
233
165
    my $checked_out_items = Koha::Items->search(
234
    my $checked_out_items = Koha::Items->search(
166
- 

Return to bug 41254