src/Form/ShipmentType.php line 603

  1. <?php
  2. namespace App\Form;
  3.  
  4. use App\Entity\Shipment;
  5. use App\Entity\Country;
  6. use App\Entity\PhoneType;
  7. use App\Entity\ProductType;
  8. use App\Entity\DescribeShipment;
  9. use App\Entity\PickupShipment;
  10. use App\Entity\AddressBook;
  11. use App\Entity\Customer;
  12. use App\Entity\Courier;
  13. use App\Entity\DutyPayer;
  14. use App\Entity\PaymentOptions;
  15. use App\Entity\Services;
  16. use App\Repository\CountryRepository;
  17. use App\Repository\PhoneTypeRepository;
  18. use App\Repository\DescribeShipmentRepository;
  19. use App\Repository\PickupShipmentRepository;
  20. use App\Repository\AddressBookRepository;
  21. use App\Repository\CustomerRepository;
  22. use App\Repository\CourierRepository;
  23. use App\Repository\DutyPayerRepository;
  24. use App\Repository\PaymentOptionsRepository;
  25. use App\Repository\ServicesRepository;
  26. use App\Repository\ProductTypeRepository;
  27. use Symfony\Component\Form\AbstractType;
  28. use Symfony\Component\Form\FormBuilderInterface;
  29. use Symfony\Component\OptionsResolver\OptionsResolver;
  30. use Symfony\Component\Form\Extension\Core\Type\TextType;
  31. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  32. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  33. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  34. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  35. use Symfony\Component\Form\Extension\Core\Type\NumberType;
  36. use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
  37. use Symfony\Component\Form\Extension\Core\Type\CollectionType;
  38. use Symfony\Component\Form\Extension\Core\Type\DateType;
  39. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  40. use Symfony\Component\Security\Core\Security;
  41. use Symfony\Component\Validator\Constraints\Choice;
  42. use Symfony\Component\Validator\Constraints\File;
  43. use Symfony\Component\Form\Extension\Core\Type\FileType;
  44. class ShipmentType extends AbstractType
  45. {
  46.     private $security;
  47.     public function __construct(Security $security)
  48.     {
  49.         $this->security $security;
  50.     }
  51.     public function buildForm(FormBuilderInterface $builder, array $options): void
  52.     {
  53.         $builder
  54.             ->add('fromAddressBook'EntityType::class, [
  55.                 // looks for choices from this entity
  56.                 'class' => AddressBook::class,
  57.                 'query_builder' => function (AddressBookRepository $er) { 
  58.                     if($this->security->getUser() === null)
  59.                     {
  60.                         return $er->createQueryBuilder('v')                       
  61.                                 ->orderBy('v.name''ASC');
  62.                     }                   
  63.                     else if(!in_array('ROLE_CUSTOMER'$this->security->getUser()->getRoles()))
  64.                     {
  65.                         return $er->createQueryBuilder('v')                       
  66.                                 ->orderBy('v.name''ASC');
  67.                     }
  68.                     else
  69.                     {
  70.                         return $er->createQueryBuilder('v'
  71.                                 ->innerJoin('v.createdBy''u')
  72.                                 ->Where('u.customer = '.$this->security->getUser()->getCustomer()->getId())                        
  73.                                 ->orderBy('v.name''ASC');
  74.                     }
  75.                     
  76.                 },              
  77.                 // uses the User.username property as the visible option string
  78.                 'choice_label'=> function ($addressBook) {
  79.                     return $addressBook->getName(). ', ' .$addressBook->getCompany() . ', ' $addressBook->getCountry()->getName().', '.$addressBook->getAddress().', '.$addressBook->getAddressTwo().', '.$addressBook->getPostalCode().', '.$addressBook->getCity();
  80.                 },
  81.                 'placeholder' => 'Select a Address Book...',
  82.                 'attr' => [
  83.                     'class' => 'form-control select-tags',
  84.                     'style' => 'width:100%;',
  85.                     ],
  86.                 'label' => 'From Address Book',
  87.                 'required' => false,  
  88.                 // used to render a select box, check boxes or radios
  89.                 // 'multiple' => true,
  90.                 // 'expanded' => true,
  91.                 ])
  92.             ->add('fromName',TextType::class, [       
  93.                 'attr' => ['autofocus' => true,
  94.                 'class' => 'form-control'
  95.                 ],   
  96.                 'label' => 'Name',             
  97.             ])
  98.             ->add('fromCompany'TextType::class, [       
  99.                 'attr' => ['class' => 'form-control'], 
  100.                 'label' => 'Company',                             
  101.             ])                
  102.             ->add('fromCountry'EntityType::class, [
  103.                 // looks for choices from this entity
  104.                 'class' => Country::class,
  105.                 'query_builder' => function (CountryRepository $er) {
  106.                     return $er->createQueryBuilder('v')                       
  107.                         ->orderBy('v.name''ASC');
  108.                 },
  109.                 // uses the User.username property as the visible option string
  110.                 'choice_label' => 'name',
  111.                 'placeholder' => 'Select a Country...',
  112.                 'attr' => [
  113.                     'class' => 'form-control',
  114.                     'style' => 'width:100%;',
  115.                     ],   
  116.                 'label' => 'Country',             
  117.                 // used to render a select box, check boxes or radios
  118.                 // 'multiple' => true,
  119.                 // 'expanded' => true,
  120.                 ])
  121.             ->add('fromAddress',TextType::class, [       
  122.                 'attr' => ['class' => 'form-control'],
  123.                 'label' => 'Address'
  124.             ])
  125.             ->add('fromAddressTwo',TextType::class, [  
  126.                 'required' => false,     
  127.                 'attr' => ['class' => 'form-control'],
  128.                 'label' => 'Address 2',
  129.             ])    
  130.             ->add('fromAddressThree',TextType::class, [  
  131.                 'required' => false,     
  132.                 'attr' => ['class' => 'form-control'],
  133.                 'label' => 'Address 3',
  134.             ])    
  135.             ->add('fromPostalCode',TextType::class, [                    
  136.                 'attr' => ['class' => 'form-control'],   
  137.                 'label' => 'Postal Code',     
  138.             ])  
  139.             ->add('fromCity',TextType::class, [       
  140.                 'attr' => ['class' => 'form-control'], 
  141.                 'label' => 'City',               
  142.             ])
  143.             ->add('fromState',TextType::class, [  
  144.                 'required' => false,     
  145.                 'attr' => ['class' => 'form-control'],
  146.                 'label' => 'State',
  147.             ])
  148.             ->add('fromEmail',EmailType::class, [   
  149.                 'label' => 'Email' ,                 
  150.                 'attr' => ['class' => 'form-control'],
  151.                 'required' => false,   
  152.             ])
  153.             // ->add('fromPhoneType', EntityType::class, [
  154.             //     // looks for choices from this entity
  155.             //     'class' => PhoneType::class,
  156.             //     'query_builder' => function (PhoneTypeRepository $er) {
  157.             //         return $er->createQueryBuilder('v')                       
  158.             //             ->orderBy('v.name', 'ASC');
  159.             //     },
  160.             //     // uses the User.username property as the visible option string
  161.             //     'choice_label' => 'name',              
  162.             //     'attr' => [
  163.             //         'class' => 'form-control',
  164.             //         ],   
  165.             //     'label' => 'Phone Type',                  
  166.             //     // used to render a select box, check boxes or radios
  167.             //     // 'multiple' => true,
  168.             //     // 'expanded' => true,
  169.             //     ])
  170.             // ->add('fromPhoneCode',TextType::class, [   
  171.             //     'label' => 'Code' ,                
  172.             //     'attr' => ['class' => 'form-control'],
  173.             //     ])
  174.             // ->add('fromPhone',TextType::class, [                       
  175.             //     'attr' => ['class' => 'form-control'],
  176.             //     'label' => 'Phone No',
  177.             //     ]) 
  178.             
  179.             ->add('fromEori'ChoiceType::class, [                           
  180.                 'choices'  => [
  181.                     'EORI' => 'EORI'
  182.                     'GSTN' => 'GSTN',                           
  183.                 ],
  184.                 'attr' => ['class' => 'form-control'],   
  185.                 'label' => 'From Type',
  186.                 // 'expanded' => true,
  187.                 // 'multiple' => false,                
  188.                 ])   
  189.             ->add('fromEroino',TextType::class, [  
  190.                 'required' => false
  191.                 'label' => 'Number' ,   
  192.                 'attr' => ['class' => 'form-control'],
  193.             ])    
  194.             ->add('fromVatTax',TextType::class, [  
  195.                     'required' => false
  196.                     'label' => 'VAT/Tax Id' ,   
  197.                     'attr' => ['class' => 'form-control'],
  198.                 ])
  199.             ->add('toAddressBook'EntityType::class, [
  200.                 // looks for choices from this entity
  201.                 'class' => AddressBook::class,
  202.                 'query_builder' => function (AddressBookRepository $er) {
  203.                     if($this->security->getUser() === null)
  204.                     {
  205.                         return $er->createQueryBuilder('v')                       
  206.                             ->orderBy('v.name''ASC');
  207.                     }
  208.                     if(!in_array('ROLE_CUSTOMER'$this->security->getUser()->getRoles()))
  209.                     {
  210.                         return $er->createQueryBuilder('v')                       
  211.                                 ->orderBy('v.name''ASC');
  212.                     }
  213.                     else
  214.                     {
  215.                         return $er->createQueryBuilder('v'
  216.                                 ->innerJoin('v.createdBy''u')
  217.                                 ->Where('u.customer = '.$this->security->getUser()->getCustomer()->getId())                        
  218.                                 ->orderBy('v.name''ASC');
  219.                     }
  220.                 },              
  221.                 // uses the User.username property as the visible option string
  222.                 'choice_label'=> function ($addressBook) {
  223.                     return $addressBook->getName(). ', ' .$addressBook->getCompany() . ', ' $addressBook->getCountry()->getName().', '.$addressBook->getAddress().', '.$addressBook->getAddressTwo().', '.$addressBook->getPostalCode().', '.$addressBook->getCity();
  224.                 },
  225.                 'placeholder' => 'Select a Address Book...',
  226.                 'attr' => [
  227.                     'class' => 'form-control select-tags',
  228.                     'style' => 'width:100%;',
  229.                     ],
  230.                 'label' => 'To Address Book',
  231.                 'required' => false,  
  232.                 // used to render a select box, check boxes or radios
  233.                 // 'multiple' => true,
  234.                 // 'expanded' => true,
  235.                 ])           
  236.             ->add('toName',TextType::class, [       
  237.                 'attr' => ['autofocus' => true,
  238.                 'class' => 'form-control'
  239.                 ], 
  240.                 'label' => 'Name',                
  241.             ])
  242.             ->add('toCompany',TextType::class, [       
  243.                 'attr' => ['class' => 'form-control'],  
  244.                 'label' => 'Company',                             
  245.             ])                
  246.             ->add('toCountry'EntityType::class, [
  247.                 // looks for choices from this entity
  248.                 'class' => Country::class,
  249.                 'query_builder' => function (CountryRepository $er) {
  250.                     return $er->createQueryBuilder('v')                       
  251.                         ->orderBy('v.name''ASC');
  252.                 },
  253.                 // uses the User.username property as the visible option string
  254.                 'choice_label' => 'name',
  255.                 'placeholder' => 'Select a Country...',
  256.                 'attr' => [
  257.                     'class' => 'form-control',
  258.                     'style' => 'width:100%;',
  259.                     ],       
  260.                 'label' => 'Country',          
  261.                 // used to render a select box, check boxes or radios
  262.                 // 'multiple' => true,
  263.                 // 'expanded' => true,
  264.                 ])
  265.             ->add('toAddress',TextType::class, [       
  266.                 'attr' => ['class' => 'form-control'],
  267.                 'label' => 'Address',
  268.             ])
  269.             ->add('toAddressTwo',TextType::class, [  
  270.                 'required' => false,     
  271.                 'attr' => ['class' => 'form-control'],
  272.                 'label' => 'Address 2',
  273.             ])    
  274.             ->add('toAddressThree',TextType::class, [  
  275.                 'required' => false,     
  276.                 'attr' => ['class' => 'form-control'],
  277.                 'label' => 'Address 3',
  278.             ])    
  279.             ->add('toPostalCode',TextType::class, [                    
  280.                 'attr' => ['class' => 'form-control'], 
  281.                 'label' => 'Postal Code',      
  282.             ])  
  283.             ->add('toCity',TextType::class, [       
  284.                 'attr' => ['class' => 'form-control'], 
  285.                 'label' => 'City',                 
  286.             ])
  287.             ->add('toState',TextType::class, [  
  288.                 'required' => false,     
  289.                 'attr' => ['class' => 'form-control'],
  290.                 'label' => 'State',  
  291.             ])
  292.             ->add('toEmail',EmailType::class, [   
  293.                 'label' => 'Email' ,                 
  294.                 'attr' => ['class' => 'form-control'],
  295.                 'required' => false,   
  296.             ])
  297.             // ->add('toPhoneType', EntityType::class, [
  298.             //     // looks for choices from this entity
  299.             //     'class' => PhoneType::class,
  300.             //     'query_builder' => function (PhoneTypeRepository $er) {
  301.             //         return $er->createQueryBuilder('v')                       
  302.             //             ->orderBy('v.name', 'ASC');
  303.             //     },
  304.             //     // uses the User.username property as the visible option string
  305.             //     'choice_label' => 'name',               
  306.             //     'attr' => [
  307.             //         'class' => 'form-control',
  308.             //         ],        
  309.             //     'label' => 'Phone Type',          
  310.             //     // used to render a select box, check boxes or radios
  311.             //     // 'multiple' => true,
  312.             //     // 'expanded' => true,
  313.             //     ])
  314.             // ->add('toPhoneCode',TextType::class, [   
  315.             //     'label' => 'Code' ,                
  316.             //     'attr' => ['class' => 'form-control'],
  317.             //     'label' => 'Phone Code',  
  318.             //     ])
  319.             // ->add('toPhone',TextType::class, [                       
  320.             //     'attr' => ['class' => 'form-control'],
  321.             //     'label' => 'Phone No',  
  322.             //     ])  
  323.             ->add('toEori'ChoiceType::class, [                           
  324.                 'choices'  => [
  325.                     'EORI' => 'EORI'
  326.                     'GSTN' => 'GSTN',                           
  327.                 ],
  328.                 'attr' => ['class' => 'form-control'],   
  329.                 'label' => 'To Type',
  330.                 // 'expanded' => true,
  331.                 // 'multiple' => false,                
  332.                 ])   
  333.             ->add('toEorino',TextType::class, [  
  334.                 'required' => false
  335.                 'label' => 'Number' ,   
  336.                 'attr' => ['class' => 'form-control'],
  337.             ])             
  338.             ->add('toVatTax',TextType::class, [  
  339.                     'required' => false
  340.                     'label' => 'VAT/Tax Id' ,   
  341.                     'attr' => ['class' => 'form-control'],
  342.                 ])
  343.             ->add('saveFromAb'CheckboxType::class, [                
  344.                 'label' => 'Save this data in the Address Book for future use.',
  345.                 'required' => false,
  346.             ]) 
  347.             ->add('saveToAb'CheckboxType::class, [               
  348.                 'label' => 'Save this data in the Address Book for future use.',
  349.                 'required' => false,
  350.             ])
  351.             ->add('shipmentDate'DateType::class, [
  352.                 'attr' => ['class' => 'form-control',
  353.                 'style' => 'line-height:20px;'],
  354.                 'widget' => 'single_text',
  355.                 'empty_data' => null,
  356.                 'label' => 'Shipment Date',                               
  357.                 ])
  358.             ->add('mawbNo'TextType::class, [
  359.                 'attr' => ['class' => 'form-control',              
  360.                     ], 
  361.                 'label' => 'Mawb No',                                                    
  362.                 ])
  363.             ->add('hawbNo'TextType::class, [
  364.                     'attr' => ['class' => 'form-control',              
  365.                         ], 
  366.                     'label' => 'Hawb No'
  367.                     'required' => false,                        
  368.                 ])
  369.             ->add('manualHawb'CheckboxType::class, [                
  370.                 'label' => 'Manual Hawb',
  371.                 'required' => false,
  372.             ]) 
  373.             ->add('courier'EntityType::class, [
  374.                 // looks for choices from this entity
  375.                 'class' => Courier::class,
  376.                 'query_builder' => function (CourierRepository $er) {
  377.                     if($this->security->getUser() === null)
  378.                     {
  379.                         return $er->createQueryBuilder('v'
  380.                             ->where('v.userCompany = 1')                      
  381.                             ->orderBy('v.name''ASC');
  382.                     }
  383.                     else
  384.                     {
  385.                         return $er->createQueryBuilder('v'
  386.                             ->where('v.userCompany = '.$this->security->getUser()->getUserCompany()->getId())                      
  387.                             ->orderBy('v.name''ASC');
  388.                     }
  389.                 },                
  390.                 // uses the User.username property as the visible option string
  391.                 'choice_label' => 'name',
  392.                 'placeholder' => 'Select a Courier...',
  393.                 'attr' => [
  394.                     'class' => 'form-control select-tags',
  395.                     'style' => 'width:100%;',
  396.                     ],
  397.                 'label' => 'Services Through',
  398.                 'required' => false
  399.                 // used to render a select box, check boxes or radios
  400.                 // 'multiple' => true,
  401.                 // 'expanded' => true,
  402.                 ])
  403.             ->add('courierHawbno'TextType::class, [
  404.                 'attr' => ['class' => 'form-control',              
  405.                     ], 
  406.                 'label' => 'Courier Hawb No'
  407.                 'required' => false,                        
  408.              ])
  409.             ->add('shipmentType'ChoiceType::class, [                           
  410.                 'choices'  => [                   
  411.                     'Export' => '1'
  412.                     'Import' => '2',               
  413.                 ],  
  414.                 'constraints' => [
  415.                     new Choice([
  416.                         'choices' => ['1''2'],
  417.                         'message' => 'Please select a valid option.',
  418.                     ]),
  419.                 ],                        
  420.                 'expanded' => true,
  421.                 'multiple' => false,
  422.                 'label' => false,  
  423.                    
  424.             ])     
  425.             ->add('productType'EntityType::class, [
  426.                 'class' => ProductType::class,
  427.                 'query_builder' => function (ProductTypeRepository $er) {
  428.                     return $er->createQueryBuilder('v'
  429.                         ->where('v.type = 1')                      
  430.                         ->orderBy('v.name''ASC');
  431.                 },   
  432.                 'choice_label' => function ($ProductType) {
  433.                     return $ProductType->getName();
  434.                 },               
  435.                 'expanded' => true,
  436.                 'multiple' => false,
  437.                 'label' => false,
  438.             ])
  439.             ->add('describeShipment'EntityType::class, [
  440.                 // looks for choices from this entity
  441.                 'class' => DescribeShipment::class,
  442.                 'query_builder' => function (DescribeShipmentRepository $er) {
  443.                     return $er->createQueryBuilder('v')                       
  444.                         ->orderBy('v.name''ASC');
  445.                 },                
  446.                 // uses the User.username property as the visible option string
  447.                 'choice_label' => 'name',
  448.                 'placeholder' => 'Select a Describe Shipment...',
  449.                 'attr' => [
  450.                     'class' => 'form-control select-tags',
  451.                     'style' => 'width:100%;',
  452.                     ],
  453.                 'label' => 'What is the purpose of your shipment?',
  454.                 // used to render a select box, check boxes or radios
  455.                 // 'multiple' => true,
  456.                 // 'expanded' => true,
  457.                 ]) 
  458.             ->add('expedite'CheckboxType::class, [                
  459.                 'label' => 'Expedite / Cash Rate Applicable',
  460.                 'required' => false,
  461.             ]) 
  462.             ->add('itemSummary'TextareaType::class, [
  463.                 'attr' => ['class' => 'form-control'], 
  464.                 'label' => 'Summarize the contents of your shipment(in details)',  
  465.                 'required' => false,                                 
  466.                 ])  
  467.             ->add('customsInvoice'ChoiceType::class, [                           
  468.                 'choices'  => [                   
  469.                     'Create Invoice' => '1'
  470.                     'Use My Own Invoice' => '0',               
  471.                 ],         
  472.                 'required' => false,                
  473.                 'expanded' => true,
  474.                 'multiple' => false,
  475.                 'label' => false,                
  476.             ])   
  477.             ->add('invoiceNo',TextType::class, [                              
  478.                 'attr' => ['class' => 'form-control'],
  479.                 'required' => false,    
  480.                 ])   
  481.             ->add('additionalInvoiceInfo'TextareaType::class, [
  482.                 'attr' => ['class' => 'form-control',              
  483.                     ], 
  484.                 'label' => 'Additional Invoice Information (Remarks)',  
  485.                 'required' => false,                      
  486.                 ]) 
  487.             ->add('imagePath'FileType::class, [
  488.                 'label' => 'Invoice Documents',
  489.                 // unmapped means that this field is not associated to any entity property
  490.                 'mapped' => false,
  491.                 // make it optional so you don't have to re-upload the PDF file
  492.                 // every time you edit the Product details
  493.                 'required' => false,
  494.                 // unmapped fields can't define their validation using annotations
  495.                 // in the associated entity, so you can use the PHP constraint classes
  496.                 'constraints' => [
  497.                     new File([
  498.                         'maxSize' => '1024k',
  499.                         'mimeTypes' => [
  500.                             'image/*',
  501.                             'application/pdf',
  502.                             'application/x-pdf',
  503.                             'application/msword',
  504.                             'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  505.                             'application/vnd.ms-excel',              
  506.                             'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',  
  507.                         ],
  508.                         'mimeTypesMessage' => 'Please upload a PDF / Image / Word / Excel File',
  509.                     ])
  510.                 ],
  511.             ])
  512.             ->add('customer'EntityType::class, [
  513.                 // looks for choices from this entity
  514.                 'class' => Customer::class,
  515.                 'query_builder' => function (CustomerRepository $er) {
  516.                     if($this->security->getUser() === null)
  517.                     {
  518.                         return $er->createQueryBuilder('v')  
  519.                             ->where('v.userCompany = 1')                     
  520.                             ->orderBy('v.name''ASC');
  521.                     }
  522.                     else if(!in_array('ROLE_CUSTOMER'$this->security->getUser()->getRoles()))
  523.                     {
  524.                         return $er->createQueryBuilder('v')  
  525.                             ->where('v.userCompany = '.$this->security->getUser()->getUserCompany()->getId())                     
  526.                             ->orderBy('v.name''ASC');
  527.                     }
  528.                     else
  529.                     {
  530.                         return $er->createQueryBuilder('v')
  531.                             ->Where('v.id = '.$this->security->getUser()->getCustomer()->getId())                       
  532.                             ->orderBy('v.name''ASC');
  533.                     }
  534.                    
  535.                 },                 
  536.                 // uses the User.username property as the visible option string                
  537.                 'choice_label'=> function ($customer) {
  538.                     return $customer->getAccountNo(). ' - ' .$customer->getName() ;
  539.                 },
  540.                 'placeholder' => 'Select a Customer...',
  541.                 'attr' => [
  542.                     'class' => 'form-control select-tags',
  543.                     'style' => 'width:100%;',
  544.                     ],
  545.                 'label' => 'Who will pay the transport charge?',
  546.                 // used to render a select box, check boxes or radios
  547.                 // 'multiple' => true,
  548.                 // 'expanded' => true,
  549.                 ])    
  550.             ->add('dutyPayer'EntityType::class, [
  551.                 // looks for choices from this entity
  552.                 'class' => DutyPayer::class,
  553.                 'query_builder' => function (DutyPayerRepository $er) {
  554.                     return $er->createQueryBuilder('v')                       
  555.                         ->orderBy('v.name''ASC');
  556.                 },                
  557.                 // uses the User.username property as the visible option string
  558.                 'choice_label' => 'name',
  559.                 'placeholder' => 'Select a Payer...',
  560.                 'attr' => [
  561.                     'class' => 'form-control select-tags',
  562.                     'style' => 'width:100%;',
  563.                     ],
  564.                 'label' => 'Who will pay Duty & Tax?',
  565.                 // used to render a select box, check boxes or radios
  566.                 // 'multiple' => true,
  567.                 // 'expanded' => true,
  568.                 ])
  569.             ->add('dutyAccountno',TextType::class, [       
  570.                     'attr' => ['class' => 'form-control'],  
  571.                     'label' => 'Third Party Account No',  
  572.                     'required' => false,                             
  573.                 ])             
  574.             ->add('paymentOptions'EntityType::class, [
  575.                 // looks for choices from this entity
  576.                 'class' => PaymentOptions::class,
  577.                 'query_builder' => function (PaymentOptionsRepository $er) {
  578.                     return $er->createQueryBuilder('v')                       
  579.                         ->orderBy('v.name''ASC');
  580.                 },                
  581.                 // uses the User.username property as the visible option string
  582.                 'choice_label' => 'name',
  583.                 'placeholder' => 'Select a Options...',
  584.                 'attr' => [
  585.                     'class' => 'form-control select-tags',
  586.                     'style' => 'width:100%;',
  587.                     ],
  588.                 'label' => 'Payment Options',
  589.                 // used to render a select box, check boxes or radios
  590.                 // 'multiple' => true,
  591.                 // 'expanded' => true,
  592.                 ])   
  593.             ->add('servicese'EntityType::class, [
  594.                 // looks for choices from this entity
  595.                 'class' => Services::class,
  596.                 'query_builder' => function (ServicesRepository $er) {
  597.                     return $er->createQueryBuilder('v')                       
  598.                         ->orderBy('v.name''ASC');
  599.                 },                
  600.                 // uses the User.username property as the visible option string
  601.                 'choice_label' => 'name',
  602.                 'placeholder' => 'Select a Services...',
  603.                 'attr' => [
  604.                     'class' => 'form-control select-tags',
  605.                     'style' => 'width:100%;',
  606.                     ],
  607.                 'label' => 'Services',
  608.                 // used to render a select box, check boxes or radios
  609.                 // 'multiple' => true,
  610.                 // 'expanded' => true,
  611.                 ])               
  612.             ->add('schedulePickup'ChoiceType::class, [                           
  613.                 'choices'  => [                   
  614.                     'Yes - Schedule Pickup' => '1'
  615.                     'NO' => '0',               
  616.                 ],                          
  617.                 'expanded' => true,
  618.                 'multiple' => false,
  619.                 'label' => false,
  620.             ])  
  621.             ->add('pickupDate'DateTimeType::class, [
  622.                 'attr' => ['class' => 'form-control',
  623.                 'style' => 'line-height:20px;'],
  624.                 'widget' => 'single_text',              
  625.                 'label' => 'Pickup Date Time',   
  626.                 'required' => false,  
  627.                                     
  628.                 ])
  629.             ->add('pickupShipment'EntityType::class, [
  630.                 // looks for choices from this entity
  631.                 'class' => PickupShipment::class,
  632.                 'query_builder' => function (PickupShipmentRepository $er) {
  633.                     return $er->createQueryBuilder('v')                       
  634.                         ->orderBy('v.name''ASC');
  635.                 },                
  636.                 // uses the User.username property as the visible option string
  637.                 'choice_label' => 'name',
  638.                 'placeholder' => 'Select a Pickup Shipment...',
  639.                 'attr' => [
  640.                     'class' => 'form-control select-tags',
  641.                     'style' => 'width:100%;',
  642.                     ],
  643.                 'label' => 'Where should the courier pickup the shipment?',
  644.                 'required' => false,
  645.                 // used to render a select box, check boxes or radios
  646.                 // 'multiple' => true,
  647.                 // 'expanded' => true, 
  648.                 ])     
  649.             ->add('pickupWeight'NumberType::class, [
  650.                 'attr' => ['class' => 'form-control',              
  651.                         ],  
  652.                 'label' => 'Total Pickup Weight (KG)',      
  653.                 'required' => false,               
  654.                 ]) 
  655.             ->add('instructions'TextareaType::class, [
  656.                 'attr' => ['class' => 'form-control',              
  657.                     ], 
  658.                 'label' => 'Instructions for the Courier',  
  659.                 'required' => false,                      
  660.                 ]) 
  661.             ->add('pickupName',TextType::class, [       
  662.                 'attr' => ['autofocus' => true,
  663.                 'class' => 'form-control'
  664.                 ], 
  665.                 'label' => 'Name',   
  666.                 'required' => false,               
  667.             ])
  668.             ->add('pickupCompany',TextType::class, [       
  669.                 'attr' => ['class' => 'form-control'],  
  670.                 'label' => 'Company',  
  671.                 'required' => false,                             
  672.             ])                
  673.             ->add('pickupCountry'EntityType::class, [
  674.                 // looks for choices from this entity
  675.                 'class' => Country::class,
  676.                 'query_builder' => function (CountryRepository $er) {
  677.                     return $er->createQueryBuilder('v')                       
  678.                         ->orderBy('v.name''ASC');
  679.                 },
  680.                 // uses the User.username property as the visible option string
  681.                 'choice_label' => 'name',
  682.                 'placeholder' => 'Select a Country...',
  683.                 'attr' => [
  684.                     'class' => 'form-control',
  685.                     'style' => 'width:100%;',
  686.                     ],       
  687.                 'label' => 'Country',         
  688.                 'required' => false,   
  689.                 // used to render a select box, check boxes or radios
  690.                 // 'multiple' => true,
  691.                 // 'expanded' => true,
  692.                 ])
  693.             ->add('pickupAddress',TextType::class, [       
  694.                 'attr' => ['class' => 'form-control'],
  695.                 'label' => 'Address',
  696.                 'required' => false,  
  697.             ])
  698.             ->add('pickupAddressTwo',TextType::class, [  
  699.                 'required' => false,     
  700.                 'attr' => ['class' => 'form-control'],
  701.                 'label' => 'Address 2',
  702.             ])    
  703.             ->add('pickupAddressThree',TextType::class, [  
  704.                 'required' => false,     
  705.                 'attr' => ['class' => 'form-control'],
  706.                 'label' => 'Address 3',
  707.             ])    
  708.             ->add('pickupPostalCode',TextType::class, [                    
  709.                 'attr' => ['class' => 'form-control'], 
  710.                 'label' => 'Postal Code',      
  711.                 'required' => false,  
  712.             ])  
  713.             ->add('pickupCity',TextType::class, [       
  714.                 'attr' => ['class' => 'form-control'], 
  715.                 'label' => 'City',  
  716.                 'required' => false,                 
  717.             ])
  718.             ->add('pickupState',TextType::class, [  
  719.                 'required' => false,     
  720.                 'attr' => ['class' => 'form-control'],
  721.                 'label' => 'State',  
  722.             ])
  723.             ->add('pickupEmail',EmailType::class, [   
  724.                 'label' => 'Email' ,                 
  725.                 'attr' => ['class' => 'form-control'],
  726.                 'required' => false,  
  727.             ])
  728.             ->add('pickupPhoneType'EntityType::class, [
  729.                 // looks for choices from this entity
  730.                 'class' => PhoneType::class,
  731.                 'query_builder' => function (PhoneTypeRepository $er) {
  732.                     return $er->createQueryBuilder('v')                       
  733.                         ->orderBy('v.name''ASC');
  734.                 },
  735.                 // uses the User.username property as the visible option string
  736.                 'choice_label' => 'name',
  737.                 'placeholder' => 'Phone Type...',
  738.                 'attr' => [
  739.                     'class' => 'form-control',
  740.                     ],        
  741.                 'label' => 'Phone Type',  
  742.                 'required' => false,          
  743.                 // used to render a select box, check boxes or radios
  744.                 // 'multiple' => true,
  745.                 // 'expanded' => true,
  746.                 ])
  747.             ->add('pickupPhoneCode',TextType::class, [   
  748.                 'label' => 'Code' ,                
  749.                 'attr' => ['class' => 'form-control'],
  750.                 'label' => 'Phone Code'
  751.                 'required' => false,   
  752.                 ])
  753.             ->add('pickupPhone',TextType::class, [                       
  754.                 'attr' => ['class' => 'form-control'],
  755.                 'label' => 'Phone No',  
  756.                 'required' => false,  
  757.                 ])           
  758.             ->add('shipmentReferences'CollectionType::class, [
  759.                 'entry_type' => ShipmentReferenceType::class,
  760.                 'entry_options' => ['label' => false],
  761.                 'by_reference'=>false,
  762.                 'allow_add' => true,
  763.                 'allow_delete'=>true,
  764.                 'label' => false,
  765.             ])
  766.  
  767.             ->add('shipmentItems'CollectionType::class, [
  768.                 'entry_type' => ShipmentItemsType::class,
  769.                 'entry_options' => ['label' => false],
  770.                 'by_reference'=>false,
  771.                 'allow_add' => true,
  772.                 'allow_delete'=>true,
  773.                 'label' => false,
  774.             ])
  775.  
  776.             ->add('shipmentPackagings'CollectionType::class, [
  777.                 'entry_type' => ShipmentPackagingType::class,
  778.                 'entry_options' => ['label' => false],
  779.                 'by_reference'=>false,
  780.                 'allow_add' => true,
  781.                 'allow_delete'=>true,
  782.                 'label' => false,
  783.             ])
  784.             ->add('fromPhoneDetails'CollectionType::class, [
  785.                 'entry_type' => FromPhoneDetailsType::class,
  786.                 'entry_options' => ['label' => false],
  787.                 'by_reference'=>false,
  788.                 'allow_add' => true,
  789.                 'allow_delete'=>true,
  790.                 'label' => false,
  791.             ])
  792.             ->add('toPhoneDetails'CollectionType::class, [
  793.                 'entry_type' => ToPhoneDetailsType::class,
  794.                 'entry_options' => ['label' => false],
  795.                 'by_reference'=>false,
  796.                 'allow_add' => true,
  797.                 'allow_delete'=>true,
  798.                 'label' => false,
  799.             ])
  800.     
  801.            
  802.            
  803.         ;
  804.     }
  805.     public function configureOptions(OptionsResolver $resolver): void
  806.     {
  807.         $resolver->setDefaults([
  808.             'data_class' => Shipment::class,
  809.         ]);
  810.     }
  811. }