💰 Twój Portfel
Dostępne środki
📊 Ostatnie transakcje
🔍 Brak transakcji
Tutaj pojawią się Twoje przyszłe transakcje
exec("SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci"); } catch (PDOException $e) { die("Błąd połączenia z bazą danych: " . $e->getMessage()); } // Pobieranie statystyk użytkownika $user_id = $_SESSION['user_id']; $stmt = $pdo->prepare("SELECT * FROM user_stats WHERE user_id = ?"); $stmt->execute([$user_id]); $stats = $stmt->fetch(PDO::FETCH_ASSOC); // Jeśli nie ma statystyk (stary użytkownik), utwórz rekord if (!$stats) { $stmt_create = $pdo->prepare("INSERT INTO user_stats (user_id, balance, matches_played, matches_won, matches_lost, matches_draw, tournaments_played, tournaments_won, leagues_participated, total_income, total_expenses, total_transactions, account_status) VALUES (?, 0.00, 0, 0, 0, 0, 0, 0, 0, 0.00, 0.00, 0, 'active')"); $stmt_create->execute([$user_id]); // Pobierz ponownie $stmt->execute([$user_id]); $stats = $stmt->fetch(PDO::FETCH_ASSOC); } // Formatowanie wartości $balance = number_format($stats['balance'], 2, '.', ''); $total_income = number_format($stats['total_income'], 2, '.', ''); $total_expenses = number_format($stats['total_expenses'], 2, '.', ''); $win_rate = $stats['matches_played'] > 0 ? round(($stats['matches_won'] / $stats['matches_played']) * 100, 1) : 0; // Pobieranie ostatnich 10 transakcji $stmt_transactions = $pdo->prepare("SELECT * FROM transactions WHERE user_id = ? ORDER BY created_at DESC LIMIT 10"); $stmt_transactions->execute([$user_id]); $transactions = $stmt_transactions->fetchAll(PDO::FETCH_ASSOC); // Funkcja do formatowania daty w języku polskim function formatPolishDate($datetime) { $months = [ 1 => 'stycznia', 2 => 'lutego', 3 => 'marca', 4 => 'kwietnia', 5 => 'maja', 6 => 'czerwca', 7 => 'lipca', 8 => 'sierpnia', 9 => 'września', 10 => 'października', 11 => 'listopada', 12 => 'grudnia' ]; $timestamp = strtotime($datetime); $day = date('j', $timestamp); $month = $months[(int)date('n', $timestamp)]; $year = date('Y', $timestamp); $time = date('H:i', $timestamp); return "$day $month $year, $time"; } ?>
🔍 Brak transakcji
Tutaj pojawią się Twoje przyszłe transakcje