Files
crm_ecosplay/templates/admin/clients/create.html.twig
Serreau Jovann ec0c0366c4 feat: auto-détection type entreprise + RNA pour associations
Customer entity :
- Ajout champ rna (VARCHAR 20, nullable) pour identifiant RNA associations
- Migration : ALTER TABLE customer ADD rna

Recherche entreprise (entreprise-search.js) :
- resolveTypeCompany() : mapping nature_juridique vers type formulaire
  92xx/91xx/93xx → association, 10xx → auto-entrepreneur,
  54xx/55xx → sarl, 57xx → sas, 52xx → eurl, 65xx → sci
- Auto-remplissage typeCompany depuis nature_juridique
- Récupération RNA depuis complements.identifiant_association
- Badge "Association" affiché dans les résultats si nature_juridique 92xx
- RNA affiché dans les résultats (ex: RNA W502004724)

Template create.html.twig :
- Ajout champ "RNA (associations)" dans la section Entreprise

ClientsController :
- populateCustomerData : ajout setRna depuis le formulaire

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 11:04:43 +02:00

187 lines
11 KiB
Twig

{% extends 'admin/_layout.html.twig' %}
{% block title %}Nouveau client - Administration - CRM SITECONSEIL{% endblock %}
{% block admin_content %}
<div class="page-container">
<div class="flex items-center justify-between mb-8">
<h1 class="text-2xl font-bold heading-page">Nouveau client</h1>
<div class="flex items-center gap-3">
<button type="button" id="btn-search-entreprise"
class="flex items-center gap-2 px-4 py-2 btn-gold text-xs font-bold uppercase tracking-wider text-gray-900">
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
</svg>
Rechercher SIRET / SIREN
</button>
<a href="{{ path('app_admin_clients_index') }}" class="px-4 py-2 glass font-bold uppercase text-xs tracking-widest hover:bg-gray-900 hover:text-white transition-all">Retour</a>
</div>
</div>
{% for type, messages in app.flashes %}
{% for message in messages %}
<div class="mb-6 p-4 glass font-medium text-sm rounded-xl {{ type == 'success' ? 'border-green-300 text-green-800' : 'border-red-300 text-red-800' }}">
{{ message }}
</div>
{% endfor %}
{% endfor %}
<form method="post" action="{{ path('app_admin_clients_create') }}" class="flex flex-col gap-6">
<section class="glass p-6">
<h2 class="text-sm font-bold uppercase tracking-wider mb-4">Identite</h2>
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
<div>
<label for="firstName" class="block text-xs font-bold uppercase tracking-wider mb-2">Prenom *</label>
<input type="text" id="firstName" name="firstName" required placeholder="Prenom"
class="w-full px-4 py-3 input-glass text-sm font-medium">
</div>
<div>
<label for="lastName" class="block text-xs font-bold uppercase tracking-wider mb-2">Nom *</label>
<input type="text" id="lastName" name="lastName" required placeholder="Nom"
class="w-full px-4 py-3 input-glass text-sm font-medium">
</div>
<div>
<label for="email" class="block text-xs font-bold uppercase tracking-wider mb-2">Email *</label>
<input type="email" id="email" name="email" required placeholder="email@exemple.fr"
class="w-full px-4 py-3 input-glass text-sm font-medium">
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mt-4">
<div>
<label for="phone" class="block text-xs font-bold uppercase tracking-wider mb-2">Telephone</label>
<input type="tel" id="phone" name="phone" placeholder="06 12 34 56 78"
class="w-full px-4 py-3 input-glass text-sm font-medium">
</div>
<div>
<label for="typeCompany" class="block text-xs font-bold uppercase tracking-wider mb-2">Type</label>
<select id="typeCompany" name="typeCompany" class="w-full px-4 py-3 glass text-sm font-bold">
<option value="">— Selectionner —</option>
<option value="particulier">Particulier</option>
<option value="association">Association</option>
<option value="auto-entrepreneur">Auto-entrepreneur / IE</option>
<option value="sas">SAS</option>
<option value="sarl">SARL</option>
<option value="eurl">EURL</option>
<option value="sa">SA</option>
<option value="sci">SCI</option>
</select>
</div>
</div>
</section>
<section class="glass p-6">
<h2 class="text-sm font-bold uppercase tracking-wider mb-4">Entreprise</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="md:col-span-2">
<label for="codeComptable" class="block text-xs font-bold uppercase tracking-wider mb-2">Code comptable</label>
<input type="text" id="codeComptable" name="codeComptable" placeholder="Laissez vide pour generation automatique (411_XXXX_XXXXX)"
class="w-full px-4 py-3 input-glass text-sm font-medium font-mono">
</div>
<div>
<label for="raisonSociale" class="block text-xs font-bold uppercase tracking-wider mb-2">Raison sociale</label>
<input type="text" id="raisonSociale" name="raisonSociale" placeholder="Nom de l'entreprise"
class="w-full px-4 py-3 input-glass text-sm font-medium">
</div>
<div>
<label for="siret" class="block text-xs font-bold uppercase tracking-wider mb-2">SIRET</label>
<input type="text" id="siret" name="siret" maxlength="14" placeholder="12345678901234"
class="w-full px-4 py-3 input-glass text-sm font-medium">
</div>
<div>
<label for="rcs" class="block text-xs font-bold uppercase tracking-wider mb-2">RCS</label>
<input type="text" id="rcs" name="rcs" placeholder="RCS Paris 123 456 789"
class="w-full px-4 py-3 input-glass text-sm font-medium">
</div>
<div>
<label for="numTva" class="block text-xs font-bold uppercase tracking-wider mb-2">N° TVA</label>
<input type="text" id="numTva" name="numTva" placeholder="FR12345678901"
class="w-full px-4 py-3 input-glass text-sm font-medium">
</div>
<div>
<label for="ape" class="block text-xs font-bold uppercase tracking-wider mb-2">Code APE / NAF</label>
<input type="text" id="ape" name="ape" maxlength="10" placeholder="62.01Z"
class="w-full px-4 py-3 input-glass text-sm font-medium">
</div>
<div>
<label for="rna" class="block text-xs font-bold uppercase tracking-wider mb-2">RNA (associations)</label>
<input type="text" id="rna" name="rna" maxlength="20" placeholder="W123456789"
class="w-full px-4 py-3 input-glass text-sm font-medium">
</div>
</div>
</section>
<section class="glass p-6">
<h2 class="text-sm font-bold uppercase tracking-wider mb-4">Adresse</h2>
<div class="flex flex-col gap-4">
<div>
<label for="address" class="block text-xs font-bold uppercase tracking-wider mb-2">Adresse</label>
<input type="text" id="address" name="address" placeholder="Numero et rue"
class="w-full px-4 py-3 input-glass text-sm font-medium">
</div>
<div>
<label for="address2" class="block text-xs font-bold uppercase tracking-wider mb-2">Complement d'adresse</label>
<input type="text" id="address2" name="address2" placeholder="Batiment, etage, etc."
class="w-full px-4 py-3 input-glass text-sm font-medium">
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label for="zipCode" class="block text-xs font-bold uppercase tracking-wider mb-2">Code postal</label>
<input type="text" id="zipCode" name="zipCode" maxlength="10" placeholder="02800"
class="w-full px-4 py-3 input-glass text-sm font-medium">
</div>
<div>
<label for="city" class="block text-xs font-bold uppercase tracking-wider mb-2">Ville</label>
<input type="text" id="city" name="city" placeholder="Saint-Quentin"
class="w-full px-4 py-3 input-glass text-sm font-medium">
</div>
</div>
</div>
</section>
<div>
<p class="text-xs text-gray-500 mb-4">Le client sera automatiquement cree chez Stripe. Un mot de passe temporaire sera genere pour son acces a l'Espace Client.</p>
<button type="submit"
class="px-6 py-3 btn-gold text-sm font-bold uppercase tracking-wider text-gray-900">
Creer le client
</button>
</div>
</form>
</div>
<!-- Modal recherche entreprise -->
<div id="modal-entreprise" class="hidden fixed inset-0 z-50 flex items-center justify-center">
<div class="absolute inset-0 bg-black/40 backdrop-blur-sm" id="modal-overlay"></div>
<div class="relative glass-heavy w-full max-w-2xl mx-4 max-h-[80vh] flex flex-col overflow-hidden" style="border-radius: 16px;">
<div class="glass-dark text-white px-6 py-4 flex items-center justify-between" style="border-radius: 16px 16px 0 0;">
<div class="flex items-center gap-3">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-[#fabf04]" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" 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>
<span class="text-sm font-bold uppercase tracking-widest">Recherche entreprise</span>
</div>
<button type="button" id="modal-close" class="text-gray-400 hover:text-white transition-colors">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</div>
<div class="p-6">
<div class="flex gap-3 mb-4">
<input type="text" id="search-entreprise-input" placeholder="SIRET, SIREN, raison sociale..."
class="flex-1 px-4 py-3 input-glass text-sm font-medium" autocomplete="off">
<button type="button" id="search-entreprise-btn"
class="px-5 py-3 btn-gold text-xs font-bold uppercase tracking-wider text-gray-900">
Rechercher
</button>
</div>
<p id="search-entreprise-status" class="text-xs text-gray-400 mb-3 hidden"></p>
</div>
<div id="search-entreprise-results" class="overflow-y-auto px-6 pb-6 flex flex-col gap-3" style="max-height: 50vh;"></div>
</div>
</div>
{% endblock %}