feat: infrastructure assets management with warranty tracking and EAN lookup integration
This commit is contained in:
148
app/Http/Controllers/AssetController.php
Normal file
148
app/Http/Controllers/AssetController.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Asset;
|
||||
use App\Models\Commune;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class AssetController extends Controller
|
||||
{
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$this->authorize('viewAny', Asset::class);
|
||||
|
||||
$query = Asset::with('commune');
|
||||
|
||||
if ($request->search) {
|
||||
$query->where(function ($q) use ($request) {
|
||||
$q->where('nom', 'like', "%{$request->search}%")
|
||||
->orWhere('numero_serie', 'like', "%{$request->search}%")
|
||||
->orWhere('type', 'like', "%{$request->search}%");
|
||||
});
|
||||
}
|
||||
|
||||
if ($request->type) {
|
||||
$query->where('type', $request->type);
|
||||
}
|
||||
|
||||
if ($request->commune_id) {
|
||||
$query->where('commune_id', $request->commune_id);
|
||||
}
|
||||
|
||||
$assets = $query->latest()->paginate(20)->withQueryString();
|
||||
|
||||
return Inertia::render('Assets/Index', [
|
||||
'assets' => $assets,
|
||||
'filters' => $request->only(['search', 'type', 'commune_id']),
|
||||
'communes' => Commune::orderBy('nom')->get(),
|
||||
'types' => Asset::distinct()->pluck('type'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(): Response
|
||||
{
|
||||
$this->authorize('create', Asset::class);
|
||||
|
||||
return Inertia::render('Assets/Form', [
|
||||
'communes' => Commune::orderBy('nom')->get(),
|
||||
'commandes' => \App\Models\Commande::select('id', 'numero_commande', 'objet')->latest()->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$this->authorize('create', Asset::class);
|
||||
|
||||
$validated = $request->validate([
|
||||
'nom' => 'required|string|max:255',
|
||||
'type' => 'required|string|max:100',
|
||||
'code_ean' => 'nullable|string|max:50',
|
||||
'marque' => 'nullable|string|max:100',
|
||||
'modele' => 'nullable|string|max:100',
|
||||
'numero_serie' => 'nullable|string|max:100',
|
||||
'emplacement' => 'nullable|string|max:255',
|
||||
'commune_id' => 'nullable|exists:communes,id',
|
||||
'commande_id' => 'nullable|exists:commandes,id',
|
||||
'date_achat' => 'nullable|date',
|
||||
'date_fin_garantie' => 'nullable|date',
|
||||
'statut' => 'required|in:en_service,hors_service,en_reparation,stock',
|
||||
'notes' => 'nullable|string',
|
||||
]);
|
||||
|
||||
Asset::create($validated);
|
||||
|
||||
return redirect()->route('assets.index')
|
||||
->with('success', 'Asset ajouté avec succès.');
|
||||
}
|
||||
|
||||
public function show(Asset $asset): Response
|
||||
{
|
||||
$this->authorize('view', $asset);
|
||||
|
||||
$asset->load(['commune', 'commande']);
|
||||
|
||||
return Inertia::render('Assets/Show', [
|
||||
'asset' => $asset,
|
||||
]);
|
||||
}
|
||||
|
||||
public function edit(Asset $asset): Response
|
||||
{
|
||||
$this->authorize('update', $asset);
|
||||
|
||||
return Inertia::render('Assets/Form', [
|
||||
'asset' => $asset,
|
||||
'communes' => Commune::orderBy('nom')->get(),
|
||||
'commandes' => \App\Models\Commande::select('id', 'numero_commande', 'objet')->latest()->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request, Asset $asset): RedirectResponse
|
||||
{
|
||||
$this->authorize('update', $asset);
|
||||
|
||||
$validated = $request->validate([
|
||||
'nom' => 'required|string|max:255',
|
||||
'type' => 'required|string|max:100',
|
||||
'code_ean' => 'nullable|string|max:50',
|
||||
'marque' => 'nullable|string|max:100',
|
||||
'modele' => 'nullable|string|max:100',
|
||||
'numero_serie' => 'nullable|string|max:100',
|
||||
'emplacement' => 'nullable|string|max:255',
|
||||
'commune_id' => 'nullable|exists:communes,id',
|
||||
'commande_id' => 'nullable|exists:commandes,id',
|
||||
'date_achat' => 'nullable|date',
|
||||
'date_fin_garantie' => 'nullable|date',
|
||||
'statut' => 'required|in:en_service,hors_service,en_reparation,stock',
|
||||
'notes' => 'nullable|string',
|
||||
]);
|
||||
|
||||
$asset->update($validated);
|
||||
|
||||
return redirect()->route('assets.index')
|
||||
->with('success', 'Asset mis à jour.');
|
||||
}
|
||||
|
||||
public function destroy(Asset $asset): RedirectResponse
|
||||
{
|
||||
$this->authorize('delete', $asset);
|
||||
|
||||
$asset->delete();
|
||||
|
||||
return redirect()->route('assets.index')
|
||||
->with('success', 'Asset supprimé.');
|
||||
}
|
||||
|
||||
public function lookupEan($ean)
|
||||
{
|
||||
$response = \Illuminate\Support\Facades\Http::get("https://api.upcitemdb.com/prod/trial/lookup", [
|
||||
'upc' => $ean
|
||||
]);
|
||||
|
||||
return response()->json($response->json(), $response->status());
|
||||
}
|
||||
}
|
||||
104
app/Http/Controllers/CalendarController.php
Normal file
104
app/Http/Controllers/CalendarController.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Contrat;
|
||||
use App\Models\Licence;
|
||||
use App\Models\Domaine;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class CalendarController extends Controller
|
||||
{
|
||||
public function index(): Response
|
||||
{
|
||||
return Inertia::render('Calendar/Index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch events for FullCalendar.
|
||||
*/
|
||||
public function events(Request $request)
|
||||
{
|
||||
$events = [];
|
||||
|
||||
// 1. Contracts expirations
|
||||
$contrats = Contrat::with(['fournisseur', 'service'])
|
||||
->whereNotNull('date_echeance')
|
||||
->get();
|
||||
|
||||
foreach ($contrats as $contrat) {
|
||||
$events[] = [
|
||||
'id' => 'contrat-' . $contrat->id,
|
||||
'title' => '📑 ' . $contrat->titre . ' (' . ($contrat->fournisseur->nom ?? 'N/A') . ')',
|
||||
'start' => $contrat->date_echeance->toDateString(),
|
||||
'url' => route('contrats.show', $contrat->id),
|
||||
'backgroundColor' => $this->getContratColor($contrat),
|
||||
'extendedProps' => [
|
||||
'type' => 'Contrat',
|
||||
'service' => $contrat->service->nom ?? 'N/A',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
// 2. Licenses expirations
|
||||
$licences = Licence::with(['fournisseur'])
|
||||
->whereNotNull('date_expiration')
|
||||
->get();
|
||||
|
||||
foreach ($licences as $licence) {
|
||||
$events[] = [
|
||||
'id' => 'licence-' . $licence->id,
|
||||
'title' => '🔑 ' . $licence->nom . ' (' . ($licence->fournisseur->nom ?? 'N/A') . ')',
|
||||
'start' => $licence->date_expiration->toDateString(),
|
||||
'url' => route('licences.index'), // Link to index or show if implemented
|
||||
'backgroundColor' => '#3498db',
|
||||
'extendedProps' => [
|
||||
'type' => 'Licence',
|
||||
'usage' => $licence->nombre_sieges_utilises . '/' . $licence->nombre_sieges_total,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
// 3. Domain expirations
|
||||
$domaines = Domaine::whereNotNull('date_echeance')->get();
|
||||
foreach ($domaines as $domaine) {
|
||||
$events[] = [
|
||||
'id' => 'domaine-' . $domaine->id,
|
||||
'title' => '🌐 ' . $domaine->nom,
|
||||
'start' => $domaine->date_echeance->toDateString(),
|
||||
'url' => route('domaines.index'),
|
||||
'backgroundColor' => '#9b59b6',
|
||||
'extendedProps' => [
|
||||
'type' => 'Domaine',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
// 4. Asset warranties
|
||||
$assets = \App\Models\Asset::whereNotNull('date_fin_garantie')->get();
|
||||
foreach ($assets as $asset) {
|
||||
$events[] = [
|
||||
'id' => 'asset-' . $asset->id,
|
||||
'title' => '🛠️ Garantie : ' . $asset->nom . ' (' . $asset->type . ')',
|
||||
'start' => $asset->date_fin_garantie->toDateString(),
|
||||
'url' => route('assets.show', $asset->id),
|
||||
'backgroundColor' => $asset->garantie_expiree ? '#e74c3c' : '#f1c40f',
|
||||
'extendedProps' => [
|
||||
'type' => 'Asset (Garantie)',
|
||||
'statut' => $asset->statut,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
return response()->json($events);
|
||||
}
|
||||
|
||||
private function getContratColor($contrat): string
|
||||
{
|
||||
if ($contrat->statut === 'expire') return '#e74c3c';
|
||||
if ($contrat->est_proche_echeance) return '#f39c12';
|
||||
return '#27ae60';
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ class CommandeController extends Controller
|
||||
$query = Commande::with(['service', 'fournisseur', 'demandeur'])
|
||||
->when($request->service_id, fn ($q) => $q->parService($request->service_id))
|
||||
->when($request->fournisseur_id, fn ($q) => $q->parFournisseur($request->fournisseur_id))
|
||||
->when($request->commune_id, fn ($q) => $q->where('commune_id', $request->commune_id))
|
||||
->when($request->statut, fn ($q) => $q->parStatut($request->statut))
|
||||
->when($request->priorite, fn ($q) => $q->where('priorite', $request->priorite))
|
||||
->when($request->date_from, fn ($q) => $q->whereDate('date_demande', '>=', $request->date_from))
|
||||
@@ -38,6 +39,7 @@ class CommandeController extends Controller
|
||||
'commandes' => $commandes,
|
||||
'services' => Service::all(),
|
||||
'fournisseurs' => Fournisseur::active()->orderBy('nom')->get(),
|
||||
'communes' => \App\Models\Commune::orderBy('nom')->get(),
|
||||
'filters' => $request->only(['search', 'service_id', 'fournisseur_id', 'statut', 'priorite', 'date_from', 'date_to']),
|
||||
]);
|
||||
}
|
||||
@@ -49,6 +51,7 @@ class CommandeController extends Controller
|
||||
return Inertia::render('Commandes/Create', [
|
||||
'services' => Service::all(),
|
||||
'fournisseurs' => Fournisseur::active()->orderBy('nom')->get(),
|
||||
'communes' => \App\Models\Commune::orderBy('nom')->get(),
|
||||
'categories' => Categorie::active()->orderBy('ordre')->get(),
|
||||
'articles' => Article::active()->with('categorie')->orderBy('designation')->get(),
|
||||
]);
|
||||
@@ -61,6 +64,7 @@ class CommandeController extends Controller
|
||||
$validated = $request->validate([
|
||||
'service_id' => 'required|exists:services,id',
|
||||
'fournisseur_id' => 'nullable|exists:fournisseurs,id',
|
||||
'commune_id' => 'nullable|exists:communes,id',
|
||||
'objet' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'justification' => 'nullable|string',
|
||||
@@ -106,10 +110,11 @@ class CommandeController extends Controller
|
||||
$this->authorize('view', $commande);
|
||||
|
||||
$commande->load([
|
||||
'service', 'fournisseur', 'demandeur', 'validateur', 'acheteur',
|
||||
'service', 'fournisseur', 'demandeur', 'validateur', 'acheteur', 'commune',
|
||||
'lignes.categorie',
|
||||
'historique.user',
|
||||
'piecesJointes.user',
|
||||
'assets',
|
||||
]);
|
||||
|
||||
$transitionsDisponibles = collect(Commande::STATUT_TRANSITIONS[$commande->statut] ?? [])
|
||||
@@ -132,6 +137,7 @@ class CommandeController extends Controller
|
||||
'commande' => $commande,
|
||||
'services' => Service::all(),
|
||||
'fournisseurs' => Fournisseur::active()->orderBy('nom')->get(),
|
||||
'communes' => \App\Models\Commune::orderBy('nom')->get(),
|
||||
'categories' => Categorie::active()->orderBy('ordre')->get(),
|
||||
'articles' => Article::active()->with('categorie')->orderBy('designation')->get(),
|
||||
]);
|
||||
@@ -144,6 +150,7 @@ class CommandeController extends Controller
|
||||
$validated = $request->validate([
|
||||
'service_id' => 'required|exists:services,id',
|
||||
'fournisseur_id' => 'nullable|exists:fournisseurs,id',
|
||||
'commune_id' => 'nullable|exists:communes,id',
|
||||
'objet' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'justification' => 'nullable|string',
|
||||
@@ -234,7 +241,7 @@ class CommandeController extends Controller
|
||||
$this->authorize('view', $commande);
|
||||
|
||||
$commande->load([
|
||||
'service', 'fournisseur', 'demandeur', 'validateur', 'acheteur',
|
||||
'service', 'fournisseur', 'demandeur', 'validateur', 'acheteur', 'commune',
|
||||
'lignes.categorie',
|
||||
]);
|
||||
|
||||
|
||||
54
app/Http/Controllers/CommuneController.php
Normal file
54
app/Http/Controllers/CommuneController.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Commune;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class CommuneController extends Controller
|
||||
{
|
||||
public function index(): Response
|
||||
{
|
||||
return Inertia::render('Communes/Index', [
|
||||
'communes' => Commune::withCount('commandes', 'contrats')->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'nom' => 'required|string|max:100|unique:communes,nom',
|
||||
'code_postal' => 'nullable|string|max:10',
|
||||
]);
|
||||
|
||||
Commune::create($validated);
|
||||
|
||||
return back()->with('success', 'Commune créée.');
|
||||
}
|
||||
|
||||
public function update(Request $request, Commune $commune): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'nom' => 'required|string|max:100|unique:communes,nom,' . $commune->id,
|
||||
'code_postal' => 'nullable|string|max:10',
|
||||
]);
|
||||
|
||||
$commune->update($validated);
|
||||
|
||||
return back()->with('success', 'Commune mise à jour.');
|
||||
}
|
||||
|
||||
public function destroy(Commune $commune): RedirectResponse
|
||||
{
|
||||
if ($commune->commandes()->exists() || $commune->contrats()->exists()) {
|
||||
return back()->with('error', 'Impossible de supprimer une commune liée à des commandes ou des contrats.');
|
||||
}
|
||||
|
||||
$commune->delete();
|
||||
|
||||
return back()->with('success', 'Commune supprimée.');
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,8 @@ class ContratController extends Controller
|
||||
}
|
||||
})->when($request->fournisseur_id, function ($q, $fournisseurId) {
|
||||
$q->where('fournisseur_id', $fournisseurId);
|
||||
})->when($request->commune_id, function ($q, $communeId) {
|
||||
$q->where('commune_id', $communeId);
|
||||
})->when($request->statut, function ($q, $statut) {
|
||||
$q->where('statut', $statut);
|
||||
});
|
||||
@@ -50,6 +52,7 @@ class ContratController extends Controller
|
||||
'contrats' => $contrats,
|
||||
'services' => $request->user()->hasRole('admin') ? Service::all() : Service::where('id', $request->user()->service_id)->get(),
|
||||
'fournisseurs' => Fournisseur::active()->orderBy('nom')->get(),
|
||||
'communes' => \App\Models\Commune::orderBy('nom')->get(),
|
||||
'filters' => $request->only(['search', 'service_id', 'fournisseur_id', 'statut']),
|
||||
'statuts' => Contrat::STATUTS_LABELS,
|
||||
]);
|
||||
@@ -62,6 +65,7 @@ class ContratController extends Controller
|
||||
return Inertia::render('Contrats/Create', [
|
||||
'services' => $request->user()->hasRole('admin') ? Service::all() : Service::where('id', $request->user()->service_id)->get(),
|
||||
'fournisseurs' => Fournisseur::active()->orderBy('nom')->get(),
|
||||
'communes' => \App\Models\Commune::orderBy('nom')->get(),
|
||||
'statuts' => Contrat::STATUTS_LABELS,
|
||||
]);
|
||||
}
|
||||
@@ -102,7 +106,7 @@ class ContratController extends Controller
|
||||
{
|
||||
$this->authorize('view', $contrat);
|
||||
|
||||
$contrat->load(['fournisseur', 'service', 'piecesJointes.user']);
|
||||
$contrat->load(['fournisseur', 'service', 'commune', 'piecesJointes.user']);
|
||||
$contrat->append(['est_proche_echeance', 'est_en_retard']);
|
||||
|
||||
return Inertia::render('Contrats/Show', [
|
||||
@@ -118,6 +122,7 @@ class ContratController extends Controller
|
||||
'contrat' => $contrat,
|
||||
'services' => $request->user()->hasRole('admin') ? Service::all() : Service::where('id', $request->user()->service_id)->get(),
|
||||
'fournisseurs' => Fournisseur::active()->orderBy('nom')->get(),
|
||||
'communes' => \App\Models\Commune::orderBy('nom')->get(),
|
||||
'statuts' => Contrat::STATUTS_LABELS,
|
||||
]);
|
||||
}
|
||||
|
||||
118
app/Http/Controllers/LicenceController.php
Normal file
118
app/Http/Controllers/LicenceController.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Commune;
|
||||
use App\Models\Contrat;
|
||||
use App\Models\Fournisseur;
|
||||
use App\Models\Licence;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class LicenceController extends Controller
|
||||
{
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$this->authorize('viewAny', Licence::class);
|
||||
|
||||
$query = Licence::with(['fournisseur', 'contrat', 'commune']);
|
||||
|
||||
if (!$request->user()->hasRole('admin')) {
|
||||
$query->where('commune_id', $request->user()->commune_id);
|
||||
}
|
||||
|
||||
$licences = $query->orderBy('date_expiration', 'asc')->paginate(20)->withQueryString();
|
||||
|
||||
return Inertia::render('Licences/Index', [
|
||||
'licences' => $licences,
|
||||
'filters' => $request->only(['search', 'commune_id', 'fournisseur_id']),
|
||||
'communes' => Commune::orderBy('nom')->get(),
|
||||
'fournisseurs' => Fournisseur::active()->orderBy('nom')->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(): Response
|
||||
{
|
||||
$this->authorize('create', Licence::class);
|
||||
|
||||
return Inertia::render('Licences/Form', [
|
||||
'contrats' => Contrat::orderBy('titre')->get(),
|
||||
'fournisseurs' => Fournisseur::active()->orderBy('nom')->get(),
|
||||
'communes' => Commune::orderBy('nom')->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$this->authorize('create', Licence::class);
|
||||
|
||||
$validated = $request->validate([
|
||||
'nom' => 'required|string|max:255',
|
||||
'contrat_id' => 'nullable|exists:contrats,id',
|
||||
'fournisseur_id' => 'required|exists:fournisseurs,id',
|
||||
'commune_id' => 'nullable|exists:communes,id',
|
||||
'cle_licence' => 'nullable|string',
|
||||
'nombre_sieges_total' => 'required|integer|min:1',
|
||||
'nombre_sieges_utilises' => 'required|integer|min:0',
|
||||
'date_acquisition' => 'nullable|date',
|
||||
'date_expiration' => 'nullable|date',
|
||||
'type_licence' => 'required|in:perpétuelle,abonnement',
|
||||
'statut' => 'required|in:active,expirée,résiliée',
|
||||
'notes' => 'nullable|string',
|
||||
]);
|
||||
|
||||
Licence::create($validated);
|
||||
|
||||
return redirect()->route('licences.index')
|
||||
->with('success', 'Licence créée avec succès.');
|
||||
}
|
||||
|
||||
public function edit(Licence $licence): Response
|
||||
{
|
||||
$this->authorize('update', $licence);
|
||||
|
||||
return Inertia::render('Licences/Form', [
|
||||
'licence' => $licence,
|
||||
'contrats' => Contrat::orderBy('titre')->get(),
|
||||
'fournisseurs' => Fournisseur::active()->orderBy('nom')->get(),
|
||||
'communes' => Commune::orderBy('nom')->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request, Licence $licence): RedirectResponse
|
||||
{
|
||||
$this->authorize('update', $licence);
|
||||
|
||||
$validated = $request->validate([
|
||||
'nom' => 'required|string|max:255',
|
||||
'contrat_id' => 'nullable|exists:contrats,id',
|
||||
'fournisseur_id' => 'required|exists:fournisseurs,id',
|
||||
'commune_id' => 'nullable|exists:communes,id',
|
||||
'cle_licence' => 'nullable|string',
|
||||
'nombre_sieges_total' => 'required|integer|min:1',
|
||||
'nombre_sieges_utilises' => 'required|integer|min:0',
|
||||
'date_acquisition' => 'nullable|date',
|
||||
'date_expiration' => 'nullable|date',
|
||||
'type_licence' => 'required|in:perpétuelle,abonnement',
|
||||
'statut' => 'required|in:active,expirée,résiliée',
|
||||
'notes' => 'nullable|string',
|
||||
]);
|
||||
|
||||
$licence->update($validated);
|
||||
|
||||
return redirect()->route('licences.index')
|
||||
->with('success', 'Licence mise à jour.');
|
||||
}
|
||||
|
||||
public function destroy(Licence $licence): RedirectResponse
|
||||
{
|
||||
$this->authorize('delete', $licence);
|
||||
|
||||
$licence->delete();
|
||||
|
||||
return redirect()->route('licences.index')
|
||||
->with('success', 'Licence supprimée.');
|
||||
}
|
||||
}
|
||||
71
app/Models/Asset.php
Normal file
71
app/Models/Asset.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Asset extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'nom',
|
||||
'type',
|
||||
'code_ean',
|
||||
'marque',
|
||||
'modele',
|
||||
'numero_serie',
|
||||
'emplacement',
|
||||
'commune_id',
|
||||
'commande_id',
|
||||
'date_achat',
|
||||
'date_fin_garantie',
|
||||
'statut',
|
||||
'notes',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'date_achat' => 'date',
|
||||
'date_fin_garantie' => 'date',
|
||||
];
|
||||
|
||||
public function commune(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Commune::class);
|
||||
}
|
||||
|
||||
public function commande(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Commande::class);
|
||||
}
|
||||
|
||||
public function getEstSousGarantieAttribute(): bool
|
||||
{
|
||||
if (!$this->date_fin_garantie) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Carbon::now()->isBefore($this->date_fin_garantie);
|
||||
}
|
||||
|
||||
public function getGarantieExpireeAttribute(): bool
|
||||
{
|
||||
if (!$this->date_fin_garantie) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Carbon::now()->isAfter($this->date_fin_garantie);
|
||||
}
|
||||
|
||||
public function getEstProcheExpirationGarantieAttribute(): bool
|
||||
{
|
||||
if (!$this->date_fin_garantie || $this->garantie_expiree) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Carbon::now()->diffInDays($this->date_fin_garantie, false) <= 30;
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ class Commande extends Model
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'numero_commande', 'service_id', 'fournisseur_id', 'user_id',
|
||||
'numero_commande', 'service_id', 'fournisseur_id', 'user_id', 'commune_id',
|
||||
'validateur_id', 'acheteur_id', 'objet', 'description', 'justification',
|
||||
'statut', 'priorite', 'reference_fournisseur', 'imputation_budgetaire',
|
||||
'montant_ht', 'montant_ttc',
|
||||
@@ -98,11 +98,21 @@ class Commande extends Model
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
|
||||
public function commune(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Commune::class);
|
||||
}
|
||||
|
||||
public function validateur(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'validateur_id');
|
||||
}
|
||||
|
||||
public function assets(): HasMany
|
||||
{
|
||||
return $this->hasMany(Asset::class);
|
||||
}
|
||||
|
||||
public function acheteur(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'acheteur_id');
|
||||
|
||||
21
app/Models/Commune.php
Normal file
21
app/Models/Commune.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Commune extends Model
|
||||
{
|
||||
protected $fillable = ['nom', 'code_postal'];
|
||||
|
||||
public function commandes(): HasMany
|
||||
{
|
||||
return $this->hasMany(Commande::class);
|
||||
}
|
||||
|
||||
public function contrats(): HasMany
|
||||
{
|
||||
return $this->hasMany(Contrat::class);
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ class Contrat extends Model
|
||||
'description',
|
||||
'fournisseur_id',
|
||||
'service_id',
|
||||
'commune_id',
|
||||
'date_debut',
|
||||
'date_echeance',
|
||||
'statut',
|
||||
@@ -47,11 +48,21 @@ class Contrat extends Model
|
||||
return $this->belongsTo(Service::class);
|
||||
}
|
||||
|
||||
public function commune(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Commune::class);
|
||||
}
|
||||
|
||||
public function piecesJointes(): HasMany
|
||||
{
|
||||
return $this->hasMany(PieceJointe::class)->orderByDesc('created_at');
|
||||
}
|
||||
|
||||
public function licences(): HasMany
|
||||
{
|
||||
return $this->hasMany(Licence::class);
|
||||
}
|
||||
|
||||
// Un contrat est considéré "proche d'expiration" si l'échéance est dans moins de 30 jours (ou selon son préavis)
|
||||
public function getEstProcheEcheanceAttribute(): bool
|
||||
{
|
||||
|
||||
60
app/Models/Licence.php
Normal file
60
app/Models/Licence.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Licence extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'contrat_id',
|
||||
'fournisseur_id',
|
||||
'commune_id',
|
||||
'nom',
|
||||
'cle_licence',
|
||||
'nombre_sieges_total',
|
||||
'nombre_sieges_utilises',
|
||||
'date_acquisition',
|
||||
'date_expiration',
|
||||
'type_licence',
|
||||
'statut',
|
||||
'notes',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'date_acquisition' => 'date',
|
||||
'date_expiration' => 'date',
|
||||
'cle_licence' => 'encrypted', // Encrypted storage for license keys
|
||||
];
|
||||
|
||||
public function contrat(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Contrat::class);
|
||||
}
|
||||
|
||||
public function fournisseur(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Fournisseur::class);
|
||||
}
|
||||
|
||||
public function commune(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Commune::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the usage rate as a percentage.
|
||||
*/
|
||||
public function getTauxUtilisationAttribute(): float
|
||||
{
|
||||
if ($this->nombre_sieges_total <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return round(($this->nombre_sieges_utilises / $this->nombre_sieges_total) * 100, 2);
|
||||
}
|
||||
}
|
||||
53
app/Policies/AssetPolicy.php
Normal file
53
app/Policies/AssetPolicy.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Asset;
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Access\Response;
|
||||
|
||||
class AssetPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, Asset $asset): bool
|
||||
{
|
||||
if ($user->hasRole('admin')) return true;
|
||||
return $user->commune_id === $asset->commune_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, Asset $asset): bool
|
||||
{
|
||||
if ($user->hasRole('admin')) return true;
|
||||
return $user->commune_id === $asset->commune_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, Asset $asset): bool
|
||||
{
|
||||
if ($user->hasRole('admin')) return true;
|
||||
return $user->commune_id === $asset->commune_id;
|
||||
}
|
||||
}
|
||||
53
app/Policies/LicencePolicy.php
Normal file
53
app/Policies/LicencePolicy.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Licence;
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Access\Response;
|
||||
|
||||
class LicencePolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return true; // Everyone can see the list (filtered in controller)
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, Licence $licence): bool
|
||||
{
|
||||
if ($user->hasRole('admin')) return true;
|
||||
return $user->commune_id === $licence->commune_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return true; // Simple users can create
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, Licence $licence): bool
|
||||
{
|
||||
if ($user->hasRole('admin')) return true;
|
||||
return $user->commune_id === $licence->commune_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, Licence $licence): bool
|
||||
{
|
||||
if ($user->hasRole('admin')) return true;
|
||||
return $user->commune_id === $licence->commune_id;
|
||||
}
|
||||
}
|
||||
649
composer.lock
generated
649
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -11,7 +11,13 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
if (Schema::getConnection()->getDriverName() === 'mysql') {
|
||||
\Illuminate\Support\Facades\DB::statement("ALTER TABLE pieces_jointes MODIFY type ENUM('devis', 'bon_commande', 'bon_livraison', 'facture', 'autre', 'contrat', 'avenant') NOT NULL;");
|
||||
} else {
|
||||
Schema::table('pieces_jointes', function (Blueprint $table) {
|
||||
$table->string('type')->change();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -19,6 +25,12 @@ return new class extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
if (Schema::getConnection()->getDriverName() === 'mysql') {
|
||||
\Illuminate\Support\Facades\DB::statement("ALTER TABLE pieces_jointes MODIFY type ENUM('devis', 'bon_commande', 'bon_livraison', 'facture', 'autre') NOT NULL;");
|
||||
} else {
|
||||
Schema::table('pieces_jointes', function (Blueprint $table) {
|
||||
$table->string('type')->change();
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('communes', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('nom')->unique();
|
||||
$table->string('code_postal')->nullable(); // Optionnel mais utile
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('communes');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('commandes', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('commandes', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('commandes', function (Blueprint $table) {
|
||||
$table->foreignId('commune_id')->nullable()->after('id')->constrained('communes')->nullOnDelete();
|
||||
});
|
||||
|
||||
Schema::table('contrats', function (Blueprint $table) {
|
||||
$table->foreignId('commune_id')->nullable()->after('id')->constrained('communes')->nullOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('commandes', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('commune_id');
|
||||
});
|
||||
|
||||
Schema::table('contrats', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('commune_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('licences', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('contrat_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignId('fournisseur_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('commune_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->string('nom');
|
||||
$table->text('cle_licence')->nullable();
|
||||
$table->integer('nombre_sieges_total')->default(1);
|
||||
$table->integer('nombre_sieges_utilises')->default(0);
|
||||
$table->date('date_acquisition')->nullable();
|
||||
$table->date('date_expiration')->nullable();
|
||||
$table->enum('type_licence', ['perpétuelle', 'abonnement'])->default('abonnement');
|
||||
$table->enum('statut', ['active', 'expirée', 'résiliée'])->default('active');
|
||||
$table->text('notes')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('licences');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('assets', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('nom');
|
||||
$table->string('type'); // Serveur, Switch, NAS, Baie, etc.
|
||||
$table->string('marque')->nullable();
|
||||
$table->string('modele')->nullable();
|
||||
$table->string('numero_serie')->nullable();
|
||||
$table->string('emplacement')->nullable();
|
||||
$table->foreignId('commune_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->date('date_achat')->nullable();
|
||||
$table->date('date_fin_garantie')->nullable();
|
||||
$table->enum('statut', ['en_service', 'hors_service', 'en_reparation', 'stock'])->default('en_service');
|
||||
$table->text('notes')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('assets');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('assets', function (Blueprint $table) {
|
||||
$table->foreignId('commande_id')->nullable()->after('commune_id')->constrained()->nullOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('assets', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('commande_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('assets', function (Blueprint $table) {
|
||||
$table->string('code_ean')->nullable()->after('type');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('assets', function (Blueprint $table) {
|
||||
$table->dropColumn('code_ean');
|
||||
});
|
||||
}
|
||||
};
|
||||
43
database/seeders/CommuneSeeder.php
Normal file
43
database/seeders/CommuneSeeder.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CommuneSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$communes = [
|
||||
'CABM (Agglomération)',
|
||||
'Alignan-du-Vent',
|
||||
'Bassan',
|
||||
'Béziers',
|
||||
'Boujan-sur-Libron',
|
||||
'Cers',
|
||||
'Corneilhan',
|
||||
'Coulobres',
|
||||
'Espondeilhan',
|
||||
'Lieuran-lès-Béziers',
|
||||
'Lignan-sur-Orb',
|
||||
'Montblanc',
|
||||
'Sauvian',
|
||||
'Sérignan',
|
||||
'Servian',
|
||||
'Valras-Plage',
|
||||
'Valros',
|
||||
'Villeneuve-lès-Béziers',
|
||||
];
|
||||
|
||||
foreach ($communes as $commune) {
|
||||
DB::table('communes')->updateOrInsert(
|
||||
['nom' => $commune],
|
||||
['created_at' => now(), 'updated_at' => now()]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ class DatabaseSeeder extends Seeder
|
||||
CategorieSeeder::class,
|
||||
RolesPermissionsSeeder::class,
|
||||
AdminUserSeeder::class,
|
||||
CommuneSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
78
package-lock.json
generated
78
package-lock.json
generated
@@ -1,9 +1,15 @@
|
||||
{
|
||||
"name": "Commandes",
|
||||
"name": "DSICommander",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"dependencies": {
|
||||
"@fullcalendar/core": "^6.1.20",
|
||||
"@fullcalendar/daygrid": "^6.1.20",
|
||||
"@fullcalendar/interaction": "^6.1.20",
|
||||
"@fullcalendar/vue3": "^6.1.20"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@inertiajs/vue3": "^2.0.0",
|
||||
"@tailwindcss/forms": "^0.5.3",
|
||||
@@ -36,7 +42,6 @@
|
||||
"version": "7.27.1",
|
||||
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz",
|
||||
"integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
@@ -46,7 +51,6 @@
|
||||
"version": "7.28.5",
|
||||
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz",
|
||||
"integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
@@ -56,7 +60,6 @@
|
||||
"version": "7.29.2",
|
||||
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.2.tgz",
|
||||
"integrity": "sha512-4GgRzy/+fsBa72/RZVJmGKPmZu9Byn8o4MoLpmNe1m8ZfYnz5emHLQz3U4gLud6Zwl0RZIcgiLD7Uq7ySFuDLA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/types": "^7.29.0"
|
||||
@@ -72,7 +75,6 @@
|
||||
"version": "7.29.0",
|
||||
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.0.tgz",
|
||||
"integrity": "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/helper-string-parser": "^7.27.1",
|
||||
@@ -116,6 +118,43 @@
|
||||
"tslib": "^2.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@fullcalendar/core": {
|
||||
"version": "6.1.20",
|
||||
"resolved": "https://registry.npmjs.org/@fullcalendar/core/-/core-6.1.20.tgz",
|
||||
"integrity": "sha512-1cukXLlePFiJ8YKXn/4tMKsy0etxYLCkXk8nUCFi11nRONF2Ba2CD5b21/ovtOO2tL6afTJfwmc1ed3HG7eB1g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"preact": "~10.12.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@fullcalendar/daygrid": {
|
||||
"version": "6.1.20",
|
||||
"resolved": "https://registry.npmjs.org/@fullcalendar/daygrid/-/daygrid-6.1.20.tgz",
|
||||
"integrity": "sha512-AO9vqhkLP77EesmJzuU+IGXgxNulsA8mgQHynclJ8U70vSwAVnbcLG9qftiTAFSlZjiY/NvhE7sflve6cJelyQ==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"@fullcalendar/core": "~6.1.20"
|
||||
}
|
||||
},
|
||||
"node_modules/@fullcalendar/interaction": {
|
||||
"version": "6.1.20",
|
||||
"resolved": "https://registry.npmjs.org/@fullcalendar/interaction/-/interaction-6.1.20.tgz",
|
||||
"integrity": "sha512-p6txmc5txL0bMiPaJxe2ip6o0T384TyoD2KGdsU6UjZ5yoBlaY+dg7kxfnYKpYMzEJLG58n+URrHr2PgNL2fyA==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"@fullcalendar/core": "~6.1.20"
|
||||
}
|
||||
},
|
||||
"node_modules/@fullcalendar/vue3": {
|
||||
"version": "6.1.20",
|
||||
"resolved": "https://registry.npmjs.org/@fullcalendar/vue3/-/vue3-6.1.20.tgz",
|
||||
"integrity": "sha512-8qg6pS27II9QBwFkkJC+7SfflMpWqOe7i3ii5ODq9KpLAjwQAd/zjfq8RvKR1Yryoh5UmMCmvRbMB7i4RGtqog==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"@fullcalendar/core": "~6.1.20",
|
||||
"vue": "^3.0.11"
|
||||
}
|
||||
},
|
||||
"node_modules/@inertiajs/core": {
|
||||
"version": "2.3.18",
|
||||
"resolved": "https://registry.npmjs.org/@inertiajs/core/-/core-2.3.18.tgz",
|
||||
@@ -182,7 +221,6 @@
|
||||
"version": "1.5.5",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz",
|
||||
"integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@jridgewell/trace-mapping": {
|
||||
@@ -873,7 +911,6 @@
|
||||
"version": "3.5.31",
|
||||
"resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.31.tgz",
|
||||
"integrity": "sha512-k/ueL14aNIEy5Onf0OVzR8kiqF/WThgLdFhxwa4e/KF/0qe38IwIdofoSWBTvvxQOesaz6riAFAUaYjoF9fLLQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/parser": "^7.29.2",
|
||||
@@ -887,7 +924,6 @@
|
||||
"version": "3.5.31",
|
||||
"resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.31.tgz",
|
||||
"integrity": "sha512-BMY/ozS/xxjYqRFL+tKdRpATJYDTTgWSo0+AJvJNg4ig+Hgb0dOsHPXvloHQ5hmlivUqw1Yt2pPIqp4e0v1GUw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vue/compiler-core": "3.5.31",
|
||||
@@ -898,7 +934,6 @@
|
||||
"version": "3.5.31",
|
||||
"resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.31.tgz",
|
||||
"integrity": "sha512-M8wpPgR9UJ8MiRGjppvx9uWJfLV7A/T+/rL8s/y3QG3u0c2/YZgff3d6SuimKRIhcYnWg5fTfDMlz2E6seUW8Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/parser": "^7.29.2",
|
||||
@@ -916,7 +951,6 @@
|
||||
"version": "3.5.31",
|
||||
"resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.31.tgz",
|
||||
"integrity": "sha512-h0xIMxrt/LHOvJKMri+vdYT92BrK3HFLtDqq9Pr/lVVfE4IyKZKvWf0vJFW10Yr6nX02OR4MkJwI0c1HDa1hog==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vue/compiler-dom": "3.5.31",
|
||||
@@ -927,7 +961,6 @@
|
||||
"version": "3.5.31",
|
||||
"resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.31.tgz",
|
||||
"integrity": "sha512-DtKXxk9E/KuVvt8VxWu+6Luc9I9ETNcqR1T1oW1gf02nXaZ1kuAx58oVu7uX9XxJR0iJCro6fqBLw9oSBELo5g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vue/shared": "3.5.31"
|
||||
@@ -937,7 +970,6 @@
|
||||
"version": "3.5.31",
|
||||
"resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.31.tgz",
|
||||
"integrity": "sha512-AZPmIHXEAyhpkmN7aWlqjSfYynmkWlluDNPHMCZKFHH+lLtxP/30UJmoVhXmbDoP1Ng0jG0fyY2zCj1PnSSA6Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vue/reactivity": "3.5.31",
|
||||
@@ -948,7 +980,6 @@
|
||||
"version": "3.5.31",
|
||||
"resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.31.tgz",
|
||||
"integrity": "sha512-xQJsNRmGPeDCJq/u813tyonNgWBFjzfVkBwDREdEWndBnGdHLHgkwNBQxLtg4zDrzKTEcnikUy1UUNecb3lJ6g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vue/reactivity": "3.5.31",
|
||||
@@ -961,7 +992,6 @@
|
||||
"version": "3.5.31",
|
||||
"resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.31.tgz",
|
||||
"integrity": "sha512-GJuwRvMcdZX/CriUnyIIOGkx3rMV3H6sOu0JhdKbduaeCji6zb60iOGMY7tFoN24NfsUYoFBhshZtGxGpxO4iA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vue/compiler-ssr": "3.5.31",
|
||||
@@ -975,7 +1005,6 @@
|
||||
"version": "3.5.31",
|
||||
"resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.31.tgz",
|
||||
"integrity": "sha512-nBxuiuS9Lj5bPkPbWogPUnjxxWpkRniX7e5UBQDWl6Fsf4roq9wwV+cR7ezQ4zXswNvPIlsdj1slcLB7XCsRAw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/ansi-regex": {
|
||||
@@ -1391,7 +1420,6 @@
|
||||
"version": "3.2.3",
|
||||
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
|
||||
"integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/delayed-stream": {
|
||||
@@ -1475,7 +1503,6 @@
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/entities/-/entities-7.0.1.tgz",
|
||||
"integrity": "sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==",
|
||||
"dev": true,
|
||||
"license": "BSD-2-Clause",
|
||||
"engines": {
|
||||
"node": ">=0.12"
|
||||
@@ -1547,7 +1574,6 @@
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz",
|
||||
"integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/fast-glob": {
|
||||
@@ -2220,7 +2246,6 @@
|
||||
"version": "0.30.21",
|
||||
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",
|
||||
"integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jridgewell/sourcemap-codec": "^1.5.5"
|
||||
@@ -2309,7 +2334,6 @@
|
||||
"version": "3.3.11",
|
||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz",
|
||||
"integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
@@ -2385,7 +2409,6 @@
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
|
||||
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/picomatch": {
|
||||
@@ -2425,7 +2448,6 @@
|
||||
"version": "8.5.8",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.8.tgz",
|
||||
"integrity": "sha512-OW/rX8O/jXnm82Ey1k44pObPtdblfiuWnrd8X7GJ7emImCOstunGbXUpp7HdBrFQX6rJzn3sPT397Wp5aCwCHg==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
"type": "opencollective",
|
||||
@@ -2584,6 +2606,16 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/preact": {
|
||||
"version": "10.12.1",
|
||||
"resolved": "https://registry.npmjs.org/preact/-/preact-10.12.1.tgz",
|
||||
"integrity": "sha512-l8386ixSsBdbreOAkqtrwqHwdvR35ID8c3rKPa8lCWuO86dBi32QWHV4vfsZK1utLLFMvw+Z5Ad4XLkZzchscg==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/preact"
|
||||
}
|
||||
},
|
||||
"node_modules/proxy-from-env": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-2.1.0.tgz",
|
||||
@@ -2864,7 +2896,6 @@
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
|
||||
"integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
@@ -3264,7 +3295,6 @@
|
||||
"version": "3.5.31",
|
||||
"resolved": "https://registry.npmjs.org/vue/-/vue-3.5.31.tgz",
|
||||
"integrity": "sha512-iV/sU9SzOlmA/0tygSmjkEN6Jbs3nPoIPFhCMLD2STrjgOU8DX7ZtzMhg4ahVwf5Rp9KoFzcXeB1ZrVbLBp5/Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vue/compiler-dom": "3.5.31",
|
||||
|
||||
@@ -19,5 +19,11 @@
|
||||
"tailwindcss": "^3.2.1",
|
||||
"vite": "^8.0.0",
|
||||
"vue": "^3.4.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fullcalendar/core": "^6.1.20",
|
||||
"@fullcalendar/daygrid": "^6.1.20",
|
||||
"@fullcalendar/interaction": "^6.1.20",
|
||||
"@fullcalendar/vue3": "^6.1.20"
|
||||
}
|
||||
}
|
||||
|
||||
BIN
public/images/logo_agglo.png
Normal file
BIN
public/images/logo_agglo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
BIN
public/images/logo_agglo_20-bleu.png
Normal file
BIN
public/images/logo_agglo_20-bleu.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 186 KiB |
@@ -105,6 +105,14 @@ function isActive(...names) {
|
||||
</svg>
|
||||
Noms de domaine
|
||||
</Link>
|
||||
<Link :href="route('assets.index')"
|
||||
:class="['flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium transition-colors',
|
||||
isActive('assets') ? 'bg-blue-600 text-white' : 'text-gray-300 hover:bg-gray-800 hover:text-white']">
|
||||
<svg class="h-5 w-5 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2m-2-4h.01M17 16h.01" />
|
||||
</svg>
|
||||
Assets (Matériels)
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -164,6 +172,33 @@ function isActive(...names) {
|
||||
</svg>
|
||||
Services
|
||||
</Link>
|
||||
<Link :href="route('licences.index')"
|
||||
:class="['flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium transition-colors',
|
||||
isActive('licences') ? 'bg-blue-600 text-white' : 'text-gray-300 hover:bg-gray-800 hover:text-white']">
|
||||
<svg class="h-5 w-5 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z" />
|
||||
</svg>
|
||||
Licences
|
||||
</Link>
|
||||
<Link :href="route('calendar.index')"
|
||||
:class="['flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium transition-colors',
|
||||
isActive('calendar') ? 'bg-blue-600 text-white' : 'text-gray-300 hover:bg-gray-800 hover:text-white']">
|
||||
<svg class="h-5 w-5 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" />
|
||||
</svg>
|
||||
Calendrier
|
||||
</Link>
|
||||
<Link :href="route('communes.index')"
|
||||
:class="['flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium transition-colors',
|
||||
isActive('communes') ? 'bg-blue-600 text-white' : 'text-gray-300 hover:bg-gray-800 hover:text-white']">
|
||||
<svg class="h-5 w-5 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4" />
|
||||
</svg>
|
||||
Communes
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
267
resources/js/Pages/Assets/Form.vue
Normal file
267
resources/js/Pages/Assets/Form.vue
Normal file
@@ -0,0 +1,267 @@
|
||||
<script setup>
|
||||
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout.vue'
|
||||
import { Head, Link, useForm } from '@inertiajs/vue3'
|
||||
import { ref } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
asset: Object,
|
||||
communes: Array,
|
||||
commandes: Array,
|
||||
})
|
||||
|
||||
const isEdit = !!props.asset
|
||||
|
||||
const form = useForm({
|
||||
nom: props.asset?.nom || '',
|
||||
type: props.asset?.type || '',
|
||||
marque: props.asset?.marque || '',
|
||||
modele: props.asset?.modele || '',
|
||||
numero_serie: props.asset?.numero_serie || '',
|
||||
emplacement: props.asset?.emplacement || '',
|
||||
commune_id: props.asset?.commune_id || '',
|
||||
date_achat: props.asset?.date_achat ? props.asset.date_achat.substring(0, 10) : '',
|
||||
date_fin_garantie: props.asset?.date_fin_garantie ? props.asset.date_fin_garantie.substring(0, 10) : '',
|
||||
statut: props.asset?.statut || 'en_service',
|
||||
commande_id: props.asset?.commande_id || '',
|
||||
code_ean: props.asset?.code_ean || '',
|
||||
notes: props.asset?.notes || '',
|
||||
})
|
||||
|
||||
const isSearchingEan = ref(false)
|
||||
const eanError = ref('')
|
||||
const eanSuccess = ref('')
|
||||
|
||||
async function fetchEanDetails() {
|
||||
if (!form.code_ean) return
|
||||
|
||||
isSearchingEan.value = true
|
||||
eanError.value = ''
|
||||
eanSuccess.value = ''
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/ean-lookup/${form.code_ean}`)
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('API limit or error')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
if (data.code === 'OK' && data.items && data.items.length > 0) {
|
||||
const item = data.items[0]
|
||||
|
||||
if (item.title && !form.nom) form.nom = item.title
|
||||
if (item.brand && !form.marque) form.marque = item.brand
|
||||
if (item.model && !form.modele) form.modele = item.model
|
||||
|
||||
// Infer type loosely
|
||||
if (!form.type && item.category) {
|
||||
const cat = item.category.toLowerCase()
|
||||
if (cat.includes('server') || cat.includes('serveur')) form.type = 'Serveur'
|
||||
else if (cat.includes('switch') || cat.includes('router') || cat.includes('network')) form.type = 'Switch'
|
||||
else if (cat.includes('storage') || cat.includes('nas')) form.type = 'NAS'
|
||||
else form.type = item.category.split('>').pop().trim()
|
||||
}
|
||||
|
||||
eanSuccess.value = "Informations pré-remplies avec succès."
|
||||
} else {
|
||||
eanError.value = 'Aucun produit trouvé pour ce code.'
|
||||
}
|
||||
} catch (error) {
|
||||
eanError.value = 'Erreur API ou limite atteinte.'
|
||||
} finally {
|
||||
isSearchingEan.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function submit() {
|
||||
if (isEdit) {
|
||||
form.put(route('assets.update', props.asset.id))
|
||||
} else {
|
||||
form.post(route('assets.store'))
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Head :title="isEdit ? 'Modifier Asset' : 'Nouvel Asset'" />
|
||||
<AuthenticatedLayout>
|
||||
<template #header>
|
||||
<div class="flex items-center gap-3">
|
||||
<Link :href="route('assets.index')" class="text-gray-400 hover:text-gray-600 transition-colors">
|
||||
<svg class="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" />
|
||||
</svg>
|
||||
</Link>
|
||||
<h1 class="text-xl font-semibold text-gray-900">{{ isEdit ? 'Modifier l\'équipement' : 'Ajouter un équipement' }}</h1>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="max-w-4xl pb-12">
|
||||
<form @submit.prevent="submit" class="space-y-6">
|
||||
<!-- Autocomplétion EAN -->
|
||||
<div class="rounded-xl bg-indigo-50 p-6 shadow-sm border border-indigo-100 mb-6">
|
||||
<h2 class="mb-3 text-sm font-semibold uppercase tracking-wide text-indigo-800 flex items-center gap-2">
|
||||
<svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v1m6 11h2m-6 0h-2v4m0-11v3m0 0h.01M12 12h4.01M16 20h4M4 12h4m12 0h.01M5 8h2a1 1 0 001-1V5a1 1 0 00-1-1H5a1 1 0 00-1 1v2a1 1 0 001 1zm14 0h2a1 1 0 001-1V5a1 1 0 00-1-1h-2a1 1 0 00-1 1v2a1 1 0 001 1zM5 20h2a1 1 0 001-1v-2a1 1 0 00-1-1H5a1 1 0 00-1 1v2a1 1 0 001 1z" />
|
||||
</svg>
|
||||
Pré-remplissage Magique par Code-Barres
|
||||
</h2>
|
||||
<div class="flex items-end gap-4">
|
||||
<div class="flex-1">
|
||||
<label class="block text-sm font-medium text-indigo-700">Scanner ou Saisir le Code EAN/UPC</label>
|
||||
<input v-model="form.code_ean" type="text" @keyup.enter.prevent="fetchEanDetails"
|
||||
class="mt-1 block w-full rounded-lg border-indigo-200 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm font-mono" placeholder="ex: 0884116301292" />
|
||||
</div>
|
||||
<button type="button" @click="fetchEanDetails" :disabled="isSearchingEan || !form.code_ean"
|
||||
class="rounded-lg bg-indigo-600 px-4 py-2 mt-1 text-sm font-medium text-white shadow hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 disabled:bg-indigo-300 transition-colors flex items-center gap-2">
|
||||
<svg v-if="isSearchingEan" class="animate-spin h-4 w-4 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
||||
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
||||
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
||||
</svg>
|
||||
Rechercher
|
||||
</button>
|
||||
</div>
|
||||
<p v-if="eanError" class="mt-2 text-xs font-semibold text-red-600">{{ eanError }}</p>
|
||||
<p v-if="eanSuccess" class="mt-2 text-xs font-semibold text-green-600">{{ eanSuccess }}</p>
|
||||
</div>
|
||||
|
||||
<!-- Informations de base -->
|
||||
<div class="rounded-xl bg-white p-6 shadow-sm border border-gray-100">
|
||||
<h2 class="mb-5 text-sm font-semibold uppercase tracking-wide text-gray-500 font-bold">Identification de l'asset</h2>
|
||||
|
||||
<div class="grid gap-6 sm:grid-cols-2">
|
||||
<div class="sm:col-span-1">
|
||||
<label class="block text-sm font-medium text-gray-700 font-bold">Nom / Hostname</label>
|
||||
<input v-model="form.nom" type="text" required class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" placeholder="ex: SRV-SQL-01" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 font-bold">Type de matériel</label>
|
||||
<input v-model="form.type" list="asset-types" required class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" placeholder="ex: Serveur" />
|
||||
<datalist id="asset-types">
|
||||
<option value="Serveur" />
|
||||
<option value="Switch" />
|
||||
<option value="NAS" />
|
||||
<option value="Baie de stockage" />
|
||||
<option value="Onduleur" />
|
||||
<option value="Firewall" />
|
||||
<option value="Cœur de réseau" />
|
||||
</datalist>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">Marque</label>
|
||||
<input v-model="form.marque" type="text" class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" placeholder="ex: Dell" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">Modèle</label>
|
||||
<input v-model="form.modele" type="text" class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" placeholder="ex: PowerEdge R640" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">Numéro de série / SN / Tag</label>
|
||||
<input v-model="form.numero_serie" type="text" class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm font-mono" placeholder="ex: ABC123D" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">Statut actuel</label>
|
||||
<select v-model="form.statut" required class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm">
|
||||
<option value="en_service">En service</option>
|
||||
<option value="hors_service">Hors service</option>
|
||||
<option value="en_reparation">En réparation</option>
|
||||
<option value="stock">En stock / Spare</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Emplacement et Commune -->
|
||||
<div class="rounded-xl bg-white p-6 shadow-sm border border-gray-100">
|
||||
<h2 class="mb-5 text-sm font-semibold uppercase tracking-wide text-gray-500 font-bold">Localisation et Affectation</h2>
|
||||
|
||||
<div class="grid gap-6 sm:grid-cols-2">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">Ville / Commune</label>
|
||||
<select v-model="form.commune_id" class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm">
|
||||
<option value="">Infrastructure Globale (Agglo)</option>
|
||||
<option v-for="c in communes" :key="c.id" :value="c.id">{{ c.nom }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">Emplacement précis / Site</label>
|
||||
<input v-model="form.emplacement" type="text" class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" placeholder="ex: Datacenter Local Lyon - Rack A2 - 12U" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Dates et Garanties -->
|
||||
<div class="rounded-xl bg-white p-6 shadow-sm border border-gray-100">
|
||||
<h2 class="mb-5 text-sm font-semibold uppercase tracking-wide text-gray-500 font-bold">Cycle de vie & Garanties</h2>
|
||||
|
||||
<div class="grid gap-6 sm:grid-cols-2">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">Date d'achat / mise en service</label>
|
||||
<input v-model="form.date_achat" type="date" class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 font-bold">Fin de garantie constructeur</label>
|
||||
<input v-model="form.date_fin_garantie" type="date" required class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" />
|
||||
<p class="mt-1 text-xs text-gray-500">Cette date sera affichée dans le calendrier global.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Lien Commande -->
|
||||
<div class="rounded-xl bg-white p-6 shadow-sm border border-gray-100">
|
||||
<h2 class="mb-5 text-sm font-semibold uppercase tracking-wide text-gray-500 font-bold">Achat & Commande</h2>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">Commande associée (optionnel)</label>
|
||||
<select v-model="form.commande_id" class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm">
|
||||
<option value="">Aucune commande liée</option>
|
||||
<option v-for="cmd in commandes" :key="cmd.id" :value="cmd.id">
|
||||
N° {{ cmd.numero_commande ?? 'Sans-N' }} - {{ cmd.objet }}
|
||||
</option>
|
||||
</select>
|
||||
<p class="mt-1 text-xs text-gray-500">Permet de retrouver l'origine de l'achat et les justificatifs.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Notes -->
|
||||
<div class="rounded-xl bg-white p-6 shadow-sm border border-gray-100">
|
||||
<label class="block text-sm font-medium text-gray-700 font-bold mb-2">Notes techniques / Configuration</label>
|
||||
<textarea v-model="form.notes" rows="4" class="block w-full rounded-lg border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" placeholder="IP, VLANs, rôles du serveur..."></textarea>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-end gap-3">
|
||||
<Link :href="route('assets.index')" class="text-sm font-medium text-gray-600 hover:text-gray-900 transition-colors">Annuler</Link>
|
||||
<button type="submit" :disabled="form.processing"
|
||||
class="rounded-lg bg-indigo-600 px-6 py-2.5 text-sm font-semibold text-white shadow-sm hover:bg-indigo-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 disabled:opacity-50 transition-colors">
|
||||
{{ isEdit ? 'Enregistrer les modifications' : 'Ajouter l\'équipement' }}
|
||||
</button>
|
||||
<button v-if="isEdit" type="button" @click="confirmDelete"
|
||||
class="ml-4 rounded-lg bg-red-50 px-4 py-2 text-sm font-medium text-red-600 hover:bg-red-100 transition-colors">
|
||||
Supprimer
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</AuthenticatedLayout>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { router } from '@inertiajs/vue3'
|
||||
|
||||
export default {
|
||||
methods: {
|
||||
confirmDelete() {
|
||||
if (confirm('Êtes-vous sûr de vouloir supprimer cet équipement ?')) {
|
||||
router.delete(route('assets.destroy', this.asset.id))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
158
resources/js/Pages/Assets/Index.vue
Normal file
158
resources/js/Pages/Assets/Index.vue
Normal file
@@ -0,0 +1,158 @@
|
||||
<script setup>
|
||||
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout.vue'
|
||||
import Pagination from '@/Components/Pagination.vue'
|
||||
import { Head, Link, router } from '@inertiajs/vue3'
|
||||
import { ref, reactive } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
assets: Object,
|
||||
communes: Array,
|
||||
types: Array,
|
||||
filters: Object,
|
||||
})
|
||||
|
||||
const filters = reactive({
|
||||
search: props.filters.search || '',
|
||||
type: props.filters.type || '',
|
||||
commune_id: props.filters.commune_id || '',
|
||||
})
|
||||
|
||||
function applyFilters() {
|
||||
router.get(route('assets.index'), filters, { preserveState: true, replace: true })
|
||||
}
|
||||
|
||||
function formatDate(d) {
|
||||
if (!d) return '—'
|
||||
return new Intl.DateTimeFormat('fr-FR').format(new Date(d))
|
||||
}
|
||||
|
||||
const statutLabels = {
|
||||
en_service: 'En service',
|
||||
hors_service: 'Hors service',
|
||||
en_reparation: 'En réparation',
|
||||
stock: 'En stock',
|
||||
}
|
||||
|
||||
const statutColors = {
|
||||
en_service: 'bg-green-100 text-green-800',
|
||||
hors_service: 'bg-red-100 text-red-800',
|
||||
en_reparation: 'bg-orange-100 text-orange-800',
|
||||
stock: 'bg-blue-100 text-blue-800',
|
||||
}
|
||||
|
||||
function checkWarranty(date) {
|
||||
if (!date) return 'text-gray-400'
|
||||
const today = new Date()
|
||||
const exp = new Date(date)
|
||||
if (exp < today) return 'text-red-600 font-bold'
|
||||
const diff = (exp - today) / (1000 * 60 * 60 * 24)
|
||||
if (diff <= 30) return 'text-orange-600 font-bold'
|
||||
return 'text-gray-600'
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Head title="Inventaire Infrastructure (Assets)" />
|
||||
<AuthenticatedLayout>
|
||||
<template #header>
|
||||
<div class="flex items-center justify-between">
|
||||
<h1 class="text-xl font-semibold text-gray-900">Assets (Hardware & Infra)</h1>
|
||||
<Link :href="route('assets.create')"
|
||||
class="rounded-lg bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 transition-colors">
|
||||
+ Nouvel Asset
|
||||
</Link>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="space-y-4">
|
||||
<!-- Filtres -->
|
||||
<div class="rounded-xl bg-white p-4 shadow-sm border border-gray-100">
|
||||
<div class="grid gap-3 sm:grid-cols-2 lg:grid-cols-4">
|
||||
<input v-model="filters.search" @input="applyFilters" type="text" placeholder="Recherche (SN, Nom, Modèle)..."
|
||||
class="rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-indigo-500 focus:outline-none placeholder-gray-400" />
|
||||
|
||||
<select v-model="filters.type" @change="applyFilters"
|
||||
class="rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-indigo-500 focus:outline-none">
|
||||
<option value="">Tous les types</option>
|
||||
<option v-for="t in types" :key="t" :value="t">{{ t }}</option>
|
||||
<option value="Serveur">Serveur</option>
|
||||
<option value="Switch">Switch</option>
|
||||
<option value="NAS">NAS</option>
|
||||
<option value="Baie de stockage">Baie de stockage</option>
|
||||
<option value="Onduleur">Onduleur</option>
|
||||
</select>
|
||||
|
||||
<select v-model="filters.commune_id" @change="applyFilters"
|
||||
class="rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-indigo-500 focus:outline-none">
|
||||
<option value="">Partout (Agglo)</option>
|
||||
<option v-for="c in communes" :key="c.id" :value="c.id">{{ c.nom }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Table -->
|
||||
<div class="rounded-xl bg-white shadow-sm border border-gray-100 overflow-hidden">
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full divide-y divide-gray-100 text-sm">
|
||||
<thead class="bg-gray-50">
|
||||
<tr>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Matériel</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Type</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">S/N</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Ville / Site</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Fin Garantie</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Statut</th>
|
||||
<th class="px-4 py-3 text-center text-xs font-medium text-gray-500 uppercase">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-50">
|
||||
<tr v-for="asset in assets.data" :key="asset.id" class="hover:bg-gray-50 transition-colors">
|
||||
<td class="px-4 py-3">
|
||||
<div class="font-medium text-gray-900">{{ asset.nom }}</div>
|
||||
<div class="text-xs text-gray-500">{{ asset.marque }} {{ asset.modele }}</div>
|
||||
</td>
|
||||
<td class="px-4 py-3 whitespace-nowrap text-gray-600">
|
||||
<span class="px-2 py-0.5 rounded border border-gray-200 bg-gray-50 text-[10px] uppercase font-bold text-gray-500">
|
||||
{{ asset.type }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-4 py-3 whitespace-nowrap font-mono text-xs text-gray-600">{{ asset.numero_serie ?? '—' }}</td>
|
||||
<td class="px-4 py-3">
|
||||
<div class="text-gray-900">{{ asset.commune?.nom ?? 'Agglo' }}</div>
|
||||
<div class="text-xs text-gray-500">{{ asset.emplacement ?? '—' }}</div>
|
||||
</td>
|
||||
<td class="px-4 py-3 whitespace-nowrap" :class="checkWarranty(asset.date_fin_garantie)">
|
||||
{{ formatDate(asset.date_fin_garantie) }}
|
||||
<span v-if="checkWarranty(asset.date_fin_garantie).includes('red')" class="ml-1" title="Expirée">⚠️</span>
|
||||
<span v-else-if="checkWarranty(asset.date_fin_garantie).includes('orange')" class="ml-1" title="Proche échéance">⏳</span>
|
||||
</td>
|
||||
<td class="px-4 py-3 whitespace-nowrap">
|
||||
<span :class="['px-2 py-0.5 rounded-full text-xs font-medium', statutColors[asset.statut]]">
|
||||
{{ statutLabels[asset.statut] }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-center">
|
||||
<div class="flex items-center justify-center gap-2">
|
||||
<Link :href="route('assets.show', asset.id)"
|
||||
class="text-gray-400 hover:text-blue-600 transition-colors" title="Afficher les détails">
|
||||
<svg class="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
|
||||
</svg>
|
||||
</Link>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div v-if="!assets.data.length" class="py-12 text-center text-gray-400">
|
||||
Aucun matériel trouvé.
|
||||
</div>
|
||||
<div class="px-4 py-3 border-t border-gray-100">
|
||||
<Pagination :links="assets.links" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</AuthenticatedLayout>
|
||||
</template>
|
||||
151
resources/js/Pages/Assets/Show.vue
Normal file
151
resources/js/Pages/Assets/Show.vue
Normal file
@@ -0,0 +1,151 @@
|
||||
<script setup>
|
||||
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout.vue'
|
||||
import { Head, Link } from '@inertiajs/vue3'
|
||||
|
||||
const props = defineProps({
|
||||
asset: Object,
|
||||
})
|
||||
|
||||
function formatDate(d) {
|
||||
if (!d) return '—'
|
||||
return new Intl.DateTimeFormat('fr-FR').format(new Date(d))
|
||||
}
|
||||
|
||||
const statutLabels = {
|
||||
en_service: 'En service',
|
||||
hors_service: 'Hors service',
|
||||
en_reparation: 'En réparation',
|
||||
stock: 'En stock',
|
||||
}
|
||||
|
||||
const statutColors = {
|
||||
en_service: 'bg-green-100 text-green-800',
|
||||
hors_service: 'bg-red-100 text-red-800',
|
||||
en_reparation: 'bg-orange-100 text-orange-800',
|
||||
stock: 'bg-blue-100 text-blue-800',
|
||||
}
|
||||
|
||||
function checkWarranty(date) {
|
||||
if (!date) return 'text-gray-400'
|
||||
const today = new Date()
|
||||
const exp = new Date(date)
|
||||
if (exp < today) return 'text-red-600 font-bold'
|
||||
const diff = (exp - today) / (1000 * 60 * 60 * 24)
|
||||
if (diff <= 30) return 'text-orange-600 font-bold'
|
||||
return 'text-gray-600'
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Head :title="asset.nom" />
|
||||
<AuthenticatedLayout>
|
||||
<template #header>
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center gap-3">
|
||||
<Link :href="route('assets.index')" class="text-gray-400 hover:text-gray-600 transition-colors">
|
||||
<svg class="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" />
|
||||
</svg>
|
||||
</Link>
|
||||
<div>
|
||||
<h1 class="text-xl font-semibold text-gray-900">{{ asset.nom }}</h1>
|
||||
<p class="text-sm text-gray-500">{{ asset.type }} - {{ asset.marque }} {{ asset.modele }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Action Buttons: Edit -->
|
||||
<Link :href="route('assets.edit', asset.id)"
|
||||
class="rounded-lg bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 transition-colors">
|
||||
Modifier
|
||||
</Link>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="grid gap-6 lg:grid-cols-3">
|
||||
<div class="space-y-6 lg:col-span-2">
|
||||
<!-- Informations de base -->
|
||||
<div class="rounded-xl bg-white p-6 shadow-sm border border-gray-100">
|
||||
<h2 class="mb-5 text-sm font-semibold uppercase tracking-wide text-gray-500">Détails du matériel</h2>
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<div>
|
||||
<p class="text-xs text-gray-500">Nom / Hostname</p>
|
||||
<p class="mt-0.5 font-medium text-gray-900">{{ asset.nom }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-xs text-gray-500">Type de matériel</p>
|
||||
<p class="mt-0.5 font-medium text-gray-900">{{ asset.type }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-xs text-gray-500">Marque & Modèle</p>
|
||||
<p class="mt-0.5 font-medium text-gray-900">{{ asset.marque || '—' }} {{ asset.modele || '' }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-xs text-gray-500">Code EAN/UPC</p>
|
||||
<p class="mt-0.5 font-mono text-sm text-gray-900">{{ asset.code_ean || '—' }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-xs text-gray-500 font-bold">Numéro de série / SN</p>
|
||||
<p class="mt-0.5 font-mono text-sm text-gray-900">{{ asset.numero_serie || '—' }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-xs text-gray-500 border-t pt-4 mt-2">Statut actuel</p>
|
||||
<span :class="['mt-2 inline-block px-2 py-0.5 rounded-full text-xs font-medium', statutColors[asset.statut]]">
|
||||
{{ statutLabels[asset.statut] }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Notes / Config -->
|
||||
<div v-if="asset.notes" class="rounded-xl bg-white p-6 shadow-sm border border-gray-100">
|
||||
<h2 class="mb-4 text-sm font-semibold uppercase tracking-wide text-gray-500">Notes & Configuration</h2>
|
||||
<div class="whitespace-pre-wrap text-sm text-gray-700">{{ asset.notes }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-6 lg:col-span-1">
|
||||
<!-- Localisation -->
|
||||
<div class="rounded-xl bg-white p-6 shadow-sm border border-gray-100">
|
||||
<h2 class="mb-4 text-sm font-semibold uppercase tracking-wide text-gray-500">Localisation</h2>
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<p class="text-xs text-gray-500">Ville / Commune</p>
|
||||
<p class="mt-0.5 font-medium text-gray-900">{{ asset.commune?.nom || 'Infrastructure Globale (Agglo)' }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-xs text-gray-500">Emplacement précis</p>
|
||||
<p class="mt-0.5 font-medium text-gray-900">{{ asset.emplacement || '—' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Cycle de vie & Garantie -->
|
||||
<div class="rounded-xl bg-white p-6 shadow-sm border border-gray-100">
|
||||
<h2 class="mb-4 text-sm font-semibold uppercase tracking-wide text-gray-500">Cycle de vie</h2>
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<p class="text-xs text-gray-500">Date d'achat</p>
|
||||
<p class="mt-0.5 font-medium text-gray-900">{{ formatDate(asset.date_achat) }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-xs text-gray-500">Fin de garantie (constructeur)</p>
|
||||
<p class="mt-0.5 font-medium" :class="checkWarranty(asset.date_fin_garantie)">
|
||||
{{ formatDate(asset.date_fin_garantie) }}
|
||||
<span v-if="checkWarranty(asset.date_fin_garantie).includes('red')" class="ml-1" title="Expirée">⚠️ Expirée</span>
|
||||
<span v-else-if="checkWarranty(asset.date_fin_garantie).includes('orange')" class="ml-1" title="Proche échéance">⏳ À renouveler</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Commande associée -->
|
||||
<div v-if="asset.commande" class="rounded-xl bg-white p-6 shadow-sm border border-gray-100">
|
||||
<h2 class="mb-4 text-sm font-semibold uppercase tracking-wide text-gray-500">Commande associée</h2>
|
||||
<Link :href="route('commandes.show', asset.commande.id)" class="block rounded-lg border border-gray-100 bg-gray-50 p-4 hover:bg-gray-100 transition-colors">
|
||||
<div class="font-medium text-indigo-600">{{ asset.commande.numero_commande }}</div>
|
||||
<div class="mt-1 text-xs text-gray-600">{{ asset.commande.objet }}</div>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</AuthenticatedLayout>
|
||||
</template>
|
||||
110
resources/js/Pages/Calendar/Index.vue
Normal file
110
resources/js/Pages/Calendar/Index.vue
Normal file
@@ -0,0 +1,110 @@
|
||||
<script setup>
|
||||
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout.vue'
|
||||
import { Head } from '@inertiajs/vue3'
|
||||
import FullCalendar from '@fullcalendar/vue3'
|
||||
import dayGridPlugin from '@fullcalendar/daygrid'
|
||||
import interactionPlugin from '@fullcalendar/interaction'
|
||||
import frLocale from '@fullcalendar/core/locales/fr'
|
||||
import { ref, onMounted } from 'vue'
|
||||
|
||||
const calendarOptions = ref({
|
||||
plugins: [dayGridPlugin, interactionPlugin],
|
||||
initialView: 'dayGridMonth',
|
||||
locale: frLocale,
|
||||
headerToolbar: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'dayGridMonth,dayGridWeek'
|
||||
},
|
||||
events: route('calendar.events'),
|
||||
eventClick: (info) => {
|
||||
if (info.event.url) {
|
||||
info.jsEvent.preventDefault()
|
||||
window.location.href = info.event.url
|
||||
}
|
||||
},
|
||||
eventDidMount: (info) => {
|
||||
// Simple tooltip-like title on hover
|
||||
info.el.title = info.event.title + (info.event.extendedProps.service ? ' - ' + info.event.extendedProps.service : '')
|
||||
},
|
||||
height: 'auto',
|
||||
firstDay: 1, // Start on Monday
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Head title="Calendrier des écheances" />
|
||||
<AuthenticatedLayout>
|
||||
<template #header>
|
||||
<h1 class="text-xl font-semibold text-gray-900">Calendrier des échéances</h1>
|
||||
</template>
|
||||
|
||||
<div class="rounded-xl bg-white p-6 shadow-sm border border-gray-100">
|
||||
<div class="calendar-container">
|
||||
<FullCalendar :options="calendarOptions" />
|
||||
</div>
|
||||
|
||||
<div class="mt-8 grid gap-4 sm:grid-cols-3">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="w-3 h-3 rounded-full bg-[#27ae60]"></span>
|
||||
<span class="text-xs text-gray-600">Contrats Actifs</span>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="w-3 h-3 rounded-full bg-[#f39c12]"></span>
|
||||
<span class="text-xs text-gray-600">Contrats à Renouveler / Proche écheance</span>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="w-3 h-3 rounded-full bg-[#3498db]"></span>
|
||||
<span class="text-xs text-gray-600">Licences / SaaS</span>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="w-3 h-3 rounded-full bg-[#9b59b6]"></span>
|
||||
<span class="text-xs text-gray-600">Noms de Domaine</span>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="w-3 h-3 rounded-full bg-[#e74c3c]"></span>
|
||||
<span class="text-xs text-gray-600">Contrats Expirés</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</AuthenticatedLayout>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
.fc {
|
||||
font-family: inherit;
|
||||
--fc-border-color: #f1f5f9;
|
||||
--fc-button-bg-color: #4f46e5;
|
||||
--fc-button-border-color: #4f46e5;
|
||||
--fc-button-hover-bg-color: #4338ca;
|
||||
--fc-button-active-bg-color: #4338ca;
|
||||
--fc-today-bg-color: #f8fafc;
|
||||
}
|
||||
|
||||
.fc .fc-toolbar-title {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
color: #1e293b;
|
||||
}
|
||||
|
||||
.fc .fc-col-header-cell {
|
||||
padding: 12px 0;
|
||||
background: #f8fafc;
|
||||
font-weight: 600;
|
||||
font-size: 0.75rem;
|
||||
text-transform: uppercase;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.fc-event {
|
||||
cursor: pointer;
|
||||
border: none !important;
|
||||
padding: 2px 4px !important;
|
||||
font-size: 0.75rem !important;
|
||||
}
|
||||
|
||||
.fc-daygrid-event {
|
||||
white-space: normal !important;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
@@ -6,6 +6,7 @@ import { Head, Link, useForm } from '@inertiajs/vue3'
|
||||
const props = defineProps({
|
||||
services: Array,
|
||||
fournisseurs: Array,
|
||||
communes: Array,
|
||||
categories: Array,
|
||||
articles: Array,
|
||||
})
|
||||
@@ -13,6 +14,7 @@ const props = defineProps({
|
||||
const form = useForm({
|
||||
service_id: '',
|
||||
fournisseur_id: '',
|
||||
commune_id: '',
|
||||
objet: '',
|
||||
description: '',
|
||||
justification: '',
|
||||
@@ -77,6 +79,15 @@ function submit() {
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">Ville / Commune</label>
|
||||
<select v-model="form.commune_id"
|
||||
class="mt-1 block w-full rounded-lg border border-gray-300 px-3 py-2 text-sm shadow-sm focus:border-blue-500 focus:outline-none">
|
||||
<option value="">— Non défini —</option>
|
||||
<option v-for="c in communes" :key="c.id" :value="c.id">{{ c.nom }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">Priorité</label>
|
||||
<select v-model="form.priorite"
|
||||
|
||||
@@ -8,6 +8,7 @@ const props = defineProps({
|
||||
commande: Object,
|
||||
services: Array,
|
||||
fournisseurs: Array,
|
||||
communes: Array,
|
||||
categories: Array,
|
||||
articles: Array,
|
||||
})
|
||||
@@ -15,6 +16,7 @@ const props = defineProps({
|
||||
const form = useForm({
|
||||
service_id: props.commande.service_id,
|
||||
fournisseur_id: props.commande.fournisseur_id ?? '',
|
||||
commune_id: props.commande.commune_id ?? '',
|
||||
objet: props.commande.objet,
|
||||
description: props.commande.description ?? '',
|
||||
justification: props.commande.justification ?? '',
|
||||
@@ -76,6 +78,14 @@ const showReceived = ['commandee','partiellement_recue','recue_complete'].includ
|
||||
<option v-for="f in fournisseurs" :key="f.id" :value="f.id">{{ f.nom }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">Ville / Commune</label>
|
||||
<select v-model="form.commune_id"
|
||||
class="mt-1 block w-full rounded-lg border border-gray-300 px-3 py-2 text-sm shadow-sm focus:border-blue-500 focus:outline-none">
|
||||
<option value="">— Non défini —</option>
|
||||
<option v-for="c in communes" :key="c.id" :value="c.id">{{ c.nom }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">Priorité</label>
|
||||
<select v-model="form.priorite"
|
||||
|
||||
@@ -11,13 +11,24 @@ const props = defineProps({
|
||||
commandes: Object,
|
||||
services: Array,
|
||||
fournisseurs: Array,
|
||||
communes: Array,
|
||||
filters: Object,
|
||||
})
|
||||
|
||||
const page = usePage()
|
||||
const statuts = page.props.config?.statuts ?? {}
|
||||
|
||||
const filters = reactive({ ...props.filters })
|
||||
const filters = reactive({
|
||||
search: '',
|
||||
service_id: '',
|
||||
fournisseur_id: '',
|
||||
commune_id: '',
|
||||
statut: '',
|
||||
priorite: '',
|
||||
date_from: '',
|
||||
date_to: '',
|
||||
...props.filters
|
||||
})
|
||||
const deleteTarget = ref(null)
|
||||
|
||||
function applyFilters() {
|
||||
@@ -97,6 +108,12 @@ function formatCurrency(v) {
|
||||
<option value="haute">Haute</option>
|
||||
<option value="normale">Normale</option>
|
||||
</select>
|
||||
|
||||
<select v-model="filters.commune_id" @change="applyFilters"
|
||||
class="rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none">
|
||||
<option value="">Toutes communes</option>
|
||||
<option v-for="c in communes" :key="c.id" :value="c.id">{{ c.nom }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="mt-3 grid gap-3 sm:grid-cols-3">
|
||||
@@ -120,6 +137,7 @@ function formatCurrency(v) {
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">N°</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Objet</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Service</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Ville</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Fournisseur</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Statut</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Priorité</th>
|
||||
@@ -141,6 +159,7 @@ function formatCurrency(v) {
|
||||
<p class="truncate text-gray-800">{{ cmd.objet }}</p>
|
||||
</td>
|
||||
<td class="px-4 py-3 whitespace-nowrap text-gray-600">{{ cmd.service?.nom }}</td>
|
||||
<td class="px-4 py-3 whitespace-nowrap text-gray-600">{{ cmd.commune?.nom ?? '—' }}</td>
|
||||
<td class="px-4 py-3 whitespace-nowrap text-gray-600">{{ cmd.fournisseur?.nom ?? '—' }}</td>
|
||||
<td class="px-4 py-3"><StatutBadge :statut="cmd.statut" /></td>
|
||||
<td class="px-4 py-3"><PrioriteBadge :priorite="cmd.priorite" /></td>
|
||||
|
||||
@@ -96,6 +96,10 @@ const transitionColors = {
|
||||
<p class="text-xs text-gray-500">Service demandeur</p>
|
||||
<p class="mt-0.5 font-medium text-gray-900">{{ commande.service?.nom ?? '—' }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-xs text-gray-500">Ville / Commune</p>
|
||||
<p class="mt-0.5 font-medium text-gray-900">{{ commande.commune?.nom ?? '—' }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-xs text-gray-500">Fournisseur</p>
|
||||
<p class="mt-0.5 font-medium text-gray-900">{{ commande.fournisseur?.nom ?? '—' }}</p>
|
||||
@@ -160,6 +164,35 @@ const transitionColors = {
|
||||
:show-received="['commandee','partiellement_recue','recue_complete','cloturee'].includes(commande.statut)" />
|
||||
</div>
|
||||
|
||||
<!-- Matériels associés (Assets) -->
|
||||
<div v-if="commande.assets?.length" class="rounded-xl bg-white p-5 shadow-sm border border-gray-100">
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<h2 class="text-sm font-semibold uppercase tracking-wide text-gray-500">Matériels livrés (Assets)</h2>
|
||||
<span class="px-2 py-0.5 rounded-full bg-blue-100 text-blue-700 text-[10px] font-bold uppercase">{{ commande.assets.length }} équipements</span>
|
||||
</div>
|
||||
<div class="divide-y divide-gray-100">
|
||||
<div v-for="asset in commande.assets" :key="asset.id" class="flex items-center justify-between py-3 first:pt-0 last:pb-0">
|
||||
<div class="flex items-start gap-3">
|
||||
<div class="mt-1 rounded bg-gray-100 p-2 text-gray-400">
|
||||
<svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h6v6H9V9z" />
|
||||
</svg>
|
||||
</div>
|
||||
<div>
|
||||
<Link :href="route('assets.show', asset.id)" class="font-medium text-gray-900 hover:text-blue-600 transition-colors">
|
||||
{{ asset.nom }}
|
||||
</Link>
|
||||
<div class="text-xs text-gray-500 font-mono">{{ asset.numero_serie ?? 'Sans S/N' }} • {{ asset.marque }} {{ asset.modele }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<span class="block text-xs font-medium text-gray-900">{{ asset.type }}</span>
|
||||
<span v-if="asset.date_fin_garantie" class="text-[10px] text-gray-500">Garantie jusqu'au {{ formatDate(asset.date_fin_garantie) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Notes -->
|
||||
<div v-if="commande.description || commande.justification || commande.notes || commande.notes_fournisseur"
|
||||
class="rounded-xl bg-white p-5 shadow-sm border border-gray-100">
|
||||
|
||||
82
resources/js/Pages/Communes/Index.vue
Normal file
82
resources/js/Pages/Communes/Index.vue
Normal file
@@ -0,0 +1,82 @@
|
||||
<script setup>
|
||||
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout.vue'
|
||||
import { Head, useForm, router } from '@inertiajs/vue3'
|
||||
import { ref } from 'vue'
|
||||
|
||||
defineProps({ communes: Array })
|
||||
|
||||
const showForm = ref(false)
|
||||
const editTarget = ref(null)
|
||||
const form = useForm({ nom: '', code_postal: '' })
|
||||
const editForm = useForm({ nom: '', code_postal: '' })
|
||||
|
||||
function openEdit(c) {
|
||||
editTarget.value = c
|
||||
editForm.nom = c.nom; editForm.code_postal = c.code_postal ?? ''
|
||||
}
|
||||
|
||||
function submitCreate() { form.post(route('communes.store'), { onSuccess: () => { showForm.value = false; form.reset() } }) }
|
||||
function submitEdit() { editForm.put(route('communes.update', editTarget.value.id), { onSuccess: () => editTarget.value = null }) }
|
||||
|
||||
function deleteCommune(c) {
|
||||
if (confirm(`Supprimer "${c.nom}" ?`)) router.delete(route('communes.destroy', c.id))
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Head title="Communes" />
|
||||
<AuthenticatedLayout>
|
||||
<template #header>
|
||||
<div class="flex items-center justify-between">
|
||||
<h1 class="text-xl font-semibold text-gray-900">Gestion des Communes</h1>
|
||||
<button @click="showForm = !showForm" class="rounded-lg bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 transition-colors">+ Ajouter</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div v-if="showForm" class="mb-6 rounded-xl bg-white p-5 shadow-sm border border-indigo-200">
|
||||
<form @submit.prevent="submitCreate" class="grid gap-3 sm:grid-cols-2">
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">Nom de la commune *</label>
|
||||
<input v-model="form.nom" type="text" required placeholder="ex: Béziers" class="block w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-indigo-500 focus:outline-none" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">Code Postal</label>
|
||||
<input v-model="form.code_postal" type="text" placeholder="ex: 34500" class="block w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-indigo-500 focus:outline-none" />
|
||||
</div>
|
||||
<div class="sm:col-span-2 flex gap-2">
|
||||
<button type="submit" :disabled="form.processing" class="rounded-lg bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 disabled:opacity-50 transition-colors">Créer</button>
|
||||
<button type="button" @click="showForm = false" class="rounded-lg border border-gray-300 px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 transition-colors">Annuler</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
|
||||
<div v-for="c in communes" :key="c.id" class="rounded-xl bg-white p-5 shadow-sm border border-gray-100 hover:border-indigo-100 transition-all">
|
||||
<template v-if="editTarget?.id !== c.id">
|
||||
<div class="flex items-start justify-between">
|
||||
<div>
|
||||
<h3 class="font-semibold text-gray-900">{{ c.nom }}</h3>
|
||||
<p v-if="c.code_postal" class="text-xs text-gray-400 mt-0.5">{{ c.code_postal }}</p>
|
||||
</div>
|
||||
<div class="flex gap-1">
|
||||
<button @click="openEdit(c)" class="text-gray-400 hover:text-indigo-600 transition-colors p-1"><svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" /></svg></button>
|
||||
<button @click="deleteCommune(c)" class="text-gray-400 hover:text-red-600 transition-colors p-1"><svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" /></svg></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-3 flex gap-4 text-xs text-gray-500 pt-3 border-t border-gray-50">
|
||||
<span>{{ c.commandes_count }} commandes</span>
|
||||
<span>{{ c.contrats_count }} contrats</span>
|
||||
</div>
|
||||
</template>
|
||||
<form v-else @submit.prevent="submitEdit" class="space-y-3">
|
||||
<div><label class="block text-xs font-medium text-gray-600 mb-1">Nom *</label><input v-model="editForm.nom" type="text" required class="block w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-indigo-500 focus:outline-none" /></div>
|
||||
<div><label class="block text-xs font-medium text-gray-600 mb-1">CP</label><input v-model="editForm.code_postal" type="text" class="block w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-indigo-500 focus:outline-none" /></div>
|
||||
<div class="flex gap-2">
|
||||
<button type="submit" :disabled="editForm.processing" class="flex-1 rounded-lg bg-indigo-600 px-3 py-2 text-sm font-medium text-white hover:bg-indigo-700 disabled:opacity-50 transition-colors">OK</button>
|
||||
<button type="button" @click="editTarget = null" class="rounded-lg border border-gray-300 px-3 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 transition-colors">X</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</AuthenticatedLayout>
|
||||
</template>
|
||||
@@ -5,6 +5,7 @@ import { Head, Link, useForm } from '@inertiajs/vue3'
|
||||
const props = defineProps({
|
||||
services: Array,
|
||||
fournisseurs: Array,
|
||||
communes: Array,
|
||||
statuts: Object,
|
||||
})
|
||||
|
||||
@@ -12,6 +13,7 @@ const form = useForm({
|
||||
titre: '',
|
||||
description: '',
|
||||
fournisseur_id: '',
|
||||
commune_id: '',
|
||||
service_id: props.services.length === 1 ? props.services[0].id : '',
|
||||
date_debut: '',
|
||||
date_echeance: '',
|
||||
@@ -79,6 +81,15 @@ function submit() {
|
||||
class="w-full rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 text-sm text-gray-500" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="mb-1 block text-sm font-medium text-gray-700">Ville / Commune</label>
|
||||
<select v-model="form.commune_id"
|
||||
class="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none">
|
||||
<option value="">— Non défini —</option>
|
||||
<option v-for="c in communes" :key="c.id" :value="c.id">{{ c.nom }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="sm:col-span-2">
|
||||
<label class="mb-1 block text-sm font-medium text-gray-700">Description</label>
|
||||
<textarea v-model="form.description" rows="3"
|
||||
|
||||
@@ -6,6 +6,7 @@ const props = defineProps({
|
||||
contrat: Object,
|
||||
services: Array,
|
||||
fournisseurs: Array,
|
||||
communes: Array,
|
||||
statuts: Object,
|
||||
})
|
||||
|
||||
@@ -13,6 +14,7 @@ const form = useForm({
|
||||
titre: props.contrat.titre ?? '',
|
||||
description: props.contrat.description ?? '',
|
||||
fournisseur_id: props.contrat.fournisseur_id ?? '',
|
||||
commune_id: props.contrat.commune_id ?? '',
|
||||
service_id: props.contrat.service_id ?? (props.services.length === 1 ? props.services[0].id : ''),
|
||||
date_debut: props.contrat.date_debut ?? '',
|
||||
date_echeance: props.contrat.date_echeance ?? '',
|
||||
@@ -80,6 +82,15 @@ function submit() {
|
||||
class="w-full rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 text-sm text-gray-500" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="mb-1 block text-sm font-medium text-gray-700">Ville / Commune</label>
|
||||
<select v-model="form.commune_id"
|
||||
class="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none">
|
||||
<option value="">— Non défini —</option>
|
||||
<option v-for="c in communes" :key="c.id" :value="c.id">{{ c.nom }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="sm:col-span-2">
|
||||
<label class="mb-1 block text-sm font-medium text-gray-700">Description</label>
|
||||
<textarea v-model="form.description" rows="3"
|
||||
|
||||
@@ -9,13 +9,21 @@ const props = defineProps({
|
||||
contrats: Object,
|
||||
services: Array,
|
||||
fournisseurs: Array,
|
||||
communes: Array,
|
||||
filters: Object,
|
||||
statuts: Object,
|
||||
})
|
||||
|
||||
const page = usePage()
|
||||
|
||||
const filters = reactive({ ...props.filters })
|
||||
const filters = reactive({
|
||||
search: '',
|
||||
service_id: '',
|
||||
fournisseur_id: '',
|
||||
commune_id: '',
|
||||
statut: '',
|
||||
...props.filters
|
||||
})
|
||||
const deleteTarget = ref(null)
|
||||
|
||||
function applyFilters() {
|
||||
@@ -93,6 +101,12 @@ const statutColors = {
|
||||
<option value="">Tous les statuts</option>
|
||||
<option v-for="(label, key) in statuts" :key="key" :value="key">{{ label }}</option>
|
||||
</select>
|
||||
|
||||
<select v-model="filters.commune_id" @change="applyFilters"
|
||||
class="rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-indigo-500 focus:outline-none">
|
||||
<option value="">Toutes communes</option>
|
||||
<option v-for="c in communes" :key="c.id" :value="c.id">{{ c.nom }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="mt-3 flex justify-end">
|
||||
@@ -111,6 +125,7 @@ const statutColors = {
|
||||
<tr>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Titre</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Service</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Ville</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Fournisseur</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Statut</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Date début</th>
|
||||
@@ -128,6 +143,7 @@ const statutColors = {
|
||||
</Link>
|
||||
</td>
|
||||
<td class="px-4 py-3 whitespace-nowrap text-gray-600">{{ cnt.service?.nom }}</td>
|
||||
<td class="px-4 py-3 whitespace-nowrap text-gray-600">{{ cnt.commune?.nom ?? '—' }}</td>
|
||||
<td class="px-4 py-3 whitespace-nowrap text-gray-600">{{ cnt.fournisseur?.nom ?? '—' }}</td>
|
||||
<td class="px-4 py-3">
|
||||
<span :class="['inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium', statutColors[cnt.statut]]">
|
||||
|
||||
@@ -71,6 +71,10 @@ const statutColors = {
|
||||
<p class="text-xs text-gray-500">Service concerné</p>
|
||||
<p class="mt-0.5 font-medium text-gray-900">{{ contrat.service?.nom ?? '—' }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-xs text-gray-500">Ville / Commune</p>
|
||||
<p class="mt-0.5 font-medium text-gray-900">{{ contrat.commune?.nom ?? '—' }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-xs text-gray-500">Fournisseur</p>
|
||||
<p class="mt-0.5 font-medium text-gray-900">{{ contrat.fournisseur?.nom ?? '—' }}</p>
|
||||
@@ -101,6 +105,20 @@ const statutColors = {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Licences associées -->
|
||||
<div v-if="contrat.licences?.length" class="mt-6 rounded-xl bg-white p-5 shadow-sm border border-gray-100">
|
||||
<h2 class="mb-4 text-sm font-semibold uppercase tracking-wide text-gray-500">Licences & Abonnements liés</h2>
|
||||
<div class="space-y-3">
|
||||
<div v-for="lic in contrat.licences" :key="lic.id" class="flex items-center justify-between p-3 rounded-lg border border-gray-50 hover:bg-gray-50 transition-colors">
|
||||
<div>
|
||||
<div class="font-medium text-gray-900">{{ lic.nom }}</div>
|
||||
<div class="text-xs text-gray-500">{{ lic.nombre_sieges_utilises }} / {{ lic.nombre_sieges_total }} sièges utilisés</div>
|
||||
</div>
|
||||
<Link :href="route('licences.edit', lic.id)" class="text-xs font-semibold text-indigo-600 hover:text-indigo-800">Afficher</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Colonne droite (Pièces jointes) -->
|
||||
|
||||
152
resources/js/Pages/Licences/Form.vue
Normal file
152
resources/js/Pages/Licences/Form.vue
Normal file
@@ -0,0 +1,152 @@
|
||||
<script setup>
|
||||
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout.vue'
|
||||
import { Head, Link, useForm } from '@inertiajs/vue3'
|
||||
|
||||
const props = defineProps({
|
||||
licence: Object,
|
||||
contrats: Array,
|
||||
fournisseurs: Array,
|
||||
communes: Array,
|
||||
})
|
||||
|
||||
const isEdit = !!props.licence
|
||||
|
||||
const form = useForm({
|
||||
nom: props.licence?.nom || '',
|
||||
contrat_id: props.licence?.contrat_id || '',
|
||||
fournisseur_id: props.licence?.fournisseur_id || '',
|
||||
commune_id: props.licence?.commune_id || '',
|
||||
cle_licence: props.licence?.cle_licence || '',
|
||||
nombre_sieges_total: props.licence?.nombre_sieges_total || 1,
|
||||
nombre_sieges_utilises: props.licence?.nombre_sieges_utilises || 0,
|
||||
date_acquisition: props.licence?.date_acquisition ? props.licence.date_acquisition.substring(0, 10) : '',
|
||||
date_expiration: props.licence?.date_expiration ? props.licence.date_expiration.substring(0, 10) : '',
|
||||
type_licence: props.licence?.type_licence || 'abonnement',
|
||||
statut: props.licence?.statut || 'active',
|
||||
notes: props.licence?.notes || '',
|
||||
})
|
||||
|
||||
function submit() {
|
||||
if (isEdit) {
|
||||
form.put(route('licences.update', props.licence.id))
|
||||
} else {
|
||||
form.post(route('licences.store'))
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Head :title="isEdit ? 'Modifier Licence' : 'Nouvelle Licence'" />
|
||||
<AuthenticatedLayout>
|
||||
<template #header>
|
||||
<div class="flex items-center gap-3">
|
||||
<Link :href="route('licences.index')" class="text-gray-400 hover:text-gray-600 transition-colors">
|
||||
<svg class="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" />
|
||||
</svg>
|
||||
</Link>
|
||||
<h1 class="text-xl font-semibold text-gray-900">{{ isEdit ? 'Modifier la licence' : 'Ajouter une licence' }}</h1>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="max-w-4xl">
|
||||
<form @submit.prevent="submit" class="space-y-6">
|
||||
<!-- Section Informations Générales -->
|
||||
<div class="rounded-xl bg-white p-6 shadow-sm border border-gray-100">
|
||||
<h2 class="mb-5 text-sm font-semibold uppercase tracking-wide text-gray-500">Informations logicielles</h2>
|
||||
|
||||
<div class="grid gap-6 sm:grid-cols-2">
|
||||
<div class="sm:col-span-2">
|
||||
<label class="block text-sm font-medium text-gray-700">Nom du produit / logiciel</label>
|
||||
<input v-model="form.nom" type="text" required class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" placeholder="ex: Microsoft 365 Business Standard" />
|
||||
<div v-if="form.errors.nom" class="mt-1 text-xs text-red-600">{{ form.errors.nom }}</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">Type de licence</label>
|
||||
<select v-model="form.type_licence" required class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm">
|
||||
<option value="perpétuelle">Perpétuelle (achat unique)</option>
|
||||
<option value="abonnement">Abonnement (annuel/mensuel)</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">Statut</label>
|
||||
<select v-model="form.statut" required class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm">
|
||||
<option value="active">Active</option>
|
||||
<option value="expirée">Expirée</option>
|
||||
<option value="résiliée">Résiliée</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Section Clé et Sièges -->
|
||||
<div class="rounded-xl bg-white p-6 shadow-sm border border-gray-100">
|
||||
<h2 class="mb-5 text-sm font-semibold uppercase tracking-wide text-gray-500">Clés et Utilisation</h2>
|
||||
|
||||
<div class="grid gap-6 sm:grid-cols-2">
|
||||
<div class="sm:col-span-2">
|
||||
<label class="block text-sm font-medium text-gray-700">Clé de licence (stockage sécurisé)</label>
|
||||
<textarea v-model="form.cle_licence" rows="2" class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" placeholder="Saisissez la clé ou le code d'activation..."></textarea>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">Nombre de sièges (Total)</label>
|
||||
<input v-model.number="form.nombre_sieges_total" type="number" min="1" required class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">Nombre de sièges (Utilisés)</label>
|
||||
<input v-model.number="form.nombre_sieges_utilises" type="number" min="0" required class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Section Dates et Liens -->
|
||||
<div class="rounded-xl bg-white p-6 shadow-sm border border-gray-100">
|
||||
<h2 class="mb-5 text-sm font-semibold uppercase tracking-wide text-gray-500">Établissement & Dates</h2>
|
||||
|
||||
<div class="grid gap-6 sm:grid-cols-2">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">Affectation Commune</label>
|
||||
<select v-model="form.commune_id" class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm">
|
||||
<option value="">Non affectée (Agglo)</option>
|
||||
<option v-for="c in communes" :key="c.id" :value="c.id">{{ c.nom }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">Fournisseur</label>
|
||||
<select v-model="form.fournisseur_id" required class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm">
|
||||
<option value="">Choisir un fournisseur</option>
|
||||
<option v-for="f in fournisseurs" :key="f.id" :value="f.id">{{ f.nom }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">Contrat lié (optionnel)</label>
|
||||
<select v-model="form.contrat_id" class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm">
|
||||
<option value="">Aucun contrat spécifique</option>
|
||||
<option v-for="cnt in contrats" :key="cnt.id" :value="cnt.id">{{ cnt.titre }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">Date d'échéance / Expiration</label>
|
||||
<input v-model="form.date_expiration" type="date" class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-end gap-3">
|
||||
<Link :href="route('licences.index')" class="text-sm font-medium text-gray-600 hover:text-gray-900 transition-colors">Annuler</Link>
|
||||
<button type="submit" :disabled="form.processing"
|
||||
class="rounded-lg bg-indigo-600 px-6 py-2.5 text-sm font-semibold text-white shadow-sm hover:bg-indigo-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 disabled:opacity-50 transition-colors">
|
||||
{{ isEdit ? 'Enregistrer les modifications' : 'Créer la licence' }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</AuthenticatedLayout>
|
||||
</template>
|
||||
141
resources/js/Pages/Licences/Index.vue
Normal file
141
resources/js/Pages/Licences/Index.vue
Normal file
@@ -0,0 +1,141 @@
|
||||
<script setup>
|
||||
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout.vue'
|
||||
import Pagination from '@/Components/Pagination.vue'
|
||||
import { Head, Link, router } from '@inertiajs/vue3'
|
||||
import { ref, reactive } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
licences: Object,
|
||||
communes: Array,
|
||||
fournisseurs: Array,
|
||||
filters: Object,
|
||||
})
|
||||
|
||||
const filters = reactive({
|
||||
search: props.filters.search || '',
|
||||
commune_id: props.filters.commune_id || '',
|
||||
fournisseur_id: props.filters.fournisseur_id || '',
|
||||
})
|
||||
|
||||
function applyFilters() {
|
||||
router.get(route('licences.index'), filters, { preserveState: true, replace: true })
|
||||
}
|
||||
|
||||
function formatDate(d) {
|
||||
if (!d) return '—'
|
||||
return new Intl.DateTimeFormat('fr-FR').format(new Date(d))
|
||||
}
|
||||
|
||||
const statutColors = {
|
||||
active: 'bg-green-100 text-green-800',
|
||||
'expirée': 'bg-red-100 text-red-800',
|
||||
'résiliée': 'bg-gray-100 text-gray-800',
|
||||
}
|
||||
|
||||
function getUsageColor(rate) {
|
||||
if (rate >= 90) return 'bg-red-500'
|
||||
if (rate >= 75) return 'bg-orange-500'
|
||||
return 'bg-blue-500'
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Head title="Gestion des Licences" />
|
||||
<AuthenticatedLayout>
|
||||
<template #header>
|
||||
<div class="flex items-center justify-between">
|
||||
<h1 class="text-xl font-semibold text-gray-900">Licences & Abonnements</h1>
|
||||
<Link :href="route('licences.create')"
|
||||
class="rounded-lg bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 transition-colors">
|
||||
+ Nouvelle licence
|
||||
</Link>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="space-y-4">
|
||||
<!-- Filtres -->
|
||||
<div class="rounded-xl bg-white p-4 shadow-sm border border-gray-100">
|
||||
<div class="grid gap-3 sm:grid-cols-2 lg:grid-cols-4">
|
||||
<input v-model="filters.search" @input="applyFilters" type="text" placeholder="Recherche produit..."
|
||||
class="rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-indigo-500 focus:outline-none" />
|
||||
|
||||
<select v-model="filters.commune_id" @change="applyFilters"
|
||||
class="rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-indigo-500 focus:outline-none">
|
||||
<option value="">Toutes les communes</option>
|
||||
<option v-for="c in communes" :key="c.id" :value="c.id">{{ c.nom }}</option>
|
||||
</select>
|
||||
|
||||
<select v-model="filters.fournisseur_id" @change="applyFilters"
|
||||
class="rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-indigo-500 focus:outline-none">
|
||||
<option value="">Tous les fournisseurs</option>
|
||||
<option v-for="f in fournisseurs" :key="f.id" :value="f.id">{{ f.nom }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Table -->
|
||||
<div class="rounded-xl bg-white shadow-sm border border-gray-100 overflow-hidden">
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full divide-y divide-gray-100 text-sm">
|
||||
<thead class="bg-gray-50">
|
||||
<tr>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Produit / Logiciel</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Commune</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Fournisseur / Contrat</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Utilisation Sièges</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Expiration</th>
|
||||
<th class="px-4 py-3 text-center text-xs font-medium text-gray-500 uppercase">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-50 text-gray-600">
|
||||
<tr v-for="lic in licences.data" :key="lic.id" class="hover:bg-gray-50 transition-colors">
|
||||
<td class="px-4 py-3">
|
||||
<div class="font-medium text-gray-900">{{ lic.nom }}</div>
|
||||
<div class="text-xs text-xs">{{ lic.type_licence }}</div>
|
||||
</td>
|
||||
<td class="px-4 py-3">{{ lic.commune?.nom ?? '—' }}</td>
|
||||
<td class="px-4 py-3">
|
||||
<div>{{ lic.fournisseur?.nom }}</div>
|
||||
<div class="text-xs text-indigo-500" v-if="lic.contrat">
|
||||
{{ lic.contrat.titre }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-4 py-3">
|
||||
<div class="flex items-center gap-2">
|
||||
<div class="w-24 h-2 bg-gray-100 rounded-full overflow-hidden">
|
||||
<div :class="['h-full transition-all', getUsageColor((lic.nombre_sieges_utilises / lic.nombre_sieges_total) * 100)]"
|
||||
:style="{ width: Math.min((lic.nombre_sieges_utilises / lic.nombre_sieges_total) * 100, 100) + '%' }">
|
||||
</div>
|
||||
</div>
|
||||
<span class="text-xs font-bold">{{ lic.nombre_sieges_utilises }} / {{ lic.nombre_sieges_total }}</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-4 py-3">
|
||||
<span :class="['px-2 py-0.5 rounded-full text-xs font-medium', statutColors[lic.statut]]">
|
||||
{{ lic.statut }}
|
||||
</span>
|
||||
<div class="mt-1 text-xs" v-if="lic.date_expiration">
|
||||
Éxpire le {{ formatDate(lic.date_expiration) }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-center">
|
||||
<div class="flex items-center justify-center gap-2">
|
||||
<Link :href="route('licences.edit', lic.id)"
|
||||
class="p-1 text-gray-400 hover:text-blue-600 transition-colors">
|
||||
<svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" />
|
||||
</svg>
|
||||
</Link>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="px-4 py-3 border-t border-gray-100">
|
||||
<Pagination :links="licences.links" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</AuthenticatedLayout>
|
||||
</template>
|
||||
@@ -2,142 +2,287 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Commande {{ $commande->numero_commande }}</title>
|
||||
<title>Proposition de commande {{ $commande->numero_commande }}</title>
|
||||
<style>
|
||||
body { font-family: 'Helvetica Neue', 'Helvetica', Arial, sans-serif; font-size: 14px; color: #333; }
|
||||
.header { text-align: center; margin-bottom: 30px; }
|
||||
.header h1 { margin: 0; font-size: 24px; color: #111; }
|
||||
.header p { margin: 5px 0 0; color: #666; }
|
||||
.info-section { width: 100%; margin-bottom: 20px; }
|
||||
.info-section td { vertical-align: top; width: 50%; }
|
||||
.box { border: 1px solid #ddd; padding: 15px; border-radius: 4px; background: #fafafa; }
|
||||
.box strong { display: block; margin-bottom: 5px; color: #555; }
|
||||
.table-items { width: 100%; border-collapse: collapse; margin-bottom: 30px; }
|
||||
.table-items th, .table-items td { border: 1px solid #ddd; padding: 10px; text-align: left; }
|
||||
.table-items th { background-color: #f5f5f5; font-weight: bold; font-size: 12px; }
|
||||
.table-items td { font-size: 13px; }
|
||||
.table-items .text-right { text-align: right; }
|
||||
.totals { width: 100%; }
|
||||
.totals td { padding: 5px 10px; text-align: right; }
|
||||
.totals .bold { font-weight: bold; font-size: 16px; }
|
||||
.footer { margin-top: 50px; page-break-inside: avoid; }
|
||||
.signature-box { width: 100%; border-collapse: collapse; }
|
||||
.signature-box td { width: 50%; padding: 10px; text-align: left; vertical-align: top; }
|
||||
.signature { border: 1px solid #333; height: 120px; padding: 10px; }
|
||||
.signature p { margin: 0; font-weight: bold; font-size: 13px; }
|
||||
@page {
|
||||
margin: 0cm 0cm;
|
||||
}
|
||||
body {
|
||||
font-family: 'Helvetica', Arial, sans-serif;
|
||||
font-size: 11pt;
|
||||
color: #333;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.header-stripe {
|
||||
background-color: #2c3e50;
|
||||
height: 10px;
|
||||
width: 100%;
|
||||
}
|
||||
.container {
|
||||
padding: 40px;
|
||||
}
|
||||
.header {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
.logo-container {
|
||||
float: left;
|
||||
width: 50%;
|
||||
}
|
||||
.order-meta {
|
||||
float: right;
|
||||
width: 50%;
|
||||
text-align: right;
|
||||
}
|
||||
.order-meta h1 {
|
||||
margin: 0;
|
||||
font-size: 18pt;
|
||||
color: #2c3e50;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.order-meta p {
|
||||
margin: 5px 0 0;
|
||||
color: #7f8c8d;
|
||||
font-weight: bold;
|
||||
}
|
||||
.clearfix::after {
|
||||
content: "";
|
||||
clear: both;
|
||||
display: table;
|
||||
}
|
||||
.info-grid {
|
||||
width: 100%;
|
||||
margin-bottom: 40px;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
.info-grid td {
|
||||
vertical-align: top;
|
||||
width: 50%;
|
||||
}
|
||||
.info-box {
|
||||
padding: 0 10px;
|
||||
}
|
||||
.info-box h3 {
|
||||
font-size: 10pt;
|
||||
text-transform: uppercase;
|
||||
color: #34495e;
|
||||
border-bottom: 2px solid #ecf0f1;
|
||||
padding-bottom: 5px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.info-content {
|
||||
line-height: 1.5;
|
||||
}
|
||||
.info-content strong {
|
||||
color: #2c3e50;
|
||||
}
|
||||
.table-items {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
.table-items th {
|
||||
background-color: #f8f9fa;
|
||||
color: #2c3e50;
|
||||
text-transform: uppercase;
|
||||
font-size: 9pt;
|
||||
padding: 12px 10px;
|
||||
border-bottom: 2px solid #dee2e6;
|
||||
text-align: left;
|
||||
}
|
||||
.table-items td {
|
||||
padding: 12px 10px;
|
||||
border-bottom: 1px solid #eee;
|
||||
font-size: 10pt;
|
||||
}
|
||||
.text-right { text-align: right !important; }
|
||||
.text-center { text-align: center !important; }
|
||||
|
||||
.summary-container {
|
||||
width: 100%;
|
||||
}
|
||||
.summary-notes {
|
||||
float: left;
|
||||
width: 55%;
|
||||
}
|
||||
.summary-totals {
|
||||
float: right;
|
||||
width: 40%;
|
||||
}
|
||||
.summary-totals table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
.summary-totals td {
|
||||
padding: 8px 10px;
|
||||
}
|
||||
.summary-totals tr.grand-total {
|
||||
background-color: #f8f9fa;
|
||||
font-weight: bold;
|
||||
font-size: 13pt;
|
||||
color: #2c3e50;
|
||||
}
|
||||
.notes-box {
|
||||
padding: 15px;
|
||||
background-color: #fdfdfd;
|
||||
border-left: 4px solid #bdc3c7;
|
||||
font-style: italic;
|
||||
font-size: 10pt;
|
||||
}
|
||||
.footer-signatures {
|
||||
margin-top: 60px;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
.signature-table {
|
||||
width: 100%;
|
||||
border-collapse: separate;
|
||||
border-spacing: 20px 0;
|
||||
}
|
||||
.signature-table td {
|
||||
width: 50%;
|
||||
border: 1px dashed #bdc3c7;
|
||||
padding: 15px;
|
||||
height: 120px;
|
||||
vertical-align: top;
|
||||
}
|
||||
.signature-table p {
|
||||
margin: 0;
|
||||
font-weight: bold;
|
||||
font-size: 9pt;
|
||||
color: #7f8c8d;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.watermark {
|
||||
position: absolute;
|
||||
bottom: 20px;
|
||||
right: 40px;
|
||||
font-size: 8pt;
|
||||
color: #bdc3c7;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="header">
|
||||
<h1>BON DE COMMANDE : {{ $commande->numero_commande }}</h1>
|
||||
<p>Objet : {{ $commande->objet }}</p>
|
||||
<div class="header-stripe"></div>
|
||||
|
||||
<div class="container">
|
||||
<div class="header clearfix">
|
||||
<div class="logo-container">
|
||||
<img src="{{ public_path('images/logo_agglo.png') }}" style="height: 70px;">
|
||||
</div>
|
||||
<div class="order-meta">
|
||||
<h1>Proposition de commande</h1>
|
||||
<p>N° {{ $commande->numero_commande }}</p>
|
||||
<div style="margin-top: 10px; font-size: 10pt; color: #333;">
|
||||
Date: {{ \Carbon\Carbon::parse($commande->date_demande)->format('d/m/Y') }}<br>
|
||||
Objet: {{ $commande->objet }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="info-section">
|
||||
<table class="info-grid">
|
||||
<tr>
|
||||
<td style="padding-right: 10px;">
|
||||
<div class="box">
|
||||
<strong>Service Demandeur</strong>
|
||||
{{ $commande->service->nom ?? 'N/A' }}<br>
|
||||
Demandé par : {{ $commande->demandeur->name ?? 'N/A' }}<br>
|
||||
Le : {{ $commande->date_demande ? \Carbon\Carbon::parse($commande->date_demande)->format('d/m/Y') : 'N/A' }}
|
||||
</div>
|
||||
</td>
|
||||
<td style="padding-left: 10px;">
|
||||
<div class="box">
|
||||
<strong>Informations Fournisseur</strong>
|
||||
{{ $commande->fournisseur->nom ?? 'N/A' }}<br>
|
||||
Réf : {{ $commande->reference_fournisseur ?? 'N/A' }}<br>
|
||||
<br>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table style="width: 100%; margin-bottom: 20px;">
|
||||
<tr>
|
||||
@if($commande->imputation_budgetaire)
|
||||
<td style="width: 50%; padding-right: 10px;">
|
||||
<div class="box">
|
||||
<strong>Imputation budgétaire :</strong>
|
||||
{{ $commande->imputation_budgetaire }}
|
||||
<td>
|
||||
<div class="info-box">
|
||||
<h3>Émetteur / Service</h3>
|
||||
<div class="info-content">
|
||||
<strong>{{ $commande->service->nom ?? 'Service Administratif' }}</strong><br>
|
||||
@if($commande->commune)
|
||||
{{ $commande->commune->nom }} ({{ $commande->commune->code_postal }})<br>
|
||||
@endif
|
||||
<span style="font-size: 9pt; color: #7f8c8d;">Demandé par: {{ $commande->demandeur->name }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="info-box">
|
||||
<h3>Fournisseur</h3>
|
||||
<div class="info-content">
|
||||
<strong>{{ $commande->fournisseur->nom ?? 'Non spécifié' }}</strong><br>
|
||||
@if($commande->reference_fournisseur)
|
||||
<span style="font-size: 9pt;">Réf. Fournisseur: {{ $commande->reference_fournisseur }}</span><br>
|
||||
@endif
|
||||
@if($commande->date_souhaitee)
|
||||
<td style="width: 50%; padding-left: {{ $commande->imputation_budgetaire ? '10px' : '0' }};">
|
||||
<div class="box">
|
||||
<strong>Date de livraison souhaitée :</strong>
|
||||
{{ \Carbon\Carbon::parse($commande->date_souhaitee)->format('d/m/Y') }}
|
||||
<span style="font-size: 9pt;">Livraison souhaitée: {{ \Carbon\Carbon::parse($commande->date_souhaitee)->format('d/m/Y') }}</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
@endif
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table class="table-items">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Désignation</th>
|
||||
<th>Réf. Article</th>
|
||||
<th class="text-right">Qté</th>
|
||||
<th class="text-right">PU HT</th>
|
||||
<th class="text-right">Total HT</th>
|
||||
<th width="50%">Désignation</th>
|
||||
<th width="15%">Référence</th>
|
||||
<th width="10%" class="text-center">Qté</th>
|
||||
<th width="12%" class="text-right">P.U. HT</th>
|
||||
<th width="13%" class="text-right">Total HT</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($commande->lignes as $ligne)
|
||||
<tr>
|
||||
<td>{{ $ligne->designation }}</td>
|
||||
<td>{{ $ligne->reference ?? '-' }}</td>
|
||||
<td class="text-right">{{ number_format($ligne->quantite, 2, ',', ' ') }} {{ $ligne->unite }}</td>
|
||||
<td class="text-right">{{ number_format($ligne->prix_unitaire_ht, 2, ',', ' ') }} €</td>
|
||||
<td class="text-right">{{ number_format($ligne->quantite * $ligne->prix_unitaire_ht, 2, ',', ' ') }} €</td>
|
||||
<td style="color: #7f8c8d; font-size: 9pt;">{{ $ligne->reference ?? '-' }}</td>
|
||||
<td class="text-center">{{ number_format($ligne->quantite, 0, ',', ' ') }}</td>
|
||||
<td class="text-right">{{ number_format($ligne->prix_unitaire_ht, 2, ',', ' ') }} €</td>
|
||||
<td class="text-right"><strong>{{ number_format($ligne->quantite * $ligne->prix_unitaire_ht, 2, ',', ' ') }} €</strong></td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table style="width: 100%">
|
||||
<tr>
|
||||
<td style="width: 50%; vertical-align: top;">
|
||||
@if($commande->justification || $commande->description)
|
||||
<div class="box" style="margin-right: 20px; min-height: 50px;">
|
||||
<strong>Notes / Justification :</strong>
|
||||
<p style="font-size: 12px; margin-top:5px;">{{ $commande->justification ?: $commande->description }}</p>
|
||||
<div class="summary-container clearfix">
|
||||
<div class="summary-notes">
|
||||
@if($commande->description || $commande->justification)
|
||||
<div class="info-box" style="padding: 0;">
|
||||
<h3>Notes & Informations</h3>
|
||||
<div class="notes-box">
|
||||
{{ $commande->description ?: $commande->justification }}
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</td>
|
||||
<td style="width: 50%; vertical-align: top;">
|
||||
<table class="totals">
|
||||
</div>
|
||||
<div class="summary-totals">
|
||||
<table>
|
||||
<tr>
|
||||
<td>Total HT :</td>
|
||||
<td>{{ number_format($commande->montant_ht, 2, ',', ' ') }} €</td>
|
||||
<td class="text-right">Sous-total HT :</td>
|
||||
<td class="text-right">{{ number_format($commande->montant_ht, 2, ',', ' ') }} €</td>
|
||||
</tr>
|
||||
@php
|
||||
$tva = $commande->montant_ttc - $commande->montant_ht;
|
||||
@endphp
|
||||
@if($tva > 0)
|
||||
<tr>
|
||||
<td class="bold">Total TTC :</td>
|
||||
<td class="bold">{{ number_format($commande->montant_ttc, 2, ',', ' ') }} €</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td class="text-right">TVA :</td>
|
||||
<td class="text-right">{{ number_format($tva, 2, ',', ' ') }} €</td>
|
||||
</tr>
|
||||
@endif
|
||||
<tr class="grand-total">
|
||||
<td class="text-right">TOTAL TTC :</td>
|
||||
<td class="text-right">{{ number_format($commande->montant_ttc, 2, ',', ' ') }} €</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
<table class="signature-box">
|
||||
<div class="footer-signatures">
|
||||
<table class="signature-table">
|
||||
<tr>
|
||||
<td>
|
||||
<div class="signature">
|
||||
<p>Date :</p>
|
||||
</div>
|
||||
<p>Date & Signature Demandeur</p>
|
||||
</td>
|
||||
<td>
|
||||
<div class="signature">
|
||||
<p>Bon pour accord (Signature) :</p>
|
||||
</div>
|
||||
<p>Bon pour accord (Direction / Élu)</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="watermark">
|
||||
DSICommander - Généré le {{ now()->format('d/m/Y H:i') }}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
use App\Http\Controllers\ArticleController;
|
||||
use App\Http\Controllers\CategorieController;
|
||||
use App\Http\Controllers\CommandeController;
|
||||
use App\Http\Controllers\CommuneController;
|
||||
use App\Http\Controllers\ContratController;
|
||||
use App\Http\Controllers\DomaineController;
|
||||
use App\Http\Controllers\DashboardController;
|
||||
@@ -11,6 +12,9 @@ use App\Http\Controllers\PieceJointeController;
|
||||
use App\Http\Controllers\ProfileController;
|
||||
use App\Http\Controllers\ServiceController;
|
||||
use App\Http\Controllers\UserController;
|
||||
use App\Http\Controllers\LicenceController;
|
||||
use App\Http\Controllers\CalendarController;
|
||||
use App\Http\Controllers\AssetController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('/', fn () => redirect()->route('dashboard'));
|
||||
@@ -75,7 +79,20 @@ Route::middleware(['auth', 'verified'])->group(function () {
|
||||
Route::put('/users/{user}', [UserController::class, 'update'])->name('users.update');
|
||||
Route::patch('/users/{user}/toggle-active', [UserController::class, 'toggleActive'])
|
||||
->name('users.toggle-active');
|
||||
|
||||
Route::resource('communes', CommuneController::class)->except(['create', 'show', 'edit']);
|
||||
});
|
||||
|
||||
// Licences
|
||||
Route::resource('licences', LicenceController::class);
|
||||
|
||||
// Calendrier
|
||||
Route::get('/calendar', [CalendarController::class, 'index'])->name('calendar.index');
|
||||
Route::get('/calendar/events', [CalendarController::class, 'events'])->name('calendar.events');
|
||||
|
||||
// Assets
|
||||
Route::resource('assets', AssetController::class);
|
||||
Route::get('/api/ean-lookup/{ean}', [AssetController::class, 'lookupEan'])->name('assets.ean-lookup');
|
||||
});
|
||||
|
||||
require __DIR__ . '/auth.php';
|
||||
|
||||
Reference in New Issue
Block a user