Upload via GUI (335 Dateien)
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
require_once __DIR__ . '/common.php';
|
||||
|
||||
/**
|
||||
* Auswertung der Zufriedenheitsabfrage.
|
||||
* GET ?days=30 (1 bis 365) → {enabled, days, stats:{sent,answered,avg,rate,dist,byStaff,recent}}
|
||||
* Mitarbeiter sehen nur die Abteilungen, in denen sie arbeiten.
|
||||
*/
|
||||
api_require_method('GET');
|
||||
$staff = api_require_staff();
|
||||
$pdo = get_db();
|
||||
$days = max(1, min(365, (int) ($_GET['days'] ?? 30)));
|
||||
$from = date('Y-m-d 00:00:00', time() - ($days - 1) * 86400);
|
||||
$to = date('Y-m-d 23:59:59');
|
||||
$stats = null;
|
||||
try {
|
||||
$stats = csat_stats($pdo, $from, $to, staff_department_ids($staff));
|
||||
} catch (Throwable $e) {
|
||||
$stats = ['sent' => 0, 'answered' => 0, 'avg' => null, 'rate' => null, 'dist' => [1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0], 'byStaff' => [], 'recent' => []];
|
||||
}
|
||||
$stats['dist'] = array_map(fn($k, $v) => ['rating' => $k, 'count' => $v], array_keys($stats['dist']), $stats['dist']);
|
||||
api_json(['enabled' => csat_enabled(), 'days' => $days, 'stats' => $stats]);
|
||||
Reference in New Issue
Block a user