|
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
|
|
|
public function buildForm(FormBuilderInterface $builder, array $options) |
|
41
|
|
|
{ |
|
42
|
|
|
$builder |
|
43
|
|
|
->add('name', 'text', array( |
|
44
|
|
|
'label' => '配送業者名', |
|
45
|
|
|
'required' => true, |
|
46
|
|
|
'constraints' => array( |
|
47
|
|
|
new Assert\NotBlank, |
|
|
|
|
|
|
48
|
|
|
), |
|
49
|
|
|
)) |
|
50
|
|
|
->add('service_name', 'text', array( |
|
51
|
|
|
'label' => '名称', |
|
52
|
|
|
'required' => true, |
|
53
|
|
|
'constraints' => array( |
|
54
|
|
|
new Assert\NotBlank(), |
|
55
|
|
|
), |
|
56
|
|
|
)) |
|
57
|
|
|
->add('description', 'textarea', array( |
|
58
|
|
|
'label' => 'ショップ用メモ欄', |
|
59
|
|
|
'required' => false, |
|
60
|
|
|
)) |
|
61
|
|
|
->add('confirm_url', 'text', array( |
|
62
|
|
|
'label' => '伝票No.URL', |
|
63
|
|
|
'required' => false, |
|
64
|
|
|
'constraints' => array( |
|
65
|
|
|
new Assert\Url(), |
|
66
|
|
|
), |
|
67
|
|
|
)) |
|
68
|
|
|
->add('product_type', 'product_type', array( |
|
69
|
|
|
'constraints' => array( |
|
70
|
|
|
new Assert\NotBlank(), |
|
71
|
|
|
), |
|
72
|
|
|
)) |
|
73
|
|
|
->add('payments', 'payment', array( |
|
74
|
|
|
'label' => '支払方法', |
|
75
|
|
|
'expanded' => true, |
|
76
|
|
|
'multiple' => true, |
|
77
|
|
|
'required' => false, |
|
78
|
|
|
'mapped' => false, |
|
79
|
|
|
)) |
|
80
|
|
|
->add('delivery_times', 'collection', array( |
|
81
|
|
|
'label' => 'お届け時間', |
|
82
|
|
|
'required' => false, |
|
83
|
|
|
'type' => 'delivery_time', |
|
84
|
|
|
'allow_add' => true, |
|
85
|
|
|
'allow_delete' => true, |
|
86
|
|
|
'prototype' => true, |
|
87
|
|
|
)) |
|
88
|
|
|
->add('free_all', 'price', array( |
|
|
|
|
|
|
89
|
|
|
'label' => false, |
|
90
|
|
|
'currency' => 'JPY', |
|
91
|
|
|
'precision' => 0, |
|
92
|
|
|
'scale' => 0, |
|
93
|
|
|
'grouping' => true, |
|
94
|
|
|
'required' => false, |
|
95
|
|
|
'mapped' => false |
|
96
|
|
|
)) |
|
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
|
|
|
)) |
|
105
|
|
|
->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
|
|
|
}) |
|
113
|
|
|
; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* {@inheritdoc} |
|
118
|
|
|
*/ |
|
119
|
|
|
public function setDefaultOptions(OptionsResolverInterface $resolver) |
|
120
|
|
|
{ |
|
121
|
|
|
$resolver->setDefaults(array( |
|
122
|
|
|
'data_class' => 'Eccube\Entity\Delivery', |
|
123
|
|
|
)); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* {@inheritdoc} |
|
128
|
|
|
*/ |
|
129
|
|
|
public function getName() |
|
130
|
|
|
{ |
|
131
|
|
|
return 'delivery'; |
|
132
|
|
|
} |
|
133
|
|
|
} |
|
134
|
|
|
|