gestion du niveau01 autre (ref #141)

This commit is contained in:
afornerot 2020-06-09 14:18:17 +02:00
parent e85f74cda5
commit f20eff9b05
9 changed files with 143 additions and 8 deletions

View File

@ -102,8 +102,19 @@ class CoreController extends Controller
} }
} }
} }
// Si niveau01 commence par autre = alors niveau01other obligatoire
$message="";
$niveau01=strtolower($user->getNiveau01()->getLabel());
if(stripos($niveau01,"autre")===0) {
if(!$user->getNiveau01other()) {
$toprofil=true;
$message="<br>Merci d'indiquer votre ".$this->getParameter("labelniveau01");
}
}
if($toprofil) { if($toprofil) {
return $this->redirect($this->generateUrl('cadoles_core_user',array("info"=>"Merci de compléter votre profil"))); return $this->redirect($this->generateUrl('cadoles_core_user',array("info"=>"Merci de compléter votre profil".$message)));
} }
} }

View File

@ -159,7 +159,7 @@ class RegistrationController extends Controller
$action, $action,
$data->getUsername(), $data->getUsername(),
$data->getEmail(), $data->getEmail(),
$data->getNiveau01()->getLabel(), $data->getNiveau01()->getLabel()."<br>".$data->getNiveau01other(),
$data->getStatut()->getLabel(), $data->getStatut()->getLabel(),
(is_null($data->getKeyexpire())?"":$data->getKeyexpire()->format('d/m/Y H:i:s')) (is_null($data->getKeyexpire())?"":$data->getKeyexpire()->format('d/m/Y H:i:s'))
)); ));
@ -859,6 +859,14 @@ class RegistrationController extends Controller
if($this->getUserBy("username",$data->getUsername())||$this->getUserBy("email",$data->getEmail())) { if($this->getUserBy("username",$data->getUsername())||$this->getUserBy("email",$data->getEmail())) {
$form->addError(new FormError('Un utilisateur utilise déjà ce login ou cet email')); $form->addError(new FormError('Un utilisateur utilise déjà ce login ou cet email'));
} }
// Si niveau01 commence par autre = niveau01other obligatoire
$niveau01=strtolower($data->getNiveau01()->getLabel());
if(stripos($niveau01,"autre")===0) {
if(!$data->getNiveau01other()) {
$form->addError(new FormError("Merci d'indiquer votre ".$this->getParameter("labelniveau01")));
}
}
} }
if ($form->get('submit')->isClicked() && !$form->isValid()) { if ($form->get('submit')->isClicked() && !$form->isValid()) {

View File

@ -303,7 +303,7 @@ class UserController extends Controller
array_push($tmp,$data->getFirstname()); array_push($tmp,$data->getFirstname());
array_push($tmp,"<a href='mailto:".$data->getEmail()."'>".$data->getEmail()."</a>"); array_push($tmp,"<a href='mailto:".$data->getEmail()."'>".$data->getEmail()."</a>");
array_push($tmp,$data->getTelephonenumber()); array_push($tmp,$data->getTelephonenumber());
array_push($tmp,$data->getNiveau01()->getLabel()); array_push($tmp,$data->getNiveau01()->getLabel()."<br>".$data->getNiveau01other());
if($viewniveau02) array_push($tmp,($data->getNiveau02()!==null?$data->getNiveau02()->getLabel():"")); if($viewniveau02) array_push($tmp,($data->getNiveau02()!==null?$data->getNiveau02()->getLabel():""));
array_push($tmp,$groups); array_push($tmp,$groups);
array_push($tmp,$data->getJob()); array_push($tmp,$data->getJob());
@ -1262,6 +1262,14 @@ class UserController extends Controller
if($this->getRegistrationBy("username",$data->getUsername())||$this->getRegistrationBy("email",$data->getEmail())) { if($this->getRegistrationBy("username",$data->getUsername())||$this->getRegistrationBy("email",$data->getEmail())) {
$form->addError(new FormError('Une inscription utilise déjà ce login ou cet email')); $form->addError(new FormError('Une inscription utilise déjà ce login ou cet email'));
} }
// Si niveau01 commence par autre = niveau01other obligatoire
$niveau01=strtolower($data->getNiveau01()->getLabel());
if(stripos($niveau01,"autre")===0) {
if(!$data->getNiveau01other()) {
$form->addError(new FormError("Merci d'indiquer votre ".$this->getParameter("labelniveau01")));
}
}
} }

View File

