connexion base et création premier crud

This commit is contained in:
Logshiro
2025-10-16 17:01:43 +02:00
parent ea9a187326
commit 2e4dce40d4
38 changed files with 653 additions and 278 deletions

View File

@@ -0,0 +1,13 @@
{#
Shared partial to include Bootstrap. Use with:
{{ include('_bootstrap.html.twig', { part: 'css' }) }} in the <head>
{{ include('_bootstrap.html.twig', { part: 'js' }) }} before closing </body>
#}
{% if part == 'css' %}
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
{% elseif part == 'js' %}
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
{% endif %}

View File

@@ -5,13 +5,17 @@
<title>{% block title %}Welcome!{% endblock %}</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 128 128%22><text y=%221.2em%22 font-size=%2296%22>⚫️</text><text y=%221.3em%22 x=%220.2em%22 font-size=%2276%22 fill=%22%23fff%22>sf</text></svg>">
{% block stylesheets %}
{{ include('_bootstrap.html.twig', { part: 'css' }) }}
{% endblock %}
{% block javascripts %}
{{ include('_bootstrap.html.twig', { part: 'js' }) }}
{% block importmap %}{{ importmap('app') }}{% endblock %}
{% endblock %}
</head>
<body>
{% block body %}{% endblock %}
<div class="container py-4">
{% block body %}{% endblock %}
</div>
</body>
</html>

View File

@@ -0,0 +1,4 @@
<form method="post" action="{{ path('app_contribution_delete', {'id': contribution.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ contribution.id) }}">
<button class="btn">Delete</button>
</form>

View File

@@ -0,0 +1,13 @@
{% extends 'base.html.twig' %}
{% block title %}Edit Contribution{% endblock %}
{% block body %}
<h1>Edit Contribution</h1>
{{ include('contribution/_form.html.twig', {'button_label': 'Update'}) }}
<a href="{{ path('app_contribution_index') }}">back to list</a>
{{ include('contribution/_delete_form.html.twig') }}
{% endblock %}

View File

@@ -0,0 +1,35 @@
{% extends 'base.html.twig' %}
{% block title %}Contribution index{% endblock %}
{% block body %}
<h1>Contribution index</h1>
<table class="table">
<thead>
<tr>
<th>Id</th>
<th>Duree</th>
<th>actions</th>
</tr>
</thead>
<tbody>
{% for contribution in contributions %}
<tr>
<td>{{ contribution.id }}</td>
<td>{{ contribution.duree }}</td>
<td>
<a href="{{ path('app_contribution_show', {'id': contribution.id}) }}">show</a>
<a href="{{ path('app_contribution_edit', {'id': contribution.id}) }}">edit</a>
</td>
</tr>
{% else %}
<tr>
<td colspan="3">no records found</td>
</tr>
{% endfor %}
</tbody>
</table>
<a href="{{ path('app_contribution_new') }}">Create new</a>
{% endblock %}

View File

@@ -0,0 +1,11 @@
{% extends 'base.html.twig' %}
{% block title %}New Contribution{% endblock %}
{% block body %}
<h1>Create new Contribution</h1>
{{ include('contribution/_form.html.twig') }}
<a href="{{ path('app_contribution_index') }}">back to list</a>
{% endblock %}

View File

@@ -0,0 +1,26 @@
{% extends 'base.html.twig' %}
{% block title %}Contribution{% endblock %}
{% block body %}
<h1>Contribution</h1>
<table class="table">
<tbody>
<tr>
<th>Id</th>
<td>{{ contribution.id }}</td>
</tr>
<tr>
<th>Duree</th>
<td>{{ contribution.duree }}</td>
</tr>
</tbody>
</table>
<a href="{{ path('app_contribution_index') }}">back to list</a>
<a href="{{ path('app_contribution_edit', {'id': contribution.id}) }}">edit</a>
{{ include('contribution/_delete_form.html.twig') }}
{% endblock %}

View File

@@ -1,4 +0,0 @@
<form method="post" action="{{ path('app_droit_delete', {'idDroit': droit.idDroit}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ droit.idDroit) }}">
<button class="btn">Delete</button>
</form>

View File

@@ -1,13 +0,0 @@
{% extends 'base.html.twig' %}
{% block title %}Edit Droit{% endblock %}
{% block body %}
<h1>Edit Droit</h1>
{{ include('droit/_form.html.twig', {'button_label': 'Update'}) }}
<a href="{{ path('app_droit_index') }}">back to list</a>
{{ include('droit/_delete_form.html.twig') }}
{% endblock %}

View File

@@ -1,35 +0,0 @@
{% extends 'base.html.twig' %}
{% block title %}Droit index{% endblock %}
{% block body %}
<h1>Droit index</h1>
<table class="table">
<thead>
<tr>
<th>IdDroit</th>
<th>LibDroit</th>
<th>actions</th>
</tr>
</thead>
<tbody>
{% for droit in droits %}
<tr>
<td>{{ droit.idDroit }}</td>
<td>{{ droit.libDroit }}</td>
<td>
<a href="{{ path('app_droit_show', {'idDroit': droit.idDroit}) }}">show</a>
<a href="{{ path('app_droit_edit', {'idDroit': droit.idDroit}) }}">edit</a>
</td>
</tr>
{% else %}
<tr>
<td colspan="3">no records found</td>
</tr>
{% endfor %}
</tbody>
</table>
<a href="{{ path('app_droit_new') }}">Create new</a>
{% endblock %}

View File

@@ -1,11 +0,0 @@
{% extends 'base.html.twig' %}
{% block title %}New Droit{% endblock %}
{% block body %}
<h1>Create new Droit</h1>
{{ include('droit/_form.html.twig') }}
<a href="{{ path('app_droit_index') }}">back to list</a>
{% endblock %}

View File

@@ -1,26 +0,0 @@
{% extends 'base.html.twig' %}
{% block title %}Droit{% endblock %}
{% block body %}
<h1>Droit</h1>
<table class="table">
<tbody>
<tr>
<th>IdDroit</th>
<td>{{ droit.idDroit }}</td>
</tr>
<tr>
<th>LibDroit</th>
<td>{{ droit.libDroit }}</td>
</tr>
</tbody>
</table>
<a href="{{ path('app_droit_index') }}">back to list</a>
<a href="{{ path('app_droit_edit', {'idDroit': droit.idDroit}) }}">edit</a>
{{ include('droit/_delete_form.html.twig') }}
{% endblock %}

View File

@@ -1,4 +1,4 @@
<form method="post" action="{{ path('app_membre_delete', {'id': membre.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ membre.id) }}">
<button class="btn">Delete</button>
<button class="btn btn-danger">Delete</button>
</form>

View File

@@ -1,4 +1,4 @@
{{ form_start(form) }}
{{ form_widget(form) }}
<button class="btn">{{ button_label|default('Save') }}</button>
<button class="btn btn-primary">{{ button_label|default('Save') }}</button>
{{ form_end(form) }}

View File

@@ -3,11 +3,16 @@
{% block title %}Edit Membre{% endblock %}
{% block body %}
<h1>Edit Membre</h1>
{{ include('membre/_form.html.twig', {'button_label': 'Update'}) }}
<a href="{{ path('app_membre_index') }}">back to list</a>
{{ include('membre/_delete_form.html.twig') }}
<div class="card mb-3">
<div class="card-header">
<h1 class="h4 mb-0">Edit Membre</h1>
</div>
<div class="card-body">
{{ include('membre/_form.html.twig', {'button_label': 'Update'}) }}
<div class="d-flex gap-2 mt-2">
<a href="{{ path('app_membre_index') }}" class="btn btn-outline-secondary">Back to list</a>
{{ include('membre/_delete_form.html.twig') }}
</div>
</div>
</div>
{% endblock %}

View File

@@ -2,44 +2,37 @@
{% block title %}Membre index{% endblock %}
{% block stylesheets %}
{{ parent() }}
{# Ajouter Bootstrap depuis le CDN #}
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
{% endblock %}
{% block body %}
<div class="container mt-4">
<h1 class="mb-4">Membre index</h1>
<table class="table table-striped table-bordered">
<thead class="table-dark">
<tr>
<th>Id</th>
<th>Nom</th>
<th>Password</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for membre in membres %}
<tr>
<td>{{ membre.id }}</td>
<td>{{ membre.nom }}</td>
<td>{{ membre.password }}</td>
<td>
<a href="{{ path('app_membre_show', {'id': membre.id}) }}" class="btn btn-sm btn-primary">Show</a>
<a href="{{ path('app_membre_edit', {'id': membre.id}) }}" class="btn btn-sm btn-warning">Edit</a>
</td>
</tr>
{% else %}
<tr>
<td colspan="4" class="text-center">No records found</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="d-flex justify-content-between align-items-center mb-3">
<h1 class="h3 mb-0">Membres</h1>
<a href="{{ path('app_membre_new') }}" class="btn btn-success">Create new</a>
</div>
<table class="table table-striped table-hover align-middle">
<thead>
<tr>
<th>Id</th>
<th>Nom</th>
<th>Droit</th>
<th class="text-end">Actions</th>
</tr>
</thead>
<tbody>
{% for membre in membres %}
<tr>
<td>{{ membre.id }}</td>
<td>{{ membre.nom }}</td>
<td>{{ membre.droit }}</td>
<td class="text-end">
<a href="{{ path('app_membre_show', {'id': membre.id}) }}" class="btn btn-sm btn-outline-primary me-1">Show</a>
<a href="{{ path('app_membre_edit', {'id': membre.id}) }}" class="btn btn-sm btn-outline-secondary">Edit</a>
</td>
</tr>
{% else %}
<tr>
<td colspan="5" class="text-center text-muted">No records found</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}

