From d60017ca30dfd948f0fa4ad54274725078ebfe64 Mon Sep 17 00:00:00 2001 From: kimbokon Date: Mon, 5 Jan 2026 04:30:37 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9A=B4=EC=98=81=EC=9E=90=20=ED=99=94?= =?UTF-8?q?=EB=A9=B4=EC=9D=98=20=EB=8C=80=EA=B8=B0=20=EC=83=81=ED=83=9C=20?= =?UTF-8?q?=EB=B0=8F=20=ED=86=B5=EA=B3=84=20=EA=B8=B0=EB=8A=A5=EC=9D=84=20?= =?UTF-8?q?=EC=9A=94=EC=B2=AD=ED=95=98=EC=8B=A0=20=EB=8C=80=EB=A1=9C=20?= =?UTF-8?q?=EC=84=B8=EB=B6=84=ED=99=94=ED=95=98=EC=97=AC=20=EC=97=85?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- salesmanagement/api/get_performance.php | 8 ++- salesmanagement/index.php | 67 ++++++++++++------------- 2 files changed, 38 insertions(+), 37 deletions(-) diff --git a/salesmanagement/api/get_performance.php b/salesmanagement/api/get_performance.php index b16aee1..fe954f4 100644 --- a/salesmanagement/api/get_performance.php +++ b/salesmanagement/api/get_performance.php @@ -238,7 +238,9 @@ try { SELECT COALESCE(SUM(contract_amount), 0) as total_sales, COALESCE(SUM(payout_amount), 0) as total_comm, -- 정산 지급액 합계 - COUNT(*) as total_count + COUNT(*) as total_count, + SUM(CASE WHEN join_approved = 0 THEN 1 ELSE 0 END) as pending_join, + SUM(CASE WHEN join_approved = 1 AND payment_approved = 0 THEN 1 ELSE 0 END) as pending_payment FROM sales_tenant_products "); $tpData = $stmt->fetch(PDO::FETCH_ASSOC); @@ -256,7 +258,9 @@ try { $totalStats = [ 'totalSales' => $tpData['total_sales'] + $srData['total_sales'], 'totalCommission' => $tpData['total_comm'] + $srData['total_comm'], - 'totalCount' => $tpData['total_count'] + $srData['total_count'] + 'totalCount' => $tpData['total_count'] + $srData['total_count'], + 'pendingJoin' => (int)($tpData['pending_join'] ?? 0), + 'pendingPayment' => (int)($tpData['pending_payment'] ?? 0) ]; } else { $totalStats = calculateTotalStats($pdo, $rootUserId, $rootUserId, 0); diff --git a/salesmanagement/index.php b/salesmanagement/index.php index e3bbc49..5b28327 100644 --- a/salesmanagement/index.php +++ b/salesmanagement/index.php @@ -430,10 +430,8 @@ totalSales: 0, totalCommission: 0, totalCount: 0, - monthlySales: 0, - monthlyCommission: 0, - monthlyCount: 0, - pendingApprovals: 0 + pendingJoin: 0, + pendingPayment: 0 }); useEffect(() => { @@ -442,34 +440,17 @@ const fetchOperatorDashboard = async () => { try { - // Fetch global stats + // Fetch global stats including pending counts from backend const res = await fetch(`api/get_performance.php`); const result = await res.json(); - // Fetch tenant product statistics for pending count - const tenantRes = await fetch('api/sales_tenants.php?action=list_tenants'); - const tenantData = await tenantRes.json(); - - let pendingCount = 0; - if (tenantData.success) { - for (const tenant of tenantData.data) { - const prodRes = await fetch(`api/sales_tenants.php?action=tenant_products&tenant_id=${tenant.id}`); - const prodData = await prodRes.json(); - if (prodData.success) { - pendingCount += prodData.data.filter(p => p.join_approved == 0 || p.payment_approved == 0).length; - } - } - } - if (result.success && result.total_stats) { setOperatorStats({ totalSales: result.total_stats.totalSales || 0, totalCommission: result.total_stats.totalCommission || 0, totalCount: result.total_stats.totalCount || 0, - monthlySales: result.period_stats?.total_period_commission || 0, // Just a placeholder for monthly - monthlyCommission: result.period_stats?.total_period_commission || 0, - monthlyCount: 0, - pendingApprovals: pendingCount + pendingJoin: result.total_stats.pendingJoin || 0, + pendingPayment: result.total_stats.pendingPayment || 0 }); } } catch (err) { @@ -495,7 +476,7 @@ {/* Dashboard Metrics */} -
+
} /> } + subtext="최종 지급 승인된 총액" + icon={} /> } /> -
0 ? 'border-red-200 bg-red-50/10' : 'border-slate-100'}`}> + + {/* 가입 승인 대기 */} +
0 ? 'border-amber-200 bg-amber-50/10' : 'border-slate-100'}`}>
-

대기 중인 승인

-
0 ? 'bg-red-100 text-red-600' : 'bg-slate-100 text-slate-400'}`}> - +

가입 승인 대기

+
0 ? 'bg-amber-100 text-amber-600' : 'bg-slate-100 text-slate-400'}`}> +
-
0 ? 'text-red-600' : 'text-slate-900'}`}> - {operatorStats.pendingApprovals}건 +
0 ? 'text-amber-600' : 'text-slate-900'}`}> + {operatorStats.pendingJoin}건
-
즉시 검토가 필요한 계약 건
+
신규 가입 검토 대기
+
+ + {/* 지급 승인 대기 */} +
0 ? 'border-rose-200 bg-rose-50/10' : 'border-slate-100'}`}> +
+

지급 승인 대기

+
0 ? 'bg-rose-100 text-rose-600' : 'bg-slate-100 text-slate-400'}`}> + +
+
+
0 ? 'text-rose-600' : 'text-slate-900'}`}> + {operatorStats.pendingPayment}건 +
+
수당 지급 검토 대기