validate([ 'newLogCategory' => 'required|in:'.implode(',', array_keys(\App\Models\OrganizationLogEntry::CATEGORIES)), 'newLogNote' => 'required|string', ]); $this->organization->logEntries()->create([ 'category' => $this->newLogCategory, 'note' => $this->newLogNote, 'created_by' => auth()->id(), ]); $this->newLogNote = ''; } public function deleteLogEntry(int $entryId): void { $this->organization->logEntries()->findOrFail($entryId)->delete(); } public function toggleTodoDone(int $todoId): void { $todo = $this->organization->todos()->findOrFail($todoId); $todo->update([ 'is_done' => ! $todo->is_done, 'completed_at' => $todo->is_done ? null : now(), ]); } public function previousActivityPage(): void { $this->activityPage = max(1, $this->activityPage - 1); } public function nextActivityPage(): void { $this->activityPage++; } public function with(): array { $expiringDomains = $this->organization->domains() ->get() ->filter(fn ($domain) => in_array($domain->expiryStatus(), ['soon', 'expired'], true)) ->sortBy(fn ($domain) => $domain->expiresInDays()); $recentDocuments = $this->organization->documents() ->with('creator') ->where('is_folder', false) ->orderByDesc('updated_at') ->limit(20) ->get() ->map(fn ($doc) => [ 'icon' => $doc->isOffice() ? ($doc->office_extension === 'xlsx' ? '📊' : '📘') : ($doc->isMarkdown() ? '📝' : '📄'), 'label' => $doc->name, 'kind' => 'Document', 'url' => route('organizations.documents.edit', [$this->organization, $doc]), 'creator' => $doc->creator?->name, 'created' => $doc->created_at->equalTo($doc->updated_at), 'at' => $doc->updated_at, ]); $recentAssets = $this->organization->flexibleAssets() ->with(['type', 'creator']) ->orderByDesc('updated_at') ->limit(20) ->get() ->map(fn ($asset) => [ 'icon' => $asset->type?->icon ?: '🗂️', 'label' => $asset->name, 'kind' => $asset->type?->name ?? 'Actif', 'url' => route('organizations.assets.edit', [$this->organization, $asset->type, $asset]), 'creator' => $asset->creator?->name, 'created' => $asset->created_at->equalTo($asset->updated_at), 'at' => $asset->updated_at, ]); $recentVirtualMachines = $this->organization->virtualMachines() ->with('creator') ->orderByDesc('updated_at') ->limit(20) ->get() ->map(fn ($vm) => [ 'icon' => '🖥️', 'label' => $vm->name, 'kind' => 'Machine virtuelle', 'url' => route('organizations.virtual-machines.edit', [$this->organization, $vm]), 'creator' => $vm->creator?->name, 'created' => $vm->created_at->equalTo($vm->updated_at), 'at' => $vm->updated_at, ]); $allActivity = $recentDocuments ->concat($recentAssets) ->concat($recentVirtualMachines) ->sortByDesc('at') ->values(); $activityPageCount = max(1, (int) ceil($allActivity->count() / self::ACTIVITY_PER_PAGE)); $this->activityPage = min($this->activityPage, $activityPageCount); $recentActivity = $allActivity->forPage($this->activityPage, self::ACTIVITY_PER_PAGE)->values(); $openTodos = $this->organization->todos() ->with('assignee') ->where('is_done', false) ->orderByRaw("CASE criticality WHEN 'urgent' THEN 0 WHEN 'high' THEN 1 WHEN 'medium' THEN 2 ELSE 3 END") ->orderByRaw('due_date IS NULL') ->orderBy('due_date') ->limit(8) ->get(); $glpi = ['tickets' => [], 'total' => 0, 'error' => null]; $glpiNewTicketUrl = null; if ($this->organization->glpi_entity_id !== null) { $glpiClient = app(GlpiClient::class); $glpi = $glpiClient->recentTicketsForEntity($this->organization->glpi_entity_id); $glpiNewTicketUrl = $glpiClient->frontUrl().'/front/ticket.form.php'; } return [ 'glpiTickets' => $glpi['tickets'], 'glpiTicketsTotal' => $glpi['total'], 'glpiError' => $glpi['error'], 'glpiNewTicketUrl' => $glpiNewTicketUrl, 'counts' => [ 'contacts' => $this->organization->contacts()->count(), 'locations' => $this->organization->locations()->count(), 'domains' => $this->organization->domains()->count(), 'documents' => $this->organization->documents()->where('is_folder', false)->count(), 'virtualMachines' => $this->organization->virtualMachines()->count(), 'assets' => $this->organization->flexibleAssets()->count(), 'openTodos' => $this->organization->todos()->where('is_done', false)->count(), ], 'expiringDomains' => $expiringDomains, 'recentActivity' => $recentActivity, 'activityPageCount' => $activityPageCount, 'openTodos' => $openTodos, 'logEntries' => $this->organization->logEntries()->with('creator')->limit(20)->get(), 'categories' => \App\Models\OrganizationLogEntry::CATEGORIES, ]; } }; ?>
Tableau de bord
Aucun domaine à surveiller.
@else{{ $activity['kind'] }} {{ $activity['created'] ? 'créé' : 'modifié' }} @if ($activity['creator']) par {{ $activity['creator'] }} @endif
{{ $todo->categoryLabel() }} @if ($todo->assignee) · {{ $todo->assignee->name }} @endif @if ($todo->due_date) · {{ $todo->due_date->format('d/m/Y') }} @endif
{{ $entry->note }}
{{ $entry->creator?->name ?? 'système' }} · {{ $entry->created_at->diffForHumans() }}
Aucune entrée dans le journal pour le moment.
@endforelse{{ $glpiError }}
@elseif (empty($glpiTickets))Aucun ticket non clos pour le moment.
@else{{ $ticket['excerpt'] }}
@endif{{ \Illuminate\Support\Carbon::parse($ticket['date_mod'])->diffForHumans() }} @if ($ticket['category']) {{ $ticket['category'] }} @endif @if ($ticket['technician']) {{ $ticket['technician'] }} @endif {{ $ticket['interactions_count'] }}
{{ $glpiTicketsTotal }} tickets non clos au total pour cette entité.
@endif @endif