From f9df134c46716e773556bba650cc31268c54b5a5 Mon Sep 17 00:00:00 2001 From: afornerot Date: Mon, 6 Apr 2020 09:28:52 +0200 Subject: [PATCH] rendre modifiable les inscriptions (ref #113) --- .../CoreBundle/Command/data/core-init-01.sql | 2 +- .../Controller/RegistrationController.php | 12 +++++ .../CoreBundle/Form/RegistrationType.php | 47 +++++++++++-------- .../views/Registration/edit.html.twig | 1 + 4 files changed, 42 insertions(+), 20 deletions(-) diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/data/core-init-01.sql b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/data/core-init-01.sql index 24d46840..aa3b0184 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/data/core-init-01.sql +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/data/core-init-01.sql @@ -8,7 +8,7 @@ INSERT IGNORE INTO `niveau01` (`id`, `label`, `siren`) VALUES (-100, 'DRAAF', '130007107'); INSERT IGNORE INTO `user` (`id`, `niveau01_id`, `username`, `firstname`, `lastname`, `password`, `email`, `avatar`, `role`,`siren`,`authlevel`) VALUES -(-100, -100, 'admin', 'Administrateur', 'draaf', '{SSHA}sh/qcK9rVlrIFTJVhcolNLa3Ww0g4ZzK +(-100, -100, 'admin', 'Administrateur', 'draaf', '{SSHA}Ohb+BjJ5uHPUGP9Xpcl3j1woHkTgkbH0 ', 'admin@ldapbundle.ac-arno.fr', 'admin.jpg', 'ROLE_ADMIN', '130007107', 'simple'); diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/RegistrationController.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/RegistrationController.php index d630e4e4..78af1c23 100755 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/RegistrationController.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/RegistrationController.php @@ -387,6 +387,18 @@ class RegistrationController extends Controller // Sur erreur $this->getErrorForm($id,$form,$request,$data,"send"); + + // Sur validation + if ($form->get('save')->isClicked() && $form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $data = $form->getData(); + + // Sauvegarde + $em->persist($data); + $em->flush(); + + return $this->redirectToRoute('cadoles_core_config_registration'); + } // Sur validation if ($form->get('submit')->isClicked() && $form->isValid()) { diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/RegistrationType.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/RegistrationType.php index 7617f0f8..7407f8e6 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/RegistrationType.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/RegistrationType.php @@ -33,11 +33,20 @@ class RegistrationType extends AbstractType $builder->add('submit', SubmitType::class, array( - "label" => ($options["mode"]=="delete"?"Confirmer la Suppression":"Valider"), + "label" => ($options["mode"]=="delete"?"Confirmer la Suppression":"Confirmer"), "attr" => ($options["mode"]=="delete"?array("class" => "btn btn-danger"):array("class" => "btn btn-success")) ) ); + if($options["mode"]=="send") { + $builder->add('save', + SubmitType::class, array( + "label" => "Sauvegarder", + "attr" => array("class" => "btn btn-success") + ) + ); + } + # Obligatoire $builder->add('username', TextType::class, array( @@ -50,7 +59,7 @@ class RegistrationType extends AbstractType $builder->add('lastname', TextType::class, array( "label" =>"Nom de Famille", - "disabled" => ($options["mode"]=="delete"||$options["mode"]=="send"?true:false), + "disabled" => ($options["mode"]=="delete"?true:false), "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") ) ); @@ -58,7 +67,7 @@ class RegistrationType extends AbstractType $builder->add('email', EmailType::class, array( "label" =>"Mail", - "disabled" => ($options["mode"]=="delete"||$options["mode"]=="send"?true:false), + "disabled" => ($options["mode"]=="delete"?true:false), "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") ) ); @@ -68,8 +77,8 @@ class RegistrationType extends AbstractType array("class" => "CadolesCoreBundle:Niveau01", "label" => $session->get('labelniveau01'), "choice_label" => "label", - "disabled" => ($options["mode"]=="delete"||$options["mode"]=="send"?true:false), - "attr" => array("class" => "form-control", "style" => "margin-bottom:15px","readonly" => ($options["mode"]=="submit"?false:true)))); + "disabled" => ($options["mode"]=="delete"?true:false), + "attr" => array("class" => "form-control", "style" => "margin-bottom:15px","readonly" => ($options["mode"]=="delete"?true:false)))); # Password if($options["mode"]!="delete"&&$options["mode"]!="send") { @@ -98,7 +107,7 @@ class RegistrationType extends AbstractType TextType::class, array( "label" =>"Prénom", "required" => (!array_key_exists("firstname",$fields)?false:($fields["firstname"]["perm"]==2)), - "disabled" => ($options["mode"]=="delete"||$options["mode"]=="send"?true:false), + "disabled" => ($options["mode"]=="delete"?true:false), "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") ) ); @@ -110,7 +119,7 @@ class RegistrationType extends AbstractType ChoiceType::class,array( "label" =>"Visible", "required" => (!array_key_exists("visible",$fields)?false:($fields["visible"]["perm"]==2)), - 'disabled' => ($options["mode"]=="submit"?false:true), + "disabled" => ($options["mode"]=="delete"?true:false), "attr" => array("class" => "form-control", "style" => "margin-bottom:15px"), "choices" => $choices ) @@ -122,7 +131,7 @@ class RegistrationType extends AbstractType TextType::class, array( "label" => "Nom d'Usage", "required" => (!array_key_exists("usualname",$fields)?false:($fields["usualname"]["perm"]==2)), - "disabled" => ($options["mode"]=="submit"?false:true), + "disabled" => ($options["mode"]=="delete"?true:false), "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") ) ); @@ -133,7 +142,7 @@ class RegistrationType extends AbstractType TextType::class, array( "label" => "Autre Prénom", "required" => (!array_key_exists("givensname",$fields)?false:($fields["givensname"]["perm"]==2)), - "disabled" => ($options["mode"]=="submit"?false:true), + "disabled" => ($options["mode"]=="delete"?true:false), "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") ) ); @@ -144,7 +153,7 @@ class RegistrationType extends AbstractType TextType::class, array( "label" => "Téléphone", "required" => (!array_key_exists("telephonenumber",$fields)?false:($fields["telephonenumber"]["perm"]==2)), - "disabled" => ($options["mode"]=="submit"?false:true), + "disabled" => ($options["mode"]=="delete"?true:false), "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") ) ); @@ -155,7 +164,7 @@ class RegistrationType extends AbstractType TextareaType::class, array( "label" => "Adresse", "required" => (!array_key_exists("postaladress",$fields)?false:($fields["postaladress"]["perm"]==2)), - "disabled" => ($options["mode"]=="submit"?false:true), + "disabled" => ($options["mode"]=="delete"?true:false), "attr" => array("class" => "form-control", "style" => "margin-bottom:15px; height: 90px") ) ); @@ -166,7 +175,7 @@ class RegistrationType extends AbstractType DateType::class, array( "label" => "Date de Naissance", "required" => (!array_key_exists("birthdate",$fields)?false:($fields["birthdate"]["perm"]==2)), - "disabled" => ($options["mode"]=="submit"?false:true), + "disabled" => ($options["mode"]=="delete"?true:false), "widget" => 'single_text', "format" => "dd/MM/yyyy", "html5" => false, @@ -182,7 +191,7 @@ class RegistrationType extends AbstractType ChoiceType::class,array( "label" =>"Sexe", "required" => (!array_key_exists("gender",$fields)?false:($fields["gender"]["perm"]==2)), - 'disabled' => ($options["mode"]=="submit"?false:true), + "disabled" => ($options["mode"]=="delete"?true:false), "attr" => array("class" => "form-control", "style" => "margin-bottom:15px"), "choices" => $choices ) @@ -194,7 +203,7 @@ class RegistrationType extends AbstractType TextType::class, array( "label" => "Métier", "required" => (!array_key_exists("job",$fields)?false:($fields["job"]["perm"]==2)), - "disabled" => ($options["mode"]=="submit"?false:true), + "disabled" => ($options["mode"]=="delete"?true:false), "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") ) ); @@ -205,7 +214,7 @@ class RegistrationType extends AbstractType TextType::class, array( "label" => "Fonction", "required" => (!array_key_exists("position",$fields)?false:($fields["position"]["perm"]==2)), - "disabled" => ($options["mode"]=="submit"?false:true), + "disabled" => ($options["mode"]=="delete"?true:false), "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") ) ); @@ -216,7 +225,7 @@ class RegistrationType extends AbstractType $builder->add('birthcountry', Select2EntityType::class, array( 'label' => "Pays de Naissance", - 'disabled' => ($options["mode"]=="delete"?true:false), + "disabled" => ($options["mode"]=="delete"?true:false), "required" => (!array_key_exists("birthcountry",$fields)?false:($fields["birthcountry"]["perm"]==2)), 'multiple' => false, 'remote_route' => 'cadoles_core_ajax_country_list', @@ -240,8 +249,8 @@ class RegistrationType extends AbstractType $builder->add('birthplace', Select2EntityType::class, array( 'label' => "Ville de Naissance", - 'disabled' => ($options["mode"]=="delete"?true:false), - "required" => false, + "disabled" => ($options["mode"]=="delete"?true:false), + "required" => false, 'multiple' => false, 'remote_route' => 'cadoles_core_ajax_city_list', 'class' => 'Cadoles\coreBundle\Entity\City', @@ -265,7 +274,7 @@ class RegistrationType extends AbstractType $builder->add('niveau02', Select2EntityType::class, array( 'label' => $session->get('labelniveau02'), - 'disabled' => ($options["mode"]=="delete"?true:false), + "disabled" => ($options["mode"]=="delete"?true:false), "required" => (!array_key_exists("niveau02",$fields)?false:($fields["niveau02"]["perm"]==2)), 'multiple' => false, 'remote_route' => 'cadoles_core_ajax_niveau02_list', diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Registration/edit.html.twig b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Registration/edit.html.twig index 5bc9f1d4..f9fab9ca 100755 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Registration/edit.html.twig +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Registration/edit.html.twig @@ -21,6 +21,7 @@ {% endif %} {% if mode!="submit" %} + {{ form_widget(form.save) }} Annuler {% endif %}