19 lines
728 B
PHP
19 lines
728 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require __DIR__.'/../public/booking/backend.php';
|
|
|
|
$database = bookingDatabase();
|
|
$result = bookingRunJobs($database);
|
|
$transport = getenv('BOOKING_MAIL_TRANSPORT') ?: 'database';
|
|
if ($transport === 'mail') {
|
|
$outbox = $database->query('SELECT id, recipient_email, subject, body FROM sufw_booking_outbox WHERE sent_at IS NULL ORDER BY id');
|
|
foreach ($outbox as $mail) {
|
|
if (mail($mail['recipient_email'], $mail['subject'], $mail['body'])) {
|
|
$database->prepare('UPDATE sufw_booking_outbox SET sent_at = UTC_TIMESTAMP() WHERE id = :id')->execute(['id' => $mail['id']]);
|
|
}
|
|
}
|
|
}
|
|
echo json_encode($result, JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR).PHP_EOL;
|