Files
sam-manage/app/Http/Controllers/Sales/SalesDashboardController.php
pro 0e88660c89 feat:영업관리 대시보드 HTMX 부분 새로고침 구현
- 기간별 조회 및 실적 새로고침 시 전체 페이지가 아닌 데이터 영역만 갱신
- partial 뷰 분리 (stats, commission-by-role, tenant-stats, no-data)
- 컨트롤러에 refresh 메서드 추가
- 로딩 인디케이터 추가

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 19:28:48 +09:00

109 lines
3.3 KiB
PHP

<?php
namespace App\Http\Controllers\Sales;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\View\View;
/**
* 영업관리 대시보드 컨트롤러
*/
class SalesDashboardController extends Controller
{
/**
* 대시보드 화면
*/
public function index(Request $request): View
{
$data = $this->getDashboardData($request);
return view('sales.dashboard.index', $data);
}
/**
* HTMX 부분 새로고침용 데이터 반환
*/
public function refresh(Request $request): View
{
$data = $this->getDashboardData($request);
return view('sales.dashboard.partials.data-container', $data);
}
/**
* 대시보드 데이터 조회
*/
private function getDashboardData(Request $request): array
{
// 기간 설정
$period = $request->input('period', 'month'); // month or custom
$year = $request->input('year', now()->year);
$month = $request->input('month', now()->month);
// 기간 설정 모드일 경우
if ($period === 'custom') {
$startDate = $request->input('start_date', now()->startOfMonth()->format('Y-m-d'));
$endDate = $request->input('end_date', now()->format('Y-m-d'));
} else {
$startDate = now()->startOfMonth()->format('Y-m-d');
$endDate = now()->endOfMonth()->format('Y-m-d');
}
// 통계 데이터 (임시 데이터 - 추후 실제 데이터로 교체)
$stats = [
'total_membership_fee' => 0, // 총 가입비
'total_commission' => 0, // 총 수당
'commission_rate' => 0, // 지급 승인 완료 비율
'total_contracts' => 0, // 전체 건수
'pending_membership_approval' => 0, // 가입 승인 대기
'pending_payment_approval' => 0, // 지급 승인 대기
];
// 역할별 수당 상세
$commissionByRole = [
[
'name' => '판매자',
'rate' => 20,
'amount' => 0,
'color' => 'green',
],
[
'name' => '관리자',
'rate' => 5,
'amount' => 0,
'color' => 'blue',
],
[
'name' => '매뉴제작 협업수당',
'rate' => null, // 별도
'amount' => null, // 운영팀 산정
'color' => 'red',
],
];
// 총 가입비 대비 수당
$totalCommissionRatio = 0;
// 수익 및 테넌트 관리 통계 (임시 데이터 - 추후 실제 데이터로 교체)
$tenantStats = [
'total_tenants' => 0, // 관리 테넌트
'total_membership_revenue' => 0, // 총 가입비 실적
'total_commission_accumulated' => 0, // 누적 가입비 수당
'confirmed_commission' => 0, // 확정 가입비 수당
];
return compact(
'stats',
'commissionByRole',
'totalCommissionRatio',
'tenantStats',
'period',
'year',
'month',
'startDate',
'endDate'
);
}
}