Upload via GUI (278 Dateien)
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
require_once __DIR__ . '/common.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Berührungs-Ping der App: meldet, dass die Person die App gerade benutzt. Dadurch geht sie nach längerer Inaktivität nicht
|
||||||
|
* auf "Offline" und kommt aus dem automatischen Offline zurück (siehe includes/staff_activity.php).
|
||||||
|
* POST {} -> {ok: true, status: "available"|...}
|
||||||
|
*/
|
||||||
|
api_require_method('POST');
|
||||||
|
$staff = api_require_staff();
|
||||||
|
$pdo = get_db();
|
||||||
|
staff_touch_activity($pdo, (int) $staff['id']);
|
||||||
|
$s = $pdo->prepare('SELECT status FROM staff_availability WHERE staff_id = ?');
|
||||||
|
$s->execute([(int) $staff['id']]);
|
||||||
|
api_json(['ok' => true, 'status' => (string) ($s->fetchColumn() ?: 'offline')]);
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
require_once __DIR__ . '/common.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Geräte der Android-App für Push-Benachrichtigungen.
|
||||||
|
* GET -> Status: ob der Server Push senden kann und wie viele Geräte des Mitarbeiters angemeldet sind
|
||||||
|
* POST {action: "register", token, deviceName?, appVersion?} Gerät anmelden (oder Token erneuern)
|
||||||
|
* POST {action: "unregister", token} Gerät abmelden (beim Ausloggen)
|
||||||
|
*/
|
||||||
|
api_require_method('GET', 'POST');
|
||||||
|
$staff = api_require_staff();
|
||||||
|
$pdo = get_db();
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||||
|
$count = $pdo->prepare('SELECT COUNT(*) FROM push_devices WHERE staff_id = ?');
|
||||||
|
$count->execute([(int) $staff['id']]);
|
||||||
|
api_json(['serverConfigured' => fcm_configured(), 'devices' => (int) $count->fetchColumn()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$body = api_request_body();
|
||||||
|
$action = (string) ($body['action'] ?? 'register');
|
||||||
|
$token = trim((string) ($body['token'] ?? ''));
|
||||||
|
if (!fcm_token_valid($token)) api_error(422, 'TOKEN_INVALID', 'Das Geräte-Token ist ungültig.');
|
||||||
|
|
||||||
|
if ($action === 'unregister') {
|
||||||
|
fcm_unregister_device($pdo, (int) $staff['id'], $token);
|
||||||
|
api_json(['registered' => false]);
|
||||||
|
}
|
||||||
|
if ($action !== 'register') api_error(422, 'ACTION_INVALID', 'Unbekannte Aktion.');
|
||||||
|
|
||||||
|
fcm_register_device($pdo, (int) $staff['id'], $token, (string) ($body['deviceName'] ?? ''), (string) ($body['appVersion'] ?? ''));
|
||||||
|
api_json(['registered' => true, 'serverConfigured' => fcm_configured()]);
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
require_once __DIR__ . '/common.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Push-Einstellungen des angemeldeten Mitarbeiters (welche Popups, stille Zeiten).
|
||||||
|
* GET -> {events: [...], eventTypes: [{key, label}], quietFrom, quietTo}
|
||||||
|
* POST {events: [...], quietFrom: "22:00", quietTo: "06:00"} (leere Zeiten = immer Popups)
|
||||||
|
*/
|
||||||
|
api_require_method('GET', 'POST');
|
||||||
|
$staff = api_require_staff();
|
||||||
|
$pdo = get_db();
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
$body = api_request_body();
|
||||||
|
$events = array_map('strval', (array) ($body['events'] ?? []));
|
||||||
|
$from = trim((string) ($body['quietFrom'] ?? ''));
|
||||||
|
$to = trim((string) ($body['quietTo'] ?? ''));
|
||||||
|
if (($from !== '' || $to !== '') && (!fcm_time_valid($from) || !fcm_time_valid($to))) {
|
||||||
|
api_error(422, 'QUIET_HOURS_INVALID', 'Stille Zeiten bitte als Uhrzeit von/bis angeben (z. B. 22:00 und 06:00).');
|
||||||
|
}
|
||||||
|
fcm_save_prefs($pdo, (int) $staff['id'], $events, $from, $to, array_keys(fcm_event_types_for($staff)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nur Arten anzeigen, die für diesen Mitarbeiter (Rechte) in Frage kommen
|
||||||
|
$allowed = fcm_event_types_for($staff);
|
||||||
|
$p = fcm_prefs($pdo, (int) $staff['id']);
|
||||||
|
$types = [];
|
||||||
|
foreach ($allowed as $k => $label) $types[] = ['key' => $k, 'label' => $label];
|
||||||
|
api_json(['events' => array_values(array_intersect($p['events'], array_keys($allowed))), 'eventTypes' => $types, 'quietFrom' => $p['quiet_from'], 'quietTo' => $p['quiet_to']]);
|
||||||
@@ -76,6 +76,7 @@ if (array_key_exists('status', $body) && $body['status'] !== $ticket['status'])
|
|||||||
}
|
}
|
||||||
if (array_key_exists('assignedStaffId', $body)) {
|
if (array_key_exists('assignedStaffId', $body)) {
|
||||||
log_activity($pdo, (int) $ticket['id'], (int) $staff['id'], 'Zuweisung geändert (Mobile App)');
|
log_activity($pdo, (int) $ticket['id'], (int) $staff['id'], 'Zuweisung geändert (Mobile App)');
|
||||||
|
if ($assignedId !== null && $assignedId !== $currentId) fcm_notify_assignment($ticket, $assignedId, (int) $staff['id']); // Push auf die Android-App des neuen Bearbeiters
|
||||||
}
|
}
|
||||||
if ($chatJustClosed && $ticket['requester_email']) {
|
if ($chatJustClosed && $ticket['requester_email']) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user