src/Eccube/Form/Type/Admin/SearchCustomerType.php line 32

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.ec-cube.co.jp/
  8.  *
  9.  * For the full copyright and license information, please view the LICENSE
  10.  * file that was distributed with this source code.
  11.  */
  12. namespace Eccube\Form\Type\Admin;
  13. use Eccube\Common\EccubeConfig;
  14. use Eccube\Entity\Master\CustomerStatus;
  15. use Eccube\Form\Type\Master\CustomerStatusType;
  16. use Eccube\Form\Type\Master\PrefType;
  17. use Eccube\Form\Type\PriceType;
  18. use Eccube\Form\Type\Master\SexType;
  19. use Eccube\Repository\Master\CustomerStatusRepository;
  20. use Symfony\Component\Form\AbstractType;
  21. use Symfony\Component\Form\Extension\Core\Type\BirthdayType;
  22. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  23. use Symfony\Component\Form\Extension\Core\Type\DateType;
  24. use Symfony\Component\Form\Extension\Core\Type\IntegerType;
  25. use Symfony\Component\Form\Extension\Core\Type\TextType;
  26. use Symfony\Component\Form\FormBuilderInterface;
  27. use Symfony\Component\Validator\Constraints as Assert;
  28. class SearchCustomerType extends AbstractType
  29. {
  30.     /**
  31.      * @var EccubeConfig
  32.      */
  33.     protected $eccubeConfig;
  34.     /**
  35.      * @var CustomerStatusRepository
  36.      */
  37.     protected $customerStatusRepository;
  38.     /**
  39.      * SearchCustomerType constructor.
  40.      *
  41.      * @param EccubeConfig $eccubeConfig
  42.      * @param CustomerStatusRepository $customerStatusRepository
  43.      */
  44.     public function __construct(
  45.         CustomerStatusRepository $customerStatusRepository,
  46.         EccubeConfig $eccubeConfig
  47.     ) {
  48.         $this->eccubeConfig $eccubeConfig;
  49.         $this->customerStatusRepository $customerStatusRepository;
  50.     }
  51.     /**
  52.      * {@inheritdoc}
  53.      */
  54.     public function buildForm(FormBuilderInterface $builder, array $options)
  55.     {
  56.         $months range(112);
  57.         $builder
  58.             // 会員ID・メールアドレス・名前・名前(フリガナ)
  59.             ->add('multi'TextType::class, [
  60.                 'label' => 'admin.customer.multi_search_label',
  61.                 'required' => false,
  62.                 'constraints' => [
  63.                     new Assert\Length(['max' => $this->eccubeConfig['eccube_stext_len']]),
  64.                 ],
  65.             ])
  66.             ->add('customer_status'CustomerStatusType::class, [
  67.                 'label' => 'admin.customer.customer_status',
  68.                 'required' => false,
  69.                 'expanded' => true,
  70.                 'multiple' => true,
  71.                 'placeholder' => false,
  72.                 'data' => $this->customerStatusRepository->findBy([
  73.                     'id' => [
  74.                         CustomerStatus::PROVISIONAL,
  75.                         CustomerStatus::REGULAR,
  76.                     ],
  77.                 ]),
  78.             ])
  79.             ->add('sex'SexType::class, [
  80.                 'label' => 'admin.common.gender',
  81.                 'required' => false,
  82.                 'expanded' => true,
  83.                 'multiple' => true,
  84.             ])
  85.             ->add('birth_month'ChoiceType::class, [
  86.                 'label' => 'admin.customer.birth_month',
  87.                 'placeholder' => 'admin.common.select',
  88.                 'required' => false,
  89.                 'choices' => array_combine($months$months),
  90.             ])
  91.             ->add('birth_start'BirthdayType::class, [
  92.                 'label' => 'admin.common.birth_day__start',
  93.                 'required' => false,
  94.                 'input' => 'datetime',
  95.                 'widget' => 'single_text',
  96.                 'format' => 'yyyy-MM-dd',
  97.                 'placeholder' => ['year' => '----''month' => '--''day' => '--'],
  98.                 'attr' => [
  99.                     'class' => 'datetimepicker-input',
  100.                     'data-target' => '#'.$this->getBlockPrefix().'_birth_start',
  101.                     'data-toggle' => 'datetimepicker',
  102.                 ],
  103.             ])
  104.             ->add('birth_end'BirthdayType::class, [
  105.                 'label' => 'admin.common.birth_day__end',
  106.                 'required' => false,
  107.                 'input' => 'datetime',
  108.                 'widget' => 'single_text',
  109.                 'format' => 'yyyy-MM-dd',
  110.                 'placeholder' => ['year' => '----''month' => '--''day' => '--'],
  111.                 'attr' => [
  112.                     'class' => 'datetimepicker-input',
  113.                     'data-target' => '#'.$this->getBlockPrefix().'_birth_end',
  114.                     'data-toggle' => 'datetimepicker',
  115.                 ],
  116.             ])
  117.             ->add('pref'PrefType::class, [
  118.                 'label' => 'admin.common.pref',
  119.                 'required' => false,
  120.             ])
  121.             ->add('phone_number'TextType::class, [
  122.                 'label' => 'admin.common.phone_number',
  123.                 'required' => false,
  124.                 'constraints' => [
  125.                     new Assert\Regex([
  126.                         'pattern' => "/^[\d-]+$/u",
  127.                         'message' => 'form_error.graph_and_hyphen_only',
  128.                     ]),
  129.                 ],
  130.             ])
  131.             ->add('buy_product_name'TextType::class, [
  132.                 'label' => 'admin.order.purchase_product',
  133.                 'required' => false,
  134.                 'constraints' => [
  135.                     new Assert\Length(['max' => $this->eccubeConfig['eccube_stext_len']]),
  136.                 ],
  137.             ])
  138.             ->add('buy_total_start'PriceType::class, [
  139.                 'label' => 'admin.order.purchase_price__start',
  140.                 'required' => false,
  141.                 'constraints' => [
  142.                     new Assert\Length(['max' => $this->eccubeConfig['eccube_price_len']]),
  143.                 ],
  144.             ])
  145.             ->add('buy_total_end'PriceType::class, [
  146.                 'label' => 'admin.order.purchase_price__end',
  147.                 'required' => false,
  148.                 'constraints' => [
  149.                     new Assert\Length(['max' => $this->eccubeConfig['eccube_price_len']]),
  150.                 ],
  151.             ])
  152.             ->add('buy_times_start'IntegerType::class, [
  153.                 'label' => 'admin.order.purchase_count__start',
  154.                 'required' => false,
  155.                 'constraints' => [
  156.                     new Assert\Length(['max' => $this->eccubeConfig['eccube_int_len']]),
  157.                 ],
  158.             ])
  159.             ->add('buy_times_end'IntegerType::class, [
  160.                 'label' => 'admin.order.purchase_count__end',
  161.                 'required' => false,
  162.                 'constraints' => [
  163.                     new Assert\Length(['max' => $this->eccubeConfig['eccube_int_len']]),
  164.                 ],
  165.             ])
  166.             ->add('create_date_start'DateType::class, [
  167.                 'label' => 'admin.common.create_date__start',
  168.                 'required' => false,
  169.                 'input' => 'datetime',
  170.                 'widget' => 'single_text',
  171.                 'format' => 'yyyy-MM-dd',
  172.                 'placeholder' => ['year' => '----''month' => '--''day' => '--'],
  173.                 'attr' => [
  174.                     'class' => 'datetimepicker-input',
  175.                     'data-target' => '#'.$this->getBlockPrefix().'_create_date_start',
  176.                     'data-toggle' => 'datetimepicker',
  177.                 ],
  178.             ])
  179.             ->add('create_date_end'DateType::class, [
  180.                 'label' => 'admin.common.create_date__end',
  181.                 'required' => false,
  182.                 'input' => 'datetime',
  183.                 'widget' => 'single_text',
  184.                 'format' => 'yyyy-MM-dd',
  185.                 'placeholder' => ['year' => '----''month' => '--''day' => '--'],
  186.                 'attr' => [
  187.                     'class' => 'datetimepicker-input',
  188.                     'data-target' => '#'.$this->getBlockPrefix().'_create_date_end',
  189.                     'data-toggle' => 'datetimepicker',
  190.                 ],
  191.             ])
  192.             ->add('update_date_start'DateType::class, [
  193.                 'label' => 'admin.common.update_date__start',
  194.                 'required' => false,
  195.                 'input' => 'datetime',
  196.                 'widget' => 'single_text',
  197.                 'format' => 'yyyy-MM-dd',
  198.                 'placeholder' => ['year' => '----''month' => '--''day' => '--'],
  199.                 'attr' => [
  200.                     'class' => 'datetimepicker-input',
  201.                     'data-target' => '#'.$this->getBlockPrefix().'_update_date_start',
  202.                     'data-toggle' => 'datetimepicker',
  203.                 ],
  204.             ])
  205.             ->add('update_date_end'DateType::class, [
  206.                 'label' => 'admin.common.update_date__end',
  207.                 'required' => false,
  208.                 'input' => 'datetime',
  209.                 'widget' => 'single_text',
  210.                 'format' => 'yyyy-MM-dd',
  211.                 'placeholder' => ['year' => '----''month' => '--''day' => '--'],
  212.                 'attr' => [
  213.                     'class' => 'datetimepicker-input',
  214.                     'data-target' => '#'.$this->getBlockPrefix().'_update_date_end',
  215.                     'data-toggle' => 'datetimepicker',
  216.                 ],
  217.             ])
  218.             ->add('last_buy_start'DateType::class, [
  219.                 'label' => 'admin.order.last_buy_date__start',
  220.                 'required' => false,
  221.                 'input' => 'datetime',
  222.                 'widget' => 'single_text',
  223.                 'format' => 'yyyy-MM-dd',
  224.                 'placeholder' => ['year' => '----''month' => '--''day' => '--'],
  225.                 'attr' => [
  226.                     'class' => 'datetimepicker-input',
  227.                     'data-target' => '#'.$this->getBlockPrefix().'_last_buy_start',
  228.                     'data-toggle' => 'datetimepicker',
  229.                 ],
  230.             ])
  231.             ->add('last_buy_end'DateType::class, [
  232.                 'label' => 'admin.order.last_buy_date__end',
  233.                 'required' => false,
  234.                 'input' => 'datetime',
  235.                 'widget' => 'single_text',
  236.                 'format' => 'yyyy-MM-dd',
  237.                 'placeholder' => ['year' => '----''month' => '--''day' => '--'],
  238.                 'attr' => [
  239.                     'class' => 'datetimepicker-input',
  240.                     'data-target' => '#'.$this->getBlockPrefix().'_last_buy_end',
  241.                     'data-toggle' => 'datetimepicker',
  242.                 ],
  243.             ])
  244.         ;
  245.     }
  246.     /**
  247.      * {@inheritdoc}
  248.      */
  249.     public function getBlockPrefix()
  250.     {
  251.         return 'admin_search_customer';
  252.     }
  253. }