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