%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/emtnaeewxm/www/src/EEM/MagasinBundle/Form/
Upload File :
Create Path :
Current File : /home/emtnaeewxm/www/src/EEM/MagasinBundle/Form/AddLigneAchatMagasinType.php

<?php

namespace EEM\MagasinBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Doctrine\ORM\EntityRepository;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Validator\Constraints\NotBlank;

class AddLigneAchatMagasinType extends AbstractType
{
    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $type = $options['type'];
        $builder
            ->add('quantite', TextType::class, [
                'label' => "Qté",
                'required' => false,
                'attr' => [
                    'autocomplete' => 'off',
                    'placeholder' => "Qté"
                ]
            ])
            ->add('prixAchat', TextType::class, [
                "label" => "Prix achat",
                "required" => false,
                'attr' => [
                    'autocomplete' => 'off',
                    'placeholder' => 'Prix achat'],
            ])
            ->add('codeBarre', TextType::class, [
                'label' => "Code à barre",
                'required' => false,
                'attr' => [
                    'autocomplete' => 'off',
                    'placeholder' => "Code à barre"
                ],
            ])
            ->add('article', HiddenType::class, [
                'label' => "article",
                'required' => false
            ])
            ->add('qteDispo', HiddenType::class, [
                "required" => false,
            ])
            ->add('achat', HiddenType::class, [
                'label' => "achat",
                'required' => false,
            ])
            ->add('ligneAchat', HiddenType::class, [
                'label' => "ligne achat",
                'required' => false,
            ])
       ->add('select_article', EntityType::class, [
                "required" => false,
                'class' => 'EEMArticleBundle:Article',
                'query_builder' => function (EntityRepository $er)use($type) {
           if($type=='vente'){
               return $er->createQueryBuilder('f')
               ->andWhere('f.archiver is null or f.archiver = :archiv')
               ->andWhere('f.qteMagasin > 0')
               ->setParameter('archiv', false);
           }
           if($type=='achat'){
               return $er->createQueryBuilder('f')
               ->andWhere('f.archiver is null or f.archiver = :archiv')
                   ->andWhere('f.qteGros > 0')
               ->setParameter('archiv', false);
           }
                },
                'placeholder' => 'Tous',
                'label' => 'Article',
                'choice_label' => 'articleComplet'
            ]);

    }

    /**
     * {@inheritdoc}
     */
    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
            'type' => null
        ));
    }

    /**
     * {@inheritdoc}
     */
    public function getBlockPrefix()
    {
        return 'add_ligne';
    }


}

Zerion Mini Shell 1.0