Files
sam-manage/resources/views/rd/ai-quotation/document.blade.php
김보곤 420b80e45a feat: [ai-quotation] 견적서 5종 템플릿 선택 시스템 추가
- classic(클래식), modern(모던), blue(블루), dark(다크), colorful(컬러풀) 5종
- 문서 상단 미리보기 카드 클릭으로 즉시 디자인 전환
- URL 쿼리 파라미터 ?template=xxx 방식, 기본값 classic
- 인쇄/PDF 시 선택 UI 자동 숨김 (no-print)
- 기존 디자인은 classic 템플릿으로 100% 보존
2026-03-02 19:28:01 +09:00

130 lines
4.9 KiB
PHP

@extends('layouts.document')
@section('title', '견적서')
@push('styles')
<style>
/* 템플릿 선택 UI */
.template-selector { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; padding: 16px 0; }
.template-card {
width: 120px; text-decoration: none; color: inherit; border: 2px solid #e5e7eb;
border-radius: 10px; overflow: hidden; transition: all 0.2s; cursor: pointer;
}
.template-card:hover { border-color: #3b82f6; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.template-card.active { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.2); }
.template-card .preview {
height: 64px; display: flex; align-items: center; justify-content: center;
font-size: 10px; font-weight: 600; letter-spacing: 0.2em;
}
.template-card .label { padding: 6px 0; text-align: center; font-size: 11px; font-weight: 500; background: #f9fafb; }
.template-card.active .label { background: #eff6ff; color: #1d4ed8; }
/* 미리보기 색상 */
.preview-classic { background: #fff; border-bottom: 2px solid #1f2937; color: #1f2937; }
.preview-modern { background: #f9fafb; border-bottom: 2px solid #9ca3af; color: #6b7280; }
.preview-blue { background: linear-gradient(135deg, #1e40af, #3b82f6); color: #fff; }
.preview-dark { background: #111827; color: #fbbf24; }
.preview-colorful { background: linear-gradient(135deg, #f59e0b, #ef4444); color: #fff; }
</style>
@endpush
@section('content')
@php
// 견적번호
$quotationNo = 'AQ-' . $quotation->created_at->format('Y') . '-' . str_pad($quotation->id, 3, '0', STR_PAD_LEFT);
// 회사 분석 정보
$company = $quotation->analysis_result['company_analysis'] ?? [];
// 구현 계획
$plan = $quotation->quotation_result['implementation_plan'] ?? [];
$estimatedMonths = $plan['estimated_months'] ?? null;
// 금액 계산
$devSubtotal = (int) $quotation->total_dev_cost;
$monthlySubtotal = (int) $quotation->total_monthly_fee;
$devVat = (int) round($devSubtotal * 0.1);
$monthlyVat = (int) round($monthlySubtotal * 0.1);
$devTotal = $devSubtotal + $devVat;
$monthlyTotal = $monthlySubtotal + $monthlyVat;
// 한글 금액 변환
if (!function_exists('numberToKorean')) {
function numberToKorean(int $number): string {
if ($number === 0) return '영';
$units = ['', '만', '억', '조'];
$digits = ['', '일', '이', '삼', '사', '오', '육', '칠', '팔', '구'];
$subUnits = ['', '십', '백', '천'];
$result = '';
$unitIndex = 0;
while ($number > 0) {
$chunk = $number % 10000;
if ($chunk > 0) {
$chunkStr = '';
$subIndex = 0;
$temp = $chunk;
while ($temp > 0) {
$digit = $temp % 10;
if ($digit > 0) {
$prefix = ($digit === 1 && $subIndex > 0) ? '' : $digits[$digit];
$chunkStr = $prefix . $subUnits[$subIndex] . $chunkStr;
}
$temp = (int)($temp / 10);
$subIndex++;
}
$result = $chunkStr . $units[$unitIndex] . $result;
}
$number = (int)($number / 10000);
$unitIndex++;
}
return $result;
}
}
$devTotalKorean = numberToKorean($devSubtotal);
// 필수 → 선택 순으로 정렬된 품목
$sortedItems = $quotation->items->sortByDesc('is_required')->values();
// 템플릿 (기본값: classic)
$template = $template ?? 'classic';
$templates = [
'classic' => '클래식',
'modern' => '모던',
'blue' => '블루',
'dark' => '다크',
'colorful' => '컬러풀',
];
@endphp
{{-- 템플릿 선택 UI (인쇄 숨김) --}}
<div class="no-print" style="max-width: 700px; margin: 24px auto 0;">
<div class="template-selector">
@foreach($templates as $key => $label)
<a href="?template={{ $key }}"
class="template-card {{ $template === $key ? 'active' : '' }}">
<div class="preview preview-{{ $key }}"> </div>
<div class="label">{{ $label }}</div>
</a>
@endforeach
</div>
</div>
{{-- 선택된 템플릿 렌더링 --}}
@include('rd.ai-quotation.document-templates.' . $template, [
'quotation' => $quotation,
'quotationNo' => $quotationNo,
'company' => $company,
'estimatedMonths' => $estimatedMonths,
'devSubtotal' => $devSubtotal,
'monthlySubtotal' => $monthlySubtotal,
'devVat' => $devVat,
'monthlyVat' => $monthlyVat,
'devTotal' => $devTotal,
'monthlyTotal' => $monthlyTotal,
'devTotalKorean' => $devTotalKorean,
'sortedItems' => $sortedItems,
])
@endsection