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,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('Отчет: Эффективность техников');
}
}