feat: [approval] 위촉증명서 기안/조회/PDF 기능 추가

- AppointmentCertService: 사원 위촉정보 조회 + TCPDF PDF 생성
- 기안 작성 폼: 사원 선택, 인적/위촉/발급 정보, 미리보기
- 상세 조회: 읽기전용 렌더링 + 미리보기/PDF 다운로드
- API: appointment-cert-info, appointment-cert-pdf 엔드포인트
This commit is contained in:
김보곤
2026-03-05 23:57:42 +09:00
parent 1fef5f16d9
commit 0445748b32
7 changed files with 780 additions and 1 deletions

View File

@@ -4,6 +4,7 @@
use App\Http\Controllers\Controller;
use App\Models\Boards\File;
use App\Services\AppointmentCertService;
use App\Services\ApprovalService;
use App\Services\CareerCertService;
use App\Services\EmploymentCertService;
@@ -330,6 +331,43 @@ public function careerCertPdf(int $id)
return $service->generatePdfResponse($content);
}
// =========================================================================
// 위촉증명서
// =========================================================================
/**
* 사원 위촉증명서 정보 조회
*/
public function appointmentCertInfo(int $userId): JsonResponse
{
try {
$tenantId = session('selected_tenant_id');
$service = app(AppointmentCertService::class);
$data = $service->getCertInfo($userId, $tenantId);
return response()->json(['success' => true, 'data' => $data]);
} catch (\Throwable $e) {
return response()->json([
'success' => false,
'message' => '사원 정보를 불러올 수 없습니다.',
], 400);
}
}
/**
* 위촉증명서 PDF 다운로드
*/
public function appointmentCertPdf(int $id)
{
$approval = \App\Models\Approvals\Approval::where('tenant_id', session('selected_tenant_id'))
->findOrFail($id);
$content = $approval->content ?? [];
$service = app(AppointmentCertService::class);
return $service->generatePdfResponse($content);
}
// =========================================================================
// 워크플로우
// =========================================================================

View File

