diff --git a/app/Http/Controllers/Sales/SalesDashboardController.php b/app/Http/Controllers/Sales/SalesDashboardController.php index a61747f7..e9c92520 100644 --- a/app/Http/Controllers/Sales/SalesDashboardController.php +++ b/app/Http/Controllers/Sales/SalesDashboardController.php @@ -896,6 +896,16 @@ public function helpGuide(): View return view('sales.dashboard.partials.help-modal', compact('htmlContent')); } + /** + * 가망고객 개별 행 반환 (HTMX 동적 업데이트용) + */ + public function getProspectRow(int $prospectId): View + { + $prospect = TenantProspect::findOrFail($prospectId); + + return view('sales.dashboard.partials.prospect-row', compact('prospect')); + } + /** * 예상 수당 요약 계산 (개발 진행중 + 인계완료 미지급) */ diff --git a/resources/views/sales/dashboard/partials/manager-dropdown.blade.php b/resources/views/sales/dashboard/partials/manager-dropdown.blade.php index 854dc545..88976814 100644 --- a/resources/views/sales/dashboard/partials/manager-dropdown.blade.php +++ b/resources/views/sales/dashboard/partials/manager-dropdown.blade.php @@ -112,6 +112,16 @@ email: managerEmail || '', is_self: managerId === 0 || result.manager.id === {{ auth()->id() }}, }; + // 동적 UI 업데이트: HTMX로 해당 행만 새로고침 + if (this.isProspect) { + const row = document.querySelector(`.prospect-row[data-prospect-id="${this.entityId}"]`); + if (row) { + htmx.ajax('GET', `/sales/salesmanagement/dashboard/prospect/${this.entityId}/row`, { + target: row, + swap: 'outerHTML' + }); + } + } } else { alert(result.message || '매니저 지정에 실패했습니다.'); } diff --git a/resources/views/sales/dashboard/partials/prospect-row.blade.php b/resources/views/sales/dashboard/partials/prospect-row.blade.php new file mode 100644 index 00000000..7269c5dc --- /dev/null +++ b/resources/views/sales/dashboard/partials/prospect-row.blade.php @@ -0,0 +1,208 @@ +{{-- 가망고객 개별 행 (영업 진행중) --}} +@php + $prospectProgress = \App\Models\Sales\SalesScenarioChecklist::getProspectProgress($prospect->id); + $prospectManagement = \App\Models\Sales\SalesTenantManagement::findOrCreateByProspect($prospect->id); + + // 계약 금액 정보 조회 (management_id 기반) + $prospectContractTotals = \App\Models\Sales\SalesContractProduct::where('management_id', $prospectManagement->id) + ->selectRaw('SUM(registration_fee) as total_registration_fee, SUM(subscription_fee) as total_subscription_fee, COUNT(*) as product_count') + ->first(); + $prospectTotalRegFee = $prospectContractTotals->total_registration_fee ?? 0; + $prospectTotalSubFee = $prospectContractTotals->total_subscription_fee ?? 0; + $prospectProductCount = $prospectContractTotals->product_count ?? 0; + + // 개발 진행 상태 (100% 완료 시 표시) + $prospectHqStatuses = \App\Models\Sales\SalesTenantManagement::$hqStatusLabels; + $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 +
+ +
+
+
+
{{ $prospect->company_name }}
+ + {{ $prospect->status_label }} + +
+
+ @if($prospect->ceo_name) + 대표: {{ $prospect->ceo_name }} + | + @endif + {{ $prospect->business_number ?? '-' }} +
+
+ {{-- 매니저 드롭다운 --}} +
+ @include('sales.dashboard.partials.manager-dropdown', ['prospect' => $prospect, 'prospectManagement' => $prospectManagement]) +
+ {{-- 영업/매니저 진행 버튼 --}} +
+ @if($showSalesButton) + + @endif + @if($showManagerButton) + + @endif +
+
+ + +
+ {{-- 영업/매니저 프로그레스 바 --}} +
+ {{-- 영업 (등록자에게만 표시) --}} + @if($showSalesButton) +
+ +
+
+
+ {{ $prospectProgress['sales']['percentage'] }}% +
+ @endif + {{-- 매니저 (매니저에게만 표시) --}} + @if($showManagerProgress) +
+ +
+
+
+ {{ $prospectProgress['manager']['percentage'] }}% +
+ @endif +
+ + {{-- 구분선 --}} +
+ + {{-- 개발 진행 상태 --}} +
+ @if($isProspectHqEnabled) + {{-- 영업/매니저 100% 완료: 개발 진행 상태 표시 --}} +
+ {{-- 8단계 프로그레스 바 --}} +
+
+ @foreach($prospectHqStatuses as $statusKey => $statusLabel) + @php + $stepNum = $prospectHqStatusOrder[$statusKey]; + $isCompleted = $stepNum < $prospectCurrentHqStep; + $isCurrent = $stepNum === $prospectCurrentHqStep; + @endphp +
+
+
+ {{ $statusLabel }} +
+
+ @endforeach +
+
+ {{-- 현재 상태 배지 --}} + + {{ $prospectManagement->hq_status_label }} + +
+ @else + {{-- 아직 100% 미완료: 비활성 상태 --}} +
+ {{-- 비활성 프로그래스 바 --}} +
+
+ @for($i = 0; $i < 8; $i++) +
+ @endfor +
+
+ {{-- 대기 배지 --}} + + 영업 진행중 + +
+ @endif +
+
+ + +
+ @if($prospectProductCount > 0) +
+
+

