gestion du niveau01 autre (ref #141)
This commit is contained in:
parent
e85f74cda5
commit
f20eff9b05
|
@ -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) {
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ class RegistrationController extends Controller
|
|||
$action,
|
||||
$data->getUsername(),
|
||||
$data->getEmail(),
|
||||
$data->getNiveau01()->getLabel(),
|
||||
$data->getNiveau01()->getLabel()."<br>".$data->getNiveau01other(),
|
||||
$data->getStatut()->getLabel(),
|
||||
(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())) {
|
||||
$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()) {
|
||||
|
|
|
@ -303,7 +303,7 @@ class UserController extends Controller
|
|||
array_push($tmp,$data->getFirstname());
|
||||
array_push($tmp,"<a href='mailto:".$data->getEmail()."'>".$data->getEmail()."</a>");
|
||||
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():""));
|
||||
array_push($tmp,$groups);
|
||||
array_push($tmp,$data->getJob());
|
||||
|
@ -1262,6 +1262,14 @@ class UserController extends Controller
|
|||
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'));
|
||||
}
|
||||
|
||||
// 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")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -123,6 +123,11 @@ class Registration implements UserInterface, \Serializable
|
|||
*/
|
||||
private $position;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=150, nullable=true)
|
||||
*/
|
||||
private $niveau01other;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="integer", length=60, nullable=true)
|
||||
*/
|
||||
|
@ -738,4 +743,28 @@ class Registration implements UserInterface, \Serializable
|
|||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,6 +173,11 @@ class User implements UserInterface, \Serializable
|
|||
*/
|
||||
private $visitecpt;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=150, nullable=true)
|
||||
*/
|
||||
private $niveau01other;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Country", inversedBy="users")
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
|
@ -1854,4 +1859,28 @@ class User implements UserInterface, \Serializable
|
|||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,10 +76,21 @@ class RegistrationType extends AbstractType
|
|||
EntityType::class,
|
||||
array("class" => "CadolesCoreBundle:Niveau01",
|
||||
"label" => $session->get('labelniveau01'),
|
||||
'placeholder' => '== Choisir '.$session->get('labelniveau01').' ==',
|
||||
"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))));
|
||||
|
||||
|
||||
$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
|
||||
if($options["mode"]!="delete"&&$options["mode"]!="send") {
|
||||
$builder->add('password',
|
||||
|
|
|
@ -84,6 +84,7 @@ class UserType extends AbstractType
|
|||
EntityType::class,
|
||||
array("class" => "CadolesCoreBundle:Niveau01",
|
||||
"label" => $session->get('labelniveau01'),
|
||||
'placeholder' => '== Choisir '.$session->get('labelniveau01').' ==',
|
||||
"choice_label" => "label",
|
||||
"query_builder"=> function (EntityRepository $er) use($access,$perm,$userid) {
|
||||
if($access=="config") {
|
||||
|
@ -103,6 +104,16 @@ class UserType extends AbstractType
|
|||
"disabled" => ($options["mode"]=="delete"||$options["masteridentity"]!="SQL"?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") {
|
||||
$builder->add('password',
|
||||
RepeatedType::class, array(
|
||||
|
|
|
@ -105,6 +105,7 @@
|
|||
{% if form.job is defined %} {{ form_row(form.job) }} {% endif %}
|
||||
{% if form.position is defined %} {{ form_row(form.position) }} {% endif %}
|
||||
{{ form_row(form.niveau01) }}
|
||||
<div id="niveau01other">{{ form_row(form.niveau01other) }}</div>
|
||||
{% if form.niveau02 is defined %} {{ form_row(form.niveau02) }} {% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -164,6 +165,10 @@
|
|||
hideshow();
|
||||
});
|
||||
|
||||
$(document.body).on("change","#registration_niveau01",function(){
|
||||
hideshow();
|
||||
});
|
||||
|
||||
$(document.body).on("change","#registration_niveau02",function(){
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
|
@ -188,6 +193,15 @@
|
|||
$("#blockcity").hide();
|
||||
$("#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() {
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
<div class='alert alert-danger' style='margin: 5px 0px'>
|
||||
<strong>Erreur</strong><br>
|
||||
{% for flashMessage in app.session.flashbag.get('error') %}
|
||||
{{ flashMessage }}<br>
|
||||
{{ flashMessage | raw }}<br>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<br>
|
||||
|
@ -37,7 +37,7 @@
|
|||
<div class='alert alert-info' style='margin: 5px 0px'>
|
||||
<strong>Information</strong><br>
|
||||
{% for flashMessage in app.session.flashbag.get('notice') %}
|
||||
{{ flashMessage }}<br>
|
||||
{{ flashMessage | raw }}<br>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<br>
|
||||
|
@ -46,7 +46,7 @@
|
|||
{% if info is defined and info %}
|
||||
<div class='alert alert-info' style='margin: 5px 0px'>
|
||||
<strong>Information</strong><br>
|
||||
{{ info }}<br>
|
||||
{{ info | raw }}<br>
|
||||
</div>
|
||||
<br>
|
||||
{% endif %}
|
||||
|
@ -114,6 +114,7 @@
|
|||
{% if form.job is defined %}{{ form_row(form.job) }}{% endif %}
|
||||
{% if form.position is defined %}{{ form_row(form.position) }}{% endif %}
|
||||
{{ form_row(form.niveau01) }}
|
||||
<div id="niveau01other">{{ form_row(form.niveau01other) }}</div>
|
||||
{% if form.niveau02 is defined %}{{ form_row(form.niveau02) }}{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -418,6 +419,10 @@
|
|||
hideshow();
|
||||
});
|
||||
|
||||
$(document.body).on("change","#user_niveau01",function(){
|
||||
hideshow();
|
||||
});
|
||||
|
||||
$(document.body).on("change","#user_niveau02",function(){
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
|
@ -449,6 +454,15 @@
|
|||
else {
|
||||
$("#panelmodos").hide();
|
||||
}
|
||||
|
||||
niveau01=$("#user_niveau01 option:selected").text().toLowerCase();
|
||||
if(niveau01.startsWith("autre")) {
|
||||
$("#niveau01other").show();
|
||||
}
|
||||
else {
|
||||
$("#user_niveau01other").val("");
|
||||
$("#niveau01other").hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue