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

(-)a/C4/Items.pm (+6 lines)
Lines 533-538 sub GetItemsForInventory { Link Here
533
    my $minlocation  = $parameters->{'minlocation'}  // '';
533
    my $minlocation  = $parameters->{'minlocation'}  // '';
534
    my $maxlocation  = $parameters->{'maxlocation'}  // '';
534
    my $maxlocation  = $parameters->{'maxlocation'}  // '';
535
    my $class_source = $parameters->{'class_source'}  // C4::Context->preference('DefaultClassificationSource');
535
    my $class_source = $parameters->{'class_source'}  // C4::Context->preference('DefaultClassificationSource');
536
    my $items_bundle = $parameters->{'items_bundle'} // '';
536
    my $location     = $parameters->{'location'}     // '';
537
    my $location     = $parameters->{'location'}     // '';
537
    my $itemtype     = $parameters->{'itemtype'}     // '';
538
    my $itemtype     = $parameters->{'itemtype'}     // '';
538
    my $ignoreissued = $parameters->{'ignoreissued'} // '';
539
    my $ignoreissued = $parameters->{'ignoreissued'} // '';
Lines 586-591 sub GetItemsForInventory { Link Here
586
        push @bind_params, $max_cnsort;
587
        push @bind_params, $max_cnsort;
587
    }
588
    }
588
589
590
    if ($items_bundle) {
591
        push @where_strings, 'items.itemnumber IN (SELECT item FROM item_bundles WHERE host = ?)';
592
        push @bind_params, $items_bundle;
593
    }
594
589
    if ($datelastseen) {
595
    if ($datelastseen) {
590
        push @where_strings, '(datelastseen < ? OR datelastseen IS NULL)';
596
        push @where_strings, '(datelastseen < ? OR datelastseen IS NULL)';
591
        push @bind_params, $datelastseen;
597
        push @bind_params, $datelastseen;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt (-1 / +19 lines)
Lines 153-158 Link Here
153
            [% END %]
153
            [% END %]
154
            </select>
154
            </select>
155
          </li>
155
          </li>
156
        [% IF item_bundles.size > 0 %]
157
            <li>
158
                <label for="items_bundle">Items bundle:</label>
159
                <select id="items_bundle" name="items_bundle">
160
                    <option value=""></option>
161
                    [% FOREACH item_bundle IN item_bundles %]
162
                        <option value="[% item_bundle.itemnumber | html %]">[% item_bundle.biblio.title | html %]</option>
163
                    [% END %]
164
                </select>
165
            </li>
166
        [% END %]
156
    </ol>
167
    </ol>
157
    </fieldset>
168
    </fieldset>
158
169
Lines 372-378 Link Here
372
                    $('#locationloop').val() ||
383
                    $('#locationloop').val() ||
373
                    $('#minlocation').val()  ||
384
                    $('#minlocation').val()  ||
374
                    $('#maxlocation').val()  ||
385
                    $('#maxlocation').val()  ||
375
                    $('#statuses input:checked').length
386
                    $('#statuses input:checked').length ||
387
                    $('#items_bundle').val()
376
                ) ) {
388
                ) ) {
377
                    return confirm(
389
                    return confirm(
378
                        _("You have not selected any catalog filters and are about to compare a file of barcodes to your entire catalog.") + "\n\n" +
390
                        _("You have not selected any catalog filters and are about to compare a file of barcodes to your entire catalog.") + "\n\n" +
Lines 512-517 Link Here
512
            });
524
            });
513
        });
525
        });
514
    </script>
526
    </script>
527
    [% INCLUDE 'select2.inc' %]
528
    <script>
529
        $(document).ready(function () {
530
            $('#items_bundle').select2();
531
        });
532
    </script>
