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

(-)a/C4/Items.pm (-8 / +22 lines)
Lines 805-811 sub GetItemsForInventory { Link Here
805
    my ( $parameters ) = @_;
805
    my ( $parameters ) = @_;
806
    my $minlocation  = $parameters->{'minlocation'}  // '';
806
    my $minlocation  = $parameters->{'minlocation'}  // '';
807
    my $maxlocation  = $parameters->{'maxlocation'}  // '';
807
    my $maxlocation  = $parameters->{'maxlocation'}  // '';
808
    my $class_source = $parameters->{'class_source'}  // C4::Context->preference('DefaultClassificationSource');
808
    my $class_source = $parameters->{'class_source'} // C4::Context->preference('DefaultClassificationSource');
809
    my $location     = $parameters->{'location'}     // '';
809
    my $location     = $parameters->{'location'}     // '';
810
    my $itemtype     = $parameters->{'itemtype'}     // '';
810
    my $itemtype     = $parameters->{'itemtype'}     // '';
811
    my $ignoreissued = $parameters->{'ignoreissued'} // '';
811
    my $ignoreissued = $parameters->{'ignoreissued'} // '';
Lines 840-853 sub GetItemsForInventory { Link Here
840
        }
840
        }
841
    }
841
    }
842
842
843
    if ($minlocation) {
843
    if( C4::Context->preference('UseCNSortForInventory') ){
844
        push @where_strings, 'items.cn_sort >= ?';
844
        my $min_cnsort = GetClassSort($class_source,undef,$minlocation);
845
        push @bind_params, $min_cnsort;
845
        my $max_cnsort = GetClassSort($class_source,undef,$maxlocation);
846
    }
846
        if ($minlocation) {
847
            push @where_strings, 'items.cn_sort >= ?';
848
            push @bind_params, $min_cnsort;
849
        }
847
850
848
    if ($maxlocation) {
851
        if ($maxlocation) {
849
        push @where_strings, 'items.cn_sort <= ?';
852
            push @where_strings, 'items.cn_sort <= ?';
850
        push @bind_params, $max_cnsort;
853
            push @bind_params, $max_cnsort;
854
        }
855
    } else {
856
        if ($minlocation) {
857
            push @where_strings, 'items.itemcallnumber >= ?';
858
            push @bind_params, $minlocation;
859
        }
860
861
        if ($maxlocation) {
862
            push @where_strings, 'items.itemcallnumber <= ?';
863
            push @bind_params, $maxlocation;
864
        }
851
    }
865
    }
