Bug 33608: Add UpdateStats to item->store
Test plan: Run t/db_dependent/Koha/Item.t Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
3f70c17fd8
commit
edc49a55bb
1 changed files with 23 additions and 8 deletions
31
Koha/Item.pm
31
Koha/Item.pm
|
@ -131,6 +131,10 @@ sub store {
|
|||
$self->cn_sort($cn_sort);
|
||||
}
|
||||
|
||||
if( $self->itemlost ) {
|
||||
$self->_add_statistic('item_lost'); # should be quite rare when adding item
|
||||
}
|
||||
|
||||
} else { # ModItem
|
||||
|
||||
$action = 'modify';
|
||||
|
@ -186,15 +190,12 @@ sub store {
|
|||
$self->permanent_location( $self->location );
|
||||
}
|
||||
|
||||
# If item was lost and has now been found,
|
||||
# reverse any list item charges if necessary.
|
||||
if ( exists $updated_columns{itemlost}
|
||||
and $updated_columns{itemlost} <= 0
|
||||
and $pre_mod_item->itemlost > 0 )
|
||||
{
|
||||
$self->_set_found_trigger($pre_mod_item);
|
||||
if( exists $updated_columns{itemlost} && !$updated_columns{itemlost} && $pre_mod_item->itemlost ) { # item found again
|
||||
$self->_set_found_trigger($pre_mod_item); # reverse any list item charges if necessary
|
||||
$self->_add_statistic('item_found');
|
||||
} elsif( exists $updated_columns{itemlost} && $updated_columns{itemlost} && !$pre_mod_item->itemlost ) { # item lost
|
||||
$self->_add_statistic('item_lost');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
my $result = $self->SUPER::store;
|
||||
|
@ -217,6 +218,20 @@ sub store {
|
|||
return $result;
|
||||
}
|
||||
|
||||
sub _add_statistic {
|
||||
my ( $self, $type ) = @_;
|
||||
C4::Stats::UpdateStats({
|
||||
type => $type,
|
||||
branch => C4::Context->userenv ? C4::Context->userenv->{branch} : undef,
|
||||
borrowernumber => undef,
|
||||
categorycode => undef,
|
||||
itemnumber => $self->itemnumber,
|
||||
ccode => $self->ccode,
|
||||
itemtype => $self->effective_itemtype,
|
||||
location => $self->location,
|
||||
});
|
||||
}
|
||||
|
||||
=head3 delete
|
||||
|
||||
=cut
|
||||
|
|
Loading…
Reference in a new issue