31) { throw new RuntimeException('납부일은 1~31 사이여야 합니다.'); } if ($useCreditGracePeriod) { if ($statementStartMonthOffset === null || $statementEndMonthOffset === null) { throw new RuntimeException('사용기간 기준 월을 선택하세요.'); } if ($statementStartDay === null || $statementStartDay < 1 || $statementStartDay > 31) { throw new RuntimeException('사용기간 시작일은 1~31 사이여야 합니다.'); } if ($statementEndDay === null || $statementEndDay < 1 || $statementEndDay > 31) { throw new RuntimeException('사용기간 종료일은 1~31 사이여야 합니다.'); } } else { $statementStartMonthOffset = null; $statementStartDay = null; $statementEndMonthOffset = null; $statementEndDay = null; } if ($billingCycleMemo === '') { $billingCycleMemo = null; } } } $stmt = $pdo->prepare(" INSERT INTO accounts ( user_id, account_type, institution_name, account_name, opening_balance, current_balance, is_active, card_kind, billing_day, payment_day, use_credit_grace_period, statement_start_month_offset, statement_start_day, statement_end_month_offset, statement_end_day, billing_cycle_memo ) VALUES (?, ?, ?, ?, ?, ?, 1, ?, ?, ?, ?, ?, ?, ?, ?, ?) "); $stmt->execute([ $uid, $accountType, $institutionName, $accountName, $openingBalance, $openingBalance, $cardKind, $billingDay, $paymentDay, $useCreditGracePeriod, $statementStartMonthOffset, $statementStartDay, $statementEndMonthOffset, $statementEndDay, $billingCycleMemo ]); redirect('/accounts.php'); } catch (Throwable $e) { $error = $e->getMessage(); } } require __DIR__ . '/../app/views/header.php'; ?>