prepare(" SELECT * FROM loans WHERE id = ? AND user_id = ? "); $stmt->execute([$id, $uid]); $loan = $stmt->fetch(); if (!$loan) { exit('대출 정보를 찾을 수 없습니다.'); } $stmt = $pdo->prepare(" SELECT * FROM accounts WHERE user_id = ? AND is_active = 1 AND account_type IN ('bank','cash','other') ORDER BY id ASC "); $stmt->execute([$uid]); $accounts = $stmt->fetchAll(); if ($_SERVER['REQUEST_METHOD'] === 'POST') { try { $accountId = !empty($_POST['account_id']) ? (int)$_POST['account_id'] : null; $paymentDate = $_POST['payment_date'] ?? date('Y-m-d'); $principalAmount = (float)($_POST['principal_amount'] ?? 0); $interestAmount = (float)($_POST['interest_amount'] ?? 0); $feeAmount = (float)($_POST['fee_amount'] ?? 0); $description = trim($_POST['description'] ?? '') ?: null; prepay_loan( $uid, $id, $accountId, $paymentDate, $principalAmount, $interestAmount, $feeAmount, $description ); $msg = '중도상환 처리되었습니다.'; $stmt->execute([$id, $uid]); $loan = $stmt->fetch(); } catch (Throwable $e) { $error = $e->getMessage(); } } $summary = get_loan_remaining_summary($id); $stmt = $pdo->prepare(" SELECT * FROM loan_schedules WHERE loan_id = ? ORDER BY cycle_no ASC "); $stmt->execute([$id]); $schedules = $stmt->fetchAll(); $stmt = $pdo->prepare(" SELECT * FROM loan_payments WHERE loan_id = ? AND payment_type = 'prepayment' ORDER BY payment_date DESC, id DESC "); $stmt->execute([$id]); $prepayments = $stmt->fetchAll(); require __DIR__ . '/../app/views/header.php'; ?>
| 일자 | 원금 | 이자 | 수수료 | 합계 |
|---|---|---|---|---|
|
= h($p['payment_date']) ?>
= h($p['description']) ?>
|
= won($p['principal_amount']) ?> | = won($p['interest_amount']) ?> | = won($p['fee_amount']) ?> | = won($p['total_amount']) ?> |
| 중도상환 이력이 없습니다. | ||||
| 회차 | 납부일 | 구간 | 기초원금 | 원금 | 이자 | 합계 | 기말원금 | 상태 |
|---|---|---|---|---|---|---|---|---|
| = $s['cycle_no'] ?> | = h($s['due_date']) ?> | = $s['payment_phase'] === 'grace' ? '거치' : '상환' ?> | = won($s['opening_principal']) ?> | = won($s['scheduled_principal']) ?> | = won($s['scheduled_interest']) ?> | = won($s['scheduled_total']) ?> | = won($s['closing_principal']) ?> | 납부완료 미납 |
| 스케줄이 없습니다. | ||||||||