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

(-)a/C4/Items.pm (+6 lines)
Lines 527-532 sub GetItemsForInventory { Link Here
527
    my $minlocation  = $parameters->{'minlocation'}  // '';
527
    my $minlocation  = $parameters->{'minlocation'}  // '';
528
    my $maxlocation  = $parameters->{'maxlocation'}  // '';
528
    my $maxlocation  = $parameters->{'maxlocation'}  // '';
529
    my $class_source = $parameters->{'class_source'}  // C4::Context->preference('DefaultClassificationSource');
529
    my $class_source = $parameters->{'class_source'}  // C4::Context->preference('DefaultClassificationSource');
530
    my $items_bundle = $parameters->{'items_bundle'} // '';
530
    my $location     = $parameters->{'location'}     // '';
531
    my $location     = $parameters->{'location'}     // '';
531
    my $itemtype     = $parameters->{'itemtype'}     // '';
532
    my $itemtype     = $parameters->{'itemtype'}     // '';
532
    my $ignoreissued = $parameters->{'ignoreissued'} // '';
533
    my $ignoreissued = $parameters->{'ignoreissued'} // '';
Lines 580-585 sub GetItemsForInventory { Link Here
580
        push @bind_params, $max_cnsort;
581
        push @bind_params, $max_cnsort;
581
    }
582
    }
582
583
584
    if ($items_bundle) {
585
        push @where_strings, 'items.itemnumber IN (SELECT item FROM item_bundles WHERE host = ?)';
586
        push @bind_params, $items_bundle;
587
    }
588
583
    if ($datelastseen) {
589
    if ($datelastseen) {
584
        push @where_strings, '(datelastseen < ? OR datelastseen IS NULL)';
590
        push @where_strings, '(datelastseen < ? OR datelastseen IS NULL)';
585
        push @bind_params, $datelastseen;
591
        push @bind_params, $datelastseen;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt (-1 / +19 lines)
Lines 150-155 Link Here
150
            [% END %]
150
            [% END %]
151
            </select>
151
            </select>
152
          </li>
152
          </li>
153
        [% IF item_bundles.size > 0 %]
154
            <li>
155
                <label for="items_bundle">Items bundle:</label>
156
                <select id="items_bundle" name="items_bundle">
157
                    <option value=""></option>
158
                    [% FOREACH item_bundle IN item_bundles %]
159
                        <option value="[% item_bundle.itemnumber | html %]">[% item_bundle.biblio.title | html %]</option>
160
                    [% END %]
161
                </select>
162
            </li>
163
        [% END %]
153
    </ol>
164
    </ol>
154
    </fieldset>
165
    </fieldset>
155
166
Lines 370-376 Link Here
370
                    $('#locationloop').val() ||
381
                    $('#locationloop').val() ||
371
                    $('#minlocation').val()  ||
382
                    $('#minlocation').val()  ||
372
                    $('#maxlocation').val()  ||
383
                    $('#maxlocation').val()  ||
373
                    $('#statuses input:checked').length
384
                    $('#statuses input:checked').length ||
385
                    $('#items_bundle').val()
374
                ) ) {
386
                ) ) {
375
                    return confirm(
387
                    return confirm(
376
                        _("You have not selected any catalog filters and are about to compare a file of barcodes to your entire catalog.") + "\n\n" +
388
                        _("You have not selected any catalog filters and are about to compare a file of barcodes to your entire catalog.") + "\n\n" +
Lines 510-515 Link Here
510
            });
522
            });
511
        });
523
        });
512
    </script>
524
    </script>
525
    [% INCLUDE 'select2.inc' %]
526
    <script>
527
        $(document).ready(function () {
528
            $('#items_bundle').select2();
529
        });
530
    </script>
513
[% END %]
531
[% END %]
514
532
515
[% INCLUDE 'intranet-bottom.inc' %]
533
[% 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