- # Send a check-in slip. # NOTE: borrower may be undef. probably shouldn't try to send messages then.
- my $circulation_alert = 'C4::ItemCirculationAlertPreference';
- my %conditions = (
- branchcode => $branch,
- categorycode => $borrower->{categorycode},
- item_type => $item->{itype},
- notification => 'CHECKIN',
- );
- if ($doreturn && $circulation_alert->is_enabled_for(\%conditions)) {
- SendCirculationAlert({
- type => 'CHECKIN',
- item => $item,
- borrower => $borrower,
- branch => $branch,
- });
- }
-
- logaction("CIRCULATION", "RETURN", $borrowernumber, $item->{'itemnumber'})
- if C4::Context->preference("ReturnLog");
-
+ # Send a check-in slip. # NOTE: borrower may be undef. Do not try to send messages then.
+ if ( $patron ) {
+ my $circulation_alert = 'C4::ItemCirculationAlertPreference';
+ my %conditions = (
+ branchcode => $branch,
+ categorycode => $patron->categorycode,
+ item_type => $item->{itype},
+ notification => 'CHECKIN',
+ );
+ if ($doreturn && $circulation_alert->is_enabled_for(\%conditions)) {
+ SendCirculationAlert({
+ type => 'CHECKIN',
+ item => $item,
+ borrower => $patron->unblessed,
+ branch => $branch,
+ });
+ }
+
+ logaction("CIRCULATION", "RETURN", $borrowernumber, $item->{'itemnumber'})
+ if C4::Context->preference("ReturnLog");
+ }
+