<?php
require_once __DIR__ . '/../../engine/engine.php';

$id = isset($_POST['id']) ? (int)$_POST['id'] : null;
$portfolioId = isset($_POST['portfolio_id']) ? (int)$_POST['portfolio_id']
			  : (isset($_POST['pid']) ? (int)$_POST['pid'] : 1);

if (!$id) {
	http_response_code(400);
	echo "ID fehlt.";
	exit;
}

// Nur im angegebenen Depot löschen
$stmt = $pdo->prepare("
	DELETE FROM depot_entries
	WHERE id = :id
	  AND portfolio_id = :pid
");
$stmt->execute([
	':id'  => $id,
	':pid' => $portfolioId
]);

echo 'success';