app/Plugin/ClaimPdf42/Form/Type/Admin/ClaimHistoryType.php line 60

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) LOCKON CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.lockon.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 Plugin\ClaimPdf42\Form\Type\Admin;
  13. use Doctrine\ORM\EntityManagerInterface;
  14. use Eccube\Common\EccubeConfig;
  15. use Symfony\Component\Form\AbstractType;
  16. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  17. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  18. use Symfony\Component\Form\Extension\Core\Type\DateType;
  19. use Symfony\Component\Form\Extension\Core\Type\TextType;
  20. use Symfony\Component\Form\FormBuilderInterface;
  21. use Symfony\Component\Form\FormError;
  22. use Symfony\Component\Form\FormEvent;
  23. use Symfony\Component\Form\FormEvents;
  24. use Symfony\Component\Validator\Constraints as Assert;
  25. /**
  26.  * Class ClaimHistoryType.
  27.  */
  28. class ClaimHistoryType extends AbstractType
  29. {
  30.     /** @var EccubeConfig */
  31.     private $eccubeConfig;
  32.     /** @var EntityManagerInterface */
  33.     private $entityManager;
  34.     /**
  35.      * ClaimPdfType constructor.
  36.      *
  37.      * @param EccubeConfig $eccubeConfig
  38.      * @param EntityManagerInterface $entityManager
  39.      */
  40.     public function __construct(EccubeConfig $eccubeConfigEntityManagerInterface $entityManager)
  41.     {
  42.         $this->eccubeConfig $eccubeConfig;
  43.         $this->entityManager $entityManager;
  44.     }
  45.     /**
  46.      * Build config type form.
  47.      *
  48.      * @param FormBuilderInterface $builder
  49.      * @param array                $options
  50.      */
  51.     public function buildForm(FormBuilderInterface $builder, array $options)
  52.     {
  53.         dump('ClaimHistoryType');
  54.         $config $this->eccubeConfig;
  55.         $builder
  56.             ->add('issue_date'DateType::class, [
  57.                 'widget' => 'single_text',
  58.                 'input' => 'datetime',
  59.                 'required' => true,
  60.                 'placeholder' => ['year' => '----''month' => '--''day' => '--'],
  61.                 'data' => new \DateTime(),
  62.                 'constraints' => [
  63.                     new Assert\NotBlank(),
  64.                     new Assert\Range([
  65.                         'min'=> '0003-01-01',
  66.                         'minMessage' => 'form_error.out_of_range',
  67.                     ]),
  68.                 ],
  69.                 'attr' => [
  70.                     'data-target' => '#'.$this->getBlockPrefix().'_issue_date',
  71.                     'data-toggle' => 'datetimepicker',
  72.                 ],
  73.             ])
  74.             ->add('orderdatetime_st'TextType::class, [
  75.                 'required' => false,
  76.                 'mapped' => false,
  77.                 'attr' => ['readonly' => 'readonly'],
  78.             ])
  79.             ->add('orderdatetime_en'TextType::class, [
  80.                 'required' => false,
  81.                 'mapped' => false,
  82.                 'attr' => ['readonly' => 'readonly'],
  83.             ])
  84.             ->add('orderids'TextType::class, [
  85.                 'required' => false,
  86.                 'mapped' => false,
  87.                 'attr' => ['readonly' => 'readonly'],
  88.                 'constraints' => [
  89.                     new Assert\NotBlank(),
  90.                 ],
  91.             ])
  92.             ->add('ids'TextType::class, [
  93.                 'required' => false,
  94.                 'attr' => ['readonly' => 'readonly'],
  95.                 'constraints' => [
  96.                     new Assert\NotBlank(),
  97.                 ],
  98.             ])
  99.             ->add('outputkbn'ChoiceType::class, [
  100.                 'choices' => [
  101.                     'admin.order.delivery_note_outputkbn_nouhin' => $config['eccube_claim_pdf_output_kbn_nouhin'],
  102.                     'admin.order.delivery_note_outputkbn_nouhin_shipping' => $config['eccube_claim_pdf_output_kbn_nouhin_shipping'],
  103.                     'admin.order.delivery_note_outputkbn_nouhin_otodoke' => $config['eccube_claim_pdf_output_kbn_nouhin_otodoke'],
  104.                     'admin.order.delivery_note_outputkbn_seikyu' => $config['eccube_claim_pdf_output_kbn_seikyu'],
  105.                     'admin.order.delivery_note_outputkbn_seikyu_matome' => $config['eccube_claim_pdf_output_kbn_seikyu_matome'],
  106.                     'admin.order.delivery_note_outputkbn_seikyu_matome_company' => $config['eccube_claim_pdf_output_kbn_seikyu_matome_company'],
  107.                     'admin.order.delivery_note_outputkbn_ryosyu' => $config['eccube_claim_pdf_output_kbn_ryosyu'],
  108.                 ],
  109.                 'expanded' => true,
  110.                 'multiple' => false,
  111.                 'required' => false,
  112.                 'mapped' => false,
  113.                 'placeholder' => false,
  114.             ])
  115.             ->add('title'TextType::class, [
  116.                 'required' => false,
  117.                 'mapped' => false,
  118.                 'attr' => ['maxlength' => $config['eccube_stext_len']],
  119.                 'constraints' => [
  120.                     new Assert\Length(['max' => $config['eccube_stext_len']]),
  121.                 ],
  122.             ])
  123.             ->add('download_kind'ChoiceType::class, [
  124.                 'choices' => [
  125.                     'admin.order.delivery_note_output_format__file' => 1,
  126.                     'admin.order.delivery_note_output_format__browser' => 2,
  127.                 ],
  128.                 'expanded' => false,
  129.                 'multiple' => false,
  130.                 'required' => false,
  131.                 'mapped' => false,
  132.                 'placeholder' => false,
  133.             ])
  134.             // メッセージ
  135.             ->add('message1'TextType::class, [
  136.                 'required' => false,
  137.                 'mapped' => false,
  138.                 'attr' => ['maxlength' => $config['eccube_claim_pdf_message_len']],
  139.                 'constraints' => [
  140.                     new Assert\Length(['max' => $config['eccube_claim_pdf_message_len']]),
  141.                 ],
  142.                 'trim' => false,
  143.             ])
  144.             ->add('message2'TextType::class, [
  145.                 'required' => false,
  146.                 'mapped' => false,
  147.                 'attr' => ['maxlength' => $config['eccube_claim_pdf_message_len']],
  148.                 'constraints' => [
  149.                     new Assert\Length(['max' => $config['eccube_claim_pdf_message_len']]),
  150.                 ],
  151.                 'trim' => false,
  152.             ])
  153.             ->add('message3'TextType::class, [
  154.                 'required' => false,
  155.                 'mapped' => false,
  156.                 'attr' => ['maxlength' => $config['eccube_claim_pdf_message_len']],
  157.                 'constraints' => [
  158.                     new Assert\Length(['max' => $config['eccube_claim_pdf_message_len']]),
  159.                 ],
  160.                 'trim' => false,
  161.             ])
  162.             // 振込先情報要素
  163.             ->add('hurikomi_bank'TextType::class, [
  164.                 'required' => false,
  165.                 'attr' => ['maxlength' => $config['eccube_claim_pdf_message_len']],
  166.                 'constraints' => [
  167.                     new Assert\Length(['max' => $config['eccube_claim_pdf_message_len']]),
  168.                 ],
  169.                 'trim' => false,
  170.             ])
  171.             ->add('hurikomi_bank_siten'TextType::class, [
  172.                 'required' => false,
  173.                 'attr' => ['maxlength' => $config['eccube_claim_pdf_message_len']],
  174.                 'constraints' => [
  175.                     new Assert\Length(['max' => $config['eccube_claim_pdf_message_len']]),
  176.                 ],
  177.                 'trim' => false,
  178.             ])
  179.             ->add('hurikomi_bank_kouza'TextType::class, [
  180.                 'required' => false,
  181.                 'attr' => ['maxlength' => $config['eccube_claim_pdf_message_len']],
  182.                 'constraints' => [
  183.                     new Assert\Length(['max' => $config['eccube_claim_pdf_message_len']]),
  184.                 ],
  185.                 'trim' => false,
  186.             ])
  187.             ->add('hurikomi_free_area'TextType::class, [
  188.                 'required' => false,
  189.                 'attr' => ['maxlength' => $config['eccube_claim_pdf_message_len']],
  190.                 'constraints' => [
  191.                     new Assert\Length(['max' => $config['eccube_claim_pdf_message_len']]),
  192.                 ],
  193.                 'trim' => false,
  194.             ])
  195.             // 納品書[受注番号別]関連隠し要素
  196.             ->add('title_nouhin'TextType::class, [
  197.                 'required' => false,
  198.                 'attr' => ['maxlength' => $config['eccube_stext_len']],
  199.                 'constraints' => [
  200.                     new Assert\Length(['max' => $config['eccube_stext_len']]),
  201.                 ],
  202.             ])
  203.             ->add('message1_nouhin'TextType::class, [
  204.                 'required' => false,
  205.                 'attr' => ['maxlength' => $config['eccube_claim_pdf_message_len']],
  206.                 'constraints' => [
  207.                     new Assert\Length(['max' => $config['eccube_claim_pdf_message_len']]),
  208.                 ],
  209.                 'trim' => false,
  210.             ])
  211.             ->add('message2_nouhin'TextType::class, [
  212.                 'required' => false,
  213.                 'attr' => ['maxlength' => $config['eccube_claim_pdf_message_len']],
  214.                 'constraints' => [
  215.                     new Assert\Length(['max' => $config['eccube_claim_pdf_message_len']]),
  216.                 ],
  217.                 'trim' => false,
  218.             ])
  219.             ->add('message3_nouhin'TextType::class, [
  220.                 'required' => false,
  221.                 'attr' => ['maxlength' => $config['eccube_claim_pdf_message_len']],
  222.                 'constraints' => [
  223.                     new Assert\Length(['max' => $config['eccube_claim_pdf_message_len']]),
  224.                 ],
  225.                 'trim' => false,
  226.             ])
  227.             // 納品書[出荷番号別]関連隠し要素
  228.             ->add('title_nouhin_shipping'TextType::class, [
  229.                 'required' => false,
  230.                 'attr' => ['maxlength' => $config['eccube_stext_len']],
  231.                 'constraints' => [
  232.                     new Assert\Length(['max' => $config['eccube_stext_len']]),
  233.                 ],
  234.             ])
  235.             ->add('message1_nouhin_shipping'TextType::class, [
  236.                 'required' => false,
  237.                 'attr' => ['maxlength' => $config['eccube_claim_pdf_message_len']],
  238.                 'constraints' => [
  239.                     new Assert\Length(['max' => $config['eccube_claim_pdf_message_len']]),
  240.                 ],
  241.                 'trim' => false,
  242.             ])
  243.             ->add('message2_nouhin_shipping'TextType::class, [
  244.                 'required' => false,
  245.                 'attr' => ['maxlength' => $config['eccube_claim_pdf_message_len']],
  246.                 'constraints' => [
  247.                     new Assert\Length(['max' => $config['eccube_claim_pdf_message_len']]),
  248.                 ],
  249.                 'trim' => false,
  250.             ])
  251.             ->add('message3_nouhin_shipping'TextType::class, [
  252.                 'required' => false,
  253.                 'attr' => ['maxlength' => $config['eccube_claim_pdf_message_len']],
  254.                 'constraints' => [
  255.                     new Assert\Length(['max' => $config['eccube_claim_pdf_message_len']]),
  256.                 ],
  257.                 'trim' => false,
  258.             ])
  259.             // 納品書(お届け先)関連隠し要素
  260.             ->add('title_otodoke'TextType::class, [
  261.                 'required' => false,
  262.                 'attr' => ['maxlength' => $config['eccube_stext_len']],
  263.                 'constraints' => [
  264.                     new Assert\Length(['max' => $config['eccube_stext_len']]),
  265.                 ],
  266.             ])
  267.             ->add('message1_otodoke'TextType::class, [
  268.                 'required' => false,
  269.                 'attr' => ['maxlength' => $config['eccube_claim_pdf_message_len']],
  270.                 'constraints' => [
  271.                     new Assert\Length(['max' => $config['eccube_claim_pdf_message_len']]),
  272.                 ],
  273.                 'trim' => false,
  274.             ])
  275.             ->add('message2_otodoke'TextType::class, [
  276.                 'required' => false,
  277.                 'attr' => ['maxlength' => $config['eccube_claim_pdf_message_len']],
  278.                 'constraints' => [
  279.                     new Assert\Length(['max' => $config['eccube_claim_pdf_message_len']]),
  280.                 ],
  281.                 'trim' => false,
  282.             ])
  283.             ->add('message3_otodoke'TextType::class, [
  284.                 'required' => false,
  285.                 'attr' => ['maxlength' => $config['eccube_claim_pdf_message_len']],
  286.                 'constraints' => [
  287.                     new Assert\Length(['max' => $config['eccube_claim_pdf_message_len']]),
  288.                 ],
  289.                 'trim' => false,
  290.             ])
  291.             // 請求書関連隠し要素
  292.             ->add('title_seikyu'TextType::class, [
  293.                 'required' => false,
  294.                 'attr' => ['maxlength' => $config['eccube_stext_len']],
  295.                 'constraints' => [
  296.                     new Assert\Length(['max' => $config['eccube_stext_len']]),
  297.                 ],
  298.             ])
  299.             ->add('message1_seikyu'TextType::class, [
  300.                 'required' => false,
  301.                 'attr' => ['maxlength' => $config['eccube_claim_pdf_message_len']],
  302.                 'constraints' => [
  303.                     new Assert\Length(['max' => $config['eccube_claim_pdf_message_len']]),
  304.                 ],
  305.                 'trim' => false,
  306.             ])
  307.             ->add('message2_seikyu'TextType::class, [
  308.                 'required' => false,
  309.                 'attr' => ['maxlength' => $config['eccube_claim_pdf_message_len']],
  310.                 'constraints' => [
  311.                     new Assert\Length(['max' => $config['eccube_claim_pdf_message_len']]),
  312.                 ],
  313.                 'trim' => false,
  314.             ])
  315.             ->add('message3_seikyu'TextType::class, [
  316.                 'required' => false,
  317.                 'attr' => ['maxlength' => $config['eccube_claim_pdf_message_len']],
  318.                 'constraints' => [
  319.                     new Assert\Length(['max' => $config['eccube_claim_pdf_message_len']]),
  320.                 ],
  321.                 'trim' => false,
  322.             ])
  323.             // 領収書・宛名出力形式
  324.             ->add('ryosyu_atena'ChoiceType::class, [
  325.                 'choices' => [
  326.                     'admin.order.delivery_note_ryosyu_format__history_customer_name' => $config['eccube_claim_pdf_output_atena_kbn_customer_name'],
  327.                     'admin.order.delivery_note_ryosyu_format__company_name' => $config['eccube_claim_pdf_output_atena_kbn_company_name'],
  328.                     'admin.order.delivery_note_ryosyu_format__history_customer_company_name' => $config['eccube_claim_pdf_output_atena_kbn_customer_company_name'],
  329.                 ],
  330.                 'expanded' => true,
  331.                 'multiple' => false,
  332.                 'required' => true,
  333.                 'mapped' => false,
  334.                 'placeholder' => false,
  335.             ])
  336.             // 宛名 会社名@hanari
  337.             ->add('ryosyu_add_company'TextType::class, [
  338.                 'required' => false,
  339.                 'mapped' => false,
  340.             ])
  341.             // 宛名 
  342.             ->add('ryosyu_add_name'TextType::class, [
  343.                 'required' => false,
  344.                 'mapped' => false,
  345.             ])
  346.             // 備考
  347.             ->add('note1'TextType::class, [
  348.                 'required' => false,
  349.                 'attr' => ['maxlength' => $config['eccube_stext_len']],
  350.                 'constraints' => [
  351.                     new Assert\Length(['max' => $config['eccube_stext_len']]),
  352.                 ],
  353.             ])
  354.             ->add('note2'TextType::class, [
  355.                 'required' => false,
  356.                 'attr' => ['maxlength' => $config['eccube_stext_len']],
  357.                 'constraints' => [
  358.                     new Assert\Length(['max' => $config['eccube_stext_len']]),
  359.                 ],
  360.             ])
  361.             ->add('note3'TextType::class, [
  362.                 'required' => false,
  363.                 'attr' => ['maxlength' => $config['eccube_stext_len']],
  364.                 'constraints' => [
  365.                     new Assert\Length(['max' => $config['eccube_stext_len']]),
  366.                 ],
  367.             ])
  368.             ->add('default'CheckboxType::class, [
  369.                 'label' => 'admin.order.delivery_note_save_input',
  370.                 'required' => false,
  371.             ])
  372.             ->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
  373.                 $form $event->getForm();
  374.                 $data $form->getData();
  375.                 if (!isset($data['ids']) || !is_string($data['ids'])) {
  376.                     return;
  377.                 }
  378.                 $ids explode(','$data['ids']);
  379.                 $qb $this->entityManager->createQueryBuilder();
  380.                 $qb->select('count(s.id)')
  381.                     ->from('Eccube\\Entity\\Shipping''s')
  382.                     ->where($qb->expr()->in('s.id'':ids'))
  383.                     ->setParameter('ids'$ids);
  384.                 $actual $qb->getQuery()->getSingleScalarResult();
  385.                 $expected count($ids);
  386.                 if ($actual != $expected) {
  387.                     $form['ids']->addError(
  388.                         new FormError(trans('admin.order.delivery_note_parameter_error'))
  389.                     );
  390.                 }
  391.             });
  392.     }
  393.     /**
  394.      * Get name method (form factory name).
  395.      *
  396.      * @return string
  397.      */
  398.     public function getName()
  399.     {
  400.         return 'admin_claim_pdf';
  401.     }
  402. }