Files
sam-manage/resources/views/rd/ai-quotation/document.blade.php
김보곤 eb45fc608e feat: [ai-quotation] 제조업 표준 견적서 문서 뷰 추가
- 인쇄 전용 standalone 레이아웃 (layouts/document.blade.php) 생성
- 한국 제조업 표준 견적서 양식 문서 뷰 생성 (A4 인쇄/PDF 최적화)
- RdController에 documentQuotation 메서드 추가
- /rd/ai-quotation/{id}/document 라우트 등록
- 상세 페이지에 "견적서 보기" 버튼 추가 (완료 상태만 표시)
- 한글 금액 변환, VAT 자동 계산, 비고란 포함
2026-03-02 19:11:33 +09:00

236 lines
9.2 KiB
PHP

@extends('layouts.document')
@section('title', '견적서')
@push('styles')
<style>
.doc-table { width: 100%; border-collapse: collapse; }
.doc-table th, .doc-table td { border: 1px solid #333; padding: 6px 10px; font-size: 13px; }
.doc-table th { background-color: #f3f4f6; font-weight: 600; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.seal-box { display: inline-block; width: 60px; height: 60px; border: 2px solid #dc2626; border-radius: 50%; text-align: center; line-height: 56px; color: #dc2626; font-weight: 700; font-size: 16px; }
</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;
// 한글 금액 변환
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();
@endphp
<div class="document-page max-w-[210mm] mx-auto my-8 bg-white shadow-lg" style="padding: 15mm 20mm;">
{{-- 제목 --}}
<h1 class="text-center text-3xl font-bold tracking-[0.5em] mb-8 pb-4 border-b-2 border-gray-800">
</h1>
{{-- 견적 정보 --}}
<div class="flex justify-between mb-6 text-sm">
<div>
<p><span class="font-semibold">견적번호:</span> {{ $quotationNo }}</p>
<p><span class="font-semibold">유효기간:</span> 견적일로부터 30</p>
</div>
<div class="text-right">
<p><span class="font-semibold">견적일자:</span> {{ $quotation->created_at->format('Y년 m월 d일') }}</p>
</div>
</div>
{{-- 수신 / 공급자 --}}
<table class="doc-table mb-6">
<colgroup>
<col style="width: 8%;">
<col style="width: 42%;">
<col style="width: 8%;">
<col style="width: 42%;">
</colgroup>
<thead>
<tr>
<th colspan="2" class="text-center" style="background-color: #eff6ff;"> </th>
<th colspan="2" class="text-center" style="background-color: #f0fdf4;"> </th>
</tr>
</thead>
<tbody>
<tr>
<th>귀사명</th>
<td>{{ $quotation->title }}</td>
<th> </th>
<td>()코드브릿지엑스</td>
</tr>
<tr>
<th> </th>
<td>{{ $company['industry'] ?? '-' }}</td>
<th> </th>
<td>권형석</td>
</tr>
<tr>
<th> </th>
<td>{{ $company['scale'] ?? '-' }}</td>
<th> </th>
<td>인천 남동구 남동대로 215번길 30</td>
</tr>
<tr>
<th>현재시스템</th>
<td>{{ !empty($company['current_systems']) ? implode(', ', $company['current_systems']) : '-' }}</td>
<th>연락처</th>
<td>032-123-4567</td>
</tr>
</tbody>
</table>
{{-- 인사말 + 합계 --}}
<div class="mb-6 p-4 border-2 border-gray-800 text-center">
<p class="text-sm mb-2">아래와 같이 견적합니다.</p>
<p class="text-xl font-bold">
합계금액: {{ $devTotalKorean }}원정
<span class="text-base font-normal">(&#8361;{{ number_format($devSubtotal) }})</span>
</p>
<p class="text-xs text-gray-600 mt-1"> 부가가치세 별도 / 구독료 {{ number_format($monthlySubtotal) }} 별도</p>
</div>
{{-- 품목 테이블 --}}
<table class="doc-table mb-6">
<colgroup>
<col style="width: 5%;">
<col style="width: 7%;">
<col style="width: 20%;">
<col style="width: 33%;">
<col style="width: 17.5%;">
<col style="width: 17.5%;">
</colgroup>
<thead>
<tr>
<th class="text-center">No</th>
<th class="text-center">구분</th>
<th class="text-center"> </th>
<th class="text-center"> </th>
<th class="text-center">개발비 ()</th>
<th class="text-center"> 구독료 ()</th>
</tr>
</thead>
<tbody>
@foreach($sortedItems as $index => $item)
<tr>
<td class="text-center">{{ $index + 1 }}</td>
<td class="text-center">
{{ $item->is_required ? '필수' : '선택' }}
</td>
<td>{{ $item->module_name }}</td>
<td class="text-xs">{{ Str::limit($item->reason, 80) }}</td>
<td class="text-right">{{ number_format((int) $item->dev_cost) }}</td>
<td class="text-right">{{ number_format((int) $item->monthly_fee) }}</td>
</tr>
@endforeach
</tbody>
<tfoot>
<tr>
<th colspan="4" class="text-right"> </th>
<td class="text-right font-bold">{{ number_format($devSubtotal) }}</td>
<td class="text-right font-bold">{{ number_format($monthlySubtotal) }}</td>
</tr>
<tr>
<th colspan="4" class="text-right">부가세 (10%)</th>
<td class="text-right">{{ number_format($devVat) }}</td>
<td class="text-right">{{ number_format($monthlyVat) }}</td>
</tr>
<tr style="background-color: #f3f4f6;">
<th colspan="4" class="text-right text-base"> </th>
<td class="text-right font-bold text-base">{{ number_format($devTotal) }}</td>
<td class="text-right font-bold text-base">{{ number_format($monthlyTotal) }}</td>
</tr>
</tfoot>
</table>
{{-- 비고 --}}
<div class="mb-8">
<table class="doc-table">
<thead>
<tr>
<th class="text-left"> </th>
</tr>
</thead>
<tbody>
<tr>
<td class="text-sm leading-relaxed" style="padding: 12px 16px;">
<ol class="list-decimal list-inside space-y-1">
<li>상기 금액은 부가가치세 별도입니다.</li>
<li>개발비 납부 조건: 계약 50%, 완료 50% 분할 납부</li>
<li> 구독료: 서비스 오픈일부터 과금 ( {{ number_format($monthlyTotal) }}, VAT 포함)</li>
@if($estimatedMonths)
<li>예상 구축 기간: {{ $estimatedMonths }}개월</li>
@endif
<li> 견적서의 유효기간은 견적일로부터 30일입니다.</li>
<li>세부 사항은 별도 협의를 통해 조정될 있습니다.</li>
</ol>
</td>
</tr>
</tbody>
</table>
</div>
{{-- 서명 --}}
<div class="flex justify-end items-center gap-6 mt-12">
<div class="text-right">
<p class="text-lg font-bold mb-1">()코드브릿지엑스</p>
<p class="text-sm text-gray-600">대표이사 </p>
</div>
<div class="seal-box">()</div>
</div>
</div>
@endsection