prepare("SELECT type, amount, symbol, status, created_at, 'finance' as source, NULL as direction, NULL as pnl FROM transactions WHERE user_id = ? UNION ALL SELECT 'binary' as type, amount, symbol, status, created_at, 'trading' as source, direction, (CASE WHEN status='won' THEN (amount * profit_rate / 100) WHEN status='lost' THEN -amount ELSE 0 END) as pnl FROM binary_orders WHERE user_id = ? UNION ALL SELECT 'contract' as type, amount, symbol, status, created_at, 'trading' as source, direction, profit as pnl FROM contract_orders WHERE user_id = ? ORDER BY created_at DESC LIMIT 100"); $stmt->execute([$user['id'], $user['id'], $user['id']]); $records = $stmt->fetchAll(); } else { if ($tab === 'binary') { $stmt = $db->prepare("SELECT 'binary' as type, amount, symbol, status, created_at, 'trading' as source, direction, (CASE WHEN status='won' THEN (amount * profit_rate / 100) WHEN status='lost' THEN -amount ELSE 0 END) as pnl FROM binary_orders WHERE user_id = ? ORDER BY created_at DESC LIMIT 100"); $stmt->execute([$user['id']]); } elseif ($tab === 'contract') { $stmt = $db->prepare("SELECT 'contract' as type, amount, symbol, status, created_at, 'trading' as source, direction, profit as pnl FROM contract_orders WHERE user_id = ? ORDER BY created_at DESC LIMIT 100"); $stmt->execute([$user['id']]); } elseif ($tab === 'spot') { $stmt = $db->prepare("SELECT 'spot' as type, amount, symbol, status, created_at, 'trading' as source, side as direction, 0 as pnl FROM spot_orders WHERE user_id = ? ORDER BY created_at DESC LIMIT 100"); $stmt->execute([$user['id']]); } else { $stmt = $db->prepare("SELECT *, 'finance' as source, NULL as direction, NULL as pnl FROM transactions WHERE user_id = ? AND type LIKE ? ORDER BY created_at DESC LIMIT 100"); $stmt->execute([$user['id'], $tab . '%']); } $records = $stmt->fetchAll(); } $types_map = [ 'recharge' => ['name' => __('recharge'), 'color' => 'success'], 'withdrawal' => ['name' => __('withdrawal'), 'color' => 'danger'], 'binary' => ['name' => __('sec_contract'), 'color' => 'primary'], 'contract' => ['name' => __('contract'), 'color' => 'warning'], 'spot' => ['name' => __('spot'), 'color' => 'info'], 'binary_win' => ['name' => __('binary_win'), 'color' => 'success'], 'binary_loss' => ['name' => __('binary_loss'), 'color' => 'danger'], ]; ?>
| = __('type') ?> | = __('amount') ?>/= __('direction') ?> | = __('pnl') ?? 'PnL' ?> | = __('status') ?> | = __('time') ?> |
|---|---|---|---|---|
|
= __('no_records_found') ?>
|
||||
|
= $type['name'] ?>
= $r['symbol'] ?>
|
= number_format($r['amount'], 2) ?>
= strtoupper($r['direction']) ?>
|
= $pnl >= 0 ? '+' : '' ?>= number_format($pnl, 2) ?>
--
|
= __('completed') ?> = __($status) ?> = __('pending') ?> | = date('Y-m-d H:i:s', strtotime($r['created_at'])) ?> |