- <?php
- namespace App\MDS\GreenPatioBundle\Form;
- use App\Entity\Client;
- use App\Entity\Supplier;
- use App\MDS\GreenPatioBundle\Entity\Reservation;
- use App\Repository\SupplierRepository;
- use Symfony\Component\Form\AbstractType;
- use Symfony\Component\Form\FormBuilderInterface;
- use Symfony\Component\OptionsResolver\OptionsResolver;
- use Symfony\Component\Form\Extension\Core\Type\SubmitType;
- use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
- use Symfony\Bridge\Doctrine\Form\Type\EntityType;
- use Symfony\Component\Form\Extension\Core\Type\TextType;
- use Symfony\Component\Form\Extension\Core\Type\TextareaType;
- use Symfony\Component\Form\Extension\Core\Type\IntegerType;
- use Symfony\Component\Form\Extension\Core\Type\HiddenType;
- class ReservationType extends AbstractType
- {
-     /**
-      * {@inheritdoc}
-      */
-     public function buildForm(FormBuilderInterface $builder, array $options)
-     {
-         $data = $builder->getData();            // usado para  ->add('cateringName', EntityType::class, array(
- //        $builder->addEventListener(FormEvents::PRE_SET_DATA, array($this, 'onPreSetData'));
- //        $builder->addEventListener(FormEvents::PRE_SUBMIT, array($this, 'onPreSubmit'));
-         $builder
-             ->add('title', TextType::class, array(
-                 'required' => true))
- //            ->add('createdAt')
- //            ->add('createdBy', TextType::class, array(
- //                'required' => false))
- //            ->add('supplier', TextType::class, array(
- //                'required' => false))
- //            ->add('status')
-             ->add('status', ChoiceType::class, array(
-                 'required' => false,
-                 'choices' => array(
-                     'Iniciado' => 'Iniciado',
-                     'Bloqueo' => 'Bloqueo',
-                     'Confirmado' => 'Confirmed',
-                     'Cotizado' => 'Cotizado',
-                     'Facturado' => 'Invoiced'
-                 ), 'placeholder' => 'Select a status'))
-             ->add('priority', ChoiceType::class, array(
-                 'required' => false,
-                 'choices' => array(
-                     '1' => '1',
-                     '2' => '2',
-                     '3' => '3',
-                     '4' => '4',
-                     '5' => '5',
-                     '6' => '6',
-                     '7' => '7',
-                     '8' => '8',
-                     '9' => '9',
-                     '10' => '10'
-                 ), 'placeholder' => 'Auto'))
-             ->add('client', EntityType::class, array(
-                 'required' => false,
-                 'class' => Client::class,
-                 'choice_label' => 'name',
-                 'choice_value' => 'id',
-                 'expanded' => false,
-                 'multiple' => false,
-                 'placeholder' => 'Select a Client'))
-             ->add('clientContact', HiddenType::class)
-             ->add('contactUnregistered', HiddenType::class, array(
-                 'required' => true))
-             ->add('days', HiddenType::class)
-             ->add('cateringName', EntityType::class, array(
-                 'class' => Supplier::class,
-                 'choice_label' => 'name',
-                 'choice_value' => 'id',
-                 'required' => false,
-                 'multiple' => false,
-                 'placeholder' => 'Select a Supplier',
-                 'query_builder' => function (SupplierRepository $er) use ($data) {
-                     $qb = $er->createQueryBuilder('e')
-                         ->where('e.tags like :manufacturer')
-                         ->setParameter('manufacturer', 'catering');
-                     return $qb->orderBy('e.company');
-                 }
-                 ))
-             ->add('advancePayment', IntegerType::class, array(
-                 'required' => false))
-             ->add('daysBlock', IntegerType::class, array(
-                 'data' => 7,
-                 'required' => false))
-             ->add('idProposal', IntegerType::class, array(
-                 'required' => false))
-             ->add('pax', IntegerType::class, array(
-                 'required' => false))
-             ->add('deposit', IntegerType::class, array(
-                 'required' => false))
-             ->add('description', TextareaType::class, array(
-                 'required' => false))
-             ->add('save', SubmitType::class);
-     }
-     
-     /**
-      * {@inheritdoc}
-      */
-     public function configureOptions(OptionsResolver $resolver)
-     {
-         $resolver->setDefaults(array(
-             'data_class' => Reservation::class
-         ));
-     }
-     /**
-      * {@inheritdoc}
-      */
-     public function getBlockPrefix()
-     {
-         return 'mds_greenpatiobundle_reservation';
-     }
- }
-