개발비

+

₩{{ number_format($prospectTotalRegFee) }}

+
+
+

월 구독료

+

₩{{ number_format($prospectTotalSubFee) }}

+
+
+ @else +
+

계약상품

+

미선택

+
+ @endif +
+ + + @php + $isFullyCompleted = $prospectProgress['sales']['percentage'] >= 100 && $prospectProgress['manager']['percentage'] >= 100; + @endphp + @if(!$isFullyCompleted) +
+ @if($prospect->isActive()) +
영업권 만료
+
D-{{ $prospect->remaining_days }}
+ @elseif($prospect->isExpired()) +
상태
+
만료됨
+ @endif +
+ @endif + + +
+ + + + + + 상세 + +
+
diff --git a/resources/views/sales/dashboard/partials/tenant-list.blade.php b/resources/views/sales/dashboard/partials/tenant-list.blade.php index 6aff4fe9..07e7852f 100644 --- a/resources/views/sales/dashboard/partials/tenant-list.blade.php +++ b/resources/views/sales/dashboard/partials/tenant-list.blade.php @@ -76,213 +76,7 @@
@foreach($prospects as $prospect) - @php - $prospectProgress = \App\Models\Sales\SalesScenarioChecklist::getProspectProgress($prospect->id); - $prospectManagement = \App\Models\Sales\SalesTenantManagement::findOrCreateByProspect($prospect->id); - - // 계약 금액 정보 조회 (management_id 기반) - $prospectContractTotals = \App\Models\Sales\SalesContractProduct::where('management_id', $prospectManagement->id) - ->selectRaw('SUM(registration_fee) as total_registration_fee, SUM(subscription_fee) as total_subscription_fee, COUNT(*) as product_count') - ->first(); - $prospectTotalRegFee = $prospectContractTotals->total_registration_fee ?? 0; - $prospectTotalSubFee = $prospectContractTotals->total_subscription_fee ?? 0; - $prospectProductCount = $prospectContractTotals->product_count ?? 0; - - // 개발 진행 상태 (100% 완료 시 표시) - $prospectHqStatuses = \App\Models\Sales\SalesTenantManagement::$hqStatusLabels; - $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 -
- -
-
-
-
{{ $prospect->company_name }}
- - {{ $prospect->status_label }} - -
-
- @if($prospect->ceo_name) - 대표: {{ $prospect->ceo_name }} - | - @endif - {{ $prospect->business_number ?? '-' }} -
-
- {{-- 매니저 드롭다운 --}} -
- @include('sales.dashboard.partials.manager-dropdown', ['prospect' => $prospect, 'prospectManagement' => $prospectManagement]) -
- {{-- 영업/매니저 진행 버튼 --}} -
- @if($showSalesButton) - - @endif - @if($showManagerButton) - - @endif -
-
- - -
- {{-- 영업/매니저 프로그레스 바 --}} -
- {{-- 영업 (등록자에게만 표시) --}} - @if($showSalesButton) -
- -
-
-
- {{ $prospectProgress['sales']['percentage'] }}% -
- @endif - {{-- 매니저 (매니저에게만 표시) --}} - @if($showManagerProgress) -
- -
-
-
- {{ $prospectProgress['manager']['percentage'] }}% -
- @endif -
- - {{-- 구분선 --}} -
- - {{-- 개발 진행 상태 --}} -
- @if($isProspectHqEnabled) - {{-- 영업/매니저 100% 완료: 개발 진행 상태 표시 --}} -
- {{-- 8단계 프로그레스 바 --}} -
-
- @foreach($prospectHqStatuses as $statusKey => $statusLabel) - @php - $stepNum = $prospectHqStatusOrder[$statusKey]; - $isCompleted = $stepNum < $prospectCurrentHqStep; - $isCurrent = $stepNum === $prospectCurrentHqStep; - @endphp -
-
-
- {{ $statusLabel }} -
-
- @endforeach -
-
- {{-- 현재 상태 배지 --}} - - {{ $prospectManagement->hq_status_label }} - -
- @else - {{-- 아직 100% 미완료: 비활성 상태 --}} -
- {{-- 비활성 프로그래스 바 --}} -
-
- @for($i = 0; $i < 8; $i++) -
- @endfor -
-
- {{-- 대기 배지 --}} - - 영업 진행중 - -
- @endif -
-
- - -
- @if($prospectProductCount > 0) -
-
-

