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

(-)a/C4/Circulation.pm (-2 / +2 lines)
Lines 672-678 sub CanBookBeIssued { Link Here
672
    my $item = GetItem(undef, $barcode );
672
    my $item = GetItem(undef, $barcode );
673
    # MANDATORY CHECKS - unless item exists, nothing else matters
673
    # MANDATORY CHECKS - unless item exists, nothing else matters
674
    unless ( $item && $item->{barcode} ) {
674
    unless ( $item && $item->{barcode} ) {
675
        Koha::Statistics->invalid_item( { item => $barcode } );
675
        Koha::Statistics->log_invalid_item( { item => $barcode } );
676
        $issuingimpossible{UNKNOWN_BARCODE} = 1;
676
        $issuingimpossible{UNKNOWN_BARCODE} = 1;
677
    }
677
    }
678
    return ( \%issuingimpossible, \%needsconfirmation ) if %issuingimpossible;
678
    return ( \%issuingimpossible, \%needsconfirmation ) if %issuingimpossible;
Lines 1806-1812 sub AddReturn { Link Here
1806
    # get information on item
1806
    # get information on item
1807
    my $item = GetItem( undef, $barcode );
1807
    my $item = GetItem( undef, $barcode );
1808
    unless ($item) {
1808
    unless ($item) {
1809
        Koha::Statistics->invalid_item( { item => $barcode } );
1809
        Koha::Statistics->log_invalid_item( { item => $barcode } );
1810
        return ( 0, { BadBarcode => $barcode } );    # no barcode means no item or borrower.  bail out.
1810
        return ( 0, { BadBarcode => $barcode } );    # no barcode means no item or borrower.  bail out.
1811
    }
1811
    }
1812
1812
(-)a/Koha/Statistics.pm (-9 / +9 lines)
Lines 35-47 Koha::Statistics - Koha Statistic Object set class Link Here
35
35
36
=head2 Class Methods
36
=head2 Class Methods
37
37
38
=head3 invalid_patron
38
=head3 log_invalid_patron
39
39
40
Koha::Statistics->invalid_patron( { patron => $cardnumber } );
40
Koha::Statistics->log_invalid_patron( { patron => $cardnumber } );
41
41
42
=cut
42
=cut
43
43
44
sub invalid_patron {
44
sub log_invalid_patron {
45
    return unless C4::Context->preference('LogInvalidPatrons');
45
    return unless C4::Context->preference('LogInvalidPatrons');
46
46
47
    my ( $class, $params ) = @_;
47
    my ( $class, $params ) = @_;
Lines 49-55 sub invalid_patron { Link Here
49
    my $patron = $params->{patron};
49
    my $patron = $params->{patron};
50
    croak('Invalid patron passed in!') unless $patron;
50
    croak('Invalid patron passed in!') unless $patron;
51
51
52
    return $class->_invalid_value(
52
    return $class->_log_invalid_value(
53
        {
53
        {
54
            type  => 'patron',
54
            type  => 'patron',
55
            value => $patron
55
            value => $patron
Lines 57-69 sub invalid_patron { Link Here
57
    );
57
    );
58
}
58
}
59
59
60
=head3 invalid_item
60
=head3 log_invalid_item
61
61
62
Koha::Statistics->invalid_item( { item => $barcode } );
62
Koha::Statistics->log_invalid_item( { item => $barcode } );
63
63
64
=cut
64
=cut
65
65
66
sub invalid_item {
66
sub log_invalid_item {
67
    return unless C4::Context->preference('LogInvalidItems');
67
    return unless C4::Context->preference('LogInvalidItems');
68
68
69
    my ( $class, $params ) = @_;
69
    my ( $class, $params ) = @_;
Lines 71-77 sub invalid_item { Link Here
71
    my $item = $params->{item};
71
    my $item = $params->{item};
72
    croak('Invalid item passed in!') unless $item;
72
    croak('Invalid item passed in!') unless $item;
73
73
74
    return $class->_invalid_value(
74
    return $class->_log_invalid_value(
75
        {
75
        {
76
            type  => 'item',
76
            type  => 'item',
77
            value => $item
77
            value => $item
Lines 85-91 Koha::Statistics->invalid_value( { type => 'patron', value => $patron } ); Link Here
85
85
86
=cut
86
=cut
87
87
88
sub _invalid_value {
88
sub _log_invalid_value {
89
    my ( $class, $params ) = @_;
89
    my ( $class, $params ) = @_;
90
90
91
    my $type  = $params->{type};
91
    my $type  = $params->{type};
(-)a/circ/circulation.pl (-1 / +1 lines)
Lines 267-273 if ($findborrower) { Link Here
267
        } elsif ( @$borrowers ) {
267
        } elsif ( @$borrowers ) {
268
            $template->param( borrowers => $borrowers );
268
            $template->param( borrowers => $borrowers );
269
        } else {
269
        } else {
270
            Koha::Statistics->invalid_patron( { patron => $findborrower } );
270
            Koha::Statistics->log_invalid_patron( { patron => $findborrower } );
271
            $query->param( 'findborrower', '' );
271
            $query->param( 'findborrower', '' );
272
            $message = "'$findborrower'";
272
            $message = "'$findborrower'";
273
        }
273
        }
(-)a/t/db_dependent/Stats.t (-7 / +6 lines)
Lines 184-211 $context->mock( Link Here
184
        };
184
        };
185
    }
185
    }
186
);
186
);
187
# Test Koha::Statistic->invalid_patron
187
# Test Koha::Statistic->log_invalid_patron
188
$dbh->do(q{DELETE FROM statistics});
188
$dbh->do(q{DELETE FROM statistics});
189
t::lib::Mocks::mock_preference( "LogInvalidPatrons", 0 );
189
t::lib::Mocks::mock_preference( "LogInvalidPatrons", 0 );
190
Koha::Statistics->invalid_patron( { patron => 'InvalidCardnumber' } );
190
Koha::Statistics->log_invalid_patron( { patron => 'InvalidCardnumber' } );
191
is( Koha::Statistics->search()->count(), 0, 'No stat line added if system preference LogInvalidPatrons is disabled' );
191
is( Koha::Statistics->search()->count(), 0, 'No stat line added if system preference LogInvalidPatrons is disabled' );
192
192
193
t::lib::Mocks::mock_preference( "LogInvalidPatrons", 1 );
193
t::lib::Mocks::mock_preference( "LogInvalidPatrons", 1 );
194
Koha::Statistics->invalid_patron( { patron => 'InvalidCardnumber' } );
194
Koha::Statistics->log_invalid_patron( { patron => 'InvalidCardnumber' } );
195
my $stat = Koha::Statistics->search()->next();
195
my $stat = Koha::Statistics->search()->next();
196
is( $stat->type, 'invalid_patron', 'Type set to invalid_patron' );
196
is( $stat->type, 'invalid_patron', 'Type set to invalid_patron' );
197
is( $stat->associatedborrower, '-1', 'Associated library id set correctly' );
197
is( $stat->associatedborrower, '-1', 'Associated library id set correctly' );
198
is( $stat->other, 'InvalidCardnumber', 'Invalid cardnumber is set correctly' );
198
is( $stat->other, 'InvalidCardnumber', 'Invalid cardnumber is set correctly' );
199
is( $stat->branch, $branchcode, 'Branchcode is set correctly' );
199
is( $stat->branch, $branchcode, 'Branchcode is set correctly' );
200
200
201
# Test Koha::Statistic->invalid_item
201
# Test Koha::Statistic->log_invalid_item
202
$dbh->do(q{DELETE FROM statistics});
202
$dbh->do(q{DELETE FROM statistics});
203
t::lib::Mocks::mock_preference( "LogInvalidItems", 0 );
203
t::lib::Mocks::mock_preference( "LogInvalidItems", 0 );
204
Koha::Statistics->invalid_item( { item => 'InvalidBarcode' } );
204
Koha::Statistics->log_invalid_item( { item => 'InvalidBarcode' } );
205
is( Koha::Statistics->search()->count(), 0, 'No stat line added if system preference LogInvalidItems is disabled' );
205
is( Koha::Statistics->search()->count(), 0, 'No stat line added if system preference LogInvalidItems is disabled' );
206
206
207
t::lib::Mocks::mock_preference( "LogInvalidItems", 1 );
207
t::lib::Mocks::mock_preference( "LogInvalidItems", 1 );
208
Koha::Statistics->invalid_item( { item => 'InvalidBarcode' } );
208
Koha::Statistics->log_invalid_item( { item => 'InvalidBarcode' } );
209
$stat = Koha::Statistics->search()->next();
209
$stat = Koha::Statistics->search()->next();
210
is( $stat->type, 'invalid_item', 'Type set to invalid_item' );
210
is( $stat->type, 'invalid_item', 'Type set to invalid_item' );
211
is( $stat->associatedborrower, '-1', 'Associated library id set correctly' );
211
is( $stat->associatedborrower, '-1', 'Associated library id set correctly' );
212
- 

Return to bug 16117