nineskeletor/templates/Registration/edit.html.twig

308 lines
12 KiB
Twig
Raw Normal View History

2022-07-21 16:15:47 +02:00
{% extends 'base.html.twig' %}
{% block localstyle %}
<style>
.captcha_image {
display:block;
}
#alertpassword input,#alertpassword label { display:none }
#alertpassword .form-group {margin:0px !important }
</style>
{% endblock %}
{% block body %}
{{ form_start(form) }}
{% if appModeregistration!="none" %}
<h1 class="page-header">
{% if mode=="update" %}
Confirmation à l'Utilisateur = {{ registration.username }}
{% elseif mode=="submit" %}
Inscription
{% endif %}
</h1>
{{ form_widget(form.submit) }}
{% if mode=="update" %}
{{ form_widget(form.save) }}
<a class="btn btn-secondary" href="mailto:{{registration.email}}?subject= {{app.session.get('appname')}} : à propos de votre inscription">Envoyer un mail</a>
<a class="btn btn-secondary" href={{ path('app_'~access~'_registration') }}>Annuler</a>
<a class="btn btn-danger float-end" href={{ path('app_'~access~'_registration_delete',{id:registration.id}) }} data-method="delete" data-confirm="Êtes-vous sûr de vouloir supprimer cet enregistrement ?">Supprimer</a>
{%endif%}
<br><br>
{% if app.session.flashbag.has('error') %}
<div class='alert alert-danger' style='margin: 5px 0px'>
<strong>Erreur</strong><br>
{% for flashMessage in app.session.flashbag.get('error') %}
{{ flashMessage | raw }}<br>
{% endfor %}
</div>
{% endif %}
{% if app.session.flashbag.has('notice') %}
<div class='alert alert-info' style='margin: 5px 0px'>
<strong>Information</strong><br>
{% for flashMessage in app.session.flashbag.get('notice') %}
{{ flashMessage | raw }}<br>
{% endfor %}
</div>
{% endif %}
{% if mode=="send" %}
<div class='alert alert-info' style='margin: 5px 0px'>
<strong>Information</strong><br>
Cette action permet de générer une nouvelle clé de validation et de renouveller la date d'expiration de cette clé.<br>
Un email sera envoyé à l'utilisateur
</div>
<br>
{% endif %}
<div class="row">
{% if mode=="update" %}
<div class="col-sm-12">
<div class="card">
<div class="card-header">
<i class="fa fa-key fa-fw"></i> Notes Administrateur
</div>
<div class="card-body">
{{ form_widget(form.note) }}
</div>
</div>
</div>
{%endif%}
<div class="col-sm-6">
<div class="card">
<div class="card-header">
<i class="fa fa-key fa-fw"></i> Connexion
</div>
<div class="card-body">
{{ form_row(form.username) }}
<div class='alert alert-info' style='font-size: 80%;padding: 5px;margin-top:-2px; border-radius:0px 0px 0.25rem 0.25rem'>
Formatez votre login sous la forme prenom.nom dans la mesure du possible<br>
Taille minimum = 5 caractères<br>
Caractères interdits = accent, espace, caractères spéciaux sauf @ . - _<br>
</div>
{% if form.password is defined %}
{{ form_row(form.password) }}
<div id="alertpassword">{{ form_row(form.passwordplain) }}</div>
<div class='alert alert-info' style='font-size: 80%;padding: 5px;margin-top:-2px; border-radius:0px 0px 0.25rem 0.25rem'>
Le mot de passe doit comporter au moins 8 caractères, avec obligatoirement des lettres, chiffres et caractères spéciaux.
</div>
{% if form.captcha is defined %}
{{ form_row(form.captcha) }}
{% endif %}
{% endif %}
</div>
</div>
<div class="card mt-3">
<div class="card-header">
<i class="fa fa-pencil-alt fa-fw"></i> Motivations
</div>
<div class="card-body">
{{ form_row(form.motivation) }}
</div>
</div>
</div>
<div class="col-sm-6">
<div class="card">
<div class="card-header">
<i class="fa fa-pencil fa-fw"></i> Informations
</div>
<div class="card-body">
{{ form_row(form.niveau01) }}
{%if form.niveau02 is defined %}{{ form_row(form.niveau02) }}{%endif%}
{%if form.niveau03 is defined %}{{ form_row(form.niveau03) }}{%endif%}
{%if form.niveau04 is defined %}{{ form_row(form.niveau04) }}{%endif%}
2022-07-21 16:15:47 +02:00
{{ form_row(form.firstname) }}
{{ form_row(form.lastname) }}
{{ form_row(form.email) }}
<div class='alert alert-info alert-email' style='display:none; font-size: 80%;padding: 5px;margin-top:-2px; border-radius:0px 0px 0.25rem 0.25rem'>
Votre mail ne fait pas partie des mails professonniels pré-inscrits dans {{app.session.get("appname")}}.<br>
S'il s'agit de votre mail professionnel vous devez compléter le formulaire "Motivations" pour que l'administrateur de {{app.session.get("appname")}} valide votre demannde d'inscription.
</div>
{{ form_row(form.isvisible) }}
</div>
</div>
<div class="card mt-3">
<div class="card-header">
<i class="fa fa-sitemap fa-fw"></i> Organisation
</div>
<div class="card-body">
{{ form_row(form.job) }}
{{ form_row(form.position) }}
{{ form_row(form.postaladress) }}
{{ form_row(form.telephonenumber) }}
</div>
</div>
2022-07-26 16:03:53 +02:00
{% if auditUse and mode=="update" and (access=="admin" or access=="modo" or access=="audit") %}
{{ render(path("app_"~access~"_audit_renderid",{entityname:"Registration",entityid:registration.id})) }}
{% endif %}
2022-07-21 16:15:47 +02:00
</div>
</div>
{% endif %}
{{ form_end(form) }}
{% endblock %}
{% block localscript %}
<script>
$(document).ready(function() {
if(!$("#paneloption").find(".card-body").find("label").length) $("#paneloption").hide();
select2niveau02();
select2niveau03();
select2niveau04();
requireniveau();
});
function requireniveau() {
roles=["ROLE_USER"];
{% if "ALL" in appNiveau02mandatory %}
$("#registration_niveau02").attr("required","required");
$("label[for='registration_niveau02']").text("{{appNiveau02label}} *");
{% else %}
$("#registration_niveau02").removeAttr("required");
$("label[for='registration_niveau02']").text("{{appNiveau02label}}");
{% for mandatory in appNiveau02mandatory %}
if(roles.includes("{{ mandatory }}")) {
$("#registration_niveau02").attr("required","required");
$("label[for='registration_niveau02']").text("{{appNiveau02label}} *");
}
{% endfor %}
{% endif %}
{% if "ALL" in appNiveau03mandatory %}
$("#registration_niveau03").attr("required","required");
$("label[for='registration_niveau03']").text("{{appNiveau03label}} *");
{% else %}
$("#registration_niveau03").removeAttr("required");
$("label[for='registration_niveau03']").text("{{appNiveau03label}}");
{% for mandatory in appNiveau03mandatory %}
if(roles.includes("{{ mandatory }}")) {
$("#registration_niveau03").attr("required","required");
$("label[for='registration_niveau03']").text("{{appNiveau03label}} *");
}
{% endfor %}
{% endif %}
{% if "ALL" in appNiveau04mandatory %}
$("#registration_niveau04").attr("required","required");
$("label[for='registration_niveau04']").text("{{appNiveau04label}} *");
{% else %}
$("#registration_niveau04").removeAttr("required");
$("label[for='registration_niveau04']").text("{{appNiveau04label}}");
{% for mandatory in appNiveau04mandatory %}
if(roles.includes("{{ mandatory }}")) {
$("#registration_niveau04").attr("required","required");
$("label[for='registration_niveau04']").text("{{appNiveau04label}} *");
}
{% endfor %}
{% endif %}
}
2022-07-21 16:15:47 +02:00
$(document.body).on("change","#registration_niveau01",function(){
$("#registration_niveau02").empty();
$("#registration_niveau03").empty();
$("#registration_niveau04").empty();
2022-07-21 16:15:47 +02:00
select2niveau02();
select2niveau03();
select2niveau04();
2022-07-21 16:15:47 +02:00
});
$(document.body).on("change","#registration_niveau02",function(){
$("#registration_niveau03").empty();
$("#registration_niveau04").empty();
select2niveau03();
select2niveau04();
});
$(document.body).on("change","#registration_niveau03",function(){
$("#registration_niveau04").empty();
select2niveau04();
});
2022-07-21 16:15:47 +02:00
function select2niveau02() {
$('#registration_niveau02').select2({
theme: 'bootstrap4',
language: "fr",
ajax: {
data: function (params) {
var query = {
niveau01: $("#registration_niveau01").val(),
}
return query;
}
}
});
}
function select2niveau03() {
$('#registration_niveau03').select2({
theme: 'bootstrap4',
language: "fr",
ajax: {
data: function (params) {
var query = {
niveau02: $("#registration_niveau02").val(),
}
return query;
}
}
});
}
function select2niveau04() {
$('#registration_niveau04').select2({
theme: 'bootstrap4',
language: "fr",
ajax: {
data: function (params) {
var query = {
niveau03: $("#registration_niveau03").val(),
}
return query;
}
}
});
}
2022-07-21 16:15:47 +02:00
$(document.body).on("focusout","#registration_email",function(){
$.ajax({
method: "POST",
url: "{{ path('app_whitelist_is') }}",
data: {
email:$("#registration_email").val(),
},
success: function(data) {
if(data=="KO") {
$("#registration_motivation").attr("required","required");
$(".alert-email").show();
$("label[for='registration_motivation']").text("Motivation *");
}
else {
$("#registration_motivation").removeAttr("required");
$(".alert-email").hide();
$("label[for='registration_motivation']").text("Motivation");
}
}
});
});
</script>
{% endblock %}