View File

@@ -1,22 +0,0 @@
{# templates/membre/index.html.twig #}
<h1>Liste des Membres</h1>
<table border="1">
<thead>
<tr>
<th>ID</th>
<th>Nom</th>
<th>Droit</th>
</tr>
</thead>
<tbody>
{% for membre in membres %}
<tr>
<td>{{ membre.id }}</td>
<td>{{ membre.nom }}</td>
<td>{{ membre.droit ? membre.droit.nom : 'Aucun' }}</td>
</tr>
{% endfor %}
</tbody>
</table>

View File

@@ -3,9 +3,13 @@
{% block title %}New Membre{% endblock %}
{% block body %}
<h1>Create new Membre</h1>
{{ include('membre/_form.html.twig') }}
<a href="{{ path('app_membre_index') }}">back to list</a>
<div class="card">
<div class="card-header">
<h1 class="h4 mb-0">Create new Membre</h1>
</div>
<div class="card-body">
{{ include('membre/_form.html.twig') }}
<a href="{{ path('app_membre_index') }}" class="btn btn-outline-secondary mt-2">Back to list</a>
</div>
</div>
{% endblock %}

View File

@@ -3,9 +3,15 @@
{% block title %}Membre{% endblock %}
{% block body %}
<h1>Membre</h1>
<div class="d-flex justify-content-between align-items-center mb-3">
<h1 class="h3 mb-0">Membre #{{ membre.id }}</h1>
<div>
<a href="{{ path('app_membre_edit', {'id': membre.id}) }}" class="btn btn-secondary me-2">Edit</a>
<a href="{{ path('app_membre_index') }}" class="btn btn-outline-secondary">Back to list</a>
</div>
</div>
<table class="table">
<table class="table table-bordered">
<tbody>
<tr>
<th>Id</th>
@@ -17,14 +23,16 @@
</tr>
<tr>
<th>Password</th>
<td>{{ membre.password }}</td>
<td>********</td>
</tr>
<tr>
<th>Droit</th>
<td>{{ membre.droit }}</td>
</tr>
</tbody>
</table>
<a href="{{ path('app_membre_index') }}">back to list</a>
<a href="{{ path('app_membre_edit', {'id': membre.id}) }}">edit</a>
{{ include('membre/_delete_form.html.twig') }}
<div class="mt-3">
{{ include('membre/_delete_form.html.twig') }}
</div>
{% endblock %}

View File

@@ -0,0 +1,4 @@
<form method="post" action="{{ path('app_projet_delete', {'id': projet.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ projet.id) }}">
<button class="btn">Delete</button>
</form>

View File

@@ -0,0 +1,4 @@
{{ form_start(form) }}
{{ form_widget(form) }}
<button class="btn">{{ button_label|default('Save') }}</button>
{{ form_end(form) }}

View File

@@ -0,0 +1,13 @@
{% extends 'base.html.twig' %}
{% block title %}Edit Projet{% endblock %}
{% block body %}
<h1>Edit Projet</h1>
{{ include('projet/_form.html.twig', {'button_label': 'Update'}) }}
<a href="{{ path('app_projet_index') }}">back to list</a>
{{ include('projet/_delete_form.html.twig') }}
{% endblock %}

View File

@@ -0,0 +1,35 @@
{% extends 'base.html.twig' %}
{% block title %}Projet index{% endblock %}
{% block body %}
<h1>Projet index</h1>
<table class="table">
<thead>
<tr>
<th>Id</th>
<th>Nom</th>
<th>actions</th>
</tr>
</thead>
<tbody>
{% for projet in projets %}
<tr>
<td>{{ projet.id }}</td>
<td>{{ projet.nom }}</td>
<td>
<a href="{{ path('app_projet_show', {'id': projet.id}) }}">show</a>
<a href="{{ path('app_projet_edit', {'id': projet.id}) }}">edit</a>
</td>
</tr>
{% else %}
<tr>
<td colspan="3">no records found</td>
</tr>
{% endfor %}
</tbody>
</table>
<a href="{{ path('app_projet_new') }}">Create new</a>
{% endblock %}

View File

@@ -0,0 +1,11 @@
{% extends 'base.html.twig' %}
{% block title %}New Projet{% endblock %}
{% block body %}
<h1>Create new Projet</h1>
{{ include('projet/_form.html.twig') }}
<a href="{{ path('app_projet_index') }}">back to list</a>
{% endblock %}

View File

@@ -0,0 +1,26 @@
{% extends 'base.html.twig' %}
{% block title %}Projet{% endblock %}
{% block body %}
<h1>Projet</h1>
<table class="table">
<tbody>
<tr>
<th>Id</th>
<td>{{ projet.id }}</td>
</tr>
<tr>
<th>Nom</th>
<td>{{ projet.nom }}</td>
</tr>
</tbody>
</table>
<a href="{{ path('app_projet_index') }}">back to list</a>
<a href="{{ path('app_projet_edit', {'id': projet.id}) }}">edit</a>
{{ include('projet/_delete_form.html.twig') }}
{% endblock %}