diff --git a/resources/views/approvals/create.blade.php b/resources/views/approvals/create.blade.php index 1260082f..dde30bcf 100644 --- a/resources/views/approvals/create.blade.php +++ b/resources/views/approvals/create.blade.php @@ -901,6 +901,109 @@ function getCertPurpose() { return sel.value; } +function openCertPreview() { + const name = document.getElementById('cert-name').value || '-'; + const resident = document.getElementById('cert-resident').value || '-'; + const address = document.getElementById('cert-address').value || '-'; + const company = document.getElementById('cert-company').value || '-'; + const businessNum = document.getElementById('cert-business-num').value || '-'; + const department = document.getElementById('cert-department').value || '-'; + const position = document.getElementById('cert-position').value || '-'; + const hireDate = document.getElementById('cert-hire-date').value || '-'; + const purpose = getCertPurpose() || '-'; + const issueDate = document.getElementById('cert-issue-date').value || '-'; + const issueDateFormatted = issueDate !== '-' ? issueDate.replace(/-/g, function(m, i) { return i === 4 ? '년 ' : '월 '; }) + '일' : '-'; + + const el = document.getElementById('cert-preview-content'); + el.innerHTML = buildCertPreviewHtml({ name, resident, address, company, businessNum, department, position, hireDate, purpose, issueDateFormatted }); + + document.getElementById('cert-preview-modal').style.display = ''; + document.body.style.overflow = 'hidden'; +} + +function closeCertPreview() { + document.getElementById('cert-preview-modal').style.display = 'none'; + document.body.style.overflow = ''; +} + +function printCertPreview() { + const content = document.getElementById('cert-preview-content').innerHTML; + const win = window.open('', '_blank', 'width=800,height=1000'); + win.document.write('재직증명서'); + win.document.write(''); + win.document.write(''); + win.document.write(content); + win.document.write(''); + win.document.close(); + win.onload = function() { win.print(); }; +} + +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;'; + const tdStyle = 'border:1px solid #333; padding:10px 14px; font-size:14px;'; + + return ` +

재 직 증 명 서

+ +

1. 인적사항

+ + + + + + + + + + + +
성 명${e(d.name)}주민등록번호${e(d.resident)}
주 소${e(d.address)}
+ +

2. 재직사항

+ + + + + + + + + + + + + + + + + + + +
회 사 명${e(d.company)}
사업자번호${e(d.businessNum)}
근무부서${e(d.department)}직 급${e(d.position)}
재직기간${e(d.hireDate)}
+ +

3. 발급정보

+ + + + + +
사용용도${e(d.purpose)}
+ +

+ 위 사항을 증명합니다. +

+ +

+ ${e(d.issueDateFormatted)} +

+ +
+

${e(d.company)}

+

대표이사            (인)

+
+ `; +} @endpush diff --git a/resources/views/approvals/edit.blade.php b/resources/views/approvals/edit.blade.php index 643d9b04..905265c5 100644 --- a/resources/views/approvals/edit.blade.php +++ b/resources/views/approvals/edit.blade.php @@ -763,5 +763,110 @@ function getCertPurpose() { } return sel.value; } + +function openCertPreview() { + const name = document.getElementById('cert-name').value || '-'; + const resident = document.getElementById('cert-resident').value || '-'; + const address = document.getElementById('cert-address').value || '-'; + const company = document.getElementById('cert-company').value || '-'; + const businessNum = document.getElementById('cert-business-num').value || '-'; + const department = document.getElementById('cert-department').value || '-'; + const position = document.getElementById('cert-position').value || '-'; + const hireDate = document.getElementById('cert-hire-date').value || '-'; + const purpose = getCertPurpose() || '-'; + const issueDate = document.getElementById('cert-issue-date').value || '-'; + + const issueDateFormatted = issueDate !== '-' ? issueDate.replace(/-/g, function(m, i) { return i === 4 ? '년 ' : '월 '; }) + '일' : '-'; + + const el = document.getElementById('cert-preview-content'); + el.innerHTML = buildCertPreviewHtml({ name, resident, address, company, businessNum, department, position, hireDate, purpose, issueDateFormatted }); + + document.getElementById('cert-preview-modal').style.display = ''; + document.body.style.overflow = 'hidden'; +} + +function closeCertPreview() { + document.getElementById('cert-preview-modal').style.display = 'none'; + document.body.style.overflow = ''; +} + +function printCertPreview() { + const content = document.getElementById('cert-preview-content').innerHTML; + const win = window.open('', '_blank', 'width=800,height=1000'); + win.document.write('재직증명서'); + win.document.write(''); + win.document.write(''); + win.document.write(content); + win.document.write(''); + win.document.close(); + win.onload = function() { win.print(); }; +} + +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;'; + const tdStyle = 'border:1px solid #333; padding:10px 14px; font-size:14px;'; + + return ` +

