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,11 +37,13 @@ class DatauserType extends AbstractType
if($options["mode"]=="datauser") {
if($key=="birthplace")
$choices=array(
"Bloqué" => 3,
"Falcultatif" => 1,
"Caché" => 0,
);
else
$choices=array(
"Bloqué" => 3,
"Obligatoire" => 2,
"Falcultatif" => 1,
"Caché" => 0,

View File

@ -116,92 +116,108 @@ class UserType extends AbstractType
# 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',
TextType::class, [
"label" =>"Prénom",
"required" => (!array_key_exists("firstname",$fields)?false:($fields["firstname"]["perm"]==2)),
"disabled" => ($options["mode"]=="delete"||$options["masteridentity"]!="SQL"?true:false),
"required" => ($fields["firstname"]["perm"]==2),
"disabled" => ($options["mode"]=="delete"||$options["masteridentity"]!="SQL"||$fields["firstname"]["perm"]==3?true:false),
"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");
$builder->add("visible",
ChoiceType::class,array(
"label" =>"Visible",
'disabled' => ($options["mode"]=="delete"?true:false),
"required" => (!array_key_exists("visible",$fields)?false:($fields["visible"]["perm"]==2)),
'disabled' => ($options["mode"]=="delete"||$fields["visible"]["perm"]==3?true:false),
"required" => ($fields["visible"]["perm"]==2),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px"),
"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',
TextType::class, array(
"label" => "Nom d'Usage",
"required" => (!array_key_exists("usualname",$fields)?false:($fields["usualname"]["perm"]==2)),
"disabled" => ($options["mode"]=="delete"?true:false),
"required" => ($fields["usualname"]["perm"]==2),
"disabled" => ($options["mode"]=="delete"||$fields["usualname"]["perm"]==3?true:false),
"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");
$builder->add("gender",
ChoiceType::class,array(
"label" =>"Sexe",
"required" => (!array_key_exists("gender",$fields)?false:($fields["gender"]["perm"]==2)),
'disabled' => ($options["mode"]=="delete"?true:false),
"required" => ($fields["gender"]["perm"]==2),
'disabled' => ($options["mode"]=="delete"||$fields["gender"]["perm"]==3?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px"),
"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',
TextType::class, array(
"label" => "Autre Prénom",
"required" => (!array_key_exists("givensname",$fields)?false:($fields["givensname"]["perm"]==2)),
"disabled" => ($options["mode"]=="delete"?true:false),
"required" => ($fields["givensname"]["perm"]==2),
"disabled" => ($options["mode"]=="delete"||$fields["givensname"]["perm"]==3?true:false),
"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',
TextType::class, array(
"label" => "Téléphone",
"required" => (!array_key_exists("telephonenumber",$fields)?false:($fields["telephonenumber"]["perm"]==2)),
"disabled" => ($options["mode"]=="delete"?true:false),
"required" => ($fields["telephonenumber"]["perm"]==2),
"disabled" => ($options["mode"]=="delete"||$fields["telephonenumber"]["perm"]==3?true:false),
"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',
TextareaType::class, array(
"label" => "Adresse",
"required" => (!array_key_exists("postaladress",$fields)?false:($fields["postaladress"]["perm"]==2)),
"disabled" => ($options["mode"]=="delete"?true:false),
"required" => ($fields["postaladress"]["perm"]==2),
"disabled" => ($options["mode"]=="delete"||$fields["postaladress"]["perm"]==3?true:false),
"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',
DateType::class, array(
"label" => "Date de Naissance",
"required" => (!array_key_exists("birthdate",$fields)?false:($fields["birthdate"]["perm"]==2)),
"disabled" => ($options["mode"]=="delete"?true:false),
"required" => ($fields["birthdate"]["perm"]==2),
"disabled" => ($options["mode"]=="delete"||$fields["birthdate"]["perm"]==3?true:false),
"widget" => 'single_text',
"format" => "dd/MM/yyyy",
"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',
Select2EntityType::class, array(
'label' => "Pays de Naissance",
'disabled' => ($options["mode"]=="delete"?true:false),
"required" => (!array_key_exists("birthcountry",$fields)?false:($fields["birthcountry"]["perm"]==2)),
'disabled' => ($options["mode"]=="delete"||$fields["birthcountry"]["perm"]==3?true:false),
"required" => ($fields["birthcountry"]["perm"]==2),
'multiple' => false,
'remote_route' => 'cadoles_core_ajax_country_list',
'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',
Select2EntityType::class, array(
'label' => "Ville de Naissance",
'disabled' => ($options["mode"]=="delete"?true:false),
'disabled' => ($options["mode"]=="delete"||$fields["birthplace"]["perm"]==3?true:false),
"required" => false,
'multiple' => false,
'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',
TextType::class, array(
"label" => "Métier",
"required" => (!array_key_exists("job",$fields)?false:($fields["job"]["perm"]==2)),
"disabled" => ($options["mode"]=="delete"?true:false),
"required" => ($fields["job"]["perm"]==2),
"disabled" => ($options["mode"]=="delete"||$fields["job"]["perm"]==3?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px")
)
);
}
if(!array_key_exists("position",$fields)||$fields["position"]["perm"]!=0) {
if(!array_key_exists("position",$fields)) $fields["position"]["perm"]==1;
if($fields["position"]["perm"]!=0) {
$builder->add('position',
TextType::class, array(
"label" => "Fonction",
"required" => (!array_key_exists("position",$fields)?false:($fields["position"]["perm"]==2)),
"disabled" => ($options["mode"]=="delete"?true:false),
"required" => ($fields["position"]["perm"]==2),
"disabled" => ($options["mode"]=="delete"||$fields["position"]["perm"]==3?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px")
)
);
}
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',
Select2EntityType::class, array(
'label' => $session->get('labelniveau02'),
'disabled' => ($options["mode"]=="delete"?true:false),
"required" => (!array_key_exists("niveau02",$fields)?false:($fields["niveau02"]["perm"]==2)),
'disabled' => ($options["mode"]=="delete"||$fields["niveau02"]["perm"]==3?true:false),
"required" => ($fields["niveau02"]["perm"]==2),
'multiple' => false,
'remote_route' => 'cadoles_core_ajax_niveau02_list',
'class' => 'Cadoles\coreBundle\Entity\Niveau02',
@ -311,26 +331,28 @@ class UserType extends AbstractType
}
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");
$builder->add("authlevel",
ChoiceType::class,array(
"label" =>"Niveau d'authentification",
"required" => (!array_key_exists("authlevel",$fields)?false:($fields["authlevel"]["perm"]==2)),
'disabled' => ($options["mode"]=="delete"?true:false),
"required" => ($fields["authlevel"]["perm"]==2),
'disabled' => ($options["mode"]=="delete"||$fields["authlevel"]["perm"]==3?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px"),
"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");
$builder->add("belongingpopulation",
ChoiceType::class,array(
"label" =>"Population d'appartenance",
"required" => (!array_key_exists("niveau02",$fields)?false:($fields["belongingpopulation"]["perm"]==2)),
'disabled' => ($options["mode"]=="delete"?true:false),
"required" => ($fields["belongingpopulation"]["perm"]==2),
'disabled' => ($options["mode"]=="delete"||$fields["belongingpopulation"]["perm"]==3?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px"),
"choices" => $choices
)