852
866
853
    if ($datelastseen) {
867
    if ($datelastseen) {
(-)a/installer/data/mysql/atomicupdate/bug19915_add_UseCNSortForInventory_pref.perl (+9 lines)
Line 0 Link Here
1
$DBversion = 'XXX';  # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
    $dbh->do( q{
4
        INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES
5
        ('UseCNSortForInventory','0','','If ON offer choice of Classification source during inventory and convert callnumber ranges when comparing','YesNo')
6
    });
7
    SetVersion( $DBversion );
8
    print "Upgrade to $DBversion done (Bug 19915: Add UseCNSortForInventory system preference)\n";
9
}
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 601-606 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
601
('UseACQFrameworkForBiblioRecords','0','','Use the ACQ framework for the catalog details','YesNo'),
601
('UseACQFrameworkForBiblioRecords','0','','Use the ACQ framework for the catalog details','YesNo'),
602
('UseAuthoritiesForTracings','1','0','Use authority record numbers for subject tracings instead of heading strings.','YesNo'),
602
('UseAuthoritiesForTracings','1','0','Use authority record numbers for subject tracings instead of heading strings.','YesNo'),
603
('UseBranchTransferLimits','0','','If ON, Koha will will use the rules defined in branch_transfer_limits to decide if an item transfer should be allowed.','YesNo'),
603
('UseBranchTransferLimits','0','','If ON, Koha will will use the rules defined in branch_transfer_limits to decide if an item transfer should be allowed.','YesNo'),
604
('UseCNSortForInventory','0','','If ON offer choice of Classification source during inventory and convert callnumber ranges when comparing','YesNo'),
604
('UseControlNumber','0','','If ON, record control number (w subfields) and control number (001) are used for linking of bibliographic records.','YesNo'),
605
('UseControlNumber','0','','If ON, record control number (w subfields) and control number (001) are used for linking of bibliographic records.','YesNo'),
605
('UseCourseReserves','0',NULL,'Enable the course reserves feature.','YesNo'),
606
('UseCourseReserves','0',NULL,'Enable the course reserves feature.','YesNo'),
606
('useDaysMode','Calendar','Calendar|Days|Datedue','Choose the method for calculating due date: select Calendar to use the holidays module, and Days to ignore the holidays module','Choice'),
607
('useDaysMode','Calendar','Calendar|Days|Datedue','Choose the method for calculating due date: select Calendar to use the holidays module, and Days to ignore the holidays module','Choice'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_client.pref (+6 lines)
Lines 167-169 Staff Client: Link Here
167
                  yes: Show
167
                  yes: Show
168
                  no: "Don't show"
168
                  no: "Don't show"
169
            - a search field pulldown for 'Search the catalog' boxes.
169
            - a search field pulldown for 'Search the catalog' boxes.
170
        -
171
            - pref: UseCNSortForInventory
172
              choices:
173
                  yes: Use
174
                  no: "Don't use"
175
            - classification sources to correct sorting for callnumbers during inventory.
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt (-11 / +14 lines)
Lines 81-98 Link Here
81
                <input type="text" name="minlocation" id="minlocation" value="[% minlocation | html %]" /> (items.itemcallnumber)  </li>
81
                <input type="text" name="minlocation" id="minlocation" value="[% minlocation | html %]" /> (items.itemcallnumber)  </li>
82
           <li><label for="maxlocation">...and: </label>
82
           <li><label for="maxlocation">...and: </label>
83
                <input type="text" name="maxlocation" id="maxlocation" value="[% maxlocation | html %]" />
83
                <input type="text" name="maxlocation" id="maxlocation" value="[% maxlocation | html %]" />
84
           <li>
84
           </li>
85
            <label for="class_source">Callnumber classification scheme</label>
85
           [% IF class_sources %]
86
            <select name="class_source">
86
               <li>
87
            [% FOREACH class_source IN class_sources %]
87
                <label for="class_source">Callnumber classification scheme</label>
88
                [% IF class_source.cn_source == pref_class %]
88
                <select name="class_source">
89
                <option value="[% class_source.cn_source | html %]" selected="selected">[% class_source.description | html %] (default)</option>
89
                [% FOREACH class_source IN class_sources %]
90
                [% ELSE %]
90
                    [% IF class_source.cn_source == pref_class %]
91
                <option value="[% class_source.cn_source | html %]">[% class_source.description | html %]</option>
91
                    <option value="[% class_source.cn_source | html %]" selected="selected">[% class_source.description | html %] (default)</option>
92
                    [% ELSE %]
93
                    <option value="[% class_source.cn_source | html %]">[% class_source.description | html %]</option>
94
                    [% END %]
92
                [% END %]
95
                [% END %]
93
            [% END %]
96
                </select>
94
            </select>
97
              </li>
95
          </li>
98
          [% END %]
96
    </ol>
99
    </ol>
97
    </fieldset>
100
    </fieldset>
98
101
(-)a/t/db_dependent/Items/GetItemsForInventory.t (-3 / +34 lines)
Lines 21-26 use Modern::Perl; Link Here
21
use Test::More tests => 2;
21
use Test::More tests => 2;
22
22
23
use t::lib::TestBuilder;
23
use t::lib::TestBuilder;
24
use t::lib::Mocks;
24
25
25
use C4::Context;
26
use C4::Context;
26
use C4::Biblio;
27
use C4::Biblio;
Lines 43-49 subtest 'Verify results with OldWay' => sub { Link Here
43
};
44
};
44
45
45
subtest 'Use cn_sort rather than callnumber to determine correct location' => sub {
46
subtest 'Use cn_sort rather than callnumber to determine correct location' => sub {
46
    plan tests => 1;
47
    plan tests => 3;
47
48
48
    my $builder = t::lib::TestBuilder->new;
49
    my $builder = t::lib::TestBuilder->new;
49
50
Lines 58-64 subtest 'Use cn_sort rather than callnumber to determine correct location' => su Link Here
58
        }
59
        }
59
    });
60
    });
60
61
61
    #Find if we have any items in our test range before we start
62
    t::lib::Mocks::mock_preference('UseCNSortForInventory', '0');
63
    #Find if we have any items in our test range before we start (using callnumber)
