Add ticket types, move Asiakaspalvelu tab first, hide closed tickets
- Asiakaspalvelu tab moved to first position in navigation - Added ticket type field (Laskutus, Tekniikka, Vika, Muu) with type filter dropdown and type column in ticket list - Type selector in ticket detail view with API endpoint - Closed tickets hidden by default (selectable via "Kaikki tilat") - Käsittelyssä rows highlighted with green background - Type badges with color coding per category Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
34
api.php
34
api.php
@@ -1655,6 +1655,40 @@ switch ($action) {
|
||||
saveTickets($tickets);
|
||||
break;
|
||||
|
||||
case 'ticket_type':
|
||||
requireAuth();
|
||||
if ($method !== 'POST') break;
|
||||
$input = json_decode(file_get_contents('php://input'), true);
|
||||
$id = $input['id'] ?? '';
|
||||
$type = $input['type'] ?? '';
|
||||
$validTypes = ['laskutus', 'tekniikka', 'vika', 'muu'];
|
||||
if (!in_array($type, $validTypes)) {
|
||||
http_response_code(400);
|
||||
echo json_encode(['error' => 'Virheellinen tyyppi']);
|
||||
break;
|
||||
}
|
||||
$tickets = loadTickets();
|
||||
$found = false;
|
||||
foreach ($tickets as &$t) {
|
||||
if ($t['id'] === $id) {
|
||||
$oldType = $t['type'] ?? 'muu';
|
||||
$t['type'] = $type;
|
||||
$t['updated'] = date('Y-m-d H:i:s');
|
||||
$found = true;
|
||||
addLog('ticket_type', $t['id'], $t['subject'], "Tyyppi: {$oldType} → {$type}");
|
||||
echo json_encode($t);
|
||||
break;
|
||||
}
|
||||
}
|
||||
unset($t);
|
||||
if (!$found) {
|
||||
http_response_code(404);
|
||||
echo json_encode(['error' => 'Tikettiä ei löydy']);
|
||||
break;
|
||||
}
|
||||
saveTickets($tickets);
|
||||
break;
|
||||
|
||||
case 'ticket_assign':
|
||||
requireAuth();
|
||||
if ($method !== 'POST') break;
|
||||
|
||||
Reference in New Issue
Block a user