@@ -0,0 +1,207 @@
<?php
namespace App\Services;
use App\Models\HR\Employee;
use App\Models\Tenants\Tenant;
use App\Models\Tenants\TenantSetting;
use Illuminate\Support\Facades\Log;
class AppointmentCertService
{
private ?string $koreanFontName = null;
public function __construct()
{
if (! defined('K_PATH_FONTS')) {
$tcpdfFontsDir = dirname(__DIR__, 2).'/storage/fonts/tcpdf/';
if (is_dir($tcpdfFontsDir)) {
define('K_PATH_FONTS', $tcpdfFontsDir);
}
}
}
/**
* 사원의 위촉증명서 정보 조회
*/
public function getCertInfo(int $userId, int $tenantId): array
{
$employee = Employee::withoutGlobalScopes()
->where('tenant_id', $tenantId)
->where('user_id', $userId)
->with(['user', 'department'])
->firstOrFail();
$tenant = Tenant::findOrFail($tenantId);
$displaySetting = TenantSetting::withoutGlobalScopes()
->where('tenant_id', $tenantId)
->where('setting_group', 'company')
->where('setting_key', 'display_company_name')
->first();
$displayName = $displaySetting?->setting_value ?? '';
$companyName = ! empty($displayName) ? $displayName : ($tenant->company_name ?? '');
// 주민등록번호 마스킹 (뒷자리 첫째만 표시)
$residentNumber = $employee->resident_number ?? '';
$maskedResident = '';
if (strlen($residentNumber) >= 8) {
$front = substr($residentNumber, 0, 6);
$back = substr($residentNumber, 7, 1); // 하이픈 뒤 첫째 자리
$maskedResident = $front.'-'.$back.'******';
} elseif (! empty($residentNumber)) {
$maskedResident = $residentNumber;
}
return [
'name' => $employee->user->name ?? $employee->display_name ?? '',
'resident_number' => $maskedResident,
'department' => $employee->department?->name ?? '',
'phone' => $employee->user->phone ?? '',
'hire_date' => $employee->hire_date ?? '',
'resign_date' => $employee->resign_date ?? '',
'contract_type' => '',
'company_name' => $companyName,
'ceo_name' => $tenant->ceo_name ?? '',
];
}
/**
* content JSON 기반 PDF Response 생성
*/
public function generatePdfResponse(array $content): \Illuminate\Http\Response
{
$pdf = new \TCPDF('P', 'mm', 'A4', true, 'UTF-8', false);
$pdf->SetCreator('SAM');
$pdf->SetAuthor($content['company_name'] ?? 'SAM');
$pdf->SetTitle('위촉증명서');
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetMargins(20, 20, 20);
$pdf->SetAutoPageBreak(true, 20);
$font = $this->getKoreanFont();
$pdf->AddPage();
// 제목
$pdf->SetFont($font, 'B', 22);
$pdf->Cell(0, 20, '위 촉 증 명 서', 0, 1, 'C');
$pdf->Ln(8);
$pageWidth = $pdf->getPageWidth() - 40;
$thWidth = 30;
$rowHeight = 8;
// 성명 / (빈칸)
$this->addTableRow($pdf, $font, [
['성 명', $content['name'] ?? '-', 0],
]);
// 주민등록번호
$this->addTableRow($pdf, $font, [
['주민등록번호', $content['resident_number'] ?? '-', 0],
]);
// 소속 / 연락처
$this->addTableRow($pdf, $font, [
['소 속', $content['department'] ?? '-', 40],
['연 락 처', $content['phone'] ?? '-', 40],
]);
// 위촉(재직)기간 / 계약자격
$hireDate = $content['hire_date'] ?? '';
$resignDate = $content['resign_date'] ?? '';
$periodDisplay = $hireDate ? $hireDate.' ~ '.($resignDate ?: '현재') : '-';
$this->addTableRow($pdf, $font, [
['위촉기간', $periodDisplay, 40],
['계약자격', $content['contract_type'] ?? '-', 40],
]);
// 용도
$this->addTableRow($pdf, $font, [
['용 도', $content['purpose'] ?? '-', 0],
]);
$pdf->Ln(12);
// 증명 문구
$pdf->SetFont($font, '', 12);
$pdf->Cell(0, 10, '위와 같이 위촉하였음을 증명합니다.', 0, 1, 'C');
$pdf->Ln(6);
// 발급일
$issueDate = $content['issue_date'] ?? date('Y-m-d');
$issueDateFormatted = $this->formatDate($issueDate);
$pdf->SetFont($font, 'B', 12);
$pdf->Cell(0, 10, $issueDateFormatted, 0, 1, 'C');
$pdf->Ln(12);
// 회사명 + 대표이사
$ceoName = $content['ceo_name'] ?? '';
$pdf->SetFont($font, 'B', 14);
$pdf->Cell(0, 10, ($content['company_name'] ?? '').' 대표이사 '.$ceoName.' (인)', 0, 1, 'C');
$pdfContent = $pdf->Output('', 'S');
$fileName = '위촉증명서_'.($content['name'] ?? '').'.pdf';
return response($pdfContent, 200, [
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="'.$fileName.'"',
]);
}
private function addTableRow(\TCPDF $pdf, string $font, array $cells): void
{
$pageWidth = $pdf->getPageWidth() - 40;
$rowHeight = 8;
$thWidth = 30;
if (count($cells) === 1) {
$pdf->SetFont($font, 'B', 10);
$pdf->SetFillColor(248, 249, 250);
$pdf->Cell($thWidth, $rowHeight, $cells[0][0], 1, 0, 'L', true);
$pdf->SetFont($font, '', 10);
$pdf->Cell($pageWidth - $thWidth, $rowHeight, $cells[0][1], 1, 1, 'L');
} else {
$tdWidth = ($pageWidth - $thWidth * 2) / 2;
foreach ($cells as $cell) {
$pdf->SetFont($font, 'B', 10);
$pdf->SetFillColor(248, 249, 250);
$pdf->Cell($thWidth, $rowHeight, $cell[0], 1, 0, 'L', true);
$pdf->SetFont($font, '', 10);
$pdf->Cell($tdWidth, $rowHeight, $cell[1], 1, 0, 'L');
}
$pdf->Ln();
}
}
private function formatDate(string $date): string
{
try {
return date('Y년 m월 d일', strtotime($date));
} catch (\Throwable) {
return $date;
}
}
private function getKoreanFont(): string
{
if ($this->koreanFontName) {
return $this->koreanFontName;
}
if (defined('K_PATH_FONTS') && file_exists(K_PATH_FONTS.'pretendard.php')) {
$this->koreanFontName = 'pretendard';
return $this->koreanFontName;
}
$fontPath = storage_path('fonts/Pretendard-Regular.ttf');
if (file_exists($fontPath)) {
try {
$this->koreanFontName = \TCPDF_FONTS::addTTFfont($fontPath, 'TrueTypeUnicode', '', 96);
} catch (\Throwable $e) {
Log::warning('TCPDF 한글 폰트 등록 실패', ['error' => $e->getMessage()]);
}
}
return $this->koreanFontName ?: 'helvetica';
}
}

View File

