Extrahiert die wichtigste DB-/netzwerkfreie Geschäftslogik (Monatsnavigation, Admin-/Aktien-Rollenprüfung, Aktien-GuV-Berechnung, OpenFIGI-/Alpha-Vantage- Antwortauswertung, Eingabevalidierung, CSV-Export, Migrations-Logik) nach html/lib/fscash.php und deckt sie mit 31 PHPUnit-Tests ab. update.sh installiert Composer-Abhängigkeiten bei Bedarf und führt die Tests jetzt vor jedem Deploy aus - bei Fehlschlag wird nichts kopiert oder migriert. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
||
require 'config.php';
|
||
require_once 'lib/fscash.php';
|
||
header('Content-Type: application/json');
|
||
|
||
// JSON-Input einlesen
|
||
$data = json_decode(file_get_contents('php://input'), true);
|
||
$id = $data['id'] ?? null;
|
||
$symbol = $data['symbol'] ?? null;
|
||
|
||
// Input validieren
|
||
if (!fscash_is_valid_symbol_payload($id, $symbol)) {
|
||
echo json_encode([
|
||
'success' => false,
|
||
'message' => 'Ungültige Eingabedaten.'
|
||
]);
|
||
exit;
|
||
}
|
||
|
||
try {
|
||
$stmt = $pdo->prepare("UPDATE aktien SET Symbol = :symbol WHERE id = :id AND user_id = :userid");
|
||
$stmt->execute([
|
||
'symbol' => $symbol,
|
||
'id' => $id,
|
||
'userid' => $_SESSION['user_id']
|
||
]);
|
||
|
||
// Prüfen, ob ein Datensatz tatsächlich aktualisiert wurde
|
||
if ($stmt->rowCount() > 0) {
|
||
echo json_encode([
|
||
'success' => true,
|
||
'symbol' => $symbol,
|
||
'message' => "Symbol erfolgreich gespeichert: $symbol"
|
||
]);
|
||
} else {
|
||
echo json_encode([
|
||
'success' => false,
|
||
'message' => 'Keine Änderung – evtl. ID existiert nicht oder gehört nicht zum Benutzer.'
|
||
]);
|
||
}
|
||
} catch (PDOException $e) {
|
||
echo json_encode([
|
||
'success' => false,
|
||
'message' => 'Datenbankfehler: ' . $e->getMessage()
|
||
]);
|
||
}
|