@ -123,6 +123,11 @@ class Registration implements UserInterface, \Serializable
*/ */
private $position; private $position;
/**
* @ORM\Column(type="string", length=150, nullable=true)
*/
private $niveau01other;
/** /**
* @ORM\Column(type="integer", length=60, nullable=true) * @ORM\Column(type="integer", length=60, nullable=true)
*/ */
@ -738,4 +743,28 @@ class Registration implements UserInterface, \Serializable
{ {
return $this->groupid; return $this->groupid;
} }
/**
* Set niveau01other
*
* @param string $niveau01other
*
* @return Registration
*/
public function setNiveau01other($niveau01other)
{
$this->niveau01other = $niveau01other;
return $this;
}
/**
* Get niveau01other
*
* @return string
*/
public function getNiveau01other()
{
return $this->niveau01other;
}
} }

View File

@ -173,6 +173,11 @@ class User implements UserInterface, \Serializable
*/ */
private $visitecpt; private $visitecpt;
/**
* @ORM\Column(type="string", length=150, nullable=true)
*/
private $niveau01other;
/** /**
* @ORM\ManyToOne(targetEntity="Country", inversedBy="users") * @ORM\ManyToOne(targetEntity="Country", inversedBy="users")
* @ORM\JoinColumn(nullable=true) * @ORM\JoinColumn(nullable=true)
@ -1854,4 +1859,28 @@ class User implements UserInterface, \Serializable
{ {
return $this->visitecpt; return $this->visitecpt;
} }
/**
* Set niveau01other
*
* @param string $niveau01other
*
* @return User
*/
public function setNiveau01other($niveau01other)
{
$this->niveau01other = $niveau01other;
return $this;
}
/**
* Get niveau01other
*
* @return string
*/
public function getNiveau01other()
{
return $this->niveau01other;
}
} }

View File

