From 58991e352ef220ab55b2a1bcf9596fc7cd1b1bdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Wed, 11 Mar 2026 16:18:37 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20[esign]=20=EA=B7=BC=EB=A1=9C=EA=B3=84?= =?UTF-8?q?=EC=95=BD=EC=84=9C=20=EC=82=AC=EC=9B=90=20=EB=B6=88=EB=9F=AC?= =?UTF-8?q?=EC=98=A4=EA=B8=B0=20=EC=8B=9C=20=EC=A3=BC=EC=86=8C,=20?= =?UTF-8?q?=EC=83=9D=EB=85=84=EC=9B=94=EC=9D=BC,=20=EA=B3=84=EC=95=BD?= =?UTF-8?q?=EC=9D=BC=20=EC=9E=90=EB=8F=99=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 주민등록번호에서 출생년도/월/일 분리 (세기 자동 판별) - 입사일 기반 계약일, 근로계약시작일, 연봉계약시작일 자동 반영 - 연봉계약종료일은 입사일 + 1년으로 계산 - 사원 주소, 계약자 이름 자동 매핑 추가 --- .../Controllers/ESign/EsignApiController.php | 41 +++++++++++++------ resources/views/esign/create.blade.php | 37 +++++++++++++++++ 2 files changed, 66 insertions(+), 12 deletions(-) diff --git a/app/Http/Controllers/ESign/EsignApiController.php b/app/Http/Controllers/ESign/EsignApiController.php index ff859641..3b0ac22e 100644 --- a/app/Http/Controllers/ESign/EsignApiController.php +++ b/app/Http/Controllers/ESign/EsignApiController.php @@ -98,18 +98,35 @@ public function searchEmployees(Request $request): JsonResponse $employees = $query->limit(20)->get(); - $data = $employees->map(fn ($emp) => [ - 'id' => $emp->id, - 'name' => $emp->user?->name, - 'phone' => $emp->user?->phone, - 'email' => $emp->user?->email, - 'department' => $emp->department?->name, - 'position' => $emp->position_label, - 'job_title' => $emp->job_title_label, - 'address' => $emp->address, - 'hire_date' => $emp->hire_date, - 'birth_year' => $emp->resident_number ? ('19'.substr($emp->resident_number, 0, 2)) : null, - ]); + $data = $employees->map(function ($emp) { + $rn = $emp->resident_number; + $birthYear = null; + $birthMonth = null; + $birthDay = null; + + if ($rn && strlen($rn) >= 7) { + $genderDigit = substr($rn, 6, 1); + $prefix = in_array($genderDigit, ['3', '4', '7', '8']) ? '20' : '19'; + $birthYear = $prefix.substr($rn, 0, 2); + $birthMonth = substr($rn, 2, 2); + $birthDay = substr($rn, 4, 2); + } + + return [ + 'id' => $emp->id, + 'name' => $emp->user?->name, + 'phone' => $emp->user?->phone, + 'email' => $emp->user?->email, + 'department' => $emp->department?->name, + 'position' => $emp->position_label, + 'job_title' => $emp->job_title_label, + 'address' => $emp->address, + 'hire_date' => $emp->hire_date, + 'birth_year' => $birthYear, + 'birth_month' => $birthMonth, + 'birth_day' => $birthDay, + ]; + }); return response()->json(['success' => true, 'data' => $data]); } diff --git a/resources/views/esign/create.blade.php b/resources/views/esign/create.blade.php index a181331b..6ea6d5a8 100644 --- a/resources/views/esign/create.blade.php +++ b/resources/views/esign/create.blade.php @@ -950,9 +950,30 @@ className={`w-full text-left px-3 py-2.5 rounded-lg mb-1 transition-colors ${i = // 사원 선택 시 근로계약서 변수 자동 채우기 const handleEmployeeSelect = (emp) => { + // 입사일에서 년/월/일 분리 + let hireYear = '', hireMonth = '', hireDay = ''; + let endYear = '', endMonth = '', endDay = ''; + if (emp.hire_date) { + const hd = emp.hire_date.replace(/-/g, ''); + if (hd.length >= 8) { + hireYear = hd.substring(0, 4); + hireMonth = hd.substring(4, 6); + hireDay = hd.substring(6, 8); + // 1년 후 계산 + const endDate = new Date(parseInt(hireYear), parseInt(hireMonth) - 1, parseInt(hireDay)); + endDate.setFullYear(endDate.getFullYear() + 1); + endYear = String(endDate.getFullYear()); + endMonth = String(endDate.getMonth() + 1).padStart(2, '0'); + endDay = String(endDate.getDate()).padStart(2, '0'); + } + } + const labelMap = { '직원.*주소': emp.address, + '주소': emp.address, '출생.*년도': emp.birth_year, + '출생.*월$': emp.birth_month, + '출생.*일$': emp.birth_day, '부서': emp.department, '직책': emp.position, '직위': emp.job_title || emp.position, @@ -964,6 +985,22 @@ className={`w-full text-left px-3 py-2.5 rounded-lg mb-1 transition-colors ${i = '근로자.*이름': emp.name, '근로자.*성명': emp.name, '입사.*일': emp.hire_date, + // 계약일 = 입사일 + '계약.*연도': hireYear, + '계약.*월$': hireMonth, + '계약.*일$': hireDay, + // 근로계약 시작일 = 입사일 + '근로계약.*시작.*년도': hireYear, + '근로계약.*시작.*월$': hireMonth, + '근로계약.*시작.*일$': hireDay, + // 연봉계약 시작일 = 입사일 + '연봉계약.*시작.*년도': hireYear, + '연봉계약.*시작.*월$': hireMonth, + '연봉계약.*시작.*일$': hireDay, + // 연봉계약 종료일 = 입사일 + 1년 + '연봉계약.*종료.*년도': endYear, + '연봉계약.*종료.*월$': endMonth, + '연봉계약.*종료.*일$': endDay, }; setMetadata(prev => {