1<?php
2/**
3 * Copyright since 2007 PrestaShop SA and Contributors
4 * PrestaShop is an International Registered Trademark & Property of PrestaShop SA
5 *
6 * NOTICE OF LICENSE
7 *
8 * This source file is subject to the Open Software License (OSL 3.0)
9 * that is bundled with this package in the file LICENSE.md.
10 * It is also available through the world-wide-web at this URL:
11 * https://opensource.org/licenses/OSL-3.0
12 * If you did not receive a copy of the license and are unable to
13 * obtain it through the world-wide-web, please send an email
14 * to license@prestashop.com so we can send you a copy immediately.
15 *
16 * DISCLAIMER
17 *
18 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
19 * versions in the future. If you wish to customize PrestaShop for your
20 * needs please refer to https://devdocs.prestashop.com/ for more information.
21 *
22 * @author    PrestaShop SA and Contributors <contact@prestashop.com>
23 * @copyright Since 2007 PrestaShop SA and Contributors
24 * @license   https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
25 */
26
27namespace PrestaShopBundle\Form\Admin\Configure\ShopParameters\CustomerPreferences;
28
29use PrestaShopBundle\Form\Admin\Type\SwitchType;
30use PrestaShopBundle\Form\Admin\Type\TextWithUnitType;
31use PrestaShopBundle\Form\Admin\Type\TranslatorAwareType;
32use Symfony\Component\Form\FormBuilderInterface;
33use Symfony\Component\OptionsResolver\OptionsResolver;
34use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
35use Symfony\Component\Validator\Constraints\Type;
36
37/**
38 * Class generates "General" form
39 * in "Configure > Shop Parameters > Customer Settings" page.
40 */
41class GeneralType extends TranslatorAwareType
42{
43    public function buildForm(FormBuilderInterface $builder, array $options)
44    {
45        $builder
46            ->add('redisplay_cart_at_login', SwitchType::class, [
47                'label' => $this->trans(
48                    'Re-display cart at login',
49                    'Admin.Shopparameters.Feature'
50                ),
51                'help' => $this->trans(
52                    'After a customer logs in, you can recall and display the content of his/her last shopping cart.',
53                    'Admin.Shopparameters.Help'
54                ),
55            ])
56            ->add('send_email_after_registration', SwitchType::class, [
57                'label' => $this->trans(
58                    'Send an email after registration',
59                    'Admin.Shopparameters.Feature'
60                ),
61                'help' => $this->trans(
62                    'Send an email with a summary of the account information after registration.',
63                    'Admin.Shopparameters.Help'
64                ),
65            ])
66            ->add('password_reset_delay', TextWithUnitType::class, [
67                'label' => $this->trans(
68                    'Password reset delay',
69                    'Admin.Shopparameters.Feature'
70                ),
71                'constraints' => [
72                    new GreaterThanOrEqual(
73                        [
74                            'value' => 0,
75                            'message' => $this->trans('The field is invalid. Please enter a positive integer.', 'Admin.Notifications.Error'),
76                        ]
77                    ),
78                    new Type(
79                        [
80                            'value' => 'numeric',
81                            'message' => $this->trans('The field is invalid. Please enter a positive integer.', 'Admin.Notifications.Error'),
82                        ]
83                    ),
84                ],
85                'help' => $this->trans(
86                    'Minimum time required between two requests for a password reset.',
87                    'Admin.Shopparameters.Help'
88                ),
89                'unit' => $this->trans('minutes', 'Admin.Shopparameters.Feature'),
90            ])
91            ->add('enable_b2b_mode', SwitchType::class, [
92                'label' => $this->trans(
93                    'Enable B2B mode',
94                    'Admin.Shopparameters.Feature'
95                ),
96                'help' => $this->trans(
97                    'Activate or deactivate B2B mode. When this option is enabled, B2B features will be made available.',
98                    'Admin.Shopparameters.Help'
99                ),
100            ])
101            ->add('ask_for_birthday', SwitchType::class, [
102                'label' => $this->trans(
103                    'Ask for birth date',
104                    'Admin.Shopparameters.Feature'
105                ),
106                'help' => $this->trans(
107                    'Display or not the birth date field.',
108                    'Admin.Shopparameters.Help'
109                ),
110            ])
111            ->add('enable_offers', SwitchType::class, [
112                'label' => $this->trans(
113                    'Enable partner offers',
114                    'Admin.Shopparameters.Feature'
115                ),
116                'help' => $this->trans(
117                    'Display or not the partner offers tick box, to receive offers from the store\'s partners.',
118                    'Admin.Shopparameters.Help'
119                ),
120            ]);
121    }
122
123    /**
124     * {@inheritdoc}
125     */
126    public function configureOptions(OptionsResolver $resolver)
127    {
128        $resolver->setDefaults([
129            'translation_domain' => 'Admin.Shopparameters.Feature',
130        ]);
131    }
132
133    /**
134     * {@inheritdoc}
135     */
136    public function getBlockPrefix()
137    {
138        return 'customer_preferences_general_block';
139    }
140}
141