id); define("INTERNAL_USER_USERNAME", $me->username); $timerecordingcars = TimerecordingCarModel::getAll(); //var_dump($timerecordingemployees); foreach ($timerecordingcars as $timerecordingcar) { unset ($approval); if ($timerecordingcar->initial_approval) { $initialApproval = date("Y-m-d H:i:s", $timerecordingcar->initial_approval); $initialApprovalMonth = date("m", $timerecordingcar->initial_approval); $firstApproval = strtotime('+' . $timerecordingcar->first_approval . 'years', strtotime($initialApproval)); if ($firstApproval < time()) { $firstApproval = strtotime(date("Y-$initialApprovalMonth-01", time())); if ($firstApproval < time()) { $firstApproval = strtotime(date("Y-$initialApprovalMonth-01", strtotime('+1 year'))); } } $checkDate = date("m/Y", strtotime('+1 month')); $approval = date("m/Y", $firstApproval); if ($checkDate == $approval) { $model = trim($timerecordingcar->brand . " " . $timerecordingcar->model); $message = "§57a Überprüfung des Fahrzeuges " . $timerecordingcar->number_plate . " (" . $model . ") ist im Monat " . $approval . " fällig."; $message .= "\n\nFahrzeuginformationen:"; $message .= "\nKennzeichen: " . $timerecordingcar->number_plate; $message .= "\nMarke/Model: " . $model; if ($timerecordingcar->mileage_now) { $message .= "\nKilometerstand: " . number_format($timerecordingcar->mileage_now, 0, ',', '.') . " KM"; } else { $message .= "\nKilometerstand: -"; } if ($timerecordingcar->user_id) { $message .= "\nFahrzeugverwalter: " . $timerecordingcar->user->name; } else { $message .= "\nFahrzeugverwalter: -"; } $email = new Emailnotification(); $email->setSubject('Fälligkeit §57a Überprüfung im Monat ' . $approval . ' (' . $timerecordingcar->number_plate . ')'); $email->setBody($message); $email->setFrom('notify@xinon.at', 'Xinon Information'); $email->setTo('backoffice@xinon.at'); $email->send(); } } echo "\n"; }