feat: infrastructure assets management with warranty tracking and EAN lookup integration
This commit is contained in:
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>
|
||||
Reference in New Issue
Block a user