@ -76,10 +76,21 @@ class RegistrationType extends AbstractType
EntityType::class, EntityType::class,
array("class" => "CadolesCoreBundle:Niveau01", array("class" => "CadolesCoreBundle:Niveau01",
"label" => $session->get('labelniveau01'), "label" => $session->get('labelniveau01'),
'placeholder' => '== Choisir '.$session->get('labelniveau01').' ==',
"choice_label" => "label", "choice_label" => "label",
"disabled" => ($options["mode"]=="delete"?true:false), "disabled" => ($options["mode"]=="delete"?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px","readonly" => ($options["mode"]=="delete"?true:false)))); "attr" => array("class" => "form-control", "style" => "margin-bottom:15px","readonly" => ($options["mode"]=="delete"?true:false))));
$builder->add('niveau01other',
TextType::class, array(
"label" =>"Autre ".$session->get('labelniveau01'),
"disabled" => ($options["mode"]=="delete"?true:false),
"required" => false,
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px")
)
);
# Password # Password
if($options["mode"]!="delete"&&$options["mode"]!="send") { if($options["mode"]!="delete"&&$options["mode"]!="send") {
$builder->add('password', $builder->add('password',

View File

@ -84,6 +84,7 @@ class UserType extends AbstractType
EntityType::class, EntityType::class,
array("class" => "CadolesCoreBundle:Niveau01", array("class" => "CadolesCoreBundle:Niveau01",
"label" => $session->get('labelniveau01'), "label" => $session->get('labelniveau01'),
'placeholder' => '== Choisir '.$session->get('labelniveau01').' ==',
"choice_label" => "label", "choice_label" => "label",
"query_builder"=> function (EntityRepository $er) use($access,$perm,$userid) { "query_builder"=> function (EntityRepository $er) use($access,$perm,$userid) {
if($access=="config") { if($access=="config") {
@ -102,7 +103,17 @@ class UserType extends AbstractType
}, },
"disabled" => ($options["mode"]=="delete"||$options["masteridentity"]!="SQL"?true:false), "disabled" => ($options["mode"]=="delete"||$options["masteridentity"]!="SQL"?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px","readonly" => ($options["mode"]=="delete"?true:false)))); "attr" => array("class" => "form-control", "style" => "margin-bottom:15px","readonly" => ($options["mode"]=="delete"?true:false))));
$builder->add('niveau01other',
TextType::class, array(
"label" =>"Autre ".$session->get('labelniveau01'),
"disabled" => ($options["mode"]=="delete"?true:false),
"required" => false,
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px")
)
);
if($options["mode"]!="delete"&&$options["masteridentity"]=="SQL") { if($options["mode"]!="delete"&&$options["masteridentity"]=="SQL") {
$builder->add('password', $builder->add('password',
RepeatedType::class, array( RepeatedType::class, array(

View File

@ -105,6 +105,7 @@
{% if form.job is defined %} {{ form_row(form.job) }} {% endif %} {% if form.job is defined %} {{ form_row(form.job) }} {% endif %}
{% if form.position is defined %} {{ form_row(form.position) }} {% endif %} {% if form.position is defined %} {{ form_row(form.position) }} {% endif %}
{{ form_row(form.niveau01) }} {{ form_row(form.niveau01) }}
<div id="niveau01other">{{ form_row(form.niveau01other) }}</div>
{% if form.niveau02 is defined %} {{ form_row(form.niveau02) }} {% endif %} {% if form.niveau02 is defined %} {{ form_row(form.niveau02) }} {% endif %}
</div> </div>
</div> </div>
@ -164,6 +165,10 @@
hideshow(); hideshow();
}); });
$(document.body).on("change","#registration_niveau01",function(){
hideshow();
});
$(document.body).on("change","#registration_niveau02",function(){ $(document.body).on("change","#registration_niveau02",function(){
$.ajax({ $.ajax({
method: "POST", method: "POST",
@ -188,6 +193,15 @@
$("#blockcity").hide(); $("#blockcity").hide();
$("#registration_birthplace").val([]).trigger('change'); $("#registration_birthplace").val([]).trigger('change');
} }
niveau01=$("#registration_niveau01 option:selected").text().toLowerCase();
if(niveau01.startsWith("autre")) {
$("#niveau01other").show();
}
else {
$("#registration_niveau01other").val("");
$("#niveau01other").hide();
}
} }
$(document).ready(function() { $(document).ready(function() {

View File

@ -27,7 +27,7 @@
<div class='alert alert-danger' style='margin: 5px 0px'> <div class='alert alert-danger' style='margin: 5px 0px'>
<strong>Erreur</strong><br> <strong>Erreur</strong><br>
{% for flashMessage in app.session.flashbag.get('error') %} {% for flashMessage in app.session.flashbag.get('error') %}
{{ flashMessage }}<br> {{ flashMessage | raw }}<br>
{% endfor %} {% endfor %}
</div> </div>
<br> <br>
@ -37,7 +37,7 @@
<div class='alert alert-info' style='margin: 5px 0px'> <div class='alert alert-info' style='margin: 5px 0px'>
<strong>Information</strong><br> <strong>Information</strong><br>
{% for flashMessage in app.session.flashbag.get('notice') %} {% for flashMessage in app.session.flashbag.get('notice') %}
{{ flashMessage }}<br> {{ flashMessage | raw }}<br>
{% endfor %} {% endfor %}
</div> </div>
<br> <br>
@ -46,7 +46,7 @@
{% if info is defined and info %} {% if info is defined and info %}
<div class='alert alert-info' style='margin: 5px 0px'> <div class='alert alert-info' style='margin: 5px 0px'>
<strong>Information</strong><br> <strong>Information</strong><br>
{{ info }}<br> {{ info | raw }}<br>
</div> </div>
<br> <br>
{% endif %} {% endif %}
@ -114,6 +114,7 @@
{% if form.job is defined %}{{ form_row(form.job) }}{% endif %} {% if form.job is defined %}{{ form_row(form.job) }}{% endif %}
{% if form.position is defined %}{{ form_row(form.position) }}{% endif %} {% if form.position is defined %}{{ form_row(form.position) }}{% endif %}
{{ form_row(form.niveau01) }} {{ form_row(form.niveau01) }}
<div id="niveau01other">{{ form_row(form.niveau01other) }}</div>
{% if form.niveau02 is defined %}{{ form_row(form.niveau02) }}{% endif %} {% if form.niveau02 is defined %}{{ form_row(form.niveau02) }}{% endif %}
</div> </div>
</div> </div>
@ -418,6 +419,10 @@
hideshow(); hideshow();
}); });
$(document.body).on("change","#user_niveau01",function(){
hideshow();
});
$(document.body).on("change","#user_niveau02",function(){ $(document.body).on("change","#user_niveau02",function(){
$.ajax({ $.ajax({
method: "POST", method: "POST",
@ -449,6 +454,15 @@
else { else {
$("#panelmodos").hide(); $("#panelmodos").hide();
} }
niveau01=$("#user_niveau01 option:selected").text().toLowerCase();
if(niveau01.startsWith("autre")) {
$("#niveau01other").show();
}
else {
$("#user_niveau01other").val("");
$("#niveau01other").hide();
}
} }