Made it work

This commit is contained in:
Erik Thuning 2022-07-20 10:41:35 +02:00
parent 311402e1b8
commit cd627f811d

@ -77,9 +77,9 @@ class Cron {
$notify_loans[] = $loan; $notify_loans[] = $loan;
} }
} }
$this->send_receipt($user, $loans); $this->send_receipt($user, $notify_loans);
$delete = prepare('delete from `pending_receipt` $delete = prepare('delete from `pending_receipt`
where `user = ? and `send_time` < ?'); where `user` = ? and `send_time` < ?');
bind($delete, 'ii', $user->get_id(), $this->now->getTimestamp()); bind($delete, 'ii', $user->get_id(), $this->now->getTimestamp());
execute($delete); execute($delete);
} }
@ -87,6 +87,9 @@ class Cron {
} }
private function send_receipt($user, $loans) { private function send_receipt($user, $loans) {
$uid = $user->get_name();
$name = $this->ldap->get_firstname($uid);
$count = count($loans); $count = count($loans);
if($count > 1) { if($count > 1) {
$new_sv = "nya lån"; $new_sv = "nya lån";
@ -292,7 +295,7 @@ EOF;
$message, $message,
'From: '.$this->sender); 'From: '.$this->sender);
} catch(Exception $e) { } catch(Exception $e) {
error_log($e->message); error_log($e->getMessage());
mb_send_mail($this->error, mb_send_mail($this->error,
"Kunde inte skicka mail", "Kunde inte skicka mail",
"Mail kunde inte skickas till ".$uid); "Mail kunde inte skickas till ".$uid);