54 lines
1.6 KiB
PHP
54 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Reports;
|
|
|
|
use App\Models\Status;
|
|
use App\Models\RequestType;
|
|
use App\Models\User;
|
|
use App\Services\ReportService;
|
|
use Livewire\Attributes\Layout;
|
|
use Livewire\Component;
|
|
|
|
#[Layout('layouts.app')]
|
|
class GeneralReportPage extends Component
|
|
{
|
|
public string $dateFrom = '';
|
|
|
|
public string $dateTo = '';
|
|
|
|
public string $technicianId = '';
|
|
|
|
public string $typeId = '';
|
|
|
|
public string $statusId = '';
|
|
|
|
public function mount(): void
|
|
{
|
|
abort_unless(auth()->user()->isAdmin() || auth()->user()->isManager(), 403);
|
|
}
|
|
|
|
public function render(ReportService $reportService)
|
|
{
|
|
$filters = [
|
|
'date_from' => $this->dateFrom ?: null,
|
|
'date_to' => $this->dateTo ?: null,
|
|
'technician_id' => $this->technicianId ?: null,
|
|
'type_id' => $this->typeId ?: null,
|
|
'status_id' => $this->statusId ?: null,
|
|
];
|
|
|
|
$rows = $reportService->requestBaseQuery($filters)->latest()->limit(200)->get();
|
|
$statusChart = $reportService->requestsByStatus($filters);
|
|
|
|
$this->dispatch('general-report-chart-updated', chart: $statusChart->values()->toArray());
|
|
|
|
return view('livewire.reports.general-report-page', [
|
|
'rows' => $rows,
|
|
'statusChart' => $statusChart,
|
|
'technicians' => User::query()->where('role', 'technician')->orderBy('name')->get(),
|
|
'types' => RequestType::query()->orderBy('name')->get(),
|
|
'statuses' => Status::query()->orderBy('sort_order')->get(),
|
|
])->title('Отчет: Общий');
|
|
}
|
|
}
|