1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright © Getnet. All rights reserved. |
4
|
|
|
* |
5
|
|
|
* @author Bruno Elisei <[email protected]> |
6
|
|
|
* See LICENSE for license details. |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Admin Form Sub Seller class add form. |
11
|
|
|
*/ |
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace Getnet\SubSellerMagento\Block\Adminhtml\SubSeller; |
15
|
|
|
|
16
|
|
|
use Getnet\SubSellerMagento\Controller\RegistryConstants; |
17
|
|
|
use Getnet\SubSellerMagento\Model\Config\Source; |
18
|
|
|
use Magento\Config\Model\Config\Source\Yesno; |
19
|
|
|
use Magento\Directory\Helper\Data as DirectoryHelper; |
20
|
|
|
use Magento\Framework\App\ObjectManager; |
21
|
|
|
use Magento\Framework\Exception\NoSuchEntityException; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Sub Seller form. |
25
|
|
|
* |
26
|
|
|
* @api |
27
|
|
|
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) |
28
|
|
|
* |
29
|
|
|
* @since 100.0.2 |
30
|
|
|
*/ |
31
|
|
|
class Form extends \Magento\Backend\Block\Widget\Form\Generic |
|
|
|
|
32
|
|
|
{ |
33
|
|
|
public const FORM_ELEMENT_ID = 'sub-seller-form'; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var null |
37
|
|
|
*/ |
38
|
|
|
protected $_titles = null; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var string |
42
|
|
|
*/ |
43
|
|
|
protected $_template = 'Getnet_SubSellerMagento::sub_seller/form.phtml'; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var \Getnet\SubSellerMagento\Helper\Data|null |
47
|
|
|
*/ |
48
|
|
|
protected $helperDataSubSeller = null; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @var \Magento\Directory\Model\Config\Source\Country |
52
|
|
|
*/ |
53
|
|
|
protected $_country; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var \Magento\Directory\Model\RegionFactory |
57
|
|
|
*/ |
58
|
|
|
protected $_regionFactory; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @var \Getnet\SubSellerMagento\Api\SubSellerRepositoryInterface |
62
|
|
|
*/ |
63
|
|
|
protected $_subSellerRepository; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @var \Getnet\SubSellerMagento\Model\SubSellerCollection |
67
|
|
|
*/ |
68
|
|
|
protected $_subSellerCollection; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @var \Getnet\SubSellerMagento\Model\Seller\Converter |
72
|
|
|
*/ |
73
|
|
|
protected $_subSellerConverter; |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @var Source\BankTypeAccounts |
77
|
|
|
*/ |
78
|
|
|
protected $bankTypeAccounts; |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @var YesNo |
82
|
|
|
*/ |
83
|
|
|
protected $yesNo; |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @param \Magento\Backend\Block\Template\Context $context |
87
|
|
|
* @param \Magento\Framework\Registry $registry |
88
|
|
|
* @param \Magento\Framework\Data\FormFactory $formFactory |
89
|
|
|
* @param \Magento\Directory\Model\RegionFactory $regionFactory |
90
|
|
|
* @param \Magento\Directory\Model\Config\Source\Country $country |
91
|
|
|
* @param \Getnet\SubSellerMagento\Helper\Data $helperDataSubSeller |
92
|
|
|
* @param \Getnet\SubSellerMagento\Api\SubSellerRepositoryInterface $subSellerRepository |
93
|
|
|
* @param \Getnet\SubSellerMagento\Model\SubSellerCollection $subSellerCollection |
94
|
|
|
* @param \Getnet\SubSellerMagento\Model\Seller\Converter $subSellerConverter |
95
|
|
|
* @param Source\BankTypeAccounts $bankTypeAccounts |
96
|
|
|
* @param Source\BankTypeAccount $bankTypeAccount |
97
|
|
|
* @param Yesno $yesNo |
98
|
|
|
* @param array $data |
99
|
|
|
* @param DirectoryHelper|null $directoryHelper |
100
|
|
|
* @SuppressWarnings(PHPMD.ExcessiveParameterList) |
101
|
|
|
*/ |
102
|
|
|
public function __construct( |
103
|
|
|
\Magento\Backend\Block\Template\Context $context, |
104
|
|
|
\Magento\Framework\Registry $registry, |
105
|
|
|
\Magento\Framework\Data\FormFactory $formFactory, |
106
|
|
|
\Magento\Directory\Model\RegionFactory $regionFactory, |
107
|
|
|
\Magento\Directory\Model\Config\Source\Country $country, |
108
|
|
|
\Getnet\SubSellerMagento\Helper\Data $helperDataSubSeller, |
109
|
|
|
\Getnet\SubSellerMagento\Api\SubSellerRepositoryInterface $subSellerRepository, |
110
|
|
|
\Getnet\SubSellerMagento\Model\SubSellerCollection $subSellerCollection, |
111
|
|
|
\Getnet\SubSellerMagento\Model\Seller\Converter $subSellerConverter, |
112
|
|
|
Source\BankTypeAccounts $bankTypeAccounts, |
113
|
|
|
Source\BankTypeAccount $bankTypeAccount, |
114
|
|
|
Yesno $yesNo, |
115
|
|
|
array $data = [], |
116
|
|
|
?DirectoryHelper $directoryHelper = null |
117
|
|
|
) { |
118
|
|
|
$this->_regionFactory = $regionFactory; |
119
|
|
|
$this->_country = $country; |
120
|
|
|
$this->helperDataSubSeller = $helperDataSubSeller; |
121
|
|
|
$this->_subSellerRepository = $subSellerRepository; |
122
|
|
|
$this->_subSellerCollection = $subSellerCollection; |
123
|
|
|
$this->_subSellerConverter = $subSellerConverter; |
124
|
|
|
$this->bankTypeAccounts = $bankTypeAccounts; |
125
|
|
|
$this->bankTypeAccount = $bankTypeAccount; |
|
|
|
|
126
|
|
|
$this->yesNo = $yesNo; |
127
|
|
|
$data['directoryHelper'] = $directoryHelper ?? ObjectManager::getInstance()->get(DirectoryHelper::class); |
128
|
|
|
parent::__construct($context, $registry, $formFactory, $data); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @inheritdoc |
133
|
|
|
*/ |
134
|
|
|
protected function _construct() |
135
|
|
|
{ |
136
|
|
|
parent::_construct(); |
137
|
|
|
$this->setDestElementId(self::FORM_ELEMENT_ID); |
|
|
|
|
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Prepare form before rendering HTML. |
142
|
|
|
* |
143
|
|
|
* @return $this |
144
|
|
|
* @SuppressWarnings(PHPMD.CyclomaticComplexity) |
145
|
|
|
* @SuppressWarnings(PHPMD.NPathComplexity) |
146
|
|
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) |
147
|
|
|
*/ |
148
|
|
|
protected function _prepareForm() |
149
|
|
|
{ |
150
|
|
|
$subSellerId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_SUB_SELLER_ID); |
|
|
|
|
151
|
|
|
|
152
|
|
|
$subSellerType = (int) $this->_coreRegistry->registry(RegistryConstants::CURRENT_SUB_SELLER_TYPE); |
|
|
|
|
153
|
|
|
|
154
|
|
|
try { |
155
|
|
|
if ($subSellerId) { |
156
|
|
|
$subSellerDataObject = $this->_subSellerRepository->get($subSellerId); |
157
|
|
|
} |
158
|
|
|
// phpcs:ignore Magento2.CodeAnalysis.EmptyBlock |
159
|
|
|
} catch (NoSuchEntityException $e) { |
160
|
|
|
//sub seller not found// |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
$sessionFormValues = (array) $this->_coreRegistry->registry(RegistryConstants::CURRENT_SUB_SELLER_FORM_DATA); |
|
|
|
|
164
|
|
|
$formData = isset($subSellerDataObject) |
165
|
|
|
? $this->_subSellerConverter->createArrayFromServiceObject($subSellerDataObject) |
166
|
|
|
: []; |
167
|
|
|
$formData = array_merge($formData, $sessionFormValues); |
168
|
|
|
|
169
|
|
|
/** @var \Magento\Framework\Data\Form $form */ |
170
|
|
|
$form = $this->_formFactory->create(); |
171
|
|
|
$bankTypeAccount = $this->bankTypeAccount->toOptionArray(); |
172
|
|
|
$dateFormat = $this->_localeDate->getDateFormatWithLongYear(); |
173
|
|
|
$yesNo = $this->yesNo->toArray(); |
174
|
|
|
|
175
|
|
|
$countries = $this->_country->toOptionArray(false, 'BR'); |
176
|
|
|
unset($countries[0]); |
177
|
|
|
|
178
|
|
|
if (!isset($formData['address_country_id'])) { |
179
|
|
|
$formData['address_country_id'] = 'BR'; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
$regionCollection = $this->_regionFactory->create()->getCollection()->addCountryFilter( |
|
|
|
|
183
|
|
|
$formData['address_country_id'] |
184
|
|
|
); |
185
|
|
|
|
186
|
|
|
$regions = $regionCollection->toOptionArray(); |
187
|
|
|
|
188
|
|
|
if (isset($formData['type'])) { |
189
|
|
|
$subSellerType = (int) $formData['type']; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
$legend = $this->getShowLegend() ? __('Sub Seller') : ''; |
|
|
|
|
193
|
|
|
$fieldset = $form->addFieldset( |
194
|
|
|
'base_fieldset', |
195
|
|
|
['legend' => $legend, 'class' => 'admin__scope-old form-inline'] |
196
|
|
|
); |
197
|
|
|
|
198
|
|
|
if (isset($formData['id']) && $formData['id'] > 0) { |
199
|
|
|
$fieldset->addField( |
200
|
|
|
'id', |
201
|
|
|
'hidden', |
202
|
|
|
['name' => 'id', 'value' => $formData['id']] |
203
|
|
|
); |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
if (isset($formData['status'])) { |
207
|
|
|
if ($formData['status'] !== 1) { |
208
|
|
|
$fieldset->addField( |
209
|
|
|
'status', |
210
|
|
|
'label', |
211
|
|
|
[ |
212
|
|
|
'name' => 'status', |
213
|
|
|
'label' => __('Status'), |
214
|
|
|
'title' => __('Status'), |
215
|
|
|
] |
216
|
|
|
); |
217
|
|
|
} else { |
218
|
|
|
$fieldset->addField( |
219
|
|
|
'status', |
220
|
|
|
'hidden', |
221
|
|
|
[ |
222
|
|
|
'name' => 'status', |
223
|
|
|
'label' => __('Status'), |
224
|
|
|
'title' => __('Status'), |
225
|
|
|
] |
226
|
|
|
); |
227
|
|
|
} |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
if (isset($formData['status_comment'])) { |
231
|
|
|
$fieldset->addField( |
232
|
|
|
'status_comment', |
233
|
|
|
'label', |
234
|
|
|
[ |
235
|
|
|
'name' => 'status', |
236
|
|
|
'label' => __('Status Comment'), |
237
|
|
|
'title' => __('Status Comment'), |
238
|
|
|
] |
239
|
|
|
); |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
if (isset($formData['created_at'])) { |
243
|
|
|
$fieldset->addField( |
244
|
|
|
'created_at', |
245
|
|
|
'label', |
246
|
|
|
[ |
247
|
|
|
'name' => 'created_at', |
248
|
|
|
'label' => __('Created At'), |
249
|
|
|
'title' => __('Status Comment'), |
250
|
|
|
] |
251
|
|
|
); |
252
|
|
|
} |
253
|
|
|
|
254
|
|
|
if (isset($formData['updated_at'])) { |
255
|
|
|
$fieldset->addField( |
256
|
|
|
'updated_at', |
257
|
|
|
'label', |
258
|
|
|
[ |
259
|
|
|
'name' => 'updated_at', |
260
|
|
|
'label' => __('Updated At'), |
261
|
|
|
'title' => __('Updated At'), |
262
|
|
|
] |
263
|
|
|
); |
264
|
|
|
} |
265
|
|
|
|
266
|
|
|
if (isset($formData['id_ext'])) { |
267
|
|
|
$fieldset->addField( |
268
|
|
|
'id_ext', |
269
|
|
|
'label', |
270
|
|
|
[ |
271
|
|
|
'name' => 'id_ext', |
272
|
|
|
'label' => __('Sub Seller Id on Getnet'), |
273
|
|
|
'title' => __('Sub Seller Id on Getnet'), |
274
|
|
|
] |
275
|
|
|
); |
276
|
|
|
} |
277
|
|
|
|
278
|
|
|
$fieldset = $form->addFieldset( |
279
|
|
|
'base_fieldset_data', |
280
|
|
|
['legend' => 'Base Data', 'class' => 'admin__scope-old form-inline'] |
281
|
|
|
); |
282
|
|
|
|
283
|
|
|
$fieldset->addField( |
284
|
|
|
'code', |
285
|
|
|
'text', |
286
|
|
|
[ |
287
|
|
|
'name' => 'code', |
288
|
|
|
'label' => __('Code'), |
289
|
|
|
'title' => __('Code'), |
290
|
|
|
'class' => 'required-entry', |
291
|
|
|
'required' => true, |
292
|
|
|
] |
293
|
|
|
); |
294
|
|
|
|
295
|
|
|
$fieldset->addField( |
296
|
|
|
'type', |
297
|
|
|
'hidden', |
298
|
|
|
[ |
299
|
|
|
'name' => 'type', |
300
|
|
|
'label' => __('Type Persona'), |
301
|
|
|
'title' => __('Type Persona'), |
302
|
|
|
'value' => isset($subSellerType) ? $subSellerType : 0, |
303
|
|
|
] |
304
|
|
|
); |
305
|
|
|
|
306
|
|
|
// validate-email... |
307
|
|
|
$fieldset->addField( |
308
|
|
|
'email', |
309
|
|
|
'text', |
310
|
|
|
[ |
311
|
|
|
'name' => 'email', |
312
|
|
|
'label' => __('Email'), |
313
|
|
|
'title' => __('Email'), |
314
|
|
|
'class' => 'required-entry', |
315
|
|
|
'required' => true, |
316
|
|
|
] |
317
|
|
|
); |
318
|
|
|
|
319
|
|
|
$fieldset->addField( |
320
|
|
|
'legal_document_number', |
321
|
|
|
'text', |
322
|
|
|
[ |
323
|
|
|
'name' => 'legal_document_number', |
324
|
|
|
'label' => __('Legal Document Number'), |
325
|
|
|
'title' => __('Legal Document Number'), |
326
|
|
|
'class' => 'required-entry', |
327
|
|
|
'required' => true, |
328
|
|
|
] |
329
|
|
|
); |
330
|
|
|
|
331
|
|
|
if (!$subSellerType) { |
332
|
|
|
$fieldset->addField( |
333
|
|
|
'legal_name', |
334
|
|
|
'text', |
335
|
|
|
[ |
336
|
|
|
'name' => 'legal_name', |
337
|
|
|
'label' => __('Legal Name'), |
338
|
|
|
'title' => __('Legal Name'), |
339
|
|
|
'class' => 'required-entry', |
340
|
|
|
'required' => true, |
341
|
|
|
] |
342
|
|
|
); |
343
|
|
|
} |
344
|
|
|
|
345
|
|
|
if ($subSellerType) { |
346
|
|
|
$fieldset->addField( |
347
|
|
|
'legal_name', |
348
|
|
|
'text', |
349
|
|
|
[ |
350
|
|
|
'name' => 'legal_name', |
351
|
|
|
'label' => __('Trade Legal Name'), |
352
|
|
|
'title' => __('Trade Legal Name'), |
353
|
|
|
'class' => 'required-entry', |
354
|
|
|
'required' => true, |
355
|
|
|
] |
356
|
|
|
); |
357
|
|
|
} |
358
|
|
|
|
359
|
|
|
$fieldset->addField( |
360
|
|
|
'birth_date', |
361
|
|
|
'date', |
362
|
|
|
[ |
363
|
|
|
'name' => 'birth_date', |
364
|
|
|
'label' => $subSellerType ? __('Founding Date') : __('Birth Date'), |
365
|
|
|
'title' => $subSellerType ? __('Founding Date') : __('Birth Date'), |
366
|
|
|
'date_format' => $dateFormat, |
367
|
|
|
'class' => 'required-entry', |
368
|
|
|
'required' => true, |
369
|
|
|
] |
370
|
|
|
); |
371
|
|
|
|
372
|
|
|
$fieldset = $form->addFieldset( |
373
|
|
|
'base_fieldset_addresses', |
374
|
|
|
[ |
375
|
|
|
'legend' => $this->getFormLabelsBySellerType($subSellerType, 'base_fieldset_addresses'), |
376
|
|
|
] |
377
|
|
|
); |
378
|
|
|
|
379
|
|
|
$fieldset->addField( |
380
|
|
|
'address_street', |
381
|
|
|
'text', |
382
|
|
|
[ |
383
|
|
|
'name' => 'addresses[0][address_street]', |
384
|
|
|
'label' => __('Street'), |
385
|
|
|
'title' => __('Street'), |
386
|
|
|
'class' => 'required-entry', |
387
|
|
|
'required' => true, |
388
|
|
|
] |
389
|
|
|
); |
390
|
|
|
|
391
|
|
|
$fieldset->addField( |
392
|
|
|
'address_street_number', |
393
|
|
|
'text', |
394
|
|
|
[ |
395
|
|
|
'name' => 'addresses[0][address_street_number]', |
396
|
|
|
'label' => __('Street Number'), |
397
|
|
|
'title' => __('Street Number'), |
398
|
|
|
'class' => 'required-entry', |
399
|
|
|
'required' => true, |
400
|
|
|
] |
401
|
|
|
); |
402
|
|
|
|
403
|
|
|
$fieldset->addField( |
404
|
|
|
'address_street_district', |
405
|
|
|
'text', |
406
|
|
|
[ |
407
|
|
|
'name' => 'addresses[0][address_street_district]', |
408
|
|
|
'label' => __('District'), |
409
|
|
|
'title' => __('District'), |
410
|
|
|
'class' => 'required-entry', |
411
|
|
|
'required' => true, |
412
|
|
|
] |
413
|
|
|
); |
414
|
|
|
|
415
|
|
|
$fieldset->addField( |
416
|
|
|
'address_street_complement', |
417
|
|
|
'text', |
418
|
|
|
[ |
419
|
|
|
'name' => 'addresses[0][address_street_complement]', |
420
|
|
|
'label' => __('Complement'), |
421
|
|
|
'title' => __('Complement'), |
422
|
|
|
] |
423
|
|
|
); |
424
|
|
|
|
425
|
|
|
$fieldset->addField( |
426
|
|
|
'address_city', |
427
|
|
|
'text', |
428
|
|
|
[ |
429
|
|
|
'name' => 'addresses[0][address_city]', |
430
|
|
|
'label' => __('City'), |
431
|
|
|
'title' => __('City'), |
432
|
|
|
'class' => 'required-entry', |
433
|
|
|
'required' => true, |
434
|
|
|
] |
435
|
|
|
); |
436
|
|
|
|
437
|
|
|
if (isset($formData['address_region'])) { |
438
|
|
|
$fieldset->addField( |
439
|
|
|
'address_region', |
440
|
|
|
'hidden', |
441
|
|
|
[ |
442
|
|
|
'name' => 'addresses[0][address_region]', |
443
|
|
|
'style' => 'display:none', |
444
|
|
|
] |
445
|
|
|
); |
446
|
|
|
} |
447
|
|
|
|
448
|
|
|
$fieldset->addField( |
449
|
|
|
'address_region_id', |
450
|
|
|
'select', |
451
|
|
|
[ |
452
|
|
|
'name' => 'addresses[0][address_region_id]', |
453
|
|
|
'label' => __('State'), |
454
|
|
|
'values' => $regions, |
455
|
|
|
'class' => 'required-entry', |
456
|
|
|
'required' => true, |
457
|
|
|
] |
458
|
|
|
); |
459
|
|
|
|
460
|
|
|
$fieldset->addField( |
461
|
|
|
'address_country_id', |
462
|
|
|
'select', |
463
|
|
|
[ |
464
|
|
|
'name' => 'addresses[0][address_country_id]', |
465
|
|
|
'label' => __('Country'), |
466
|
|
|
'required' => true, |
467
|
|
|
'values' => $countries, |
468
|
|
|
] |
469
|
|
|
); |
470
|
|
|
|
471
|
|
|
$fieldset->addField( |
472
|
|
|
'address_postcode', |
473
|
|
|
'text', |
474
|
|
|
[ |
475
|
|
|
'name' => 'addresses[0][address_postcode]', |
476
|
|
|
'label' => __('Postcode'), |
477
|
|
|
'title' => __('Postcode'), |
478
|
|
|
'class' => 'required-entry validate-zip-br', |
479
|
|
|
'required' => true, |
480
|
|
|
] |
481
|
|
|
); |
482
|
|
|
|
483
|
|
|
$fieldset->addField( |
484
|
|
|
'telephone', |
485
|
|
|
'text', |
486
|
|
|
[ |
487
|
|
|
'name' => 'telephone', |
488
|
|
|
'label' => __('Telephone'), |
489
|
|
|
'title' => __('Telephone'), |
490
|
|
|
'class' => 'required-entry', |
491
|
|
|
'required' => true, |
492
|
|
|
] |
493
|
|
|
); |
494
|
|
|
|
495
|
|
|
$fieldset = $form->addFieldset('base_fieldset_bank', ['legend' => __('Bank Account')]); |
496
|
|
|
|
497
|
|
|
$fieldset->addField( |
498
|
|
|
'account_type', |
499
|
|
|
'select', |
500
|
|
|
[ |
501
|
|
|
'name' => 'bank_accounts[0][account_type]', |
502
|
|
|
'label' => __('Account Type'), |
503
|
|
|
'title' => __('Account Type'), |
504
|
|
|
'values' => $bankTypeAccount, |
505
|
|
|
'value' => isset($formData['account_type']) ? $formData['account_type'] : 'C', |
506
|
|
|
'class' => 'required-entry', |
507
|
|
|
'required' => true, |
508
|
|
|
] |
509
|
|
|
); |
510
|
|
|
|
511
|
|
|
$fieldset->addField( |
512
|
|
|
'bank', |
513
|
|
|
'text', |
514
|
|
|
[ |
515
|
|
|
'name' => 'bank_accounts[0][bank]', |
516
|
|
|
'label' => __('Bank'), |
517
|
|
|
'title' => __('Bank'), |
518
|
|
|
'class' => 'required-entry', |
519
|
|
|
'required' => true, |
520
|
|
|
] |
521
|
|
|
); |
522
|
|
|
|
523
|
|
|
$fieldset->addField( |
524
|
|
|
'agency', |
525
|
|
|
'text', |
526
|
|
|
[ |
527
|
|
|
'name' => 'bank_accounts[0][agency]', |
528
|
|
|
'label' => __('Agency'), |
529
|
|
|
'title' => __('Agency'), |
530
|
|
|
'class' => 'required-entry', |
531
|
|
|
'required' => true, |
532
|
|
|
] |
533
|
|
|
); |
534
|
|
|
|
535
|
|
|
$fieldset->addField( |
536
|
|
|
'agency_digit', |
537
|
|
|
'text', |
538
|
|
|
[ |
539
|
|
|
'name' => 'bank_accounts[0][agency_digit]', |
540
|
|
|
'label' => __('Agency Digit'), |
541
|
|
|
'title' => __('Agency Digit'), |
542
|
|
|
'class' => 'required-entry', |
543
|
|
|
'required' => true, |
544
|
|
|
] |
545
|
|
|
); |
546
|
|
|
|
547
|
|
|
$fieldset->addField( |
548
|
|
|
'account', |
549
|
|
|
'text', |
550
|
|
|
[ |
551
|
|
|
'name' => 'bank_accounts[0][account]', |
552
|
|
|
'label' => __('Account'), |
553
|
|
|
'title' => __('Account'), |
554
|
|
|
'class' => 'required-entry', |
555
|
|
|
'required' => true, |
556
|
|
|
] |
557
|
|
|
); |
558
|
|
|
|
559
|
|
|
$fieldset->addField( |
560
|
|
|
'account_digit', |
561
|
|
|
'text', |
562
|
|
|
[ |
563
|
|
|
'name' => 'bank_accounts[0][account_digit]', |
564
|
|
|
'label' => __('Account Digit'), |
565
|
|
|
'title' => __('Account Digit'), |
566
|
|
|
'class' => 'required-entry', |
567
|
|
|
'required' => true, |
568
|
|
|
] |
569
|
|
|
); |
570
|
|
|
|
571
|
|
|
$fieldset = $form->addFieldset('base_fieldset_settings', ['legend' => __('Marketplace Settings')]); |
572
|
|
|
|
573
|
|
|
$fieldset->addField( |
574
|
|
|
'payment_plan', |
575
|
|
|
'text', |
576
|
|
|
[ |
577
|
|
|
'name' => 'payment_plan', |
578
|
|
|
'label' => __('Payment Plan'), |
579
|
|
|
'title' => __('Payment Plan'), |
580
|
|
|
'class' => 'required-entry', |
581
|
|
|
'required' => true, |
582
|
|
|
] |
583
|
|
|
); |
584
|
|
|
|
585
|
|
|
$fieldset->addField( |
586
|
|
|
'accepted_contract', |
587
|
|
|
'select', |
588
|
|
|
[ |
589
|
|
|
'name' => 'type', |
590
|
|
|
'label' => __('Accepted Contract'), |
591
|
|
|
'title' => __('Accepted Contract'), |
592
|
|
|
'values' => $yesNo, |
593
|
|
|
'value' => isset($formData['accepted_contract']) ? $formData['accepted_contract'] : 1, |
594
|
|
|
'class' => 'required-entry', |
595
|
|
|
'required' => true, |
596
|
|
|
] |
597
|
|
|
); |
598
|
|
|
|
599
|
|
|
$fieldset->addField( |
600
|
|
|
'marketplace_store', |
601
|
|
|
'select', |
602
|
|
|
[ |
603
|
|
|
'name' => 'marketplace_store', |
604
|
|
|
'label' => __('Marketplace Store'), |
605
|
|
|
'title' => __('Marketplace Store'), |
606
|
|
|
'values' => $yesNo, |
607
|
|
|
'value' => isset($formData['marketplace_store']) ? $formData['marketplace_store'] : 0, |
608
|
|
|
'class' => 'required-entry', |
609
|
|
|
'required' => true, |
610
|
|
|
] |
611
|
|
|
); |
612
|
|
|
|
613
|
|
|
$fieldset = $form->addFieldset( |
614
|
|
|
'base_fieldset_additional_data', |
615
|
|
|
[ |
616
|
|
|
'legend' => $this->getFormLabelsBySellerType($subSellerType, 'base_fieldset_additional_data'), |
617
|
|
|
] |
618
|
|
|
); |
619
|
|
|
|
620
|
|
|
$fieldset->addField( |
621
|
|
|
'occupation', |
622
|
|
|
'text', |
623
|
|
|
[ |
624
|
|
|
'name' => 'occupation', |
625
|
|
|
'label' => __('Occupation'), |
626
|
|
|
'title' => __('Occupation'), |
627
|
|
|
] |
628
|
|
|
); |
629
|
|
|
|
630
|
|
|
$fieldset = $form->addFieldset( |
631
|
|
|
'base_fieldset_gross', |
632
|
|
|
[ |
633
|
|
|
'legend' => $this->getFormLabelsBySellerType($subSellerType, 'base_fieldset_gross'), |
634
|
|
|
] |
635
|
|
|
); |
636
|
|
|
|
637
|
|
|
$fieldset->addField( |
638
|
|
|
'monthly_gross_income', |
639
|
|
|
'text', |
640
|
|
|
[ |
641
|
|
|
'name' => 'monthly_gross_income', |
642
|
|
|
'label' => __('Monthly Gross Income'), |
643
|
|
|
'title' => __('Monthly Gross Income'), |
644
|
|
|
] |
645
|
|
|
); |
646
|
|
|
|
647
|
|
|
$fieldset->addField( |
648
|
|
|
'gross_equity', |
649
|
|
|
'text', |
650
|
|
|
[ |
651
|
|
|
'name' => 'gross_equity', |
652
|
|
|
'label' => __('Gross Equity'), |
653
|
|
|
'title' => __('Gross Equity'), |
654
|
|
|
] |
655
|
|
|
); |
656
|
|
|
|
657
|
|
|
$form->setAction($this->getUrl('subseller/subseller/save')); |
658
|
|
|
$form->setUseContainer(true); |
659
|
|
|
$form->setId(self::FORM_ELEMENT_ID); |
660
|
|
|
$form->setMethod('post'); |
661
|
|
|
|
662
|
|
|
$form->setValues($formData); |
663
|
|
|
$this->setForm($form); |
664
|
|
|
|
665
|
|
|
$this->setChild( |
666
|
|
|
'form_after', |
667
|
|
|
$this->getLayout()->createBlock( |
668
|
|
|
\Magento\Framework\View\Element\Template::class |
669
|
|
|
)->setTemplate('Getnet_SubSellerMagento::sub_seller/js.phtml') |
|
|
|
|
670
|
|
|
); |
671
|
|
|
|
672
|
|
|
return parent::_prepareForm(); |
673
|
|
|
} |
674
|
|
|
|
675
|
|
|
/** |
676
|
|
|
* Get Form Labels by Seller Type. |
677
|
|
|
* |
678
|
|
|
* @param int $type |
679
|
|
|
* @param string $field |
680
|
|
|
* |
681
|
|
|
* @return \Magento\Framework\Phrase |
682
|
|
|
*/ |
683
|
|
|
public function getFormLabelsBySellerType(int $type, string $field): \Magento\Framework\Phrase |
684
|
|
|
{ |
685
|
|
|
if ($type === 0) { |
686
|
|
|
$label = [ |
687
|
|
|
'base_fieldset_addresses' => __('Addresses'), |
688
|
|
|
'base_fieldset_additional_data' => __('Additional data'), |
689
|
|
|
'base_fieldset_document' => __('Identification Document'), |
690
|
|
|
'base_fieldset_gross' => __('Gross'), |
691
|
|
|
]; |
692
|
|
|
|
693
|
|
|
return $label[$field]; |
694
|
|
|
} |
695
|
|
|
|
696
|
|
|
if ($type === 1) { |
697
|
|
|
$label = [ |
698
|
|
|
'base_fieldset_addresses' => __('Company Addresses'), |
699
|
|
|
'base_fieldset_additional_data' => __('Legal Data Representative'), |
700
|
|
|
'base_fieldset_document' => __('Legal Representative Document\'s'), |
701
|
|
|
'base_fieldset_gross' => __('Gross'), |
702
|
|
|
]; |
703
|
|
|
|
704
|
|
|
return $label[$field]; |
705
|
|
|
} |
|
|
|
|
706
|
|
|
} |
707
|
|
|
} |
708
|
|
|
|