0) { $where[] = "t.account_id = ?"; $params[] = $accountId; } if ($categoryId > 0) { $where[] = "t.category_id = ?"; $params[] = $categoryId; } $sql = " SELECT t.*, a.account_name, a.account_type, a.card_kind, ra.account_name AS related_account_name, c.name AS category_name FROM transactions t JOIN accounts a ON t.account_id = a.id LEFT JOIN accounts ra ON t.related_account_id = ra.id JOIN categories c ON t.category_id = c.id WHERE " . implode(' AND ', $where) . " ORDER BY t.transaction_date DESC, t.id DESC "; $stmt = $pdo->prepare($sql); $stmt->execute($params); $list = $stmt->fetchAll(); $stmt = $pdo->prepare("SELECT id, account_name FROM accounts WHERE user_id = ? AND is_active = 1 ORDER BY id ASC"); $stmt->execute([$uid]); $accounts = $stmt->fetchAll(); $stmt = $pdo->prepare("SELECT id, category_type, name FROM categories WHERE user_id = ? AND is_active = 1 ORDER BY category_type, sort_order, id"); $stmt->execute([$uid]); $categories = $stmt->fetchAll(); /* 요약 */ $sumIncome = 0; $sumExpense = 0; $sumTransfer = 0; $sumCardPay = 0; foreach ($list as $row) { $amt = (float)$row['amount']; if ($row['transaction_type'] === 'income') $sumIncome += $amt; elseif ($row['transaction_type'] === 'expense') $sumExpense += $amt; elseif ($row['transaction_type'] === 'transfer') $sumTransfer += $amt; elseif ($row['transaction_type'] === 'card_payment') $sumCardPay += $amt; } function tx_label(string $type): string { return match ($type) { 'income' => '수입', 'expense' => '지출', 'transfer' => '이체', 'card_payment' => '카드납부', default => $type }; } require __DIR__ . '/../app/views/header.php'; ?>

거래내역

거래등록
초기화
수입
지출
이체
카드납부
날짜 유형 계좌 관련 카테고리 사용처 금액 부가정보 메모 관리
복사 수정
조회 결과가 없습니다.