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\FormBuilderInterface; |
29
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolverInterface; |
30
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
31
|
|
|
|
32
|
|
|
class TaxRuleType extends AbstractType |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* {@inheritdoc} |
36
|
|
|
*/ |
37
|
15 |
|
public function buildForm(FormBuilderInterface $builder, array $options) |
38
|
|
|
{ |
39
|
|
|
$builder |
40
|
15 |
|
->add('option_product_tax_rule', 'choice', array( |
41
|
15 |
|
'label' => '商品別税率機能', |
42
|
|
|
'choices' => array( |
43
|
|
|
'1' => '有効', |
44
|
|
|
'0' => '無効', |
45
|
|
|
), |
46
|
|
|
'expanded' => true, |
47
|
|
|
'multiple' => false, |
48
|
|
|
'mapped' => false, |
49
|
|
|
)) |
50
|
15 |
|
->add('tax_rate', 'integer', array( |
51
|
15 |
|
'label' => '消費税率', |
52
|
|
|
'required' => true, |
53
|
|
|
'constraints' => array( |
54
|
15 |
|
new Assert\NotBlank(), |
55
|
15 |
|
new Assert\Range(array('min' => 0, 'max' => 100)), |
56
|
15 |
|
new Assert\Regex(array( |
|
|
|
|
57
|
15 |
|
'pattern' => "/^\d+(\.\d+)?$/u", |
58
|
|
|
'message' => 'form.type.float.invalid' |
59
|
|
|
)), |
60
|
|
|
), |
61
|
|
|
)) |
62
|
15 |
|
->add('calc_rule', 'calc_rule', array( |
63
|
15 |
|
'label' => '課税規則', |
64
|
|
|
'required' => true, |
65
|
|
|
)) |
66
|
15 |
|
->add('apply_date', 'date', array( |
67
|
15 |
|
'label' => '適用日時', |
68
|
15 |
|
'required' => 'false', |
69
|
15 |
|
'input' => 'datetime', |
70
|
15 |
|
'widget' => 'single_text', |
71
|
15 |
|
'format' => 'yyyy-MM-dd HH:mm', |
72
|
15 |
|
'years' => range(date('Y'), date('Y') + 2), |
73
|
|
|
'empty_value' => array( |
|
|
|
|
74
|
|
|
'year' => '----', |
75
|
|
|
'month' => '--', |
76
|
|
|
'day' => '--', |
77
|
|
|
'hours' => '--', |
78
|
|
|
'minutes' => '--' |
79
|
|
|
), |
80
|
|
|
'constraints' => array( |
81
|
15 |
|
new Assert\NotBlank(), |
82
|
|
|
), |
83
|
|
|
)); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* {@inheritdoc} |
88
|
|
|
*/ |
89
|
15 |
|
public function setDefaultOptions(OptionsResolverInterface $resolver) |
90
|
|
|
{ |
91
|
15 |
|
$resolver->setDefaults(array( |
92
|
15 |
|
'allow_extra_fields' => true, |
93
|
|
|
)); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* {@inheritdoc} |
98
|
|
|
*/ |
99
|
663 |
|
public function getName() |
100
|
|
|
{ |
101
|
663 |
|
return 'tax_rule'; |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|