feat:영업/매니저 버튼 및 프로그레스바 역할별 표시

- 다른 매니저 지정 시: 등록자에게 매니저 버튼/프로그레스바 숨김
- 매니저로만 참여 시: 영업 버튼/프로그레스바 숨김
- 본인 역할에 해당하는 영역만 표시

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
김보곤
2026-02-02 14:32:59 +09:00
parent 3688e76bb8
commit 6ca48c3f93

View File

@@ -92,6 +92,17 @@
$prospectHqStatusOrder = \App\Models\Sales\SalesTenantManagement::$hqStatusOrder;
$prospectCurrentHqStep = $prospectHqStatusOrder[$prospectManagement->hq_status ?? 'pending'] ?? 0;
$isProspectHqEnabled = $prospectProgress['sales']['percentage'] >= 100 && $prospectProgress['manager']['percentage'] >= 100;
// 현재 사용자의 역할 확인
$currentUserId = auth()->id();
$isRegistrar = $prospect->registered_by === $currentUserId; // 영업권 등록자
$isManager = $prospectManagement->manager_user_id === $currentUserId; // 담당 매니저
$hasDifferentManager = $prospectManagement->manager_user_id && $prospectManagement->manager_user_id !== $currentUserId;
// 버튼 표시 여부
$showSalesButton = $isRegistrar; // 등록자만 영업 버튼
$showManagerButton = $isManager || (!$hasDifferentManager && $isRegistrar); // 매니저이거나, 다른 매니저 미지정 시 등록자
$showManagerProgress = $showManagerButton; // 매니저 프로그레스바도 동일
@endphp
<div class="prospect-row flex items-center gap-4 px-4 py-3 hover:bg-orange-50 transition-colors" data-prospect-id="{{ $prospect->id }}">
<!-- 업체명 정보 + 매니저 드롭다운 + 영업/매니저 버튼 -->
@@ -117,6 +128,7 @@
</div>
{{-- 영업/매니저 진행 버튼 --}}
<div class="flex-shrink-0 flex items-center gap-1">
@if($showSalesButton)
<button
x-on:click="openProspectScenarioModal({{ $prospect->id }}, 'sales')"
class="inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium bg-blue-600 text-white hover:bg-blue-700 transition-colors"
@@ -126,6 +138,8 @@ class="inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium bg-b
</svg>
영업
</button>
@endif
@if($showManagerButton)
<button
x-on:click="openProspectScenarioModal({{ $prospect->id }}, 'manager')"
class="inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium bg-green-600 text-white hover:bg-green-700 transition-colors"
@@ -135,14 +149,16 @@ class="inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium bg-g
</svg>
매니저
</button>
@endif
</div>
</div>
<!-- 진행 현황 (영업/매니저 프로그레스 ) -->
<div class="flex-1 min-w-0 flex items-center gap-4" id="prospect-progress-{{ $prospect->id }}">
{{-- 영업/매니저 프로그레스 (절반) --}}
{{-- 영업/매니저 프로그레스 --}}
<div class="flex-1 space-y-1">
{{-- 영업 --}}
{{-- 영업 (등록자에게만 표시) --}}
@if($showSalesButton)
<div class="flex items-center gap-1" title="영업 {{ $prospectProgress['sales']['percentage'] }}%">
<span class="text-xs font-medium text-blue-600 w-5 flex-shrink-0"></span>
<div class="flex-1 bg-gray-200 rounded-full h-1.5 min-w-0">
@@ -150,7 +166,9 @@ class="inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium bg-g
</div>
<span class="text-xs text-gray-500 w-8 text-right flex-shrink-0" id="prospect-sales-pct-{{ $prospect->id }}">{{ $prospectProgress['sales']['percentage'] }}%</span>
</div>
{{-- 매니저 --}}
@endif
{{-- 매니저 (매니저에게만 표시) --}}
@if($showManagerProgress)
<div class="flex items-center gap-1" title="매니저 {{ $prospectProgress['manager']['percentage'] }}%">
<span class="text-xs font-medium text-green-600 w-5 flex-shrink-0"></span>
<div class="flex-1 bg-gray-200 rounded-full h-1.5 min-w-0">
@@ -158,6 +176,7 @@ class="inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium bg-g
</div>
<span class="text-xs text-gray-500 w-8 text-right flex-shrink-0" id="prospect-manager-pct-{{ $prospect->id }}">{{ $prospectProgress['manager']['percentage'] }}%</span>
</div>
@endif
</div>
{{-- 구분선 --}}
@@ -426,6 +445,19 @@ class="inline-flex items-center gap-1 px-3 py-1.5 rounded text-xs font-medium bg
$totalRegFee = $contractTotals->total_registration_fee ?? 0;
$totalSubFee = $contractTotals->total_subscription_fee ?? 0;
$productCount = $contractTotals->product_count ?? 0;
// 현재 사용자의 역할 확인 (tenant 기준 - registered_by는 연결된 prospect에서 확인)
$currentUserId = auth()->id();
// 테넌트와 연결된 prospect 조회
$linkedProspect = \App\Models\Sales\TenantProspect::where('tenant_id', $tenant->id)->first();
$tenantIsRegistrar = $linkedProspect && $linkedProspect->registered_by === $currentUserId;
$tenantIsManager = $management->manager_user_id === $currentUserId;
$tenantHasDifferentManager = $management->manager_user_id && $management->manager_user_id !== $currentUserId;
// 버튼 표시 여부
$tenantShowSalesButton = $tenantIsRegistrar;
$tenantShowManagerButton = $tenantIsManager || (!$tenantHasDifferentManager && $tenantIsRegistrar);
$tenantShowManagerProgress = $tenantShowManagerButton;
@endphp
<div class="tenant-row" data-tenant-id="{{ $tenant->id }}">
<!-- 메인 -->
@@ -448,6 +480,7 @@ class="inline-flex items-center gap-1 px-3 py-1.5 rounded text-xs font-medium bg
</div>
{{-- 영업/매니저 진행 버튼 --}}
<div class="flex-shrink-0 flex items-center gap-1">
@if($tenantShowSalesButton)
<button
x-on:click="openScenarioModal({{ $tenant->id }}, 'sales')"
class="inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium bg-blue-600 text-white hover:bg-blue-700 transition-colors"
@@ -457,6 +490,8 @@ class="inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium bg-b
</svg>
영업
</button>
@endif
@if($tenantShowManagerButton)
<button
x-on:click="openScenarioModal({{ $tenant->id }}, 'manager')"
class="inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium bg-green-600 text-white hover:bg-green-700 transition-colors"
@@ -466,14 +501,16 @@ class="inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium bg-g
</svg>
매니저
</button>
@endif
</div>
</div>
<!-- 진행 현황 (영업/매니저 | 개발 진행) -->
<div class="flex-1 min-w-0 flex items-center gap-4" id="progress-{{ $tenant->id }}">
{{-- 좌측: 영업/매니저 프로그레스 (절반) --}}
{{-- 좌측: 영업/매니저 프로그레스 --}}
<div class="flex-1 space-y-1">
{{-- 영업 --}}
{{-- 영업 (등록자에게만 표시) --}}
@if($tenantShowSalesButton)
<div class="flex items-center gap-1" title="영업 {{ $progress['sales']['percentage'] }}%">
<span class="text-xs font-medium text-blue-600 w-5 flex-shrink-0"></span>
<div class="flex-1 bg-gray-200 rounded-full h-1.5 min-w-0">
@@ -481,7 +518,9 @@ class="inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium bg-g
</div>
<span class="text-xs text-gray-500 w-8 text-right flex-shrink-0" id="sales-pct-{{ $tenant->id }}">{{ $progress['sales']['percentage'] }}%</span>
</div>
{{-- 매니저 --}}
@endif
{{-- 매니저 (매니저에게만 표시) --}}
@if($tenantShowManagerProgress)
<div class="flex items-center gap-1" title="매니저 {{ $progress['manager']['percentage'] }}%">
<span class="text-xs font-medium text-green-600 w-5 flex-shrink-0"></span>
<div class="flex-1 bg-gray-200 rounded-full h-1.5 min-w-0">
@@ -489,6 +528,7 @@ class="inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium bg-g
</div>
<span class="text-xs text-gray-500 w-8 text-right flex-shrink-0" id="manager-pct-{{ $tenant->id }}">{{ $progress['manager']['percentage'] }}%</span>
</div>
@endif
</div>
{{-- 구분선 --}}