21 lines
974 B
PHP
21 lines
974 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
require_once __DIR__ . '/common.php';
|
|
|
|
api_require_method('POST');
|
|
$staff = api_require_staff();
|
|
$body = api_request_body();
|
|
$number = trim((string) ($body['number'] ?? ''));
|
|
$type = (string) ($body['type'] ?? '');
|
|
$message = (string) ($body['message'] ?? '');
|
|
$setStatus = isset($body['setStatus']) ? (string) $body['setStatus'] : null;
|
|
// Optional: welche Signatur angehängt wird (own = eigene, dept = Abteilung, none = keine); ohne Angabe eigene, ersatzweise Abteilung
|
|
$signatureChoice = isset($body['signature']) && in_array($body['signature'], ['own', 'dept', 'none'], true) ? (string) $body['signature'] : null;
|
|
if ($number === '') {
|
|
api_error(422, 'TICKET_NUMBER_REQUIRED', 'Eine Ticketnummer ist erforderlich.');
|
|
}
|
|
$pdo = get_db();
|
|
$ticket = api_find_ticket($pdo, $staff, $number);
|
|
$threadId = api_add_ticket_message($pdo, $staff, $ticket, $type, $message, $setStatus, $signatureChoice);
|
|
api_json(['threadId' => $threadId], 201);
|