- Handler funkce extrahovany z API souboru do api/admin/handlers/ - config.php rozdeleny na helpers.php (funkce) a constants.php (konstanty) - require_once odstranen z class souboru (AuditLog, JWTAuth, LeaveNotification) - vendor/autoload.php presunuto do config.php bootstrap - totp-handlers.php: pridany use deklarace pro TwoFactorAuth - phpstan.neon: bootstrapFiles, scanDirectories, dynamicConstantNames - Opraveny chybejici routing bloky v totp.php a session.php Vysledek: phpcs 0 errors 0 warnings, PHPStan 0 errors, ESLint 0 errors Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
71 lines
2.0 KiB
PHP
71 lines
2.0 KiB
PHP
<?php
|
|
|
|
/**
|
|
* BOHA Automation - Bank Accounts API
|
|
*
|
|
* GET /api/admin/bank-accounts.php - Seznam bankovnich uctu
|
|
* POST /api/admin/bank-accounts.php - Vytvoreni uctu
|
|
* PUT /api/admin/bank-accounts.php?id=X - Uprava uctu
|
|
* DELETE /api/admin/bank-accounts.php?id=X - Smazani uctu
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
require_once dirname(__DIR__) . '/config.php';
|
|
require_once dirname(__DIR__) . '/includes/JWTAuth.php';
|
|
require_once dirname(__DIR__) . '/includes/AuditLog.php';
|
|
require_once __DIR__ . '/handlers/bank-accounts-handlers.php';
|
|
|
|
setCorsHeaders();
|
|
setSecurityHeaders();
|
|
setNoCacheHeaders();
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
|
|
$authData = JWTAuth::requireAuth();
|
|
AuditLog::setUser($authData['user_id'], $authData['user']['username'] ?? 'unknown');
|
|
|
|
$method = $_SERVER['REQUEST_METHOD'];
|
|
$id = isset($_GET['id']) ? (int) $_GET['id'] : null;
|
|
|
|
try {
|
|
$pdo = db();
|
|
|
|
switch ($method) {
|
|
case 'GET':
|
|
requirePermission($authData, 'offers.settings');
|
|
handleGetBankAccountList($pdo);
|
|
break;
|
|
|
|
case 'POST':
|
|
requirePermission($authData, 'offers.settings');
|
|
handleCreateBankAccount($pdo);
|
|
break;
|
|
|
|
case 'PUT':
|
|
requirePermission($authData, 'offers.settings');
|
|
if (!$id) {
|
|
errorResponse('ID účtu je povinné');
|
|
}
|
|
handleUpdateBankAccount($pdo, $id);
|
|
break;
|
|
|
|
case 'DELETE':
|
|
requirePermission($authData, 'offers.settings');
|
|
if (!$id) {
|
|
errorResponse('ID účtu je povinné');
|
|
}
|
|
handleDeleteBankAccount($pdo, $id);
|
|
break;
|
|
|
|
default:
|
|
errorResponse('Metoda není povolena', 405);
|
|
}
|
|
} catch (PDOException $e) {
|
|
error_log('Bank Accounts API error: ' . $e->getMessage());
|
|
if (DEBUG_MODE) {
|
|
errorResponse('Chyba databáze: ' . $e->getMessage(), 500);
|
|
} else {
|
|
errorResponse('Chyba databáze', 500);
|
|
}
|
|
}
|