재 직 증 명 서

+ +

1. 인적사항

+ + + + + + + + + + + +
성 명${e(d.name)}주민등록번호${e(d.resident)}
주 소${e(d.address)}
+ +

2. 재직사항

+ + + + + + + + + + + + + + + + + + + +
회 사 명${e(d.company)}
사업자번호${e(d.businessNum)}
근무부서${e(d.department)}직 급${e(d.position)}
재직기간${e(d.hireDate)}
+ +

3. 발급정보

+ + + + + +
사용용도${e(d.purpose)}
+ +

+ 위 사항을 증명합니다. +

+ +

+ ${e(d.issueDateFormatted)} +

+ +
+

${e(d.company)}

+

대표이사            (인)

+
+ `; +} @endpush diff --git a/resources/views/approvals/partials/_certificate-form.blade.php b/resources/views/approvals/partials/_certificate-form.blade.php index 4f71c182..fcabdddb 100644 --- a/resources/views/approvals/partials/_certificate-form.blade.php +++ b/resources/views/approvals/partials/_certificate-form.blade.php @@ -13,15 +13,25 @@ {{-- 대상 사원 --}}
- +
+ + +
{{-- 인적사항 --}} @@ -122,3 +132,35 @@ class="w-full px-3 py-2 border border-gray-200 rounded-lg text-sm bg-gray-50 tex + +{{-- 재직증명서 미리보기 모달 --}} + diff --git a/resources/views/approvals/partials/_certificate-show.blade.php b/resources/views/approvals/partials/_certificate-show.blade.php index dabc20da..7f777f92 100644 --- a/resources/views/approvals/partials/_certificate-show.blade.php +++ b/resources/views/approvals/partials/_certificate-show.blade.php @@ -4,6 +4,18 @@ $content (array) - approvals.content JSON --}}
+ {{-- 미리보기 버튼 --}} +
+ +
+ {{-- 인적사항 --}}
@@ -99,3 +111,34 @@
@endif
+ +{{-- 미리보기 모달 --}} + diff --git a/resources/views/approvals/show.blade.php b/resources/views/approvals/show.blade.php index 8084a646..b36520a2 100644 --- a/resources/views/approvals/show.blade.php +++ b/resources/views/approvals/show.blade.php @@ -484,5 +484,85 @@ class="bg-red-600 hover:bg-red-700 text-white px-6 py-2 rounded-lg transition te showToast('서버 오류가 발생했습니다.', 'error'); } } + +// ========================================================================= +// 재직증명서 미리보기 (show 페이지용) +// ========================================================================= + +@if(!empty($approval->content) && $approval->form?->code === 'employment_cert') +const _certContent = @json($approval->content); + +function openCertShowPreview() { + const c = _certContent; + const issueDate = c.issue_date || ''; + const issueDateFormatted = issueDate ? issueDate.replace(/-/g, function(m, i) { return i === 4 ? '년 ' : '월 '; }) + '일' : '-'; + + const el = document.getElementById('cert-show-preview-content'); + el.innerHTML = _buildCertHtml({ + name: c.name || '-', + resident: c.resident_number || '-', + address: c.address || '-', + company: c.company_name || '-', + businessNum: c.business_num || '-', + department: c.department || '-', + position: c.position || '-', + hireDate: c.hire_date || '-', + purpose: c.purpose || '-', + issueDateFormatted: issueDateFormatted, + }); + + document.getElementById('cert-show-preview-modal').style.display = ''; + document.body.style.overflow = 'hidden'; +} + +function closeCertShowPreview() { + document.getElementById('cert-show-preview-modal').style.display = 'none'; + document.body.style.overflow = ''; +} + +function printCertShowPreview() { + const content = document.getElementById('cert-show-preview-content').innerHTML; + const win = window.open('', '_blank', 'width=800,height=1000'); + win.document.write('재직증명서'); + win.document.write(''); + win.document.write(''); + win.document.write(content); + win.document.write(''); + win.document.close(); + win.onload = function() { win.print(); }; +} + +function _buildCertHtml(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 ` +

재 직 증 명 서

+

1. 인적사항

+ + + +
성 명${e(d.name)}주민등록번호${e(d.resident)}
주 소${e(d.address)}
+

2. 재직사항

+ + + + + +
회 사 명${e(d.company)}
사업자번호${e(d.businessNum)}
근무부서${e(d.department)}직 급${e(d.position)}
재직기간${e(d.hireDate)}
+

3. 발급정보

+ + +
사용용도${e(d.purpose)}
+

위 사항을 증명합니다.

+

${e(d.issueDateFormatted)}

+
+

${e(d.company)}

+

대표이사            (인)

+
+ `; +} +@endif @endpush