forked from Qloapps/QloApps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdminCustomerPreferencesController.php
204 lines (197 loc) · 9.28 KB
/
AdminCustomerPreferencesController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<?php
/*
* 2007-2017 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2017 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
* @property Configuration $object
*/
class AdminCustomerPreferencesControllerCore extends AdminController
{
public function __construct()
{
$this->bootstrap = true;
$this->className = 'Configuration';
$this->table = 'configuration';
parent::__construct();
$registration_process_type = array(
array(
'value' => PS_REGISTRATION_PROCESS_STANDARD,
'name' => $this->l('Only account creation')
),
array(
'value' => PS_REGISTRATION_PROCESS_AIO,
'name' => $this->l('Standard (account creation and address creation)')
)
);
$this->fields_options = array(
'general' => array(
'title' => $this->l('General'),
'icon' => 'icon-cogs',
'fields' => array(
'PS_REGISTRATION_PROCESS_TYPE' => array(
'title' => $this->l('Registration process type'),
'hint' => $this->l('The "Only account creation" registration option allows the customer to register faster, and create his/her address later.'),
'validation' => 'isInt',
'cast' => 'intval',
'type' => 'select',
'list' => $registration_process_type,
'identifier' => 'value'
),
'PS_ONE_PHONE_AT_LEAST' => array(
'title' => $this->l('Phone number is mandatory'),
'hint' => $this->l('If you chose yes, your customer will have to provide at least one phone number to register.'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
'PS_CART_FOLLOWING' => array(
'title' => $this->l('Re-display cart at login'),
'hint' => $this->l('After a customer logs in, you can recall and display the content of his/her last shopping cart.'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
'PS_CUSTOMER_CREATION_EMAIL' => array(
'title' => $this->l('Send an email after registration'),
'hint' => $this->l('Send an email with summary of the account information (email, password) after registration.'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
'PS_PASSWD_TIME_FRONT' => array(
'title' => $this->l('Password reset delay'),
'hint' => $this->l('Minimum time required between two requests for a password reset.'),
'validation' => 'isUnsignedInt',
'cast' => 'intval',
'size' => 5,
'type' => 'text',
'suffix' => $this->l('minutes'),
'class' => 'fixed-width-xl',
),
'PS_B2B_ENABLE' => array(
'title' => $this->l('Enable B2B mode'),
'hint' => $this->l('Activate or deactivate B2B mode. When this option is enabled, B2B features will be made available.'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
'PS_CUSTOMER_BIRTHDATE' => array(
'title' => $this->l('Enable date of birth'),
'hint' => $this->l('Display or not the date of birth field.'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
'PS_CUSTOMER_NWSL' => array(
'title' => $this->l('Enable newsletter registration'),
'hint' => $this->l('Display or not the newsletter registration tick box.'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
'PS_CUSTOMER_OPTIN' => array(
'title' => $this->l('Enable opt-in'),
'hint' => $this->l('Display or not the opt-in tick box, to receive offers from your hotel partners.'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
),
'submit' => array(
'title' => $this->l('Save'),
),
),
'customer_kpi' => array(
'title' => $this->l('Customer KPI configuration'),
'icon' => 'icon-cogs',
'fields' => array(
'PS_KPI_FREQUENT_CUSTOMER_NB_ORDERS' => array(
'title' => $this->l('Number of orders to use to calculate frequent customers'),
'hint' => $this->l('Set the number of orders to use to calculate frequent customers.'),
'validation' => 'isInt',
'cast' => 'intval',
'type' => 'text',
'class' => 'fixed-width-xxl',
),
'PS_KPI_REVPAC_NB_DAYS' => array(
'title' => $this->l('Number of days to use to calculate RevPAC'),
'hint' => $this->l('Set the number of days to use to calculate Revenue Per Available Customer.'),
'validation' => 'isUnsignedInt',
'cast' => 'intval',
'type' => 'text',
'suffix' => $this->l('days'),
'class' => 'fixed-width-xl',
),
'PS_KPI_CONVERSION_RATE_NB_DAYS' => array(
'title' => $this->l('Number of days to use to calculate Conversion Rate'),
'hint' => $this->l('Set the number of days to use to calculate Conversion Rate.'),
'validation' => 'isUnsignedInt',
'cast' => 'intval',
'type' => 'text',
'suffix' => $this->l('days'),
'class' => 'fixed-width-xl',
),
'PS_KPI_NEW_CUSTOMERS_NB_DAYS' => array(
'title' => $this->l('Number of days for which a customer is considered \'new\''),
'hint' => $this->l('Set the number of days for which a customer is considered \'new\' after creation date.'),
'validation' => 'isUnsignedInt',
'cast' => 'intval',
'type' => 'text',
'suffix' => $this->l('days'),
'class' => 'fixed-width-xl',
),
),
'submit' => array(
'title' => $this->l('Save'),
),
)
);
}
public function beforeUpdateOptions()
{
$fieldData = $this->fields_options['customer_kpi']['fields']['PS_KPI_FREQUENT_CUSTOMER_NB_ORDERS'];
if (!Tools::getValue('PS_KPI_FREQUENT_CUSTOMER_NB_ORDERS')) {
$this->errors[] = sprintf(Tools::displayError('field %s must be greater than 0.'), $fieldData['title']);;
}
}
/**
* Update PS_B2B_ENABLE and enables / disables the associated tabs
* @param $value integer Value of option
*/
public function updateOptionPsB2bEnable($value)
{
$value = (int)$value;
$tabs_class_name = array('AdminOutstanding');
if (!empty($tabs_class_name)) {
foreach ($tabs_class_name as $tab_class_name) {
$tab = Tab::getInstanceFromClassName($tab_class_name);
if (Validate::isLoadedObject($tab)) {
$tab->active = $value;
$tab->save();
}
}
}
Configuration::updateValue('PS_B2B_ENABLE', $value);
}
}