Initial commit: CABM-IT (ItGlue-style MSP documentation platform)

Laravel 13 + Livewire/Volt app for managing client organizations,
documents, passwords, flexible assets, virtual machines, contacts,
domains, todos, shortcuts, and role-based user administration.
This commit is contained in:
jeremy bayse
2026-08-16 13:28:12 +02:00
commit 8f22dca9c8
209 changed files with 23324 additions and 0 deletions
@@ -0,0 +1,143 @@
<?php
use App\Models\Organization;
use App\Models\Todo;
use App\Models\User;
use Livewire\Component;
new class extends Component
{
public Organization $organization;
public ?Todo $todo = null;
public string $title = '';
public string $description = '';
public string $category = 'infra';
public string $criticality = 'medium';
public ?string $due_date = null;
public ?int $assigned_to = null;
public function mount(Organization $organization, ?Todo $todo = null): void
{
$this->organization = $organization;
if ($todo?->exists) {
$this->todo = $todo;
$this->title = $todo->title;
$this->description = $todo->description ?? '';
$this->category = $todo->category;
$this->criticality = $todo->criticality;
$this->due_date = $todo->due_date?->format('Y-m-d');
$this->assigned_to = $todo->assigned_to;
}
}
public function save(): void
{
$validated = $this->validate([
'title' => 'required|string|max:255',
'description' => 'nullable|string',
'category' => 'required|in:'.implode(',', array_keys(Todo::CATEGORIES)),
'criticality' => 'required|in:'.implode(',', array_keys(Todo::CRITICALITIES)),
'due_date' => 'nullable|date',
'assigned_to' => 'nullable|exists:users,id',
]);
if ($this->todo?->exists) {
$this->todo->update($validated);
session()->flash('status', "Tâche \"{$this->todo->title}\" mise à jour.");
} else {
$this->organization->todos()->create([
...$validated,
'created_by' => auth()->id(),
]);
session()->flash('status', "Tâche \"{$this->title}\" créée.");
}
$this->redirectRoute('organizations.todos.index', $this->organization, navigate: true);
}
public function with(): array
{
return [
'assignableUsers' => User::role(['Administrateur', 'Technicien'])->orderBy('name')->get(),
];
}
};
?>
<div class="max-w-2xl">
<p class="text-sm text-slate-500">{{ $organization->name }}</p>
<h1 class="mb-6 text-2xl font-semibold text-slate-900">
{{ $todo?->exists ? 'Modifier la tâche' : 'Nouvelle tâche' }}
</h1>
<form wire:submit="save" class="space-y-4 rounded border border-slate-200 bg-white p-6">
<div>
<label class="block text-sm font-medium text-slate-700">Titre</label>
<input type="text" wire:model="title"
class="mt-1 w-full rounded border-slate-300 text-sm shadow-sm focus:border-slate-500 focus:ring-slate-500">
@error('title') <p class="mt-1 text-sm text-red-600">{{ $message }}</p> @enderror
</div>
<div>
<label class="block text-sm font-medium text-slate-700">Description</label>
<textarea wire:model="description" rows="3"
class="mt-1 w-full rounded border-slate-300 text-sm shadow-sm focus:border-slate-500 focus:ring-slate-500"></textarea>
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-slate-700">Catégorie</label>
<select wire:model="category"
class="mt-1 w-full rounded border-slate-300 text-sm shadow-sm focus:border-slate-500 focus:ring-slate-500">
@foreach (Todo::CATEGORIES as $value => $label)
<option value="{{ $value }}">{{ $label }}</option>
@endforeach
</select>
</div>
<div>
<label class="block text-sm font-medium text-slate-700">Criticité</label>
<select wire:model="criticality"
class="mt-1 w-full rounded border-slate-300 text-sm shadow-sm focus:border-slate-500 focus:ring-slate-500">
@foreach (Todo::CRITICALITIES as $value => $label)
<option value="{{ $value }}">{{ $label }}</option>
@endforeach
</select>
</div>
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-slate-700">Date d'échéance</label>
<input type="date" wire:model="due_date"
class="mt-1 w-full rounded border-slate-300 text-sm shadow-sm focus:border-slate-500 focus:ring-slate-500">
@error('due_date') <p class="mt-1 text-sm text-red-600">{{ $message }}</p> @enderror
</div>
<div>
<label class="block text-sm font-medium text-slate-700">Assigné à</label>
<select wire:model="assigned_to"
class="mt-1 w-full rounded border-slate-300 text-sm shadow-sm focus:border-slate-500 focus:ring-slate-500">
<option value="">—</option>
@foreach ($assignableUsers as $user)
<option value="{{ $user->id }}">{{ $user->name }}</option>
@endforeach
</select>
</div>
</div>
<div class="flex items-center gap-3 pt-2">
<button type="submit"
class="rounded bg-slate-900 px-4 py-2 text-sm font-medium text-white hover:bg-slate-700">
Enregistrer
</button>
<a href="{{ route('organizations.todos.index', $organization) }}" class="text-sm text-slate-500 hover:text-slate-900">Annuler</a>
</div>
</form>
@if ($todo?->exists)
<div class="mt-8">
<livewire:related-items.panel :organization="$organization" :item="$todo" :key="'related-'.$todo->id" />
</div>
@endif
</div>
@@ -0,0 +1,158 @@
<?php
use App\Models\Organization;
use App\Models\Todo;
use Livewire\Attributes\Url;
use Livewire\Component;
use Livewire\WithPagination;
new class extends Component
{
use WithPagination;
public Organization $organization;
#[Url]
public string $search = '';
#[Url]
public string $category = '';
#[Url]
public string $status = 'open';
public function toggleDone(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 delete(int $todoId): void
{
$todo = $this->organization->todos()->findOrFail($todoId);
$todo->delete();
session()->flash('status', "Tâche \"{$todo->title}\" supprimée.");
}
public function with(): array
{
return [
'todos' => $this->organization->todos()
->with(['assignee', 'creator'])
->when($this->search, fn ($q) => $q->where('title', 'like', "%{$this->search}%"))
->when($this->category, fn ($q) => $q->where('category', $this->category))
->when($this->status === 'open', fn ($q) => $q->where('is_done', false))
->when($this->status === 'done', fn ($q) => $q->where('is_done', true))
->orderBy('is_done')
->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')
->paginate(15),
'categories' => Todo::CATEGORIES,
];
}
};
?>
<div>
<div class="mb-6 flex items-center justify-between">
<div>
<p class="text-sm text-slate-500">{{ $organization->name }}</p>
<h1 class="text-2xl font-semibold text-slate-900">ToDo</h1>
</div>
<a href="{{ route('organizations.todos.create', $organization) }}"
class="rounded bg-slate-900 px-4 py-2 text-sm font-medium text-white hover:bg-slate-700">
+ Nouvelle tâche
</a>
</div>
<div class="mb-4 flex flex-wrap items-center gap-2">
<input type="text" wire:model.live.debounce.300ms="search" placeholder="Filtrer par titre..."
class="w-full max-w-sm rounded border-slate-300 text-sm shadow-sm focus:border-slate-500 focus:ring-slate-500">
<select wire:model.live="category" class="rounded border-slate-300 text-sm shadow-sm focus:border-slate-500 focus:ring-slate-500">
<option value="">Toutes catégories</option>
@foreach ($categories as $value => $label)
<option value="{{ $value }}">{{ $label }}</option>
@endforeach
</select>
<select wire:model.live="status" class="rounded border-slate-300 text-sm shadow-sm focus:border-slate-500 focus:ring-slate-500">
<option value="open">À faire</option>
<option value="done">Terminées</option>
<option value="">Toutes</option>
</select>
</div>
<div class="overflow-x-auto rounded border border-slate-200 bg-white">
<table class="min-w-full divide-y divide-slate-200 text-sm">
<thead class="bg-slate-50 text-left text-xs uppercase tracking-wide text-slate-500">
<tr>
<th class="px-4 py-3"></th>
<th class="px-4 py-3">Titre</th>
<th class="px-4 py-3">Catégorie</th>
<th class="px-4 py-3">Criticité</th>
<th class="px-4 py-3">Échéance</th>
<th class="px-4 py-3">Assigné à</th>
<th class="px-4 py-3"></th>
</tr>
</thead>
<tbody class="divide-y divide-slate-100">
@forelse ($todos as $todo)
<tr wire:key="todo-{{ $todo->id }}" class="{{ $todo->is_done ? 'opacity-50' : '' }}">
<td class="px-4 py-3">
<input type="checkbox" wire:click="toggleDone({{ $todo->id }})" @checked($todo->is_done)
class="rounded border-slate-300">
</td>
<td class="px-4 py-3">
<a href="{{ route('organizations.todos.edit', [$organization, $todo]) }}"
class="font-medium text-slate-900 hover:underline {{ $todo->is_done ? 'line-through' : '' }}">
{{ $todo->title }}
</a>
</td>
<td class="px-4 py-3 text-slate-600">{{ $todo->categoryLabel() }}</td>
<td class="px-4 py-3">
<span class="rounded-full px-2 py-0.5 text-xs font-medium
{{ match($todo->criticality) {
'urgent' => 'bg-red-100 text-red-700',
'high' => 'bg-amber-100 text-amber-700',
'medium' => 'bg-blue-100 text-blue-700',
default => 'bg-slate-100 text-slate-600',
} }}">
{{ $todo->criticalityLabel() }}
</span>
</td>
<td class="px-4 py-3 {{ $todo->isOverdue() ? 'font-medium text-red-600' : 'text-slate-600' }}">
{{ $todo->due_date?->format('d/m/Y') ?? '—' }}
@if ($todo->isOverdue())
<span class="ml-1 text-xs">(en retard)</span>
@endif
</td>
<td class="px-4 py-3 text-slate-600">{{ $todo->assignee?->name ?? '—' }}</td>
<td class="px-4 py-3 text-right whitespace-nowrap">
<a href="{{ route('organizations.todos.edit', [$organization, $todo]) }}" class="text-slate-500 hover:text-slate-900">Modifier</a>
<button type="button"
wire:click="delete({{ $todo->id }})"
wire:confirm="Supprimer cette tâche ? Cette action est irréversible."
class="ml-3 text-red-500 hover:text-red-700">
Supprimer
</button>
</td>
</tr>
@empty
<tr>
<td colspan="7" class="px-4 py-6 text-center text-slate-400">Aucune tâche pour le moment.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<div class="mt-4">
{{ $todos->links() }}
</div>
</div>