#
if ( $borrower->{'category_type'} eq 'X' && ( $item->{barcode} )) {
# stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1 .
- &UpdateStats(C4::Context->userenv->{'branch'},'localuse','','',$item->{'itemnumber'},$item->{'itemtype'},$borrower->{'borrowernumber'}, undef, $item->{'ccode'});
+ &UpdateStats({
+ branch => C4::Context->userenv->{'branch'},
+ type => 'localuse',
+ itemnumber => $item->{'itemnumber'},
+ itemtype => $item->{'itemtype'},
+ borrowernumber => $borrower->{'borrowernumber'},
+ ccode => $item->{'ccode'}}
+ );
ModDateLastSeen( $item->{'itemnumber'} );
return( { STATS => 1 }, {});
}
}
# Record the fact that this book was issued.
- &UpdateStats(
- C4::Context->userenv->{'branch'},
- 'issue', $charge,
- ($sipmode ? "SIP-$sipmode" : ''), $item->{'itemnumber'},
- $item->{'itype'}, $borrower->{'borrowernumber'}, undef, $item->{'ccode'}
+ &UpdateStats({
+ branch => C4::Context->userenv->{'branch'},
+ type => 'issue',
+ amount => $charge,
+ other => ($sipmode ? "SIP-$sipmode" : ''),
+ itemnumber => $item->{'itemnumber'},
+ itemtype => $item->{'itype'},
+ borrowernumber => $borrower->{'borrowernumber'},
+ ccode => $item->{'ccode'}}
);
# Send a checkout slip.
my $biblio;
my $doreturn = 1;
my $validTransfert = 0;
- my $stat_type = 'return';
+ my $stat_type = 'return';
# get information on item
my $itemnumber = GetItemnumberFromBarcode( $barcode );
my $borrowernumber = $borrower->{'borrowernumber'} || undef; # we don't know if we had a borrower or not
+ my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckin');
+ if ($yaml) {
+ $yaml = "$yaml\n\n"; # YAML is anal on ending \n. Surplus does not hurt
+ my $rules;
+ eval { $rules = YAML::Load($yaml); };
+ if ($@) {
+ warn "Unable to parse UpdateNotForLoanStatusOnCheckin syspref : $@";
+ }
+ else {
+ foreach my $key ( keys %$rules ) {
+ if ( $item->{notforloan} eq $key ) {
+ $messages->{'NotForLoanStatusUpdated'} = { from => $item->{notforloan}, to => $rules->{$key} };
+ ModItem( { notforloan => $rules->{$key} }, undef, $itemnumber );
+ last;
+ }
+ }
+ }
+ }
+
+
# check if the book is in a permanent collection....
# FIXME -- This 'PE' attribute is largely undocumented. afaict, there's no user interface that reflects this functionality.
if ( $hbr ) {
# case of a return of document (deal with issues and holdingbranch)
my $today = DateTime->now( time_zone => C4::Context->tz() );
+
if ($doreturn) {
my $datedue = $issue->{date_due};
$borrower or warn "AddReturn without current borrower";
$messages->{'ResFound'} = $resrec;
}
- # update stats?
# Record the fact that this book was returned.
- UpdateStats(
- $branch, $stat_type, '0', '',
- $item->{'itemnumber'},
- $biblio->{'itemtype'},
- $borrowernumber, undef, $item->{'ccode'}
+ # FIXME itemtype should record item level type, not bibliolevel type
+ UpdateStats({
+ branch => $branch,
+ type => $stat_type,
+ itemnumber => $item->{'itemnumber'},
+ itemtype => $biblio->{'itemtype'},
+ borrowernumber => $borrowernumber,
+ ccode => $item->{'ccode'}}
);
# Send a check-in slip. # NOTE: borrower may be undef. probably shouldn't try to send messages then.
# grace period is measured in the same units as the loan
my $grace =
DateTime::Duration->new( $unit => $issuingrule->{firstremind} );
+
if ( $deltadays->subtract($grace)->is_positive() ) {
+ my $suspension_days = $deltadays * $finedays;
+
+ # If the max suspension days is < than the suspension days
+ # the suspension days is limited to this maximum period.
+ my $max_sd = $issuingrule->{maxsuspensiondays};
+ if ( defined $max_sd ) {
+ $max_sd = DateTime::Duration->new( days => $max_sd );
+ $suspension_days = $max_sd
+ if DateTime::Duration->compare( $max_sd, $suspension_days ) < 0;
+ }
my $new_debar_dt =
- $dt_today->clone()->add_duration( $deltadays * $finedays );
+ $dt_today->clone()->add_duration( $suspension_days );
Koha::Borrower::Debarments::AddUniqueDebarment({
borrowernumber => $borrower->{borrowernumber},
}
# Log the renewal
- UpdateStats( $branch, 'renew', $charge, '', $itemnumber, $item->{itype}, $borrowernumber, undef, $item->{'ccode'});
+ UpdateStats({branch => $branch,
+ type => 'renew',
+ amount => $charge,
+ itemnumber => $itemnumber,
+ itemtype => $item->{itype},
+ borrowernumber => $borrowernumber,
+ ccode => $item->{'ccode'}}
+ );
return $datedue;
}