1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony). |
4
|
|
|
* |
5
|
|
|
* Copyright (C) 2019 - 2020 Jan Böhmer (https://github.com/jbtronics) |
6
|
|
|
* |
7
|
|
|
* This program is free software: you can redistribute it and/or modify |
8
|
|
|
* it under the terms of the GNU Affero General Public License as published |
9
|
|
|
* by the Free Software Foundation, either version 3 of the License, or |
10
|
|
|
* (at your option) any later version. |
11
|
|
|
* |
12
|
|
|
* This program is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU Affero General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU Affero General Public License |
18
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
declare(strict_types=1); |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony). |
25
|
|
|
* |
26
|
|
|
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics) |
27
|
|
|
* |
28
|
|
|
* This program is free software; you can redistribute it and/or |
29
|
|
|
* modify it under the terms of the GNU General Public License |
30
|
|
|
* as published by the Free Software Foundation; either version 2 |
31
|
|
|
* of the License, or (at your option) any later version. |
32
|
|
|
* |
33
|
|
|
* This program is distributed in the hope that it will be useful, |
34
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
35
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
36
|
|
|
* GNU General Public License for more details. |
37
|
|
|
* |
38
|
|
|
* You should have received a copy of the GNU General Public License |
39
|
|
|
* along with this program; if not, write to the Free Software |
40
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
41
|
|
|
*/ |
42
|
|
|
|
43
|
|
|
namespace App\Form\AdminPages; |
44
|
|
|
|
45
|
|
|
use App\Entity\Base\AbstractNamedDBElement; |
46
|
|
|
use App\Entity\PriceInformations\Currency; |
47
|
|
|
use App\Form\Type\StructuralEntityType; |
48
|
|
|
use Symfony\Component\Form\Extension\Core\Type\MoneyType; |
49
|
|
|
use Symfony\Component\Form\FormBuilderInterface; |
50
|
|
|
use Symfony\Component\Security\Core\Security; |
51
|
|
|
|
52
|
|
|
class SupplierForm extends CompanyForm |
53
|
|
|
{ |
54
|
|
|
protected $default_currency; |
55
|
|
|
|
56
|
|
|
public function __construct(Security $security, string $default_currency) |
57
|
|
|
{ |
58
|
|
|
parent::__construct($security); |
59
|
|
|
$this->default_currency = $default_currency; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
protected function additionalFormElements(FormBuilderInterface $builder, array $options, AbstractNamedDBElement $entity): void |
63
|
|
|
{ |
64
|
|
|
$is_new = null === $entity->getID(); |
65
|
|
|
|
66
|
|
|
parent::additionalFormElements($builder, $options, $entity); |
67
|
|
|
|
68
|
|
|
$builder->add('default_currency', StructuralEntityType::class, [ |
69
|
|
|
'class' => Currency::class, |
70
|
|
|
'required' => false, |
71
|
|
|
'label' => 'supplier.edit.default_currency', |
72
|
|
|
'disable_not_selectable' => true, |
73
|
|
|
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity), |
74
|
|
|
]); |
75
|
|
|
|
76
|
|
|
$builder->add('shipping_costs', MoneyType::class, [ |
77
|
|
|
'required' => false, |
78
|
|
|
'currency' => $this->default_currency, |
79
|
|
|
'scale' => 3, |
80
|
|
|
'label' => 'supplier.shipping_costs.label', |
81
|
|
|
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity), |
82
|
|
|
]); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|