ApplicationService.php
8 months ago
DataModifier.php
4 months ago
DomainService.php
2 years ago
EventListener.php
1 year ago
InfrastructureService.php
4 months ago
Licence.php
3 months ago
DataModifier.php
378 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AmeliaBooking\Infrastructure\Licence\Lite; |
| 4 | |
| 5 | use AmeliaBooking\Infrastructure\WP\InstallActions\ActivationSettingsHook; |
| 6 | |
| 7 | /** |
| 8 | * Class DataModifier |
| 9 | * |
| 10 | * @package AmeliaBooking\Infrastructure\Licence\Lite |
| 11 | */ |
| 12 | class DataModifier |
| 13 | { |
| 14 | /** |
| 15 | * @param array $settings |
| 16 | * @param array $savedSettings |
| 17 | */ |
| 18 | public static function restoreSettings(&$settings, $savedSettings) |
| 19 | { |
| 20 | self::commonRestoreSettings($settings, $savedSettings); |
| 21 | |
| 22 | $settings['general']['serviceDurationAsSlot'] = $savedSettings['general']['serviceDurationAsSlot']; |
| 23 | |
| 24 | $settings['general']['bufferTimeInSlot'] = $savedSettings['general']['bufferTimeInSlot']; |
| 25 | |
| 26 | $settings['general']['minimumTimeRequirementPriorToBooking'] = $savedSettings['general']['minimumTimeRequirementPriorToBooking']; |
| 27 | |
| 28 | $settings['general']['minimumTimeRequirementPriorToCanceling'] = $savedSettings['general']['minimumTimeRequirementPriorToCanceling']; |
| 29 | |
| 30 | $settings['general']['minimumTimeRequirementPriorToRescheduling'] = $savedSettings['general']['minimumTimeRequirementPriorToRescheduling']; |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * @param array $settings |
| 35 | * @param array $savedSettings |
| 36 | */ |
| 37 | public static function commonRestoreSettings(&$settings, $savedSettings) |
| 38 | { |
| 39 | $settings['payments']['stripe']['enabled'] = $savedSettings['payments']['stripe']['enabled']; |
| 40 | |
| 41 | $settings['payments']['payPal']['enabled'] = $savedSettings['payments']['payPal']['enabled']; |
| 42 | |
| 43 | $settings['payments']['razorpay']['enabled'] = $savedSettings['payments']['razorpay']['enabled']; |
| 44 | |
| 45 | $settings['payments']['mollie']['enabled'] = $savedSettings['payments']['mollie']['enabled']; |
| 46 | |
| 47 | $settings['payments']['wc']['enabled'] = $savedSettings['payments']['wc']['enabled']; |
| 48 | |
| 49 | $settings['payments']['paymentLinks']['enabled'] = $savedSettings['payments']['paymentLinks']['enabled']; |
| 50 | |
| 51 | $settings['roles']['limitPerCustomerService']['enabled'] = $savedSettings['roles']['limitPerCustomerService']['enabled']; |
| 52 | |
| 53 | $settings['roles']['limitPerCustomerPackage']['enabled'] = $savedSettings['roles']['limitPerCustomerPackage']['enabled']; |
| 54 | |
| 55 | $settings['roles']['limitPerCustomerEvent']['enabled'] = $savedSettings['roles']['limitPerCustomerEvent']['enabled']; |
| 56 | |
| 57 | $settings['roles']['limitPerEmployee']['enabled'] = $savedSettings['roles']['limitPerEmployee']['enabled']; |
| 58 | |
| 59 | $settings['roles']['allowCustomerCancelPackages'] = $savedSettings['roles']['allowCustomerCancelPackages']; |
| 60 | |
| 61 | $settings['general']['usedLanguages'] = $savedSettings['general']['usedLanguages']; |
| 62 | |
| 63 | $settings['appointments']['employeeSelection'] = $savedSettings['appointments']['employeeSelection']; |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * @param array $settings |
| 68 | */ |
| 69 | public static function modifySettings(&$settings) |
| 70 | { |
| 71 | $generalSettings = ActivationSettingsHook::getDefaultGeneralSettings($settings); |
| 72 | |
| 73 | |
| 74 | self::commonModifySettings($settings); |
| 75 | |
| 76 | if ($settings && isset($settings['activation'])) { |
| 77 | $settings['activation']['hideUnavailableFeatures'] = false; |
| 78 | } |
| 79 | |
| 80 | if ($settings && isset($settings['general'])) { |
| 81 | $settings['general']['serviceDurationAsSlot'] = $generalSettings['serviceDurationAsSlot']; |
| 82 | |
| 83 | $settings['general']['bufferTimeInSlot'] = $generalSettings['bufferTimeInSlot']; |
| 84 | |
| 85 | $settings['general']['minimumTimeRequirementPriorToBooking'] = $generalSettings['minimumTimeRequirementPriorToBooking']; |
| 86 | |
| 87 | $settings['general']['minimumTimeRequirementPriorToCanceling'] = $generalSettings['minimumTimeRequirementPriorToCanceling']; |
| 88 | |
| 89 | $settings['general']['minimumTimeRequirementPriorToRescheduling'] = $generalSettings['minimumTimeRequirementPriorToRescheduling']; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * @param array $settings |
| 95 | */ |
| 96 | public static function commonModifySettings(&$settings) |
| 97 | { |
| 98 | $rolesSettings = ActivationSettingsHook::getDefaultRolesSettings(); |
| 99 | |
| 100 | $generalSettings = ActivationSettingsHook::getDefaultGeneralSettings($settings); |
| 101 | |
| 102 | $appointmentsSettings = ActivationSettingsHook::getDefaultAppointmentsSettings(); |
| 103 | |
| 104 | $paymentSettings = ActivationSettingsHook::getDefaultPaymentsSettings($settings); |
| 105 | |
| 106 | |
| 107 | if ($settings && isset($settings['payments'])) { |
| 108 | $settings['payments']['stripe']['enabled'] = $paymentSettings['stripe']['enabled']; |
| 109 | |
| 110 | $settings['payments']['payPal']['enabled'] = $paymentSettings['payPal']['enabled']; |
| 111 | |
| 112 | $settings['payments']['razorpay']['enabled'] = $paymentSettings['razorpay']['enabled']; |
| 113 | |
| 114 | $settings['payments']['mollie']['enabled'] = $paymentSettings['mollie']['enabled']; |
| 115 | |
| 116 | $settings['payments']['wc']['enabled'] = $paymentSettings['wc']['enabled']; |
| 117 | |
| 118 | $settings['payments']['paymentLinks']['enabled'] = $paymentSettings['paymentLinks']['enabled']; |
| 119 | } |
| 120 | |
| 121 | if ($settings && isset($settings['roles'])) { |
| 122 | $settings['roles']['limitPerCustomerService']['enabled'] = $rolesSettings['limitPerCustomerService']['enabled']; |
| 123 | |
| 124 | $settings['roles']['limitPerCustomerPackage']['enabled'] = $rolesSettings['limitPerCustomerPackage']['enabled']; |
| 125 | |
| 126 | $settings['roles']['limitPerCustomerEvent']['enabled'] = $rolesSettings['limitPerCustomerEvent']['enabled']; |
| 127 | |
| 128 | $settings['roles']['limitPerEmployee']['enabled'] = $rolesSettings['limitPerEmployee']['enabled']; |
| 129 | |
| 130 | $settings['roles']['allowCustomerCancelPackages'] = false; |
| 131 | } |
| 132 | |
| 133 | if ($settings && isset($settings['general'])) { |
| 134 | $settings['general']['usedLanguages'] = $generalSettings['usedLanguages']; |
| 135 | } |
| 136 | |
| 137 | if ($settings && isset($settings['appointments'])) { |
| 138 | $settings['appointments']['employeeSelection'] = $appointmentsSettings['employeeSelection']; |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * @param array $data |
| 144 | * |
| 145 | * @return array |
| 146 | */ |
| 147 | public static function getUserRepositoryData($data) |
| 148 | { |
| 149 | return [ |
| 150 | 'values' => |
| 151 | [], |
| 152 | 'columns' => |
| 153 | '', |
| 154 | 'placeholders' => |
| 155 | '', |
| 156 | 'columnsPlaceholders' => |
| 157 | '', |
| 158 | ]; |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * @param array $data |
| 163 | * |
| 164 | * @return void |
| 165 | */ |
| 166 | public static function userFactory(&$data) |
| 167 | { |
| 168 | $data['locationId'] = null; |
| 169 | |
| 170 | $data['googleCalendar'] = null; |
| 171 | |
| 172 | $data['outlookCalendar'] = null; |
| 173 | |
| 174 | $data['badgeId'] = null; |
| 175 | |
| 176 | $data['zoomUserId'] = null; |
| 177 | |
| 178 | $data['appleCalendarId'] = null; |
| 179 | |
| 180 | $data['googleCalendarId'] = null; |
| 181 | |
| 182 | $data['outlookCalendarId'] = null; |
| 183 | |
| 184 | $data['translations'] = null; |
| 185 | |
| 186 | $data['timeZone'] = null; |
| 187 | |
| 188 | $data['employeeAppleCalendar'] = null; |
| 189 | |
| 190 | if (!empty($data['serviceList'])) { |
| 191 | foreach ($data['serviceList'] as $key => $value) { |
| 192 | $data['serviceList'][$key]['customPricing'] = null; |
| 193 | } |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | /** |
| 198 | * @param array $data |
| 199 | * |
| 200 | * @return array |
| 201 | */ |
| 202 | public static function getProviderServiceRepositoryData($data) |
| 203 | { |
| 204 | return [ |
| 205 | 'values' => |
| 206 | [], |
| 207 | 'columns' => |
| 208 | '', |
| 209 | 'placeholders' => |
| 210 | '', |
| 211 | 'columnsPlaceholders' => |
| 212 | '', |
| 213 | ]; |
| 214 | } |
| 215 | |
| 216 | /** |
| 217 | * @param array $data |
| 218 | * |
| 219 | * @return void |
| 220 | */ |
| 221 | public static function providerServiceFactory(&$data) |
| 222 | { |
| 223 | } |
| 224 | |
| 225 | /** |
| 226 | * @param array $data |
| 227 | * |
| 228 | * @return array |
| 229 | */ |
| 230 | public static function getPeriodRepositoryData($data) |
| 231 | { |
| 232 | return [ |
| 233 | 'values' => |
| 234 | [], |
| 235 | 'columns' => |
| 236 | '', |
| 237 | 'placeholders' => |
| 238 | '', |
| 239 | 'columnsPlaceholders' => |
| 240 | '', |
| 241 | ]; |
| 242 | } |
| 243 | |
| 244 | /** |
| 245 | * @param array $data |
| 246 | * |
| 247 | * @return void |
| 248 | */ |
| 249 | public static function periodFactory(&$data) |
| 250 | { |
| 251 | $data['locationId'] = null; |
| 252 | |
| 253 | $data['periodLocationList'] = []; |
| 254 | } |
| 255 | |
| 256 | /** |
| 257 | * @param array $data |
| 258 | * |
| 259 | * @return array |
| 260 | */ |
| 261 | public static function getServiceRepositoryData($data) |
| 262 | { |
| 263 | return [ |
| 264 | 'values' => |
| 265 | [], |
| 266 | 'columns' => |
| 267 | '', |
| 268 | 'placeholders' => |
| 269 | '', |
| 270 | 'columnsPlaceholders' => |
| 271 | '', |
| 272 | ]; |
| 273 | } |
| 274 | |
| 275 | /** |
| 276 | * @param array $data |
| 277 | * |
| 278 | * @return void |
| 279 | */ |
| 280 | public static function serviceFactory(&$data) |
| 281 | { |
| 282 | self::commonServiceFactory($data); |
| 283 | |
| 284 | $data['extras'] = []; |
| 285 | |
| 286 | $data['show'] = 1; |
| 287 | |
| 288 | $data['timeAfter'] = 0; |
| 289 | |
| 290 | $data['timeBefore'] = 0; |
| 291 | |
| 292 | $data['minCapacity'] = 1; |
| 293 | |
| 294 | $data['maxCapacity'] = 1; |
| 295 | } |
| 296 | |
| 297 | /** |
| 298 | * @param array $data |
| 299 | * |
| 300 | * @return void |
| 301 | */ |
| 302 | public static function commonServiceFactory(&$data) |
| 303 | { |
| 304 | $data['recurringCycle'] = 'disabled'; |
| 305 | |
| 306 | $data['recurringSub'] = 'future'; |
| 307 | |
| 308 | $data['recurringPayment'] = 0; |
| 309 | |
| 310 | $data['customPricing'] = null; |
| 311 | |
| 312 | $data['limitPerCustomer'] = null; |
| 313 | |
| 314 | $data['deposit'] = 0; |
| 315 | |
| 316 | $data['depositPayment'] = 'disabled'; |
| 317 | |
| 318 | $data['depositPerPerson'] = 1; |
| 319 | |
| 320 | $data['fullPayment'] = 0; |
| 321 | } |
| 322 | |
| 323 | /** |
| 324 | * @param array $data |
| 325 | * |
| 326 | * @return array |
| 327 | */ |
| 328 | public static function getEventRepositoryData($data) |
| 329 | { |
| 330 | return [ |
| 331 | 'values' => |
| 332 | [], |
| 333 | 'addValues' => |
| 334 | [], |
| 335 | 'columns' => |
| 336 | '', |
| 337 | 'placeholders' => |
| 338 | '', |
| 339 | 'columnsPlaceholders' => |
| 340 | '', |
| 341 | ]; |
| 342 | } |
| 343 | |
| 344 | /** |
| 345 | * @param array $data |
| 346 | * |
| 347 | * @return void |
| 348 | */ |
| 349 | public static function eventFactory(&$data) |
| 350 | { |
| 351 | self::commonEventFactory($data); |
| 352 | |
| 353 | $data['tags'] = []; |
| 354 | } |
| 355 | |
| 356 | /** |
| 357 | * @param array $data |
| 358 | * |
| 359 | * @return void |
| 360 | */ |
| 361 | public static function commonEventFactory(&$data) |
| 362 | { |
| 363 | $data['ticketRangeRec'] = 'calculate'; |
| 364 | |
| 365 | $data['deposit'] = 0; |
| 366 | |
| 367 | $data['depositPayment'] = 'disabled'; |
| 368 | |
| 369 | $data['fullPayment'] = 0; |
| 370 | |
| 371 | $data['customPricing'] = 0; |
| 372 | |
| 373 | $data['depositPerPerson'] = 1; |
| 374 | |
| 375 | $data['locationId'] = null; |
| 376 | } |
| 377 | } |
| 378 |