prepare( "SELECT o.id, o.ad_id, o.amount_crypto, o.amount_fiat, o.status, o.created_at, b.nickname AS buyer_nickname, s.nickname AS seller_nickname, a.currency, a.payment_currency FROM orders o JOIN users b ON o.buyer_id = b.id JOIN users s ON o.seller_id = s.id JOIN ads a ON o.ad_id = a.id WHERE o.buyer_id = :user_id OR o.seller_id = :user_id ORDER BY o.created_at DESC" ); $stmt->bindParam(':user_id', $current_user_id, PDO::PARAM_INT); $stmt->execute(); $orders = $stmt->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { $error = "Database error: " . $e->getMessage(); } // Helper to display status with a nice badge function getStatusBadge($status) { $map = [ 'AWAITING_PAYMENT' => 'bg-warning text-dark', 'AWAITING_SELLER_CONFIRMATION' => 'bg-info text-dark', 'COMPLETED' => 'bg-success', 'CANCELED' => 'bg-secondary', 'DISPUTED' => 'bg-danger', 'PENDING_CONFIRMATION' => 'bg-light text-dark', ]; $class = $map[$status] ?? 'bg-light text-dark'; $status_text = str_replace('_', ' ', $status); return "" . htmlspecialchars($status_text) . ""; } ?>
| Role | Deal With | Amount | Status | Date | Action |
|---|---|---|---|---|---|
| BUYING SELLING |
|
View |