- 테넌트 목록 표시 (업체명, 담당자, 등록일) - 계약관리 버튼 (영업 진행, 상세계약 설정, 매니저 진행) - 행 클릭 시 상세 정보 토글 - 신규 테넌트 등록 버튼 제외 (가망고객 관리에서 처리) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
116 lines
3.5 KiB
PHP
116 lines
3.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Sales;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Tenants\Tenant;
|
|
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, // 확정 가입비 수당
|
|
];
|
|
|
|
// 테넌트 목록 (HQ 제외)
|
|
$tenants = Tenant::where('tenant_type', '!=', 'HQ')
|
|
->orderBy('created_at', 'desc')
|
|
->get();
|
|
|
|
return compact(
|
|
'stats',
|
|
'commissionByRole',
|
|
'totalCommissionRatio',
|
|
'tenantStats',
|
|
'tenants',
|
|
'period',
|
|
'year',
|
|
'month',
|
|
'startDate',
|
|
'endDate'
|
|
);
|
|
}
|
|
}
|