]> Raphaƫl G. Git Repositories - airbundle/blobdiff - Form/SessionEditType.php
Add localizer rapsys_user routes
[airbundle] / Form / SessionEditType.php
index 24a15446c4fcfecec6e20ae6d8fe32479573ecbd..7841e70cc7eaff85c49ef4606a09f4b7f78a9636 100644 (file)
@@ -19,25 +19,25 @@ class SessionEditType extends AbstractType {
        //Doctrine instance
        private $doctrine;
 
        //Doctrine instance
        private $doctrine;
 
-       //Translator instance
-       protected $translator;
-
        /**
         * {@inheritdoc}
         */
        /**
         * {@inheritdoc}
         */
-       public function __construct(RegistryInterface $doctrine, TranslatorInterface $translator) {
+       public function __construct(RegistryInterface $doctrine) {
                $this->doctrine = $doctrine;
                $this->doctrine = $doctrine;
-               $this->translator = $translator;
        }
 
        /**
         * {@inheritdoc}
         */
        public function buildForm(FormBuilderInterface $builder, array $options) {
        }
 
        /**
         * {@inheritdoc}
         */
        public function buildForm(FormBuilderInterface $builder, array $options) {
-               //Is admin or rainfall >= 2
+               //Is admin or user with rainfall >= 2
                if (!empty($options['raincancel'])) {
                        //Add raincancel item
                        $builder->add('raincancel', SubmitType::class, ['label' => 'Rain cancel', 'attr' => ['class' => 'submit']]);
                if (!empty($options['raincancel'])) {
                        //Add raincancel item
                        $builder->add('raincancel', SubmitType::class, ['label' => 'Rain cancel', 'attr' => ['class' => 'submit']]);
+               //Is admin
+               } elseif (!empty($options['admin'])) {
+                       //Add forcecancel item
+                       $builder->add('forcecancel', SubmitType::class, ['label' => 'Force cancel', 'attr' => ['class' => 'submit']]);
                }
 
                //Is admin or owner
                }
 
                //Is admin or owner
@@ -55,13 +55,10 @@ class SessionEditType extends AbstractType {
                        $builder->add('cancel', SubmitType::class, ['label' => 'Cancel', 'attr' => ['class' => 'submit']]);
                }
 
                        $builder->add('cancel', SubmitType::class, ['label' => 'Cancel', 'attr' => ['class' => 'submit']]);
                }
 
-               //Is admin or session not finished
-               #if (!empty($options['admin']) || $options['stop'] > new \DateTime('now')) {
-
                //Is admin or senior owner
                if (!empty($options['move'])) {
                        //Load locations
                //Is admin or senior owner
                if (!empty($options['move'])) {
                        //Load locations
-                       $locations = $this->doctrine->getRepository(Location::class)->findComplementBySessionId($this->translator, $options['session']);
+                       $locations = $this->doctrine->getRepository(Location::class)->findComplementBySessionId($options['session']);
                        $builder
                                //TODO: class senior en orange ???
                                ->add('location', ChoiceType::class, ['attr' => ['placeholder' => 'Your location'], 'constraints' => [new NotBlank(['message' => 'Please provide your location'])], 'choices' => $locations, 'choice_translation_domain' => true])
                        $builder
                                //TODO: class senior en orange ???
                                ->add('location', ChoiceType::class, ['attr' => ['placeholder' => 'Your location'], 'constraints' => [new NotBlank(['message' => 'Please provide your location'])], 'choices' => $locations, 'choice_translation_domain' => true])
@@ -76,9 +73,15 @@ class SessionEditType extends AbstractType {
                        $builder
                                //TODO: class admin en rouge ???
                                ->add('user', ChoiceType::class, ['attr' => ['placeholder' => 'Your user'], 'constraints' => [new NotBlank(['message' => 'Please provide your user'])], 'choices' => $users, 'data' => $options['user'], 'choice_translation_domain' => false])
                        $builder
                                //TODO: class admin en rouge ???
                                ->add('user', ChoiceType::class, ['attr' => ['placeholder' => 'Your user'], 'constraints' => [new NotBlank(['message' => 'Please provide your user'])], 'choices' => $users, 'data' => $options['user'], 'choice_translation_domain' => false])
-                               ->add('attribute', SubmitType::class, ['label' => 'Attribute', 'attr' => ['class' => 'submit']])
-                               ->add('autoattribute', SubmitType::class, ['label' => 'Auto attribute', 'attr' => ['class' => 'submit']])
                                ->add('lock', SubmitType::class, ['label' => 'Lock', 'attr' => ['class' => 'submit']]);
                                ->add('lock', SubmitType::class, ['label' => 'Lock', 'attr' => ['class' => 'submit']]);
+
+                       //Is admin and locked === null
+                       if (!empty($options['attribute'])) {
+                               //Add attribute fields
+                               $builder
+                                       ->add('attribute', SubmitType::class, ['label' => 'Attribute', 'attr' => ['class' => 'submit']])
+                                       ->add('autoattribute', SubmitType::class, ['label' => 'Auto attribute', 'attr' => ['class' => 'submit']]);
+                       }
                }
 
                //Return form
                }
 
                //Return form
@@ -89,7 +92,7 @@ class SessionEditType extends AbstractType {
         * {@inheritdoc}
         */
        public function configureOptions(OptionsResolver $resolver) {
         * {@inheritdoc}
         */
        public function configureOptions(OptionsResolver $resolver) {
-               $resolver->setDefaults(['error_bubbling' => true, 'admin' => false, 'begin' => null, 'length' => null, 'cancel' => false, 'raincancel' => false, 'modify' => false, 'move' => false, 'user' => null, 'session' => null]);
+               $resolver->setDefaults(['error_bubbling' => true, 'admin' => false, 'begin' => null, 'length' => null, 'cancel' => false, 'raincancel' => false, 'modify' => false, 'move' => false, 'attribute' => false, 'user' => null, 'session' => null]);
                $resolver->setAllowedTypes('admin', 'boolean');
                #TODO: voir si c'est le bon type
                $resolver->setAllowedTypes('begin', 'datetime');
                $resolver->setAllowedTypes('admin', 'boolean');
                #TODO: voir si c'est le bon type
                $resolver->setAllowedTypes('begin', 'datetime');
@@ -98,6 +101,7 @@ class SessionEditType extends AbstractType {
                $resolver->setAllowedTypes('raincancel', 'boolean');
                $resolver->setAllowedTypes('modify', 'boolean');
                $resolver->setAllowedTypes('move', 'boolean');
                $resolver->setAllowedTypes('raincancel', 'boolean');
                $resolver->setAllowedTypes('modify', 'boolean');
                $resolver->setAllowedTypes('move', 'boolean');
+               $resolver->setAllowedTypes('attribute', 'boolean');
                $resolver->setAllowedTypes('user', 'integer');
                $resolver->setAllowedTypes('session', 'integer');
        }
                $resolver->setAllowedTypes('user', 'integer');
                $resolver->setAllowedTypes('session', 'integer');
        }