개발비

-

₩{{ number_format($prospectTotalRegFee) }}

-
-
-

월 구독료

-

₩{{ number_format($prospectTotalSubFee) }}

-
-
- @else -
-

계약상품

-

미선택

-
- @endif -
- - - @php - $isFullyCompleted = $prospectProgress['sales']['percentage'] >= 100 && $prospectProgress['manager']['percentage'] >= 100; - @endphp - @if(!$isFullyCompleted) -
- @if($prospect->isActive()) -
영업권 만료
-
D-{{ $prospect->remaining_days }}
- @elseif($prospect->isExpired()) -
상태
-
만료됨
- @endif -
- @endif - - - -
+ @include('sales.dashboard.partials.prospect-row', ['prospect' => $prospect]) @endforeach
diff --git a/routes/web.php b/routes/web.php index c2659b6c..98744f9a 100644 --- a/routes/web.php +++ b/routes/web.php @@ -904,6 +904,7 @@ Route::get('salesmanagement/dashboard/tenants', [\App\Http\Controllers\Sales\SalesDashboardController::class, 'refreshTenantList'])->name('salesmanagement.dashboard.tenants'); Route::get('salesmanagement/dashboard/partner-activity', [\App\Http\Controllers\Sales\SalesDashboardController::class, 'partnerActivity'])->name('salesmanagement.dashboard.partner-activity'); Route::get('salesmanagement/dashboard/help', [\App\Http\Controllers\Sales\SalesDashboardController::class, 'helpGuide'])->name('salesmanagement.dashboard.help'); + Route::get('salesmanagement/dashboard/prospect/{id}/row', [\App\Http\Controllers\Sales\SalesDashboardController::class, 'getProspectRow'])->name('salesmanagement.dashboard.prospect-row'); // 영업파트너 승인 (본사 관리자 전용) - resource 전에 정의해야 함 Route::get('managers/approvals', [\App\Http\Controllers\Sales\SalesManagerController::class, 'approvals'])->name('managers.approvals');