Files
deskhub/DeskHub-Webseite/cron/send_csat.php
T
2026-10-24 20:14:51 +00:00

26 lines
1.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// Direkter Web-Zugriff wird geblockt (nur CLI oder Einbindung aus dem Backend/Pseudo-Cron).
if (php_sapi_name() !== 'cli' && !defined('DESKHUB_CRON_RUNNER')) { http_response_code(403); exit('Kein Web-Zugriff.'); }
/**
* cron/send_csat.php
*
* Verschickt die Zufriedenheitsabfrage an Kunden, deren Ticket geschlossen oder gelöst wurde (Einstellungen → Allgemein →
* „Zufriedenheitsabfrage“). Pro Ticket gibt es höchstens eine Mail.
*/
require_once __DIR__ . '/../includes/bootstrap.php';
/** @return array{sent:int, log:string[]} */
function run_send_csat(PDO $pdo, bool $verbose = false): array
{
set_setting('cron_send_csat_last_run', db_now());
if (!csat_enabled()) {
return ['sent' => 0, 'log' => ['[' . date('Y-m-d H:i:s') . '] Zufriedenheitsabfrage ist deaktiviert – nichts zu tun.']];
}
$sent = csat_send_due($pdo);
return ['sent' => $sent, 'log' => ['[' . date('Y-m-d H:i:s') . "] Zufriedenheitsabfrage: {$sent} Mail(s) gesendet."]];
}
if (php_sapi_name() === 'cli') {
foreach (run_send_csat(get_db(), true)['log'] as $line) echo $line . "\n";
}