55namespace Shopsys \FrameworkBundle \Form \Admin \Order ;
66
77use Override ;
8- use Shopsys \FormTypesBundle \ActionBarType ;
9- use Shopsys \FrameworkBundle \Component \Domain \Domain ;
108use Shopsys \FrameworkBundle \Form \Constraints \Email ;
119use Shopsys \FrameworkBundle \Form \DateTimeType ;
12- use Shopsys \FrameworkBundle \Form \DisplayOnlyCompanyNameType ;
13- use Shopsys \FrameworkBundle \Form \DisplayOnlyCustomerType ;
14- use Shopsys \FrameworkBundle \Form \DisplayOnlyDomainIconType ;
15- use Shopsys \FrameworkBundle \Form \DisplayOnlyType ;
16- use Shopsys \FrameworkBundle \Form \DisplayOnlyUrlType ;
1710use Shopsys \FrameworkBundle \Form \GroupType ;
18- use Shopsys \FrameworkBundle \Form \MessageType ;
1911use Shopsys \FrameworkBundle \Form \PhoneType ;
2012use Shopsys \FrameworkBundle \Form \ValidationGroup ;
2113use Shopsys \FrameworkBundle \Model \Country \CountryFacade ;
22- use Shopsys \FrameworkBundle \Model \GoPay \GoPayOrderStatus ;
2314use Shopsys \FrameworkBundle \Model \Order \Order ;
2415use Shopsys \FrameworkBundle \Model \Order \OrderData ;
25- use Shopsys \FrameworkBundle \Model \Order \Status \OrderStatus ;
26- use Shopsys \FrameworkBundle \Model \Order \Status \OrderStatusFacade ;
2716use Shopsys \FrameworkBundle \Model \Order \Status \OrderStatusTypeEnum ;
28- use Shopsys \FrameworkBundle \Model \Order \Withdrawal \WithdrawalRequest ;
2917use Shopsys \FrameworkBundle \Model \Order \Withdrawal \WithdrawalRequestFacade ;
30- use Shopsys \FrameworkBundle \Twig \DateTimeFormatterExtension ;
3118use Symfony \Component \Form \AbstractType ;
3219use Symfony \Component \Form \Extension \Core \Type \CheckboxType ;
3320use Symfony \Component \Form \Extension \Core \Type \ChoiceType ;
@@ -47,9 +34,6 @@ final class OrderFormType extends AbstractType
4734
4835 public function __construct (
4936 private readonly CountryFacade $ countryFacade ,
50- private readonly OrderStatusFacade $ orderStatusFacade ,
51- private readonly DateTimeFormatterExtension $ dateTimeFormatterExtension ,
52- private readonly Domain $ domain ,
5337 private readonly WithdrawalRequestFacade $ withdrawalRequestFacade ,
5438 ) {
5539 }
@@ -69,12 +53,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
6953 ->add ($ this ->createBillingDataGroup ($ builder , $ countries ))
7054 ->add ($ this ->createShippingAddressGroup ($ builder , $ countries , $ domainId ))
7155 ->add ($ this ->createNoteGroup ($ builder ));
72-
73- $ builder
74- ->add ('actionBar ' , ActionBarType::class, [
75- 'back_route ' => 'admin_order_list ' ,
76- 'entity ' => $ options ['order ' ],
77- ]);
7856 }
7957
8058 #[Override]
@@ -95,7 +73,7 @@ public function configureOptions(OptionsResolver $resolver): void
9573 $ orderData = $ form ->getData ();
9674
9775 if (!$ orderData ->deliveryAddressSameAsBillingAddress ) {
98- $ validationGroups [] = static ::VALIDATION_GROUP_DELIVERY_ADDRESS_SAME_AS_BILLING_ADDRESS ;
76+ $ validationGroups [] = self ::VALIDATION_GROUP_DELIVERY_ADDRESS_SAME_AS_BILLING_ADDRESS ;
9977 }
10078
10179 /** @var \Shopsys\FrameworkBundle\Model\Order\Order $order */
@@ -116,139 +94,13 @@ public function configureOptions(OptionsResolver $resolver): void
11694
11795 private function createBasicInformationGroup (FormBuilderInterface $ builder , Order $ order ): FormBuilderInterface
11896 {
119- $ domainConfig = $ this ->domain ->getDomainConfigById ($ order ->getDomainId ());
12097 $ builderBasicInformationGroup = $ builder ->create ('basicInformationGroup ' , GroupType::class, [
12198 'label ' => 'Basic information ' ,
12299 ]);
123- $ withdrawalRequest = $ this ->withdrawalRequestFacade ->findByOrder ($ order );
124-
125- if ($ withdrawalRequest !== null ) {
126- $ builderBasicInformationGroup
127- ->add ('withdrawalWarning ' , MessageType::class, [
128- 'message_level ' => MessageType::MESSAGE_LEVEL_WARNING ,
129- 'data ' => t ('There is a withdrawal request for this order. ' ),
130- ]);
131- }
132-
133- $ builderBasicInformationGroup
134- ->add ('id ' , DisplayOnlyType::class, [
135- 'label ' => 'ID ' ,
136- 'data ' => $ order ->getId (),
137- ])
138- ->add ('orderDetail ' , DisplayOnlyUrlType::class, [
139- 'label ' => 'Order detail ' ,
140- 'route ' => 'front_customer_order_detail_unregistered ' ,
141- 'route_params ' => [
142- 'urlHash ' => $ order ->getUrlHash (),
143- ],
144- 'domain_id ' => $ order ->getDomainId (),
145- ]);
146-
147- if ($ this ->domain ->isMultidomain ()) {
148- $ builderBasicInformationGroup
149- ->add ('domainIcon ' , DisplayOnlyDomainIconType::class, [
150- 'label ' => 'Domain ' ,
151- 'data ' => $ order ->getDomainId (),
152- ]);
153- }
154-
155- $ builderBasicInformationGroup
156- ->add ('orderNumber ' , DisplayOnlyType::class, [
157- 'label ' => 'Order number ' ,
158- 'data ' => $ order ->getNumber (),
159- ])
160- ->add ('dateOfCreation ' , DisplayOnlyType::class, [
161- 'label ' => 'Date of creation and privacy policy agreement ' ,
162- 'data ' => $ this ->dateTimeFormatterExtension ->formatDateTime ($ order ->getCreatedAt ()),
163- ])
164- ->add ('status ' , ChoiceType::class, [
165- 'label ' => 'Status ' ,
166- 'required ' => true ,
167- 'choices ' => $ this ->orderStatusFacade ->getAll (),
168- 'choice_label ' => 'name ' ,
169- 'choice_value ' => 'id ' ,
170- 'choice_attr ' => function (OrderStatus $ orderStatus ) {
171- return [
172- 'data-js-order-status-type ' => $ orderStatus ->getType (),
173- ];
174- },
175- 'multiple ' => false ,
176- 'expanded ' => false ,
177- 'attr ' => [
178- 'data-js-order-status-select ' => null ,
179- ],
180- ]);
181100
182- $ builderBasicInformationGroup ->add ($ this ->createWithdrawalRequestGroup ($ builderBasicInformationGroup , $ withdrawalRequest , $ order ->getDomainId ()));
183-
184- if ($ order ->getCreatedAsAdministrator () || $ order ->getCreatedAsAdministratorName ()) {
185- $ builderBasicInformationGroup
186- ->add ('createdAsAdministrator ' , DisplayOnlyType::class, [
187- 'label ' => 'Created by administrator ' ,
188- 'data ' => $ order ->getCreatedAsAdministrator () === null ? $ order ->getCreatedAsAdministratorName () : $ order ->getCreatedAsAdministrator ()->getRealName (),
189- ]);
190- }
191-
192- $ builderBasicInformationGroup
193- ->add ('user ' , DisplayOnlyCustomerType::class, [
194- 'label ' => 'Customer ' ,
195- 'user ' => $ order ->getCustomerUser (),
196- ]);
197-
198- if ($ domainConfig ->isB2b () && $ order ->getCustomer ()?->getBillingAddress()->getCompanyNumber () !== null ) {
199- $ builderBasicInformationGroup
200- ->add ('company ' , DisplayOnlyCompanyNameType::class, [
201- 'label ' => 'Company ' ,
202- 'customer ' => $ order ->getCustomer (),
203- ]);
204- }
101+ $ builderBasicInformationGroup ->add ($ this ->createWithdrawalRequestGroup ($ builderBasicInformationGroup , $ order ->getDomainId ()));
205102
206103 $ builderBasicInformationGroup
207- ->add ('heurekaAgreement ' , DisplayOnlyType::class, [
208- 'label ' => 'Heureka agreement ' ,
209- 'data ' => $ order ->isHeurekaAgreement () ? t ('Yes ' ) : t ('No ' ),
210- ]);
211-
212- if ($ order ->getOrigin () !== null ) {
213- $ builderBasicInformationGroup
214- ->add ('origin ' , DisplayOnlyType::class, [
215- 'label ' => 'Origin ' ,
216- 'data ' => $ order ->getOrigin (),
217- ]);
218- }
219-
220- $ builderBasicInformationGroup
221- ->add ('payment ' , DisplayOnlyType::class, [
222- 'label ' => 'Payment type ' ,
223- 'data ' => $ order ->getPayment ()->getName (),
224- ]);
225-
226- if ($ order ->getPayment ()->isGoPay () === true ) {
227- $ goPayPaymentTransaction = $ order ->getLastGoPayTransaction ();
228-
229- if ($ goPayPaymentTransaction !== null ) {
230- $ translatedGoPayStatus = GoPayOrderStatus::getTranslatedGoPayStatus ($ goPayPaymentTransaction ->getExternalPaymentStatus ());
231- $ translatedGoPaySubStatus = GoPayOrderStatus::getTranslatedGoPaySubStatus ($ goPayPaymentTransaction ->getExternalPaymentSubStatus ());
232-
233- if ($ translatedGoPaySubStatus !== null ) {
234- $ translatedGoPayStatus .= ' - ' . $ translatedGoPaySubStatus ;
235- }
236- } else {
237- $ translatedGoPayStatus = t ('Order has not been sent to GoPay ' );
238- }
239-
240- $ builderBasicInformationGroup
241- ->add ('gopayStatus ' , DisplayOnlyType::class, [
242- 'label ' => 'GoPay payment status ' ,
243- 'data ' => $ translatedGoPayStatus ,
244- ]);
245- }
246-
247- $ builderBasicInformationGroup
248- ->add ('transport ' , DisplayOnlyType::class, [
249- 'label ' => 'Transport type ' ,
250- 'data ' => $ order ->getTransport ()->getName (),
251- ])
252104 ->add ('trackingNumber ' , TextType::class, [
253105 'label ' => 'Tracking number ' ,
254106 'required ' => false ,
@@ -261,16 +113,6 @@ private function createBasicInformationGroup(FormBuilderInterface $builder, Orde
261113 'required ' => false ,
262114 ]);
263115
264- $ promoCode = $ order ->getPromoCode ();
265-
266- if ($ promoCode !== null ) {
267- $ builderBasicInformationGroup
268- ->add ('promoCode ' , DisplayOnlyType::class, [
269- 'label ' => 'Promo code ' ,
270- 'data ' => $ promoCode ,
271- ]);
272- }
273-
274116 return $ builderBasicInformationGroup ;
275117 }
276118
@@ -562,20 +404,10 @@ private function createNoteGroup(FormBuilderInterface $builder): FormBuilderInte
562404
563405 private function createWithdrawalRequestGroup (
564406 FormBuilderInterface $ builder ,
565- ?WithdrawalRequest $ withdrawalRequest ,
566407 int $ domainId ,
567408 ): FormBuilderInterface {
568- $ rowAttr = [
569- 'data-withdrawal-request-exists ' => $ withdrawalRequest !== null ? 'true ' : 'false ' ,
570- ];
571-
572- if ($ withdrawalRequest === null ) {
573- $ rowAttr ['style ' ] = 'display: none; ' ;
574- }
575-
576409 $ builderWithdrawalRequestGroup = $ builder ->create ('withdrawalRequestGroup ' , GroupType::class, [
577410 'label ' => 'Withdrawal Request ' ,
578- 'row_attr ' => $ rowAttr ,
579411 ]);
580412
581413 $ builderWithdrawalRequestGroup
0 commit comments