Premier commit
This commit is contained in:
127
resources/views/contracts/edit.blade.php
Normal file
127
resources/views/contracts/edit.blade.php
Normal file
@@ -0,0 +1,127 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header bg-primary text-white">Modifier le Contrat</div>
|
||||
|
||||
<div class="card-body">
|
||||
<form method="POST" action="{{ route('contracts.update', $contract) }}">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="name" class="form-label">Nom du Contrat</label>
|
||||
<input type="text" class="form-control" id="name" name="name" value="{{ old('name', $contract->name) }}" required>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-md-6">
|
||||
<label for="provider" class="form-label">Fournisseur</label>
|
||||
<input type="text" class="form-control" id="provider" name="provider" value="{{ old('provider', $contract->provider) }}" required>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="municipality_id" class="form-label">Commune Affectée</label>
|
||||
<select class="form-select" id="municipality_id" name="municipality_id">
|
||||
<option value="">Global / Agglomération</option>
|
||||
@foreach($municipalities as $municipality)
|
||||
<option value="{{ $municipality->id }}" {{ (old('municipality_id', $contract->municipality_id) == $municipality->id) ? 'selected' : '' }}>
|
||||
{{ $municipality->name }} ({{ $municipality->zip_code }})
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="reference" class="form-label">Référence</label>
|
||||
<input type="text" class="form-control" id="reference" name="reference" value="{{ old('reference', $contract->reference) }}">
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-md-6">
|
||||
<label for="start_date" class="form-label">Date Début</label>
|
||||
<input type="date" class="form-control" id="start_date" name="start_date" value="{{ old('start_date', $contract->start_date->format('Y-m-d')) }}" required>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="end_date" class="form-label">Date Fin (Optionnel)</label>
|
||||
<input type="date" class="form-control" id="end_date" name="end_date" value="{{ old('end_date', $contract->end_date ? $contract->end_date->format('Y-m-d') : '') }}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-md-6">
|
||||
<label for="amount" class="form-label">Montant (€)</label>
|
||||
<input type="number" step="0.01" class="form-control" id="amount" name="amount" value="{{ old('amount', $contract->amount) }}">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="status" class="form-label">Statut</label>
|
||||
<select class="form-select" id="status" name="status" required>
|
||||
<option value="active" {{ $contract->status == 'active' ? 'selected' : '' }}>Actif</option>
|
||||
<option value="pending" {{ $contract->status == 'pending' ? 'selected' : '' }}>En attente</option>
|
||||
<option value="expired" {{ $contract->status == 'expired' ? 'selected' : '' }}>Expiré</option>
|
||||
<option value="cancelled" {{ $contract->status == 'cancelled' ? 'selected' : '' }}>Annulé</option>
|
||||
<option value="draft" {{ $contract->status == 'draft' ? 'selected' : '' }}>Brouillon</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="notes" class="form-label">Notes</label>
|
||||
<textarea class="form-control" id="notes" name="notes" rows="3">{{ old('notes', $contract->notes) }}</textarea>
|
||||
</div>
|
||||
|
||||
<!-- M365 Specifics -->
|
||||
@if($contract->type === 'microsoft_365')
|
||||
<div id="m365-fields" class="mb-3 p-3 bg-light border rounded">
|
||||
<h6>Détails Microsoft 365</h6>
|
||||
@php
|
||||
$level = $contract->meta->where('key', 'm365_license_level')->first()?->value;
|
||||
$qty = $contract->meta->where('key', 'm365_quantity')->first()?->value;
|
||||
@endphp
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Niveau de Licence</label>
|
||||
<select class="form-select" name="meta[m365_license_level]">
|
||||
<option value="">Sélectionner...</option>
|
||||
@php
|
||||
// Fallback if licenseLevels is not passed (though controller should pass it)
|
||||
$licenseLevels = $licenseLevels ?? \App\Models\LicenseLevel::active()->get();
|
||||
@endphp
|
||||
@foreach($licenseLevels as $l)
|
||||
<option value="{{ $l->name }}" {{ $level == $l->name ? 'selected' : '' }}>{{ $l->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Nombre de Licences</label>
|
||||
<input type="number" class="form-control" name="meta[m365_quantity]" value="{{ $qty }}" placeholder="ex: 10">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<!-- Meta Data Handling could be improved here, currently simplistic -->
|
||||
|
||||
<div class="d-grid gap-2 mt-4">
|
||||
<button type="submit" class="btn btn-primary">Mettre à jour</button>
|
||||
<a href="{{ route('contracts.show', $contract) }}" class="btn btn-link text-muted">Annuler</a>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<hr>
|
||||
@if(auth()->user()->isAdmin())
|
||||
<form action="{{ route('contracts.destroy', $contract) }}" method="POST" onsubmit="return confirm('Êtes-vous sûr de vouloir supprimer définitivement ce contrat ?');">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="btn btn-outline-danger w-100">Supprimer le Contrat</button>
|
||||
</form>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
Reference in New Issue
Block a user