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

(-)a/Koha/Items.pm (+15 lines)
Lines 675-691 sub search { Link Here
675
        if ( $status eq 'lost' ) {
675
        if ( $status eq 'lost' ) {
676
            $self = $self->search( { itemlost => { '!=' => 0 } } );
676
            $self = $self->search( { itemlost => { '!=' => 0 } } );
677
        }
677
        }
678
        if ( $status =~ '^lost-(.*)' ) {
679
            $self = $self->search( { itemlost => $1 } );
680
        }
678
        if ( $status eq 'withdrawn' ) {
681
        if ( $status eq 'withdrawn' ) {
679
            $self = $self->search( { withdrawn => { '!=' => 0 } } );
682
            $self = $self->search( { withdrawn => { '!=' => 0 } } );
680
        }
683
        }
684
        if ( $status =~ '^withdrawn-(.*)' ) {
685
            $self = $self->search( { withdrawn => $1 } );
686
        }
681
        if ( $status eq 'damaged' ) {
687
        if ( $status eq 'damaged' ) {
682
            $self = $self->search( { damaged => { '!=' => 0 } } );
688
            $self = $self->search( { damaged => { '!=' => 0 } } );
683
        }
689
        }
690
        if ( $status =~ '^damaged-(.*)' ) {
691
            $self = $self->search( { damaged => $1 } );
692
        }
684
        if ( $status eq 'not_for_loan' ) {
693
        if ( $status eq 'not_for_loan' ) {
685
            my @item_types_notforloan =
694
            my @item_types_notforloan =
686
                Koha::ItemTypes->search( { notforloan => { '!=' => 0 } } )->get_column('itemtype');
695
                Koha::ItemTypes->search( { notforloan => { '!=' => 0 } } )->get_column('itemtype');
687
            $self = $self->search( [ { notforloan => { '!=' => 0 } }, { 'me.itype' => \@item_types_notforloan } ] );
696
            $self = $self->search( [ { notforloan => { '!=' => 0 } }, { 'me.itype' => \@item_types_notforloan } ] );
688
        }
697
        }
698
        if ( $status =~ '^not_for_loan-(.*)' ) {
699
            my $av_not_for_loan = $1;
700
            my @item_types_notforloan =
701
                Koha::ItemTypes->search( { notforloan => $av_not_for_loan } )->get_column('itemtype');
702
            $self = $self->search( [ { notforloan => $av_not_for_loan }, { 'me.itype' => \@item_types_notforloan } ] );
703
        }
689
        if ( $status eq 'on_hold' ) {
704
        if ( $status eq 'on_hold' ) {
690
            $self = $self->filter_by_has_holds;
705
            $self = $self->filter_by_has_holds;
691
        }
706
        }
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc (-3 / +28 lines)
Lines 218-226 Link Here
218
                });
218
                });
219
        const item_types_notforloan = new Map(all_item_types.map( it => [it.itemtype, it.notforloan] ));
219
        const item_types_notforloan = new Map(all_item_types.map( it => [it.itemtype, it.notforloan] ));
220
220
221
        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")};
222
        const all_statuses = Object.keys(statuses).map(k => {return {_id: k, _str: statuses[k]}});
223
224
        const can_edit_items_from = [% To.json(can_edit_items_from || []) | $raw %];
221
        const can_edit_items_from = [% To.json(can_edit_items_from || []) | $raw %];
225
        const item_type_image_locations = [% To.json(item_type_image_locations) | $raw %];
222
        const item_type_image_locations = [% To.json(item_type_image_locations) | $raw %];
226
        const av_loc = new Map([% To.json(AuthorisedValues.Get('LOC')) | $raw %].map( av => [av.authorised_value, av.lib]));
223
        const av_loc = new Map([% To.json(AuthorisedValues.Get('LOC')) | $raw %].map( av => [av.authorised_value, av.lib]));
Lines 240-245 Link Here
240
            location: new Map([% To.json(AuthorisedValues.GetDescriptionsByKohaField({ kohafield => 'items.location' })) | $raw %].map( av => [av.lib, av.authorised_value])),
237
            location: new Map([% To.json(AuthorisedValues.GetDescriptionsByKohaField({ kohafield => 'items.location' })) | $raw %].map( av => [av.lib, av.authorised_value])),
241
        };
238
        };
242
239
240
        const statuses = {
241
            checked_out: _("Checked out"),
242
            local_use: _("On-site checkout"),
243
            in_transit: _("In transit"),
244
            lost: _("Lost"),
245
            ...Object.fromEntries(
246
                [...av_lost].map(([k, v]) => [`lost-${k}`, `* ${v}`])
247
            ),
248
            withdrawn: _("Withdrawn"),
249
            ...Object.fromEntries(
250
                [...av_withdrawn].map(([k, v]) => [`withdrawn-${k}`, `* ${v}`])
251
            ),
252
            damaged:_("Damaged"),
253
            ...Object.fromEntries(
254
                [...av_damaged].map(([k, v]) => [`damaged-${k}`, `* ${v}`])
255
            ),
256
            not_for_loan: _("Not for loan"),
257
            ...Object.fromEntries(
258
                [...av_not_for_loan].map(([k, v]) => [`not_for_loan-${k}`, `* ${v}`])
259
            ),
260
            on_hold: _("On hold"),
261
            recalled: _("Recalled"),
262
            available: _("Available"),
263
            restricted: _("Restricted"),
264
            in_bundle: _("In bundle"),
265
        };
266
        const all_statuses = Object.keys(statuses).map(k => {return {_id: k, _str: statuses[k]}});
267
243
        let filters_options = {
268
        let filters_options = {
244
            item_types: all_item_types,
269
            item_types: all_item_types,
245
            libraries: all_libraries,
270
            libraries: all_libraries,
(-)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
    is( $withdrawn_items->count,  1, "Filtered to 1 withdrawn item" );
160
    is( $withdrawn_items->count,  1, "Filtered to 1 withdrawn item" );
161
    is( $notforloan_items->count, 1, "Filtered to 1 notforloan item" );
161
    is( $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