first&last

This commit is contained in:
sbb45
2026-03-20 15:47:17 +05:00
commit d6441abdd2
230 changed files with 20367 additions and 0 deletions
@@ -0,0 +1,32 @@
<?php
namespace App\Livewire\Reports;
use App\Services\ReportService;
use Livewire\Attributes\Layout;
use Livewire\Component;
#[Layout('layouts.app')]
class EquipmentReportPage extends Component
{
public string $dateFrom = '';
public string $dateTo = '';
public function mount(): void
{
abort_unless(auth()->user()->isAdmin() || auth()->user()->isManager(), 403);
}
public function render(ReportService $reportService)
{
$rows = $reportService->equipmentFailureFrequency([
'date_from' => $this->dateFrom ?: null,
'date_to' => $this->dateTo ?: null,
]);
return view('livewire.reports.equipment-report-page', [
'rows' => $rows,
])->title('Отчет: Оборудование');
}
}
@@ -0,0 +1,53 @@
<?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('Отчет: Общий');
}
}
+32
View File
@@ -0,0 +1,32 @@
<?php
namespace App\Livewire\Reports;
use App\Services\ReportService;
use Livewire\Attributes\Layout;
use Livewire\Component;
#[Layout('layouts.app')]
class SlaReportPage extends Component
{
public string $dateFrom = '';
public string $dateTo = '';
public function mount(): void
{
abort_unless(auth()->user()->isAdmin() || auth()->user()->isManager(), 403);
}
public function render(ReportService $reportService)
{
$rows = $reportService->slaCompliance([
'date_from' => $this->dateFrom ?: null,
'date_to' => $this->dateTo ?: null,
]);
return view('livewire.reports.sla-report-page', [
'rows' => $rows,
])->title('Отчет: SLA');
}
}
@@ -0,0 +1,68 @@
<?php
namespace App\Livewire\Reports;
use App\Exports\CsvExport;
use App\Services\ReportService;
use Barryvdh\DomPDF\Facade\Pdf;
use Livewire\Attributes\Layout;
use Livewire\Component;
#[Layout('layouts.app')]
class TechniciansReportPage extends Component
{
public string $dateFrom = '';
public string $dateTo = '';
public function mount(): void
{
abort_unless(auth()->user()->isAdmin() || auth()->user()->isManager(), 403);
}
public function exportCsv(ReportService $reportService)
{
$rows = $reportService->technicianPerformance([
'date_from' => $this->dateFrom ?: null,
'date_to' => $this->dateTo ?: null,
])->values()->all();
return CsvExport::download('technicians-report.csv', [
'Техник', 'Назначено', 'Решено', 'Среднее время (ч)', 'Рейтинг', 'Просрочено',
], array_map(fn ($item) => [
$item['technician'],
$item['assigned'],
$item['resolved'],
$item['avg_resolution_hours'],
$item['rating'],
$item['overdue'],
], $rows));
}
public function exportPdf(ReportService $reportService)
{
$rows = $reportService->technicianPerformance([
'date_from' => $this->dateFrom ?: null,
'date_to' => $this->dateTo ?: null,
])->values()->all();
$pdf = Pdf::loadView('exports.technicians-report-pdf', [
'rows' => $rows,
'generatedAt' => now()->format('d.m.Y H:i'),
]);
return response()->streamDownload(fn () => print($pdf->output()), 'technicians-report.pdf');
}
public function render(ReportService $reportService)
{
$rows = $reportService->technicianPerformance([
'date_from' => $this->dateFrom ?: null,
'date_to' => $this->dateTo ?: null,
]);
return view('livewire.reports.technicians-report-page', [
'rows' => $rows,
])->title('Отчет: Эффективность техников');
}
}