diff --git a/resources/views/hr/leaves/index.blade.php b/resources/views/hr/leaves/index.blade.php index e6948fc8..e866475a 100644 --- a/resources/views/hr/leaves/index.blade.php +++ b/resources/views/hr/leaves/index.blade.php @@ -756,6 +756,50 @@ function cancelLeave(id) { .catch(() => showToast('네트워크 오류가 발생했습니다.', 'error')); } + function deleteLeave(id) { + if (!confirm('삭제하시겠습니까?')) return; + + fetch('{{ url("/api/admin/hr/leaves") }}/' + id, { + method: 'DELETE', + headers: { + 'Accept': 'application/json', + 'X-CSRF-TOKEN': '{{ csrf_token() }}' + } + }) + .then(r => r.json()) + .then(res => { + if (res.success) { + refreshTable(); + showToast(res.message, 'success'); + } else { + showToast(res.message || '삭제 실패', 'error'); + } + }) + .catch(() => showToast('네트워크 오류가 발생했습니다.', 'error')); + } + + function forceDeleteLeave(id) { + if (!confirm('영구 삭제하시겠습니까?\n이 작업은 되돌릴 수 없으며, 연결된 결재 기록도 함께 삭제됩니다.')) return; + + fetch('{{ url("/api/admin/hr/leaves") }}/' + id + '?force=1', { + method: 'DELETE', + headers: { + 'Accept': 'application/json', + 'X-CSRF-TOKEN': '{{ csrf_token() }}' + } + }) + .then(r => r.json()) + .then(res => { + if (res.success) { + refreshTable(); + showToast(res.message, 'success'); + } else { + showToast(res.message || '영구 삭제 실패', 'error'); + } + }) + .catch(() => showToast('네트워크 오류가 발생했습니다.', 'error')); + } + // ===== 토스트 ===== function showToast(message, type) { if (typeof window.showToastNotification === 'function') {