1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of EC-CUBE |
4
|
|
|
* |
5
|
|
|
* Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved. |
6
|
|
|
* |
7
|
|
|
* http://www.lockon.co.jp/ |
8
|
|
|
* |
9
|
|
|
* This program is free software; you can redistribute it and/or |
10
|
|
|
* modify it under the terms of the GNU General Public License |
11
|
|
|
* as published by the Free Software Foundation; either version 2 |
12
|
|
|
* of the License, or (at your option) any later version. |
13
|
|
|
* |
14
|
|
|
* This program is distributed in the hope that it will be useful, |
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17
|
|
|
* GNU General Public License for more details. |
18
|
|
|
* |
19
|
|
|
* You should have received a copy of the GNU General Public License |
20
|
|
|
* along with this program; if not, write to the Free Software |
21
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
namespace Eccube\Form\Type\Admin; |
26
|
|
|
|
27
|
|
|
use Symfony\Component\Form\AbstractType; |
28
|
|
|
use Symfony\Component\Form\Extension\Core\Type; |
29
|
|
|
use Symfony\Component\Form\FormBuilderInterface; |
30
|
|
|
use Symfony\Component\Form\FormError; |
31
|
|
|
use Symfony\Component\Form\FormEvents; |
32
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolverInterface; |
33
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
34
|
|
|
|
35
|
|
|
class DeliveryType extends AbstractType |
36
|
|
|
{ |
37
|
|
|
/** |
38
|
|
|
* {@inheritdoc} |
39
|
|
|
*/ |
40
|
6 |
|
public function buildForm(FormBuilderInterface $builder, array $options) |
41
|
|
|
{ |
42
|
|
|
$builder |
43
|
6 |
|
->add('name', 'text', array( |
44
|
6 |
|
'label' => '配送業者名', |
45
|
|
|
'required' => true, |
46
|
|
|
'constraints' => array( |
47
|
6 |
|
new Assert\NotBlank, |
48
|
|
|
), |
49
|
|
|
)) |
50
|
6 |
|
->add('service_name', 'text', array( |
51
|
6 |
|
'label' => '名称', |
52
|
|
|
'required' => true, |
53
|
|
|
'constraints' => array( |
54
|
6 |
|
new Assert\NotBlank(), |
55
|
|
|
), |
56
|
|
|
)) |
57
|
6 |
|
->add('description', 'textarea', array( |
58
|
6 |
|
'label' => 'ショップ用メモ欄', |
59
|
|
|
'required' => false, |
60
|
|
|
)) |
61
|
6 |
|
->add('confirm_url', 'text', array( |
62
|
6 |
|
'label' => '伝票No.URL', |
63
|
|
|
'required' => false, |
64
|
|
|
'constraints' => array( |
65
|
6 |
|
new Assert\Url(), |
66
|
|
|
), |
67
|
|
|
)) |
68
|
6 |
|
->add('product_type', 'product_type', array( |
69
|
|
|
'constraints' => array( |
70
|
6 |
|
new Assert\NotBlank(), |
71
|
|
|
), |
72
|
|
|
)) |
73
|
|
|
->add('payments', 'payment', array( |
74
|
6 |
|
'label' => '支払方法', |
75
|
6 |
|
'expanded' => true, |
76
|
6 |
|
'multiple' => true, |
77
|
6 |
|
'required' => false, |
78
|
|
|
'mapped' => false, |
79
|
|
|
)) |
80
|
|
|
->add('delivery_times', 'collection', array( |
81
|
|
|
'label' => 'お届け時間', |
82
|
6 |
|
'required' => false, |
83
|
6 |
|
'type' => 'delivery_time', |
84
|
6 |
|
'allow_add' => true, |
85
|
|
|
'allow_delete' => true, |
86
|
|
|
'prototype' => true, |
87
|
6 |
|
)) |
88
|
6 |
|
->add('free_all', 'price', array( |
|
|
|
|
89
|
|
|
'label' => false, |
90
|
|
|
'currency' => 'JPY', |
91
|
|
|
'precision' => 0, |
92
|
|
|
'scale' => 0, |
93
|
|
|
'grouping' => true, |
94
|
|
|
'required' => false, |
95
|
6 |
|
'mapped' => false |
96
|
6 |
|
)) |
97
|
|
|
->add('delivery_fees', 'collection', array( |
98
|
|
|
'label' => '都道府県別設定', |
99
|
|
|
'required' => true, |
100
|
|
|
'type' => 'delivery_fee', |
101
|
|
|
'allow_add' => true, |
102
|
|
|
'allow_delete' => true, |
103
|
|
|
'prototype' => true, |
104
|
6 |
|
)) |
105
|
6 |
|
->addEventListener(FormEvents::POST_SUBMIT, function($event) { |
106
|
|
|
$form = $event->getForm(); |
107
|
|
|
$payments = $form['payments']->getData(); |
108
|
|
|
|
109
|
|
|
if (empty($payments) || count($payments) < 1) { |
110
|
|
|
$form['payments']->addError(new FormError('支払方法を選択してください。')); |
111
|
|
|
} |
112
|
6 |
|
}) |
113
|
4 |
|
; |
114
|
4 |
|
} |
115
|
|
|
|
116
|
4 |
|
/** |
117
|
|
|
* {@inheritdoc} |
118
|
|
|
*/ |
119
|
6 |
|
public function setDefaultOptions(OptionsResolverInterface $resolver) |
120
|
|
|
{ |
121
|
|
|
$resolver->setDefaults(array( |
122
|
|
|
'data_class' => 'Eccube\Entity\Delivery', |
123
|
|
|
)); |
124
|
|
|
} |
125
|
|
|
|
126
|
6 |
|
/** |
127
|
|
|
* {@inheritdoc} |
128
|
6 |
|
*/ |
129
|
6 |
|
public function getName() |
130
|
|
|
{ |
131
|
|
|
return 'delivery'; |
132
|
|
|
} |
133
|
|
|
} |
134
|
|
|
|