@@ -105,6 +105,11 @@ class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:outline-
'employees' => $employees ?? collect(),
])
{{-- 위촉증명서 전용 --}}
@include('approvals.partials._appointment-cert-form', [
'employees' => $employees ?? collect(),
])
{{-- 지출결의서 전용 --}}
@include('approvals.partials._expense-form', [
'initialData' => [],
@@ -229,6 +234,7 @@ class="p-1 text-gray-400 hover:text-gray-600 transition">
let isLeaveForm = false;
let isCertForm = false;
let isCareerCertForm = false;
let isAppointmentCertForm = false;
// 양식코드별 표시할 유형 목록
const leaveTypesByFormCode = {
@@ -473,6 +479,7 @@ function switchFormMode(formId) {
const leaveContainer = document.getElementById('leave-form-container');
const certContainer = document.getElementById('cert-form-container');
const careerCertContainer = document.getElementById('career-cert-form-container');
const appointmentCertContainer = document.getElementById('appointment-cert-form-container');
const bodyArea = document.getElementById('body-area');
const expenseLoadBtn = document.getElementById('expense-load-btn');
@@ -483,12 +490,14 @@ function switchFormMode(formId) {
leaveContainer.style.display = 'none';
certContainer.style.display = 'none';
careerCertContainer.style.display = 'none';
appointmentCertContainer.style.display = 'none';
expenseLoadBtn.style.display = 'none';
bodyArea.style.display = 'none';
isExpenseForm = false;
isLeaveForm = false;
isCertForm = false;
isCareerCertForm = false;
isAppointmentCertForm = false;
if (code === 'expense') {
isExpenseForm = true;
@@ -514,6 +523,11 @@ function switchFormMode(formId) {
careerCertContainer.style.display = '';
const ccUserId = document.getElementById('cc-user-id').value;
if (ccUserId) loadCareerCertInfo(ccUserId);
} else if (code === 'appointment_cert') {
isAppointmentCertForm = true;
appointmentCertContainer.style.display = '';
const acUserId = document.getElementById('ac-user-id').value;
if (acUserId) loadAppointmentCertInfo(acUserId);
} else {
bodyArea.style.display = '';
}
@@ -524,7 +538,7 @@ function applyBodyTemplate(formId) {
switchFormMode(formId);
// 전용 폼이면 제목을 양식명으로 설정하고 body template 적용 건너뜀
if (isExpenseForm || isLeaveForm || isCertForm || isCareerCertForm) {
if (isExpenseForm || isLeaveForm || isCertForm || isCareerCertForm || isAppointmentCertForm) {
const titleEl = document.getElementById('title');
const formSelect = document.getElementById('form_id');
titleEl.value = formSelect.options[formSelect.selectedIndex].text;
@@ -676,6 +690,28 @@ function applyBodyTemplate(formId) {
issue_date: document.getElementById('cc-issue-date').value,
};
formBody = null;
} else if (isAppointmentCertForm) {
const purpose = getAppointmentCertPurpose();
if (!purpose) {
showToast('용도를 입력해주세요.', 'warning');
return;
}
formContent = {
cert_user_id: document.getElementById('ac-user-id').value,
name: document.getElementById('ac-name').value,
resident_number: document.getElementById('ac-resident').value,
department: document.getElementById('ac-department').value,
phone: document.getElementById('ac-phone').value,
hire_date: document.getElementById('ac-hire-date').value,
resign_date: document.getElementById('ac-resign-date').value,
contract_type: document.getElementById('ac-contract-type').value,
company_name: document.getElementById('ac-company-name').value,
ceo_name: document.getElementById('ac-ceo-name').value,
purpose: purpose,
issue_date: document.getElementById('ac-issue-date').value,
};
formBody = null;
}
const payload = {
@@ -1119,6 +1155,145 @@ function buildCareerCertPreviewHtml(d) {
`;
}
// =========================================================================
// 위촉증명서 관련 함수
// =========================================================================
async function loadAppointmentCertInfo(userId) {
if (!userId) return;
try {
const resp = await fetch(`/api/admin/approvals/appointment-cert-info/${userId}`, {
headers: { 'Accept': 'application/json', 'X-CSRF-TOKEN': '{{ csrf_token() }}' }
});
const data = await resp.json();
if (data.success) {
const d = data.data;
document.getElementById('ac-name').value = d.name || '';
document.getElementById('ac-resident').value = d.resident_number || '';
document.getElementById('ac-department').value = d.department || '';
document.getElementById('ac-phone').value = d.phone || '';
document.getElementById('ac-hire-date').value = d.hire_date || '';
document.getElementById('ac-resign-date').value = d.resign_date || '';
document.getElementById('ac-contract-type').value = d.contract_type || '';
document.getElementById('ac-company-name').value = d.company_name || '';
document.getElementById('ac-ceo-name').value = d.ceo_name || '';
} else {
showToast(data.message || '사원 정보를 불러올 수 없습니다.', 'error');
}
} catch (e) {
showToast('사원 정보 조회 중 오류가 발생했습니다.', 'error');
}
}
function onAppointmentCertPurposeChange() {
const sel = document.getElementById('ac-purpose-select');
const customWrap = document.getElementById('ac-purpose-custom-wrap');
if (sel.value === '__custom__') {
customWrap.style.display = '';
document.getElementById('ac-purpose-custom').focus();
} else {
customWrap.style.display = 'none';
}
}
function getAppointmentCertPurpose() {
const sel = document.getElementById('ac-purpose-select');
if (sel.value === '__custom__') {
return document.getElementById('ac-purpose-custom').value.trim();
}
return sel.value;
}
function openAppointmentCertPreview() {
const name = document.getElementById('ac-name').value || '-';
const resident = document.getElementById('ac-resident').value || '-';
const department = document.getElementById('ac-department').value || '-';
const phone = document.getElementById('ac-phone').value || '-';
const hireDate = document.getElementById('ac-hire-date').value || '-';
const resignDate = document.getElementById('ac-resign-date').value || '현재';
const contractType = document.getElementById('ac-contract-type').value || '-';
const purpose = getAppointmentCertPurpose() || '-';
const issueDate = document.getElementById('ac-issue-date').value || '-';
const issueDateFormatted = issueDate !== '-' ? issueDate.replace(/-/g, function(m, i) { return i === 4 ? '년 ' : '월 '; }) + '일' : '-';
const company = document.getElementById('ac-company-name').value || '-';
const ceoName = document.getElementById('ac-ceo-name').value || '-';
const el = document.getElementById('appointment-cert-preview-content');
el.innerHTML = buildAppointmentCertPreviewHtml({ name, resident, department, phone, hireDate, resignDate, contractType, purpose, issueDateFormatted, company, ceoName });
document.getElementById('appointment-cert-preview-modal').style.display = '';
document.body.style.overflow = 'hidden';
}
function closeAppointmentCertPreview() {
document.getElementById('appointment-cert-preview-modal').style.display = 'none';
document.body.style.overflow = '';
}
function printAppointmentCertPreview() {
const content = document.getElementById('appointment-cert-preview-content').innerHTML;
const win = window.open('', '_blank', 'width=800,height=1000');
win.document.write('<html><head><title>위촉증명서</title>');
win.document.write('<style>body{font-family:"Pretendard","Malgun Gothic",sans-serif;padding:48px 56px;margin:0;} table{border-collapse:collapse;width:100%;} th,td{border:1px solid #333;padding:10px 14px;font-size:14px;} th{background:#f8f9fa;font-weight:600;text-align:left;white-space:nowrap;width:120px;} @media print{body{padding:40px 48px;}}</style>');
win.document.write('</head><body>');
win.document.write(content);
win.document.write('</body></html>');
win.document.close();
win.onload = function() { win.print(); };
}
function buildAppointmentCertPreviewHtml(d) {
const e = (s) => { const div = document.createElement('div'); div.textContent = s; return div.innerHTML; };
const thStyle = 'border:1px solid #333; padding:10px 14px; background:#f8f9fa; font-weight:600; text-align:left; white-space:nowrap; width:120px; font-size:14px;';
const tdStyle = 'border:1px solid #333; padding:10px 14px; font-size:14px;';
return `
<h1 style="text-align:center; font-size:28px; font-weight:700; letter-spacing:12px; margin-bottom:40px;">위 촉 증 명 서</h1>
<table style="border-collapse:collapse; width:100%; margin-bottom:20px;">
<tr>
<th style="${thStyle}">성 명</th>
<td style="${tdStyle}" colspan="3">${e(d.name)}</td>
</tr>
<tr>
<th style="${thStyle}">주민등록번호</th>
<td style="${tdStyle}" colspan="3">${e(d.resident)}</td>
</tr>
<tr>
<th style="${thStyle}">소 속</th>
<td style="${tdStyle}">${e(d.department)}</td>
<th style="${thStyle}">연 락 처</th>
<td style="${tdStyle}">${e(d.phone)}</td>
</tr>
<tr>
<th style="${thStyle}">위촉(재직)기간</th>
<td style="${tdStyle}">${e(d.hireDate)} ~ ${e(d.resignDate)}</td>
<th style="${thStyle}">계약자격</th>
<td style="${tdStyle}">${e(d.contractType)}</td>
</tr>
<tr>
<th style="${thStyle}">용 도</th>
<td style="${tdStyle}" colspan="3">${e(d.purpose)}</td>
</tr>
</table>
<p style="text-align:center; font-size:15px; line-height:2; margin:36px 0;">
위와 같이 위촉하였음을 증명합니다.
</p>
<p style="text-align:center; font-size:15px; font-weight:500; margin-bottom:48px;">
${e(d.issueDateFormatted)}
</p>
<div style="text-align:center; margin-top:32px;">
<p style="font-size:16px; font-weight:600; margin-bottom:8px;">${e(d.company)}</p>
<p style="font-size:14px; color:#555;">대표이사 &nbsp;&nbsp; ${e(d.ceoName)} &nbsp;&nbsp; (인)</p>
</div>
`;
}
function buildCertPreviewHtml(d) {
const e = (s) => { const div = document.createElement('div'); div.textContent = s; return div.innerHTML; };
const thStyle = 'border:1px solid #333; padding:10px 14px; background:#f8f9fa; font-weight:600; text-align:left; white-space:nowrap; width:120px; font-size:14px;';

View File

@@ -0,0 +1,162 @@
{{--
위촉증명서 전용
Props:
$employees (Collection) - 활성 사원 목록
--}}
@php
$employees = $employees ?? collect();
$currentUserId = auth()->id();
@endphp
<div id="appointment-cert-form-container" style="display: none;" class="mb-4">
<input type="hidden" id="ac-company-name" value="">
<input type="hidden" id="ac-ceo-name" value="">
<div class="space-y-4">
{{-- 대상 사원 --}}
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">대상 사원 <span class="text-red-500">*</span></label>
<div class="flex items-center gap-2">
<select id="ac-user-id" onchange="loadAppointmentCertInfo(this.value)"
class="px-3 py-2 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
style="max-width: 300px;">
@foreach($employees as $emp)
<option value="{{ $emp->user_id }}" {{ $emp->user_id == $currentUserId ? 'selected' : '' }}>
{{ $emp->display_name }}
</option>
@endforeach
</select>
<button type="button" onclick="openAppointmentCertPreview()"
class="shrink-0 px-3 py-2 bg-indigo-50 text-indigo-600 hover:bg-indigo-100 border border-indigo-200 rounded-lg text-sm font-medium transition inline-flex items-center gap-1">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/>
</svg>
미리보기
</button>
</div>
</div>
{{-- 인적사항 --}}
<div class="border border-gray-200 rounded-lg overflow-hidden">
<div class="bg-gray-50 px-4 py-2 border-b border-gray-200">
<h3 class="text-sm font-semibold text-gray-700">인적사항</h3>
</div>
<div class="p-4 space-y-3">
<div class="flex gap-4 flex-wrap">
<div style="flex: 1 1 200px; max-width: 300px;">
<label class="block text-xs font-medium text-gray-500 mb-1">성명</label>
<input type="text" id="ac-name" readonly
class="w-full px-3 py-2 border border-gray-200 rounded-lg text-sm bg-gray-50 text-gray-700">
</div>
<div style="flex: 1 1 200px; max-width: 300px;">
<label class="block text-xs font-medium text-gray-500 mb-1">주민등록번호</label>
<input type="text" id="ac-resident" readonly
class="w-full px-3 py-2 border border-gray-200 rounded-lg text-sm bg-gray-50 text-gray-700">
</div>
</div>
<div class="flex gap-4 flex-wrap">
<div style="flex: 1 1 200px; max-width: 300px;">
<label class="block text-xs font-medium text-gray-500 mb-1">소속</label>
<input type="text" id="ac-department" readonly
class="w-full px-3 py-2 border border-gray-200 rounded-lg text-sm bg-gray-50 text-gray-700">
</div>
<div style="flex: 1 1 200px; max-width: 300px;">
<label class="block text-xs font-medium text-gray-500 mb-1">연락처 <span class="text-blue-500 text-xs">(수정 가능)</span></label>
<input type="text" id="ac-phone"
class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
</div>
</div>
</div>
{{-- 위촉정보 --}}
<div class="border border-gray-200 rounded-lg overflow-hidden">
<div class="bg-gray-50 px-4 py-2 border-b border-gray-200">
<h3 class="text-sm font-semibold text-gray-700">위촉정보</h3>
</div>
<div class="p-4 space-y-3">
<div class="flex gap-4 flex-wrap">
<div style="flex: 1 1 200px; max-width: 200px;">
<label class="block text-xs font-medium text-gray-500 mb-1">위촉(재직)기간 (시작)</label>
<input type="text" id="ac-hire-date" readonly
class="w-full px-3 py-2 border border-gray-200 rounded-lg text-sm bg-gray-50 text-gray-700">
</div>
<div style="flex: 1 1 200px; max-width: 200px;">
<label class="block text-xs font-medium text-gray-500 mb-1">위촉(재직)기간 (종료) <span class="text-blue-500 text-xs">(수정 가능)</span></label>
<input type="date" id="ac-resign-date"
class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
</div>
<div style="max-width: 300px;">
<label class="block text-xs font-medium text-gray-500 mb-1">계약자격 <span class="text-blue-500 text-xs">(수정 가능)</span></label>
<input type="text" id="ac-contract-type" placeholder="예: 프리랜서, 자문위원, 강사 등"
class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
</div>
</div>
{{-- 발급정보 --}}
<div class="border border-gray-200 rounded-lg overflow-hidden">
<div class="bg-gray-50 px-4 py-2 border-b border-gray-200">
<h3 class="text-sm font-semibold text-gray-700">발급정보</h3>
</div>
<div class="p-4 space-y-3">
<div class="flex gap-4 flex-wrap">
<div style="flex: 1 1 250px; max-width: 300px;">
<label class="block text-xs font-medium text-gray-500 mb-1">용도 <span class="text-red-500">*</span></label>
<select id="ac-purpose-select" onchange="onAppointmentCertPurposeChange()"
class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
<option value="은행 제출용">은행 제출용</option>
<option value="관공서 제출용">관공서 제출용</option>
<option value="비자 신청용">비자 신청용</option>
<option value="대출 신청용">대출 신청용</option>
<option value="__custom__">기타 (직접입력)</option>
</select>
</div>
<div id="ac-purpose-custom-wrap" style="flex: 1 1 250px; max-width: 300px; display: none;">
<label class="block text-xs font-medium text-gray-500 mb-1">직접입력</label>
<input type="text" id="ac-purpose-custom" placeholder="용도를 입력하세요"
class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
</div>
<div style="max-width: 200px;">
<label class="block text-xs font-medium text-gray-500 mb-1">발급일</label>
<input type="text" id="ac-issue-date" readonly
class="w-full px-3 py-2 border border-gray-200 rounded-lg text-sm bg-gray-50 text-gray-700"
value="{{ now()->format('Y-m-d') }}">
</div>
</div>
</div>
</div>
</div>
{{-- 위촉증명서 미리보기 모달 --}}
<div id="appointment-cert-preview-modal" style="display: none;" class="fixed inset-0 z-50">
<div class="absolute inset-0 bg-black/50" onclick="closeAppointmentCertPreview()"></div>
<div class="relative flex items-center justify-center min-h-full p-4">
<div class="bg-white rounded-xl shadow-2xl w-full overflow-hidden relative" style="max-width: 700px;">
<div class="flex items-center justify-between px-5 py-3 border-b border-gray-200 bg-gray-50">
<h3 class="text-base font-semibold text-gray-800">위촉증명서 미리보기</h3>
<div class="flex items-center gap-2">
<button type="button" onclick="printAppointmentCertPreview()"
class="px-3 py-1.5 bg-white border border-gray-300 hover:bg-gray-50 rounded-lg text-xs font-medium transition inline-flex items-center gap-1">
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 17h2a2 2 0 002-2v-4a2 2 0 00-2-2H5a2 2 0 00-2 2v4a2 2 0 002 2h2m2 4h6a2 2 0 002-2v-4a2 2 0 00-2-2H9a2 2 0 00-2 2v4a2 2 0 002 2zm8-12V5a2 2 0 00-2-2H9a2 2 0 00-2 2v4h10z"/>
</svg>
인쇄
</button>
<button type="button" onclick="closeAppointmentCertPreview()"
class="p-1 text-gray-400 hover:text-gray-600 transition">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
</svg>
</button>
</div>
</div>
<div class="overflow-y-auto" style="max-height: 80vh;">
<div id="appointment-cert-preview-content" style="padding: 48px 56px; font-family: 'Pretendard', 'Malgun Gothic', sans-serif;">
</div>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,123 @@
{{--
위촉증명서 읽기전용 렌더링
Props:
$content (array) - approvals.content JSON
--}}
<div class="space-y-4">
{{-- 미리보기 / PDF 다운로드 버튼 --}}
<div class="flex justify-end gap-2">
<button type="button" onclick="openAppointmentCertShowPreview()"
class="px-3 py-1.5 bg-indigo-50 text-indigo-600 hover:bg-indigo-100 border border-indigo-200 rounded-lg text-sm font-medium transition inline-flex items-center gap-1">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/>
</svg>
증명서 미리보기
</button>
<a href="{{ route('api.admin.approvals.appointment-cert-pdf', $approval->id) }}" target="_blank"
class="px-3 py-1.5 bg-green-50 text-green-600 hover:bg-green-100 border border-green-200 rounded-lg text-sm font-medium transition inline-flex items-center gap-1">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
</svg>
PDF 다운로드
</a>
</div>
{{-- 인적사항 --}}
<div class="border border-gray-200 rounded-lg overflow-hidden">
<div class="bg-gray-50 px-4 py-2 border-b border-gray-200">
<h3 class="text-sm font-semibold text-gray-700">인적사항</h3>
</div>
<div class="p-4">
<div class="grid gap-3" style="grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));">
<div>
<span class="text-xs text-gray-500">성명</span>
<div class="text-sm font-medium mt-0.5">{{ $content['name'] ?? '-' }}</div>
</div>
<div>
<span class="text-xs text-gray-500">주민등록번호</span>
<div class="text-sm font-medium mt-0.5">{{ $content['resident_number'] ?? '-' }}</div>
</div>
<div>
<span class="text-xs text-gray-500">소속</span>
<div class="text-sm font-medium mt-0.5">{{ $content['department'] ?? '-' }}</div>
</div>
<div>
<span class="text-xs text-gray-500">연락처</span>
<div class="text-sm font-medium mt-0.5">{{ $content['phone'] ?? '-' }}</div>
</div>
</div>
</div>
</div>
{{-- 위촉정보 --}}
<div class="border border-gray-200 rounded-lg overflow-hidden">
<div class="bg-gray-50 px-4 py-2 border-b border-gray-200">
<h3 class="text-sm font-semibold text-gray-700">위촉정보</h3>
</div>
<div class="p-4">
<div class="grid gap-3" style="grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));">
<div>
<span class="text-xs text-gray-500">위촉(재직)기간</span>
<div class="text-sm font-medium mt-0.5">
{{ $content['hire_date'] ?? '-' }} ~ {{ $content['resign_date'] ?? '현재' }}
</div>
</div>
<div>
<span class="text-xs text-gray-500">계약자격</span>
<div class="text-sm font-medium mt-0.5">{{ $content['contract_type'] ?? '-' }}</div>
</div>
</div>
</div>
</div>
{{-- 발급정보 --}}
<div class="border border-gray-200 rounded-lg overflow-hidden">
<div class="bg-gray-50 px-4 py-2 border-b border-gray-200">
<h3 class="text-sm font-semibold text-gray-700">발급정보</h3>
</div>
<div class="p-4">
<div class="grid gap-3" style="grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));">
<div>
<span class="text-xs text-gray-500">용도</span>
<div class="text-sm font-medium mt-0.5">{{ $content['purpose'] ?? '-' }}</div>
</div>
<div>
<span class="text-xs text-gray-500">발급일</span>
<div class="text-sm font-medium mt-0.5">{{ $content['issue_date'] ?? '-' }}</div>
</div>
</div>
</div>
</div>
</div>
{{-- 미리보기 모달 --}}
<div id="appointment-cert-show-preview-modal" style="display: none;" class="fixed inset-0 z-50">
<div class="absolute inset-0 bg-black/50" onclick="closeAppointmentCertShowPreview()"></div>
<div class="relative flex items-center justify-center min-h-full p-4">
<div class="bg-white rounded-xl shadow-2xl w-full overflow-hidden relative" style="max-width: 700px;">
<div class="flex items-center justify-between px-5 py-3 border-b border-gray-200 bg-gray-50">
<h3 class="text-base font-semibold text-gray-800">위촉증명서 미리보기</h3>
<div class="flex items-center gap-2">
<button type="button" onclick="printAppointmentCertShowPreview()"
class="px-3 py-1.5 bg-white border border-gray-300 hover:bg-gray-50 rounded-lg text-xs font-medium transition inline-flex items-center gap-1">
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 17h2a2 2 0 002-2v-4a2 2 0 00-2-2H5a2 2 0 00-2 2v4a2 2 0 002 2h2m2 4h6a2 2 0 002-2v-4a2 2 0 00-2-2H9a2 2 0 00-2 2v4a2 2 0 002 2zm8-12V5a2 2 0 00-2-2H9a2 2 0 00-2 2v4h10z"/>
</svg>
인쇄
</button>
<button type="button" onclick="closeAppointmentCertShowPreview()"
class="p-1 text-gray-400 hover:text-gray-600 transition">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
</svg>
</button>
</div>
</div>
<div class="overflow-y-auto" style="max-height: 80vh;">
<div id="appointment-cert-show-preview-content" style="padding: 48px 56px; font-family: 'Pretendard', 'Malgun Gothic', sans-serif;">
</div>
</div>
</div>
</div>
</div>

View File

@@ -86,6 +86,8 @@ class="bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded-lg transition
@include('approvals.partials._certificate-show', ['content' => $approval->content])
@elseif(!empty($approval->content) && $approval->form?->code === 'career_cert')
@include('approvals.partials._career-cert-show', ['content' => $approval->content])
@elseif(!empty($approval->content) && $approval->form?->code === 'appointment_cert')
@include('approvals.partials._appointment-cert-show', ['content' => $approval->content])
@elseif($approval->body && preg_match('/<[a-z][\s\S]*>/i', $approval->body))
<div class="prose prose-sm max-w-none text-gray-700">
{!! strip_tags($approval->body, '<p><br><strong><b><em><i><u><s><del><h1><h2><h3><h4><h5><h6><ul><ol><li><blockquote><pre><code><a><span><div><table><thead><tbody><tr><th><td>') !!}
@@ -491,6 +493,74 @@ class="bg-red-600 hover:bg-red-700 text-white px-6 py-2 rounded-lg transition te
// 재직증명서 미리보기 (show 페이지용)
// =========================================================================
@if(!empty($approval->content) && $approval->form?->code === 'appointment_cert')
const _appointmentCertContent = @json($approval->content);
function openAppointmentCertShowPreview() {
const c = _appointmentCertContent;
const issueDate = c.issue_date || '';
const issueDateFormatted = issueDate ? issueDate.replace(/-/g, function(m, i) { return i === 4 ? '년 ' : '월 '; }) + '일' : '-';
const el = document.getElementById('appointment-cert-show-preview-content');
el.innerHTML = _buildAppointmentCertHtml({
name: c.name || '-',
resident: c.resident_number || '-',
department: c.department || '-',
phone: c.phone || '-',
hireDate: c.hire_date || '-',
resignDate: c.resign_date || '현재',
contractType: c.contract_type || '-',
purpose: c.purpose || '-',
issueDateFormatted: issueDateFormatted,
company: c.company_name || '-',
ceoName: c.ceo_name || '-',
});
document.getElementById('appointment-cert-show-preview-modal').style.display = '';
document.body.style.overflow = 'hidden';
}
function closeAppointmentCertShowPreview() {
document.getElementById('appointment-cert-show-preview-modal').style.display = 'none';
document.body.style.overflow = '';
}
function printAppointmentCertShowPreview() {
const content = document.getElementById('appointment-cert-show-preview-content').innerHTML;
const win = window.open('', '_blank', 'width=800,height=1000');
win.document.write('<html><head><title>위촉증명서</title>');
win.document.write('<style>body{font-family:"Pretendard","Malgun Gothic",sans-serif;padding:48px 56px;margin:0;} table{border-collapse:collapse;width:100%;} th,td{border:1px solid #333;padding:10px 14px;font-size:14px;} th{background:#f8f9fa;font-weight:600;text-align:left;white-space:nowrap;width:120px;} @media print{body{padding:40px 48px;}}</style>');
win.document.write('</head><body>');
win.document.write(content);
win.document.write('</body></html>');
win.document.close();
win.onload = function() { win.print(); };
}
function _buildAppointmentCertHtml(d) {
const e = (s) => { const div = document.createElement('div'); div.textContent = s; return div.innerHTML; };
const thStyle = 'border:1px solid #333; padding:10px 14px; background:#f8f9fa; font-weight:600; text-align:left; white-space:nowrap; width:120px; font-size:14px;';
const tdStyle = 'border:1px solid #333; padding:10px 14px; font-size:14px;';
return `
<h1 style="text-align:center; font-size:28px; font-weight:700; letter-spacing:12px; margin-bottom:40px;">위 촉 증 명 서</h1>
<table style="border-collapse:collapse; width:100%; margin-bottom:20px;">
<tr><th style="${thStyle}">성 명</th><td style="${tdStyle}" colspan="3">${e(d.name)}</td></tr>
<tr><th style="${thStyle}">주민등록번호</th><td style="${tdStyle}" colspan="3">${e(d.resident)}</td></tr>
<tr><th style="${thStyle}">소 속</th><td style="${tdStyle}">${e(d.department)}</td><th style="${thStyle}">연 락 처</th><td style="${tdStyle}">${e(d.phone)}</td></tr>
<tr><th style="${thStyle}">위촉(재직)기간</th><td style="${tdStyle}">${e(d.hireDate)} ~ ${e(d.resignDate)}</td><th style="${thStyle}">계약자격</th><td style="${tdStyle}">${e(d.contractType)}</td></tr>
<tr><th style="${thStyle}">용 도</th><td style="${tdStyle}" colspan="3">${e(d.purpose)}</td></tr>
</table>
<p style="text-align:center; font-size:15px; line-height:2; margin:36px 0;">위와 같이 위촉하였음을 증명합니다.</p>
<p style="text-align:center; font-size:15px; font-weight:500; margin-bottom:48px;">${e(d.issueDateFormatted)}</p>
<div style="text-align:center; margin-top:32px;">
<p style="font-size:16px; font-weight:600; margin-bottom:8px;">${e(d.company)}</p>
<p style="font-size:14px; color:#555;">대표이사 &nbsp;&nbsp; ${e(d.ceoName)} &nbsp;&nbsp; (인)</p>
</div>
`;
}
@endif
@if(!empty($approval->content) && $approval->form?->code === 'career_cert')
const _careerCertContent = @json($approval->content);

View File

@@ -977,6 +977,10 @@
Route::get('/career-cert-info/{userId}', [\App\Http\Controllers\Api\Admin\ApprovalApiController::class, 'careerCertInfo'])->name('career-cert-info');
Route::get('/{id}/career-cert-pdf', [\App\Http\Controllers\Api\Admin\ApprovalApiController::class, 'careerCertPdf'])->name('career-cert-pdf');
// 위촉증명서
Route::get('/appointment-cert-info/{userId}', [\App\Http\Controllers\Api\Admin\ApprovalApiController::class, 'appointmentCertInfo'])->name('appointment-cert-info');
Route::get('/{id}/appointment-cert-pdf', [\App\Http\Controllers\Api\Admin\ApprovalApiController::class, 'appointmentCertPdf'])->name('appointment-cert-pdf');
// CRUD
Route::post('/', [\App\Http\Controllers\Api\Admin\ApprovalApiController::class, 'store'])->name('store');
Route::get('/{id}', [\App\Http\Controllers\Api\Admin\ApprovalApiController::class, 'show'])->name('show');