src/Form/ClientContactType.php line 69

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\NewsLetterControl;
  4. use App\Entity\User;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\EntityRepository;
  7. use Symfony\Component\Form\AbstractType;
  8. use Symfony\Component\Form\FormBuilderInterface;
  9. use Symfony\Component\OptionsResolver\OptionsResolver;
  10. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  11. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  12. use Symfony\Component\Form\Extension\Core\Type\TextType;
  13. use Symfony\Component\Form\Extension\Core\Type\DateType;
  14. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  15. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  16. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  17. class ClientContactType extends AbstractType
  18. {
  19.     /**
  20.      * {@inheritdoc}
  21.      */
  22.     public function buildForm(FormBuilderInterface $builder, array $options)
  23.     {
  24.         $builder
  25.             ->add('picture'HiddenType::class)
  26.             ->add('clientId'HiddenType::class)
  27.             ->add('position'TextType::class)
  28.             ->add('department'TextType::class)
  29.             ->add('name'TextType::class)
  30.             ->add('lastName'TextType::class)
  31.             ->add('email'EmailType::class)
  32.             ->add('phone'TextType::class)
  33.             ->add('mobile'TextType::class)
  34.             ->add('birthday'DateType::class, array(
  35.                 'widget' => 'single_text',
  36.                 'format' => 'yyyy-MM-dd',
  37.             ))
  38. //            ->add('assignedAgent', EntityType::class, array(
  39. //                'class' => User::class,
  40. //                'query_builder' => function(EntityRepository $userRepository) {
  41. //                    $qb =  $userRepository->createQueryBuilder('u')
  42. //                        ->andWhere('u.userrol = :rol')
  43. //                        ->setParameters(array('rol'=> 5, 'rol' => 21));
  44. //                    return $qb->orderBy('u.name', 'ASC');
  45. //                },
  46. //                'choice_label' => 'name',
  47. //                'choice_value' => 'id',
  48. //                'expanded' => false,
  49. //                'multiple' => false,
  50. //                'placeholder' => 'Select a Commercial'))
  51. //            ->add('assignedAgent', ChoiceType::class, array(
  52. //            'choice_label' => 'fullName',
  53. //            'choice_value' => 'id',
  54. //            'placeholder' => 'Select a Commercial'))
  55.             ->add('assignedAgent'EntityType::class, array(
  56.                 'required' => true,
  57.                 'choice_label' => 'fullName',
  58.                 'choice_value' => 'id',
  59. //                'multiple' => 'true',
  60. //                'mapped' => true,
  61.                 'query_builder' => function(EntityRepository $userRepository) {
  62.                     $esto = array(
  63.                         "19" => "19",
  64.                         "21" => "21",
  65.                         "5" => "5",
  66.                     );
  67.                     $qb =  $userRepository->createQueryBuilder('u')
  68. //                        ->andWhere('u.status = :myStatus')
  69.                         ->andWhere('u.status in (:status)')
  70. //                        ->setParameter('myStatus', HolidaySummaryConstants::FILTER_USER_BY_STATUS)
  71.                         ->setParameter('status'1);
  72. //                        ->setParameter('userrol', 5);
  73.                     return $qb->orderBy('u.name''ASC');
  74.                 },
  75.                 'class' => User::class,
  76.             ))
  77.             ->add('typeclient'ChoiceType::class, array(
  78.                 'choices' => array(
  79.                     'Business Travel' => 'Business Travel',
  80.                     'MICE' => 'MICE',
  81.                     'BT & MICE' => 'BT & MICE'
  82.                 ), 'placeholder' => 'Select a Type Client'))
  83.             ->add('newsletter'EntityType::class, array(
  84.                 'class' => NewsLetterControl::class,
  85.                 'choice_label' => 'name',
  86.                 'choice_value' => 'id',
  87.                 'expanded' => false,
  88.                 'multiple' => true,
  89.                 'placeholder' => 'Select a newsletter'))
  90.             ->add('situation'ChoiceType::class, array(
  91.                 'choices' => array(
  92.                     'SCOPE' => 'SCOPE',
  93.                     'TRACING' => 'TRACING',
  94.                     'PRESENTATION' => 'PRESENTATION',
  95.                     'PRESENTATION SEND' => 'PRESENTATION SEND',
  96.                     'PENDING OFFER' => 'PENDING OFFER',
  97.                     'OFFER SENT' => 'OFFER SENT',
  98.                     'PRESENTED OFFER' => 'PRESENTED OFFER',
  99.                     'OFFER DISCARDED' => 'OFFER DISCARDED',
  100.                     'OFFERED DISCARDED TRACKING' => 'OFFERED DISCARDED TRACKING',
  101.                     'CLIENT' => 'CLIENT',
  102.                     'CLIENT LOST' => 'CLIENT LOST',
  103.                 ), 'placeholder' => 'Select a situation'))
  104.             ->add('status'ChoiceType::class, array(
  105.                 'choices' => array(
  106.                     'NO CLIENT' => array(
  107.                         'NEW OPPORTUNITY' => 'NEW OPPORTUNITY',
  108.                         'FIRST CONTACT' => 'FIRST CONTACT',
  109.                         'PROPOSAL' => 'PROPOSAL',
  110.                         'NEGOTIATION' => 'NEGOTIATION',
  111.                         'WIN OPPORTUNITY' => 'WIN OPPORTUNITY',
  112.                         'LOST OPPORTUNITY' => 'LOST OPPORTUNITY',
  113.                     ),
  114.                     'CLIENT' => array(
  115.                         'FOLLOW UP' => 'FOLLOW UP',
  116.                         'INCIDENCE' => 'INCIDENCE',
  117.                         'RISK/RFP' => 'RISK/RFP',
  118.                         'CLIENT LOST' => 'CLIENT LOST'
  119.                     ),
  120.                 ), 'placeholder' => 'Select a situation'))
  121.             ->add('save'SubmitType::class)
  122.         ;
  123.     }
  124.     
  125.     /**
  126.      * {@inheritdoc}
  127.      */
  128.     public function configureOptions(OptionsResolver $resolver)
  129.     {
  130.         $resolver->setDefaults(array(
  131.             'data_class' => 'App\entity\ClientContact'
  132.         ));
  133.     }
  134.     /**
  135.      * {@inheritdoc}
  136.      */
  137.     public function getBlockPrefix()
  138.     {
  139.         return 'contact';
  140.     }
  141. }