Drink it cold: Terminplanung für Kühlanhänger
This commit is contained in:
commit
ec88c8ebac
55 changed files with 7091 additions and 0 deletions
42
tools/send_reminders.php
Normal file
42
tools/send_reminders.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Täglicher Erinnerungs-Digest per E-Mail.
|
||||
*
|
||||
* Cron-Beispiel (täglich 07:00):
|
||||
* 0 7 * * * /usr/bin/php /pfad/zu/drink-it-cold/tools/send_reminders.php
|
||||
*
|
||||
* Voraussetzung: app.mail_enabled = true und Benutzer mit E-Mail-Adresse,
|
||||
* die mit einem Mitarbeiterkonto verknüpft sind. Die In-App-Erinnerungen
|
||||
* funktionieren unabhängig davon.
|
||||
*/
|
||||
|
||||
require __DIR__ . '/../app/bootstrap.php';
|
||||
|
||||
$lookback = 7;
|
||||
foreach ($argv ?? [] as $arg) {
|
||||
if (preg_match('/^--lookback=(\d+)$/', $arg, $m)) {
|
||||
$lookback = max(1, min(60, (int) $m[1]));
|
||||
}
|
||||
}
|
||||
|
||||
$result = reminder_send_due($lookback);
|
||||
|
||||
if (!$result['enabled']) {
|
||||
fwrite(STDOUT, "E-Mail-Versand ist deaktiviert (app.mail_enabled = false).\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
fwrite(STDOUT, sprintf(
|
||||
"Erinnerungen: %d versendet, %d übersprungen.\n",
|
||||
$result['sent'],
|
||||
$result['skipped']
|
||||
));
|
||||
foreach ($result['details'] as $detail) {
|
||||
fwrite(STDOUT, ' ' . $detail . "\n");
|
||||
}
|
||||
foreach ($result['errors'] as $error) {
|
||||
fwrite(STDERR, ' Fehler: ' . $error . "\n");
|
||||
}
|
||||
exit($result['errors'] ? 1 : 0);
|
||||
Loading…
Add table
Add a link
Reference in a new issue