515
[% END %]
533
[% END %]
516
534
517
[% INCLUDE 'intranet-bottom.inc' %]
535
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/t/db_dependent/Items/GetItemsForInventory.t (-1 / +22 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 7;
22
use Test::More tests => 8;
23
use t::lib::TestBuilder;
23
use t::lib::TestBuilder;
24
24
25
use List::MoreUtils qw( any none );
25
use List::MoreUtils qw( any none );
Lines 186-188 subtest 'Use cn_sort rather than callnumber to determine correct location' => su Link Here
186
    $schema->storage->txn_rollback;
186
    $schema->storage->txn_rollback;
187
187
188
};
188
};
189
190
subtest 'Search by items bundle' => sub {
191
    $schema->storage->txn_begin;
192
    plan tests => 1;
193
194
    my $builder = t::lib::TestBuilder->new;
195
196
    my $item_bundle = $builder->build_object({ class => 'Koha::Items' });
197
    my $item1 = $builder->build_object({ class => 'Koha::Items' });
198
    my $item2 = $builder->build_object({ class => 'Koha::Items' });
199
200
    $item_bundle->_result->add_to_item_bundles_hosts({ item => $item1->itemnumber });
201
    $item_bundle->_result->add_to_item_bundles_hosts({ item => $item2->itemnumber });
202
203
    my ($items) = C4::Items::GetItemsForInventory({ items_bundle => $item_bundle->itemnumber });
204
205
    my @itemnumbers = sort map { $_->{itemnumber} } @$items;
206
    is_deeply(\@itemnumbers, [$item1->itemnumber, $item2->itemnumber]);
207
208
    $schema->storage->txn_rollback;
209
};
(-)a/tools/inventory.pl (-1 / +17 lines)
Lines 49-54 my $minlocation=$input->param('minlocation') || ''; Link Here
49
my $maxlocation=$input->param('maxlocation');
49
my $maxlocation=$input->param('maxlocation');
50
my $class_source=$input->param('class_source');
50
my $class_source=$input->param('class_source');
51
$maxlocation=$minlocation.'Z' unless ( $maxlocation || ! $minlocation );
51
$maxlocation=$minlocation.'Z' unless ( $maxlocation || ! $minlocation );
52
my $items_bundle = $input->param('items_bundle');
52
my $location=$input->param('location') || '';
53
my $location=$input->param('location') || '';
53
my $ignoreissued=$input->param('ignoreissued');
54
my $ignoreissued=$input->param('ignoreissued');
54
my $ignore_waiting_holds = $input->param('ignore_waiting_holds');
55
my $ignore_waiting_holds = $input->param('ignore_waiting_holds');
Lines 69-74 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
69
    }
70
    }
70
);
71
);
71
72
73
my $schema = Koha::Database->new()->schema();
74
my $item_bundles_rs = Koha::Items->search(
75
    {
76
        'item_bundles_hosts.item' => { '!=' => undef },
77
    },
78
    {
79
        join => 'item_bundles_hosts',
80
        group_by => 'itemnumber',
81
    }
82
);
83
84
my @item_bundles = $item_bundles_rs->as_list;
85
72
my @authorised_value_list;
86
my @authorised_value_list;
73
my $authorisedvalue_categories = '';
87
my $authorisedvalue_categories = '';
74
88
Lines 140-145 foreach my $itemtype ( @itemtypes ) { Link Here
140
154
141
$template->param(
155
$template->param(
142
    authorised_values        => \@authorised_value_list,
156
    authorised_values        => \@authorised_value_list,
157
    item_bundles             => \@item_bundles,
143
    today                    => dt_from_string,
158
    today                    => dt_from_string,
144
    minlocation              => $minlocation,
159
    minlocation              => $minlocation,
145
    maxlocation              => $maxlocation,
160
    maxlocation              => $maxlocation,
Lines 259-264 if ( $op && ( !$uploadbarcodes || $compareinv2barcd )) { Link Here
259
      minlocation  => $minlocation,
274
      minlocation  => $minlocation,
260
      maxlocation  => $maxlocation,
275
      maxlocation  => $maxlocation,
261
      class_source => $class_source,
276
      class_source => $class_source,
277
      items_bundle => $items_bundle,
262
      location     => $location,
278
      location     => $location,
263
      ignoreissued => $ignoreissued,
279
      ignoreissued => $ignoreissued,
264
      datelastseen => $datelastseen,
280
      datelastseen => $datelastseen,
Lines 279-284 if( @scanned_items ) { Link Here
279
      maxlocation  => $maxlocation,
295
      maxlocation  => $maxlocation,
280
      class_source => $class_source,
296
      class_source => $class_source,
281
      location     => $location,
297
      location     => $location,
298
      items_bundle => $items_bundle,
282
      ignoreissued => undef,
299
      ignoreissued => undef,
283
      datelastseen => undef,
300
      datelastseen => undef,
284
      branchcode   => $branchcode,
301
      branchcode   => $branchcode,
285
- 

Return to bug 29099