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

(-)a/Koha/Item.pm (-9 / +23 lines)
Lines 130-135 sub store { Link Here
130
            $self->cn_sort($cn_sort);
130
            $self->cn_sort($cn_sort);
131
        }
131
        }
132
132
133
        if( $self->itemlost ) {
134
            $self->_add_statistic('item_lost'); # should be quite rare when adding item
135
        }
136
133
    } else { # ModItem
137
    } else { # ModItem
134
138
135
        $action = 'modify';
139
        $action = 'modify';
Lines 185-199 sub store { Link Here
185
            $self->permanent_location( $self->location );
189
            $self->permanent_location( $self->location );
186
        }
190
        }
187
191
188
        # If item was lost and has now been found,
192
        if( exists $updated_columns{itemlost} && !$updated_columns{itemlost} && $pre_mod_item->itemlost ) { # item found again
189
        # reverse any list item charges if necessary.
193
            $self->_set_found_trigger($pre_mod_item); # reverse any list item charges if necessary
190
        if (    exists $updated_columns{itemlost}
194
            $self->_add_statistic('item_found');
191
            and $updated_columns{itemlost} <= 0
195
        } elsif( exists $updated_columns{itemlost} && $updated_columns{itemlost} && !$pre_mod_item->itemlost ) { # item lost
192
            and $pre_mod_item->itemlost > 0 )
196
            $self->_add_statistic('item_lost');
193
        {
194
            $self->_set_found_trigger($pre_mod_item);
195
        }
197
        }
196
197
    }
198
    }
198
199
199
    my $result = $self->SUPER::store;
200
    my $result = $self->SUPER::store;
Lines 216-221 sub store { Link Here
216
    return $result;
217
    return $result;
217
}
218
}
218
219
220
sub _add_statistic {
221
    my ( $self, $type ) = @_;
222
    C4::Stats::UpdateStats({
223
        type           => $type,
224
        branch         => C4::Context->userenv ? C4::Context->userenv->{branch} : undef,
225
        borrowernumber => undef,
226
        categorycode   => undef,
227
        itemnumber     => $self->itemnumber,
228
        ccode          => $self->ccode,
229
        itemtype       => $self->effective_itemtype,
230
        location       => $self->location,
231
    });
232
}
233
219
=head3 delete
234
=head3 delete
220
235
221
=cut
236
=cut
222
- 

Return to bug 33608