submitter ??= $this->submitters->first()?->id; } #[Computed] public function submitters(): \Illuminate\Support\Collection { return app(SubmitterContactReport::class)->submitters(12); } #[Computed] public function user(): ?User { return $this->submitter === null ? null : User::query()->withoutGlobalScopes()->find($this->submitter); } /** * Der Bericht als Text — genau das, was in eine Mail an den Einlieferer * kopiert wird. */ #[Computed] public function plainText(): string { $user = $this->user; if ($user === null) { return ''; } $report = app(SubmitterContactReport::class); $contacts = $report->brokenContacts($user, $this->months); $rejected = $report->rejectedReleases($user, $this->months); $lines = [ sprintf('Kontakt- und Prüfbericht %s', now()->format('d.m.Y')), sprintf('Einlieferer: %s (%s)', $user->name, $user->email), sprintf('Zeitraum: letzte %d Monate', $this->months), '', sprintf('1. Nicht erreichbare E-Mail-Adressen (%d)', $contacts->count()), '', ]; foreach ($contacts as $row) { $lines[] = sprintf('- %s — %s', $row->email, $row->company); $lines[] = sprintf(' Grund: %s%s', $row->reason, $row->detail !== null ? ' ('.$row->detail.')' : ''); $lines[] = sprintf(' Betroffene Meldungen im Zeitraum: %d', $row->releases); } if ($contacts->isEmpty()) { $lines[] = '- keine'; } $lines[] = ''; $lines[] = sprintf('2. Automatisch abgelehnte Meldungen (%d)', $rejected->count()); $lines[] = ''; foreach ($rejected as $release) { $lines[] = sprintf('- %s — %s', $release->title, $release->company); $lines[] = sprintf(' %s: %s', $release->rejectedAt?->format('d.m.Y') ?? '', $release->reason); } if ($rejected->isEmpty()) { $lines[] = '- keine'; } return implode("\n", $lines); } public function downloadContacts(): StreamedResponse { $user = $this->user; abort_if($user === null, 404); $rows = app(SubmitterContactReport::class)->brokenContacts($user, $this->months); $name = sprintf('kontakte-%s-%s.csv', \Illuminate\Support\Str::slug($user->name), now()->format('Y-m-d')); return response()->streamDownload(function () use ($rows): void { $handle = fopen('php://output', 'wb'); fputcsv($handle, ['E-Mail', 'Firma', 'Befund', 'Grund', 'Detail', 'Meldungen', 'Zuletzt'], ';'); foreach ($rows as $row) { fputcsv($handle, [ $row->email, $row->company, $row->fromDomain ? 'Domainprüfung' : 'Rückläufer', $row->reason, $row->detail ?? '', $row->releases, $row->lastEvent?->format('d.m.Y') ?? '', ], ';'); } fclose($handle); }, $name, ['Content-Type' => 'text/csv; charset=UTF-8']); } public function downloadRejected(): StreamedResponse { $user = $this->user; abort_if($user === null, 404); $rows = app(SubmitterContactReport::class)->rejectedReleases($user, $this->months); $name = sprintf('ablehnungen-%s-%s.csv', \Illuminate\Support\Str::slug($user->name), now()->format('Y-m-d')); return response()->streamDownload(function () use ($rows): void { $handle = fopen('php://output', 'wb'); fputcsv($handle, ['ID', 'Titel', 'Firma', 'Datum', 'Begründung'], ';'); foreach ($rows as $row) { fputcsv($handle, [$row->id, $row->title, $row->company, $row->rejectedAt?->format('d.m.Y') ?? '', $row->reason], ';'); } fclose($handle); }, $name, ['Content-Type' => 'text/csv; charset=UTF-8']); } public function with(): array { $user = $this->user; if ($user === null) { return ['contacts' => collect(), 'rejected' => collect(), 'policy' => collect()]; } $report = app(SubmitterContactReport::class); return [ 'contacts' => $report->brokenContacts($user, $this->months), 'rejected' => $report->rejectedReleases($user, $this->months), 'policy' => $report->policyRejections($user, $this->months), ]; } }; ?>
{{ __('Auswahl') }}
@foreach ($this->submitters as $option) @endforeach
{{ __(':count Meldungen betroffen', ['count' => $contacts->sum(fn ($row) => $row->releases)]) }} {{ __('automatische Prüfung') }} {{ __('Empfänger filtert — keine Sperre') }}
{{ __('Nicht erreichbare Adressen') }} @if ($contacts->isNotEmpty()) {{ __('CSV') }} @endif
{{ __('Adresse') }} {{ __('Firma') }} {{ __('Befund') }} {{ __('Meldungen') }} {{ __('Zuletzt') }} @forelse ($contacts as $row) {{ $row->email }} {{ $row->company }} {{ $row->reason }} {{ $row->fromDomain ? __('DNS-Prüfung der Domain') : __('Rückläufer') }}@if ($row->detail) · {{ $row->detail }}@endif {{ $row->releases }} {{ $row->lastEvent?->format('d.m.Y') ?? '—' }} @empty
{{ __('Keine unzustellbaren Adressen in diesem Zeitraum.') }}
@endforelse
{{ __('Abgelehnte Meldungen') }} @if ($rejected->isNotEmpty()) {{ __('CSV') }} @endif
    @forelse ($rejected as $release)
  • {{ $release->title }} {{ $release->company }} {{ $release->rejectedAt?->format('d.m.Y') }}

    {{ $release->reason }}

  • @empty
  • {{ __('Keine automatischen Ablehnungen in diesem Zeitraum.') }}
  • @endforelse
@if ($policy->isNotEmpty())
{{ __('Richtlinien-Ablehnungen') }} {{ __('Empfängerserver hat abgelehnt — die Adresse bleibt frei') }}
    @foreach ($policy as $bounce)
  • {{ $bounce->received_at?->format('d.m.') }} {{ $bounce->email }} {{ $bounce->status }} · {{ Str::limit($bounce->diagnostic, 90) }}
  • @endforeach
@endif
{{ __('Bericht zum Kopieren') }} {{ __('für die Mail an den Einlieferer') }}