diff --git a/app/Http/Controllers/TenantSettingController.php b/app/Http/Controllers/TenantSettingController.php index ecf362a3..524fa93c 100644 --- a/app/Http/Controllers/TenantSettingController.php +++ b/app/Http/Controllers/TenantSettingController.php @@ -14,7 +14,7 @@ class TenantSettingController extends Controller { /** - * 설정 목록 (재고 설정 페이지) + * 설정 목록 (재고 설정 + 회사 표시명 설정) */ public function index(Request $request): View|Response { @@ -30,21 +30,25 @@ public function index(Request $request): View|Response $itemTypeLabels = $tenantId ? CommonCode::getItemTypes($tenantId) : []; // 테넌트 미선택 시 빈 설정 - $stockSettings = collect(); + $allSettings = collect(); if ($tenantId) { - $stockSettings = TenantSetting::withoutGlobalScopes() + $allSettings = TenantSetting::withoutGlobalScopes() ->where('tenant_id', $tenantId) - ->where('setting_group', 'stock') - ->get() - ->keyBy('setting_key'); + ->get(); } - // 설정값 (저장된 값이 없으면 빈 배열/기본값) + $stockSettings = $allSettings->where('setting_group', 'stock')->keyBy('setting_key'); + $companySettings = $allSettings->where('setting_group', 'company')->keyBy('setting_key'); + + // 재고 설정값 $hasSettings = $stockSettings->isNotEmpty(); $stockItemTypes = $stockSettings->get('stock_item_types')?->setting_value ?? []; $defaultSafetyStock = $stockSettings->get('default_safety_stock')?->setting_value ?? 10; $lowStockAlert = $stockSettings->get('low_stock_alert')?->setting_value ?? true; + // 회사 표시명 설정값 + $displayCompanyName = $companySettings->get('display_company_name')?->setting_value ?? ''; + return view('tenant-settings.index', [ 'tenant' => $tenant, 'hasSettings' => $hasSettings, @@ -52,6 +56,7 @@ public function index(Request $request): View|Response 'stockItemTypes' => $stockItemTypes, 'defaultSafetyStock' => $defaultSafetyStock, 'lowStockAlert' => $lowStockAlert, + 'displayCompanyName' => $displayCompanyName, ]); } @@ -77,6 +82,7 @@ public function store(Request $request): RedirectResponse 'stock_item_types.*' => 'string|in:'.implode(',', $validItemTypes), 'default_safety_stock' => 'required|integer|min:0|max:9999', 'low_stock_alert' => 'nullable|boolean', + 'display_company_name' => 'nullable|string|max:100', ]); // 재고관리 품목유형 저장 @@ -121,6 +127,20 @@ public function store(Request $request): RedirectResponse ] ); + // 회사 표시명 저장 + TenantSetting::withoutGlobalScopes()->updateOrCreate( + [ + 'tenant_id' => $tenantId, + 'setting_group' => 'company', + 'setting_key' => 'display_company_name', + ], + [ + 'setting_value' => trim($validated['display_company_name'] ?? ''), + 'description' => '문서에 인쇄되는 회사 표시명', + 'updated_by' => $userId, + ] + ); + return redirect()->route('tenant-settings.index') ->with('success', '설정이 저장되었습니다.'); } diff --git a/app/Services/EmploymentCertService.php b/app/Services/EmploymentCertService.php index 3da83705..a22e8e27 100644 --- a/app/Services/EmploymentCertService.php +++ b/app/Services/EmploymentCertService.php @@ -4,6 +4,7 @@ use App\Models\HR\Employee; use App\Models\Tenants\Tenant; +use App\Models\Tenants\TenantSetting; use Illuminate\Support\Facades\Log; class EmploymentCertService @@ -33,6 +34,15 @@ public function getCertInfo(int $userId, int $tenantId): array $tenant = Tenant::findOrFail($tenantId); + // 인쇄용 회사 표시명 조회 (설정 없으면 기본 company_name 사용) + $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 = $residentNumber ? substr($residentNumber, 0, 8).'******' @@ -46,7 +56,7 @@ public function getCertInfo(int $userId, int $tenantId): array 'department' => $employee->department?->name ?? '', 'position' => $employee->position_label ?? '', 'hire_date' => $employee->hire_date ?? '', - 'company_name' => $tenant->company_name ?? '', + 'company_name' => $companyName, 'business_num' => $tenant->business_num ?? '', 'ceo_name' => $tenant->ceo_name ?? '', 'phone' => $tenant->phone ?? '', diff --git a/resources/views/tenant-settings/index.blade.php b/resources/views/tenant-settings/index.blade.php index 82febc3e..257a506a 100644 --- a/resources/views/tenant-settings/index.blade.php +++ b/resources/views/tenant-settings/index.blade.php @@ -63,6 +63,36 @@ @csrf
재직증명서 등 문서 인쇄 시 사용
++ 비워두면 기본 회사명({{ $tenant?->company_name ?? '-' }})이 사용됩니다. +
+