- Added methods to AnalysisService for retrieving monthly revenue by channel and revenue by payment type. - Updated AnalysisController to include new metrics in the index response. - Enhanced Analysis.vue to visualize revenue data by channel and payment type with appropriate charts and tooltips.
50 lines
2.6 KiB
PHP
50 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Services\System\AnalysisService;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Http\Request;
|
|
use Inertia\Inertia;
|
|
use Inertia\Response;
|
|
|
|
class AnalysisController extends Controller
|
|
{
|
|
public function __construct(
|
|
private readonly AnalysisService $analysisService,
|
|
) {}
|
|
|
|
public function index(Request $request): Response
|
|
{
|
|
$startDate = $request->query('start_date') ? Carbon::parse($request->query('start_date'))->startOfDay() : null;
|
|
$endDate = $request->query('end_date') ? Carbon::parse($request->query('end_date'))->endOfDay() : null;
|
|
$user = $request->user();
|
|
|
|
return Inertia::render('admin/Analysis', [
|
|
'filters' => [
|
|
'start_date' => $request->query('start_date', ''),
|
|
'end_date' => $request->query('end_date', ''),
|
|
],
|
|
'attendance' => $this->analysisService->getAttendance($startDate, $endDate),
|
|
'myAttendance' => $user ? $this->analysisService->getMyAttendance($user, $startDate, $endDate) : null,
|
|
'isManager' => $this->analysisService->isManager($user),
|
|
'cashOverview' => $this->analysisService->getCashOverview($startDate, $endDate),
|
|
'rawMaterialStock' => $this->analysisService->getRawMaterialStock(),
|
|
'productStock' => $this->analysisService->getProductStock(),
|
|
'revenueSummary' => $this->analysisService->getRevenueSummary($startDate, $endDate),
|
|
'monthlyRevenue' => $this->analysisService->getMonthlyRevenue($startDate, $endDate),
|
|
'monthlyRevenueByChannel' => $this->analysisService->getMonthlyRevenueByChannel($startDate, $endDate),
|
|
'revenueByPaymentType' => $this->analysisService->getRevenueByPaymentType($startDate, $endDate),
|
|
'expenseSummary' => $this->analysisService->getExpenseSummary($startDate, $endDate),
|
|
'monthlyExpense' => $this->analysisService->getMonthlyExpense($startDate, $endDate),
|
|
'busyHours' => $this->analysisService->getBusyHours($startDate, $endDate),
|
|
'profitMetrics' => $this->analysisService->getProfitMetrics($startDate, $endDate),
|
|
'topSuppliers' => $this->analysisService->getTopSuppliers($startDate, $endDate),
|
|
'topCustomers' => $this->analysisService->getTopCustomers($startDate, $endDate),
|
|
'topProducts' => $this->analysisService->getTopProducts($startDate, $endDate),
|
|
'marketingSales' => $this->analysisService->getMarketingSales($startDate, $endDate),
|
|
]);
|
|
}
|
|
}
|