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 +
개발비
+₩{{ number_format($prospectTotalRegFee) }}
+월 구독료
+₩{{ number_format($prospectTotalSubFee) }}
+계약상품
+미선택
+개발비
-₩{{ number_format($prospectTotalRegFee) }}
-월 구독료
-₩{{ number_format($prospectTotalSubFee) }}
-계약상품
-미선택
-