64
    my( undef, $pre_nosort_item_count) = GetItemsForInventory({
65
        maxlocation => 'GT100',
66
        minlocation => 'GT90',
67
        class_source => $class_source->{cn_source},
68
    });
69
70
    t::lib::Mocks::mock_preference('UseCNSortForInventory', '1');
71
    #Find if we have any items in our test range before we start (using cn_sort)
62
    my( undef, $pre_item_count) = GetItemsForInventory({
72
    my( undef, $pre_item_count) = GetItemsForInventory({
63
        maxlocation => 'GT100',
73
        maxlocation => 'GT100',
64
        minlocation => 'GT90',
74
        minlocation => 'GT90',
Lines 72-84 subtest 'Use cn_sort rather than callnumber to determine correct location' => su Link Here
72
                cn_sort => GetClassSort($class_source->{cn_source},undef,'GT95'),
82
                cn_sort => GetClassSort($class_source->{cn_source},undef,'GT95'),
73
            }
83
            }
74
    });
84
    });
85
    my $item_1 = $builder->build({
86
            source => 'Item',
87
            value  => {
88
                itemcallnumber => 'GT101',
89
                cn_sort => GetClassSort($class_source->{cn_source},undef,'GT101'),
90
            }
91
    });
75
92
76
    my( undef, $item_count) = GetItemsForInventory({
93
    my( undef, $item_count) = GetItemsForInventory({
77
        maxlocation => 'GT100',
94
        maxlocation => 'GT100',
78
        minlocation => 'GT90',
95
        minlocation => 'GT90',
79
        class_source => $class_source->{cn_source},
96
        class_source => $class_source->{cn_source},
80
    });
97
    });
81
    is($item_count,$pre_item_count + 1,"We should return GT95 as between GT90 and GT100");
98
    is($item_count,$pre_item_count + 1,"We should return GT95 as between GT90 and GT100, but not GT101");
99
100
    t::lib::Mocks::mock_preference('UseCNSortForInventory', '0');
101
    my( undef, $item_nosort_count) = GetItemsForInventory({
102
        maxlocation => 'GT100',
103
        minlocation => 'GT90',
104
        class_source => $class_source->{cn_source},
105
    });
106
    is($item_nosort_count,$pre_nosort_item_count,"We won't return GT95 or 101 as between GT90 and GT100 if using callnumber");
107
    my( undef, $item_nosort_count_1) = GetItemsForInventory({
108
        maxlocation => 'GT90',
109
        minlocation => 'GT100',
110
        class_source => $class_source->{cn_source},
111
    });
112
    is($item_nosort_count_1,$pre_nosort_item_count + 1,"We won't include GT95 but will include GT101 as between GT100 and GT90 if using callnumber");
82
113
83
};
114
};
84
115
(-)a/tools/inventory.pl (-6 / +8 lines)
Lines 116-124 for my $authvfield (@$statuses) { Link Here
116
    }
116
    }
117
}
117
}
118
118
119
my @class_sources = Koha::ClassSources->search({ used => 1 });
119
if( C4::Context->preference('UseCNSortForInventory') ){
120
my $pref_class = C4::Context->preference("DefaultClassificationSource");
120
    my @class_sources = Koha::ClassSources->search({ used => 1 });
121
121
    my $pref_class = C4::Context->preference("DefaultClassificationSource");
122
    $template->param(
123
        class_sources            => \@class_sources,
124
        pref_class               => $pref_class
125
    );
126
}
122
127
123
$template->param(
128
$template->param(
124
    authorised_values        => \@authorised_value_list,
129
    authorised_values        => \@authorised_value_list,
Lines 132-139 $template->param( Link Here
132
    datelastseen             => $datelastseen,
137
    datelastseen             => $datelastseen,
133
    compareinv2barcd         => $compareinv2barcd,
138
    compareinv2barcd         => $compareinv2barcd,
134
    uploadedbarcodesflag     => $uploadbarcodes ? 1 : 0,
139
    uploadedbarcodesflag     => $uploadbarcodes ? 1 : 0,
135
    class_sources            => \@class_sources,
136
    pref_class               => $pref_class
137
);
140
);
138
141
139
# Walk through uploaded barcodes, report errors, mark as seen, check in
142
# Walk through uploaded barcodes, report errors, mark as seen, check in
140
- 

Return to bug 19915