option bloqué dans la fiche user (fixes #6)

This commit is contained in:
afornerot 2019-08-19 16:02:56 +02:00
parent caf2cf21fe
commit 1516765e76
2 changed files with 76 additions and 52 deletions

View File

@ -37,22 +37,24 @@ class DatauserType extends AbstractType
if($options["mode"]=="datauser") { if($options["mode"]=="datauser") {
if($key=="birthplace") if($key=="birthplace")
$choices=array( $choices=array(
"Bloqué" => 3,
"Falcultatif" => 1, "Falcultatif" => 1,
"Caché" => 0, "Caché" => 0,
); );
else else
$choices=array( $choices=array(
"Bloqué" => 3,
"Obligatoire" => 2, "Obligatoire" => 2,
"Falcultatif" => 1, "Falcultatif" => 1,
"Caché" => 0, "Caché" => 0,
); );
} }
else { else {
$choices=array( $choices=array(
"Visible" => 1, "Visible" => 1,
"Caché" => 0, "Caché" => 0,
); );
} }
$builder->add($key, ChoiceType::class, $builder->add($key, ChoiceType::class,
array("label" => $field["label"], array("label" => $field["label"],

View File

@ -116,92 +116,108 @@ class UserType extends AbstractType
# En fonction de datauser # En fonction de datauser
if(!array_key_exists("firstname",$fields)||$fields["firstname"]["perm"]!=0) {
// acces jamais bloqué en config
if($access=="config") {
foreach($fields as $key => $field) {
if($field["perm"]==3) $fields[$key]["perm"]=1;
}
}
if(!array_key_exists("firstname",$fields)) $fields["firstname"]["perm"]==1;
if($fields["firstname"]["perm"]!=0) {
$builder->add('firstname', $builder->add('firstname',
TextType::class, [ TextType::class, [
"label" =>"Prénom", "label" =>"Prénom",
"required" => (!array_key_exists("firstname",$fields)?false:($fields["firstname"]["perm"]==2)), "required" => ($fields["firstname"]["perm"]==2),
"disabled" => ($options["mode"]=="delete"||$options["masteridentity"]!="SQL"?true:false), "disabled" => ($options["mode"]=="delete"||$options["masteridentity"]!="SQL"||$fields["firstname"]["perm"]==3?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px") "attr" => array("class" => "form-control", "style" => "margin-bottom:15px")
]); ]);
} }
if(!array_key_exists("visible",$fields)||$fields["visible"]["perm"]!=0) { if(!array_key_exists("visible",$fields)) $fields["visible"]["perm"]==2;
if($fields["visible"]["perm"]!=0) {
$choices=array("oui" => "1","non" => "0"); $choices=array("oui" => "1","non" => "0");
$builder->add("visible", $builder->add("visible",
ChoiceType::class,array( ChoiceType::class,array(
"label" =>"Visible", "label" =>"Visible",
'disabled' => ($options["mode"]=="delete"?true:false), 'disabled' => ($options["mode"]=="delete"||$fields["visible"]["perm"]==3?true:false),
"required" => (!array_key_exists("visible",$fields)?false:($fields["visible"]["perm"]==2)), "required" => ($fields["visible"]["perm"]==2),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px"), "attr" => array("class" => "form-control", "style" => "margin-bottom:15px"),
"choices" => $choices "choices" => $choices
) )
); );
} }
if(!array_key_exists("usualname",$fields)||$fields["usualname"]["perm"]!=0) { if(!array_key_exists("usualname",$fields)) $fields["usualname"]["perm"]==1;
if($fields["usualname"]["perm"]!=0) {
$builder->add('usualname', $builder->add('usualname',
TextType::class, array( TextType::class, array(
"label" => "Nom d'Usage", "label" => "Nom d'Usage",
"required" => (!array_key_exists("usualname",$fields)?false:($fields["usualname"]["perm"]==2)), "required" => ($fields["usualname"]["perm"]==2),
"disabled" => ($options["mode"]=="delete"?true:false), "disabled" => ($options["mode"]=="delete"||$fields["usualname"]["perm"]==3?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px") "attr" => array("class" => "form-control", "style" => "margin-bottom:15px")
) )
); );
} }
if(!array_key_exists("gender",$fields)||$fields["gender"]["perm"]!=0) { if(!array_key_exists("gender",$fields)) $fields["gender"]["perm"]==1;
if($fields["gender"]["perm"]!=0) {
$choices=array("" => "", "homme" => "male","femme" => "female"); $choices=array("" => "", "homme" => "male","femme" => "female");
$builder->add("gender", $builder->add("gender",
ChoiceType::class,array( ChoiceType::class,array(
"label" =>"Sexe", "label" =>"Sexe",
"required" => (!array_key_exists("gender",$fields)?false:($fields["gender"]["perm"]==2)), "required" => ($fields["gender"]["perm"]==2),
'disabled' => ($options["mode"]=="delete"?true:false), 'disabled' => ($options["mode"]=="delete"||$fields["gender"]["perm"]==3?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px"), "attr" => array("class" => "form-control", "style" => "margin-bottom:15px"),
"choices" => $choices "choices" => $choices
) )
); );
} }
if(!array_key_exists("givensname",$fields)||$fields["givensname"]["perm"]!=0) { if(!array_key_exists("givensname",$fields)) $fields["givensname"]["perm"]==1;
if($fields["givensname"]["perm"]!=0) {
$builder->add('givensname', $builder->add('givensname',
TextType::class, array( TextType::class, array(
"label" => "Autre Prénom", "label" => "Autre Prénom",
"required" => (!array_key_exists("givensname",$fields)?false:($fields["givensname"]["perm"]==2)), "required" => ($fields["givensname"]["perm"]==2),
"disabled" => ($options["mode"]=="delete"?true:false), "disabled" => ($options["mode"]=="delete"||$fields["givensname"]["perm"]==3?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px") "attr" => array("class" => "form-control", "style" => "margin-bottom:15px")
) )
); );
} }
if(!array_key_exists("telephonenumber",$fields)||$fields["telephonenumber"]["perm"]!=0) { if(!array_key_exists("telephonenumber",$fields)) $fields["telephonenumber"]["perm"]==1;
if($fields["telephonenumber"]["perm"]!=0) {
$builder->add('telephonenumber', $builder->add('telephonenumber',
TextType::class, array( TextType::class, array(
"label" => "Téléphone", "label" => "Téléphone",
"required" => (!array_key_exists("telephonenumber",$fields)?false:($fields["telephonenumber"]["perm"]==2)), "required" => ($fields["telephonenumber"]["perm"]==2),
"disabled" => ($options["mode"]=="delete"?true:false), "disabled" => ($options["mode"]=="delete"||$fields["telephonenumber"]["perm"]==3?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px") "attr" => array("class" => "form-control", "style" => "margin-bottom:15px")
) )
); );
} }
if(!array_key_exists("postaladress",$fields)||$fields["postaladress"]["perm"]!=0) { if(!array_key_exists("postaladress",$fields)) $fields["postaladress"]["perm"]==1;
if($fields["postaladress"]["perm"]!=0) {
$builder->add('postaladress', $builder->add('postaladress',
TextareaType::class, array( TextareaType::class, array(
"label" => "Adresse", "label" => "Adresse",
"required" => (!array_key_exists("postaladress",$fields)?false:($fields["postaladress"]["perm"]==2)), "required" => ($fields["postaladress"]["perm"]==2),
"disabled" => ($options["mode"]=="delete"?true:false), "disabled" => ($options["mode"]=="delete"||$fields["postaladress"]["perm"]==3?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px; height:90px") "attr" => array("class" => "form-control", "style" => "margin-bottom:15px; height:90px")
) )
); );
} }
if(!array_key_exists("birthdate",$fields)||$fields["birthdate"]["perm"]!=0) { if(!array_key_exists("birthdate",$fields)) $fields["birthdate"]["perm"]==1;
if($fields["birthdate"]["perm"]!=0) {
$builder->add('birthdate', $builder->add('birthdate',
DateType::class, array( DateType::class, array(
"label" => "Date de Naissance", "label" => "Date de Naissance",
"required" => (!array_key_exists("birthdate",$fields)?false:($fields["birthdate"]["perm"]==2)), "required" => ($fields["birthdate"]["perm"]==2),
"disabled" => ($options["mode"]=="delete"?true:false), "disabled" => ($options["mode"]=="delete"||$fields["birthdate"]["perm"]==3?true:false),
"widget" => 'single_text', "widget" => 'single_text',
"format" => "dd/MM/yyyy", "format" => "dd/MM/yyyy",
"html5" => false, "html5" => false,
@ -211,12 +227,13 @@ class UserType extends AbstractType
); );
} }
if(!array_key_exists("birthcountry",$fields)||$fields["birthcountry"]["perm"]!=0) { if(!array_key_exists("birthcountry",$fields)) $fields["birthcountry"]["perm"]==1;
if($fields["birthcountry"]["perm"]!=0) {
$builder->add('birthcountry', $builder->add('birthcountry',
Select2EntityType::class, array( Select2EntityType::class, array(
'label' => "Pays de Naissance", 'label' => "Pays de Naissance",
'disabled' => ($options["mode"]=="delete"?true:false), 'disabled' => ($options["mode"]=="delete"||$fields["birthcountry"]["perm"]==3?true:false),
"required" => (!array_key_exists("birthcountry",$fields)?false:($fields["birthcountry"]["perm"]==2)), "required" => ($fields["birthcountry"]["perm"]==2),
'multiple' => false, 'multiple' => false,
'remote_route' => 'cadoles_core_ajax_country_list', 'remote_route' => 'cadoles_core_ajax_country_list',
'class' => 'Cadoles\coreBundle\Entity\Country', 'class' => 'Cadoles\coreBundle\Entity\Country',
@ -235,11 +252,12 @@ class UserType extends AbstractType
); );
} }
if(!array_key_exists("birthplace",$fields)||($fields["birthcountry"]["perm"]!=0&&$fields["birthplace"]["perm"]!=0)) { if(!array_key_exists("birthplace",$fields)) $fields["birthplace"]["perm"]==1;
if($fields["birthcountry"]["perm"]!=0&&$fields["birthplace"]["perm"]!=0) {
$builder->add('birthplace', $builder->add('birthplace',
Select2EntityType::class, array( Select2EntityType::class, array(
'label' => "Ville de Naissance", 'label' => "Ville de Naissance",
'disabled' => ($options["mode"]=="delete"?true:false), 'disabled' => ($options["mode"]=="delete"||$fields["birthplace"]["perm"]==3?true:false),
"required" => false, "required" => false,
'multiple' => false, 'multiple' => false,
'remote_route' => 'cadoles_core_ajax_city_list', 'remote_route' => 'cadoles_core_ajax_city_list',
@ -259,37 +277,39 @@ class UserType extends AbstractType
); );
} }
if(!array_key_exists("job",$fields)||$fields["job"]["perm"]!=0) { if(!array_key_exists("job",$fields)) $fields["job"]["perm"]==1;
if($fields["job"]["perm"]!=0) {
$builder->add('job', $builder->add('job',
TextType::class, array( TextType::class, array(
"label" => "Métier", "label" => "Métier",
"required" => (!array_key_exists("job",$fields)?false:($fields["job"]["perm"]==2)), "required" => ($fields["job"]["perm"]==2),
"disabled" => ($options["mode"]=="delete"?true:false), "disabled" => ($options["mode"]=="delete"||$fields["job"]["perm"]==3?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px") "attr" => array("class" => "form-control", "style" => "margin-bottom:15px")
) )
); );
} }
if(!array_key_exists("position",$fields)) $fields["position"]["perm"]==1;
if(!array_key_exists("position",$fields)||$fields["position"]["perm"]!=0) { if($fields["position"]["perm"]!=0) {
$builder->add('position', $builder->add('position',
TextType::class, array( TextType::class, array(
"label" => "Fonction", "label" => "Fonction",
"required" => (!array_key_exists("position",$fields)?false:($fields["position"]["perm"]==2)), "required" => ($fields["position"]["perm"]==2),
"disabled" => ($options["mode"]=="delete"?true:false), "disabled" => ($options["mode"]=="delete"||$fields["position"]["perm"]==3?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px") "attr" => array("class" => "form-control", "style" => "margin-bottom:15px")
) )
); );
} }
if($session->get('viewniveau02')) { if($session->get('viewniveau02')) {
if(!array_key_exists("niveau02",$fields)||$fields["niveau02"]["perm"]!=0) { if(!array_key_exists("niveau02",$fields)) $fields["niveau02"]["perm"]==1;
if($fields["niveau02"]["perm"]!=0) {
$builder->add('niveau02', $builder->add('niveau02',
Select2EntityType::class, array( Select2EntityType::class, array(
'label' => $session->get('labelniveau02'), 'label' => $session->get('labelniveau02'),
'disabled' => ($options["mode"]=="delete"?true:false), 'disabled' => ($options["mode"]=="delete"||$fields["niveau02"]["perm"]==3?true:false),
"required" => (!array_key_exists("niveau02",$fields)?false:($fields["niveau02"]["perm"]==2)), "required" => ($fields["niveau02"]["perm"]==2),
'multiple' => false, 'multiple' => false,
'remote_route' => 'cadoles_core_ajax_niveau02_list', 'remote_route' => 'cadoles_core_ajax_niveau02_list',
'class' => 'Cadoles\coreBundle\Entity\Niveau02', 'class' => 'Cadoles\coreBundle\Entity\Niveau02',
@ -311,26 +331,28 @@ class UserType extends AbstractType
} }
if($options["access"]=="config") { if($options["access"]=="config") {
if(!array_key_exists("authlevel",$fields)||$fields["authlevel"]["perm"]!=0) { if(!array_key_exists("authlevel",$fields)) $fields["authlevel"]["perm"]==2;
if($fields["authlevel"]["perm"]!=0) {
$choices=array("simple" => "simple","substantiel" => "substantiel","fort" => "fort"); $choices=array("simple" => "simple","substantiel" => "substantiel","fort" => "fort");
$builder->add("authlevel", $builder->add("authlevel",
ChoiceType::class,array( ChoiceType::class,array(
"label" =>"Niveau d'authentification", "label" =>"Niveau d'authentification",
"required" => (!array_key_exists("authlevel",$fields)?false:($fields["authlevel"]["perm"]==2)), "required" => ($fields["authlevel"]["perm"]==2),
'disabled' => ($options["mode"]=="delete"?true:false), 'disabled' => ($options["mode"]=="delete"||$fields["authlevel"]["perm"]==3?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px"), "attr" => array("class" => "form-control", "style" => "margin-bottom:15px"),
"choices" => $choices "choices" => $choices
) )
); );
} }
if(!array_key_exists("belongingpopulation",$fields)||$fields["belongingpopulation"]["perm"]!=0) { if(!array_key_exists("belongingpopulation",$fields)) $fields["belongingpopulation"]["perm"]==2;
if($fields["belongingpopulation"]["perm"]!=0) {
$choices=array("agent" => "agent","prestataire" => "prestataire","partenaire" => "partenaire","stagiaire" => "stagiare"); $choices=array("agent" => "agent","prestataire" => "prestataire","partenaire" => "partenaire","stagiaire" => "stagiare");
$builder->add("belongingpopulation", $builder->add("belongingpopulation",
ChoiceType::class,array( ChoiceType::class,array(
"label" =>"Population d'appartenance", "label" =>"Population d'appartenance",
"required" => (!array_key_exists("niveau02",$fields)?false:($fields["belongingpopulation"]["perm"]==2)), "required" => ($fields["belongingpopulation"]["perm"]==2),
'disabled' => ($options["mode"]=="delete"?true:false), 'disabled' => ($options["mode"]=="delete"||$fields["belongingpopulation"]["perm"]==3?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px"), "attr" => array("class" => "form-control", "style" => "margin-bottom:15px"),
"choices" => $choices "choices" => $choices
) )