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

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\Master\SexType;
  18. use Eccube\Form\Type\PriceType;
  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\DateTimeType;
  24. use Symfony\Component\Form\Extension\Core\Type\DateType;
  25. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  26. use Symfony\Component\Form\Extension\Core\Type\IntegerType;
  27. use Symfony\Component\Form\Extension\Core\Type\TextType;
  28. use Symfony\Component\Form\FormBuilderInterface;
  29. use Symfony\Component\Validator\Constraints as Assert;
  30. class SearchCustomerType extends AbstractType
  31. {
  32.     /**
  33.      * @var EccubeConfig
  34.      */
  35.     protected $eccubeConfig;
  36.     /**
  37.      * @var CustomerStatusRepository
  38.      */
  39.     protected $customerStatusRepository;
  40.     /**
  41.      * SearchCustomerType constructor.
  42.      *
  43.      * @param EccubeConfig $eccubeConfig
  44.      * @param CustomerStatusRepository $customerStatusRepository
  45.      */
  46.     public function __construct(
  47.         CustomerStatusRepository $customerStatusRepository,
  48.         EccubeConfig $eccubeConfig
  49.     ) {
  50.         $this->eccubeConfig $eccubeConfig;
  51.         $this->customerStatusRepository $customerStatusRepository;
  52.     }
  53.     /**
  54.      * {@inheritdoc}
  55.      */
  56.     public function buildForm(FormBuilderInterface $builder, array $options)
  57.     {
  58.         $months range(112);
  59.         $builder
  60.             // 会員ID・メールアドレス・名前・名前(フリガナ)
  61.             ->add('multi'TextType::class, [
  62.                 'label' => 'admin.customer.multi_search_label',
  63.                 'required' => false,
  64.                 'constraints' => [
  65.                     new Assert\Length(['max' => $this->eccubeConfig['eccube_stext_len']]),
  66.                 ],
  67.             ])
  68.             ->add('customer_status'CustomerStatusType::class, [
  69.                 'label' => 'admin.customer.customer_status',
  70.                 'required' => false,
  71.                 'expanded' => true,
  72.                 'multiple' => true,
  73.                 'placeholder' => false,
  74.                 'data' => $this->customerStatusRepository->findBy([
  75.                     'id' => [
  76.                         CustomerStatus::PROVISIONAL,
  77.                         CustomerStatus::REGULAR,
  78.                     ],
  79.                 ]),
  80.             ])
  81.             ->add('sex'SexType::class, [
  82.                 'label' => 'admin.common.gender',
  83.                 'required' => false,
  84.                 'expanded' => true,
  85.                 'multiple' => true,
  86.             ])
  87.             ->add('birth_month'ChoiceType::class, [
  88.                 'label' => 'admin.customer.birth_month',
  89.                 'placeholder' => 'admin.common.select',
  90.                 'required' => false,
  91.                 'choices' => array_combine($months$months),
  92.             ])
  93.             ->add('birth_start'BirthdayType::class, [
  94.                 'label' => 'admin.common.birth_day__start',
  95.                 'required' => false,
  96.                 'input' => 'datetime',
  97.                 'widget' => 'single_text',
  98.                 'placeholder' => ['year' => '----''month' => '--''day' => '--'],
  99.                 'constraints' => [
  100.                     new Assert\Range([
  101.                         'min'=> '0003-01-01',
  102.                         'minMessage' => 'form_error.out_of_range',
  103.                     ]),
  104.                 ],
  105.                 'attr' => [
  106.                     'class' => 'datetimepicker-input',
  107.                     'data-target' => '#'.$this->getBlockPrefix().'_birth_start',
  108.                     'data-toggle' => 'datetimepicker',
  109.                 ],
  110.             ])
  111.             ->add('birth_end'BirthdayType::class, [
  112.                 'label' => 'admin.common.birth_day__end',
  113.                 'required' => false,
  114.                 'input' => 'datetime',
  115.                 'widget' => 'single_text',
  116.                 'placeholder' => ['year' => '----''month' => '--''day' => '--'],
  117.                 'constraints' => [
  118.                     new Assert\Range([
  119.                         'min'=> '0003-01-01',
  120.                         'minMessage' => 'form_error.out_of_range',
  121.                     ]),
  122.                 ],
  123.                 'attr' => [
  124.                     'class' => 'datetimepicker-input',
  125.                     'data-target' => '#'.$this->getBlockPrefix().'_birth_end',
  126.                     'data-toggle' => 'datetimepicker',
  127.                 ],
  128.             ])
  129.             ->add('pref'PrefType::class, [
  130.                 'label' => 'admin.common.pref',
  131.                 'required' => false,
  132.             ])
  133.             ->add('phone_number'TextType::class, [
  134.                 'label' => 'admin.common.phone_number',
  135.                 'required' => false,
  136.                 'constraints' => [
  137.                     new Assert\Regex([
  138.                         'pattern' => "/^[\d-]+$/u",
  139.                         'message' => 'form_error.graph_and_hyphen_only',
  140.                     ]),
  141.                 ],
  142.             ])
  143.             ->add('buy_product_name'TextType::class, [
  144.                 'label' => 'admin.order.purchase_product',
  145.                 'required' => false,
  146.                 'constraints' => [
  147.                     new Assert\Length(['max' => $this->eccubeConfig['eccube_stext_len']]),
  148.                 ],
  149.             ])
  150.             ->add('buy_total_start'PriceType::class, [
  151.                 'label' => 'admin.order.purchase_price__start',
  152.                 'required' => false,
  153.                 'constraints' => [
  154.                     new Assert\Length(['max' => $this->eccubeConfig['eccube_price_len']]),
  155.                 ],
  156.             ])
  157.             ->add('buy_total_end'PriceType::class, [
  158.                 'label' => 'admin.order.purchase_price__end',
  159.                 'required' => false,
  160.                 'constraints' => [
  161.                     new Assert\Length(['max' => $this->eccubeConfig['eccube_price_len']]),
  162.                 ],
  163.             ])
  164.             ->add('buy_times_start'IntegerType::class, [
  165.                 'label' => 'admin.order.purchase_count__start',
  166.                 'required' => false,
  167.                 'constraints' => [
  168.                     new Assert\Length(['max' => $this->eccubeConfig['eccube_int_len']]),
  169.                 ],
  170.             ])
  171.             ->add('buy_times_end'IntegerType::class, [
  172.                 'label' => 'admin.order.purchase_count__end',
  173.                 'required' => false,
  174.                 'constraints' => [
  175.                     new Assert\Length(['max' => $this->eccubeConfig['eccube_int_len']]),
  176.                 ],
  177.             ])
  178.             ->add('create_date_start'DateType::class, [
  179.                 'label' => 'admin.common.create_date__start',
  180.                 'required' => false,
  181.                 'input' => 'datetime',
  182.                 'widget' => 'single_text',
  183.                 'placeholder' => ['year' => '----''month' => '--''day' => '--'],
  184.                 'constraints' => [
  185.                     new Assert\Range([
  186.                         'min'=> '0003-01-01',
  187.                         'minMessage' => 'form_error.out_of_range',
  188.                     ]),
  189.                 ],
  190.                 'attr' => [
  191.                     'class' => 'datetimepicker-input',
  192.                     'data-target' => '#'.$this->getBlockPrefix().'_create_date_start',
  193.                     'data-toggle' => 'datetimepicker',
  194.                 ],
  195.             ])
  196.             ->add('create_datetime_start'DateTimeType::class, [
  197.                 'label' => 'admin.common.create_date__start',
  198.                 'required' => false,
  199.                 'input' => 'datetime',
  200.                 'widget' => 'single_text',
  201.                 'constraints' => [
  202.                     new Assert\Range([
  203.                         'min'=> '0003-01-01',
  204.                         'minMessage' => 'form_error.out_of_range',
  205.                     ]),
  206.                 ],
  207.                 'attr' => [
  208.                     'class' => 'datetimepicker-input',
  209.                     'data-target' => '#'.$this->getBlockPrefix().'_create_datetime_start',
  210.                     'data-toggle' => 'datetimepicker',
  211.                 ],
  212.             ])
  213.             ->add('create_date_end'DateType::class, [
  214.                 'label' => 'admin.common.create_date__end',
  215.                 'required' => false,
  216.                 'input' => 'datetime',
  217.                 'widget' => 'single_text',
  218.                 'placeholder' => ['year' => '----''month' => '--''day' => '--'],
  219.                 'constraints' => [
  220.                     new Assert\Range([
  221.                         'min'=> '0003-01-01',
  222.                         'minMessage' => 'form_error.out_of_range',
  223.                     ]),
  224.                 ],
  225.                 'attr' => [
  226.                     'class' => 'datetimepicker-input',
  227.                     'data-target' => '#'.$this->getBlockPrefix().'_create_date_end',
  228.                     'data-toggle' => 'datetimepicker',
  229.                 ],
  230.             ])
  231.             ->add('create_datetime_end'DateTimeType::class, [
  232.                 'label' => 'admin.common.create_date__end',
  233.                 'required' => false,
  234.                 'input' => 'datetime',
  235.                 'widget' => 'single_text',
  236.                 'constraints' => [
  237.                     new Assert\Range([
  238.                         'min'=> '0003-01-01',
  239.                         'minMessage' => 'form_error.out_of_range',
  240.                     ]),
  241.                 ],
  242.                 'attr' => [
  243.                     'class' => 'datetimepicker-input',
  244.                     'data-target' => '#'.$this->getBlockPrefix().'_create_datetime_end',
  245.                     'data-toggle' => 'datetimepicker',
  246.                 ],
  247.             ])
  248.             ->add('update_date_start'DateType::class, [
  249.                 'label' => 'admin.common.update_date__start',
  250.                 'required' => false,
  251.                 'input' => 'datetime',
  252.                 'widget' => 'single_text',
  253.                 'placeholder' => ['year' => '----''month' => '--''day' => '--'],
  254.                 'constraints' => [
  255.                     new Assert\Range([
  256.                         'min'=> '0003-01-01',
  257.                         'minMessage' => 'form_error.out_of_range',
  258.                     ]),
  259.                 ],
  260.                 'attr' => [
  261.                     'class' => 'datetimepicker-input',
  262.                     'data-target' => '#'.$this->getBlockPrefix().'_update_date_start',
  263.                     'data-toggle' => 'datetimepicker',
  264.                 ],
  265.             ])
  266.             ->add('update_datetime_start'DateTimeType::class, [
  267.                 'label' => 'admin.common.update_date__start',
  268.                 'required' => false,
  269.                 'input' => 'datetime',
  270.                 'widget' => 'single_text',
  271.                 'constraints' => [
  272.                     new Assert\Range([
  273.                         'min'=> '0003-01-01',
  274.                         'minMessage' => 'form_error.out_of_range',
  275.                     ]),
  276.                 ],
  277.                 'attr' => [
  278.                     'class' => 'datetimepicker-input',
  279.                     'data-target' => '#'.$this->getBlockPrefix().'_update_datetime_start',
  280.                     'data-toggle' => 'datetimepicker',
  281.                 ],
  282.             ])
  283.             ->add('update_date_end'DateType::class, [
  284.                 'label' => 'admin.common.update_date__end',
  285.                 'required' => false,
  286.                 'input' => 'datetime',
  287.                 'widget' => 'single_text',
  288.                 'placeholder' => ['year' => '----''month' => '--''day' => '--'],
  289.                 'constraints' => [
  290.                     new Assert\Range([
  291.                         'min'=> '0003-01-01',
  292.                         'minMessage' => 'form_error.out_of_range',
  293.                     ]),
  294.                 ],
  295.                 'attr' => [
  296.                     'class' => 'datetimepicker-input',
  297.                     'data-target' => '#'.$this->getBlockPrefix().'_update_date_end',
  298.                     'data-toggle' => 'datetimepicker',
  299.                 ],
  300.             ])
  301.             ->add('update_datetime_end'DateTimeType::class, [
  302.                 'label' => 'admin.common.update_date__end',
  303.                 'required' => false,
  304.                 'input' => 'datetime',
  305.                 'widget' => 'single_text',
  306.                 'constraints' => [
  307.                     new Assert\Range([
  308.                         'min'=> '0003-01-01',
  309.                         'minMessage' => 'form_error.out_of_range',
  310.                     ]),
  311.                 ],
  312.                 'attr' => [
  313.                     'class' => 'datetimepicker-input',
  314.                     'data-target' => '#'.$this->getBlockPrefix().'_update_datetime_end',
  315.                     'data-toggle' => 'datetimepicker',
  316.                 ],
  317.             ])
  318.             ->add('last_buy_start'DateType::class, [
  319.                 'label' => 'admin.order.last_buy_date__start',
  320.                 'required' => false,
  321.                 'input' => 'datetime',
  322.                 'widget' => 'single_text',
  323.                 'placeholder' => ['year' => '----''month' => '--''day' => '--'],
  324.                 'constraints' => [
  325.                     new Assert\Range([
  326.                         'min'=> '0003-01-01',
  327.                         'minMessage' => 'form_error.out_of_range',
  328.                     ]),
  329.                 ],
  330.                 'attr' => [
  331.                     'class' => 'datetimepicker-input',
  332.                     'data-target' => '#'.$this->getBlockPrefix().'_last_buy_start',
  333.                     'data-toggle' => 'datetimepicker',
  334.                 ],
  335.             ])
  336.             ->add('last_buy_datetime_start'DateTimeType::class, [
  337.                 'label' => 'admin.order.last_buy_date__start',
  338.                 'required' => false,
  339.                 'input' => 'datetime',
  340.                 'widget' => 'single_text',
  341.                 'constraints' => [
  342.                     new Assert\Range([
  343.                         'min'=> '0003-01-01',
  344.                         'minMessage' => 'form_error.out_of_range',
  345.                     ]),
  346.                 ],
  347.                 'attr' => [
  348.                     'class' => 'datetimepicker-input',
  349.                     'data-target' => '#'.$this->getBlockPrefix().'_last_buy_datetime_start',
  350.                     'data-toggle' => 'datetimepicker',
  351.                 ],
  352.             ])
  353.             ->add('last_buy_end'DateType::class, [
  354.                 'label' => 'admin.order.last_buy_date__end',
  355.                 'required' => false,
  356.                 'input' => 'datetime',
  357.                 'widget' => 'single_text',
  358.                 'placeholder' => ['year' => '----''month' => '--''day' => '--'],
  359.                 'constraints' => [
  360.                     new Assert\Range([
  361.                         'min'=> '0003-01-01',
  362.                         'minMessage' => 'form_error.out_of_range',
  363.                     ]),
  364.                 ],
  365.                 'attr' => [
  366.                     'class' => 'datetimepicker-input',
  367.                     'data-target' => '#'.$this->getBlockPrefix().'_last_buy_end',
  368.                     'data-toggle' => 'datetimepicker',
  369.                 ],
  370.             ])
  371.             ->add('last_buy_datetime_end'DateTimeType::class, [
  372.                 'label' => 'admin.order.last_buy_date__end',
  373.                 'required' => false,
  374.                 'input' => 'datetime',
  375.                 'widget' => 'single_text',
  376.                 'constraints' => [
  377.                     new Assert\Range([
  378.                         'min'=> '0003-01-01',
  379.                         'minMessage' => 'form_error.out_of_range',
  380.                     ]),
  381.                 ],
  382.                 'attr' => [
  383.                     'class' => 'datetimepicker-input',
  384.                     'data-target' => '#'.$this->getBlockPrefix().'_last_buy_datetime_end',
  385.                     'data-toggle' => 'datetimepicker',
  386.                 ],
  387.             ])
  388.             // ソート用
  389.             ->add('sortkey'HiddenType::class, [
  390.                 'label' => 'admin.list.sort.key',
  391.                 'required' => false,
  392.             ])
  393.             ->add('sorttype'HiddenType::class, [
  394.                 'label' => 'admin.list.sort.type',
  395.                 'required' => false,
  396.             ])
  397.         ;
  398.     }
  399.     /**
  400.      * {@inheritdoc}
  401.      */
  402.     public function getBlockPrefix()
  403.     {
  404.         return 'admin_search_customer';
  405.     }
  406. }