Ajout du module gestion des sociétés

This commit is contained in:
2026-07-23 10:51:11 +02:00
parent 607fe553d4
commit 67a0147412
3 changed files with 508 additions and 3 deletions
+79
View File
@@ -224,3 +224,82 @@ def gestion_actions():
}) })
return render_template('gestion_actions.html', actions=actions_list) return render_template('gestion_actions.html', actions=actions_list)
# Route pour la gestion des sociétés
@main.route('/gestion-societes', methods=['GET', 'POST'])
def gestion_societes():
if 'user_id' not in session:
return redirect(url_for('main.index'))
if request.method == 'POST':
action = request.form.get('action')
soc_id = request.form.get('id')
nom = request.form.get('Nom')
forme = request.form.get('Forme')
capital = request.form.get('Capital')
siren = request.form.get('siren')
siret = request.form.get('siret')
rcs = request.form.get('RCS')
tva = request.form.get('TVA')
naf = request.form.get('NAF')
tel = request.form.get('Tel')
web = request.form.get('Web')
mail = request.form.get('Mail')
if action == 'creer':
query = text("""
INSERT INTO societe (Nom, Forme, Capital, siren, siret, RCS, TVA, NAF, Tel, Web, Mail)
VALUES (:nom, :forme, :capital, :siren, :siret, :rcs, :tva, :naf, :tel, :web, :mail)
""")
db.session.execute(query, {
"nom": nom, "forme": forme, "capital": capital,
"siren": siren, "siret": siret, "rcs": rcs,
"tva": tva, "naf": naf, "tel": tel,
"web": web, "mail": mail
})
db.session.commit()
flash("Société créée avec succès.", "success")
elif action == 'modifier' and soc_id:
query = text("""
UPDATE societe
SET Nom = :nom, Forme = :forme, Capital = :capital, siren = :siren,
siret = :siret, RCS = :rcs, TVA = :tva, NAF = :naf,
Tel = :tel, Web = :web, Mail = :mail
WHERE id = :id
""")
db.session.execute(query, {
"id": soc_id, "nom": nom, "forme": forme, "capital": capital,
"siren": siren, "siret": siret, "rcs": rcs,
"tva": tva, "naf": naf, "tel": tel,
"web": web, "mail": mail
})
db.session.commit()
flash("Société modifiée avec succès.", "success")
return redirect(url_for('main.gestion_societes'))
# Lecture de la table societe
societes_query = text("SELECT id, Nom, Forme, Capital, siren, siret, RCS, TVA, NAF, Tel, Web, Mail FROM societe ORDER BY id ASC")
result = db.session.execute(societes_query)
societes = []
for row in result:
societes.append({
'id': row.id,
'Nom': row.Nom if row.Nom else '',
'Forme': row.Forme if row.Forme else '',
'Capital': row.Capital if row.Capital is not None else 0,
'siren': row.siren if row.siren is not None else '',
'siret': row.siret if row.siret is not None else '',
'RCS': row.RCS if row.RCS else '',
'TVA': row.TVA if row.TVA else '',
'NAF': row.NAF if row.NAF else '',
'Tel': row.Tel if row.Tel else '',
'Web': row.Web if row.Web else '',
'Mail': row.Mail if row.Mail else ''
})
return render_template('gestion_societes.html', societes=societes)
+412
View File
@@ -0,0 +1,412 @@
{% extends "base.html" %} {% block title %}Gestion des sociétés - Bolsa{%
endblock %} {% block header_title %}Gestion sociétés{% endblock %} {% block
content %}
<div class="flex flex-col items-center justify-center py-6 relative">
<!-- Système de Toasts (Notifications flottantes centrées) -->
<div
id="toast-container"
class="fixed top-6 left-1/2 transform -translate-x-1/2 z-50 space-y-3 w-full max-w-md px-4 pointer-events-none"
>
{% set messages = get_flashed_messages(with_categories=true) %} {% if
messages %} {% for category, message in messages %}
<div
class="toast-message pointer-events-auto flex items-center justify-center px-4 py-3 rounded-xl shadow-2xl text-white text-sm font-medium transition-all duration-300 transform translate-y-0 opacity-100 text-center {% if category == 'success' %} bg-emerald-600 border border-emerald-500 {% elif category == 'warning' %} bg-amber-600 border border-amber-500 {% else %} bg-rose-600 border border-rose-500 {% endif %}"
>
<span>{{ message }}</span>
</div>
{% endfor %} {% endif %}
</div>
<!-- Box centrée principale -->
<div
class="bg-gray-900 border border-gray-800 p-8 rounded-2xl shadow-2xl w-full max-w-6xl"
>
<!-- En-tête de section -->
<div
class="flex justify-between items-center mb-6 border-b border-gray-800 pb-4"
>
<div>
<h2 class="text-2xl font-extrabold text-white">
Administration des sociétés
</h2>
<p class="text-gray-400 text-sm">
Gérez les informations légales et coordonnées des sociétés.
</p>
</div>
<a
href="{{ url_for('main.menu') }}"
class="px-4 py-2 bg-gray-800 hover:bg-gray-700 text-gray-200 text-sm font-medium rounded-lg transition duration-200"
>
Retour au menu
</a>
</div>
<!-- Grille principale -->
<div class="grid grid-cols-1 md:grid-cols-12 gap-8 py-4">
<!-- COLONNE GAUCHE : Liste des sociétés -->
<div
class="md:col-span-4 bg-gray-950 border border-gray-800 rounded-xl p-4 flex flex-col h-[560px]"
>
<h3
class="text-sm font-semibold text-gray-300 uppercase tracking-wider mb-3 px-2"
>
Sociétés enregistrées
</h3>
<!-- Liste scrollable -->
<div class="overflow-y-auto flex-1 space-y-1 pr-1">
{% for s in societes %}
<div
onclick="selectionnerSociete('{{ s.id }}', '{{ s.Nom | e }}', '{{ s.Forme | e }}', '{{ s.Capital }}', '{{ s.siren }}', '{{ s.siret }}', '{{ s.RCS | e }}', '{{ s.TVA | e }}', '{{ s.NAF | e }}', '{{ s.Tel | e }}', '{{ s.Web | e }}', '{{ s.Mail | e }}')"
class="societe-item cursor-pointer px-3 py-2.5 rounded-lg {% if loop.first %}bg-blue-600 text-white{% else %}hover:bg-gray-800 text-gray-300{% endif %} font-medium text-sm transition flex justify-between items-center"
data-id="{{ s.id }}"
>
<span class="truncate pr-2 font-semibold">{{ s.Nom }}</span>
<span
class="text-xs {% if loop.first %}bg-blue-800{% else %}bg-gray-800 text-gray-400{% endif %} px-2 py-0.5 rounded whitespace-nowrap"
>
{{ s.Forme or 'N/A' }}
</span>
</div>
{% endfor %}
</div>
</div>
<!-- COLONNE DROITE : Formulaire -->
<div
class="md:col-span-8 bg-gray-950 border border-gray-800 rounded-xl p-6 flex flex-col justify-between"
>
<form
id="societe-form"
method="POST"
action=""
class="space-y-4 flex-1 flex flex-col justify-between"
>
<!-- ID technique caché -->
<input type="hidden" id="field-id" name="id" />
<div class="space-y-4">
<h3
class="text-sm font-semibold text-gray-300 uppercase tracking-wider mb-2"
>
Détails de la société
</h3>
<!-- Ligne 1 : Nom (50%), Forme (25%), Capital (25%) -->
<div class="grid grid-cols-1 md:grid-cols-4 gap-4">
<div class="md:col-span-2">
<label class="block text-xs font-medium text-gray-400 mb-1"
>Nom</label
>
<input
type="text"
id="field-nom"
name="Nom"
required
maxlength="60"
class="w-full bg-gray-900 border border-gray-800 rounded-lg px-3 py-2 text-white text-sm focus:outline-none focus:border-blue-500"
/>
</div>
<div class="md:col-span-1">
<label class="block text-xs font-medium text-gray-400 mb-1"
>Forme</label
>
<input
type="text"
id="field-forme"
name="Forme"
required
maxlength="10"
class="w-full bg-gray-900 border border-gray-800 rounded-lg px-3 py-2 text-white text-sm focus:outline-none focus:border-blue-500"
/>
</div>
<div class="md:col-span-1">
<label class="block text-xs font-medium text-gray-400 mb-1"
>Capital (€)</label
>
<input
type="number"
id="field-capital"
name="Capital"
required
class="w-full bg-gray-900 border border-gray-800 rounded-lg px-3 py-2 text-white text-sm focus:outline-none focus:border-blue-500"
/>
</div>
</div>
<!-- Toutes les autres lignes sur 2 colonnes -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<!-- SIREN -->
<div>
<label class="block text-xs font-medium text-gray-400 mb-1"
>SIREN</label
>
<input
type="text"
id="field-siren"
name="siren"
required
maxlength="14"
class="w-full bg-gray-900 border border-gray-800 rounded-lg px-3 py-2 text-white text-sm focus:outline-none focus:border-blue-500"
/>
</div>
<!-- SIRET -->
<div>
<label class="block text-xs font-medium text-gray-400 mb-1"
>SIRET</label
>
<input
type="text"
id="field-siret"
name="siret"
required
maxlength="14"
class="w-full bg-gray-900 border border-gray-800 rounded-lg px-3 py-2 text-white text-sm focus:outline-none focus:border-blue-500"
/>
</div>
<!-- RCS -->
<div>
<label class="block text-xs font-medium text-gray-400 mb-1"
>RCS</label
>
<input
type="text"
id="field-rcs"
name="RCS"
required
maxlength="50"
class="w-full bg-gray-900 border border-gray-800 rounded-lg px-3 py-2 text-white text-sm focus:outline-none focus:border-blue-500"
/>
</div>
<!-- TVA Intra. -->
<div>
<label class="block text-xs font-medium text-gray-400 mb-1"
>TVA Intra.</label
>
<input
type="text"
id="field-tva"
name="TVA"
required
maxlength="50"
class="w-full bg-gray-900 border border-gray-800 rounded-lg px-3 py-2 text-white text-sm focus:outline-none focus:border-blue-500"
/>
</div>
<!-- Code NAF -->
<div>
<label class="block text-xs font-medium text-gray-400 mb-1"
>Code NAF</label
>
<input
type="text"
id="field-naf"
name="NAF"
required
maxlength="10"
class="w-full bg-gray-900 border border-gray-800 rounded-lg px-3 py-2 text-white text-sm focus:outline-none focus:border-blue-500"
/>
</div>
<!-- Téléphone -->
<div>
<label class="block text-xs font-medium text-gray-400 mb-1"
>Téléphone</label
>
<input
type="text"
id="field-tel"
name="Tel"
required
maxlength="30"
class="w-full bg-gray-900 border border-gray-800 rounded-lg px-3 py-2 text-white text-sm focus:outline-none focus:border-blue-500"
/>
</div>
<!-- Site Web -->
<div>
<label class="block text-xs font-medium text-gray-400 mb-1"
>Site Web</label
>
<input
type="text"
id="field-web"
name="Web"
required
maxlength="100"
class="w-full bg-gray-900 border border-gray-800 rounded-lg px-3 py-2 text-white text-sm focus:outline-none focus:border-blue-500"
/>
</div>
<!-- Email -->
<div>
<label class="block text-xs font-medium text-gray-400 mb-1"
>Email</label
>
<input
type="email"
id="field-mail"
name="Mail"
required
maxlength="100"
class="w-full bg-gray-900 border border-gray-800 rounded-lg px-3 py-2 text-white text-sm focus:outline-none focus:border-blue-500"
/>
</div>
</div>
</div>
<!-- Bas : Boutons -->
<div
class="flex items-center justify-end space-x-3 pt-6 border-t border-gray-800 mt-6"
>
<button
type="button"
onclick="preparerCreation()"
class="px-4 py-2 bg-gray-800 hover:bg-gray-700 text-gray-300 text-sm font-medium rounded-lg transition duration-200"
>
Nouveau / Vider
</button>
<button
type="button"
onclick="annulerAction()"
class="px-4 py-2 bg-gray-800 hover:bg-gray-700 text-gray-300 text-sm font-medium rounded-lg transition duration-200"
>
Annuler
</button>
<button
type="submit"
name="action"
value="creer"
class="px-4 py-2 bg-emerald-600 hover:bg-emerald-500 text-white text-sm font-medium rounded-lg transition duration-200"
>
Créer
</button>
<button
type="submit"
name="action"
value="modifier"
class="px-4 py-2 bg-blue-600 hover:bg-blue-500 text-white text-sm font-medium rounded-lg transition duration-200"
>
Modifier
</button>
</div>
</form>
</div>
</div>
<!-- Pied de page sécurisé centré -->
<div
class="border-t border-gray-800 pt-4 mt-6 text-xs text-gray-400 italic text-center w-full"
>
Positions en bourse : Accès sécurisé. Veillez à fermer votre session après
chaque utilisation.
</div>
</div>
</div>
<script>
// Disparition automatique des Toasts au bout de 4 secondes
document.addEventListener("DOMContentLoaded", () => {
const toasts = document.querySelectorAll(".toast-message");
toasts.forEach((toast) => {
setTimeout(() => {
toast.style.opacity = "0";
toast.style.transform = "translateY(-10px)";
setTimeout(() => toast.remove(), 300);
}, 4000);
});
const premiereSociete = document.querySelector(".societe-item");
if (premiereSociete) {
premiereSociete.click();
}
});
function selectionnerSociete(
id,
nom,
forme,
capital,
siren,
siret,
rcs,
tva,
naf,
tel,
web,
mail,
) {
document.getElementById("field-id").value = id;
document.getElementById("field-nom").value = nom;
document.getElementById("field-forme").value = forme;
document.getElementById("field-capital").value = capital;
document.getElementById("field-siren").value = siren;
document.getElementById("field-siret").value = siret;
document.getElementById("field-rcs").value = rcs;
document.getElementById("field-tva").value = tva;
document.getElementById("field-naf").value = naf;
document.getElementById("field-tel").value = tel;
document.getElementById("field-web").value = web;
document.getElementById("field-mail").value = mail;
document.querySelectorAll(".societe-item").forEach((el) => {
el.classList.remove("bg-blue-600", "text-white");
el.classList.add("hover:bg-gray-800", "text-gray-300");
const badge = el.querySelector("span:last-child");
if (badge) {
badge.classList.remove("bg-blue-800");
badge.classList.add("bg-gray-800", "text-gray-400");
}
});
const selectedEl = document.querySelector(`[data-id="${id}"]`);
if (selectedEl) {
selectedEl.classList.remove("hover:bg-gray-800", "text-gray-300");
selectedEl.classList.add("bg-blue-600", "text-white");
const badge = selectedEl.querySelector("span:last-child");
if (badge) {
badge.classList.remove("bg-gray-800", "text-gray-400");
badge.classList.add("bg-blue-800");
}
selectedEl.scrollIntoView({ block: "nearest" });
}
}
// Fonction pour vider le formulaire pour une création propre
function preparerCreation() {
document.getElementById("field-id").value = "";
document.getElementById("field-nom").value = "";
document.getElementById("field-forme").value = "";
document.getElementById("field-capital").value = "";
document.getElementById("field-siren").value = "";
document.getElementById("field-siret").value = "";
document.getElementById("field-rcs").value = "";
document.getElementById("field-tva").value = "";
document.getElementById("field-naf").value = "";
document.getElementById("field-tel").value = "";
document.getElementById("field-web").value = "";
document.getElementById("field-mail").value = "";
// Retirer la surbrillance de la liste
document.querySelectorAll(".societe-item").forEach((el) => {
el.classList.remove("bg-blue-600", "text-white");
el.classList.add("hover:bg-gray-800", "text-gray-300");
const badge = el.querySelector("span:last-child");
if (badge) {
badge.classList.remove("bg-blue-800");
badge.classList.add("bg-gray-800", "text-gray-400");
}
});
}
function annulerAction() {
const premiereSociete = document.querySelector(".societe-item");
if (premiereSociete) {
premiereSociete.click();
}
}
</script>
{% endblock %}
+16 -2
View File
@@ -14,6 +14,7 @@ header_title %}Tableau de bord{% endblock %} {% block content %}
<!-- Grille principale : 2 colonnes pour les boutons --> <!-- Grille principale : 2 colonnes pour les boutons -->
<!-- Grille des 8 gros boutons --> <!-- Grille des 8 gros boutons -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-5 mb-8"> <div class="grid grid-cols-1 md:grid-cols-2 gap-5 mb-8">
<!-- btn 1 -->
<a <a
href="{{ url_for('main.gestion_actions') }}" href="{{ url_for('main.gestion_actions') }}"
class="py-6 px-6 bg-gray-950 hover:bg-blue-600/30 border-2 border-gray-800 hover:border-blue-500 rounded-xl text-white text-lg font-bold tracking-wide transition-all duration-200 flex items-center justify-center shadow-lg hover:scale-[1.01]" class="py-6 px-6 bg-gray-950 hover:bg-blue-600/30 border-2 border-gray-800 hover:border-blue-500 rounded-xl text-white text-lg font-bold tracking-wide transition-all duration-200 flex items-center justify-center shadow-lg hover:scale-[1.01]"
@@ -21,42 +22,55 @@ header_title %}Tableau de bord{% endblock %} {% block content %}
1. Gérer les actions 1. Gérer les actions
</a> </a>
<!-- btn 2 -->
<a <a
href="#" href="#"
class="py-6 px-6 bg-gray-950 hover:bg-blue-600/30 border-2 border-gray-800 hover:border-blue-500 rounded-xl text-white text-lg font-bold tracking-wide transition-all duration-200 flex items-center justify-center shadow-lg hover:scale-[1.01]" class="py-6 px-6 bg-gray-950 hover:bg-blue-600/30 border-2 border-gray-800 hover:border-blue-500 rounded-xl text-white text-lg font-bold tracking-wide transition-all duration-200 flex items-center justify-center shadow-lg hover:scale-[1.01]"
> >
2. Ordres 2. Ordres
</a> </a>
<!-- btn 3 -->
<a <a
href="#" href="#"
class="py-6 px-6 bg-gray-950 hover:bg-blue-600/30 border-2 border-gray-800 hover:border-blue-500 rounded-xl text-white text-lg font-bold tracking-wide transition-all duration-200 flex items-center justify-center shadow-lg hover:scale-[1.01]" class="py-6 px-6 bg-gray-950 hover:bg-blue-600/30 border-2 border-gray-800 hover:border-blue-500 rounded-xl text-white text-lg font-bold tracking-wide transition-all duration-200 flex items-center justify-center shadow-lg hover:scale-[1.01]"
> >
3. Comptes 3. Comptes
</a> </a>
<!-- btn 4 -->
<a <a
href="#" href="{{ url_for('main.gestion_societes') }}"
class="py-6 px-6 bg-gray-950 hover:bg-blue-600/30 border-2 border-gray-800 hover:border-blue-500 rounded-xl text-white text-lg font-bold tracking-wide transition-all duration-200 flex items-center justify-center shadow-lg hover:scale-[1.01]" class="py-6 px-6 bg-gray-950 hover:bg-blue-600/30 border-2 border-gray-800 hover:border-blue-500 rounded-xl text-white text-lg font-bold tracking-wide transition-all duration-200 flex items-center justify-center shadow-lg hover:scale-[1.01]"
> >
4. Données perso 4. Gestion sociétés
</a> </a>
<!-- btn 5 -->
<a <a
href="{{ url_for('main.gestion_utilisateurs') }}" href="{{ url_for('main.gestion_utilisateurs') }}"
class="py-6 px-6 bg-gray-950 hover:bg-blue-600/30 border-2 border-gray-800 hover:border-blue-500 rounded-xl text-white text-lg font-bold tracking-wide transition-all duration-200 flex items-center justify-center shadow-lg hover:scale-[1.01]" class="py-6 px-6 bg-gray-950 hover:bg-blue-600/30 border-2 border-gray-800 hover:border-blue-500 rounded-xl text-white text-lg font-bold tracking-wide transition-all duration-200 flex items-center justify-center shadow-lg hover:scale-[1.01]"
> >
5. Gestion utilisateurs 5. Gestion utilisateurs
</a> </a>
<!-- btn 6 -->
<a <a
href="#" href="#"
class="py-6 px-6 bg-gray-950 hover:bg-blue-600/30 border-2 border-gray-800 hover:border-blue-500 rounded-xl text-white text-lg font-bold tracking-wide transition-all duration-200 flex items-center justify-center shadow-lg hover:scale-[1.01]" class="py-6 px-6 bg-gray-950 hover:bg-blue-600/30 border-2 border-gray-800 hover:border-blue-500 rounded-xl text-white text-lg font-bold tracking-wide transition-all duration-200 flex items-center justify-center shadow-lg hover:scale-[1.01]"
> >
6. Stat historique 6. Stat historique
</a> </a>
<!-- btn 7 -->
<a <a
href="#" href="#"
class="py-6 px-6 bg-gray-950 hover:bg-blue-600/30 border-2 border-gray-800 hover:border-blue-500 rounded-xl text-white text-lg font-bold tracking-wide transition-all duration-200 flex items-center justify-center shadow-lg hover:scale-[1.01]" class="py-6 px-6 bg-gray-950 hover:bg-blue-600/30 border-2 border-gray-800 hover:border-blue-500 rounded-xl text-white text-lg font-bold tracking-wide transition-all duration-200 flex items-center justify-center shadow-lg hover:scale-[1.01]"
> >
7. Import/Export Actions CSV 7. Import/Export Actions CSV
</a> </a>
<!-- btn 8 -->
<a <a
href="#" href="#"
class="py-6 px-6 bg-gray-950 hover:bg-blue-600/30 border-2 border-gray-800 hover:border-blue-500 rounded-xl text-white text-lg font-bold tracking-wide transition-all duration-200 flex items-center justify-center shadow-lg hover:scale-[1.01]" class="py-6 px-6 bg-gray-950 hover:bg-blue-600/30 border-2 border-gray-800 hover:border-blue-500 rounded-xl text-white text-lg font-bold tracking-wide transition-all duration-200 flex items-center justify-center shadow-lg hover:scale-[1.01]"