PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.3
Booking for Appointments and Events Calendar – Amelia v2.3
2.4.9 2.4.8 2.4.7 2.4.6 2.4.5 2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / src / Infrastructure / WP / InstallActions / ActivationSettingsHook.php
ameliabooking / src / Infrastructure / WP / InstallActions Last commit date
DB 4 months ago ActivationDatabaseHook.php 8 months ago ActivationMultisite.php 1 year ago ActivationNewSiteMultisite.php 1 year ago ActivationRolesHook.php 1 year ago ActivationSettingsHook.php 4 months ago AutoUpdateHook.php 4 months ago DeleteDatabaseHook.php 1 year ago DeletionMultisite.php 1 year ago
ActivationSettingsHook.php
2664 lines
1 <?php
2
3 /**
4 * Settings hook for activation
5 */
6
7 namespace AmeliaBooking\Infrastructure\WP\InstallActions;
8
9 use AmeliaBooking\Domain\Entity\Entities;
10 use AmeliaBooking\Domain\Services\Settings\SettingsService;
11 use AmeliaBooking\Domain\ValueObjects\String\Token;
12 use AmeliaBooking\Infrastructure\Licence\Licence;
13 use AmeliaBooking\Infrastructure\WP\InstallActions\DB\Booking\EventsTagsTable;
14 use AmeliaBooking\Infrastructure\WP\SettingsService\SettingsStorage;
15 use AmeliaBooking\Infrastructure\WP\PermissionsService\PermissionsChecker;
16 use Exception;
17
18 /**
19 * Class ActivationSettingsHook
20 *
21 * @package AmeliaBooking\Infrastructure\WP\InstallActions
22 */
23 class ActivationSettingsHook
24 {
25 /**
26 * Initialize the plugin
27 *
28 * @throws Exception
29 */
30 public static function init()
31 {
32 self::initDBSettings();
33
34 self::initGeneralSettings();
35
36 self::initCompanySettings();
37
38 self::initNotificationsSettings();
39
40 self::initDaysOffSettings();
41
42 self::initWeekScheduleSettings();
43
44 self::initGoogleCalendarSettings();
45
46 self::initOutlookCalendarSettings();
47
48 self::initPaymentsSettings();
49
50 self::initActivationSettings();
51
52 self::initLabelsSettings();
53
54 self::initRolesSettings();
55
56 self::initAppointmentsSettings();
57
58 self::initWebHooksSettings();
59
60 self::initZoomSettings();
61
62 self::initApiKeySettings();
63
64 self::initLessonSpaceSettings();
65
66 self::initIcsSettings();
67
68 self::initFacebookPixelSettings();
69
70 self::initGoogleAnalyticsSettings();
71
72 self::initGoogleTagSettings();
73
74 self::initMailchimpSettings();
75
76 self::initAppleCalendarSettings();
77
78 self::initPageColumnSettings();
79
80 self::initSocialLoginSettings();
81
82 self::initFeaturesIntegrationsSettings();
83 }
84
85 /**
86 * @param string $category
87 * @param array $settings
88 * @param bool $replace
89 */
90 public static function initSettings($category, $settings, $replace = false)
91 {
92 $settingsService = new SettingsService(new SettingsStorage());
93
94 if (!$settingsService->getCategorySettings($category)) {
95 $settingsService->setCategorySettings(
96 $category,
97 []
98 );
99 }
100
101 foreach ($settings as $key => $value) {
102 if ($replace || null === $settingsService->getSetting($category, $key)) {
103 $settingsService->setSetting(
104 $category,
105 $key,
106 $value
107 );
108 }
109 }
110 }
111
112 /**
113 * Init General Settings
114 *
115 * @param array $savedSettings
116 *
117 * @return array
118 */
119 public static function getDefaultGeneralSettings($savedSettings)
120 {
121 return [
122 'timeSlotLength' => 1800,
123 'serviceDurationAsSlot' => false,
124 'bufferTimeInSlot' => true,
125 'defaultAppointmentStatus' => 'approved',
126 'defaultEventStatus' => 'approved',
127 'minimumTimeRequirementPriorToBooking' => 0,
128 'minimumTimeRequirementPriorToCanceling' => 0,
129 'minimumTimeRequirementPriorToRescheduling' =>
130 isset($savedSettings['minimumTimeRequirementPriorToCanceling']) &&
131 !isset($savedSettings['minimumTimeRequirementPriorToRescheduling']) ?
132 $savedSettings['minimumTimeRequirementPriorToCanceling'] : 0,
133 'numberOfDaysAvailableForBooking' => SettingsService::NUMBER_OF_DAYS_AVAILABLE_FOR_BOOKING,
134 'backendSlotsDaysInFuture' => SettingsService::NUMBER_OF_DAYS_AVAILABLE_FOR_BOOKING,
135 'backendSlotsDaysInPast' => SettingsService::NUMBER_OF_DAYS_AVAILABLE_FOR_BOOKING,
136 'phoneDefaultCountryCode' => 'auto',
137 'ipLocateApiKey' => '',
138 'requiredPhoneNumberField' => false,
139 'requiredEmailField' => true,
140 'itemsPerPage' => 12,
141 'appointmentsPerPage' => 100,
142 'eventsPerPage' => 100,
143 'servicesPerPage' => 100,
144 'customersFilterLimit' => 100,
145 'eventsFilterLimit' => 1000,
146 'calendarEmployeesPreselected' => 0,
147 'gMapApiKey' => '',
148 'addToCalendar' => true,
149 'defaultPageOnBackend' => 'Dashboard',
150 'showClientTimeZone' => false,
151 'redirectUrlAfterAppointment' => '',
152 'customFieldsUploadsPath' => '',
153 'customFieldsAllowedExtensions' => [
154 '.jpg' => 'image/jpeg',
155 '.jpeg' => 'image/jpeg',
156 '.png' => 'image/png',
157 '.mp3' => 'audio/mpeg',
158 '.mpeg' => 'video/mpeg',
159 '.mp4' => 'video/mp4',
160 '.txt' => 'text/plain',
161 '.csv' => 'text/plain',
162 '.xls' => 'application/vnd.ms-excel',
163 '.pdf' => 'application/pdf',
164 '.doc' => 'application/msword',
165 '.docx' => 'application/msword'
166 ],
167 'customFieldsBackendValidation' => false,
168 'runInstantPostBookingActions' => false,
169 'sortingPackages' => 'nameAsc',
170 'sortingServices' => 'nameAsc',
171 'calendarLocaleSubstitutes' => [],
172 'googleRecaptcha' => [
173 'invisible' => true,
174 'siteKey' => '',
175 'secret' => '',
176 ],
177 'usedLanguages' => [],
178 ];
179 }
180
181 /**
182 * Get General Settings
183 */
184 private static function initGeneralSettings()
185 {
186 $settingsService = new SettingsService(new SettingsStorage());
187
188 $savedSettings = $settingsService->getCategorySettings('general');
189
190 $settings = self::getDefaultGeneralSettings($savedSettings);
191
192 $settings['backLink'] = self::getBackLinkSetting();
193
194 self::initSettings('general', $settings);
195
196 self::setNewSettingsToExistingSettings(
197 'general',
198 [
199 ['backLink', 'url'],
200 ],
201 $settings
202 );
203 }
204
205 /**
206 * Init DB Settings
207 */
208 private static function initDBSettings()
209 {
210 self::initSettings('db', [
211 'wpTablesPrefix' => '',
212 ]);
213 }
214
215 /**
216 * Init Company Settings
217 */
218 private static function initCompanySettings()
219 {
220
221 $settings = [
222 'pictureFullPath' => '',
223 'pictureThumbPath' => '',
224 'name' => '',
225 'address' => '',
226 'addressComponents' => [],
227 'countryCode' => '',
228 'phone' => '',
229 'vat' => '',
230 'countryPhoneIso' => '',
231 'website' => '',
232 'translations' => '',
233 ];
234
235 self::initSettings('company', $settings);
236 }
237
238 /**
239 * Get Notification Settings
240 *
241 * @return array
242 */
243 public static function getDefaultNotificationsSettings()
244 {
245 return [
246 'mailService' => '',
247 'smtpHost' => '',
248 'smtpPort' => '',
249 'smtpSecure' => 'ssl',
250 'smtpUsername' => '',
251 'smtpPassword' => '',
252 'mailgunApiKey' => '',
253 'mailgunDomain' => '',
254 'mailgunEndpoint' => '',
255 'senderName' => '',
256 'replyTo' => '',
257 'senderEmail' => '',
258 'sendAllCF' => true,
259 'smsAlphaSenderId' => 'Amelia',
260 'smsSignedIn' => false,
261 'smsApiToken' => '',
262 'bccEmail' => '',
263 'bccSms' => '',
264 'emptyPackageEmployees' => '',
265 'smsBalanceEmail' => ['enabled' => false, 'minimum' => 0, 'email' => ''],
266 'cancelSuccessUrl' => '',
267 'cancelErrorUrl' => '',
268 'approveSuccessUrl' => '',
269 'approveErrorUrl' => '',
270 'rejectSuccessUrl' => '',
271 'rejectErrorUrl' => '',
272 'breakReplacement' => '<br>',
273 'pendingReminder' => false,
274 'sendInvoice' => false,
275 'invoiceFormat' => 'pdf',
276 'whatsAppPhoneID' => '',
277 'whatsAppAccessToken' => '',
278 'whatsAppBusinessID' => '',
279 'whatsAppLanguage' => '',
280 'whatsAppReplyEnabled' => false,
281 'whatsAppReplyMsg' => 'Dear %customer_full_name%,
282 This message does not have an option for responding. If you need additional information about your booking, please contact us at %company_phone%',
283 'whatsAppReplyToken' => (new Token(null, 20))->getValue(),
284 ];
285 }
286
287 /**
288 * Init Notification Settings
289 */
290 private static function initNotificationsSettings()
291 {
292 $settings = self::getDefaultNotificationsSettings();
293
294 self::initSettings('notifications', $settings);
295 }
296
297 /**
298 * Init Days Off Settings
299 */
300 private static function initDaysOffSettings()
301 {
302 self::initSettings('daysOff', []);
303 }
304
305 /**
306 * Init Work Schedule Settings
307 */
308 private static function initWeekScheduleSettings()
309 {
310 self::initSettings(
311 'weekSchedule',
312 [
313 [
314 'day' => 'Monday',
315 'time' => ['09:00', '17:00'],
316 'breaks' => [],
317 'periods' => []
318 ],
319 [
320 'day' => 'Tuesday',
321 'time' => ['09:00', '17:00'],
322 'breaks' => [],
323 'periods' => []
324 ],
325 [
326 'day' => 'Wednesday',
327 'time' => ['09:00', '17:00'],
328 'breaks' => [],
329 'periods' => []
330 ],
331 [
332 'day' => 'Thursday',
333 'time' => ['09:00', '17:00'],
334 'breaks' => [],
335 'periods' => []
336 ],
337 [
338 'day' => 'Friday',
339 'time' => ['09:00', '17:00'],
340 'breaks' => [],
341 'periods' => []
342 ],
343 [
344 'day' => 'Saturday',
345 'time' => [],
346 'breaks' => [],
347 'periods' => []
348 ],
349 [
350 'day' => 'Sunday',
351 'time' => [],
352 'breaks' => [],
353 'periods' => []
354 ]
355 ]
356 );
357 }
358
359 /**
360 * Init Google Calendar Settings
361 */
362 private static function initGoogleCalendarSettings()
363 {
364 $settingsService = new SettingsService(new SettingsStorage());
365
366 $savedSettings = $settingsService->getCategorySettings('googleCalendar');
367
368 $settings = [
369 'clientID' => '',
370 'clientSecret' => '',
371 'redirectURI' => AMELIA_SITE_URL . '/wp-admin/admin.php?page=wpamelia-employees',
372 'showAttendees' => false,
373 'insertPendingAppointments' => false,
374 'addAttendees' => false,
375 'sendEventInvitationEmail' => false,
376 'removeGoogleCalendarBusySlots' => false,
377 'maximumNumberOfEventsReturned' => 50,
378 'eventTitle' => '%service_name%',
379 'eventDescription' => '',
380 'includeBufferTimeGoogleCalendar' => false,
381 'status' => 'tentative',
382 'enableGoogleMeet' => false,
383 'title' => [
384 'appointment' => $savedSettings && !empty($savedSettings['eventTitle']) ?
385 $savedSettings['eventTitle'] : '%service_name%',
386 'event' => '%event_name%'
387 ],
388 'description' => [
389 'appointment' => $savedSettings && !empty($savedSettings['eventDescription']) ?
390 $savedSettings['eventDescription'] : '',
391 'event' => ''
392 ],
393 'accessToken' => '',
394 'googleAccountData' => null
395 ];
396
397 self::initSettings('googleCalendar', $settings);
398 }
399
400 /**
401 * Init Outlook Calendar Settings
402 */
403 private static function initOutlookCalendarSettings()
404 {
405 $settingsService = new SettingsService(new SettingsStorage());
406
407 $savedSettings = $settingsService->getCategorySettings('outlookCalendar');
408
409 $settings = [
410 'clientID' => '',
411 'clientSecret' => '',
412 'redirectURI' => AMELIA_SITE_URL . '/wp-admin/',
413 'insertPendingAppointments' => false,
414 'addAttendees' => false,
415 'sendEventInvitationEmail' => false,
416 'removeOutlookCalendarBusySlots' => false,
417 'maximumNumberOfEventsReturned' => 50,
418 'ignoreAmeliaEvents' => false,
419 'eventTitle' => '%service_name%',
420 'eventDescription' => '',
421 'includeBufferTimeOutlookCalendar' => false,
422 'enableMicrosoftTeams' => false,
423 'title' => [
424 'appointment' => $savedSettings && !empty($savedSettings['eventTitle']) ?
425 $savedSettings['eventTitle'] : '%service_name%',
426 'event' => '%event_name%'
427 ],
428 'description' => [
429 'appointment' => $savedSettings && !empty($savedSettings['eventDescription']) ?
430 $savedSettings['eventDescription'] : '',
431 'event' => ''
432 ],
433 'mailEnabled' => false,
434 'token' => null,
435 'accessToken' => '',
436 'outlookAccountData' => null
437 ];
438
439 self::initSettings('outlookCalendar', $settings);
440 }
441
442 /**
443 * Init Apple Calendar Settings
444 */
445 private static function initAppleCalendarSettings()
446 {
447 $settings = [
448 'clientID' => '',
449 'clientSecret' => '',
450 'redirectURI' => AMELIA_SITE_URL . '/wp-admin/admin.php?page=wpamelia-employees',
451 'insertPendingAppointments' => false,
452 'addAttendees' => false,
453 'removeAppleCalendarBusySlots' => false,
454 'eventTitle' => '%service_name%',
455 'eventDescription' => '',
456 'includeBufferTimeAppleCalendar' => false,
457 'title' => [
458 'appointment' => '%service_name%',
459 'event' => '%event_name%'
460 ],
461 'description' => [
462 'appointment' => '',
463 'event' => ''
464 ],
465 ];
466
467 self::initSettings('appleCalendar', $settings);
468 }
469
470 /**
471 * Init Zoom Settings
472 */
473 private static function initZoomSettings()
474 {
475 $settings = [
476 'enabled' => true,
477 'apiKey' => '',
478 'apiSecret' => '',
479 'meetingTitle' => '%reservation_name%',
480 'meetingAgenda' => '%reservation_description%',
481 'pendingAppointmentsMeetings' => false,
482 's2sEnabled' => true,
483 'accountId' => '',
484 'clientId' => '',
485 'clientSecret' => '',
486 'accessToken' => '',
487 ];
488
489 self::initSettings('zoom', $settings);
490 }
491
492
493 /**
494 * Init Api Key Settings
495 */
496 private static function initApiKeySettings()
497 {
498 $settings = [
499 'apiKeys' => []
500 ];
501
502 self::initSettings('apiKeys', $settings);
503 }
504
505 /**
506 * Init Lesson Space Settings
507 */
508 private static function initLessonSpaceSettings()
509 {
510 $settings = [
511 'apiKey' => '',
512 'spaceNameAppointments' => '%reservation_name%',
513 'spaceNameEvents' => '%reservation_name%',
514 'pendingAppointments' => false,
515 'companyId' => ''
516 ];
517
518 self::initSettings('lessonSpace', $settings);
519 }
520
521 /**
522 * Init FacebookPixel Settings
523 */
524 private static function initFacebookPixelSettings()
525 {
526 $settings = [
527 'id' => '',
528 'tracking' => [
529 'appointment' => [],
530 'event' => [],
531 'package' => [],
532 ],
533 ];
534
535 self::initSettings('facebookPixel', $settings);
536 }
537
538 /**
539 * Init Google Analytics Settings
540 */
541 private static function initGoogleAnalyticsSettings()
542 {
543 $settings = [
544 'id' => '',
545 'tracking' => [
546 'appointment' => [],
547 'event' => [],
548 'package' => [],
549 ],
550 ];
551
552 self::initSettings('googleAnalytics', $settings);
553 }
554
555 /**
556 * Init GoogleTag Settings
557 */
558 private static function initGoogleTagSettings()
559 {
560 $settings = [
561 'id' => '',
562 'tracking' => [
563 'appointment' => [],
564 'event' => [],
565 'package' => [],
566 ],
567 ];
568
569 self::initSettings('googleTag', $settings);
570 }
571
572
573 /**
574 * Init Mailchimp Settings
575 */
576 private static function initMailchimpSettings()
577 {
578 $settings = [
579 'accessToken' => null,
580 'server' => null,
581 'list' => null,
582 'checkedByDefault' => false
583 ];
584
585 self::initSettings('mailchimp', $settings);
586 }
587
588 /**
589 * Init Page Column Settings
590 */
591 private static function initPageColumnSettings()
592 {
593 $settings = self::getDefaultPageColumnSettings();
594
595 self::initSettings('pageColumnSettings', $settings);
596
597 // Handle updates to existing page column settings
598 self::updatePageColumnSettings($settings);
599 }
600
601 /**
602 * Get Default Page Column Settings
603 *
604 * @return array
605 */
606 public static function getDefaultPageColumnSettings()
607 {
608 return [
609 "customersPage" => [
610 [
611 "prop" => "id",
612 "visible" => true,
613 "width" => 80,
614 "label" => "id",
615 "sortable" => false
616 ],
617 [
618 "prop" => "name",
619 "visible" => true,
620 "width" => 320,
621 "label" => "name",
622 "sortable" => true,
623 "required" => true
624 ],
625 [
626 "prop" => "phone",
627 "visible" => true,
628 "width" => 160,
629 "label" => "phone",
630 "sortable" => false
631 ],
632 [
633 "prop" => "email",
634 "visible" => true,
635 "width" => 240,
636 "label" => "email",
637 "sortable" => false
638 ],
639 [
640 "prop" => "note",
641 "visible" => true,
642 "width" => 80,
643 "label" => "note",
644 "sortable" => false
645 ],
646 [
647 "prop" => "lastBooking",
648 "visible" => true,
649 "width" => 240,
650 "label" => "last_booking",
651 "sortable" => false
652 ],
653 [
654 "prop" => "totalBookings",
655 "visible" => true,
656 "width" => 160,
657 "label" => "total_bookings",
658 "sortable" => false
659 ],
660 [
661 "prop" => "wordPressUser",
662 "visible" => true,
663 "width" => 240,
664 "label" => "wp_user",
665 "sortable" => false
666 ]
667 ],
668
669 "employeesPage" => [
670 [
671 "prop" => "id",
672 "visible" => true,
673 "width" => 80,
674 "label" => "id",
675 "sortable" => false
676 ],
677 [
678 "prop" => "name",
679 "visible" => true,
680 "width" => 320,
681 "label" => "name",
682 "sortable" => true,
683 "required" => true
684 ],
685 [
686 "prop" => "status",
687 "visible" => true,
688 "width" => 160,
689 "label" => "visibility",
690 "sortable" => false
691 ],
692 [
693 "prop" => "availability",
694 "visible" => true,
695 "width" => 160,
696 "label" => "red_availability",
697 "sortable" => false
698 ],
699 [
700 "prop" => "phone",
701 "visible" => true,
702 "width" => 160,
703 "label" => "phone",
704 "sortable" => false
705 ],
706 [
707 "prop" => "email",
708 "visible" => true,
709 "width" => 240,
710 "label" => "email",
711 "sortable" => false
712 ],
713 [
714 "prop" => "actions",
715 "visible" => true,
716 "width" => 240,
717 "label" => "red_actions",
718 "sortable" => false
719 ],
720 ],
721
722 "locationsPage" => [
723 [
724 "prop" => "id",
725 "visible" => true,
726 "width" => 80,
727 "label" => "id",
728 "sortable" => false
729 ],
730 [
731 "prop" => "name",
732 "visible" => true,
733 "width" => 320,
734 "label" => "name",
735 "sortable" => true,
736 "required" => true
737 ],
738 [
739 "prop" => "address",
740 "visible" => true,
741 "width" => 320,
742 "label" => "address",
743 "sortable" => false
744 ],
745 [
746 "prop" => "phone",
747 "visible" => true,
748 "width" => 160,
749 "label" => "phone",
750 "sortable" => false
751 ],
752 [
753 "prop" => "status",
754 "visible" => true,
755 "width" => 160,
756 "label" => "visibility",
757 "sortable" => false
758 ]
759 ],
760
761 "bookingsAppointmentsPage" => [
762 [
763 "prop" => "id",
764 "visible" => true,
765 "width" => 80,
766 "label" => "id",
767 "sortable" => true
768 ],
769 [
770 "prop" => "date",
771 "visible" => true,
772 "width" => 160,
773 "label" => "date",
774 "sortable" => false,
775 "required" => true
776 ],
777 [
778 "prop" => "time",
779 "visible" => true,
780 "width" => 160,
781 "label" => "time",
782 "sortable" => false,
783 "required" => true
784 ],
785 [
786 "prop" => "customer",
787 "visible" => true,
788 "width" => 320,
789 "label" => "customer",
790 "sortable" => true,
791 "required" => true
792 ],
793 [
794 "prop" => "service",
795 "visible" => true,
796 "width" => 240,
797 "label" => "service",
798 "sortable" => true,
799 "required" => true
800 ],
801 [
802 "prop" => "type",
803 "visible" => true,
804 "width" => 160,
805 "label" => "type",
806 "sortable" => false
807 ],
808 [
809 "prop" => "status",
810 "visible" => true,
811 "width" => 200,
812 "label" => "status",
813 "sortable" => false
814 ],
815 [
816 "prop" => "employee",
817 "visible" => true,
818 "width" => 320,
819 "label" => "employee",
820 "sortable" => false
821 ],
822 [
823 "prop" => "location",
824 "visible" => true,
825 "width" => 240,
826 "label" => "location",
827 "sortable" => false
828 ],
829 [
830 "prop" => "duration",
831 "visible" => false,
832 "width" => 160,
833 "label" => "duration",
834 "sortable" => false
835 ],
836 [
837 "prop" => "customerEmail",
838 "visible" => false,
839 "width" => 240,
840 "label" => "customer_email",
841 "sortable" => false
842 ],
843 [
844 "prop" => "customerPhone",
845 "visible" => false,
846 "width" => 240,
847 "label" => "customer_phone",
848 "sortable" => false
849 ],
850 [
851 "prop" => "booked",
852 "visible" => false,
853 "width" => 80,
854 "label" => "booked",
855 "sortable" => false
856 ],
857 [
858 "prop" => "note",
859 "visible" => false,
860 "width" => 80,
861 "label" => "note",
862 "sortable" => false
863 ],
864 [
865 "prop" => "paidPrice",
866 "visible" => false,
867 "width" => 160,
868 "label" => "paid",
869 "sortable" => false
870 ],
871 [
872 "prop" => "payment",
873 "visible" => false,
874 "width" => 160,
875 "label" => "payment",
876 "sortable" => false
877 ],
878 [
879 "prop" => "totalPrice",
880 "visible" => false,
881 "width" => 160,
882 "label" => "total_price",
883 "sortable" => false
884 ],
885 [
886 "prop" => "hostLink",
887 "visible" => false,
888 "width" => 160,
889 "label" => "red_host_link",
890 "sortable" => false
891 ],
892 [
893 "prop" => "joinLink",
894 "visible" => false,
895 "width" => 200,
896 "label" => "red_join_link",
897 "sortable" => false
898 ],
899 [
900 "prop" => "created",
901 "visible" => false,
902 "width" => 160,
903 "label" => "created_on",
904 "sortable" => true,
905 "required" => false
906 ],
907 [
908 "prop" => "bookingSource",
909 "visible" => false,
910 "width" => 64,
911 "label" => "red_booking_source",
912 "sortable" => false,
913 "showLabel" => false
914 ],
915 ],
916
917 "bookingsPackagesPage" => [
918 [
919 "prop" => "id",
920 "visible" => true,
921 "width" => 80,
922 "label" => "id",
923 "sortable" => true
924 ],
925 [
926 "prop" => "date",
927 "visible" => true,
928 "width" => 160,
929 "label" => "package_date_purchased",
930 "sortable" => true
931 ],
932 [
933 "prop" => "customer",
934 "visible" => true,
935 "width" => 320,
936 "label" => "customer",
937 "sortable" => true,
938 "required" => true
939 ],
940 [
941 "prop" => "package",
942 "visible" => true,
943 "width" => 320,
944 "label" => "package",
945 "sortable" => true,
946 "required" => true
947 ],
948 [
949 "prop" => "status",
950 "visible" => true,
951 "width" => 200,
952 "label" => "status",
953 "sortable" => false
954 ],
955 [
956 "prop" => "appointments",
957 "visible" => true,
958 "width" => 160,
959 "label" => "appointments",
960 "sortable" => false
961 ],
962 [
963 "prop" => "employees",
964 "visible" => true,
965 "width" => 320,
966 "label" => "employees",
967 "sortable" => false
968 ],
969 [
970 "prop" => "expirationDate",
971 "visible" => false,
972 "width" => 240,
973 "label" => "expiration_date",
974 "sortable" => false
975 ],
976 [
977 "prop" => "price",
978 "visible" => false,
979 "width" => 160,
980 "label" => "price",
981 "sortable" => false
982 ],
983 [
984 "prop" => "paymentStatus",
985 "visible" => false,
986 "width" => 200,
987 "label" => "payment_status",
988 "sortable" => false
989 ]
990 ],
991
992 "bookingsEventsPage" => [
993 [
994 "prop" => "code",
995 "visible" => true,
996 "width" => 120,
997 "label" => "code",
998 "sortable" => false
999 ],
1000 [
1001 "prop" => "date",
1002 "visible" => true,
1003 "width" => 160,
1004 "label" => "date",
1005 "sortable" => false
1006 ],
1007 [
1008 "prop" => "time",
1009 "visible" => true,
1010 "width" => 160,
1011 "label" => "time",
1012 "sortable" => false
1013 ],
1014 [
1015 "prop" => "attendee",
1016 "visible" => true,
1017 "width" => 240,
1018 "label" => "attendee",
1019 "sortable" => true,
1020 "required" => true
1021 ],
1022 [
1023 "prop" => "event",
1024 "visible" => true,
1025 "width" => 320,
1026 "label" => "event",
1027 "sortable" => true,
1028 "required" => true
1029 ],
1030 [
1031 "prop" => "status",
1032 "visible" => true,
1033 "width" => 200,
1034 "label" => "status",
1035 "sortable" => false
1036 ],
1037 [
1038 "prop" => "spots",
1039 "visible" => true,
1040 "width" => 80,
1041 "label" => "red_booked",
1042 "sortable" => false
1043 ],
1044 [
1045 "prop" => "organizer",
1046 "visible" => false,
1047 "width" => 240,
1048 "label" => "event_organizer",
1049 "sortable" => false
1050 ],
1051 [
1052 "prop" => "staff",
1053 "visible" => false,
1054 "width" => 240,
1055 "label" => "event_staff",
1056 "sortable" => false
1057 ],
1058 [
1059 "prop" => "price",
1060 "visible" => false,
1061 "width" => 160,
1062 "label" => "price",
1063 "sortable" => false
1064 ],
1065 [
1066 "prop" => "paymentStatus",
1067 "visible" => false,
1068 "width" => 200,
1069 "label" => "payment_status",
1070 "sortable" => false
1071 ],
1072 [
1073 "prop" => "created",
1074 "visible" => false,
1075 "width" => 160,
1076 "label" => "created_on",
1077 "sortable" => true,
1078 "required" => false
1079 ],
1080 ],
1081
1082 "eventsPage" => [
1083 [
1084 "prop" => "id",
1085 "visible" => true,
1086 "width" => 80,
1087 "label" => "id",
1088 "sortable" => true
1089 ],
1090 [
1091 "prop" => "dateTime",
1092 "visible" => true,
1093 "width" => 240,
1094 "label" => "date_time",
1095 "sortable" => true,
1096 "required" => true
1097 ],
1098 [
1099 "prop" => "name",
1100 "visible" => true,
1101 "width" => 320,
1102 "label" => "name",
1103 "sortable" => true,
1104 "required" => true
1105 ],
1106 [
1107 "prop" => "status",
1108 "visible" => true,
1109 "width" => 200,
1110 "label" => "status",
1111 "sortable" => false
1112 ],
1113 [
1114 "prop" => "spots",
1115 "visible" => true,
1116 "width" => 80,
1117 "label" => "red_booked",
1118 "sortable" => false
1119 ],
1120 [
1121 "prop" => "organizer",
1122 "visible" => true,
1123 "width" => 240,
1124 "label" => "event_organizer",
1125 "sortable" => false
1126 ],
1127 [
1128 "prop" => "staff",
1129 "visible" => true,
1130 "width" => 240,
1131 "label" => "event_staff",
1132 "sortable" => false
1133 ],
1134 [
1135 "prop" => "recurring",
1136 "visible" => true,
1137 "width" => 120,
1138 "label" => "recurring",
1139 "sortable" => false
1140 ],
1141 [
1142 "prop" => "waitingList",
1143 "visible" => true,
1144 "width" => 200,
1145 "label" => "waiting_list",
1146 "sortable" => false
1147 ],
1148 [
1149 "prop" => "bookingOpens",
1150 "visible" => true,
1151 "width" => 240,
1152 "label" => "red_booking_opens",
1153 "sortable" => true
1154 ],
1155 [
1156 "prop" => "bookingCloses",
1157 "visible" => true,
1158 "width" => 240,
1159 "label" => "red_booking_closes",
1160 "sortable" => true
1161 ],
1162 [
1163 "prop" => "visibility",
1164 "visible" => true,
1165 "width" => 160,
1166 "label" => "visibility",
1167 "sortable" => false
1168 ],
1169 ],
1170
1171 "catalogServicesPage" => [
1172 [
1173 "prop" => "id",
1174 "visible" => true,
1175 "width" => 80,
1176 "label" => "id",
1177 "sortable" => true
1178 ],
1179 [
1180 "prop" => "service",
1181 "visible" => true,
1182 "width" => 320,
1183 "label" => "service",
1184 "sortable" => true,
1185 "required" => true
1186 ],
1187 [
1188 "prop" => "duration",
1189 "visible" => true,
1190 "width" => 160,
1191 "label" => "duration",
1192 "sortable" => true
1193 ],
1194 [
1195 "prop" => "price",
1196 "visible" => true,
1197 "width" => 160,
1198 "label" => "price",
1199 "sortable" => true
1200 ],
1201 [
1202 "prop" => "employees",
1203 "visible" => true,
1204 "width" => 320,
1205 "label" => "employees",
1206 "sortable" => false
1207 ],
1208 [
1209 "prop" => "visibility",
1210 "visible" => true,
1211 "width" => 160,
1212 "label" => "visibility",
1213 "sortable" => false
1214 ],
1215 ],
1216
1217 "catalogPackagesPage" => [
1218 [
1219 "prop" => "id",
1220 "visible" => true,
1221 "width" => 80,
1222 "label" => "id",
1223 "sortable" => true
1224 ],
1225 [
1226 "prop" => "name",
1227 "visible" => true,
1228 "width" => 320,
1229 "label" => "name",
1230 "sortable" => true,
1231 "required" => true
1232 ],
1233 [
1234 "prop" => "services",
1235 "visible" => true,
1236 "width" => 200,
1237 "label" => "services",
1238 "sortable" => true
1239 ],
1240 [
1241 "prop" => "price",
1242 "visible" => true,
1243 "width" => 160,
1244 "label" => "price",
1245 "sortable" => true
1246 ],
1247 [
1248 "prop" => "duration",
1249 "visible" => true,
1250 "width" => 160,
1251 "label" => "duration",
1252 "sortable" => false
1253 ],
1254 [
1255 "prop" => "employees",
1256 "visible" => true,
1257 "width" => 320,
1258 "label" => "employees",
1259 "sortable" => false
1260 ],
1261 [
1262 "prop" => "status",
1263 "visible" => true,
1264 "width" => 160,
1265 "label" => "visibility",
1266 "sortable" => false
1267 ]
1268 ],
1269
1270 "catalogResourcesPage" => [
1271 [
1272 "prop" => "id",
1273 "visible" => true,
1274 "width" => 80,
1275 "label" => "id",
1276 "sortable" => true
1277 ],
1278 [
1279 "prop" => "name",
1280 "visible" => true,
1281 "width" => 320,
1282 "label" => "name",
1283 "sortable" => true,
1284 "required" => true
1285 ],
1286 [
1287 "prop" => "quantity",
1288 "visible" => true,
1289 "width" => 160,
1290 "label" => "quantity",
1291 "sortable" => true
1292 ],
1293 [
1294 "prop" => "services",
1295 "visible" => true,
1296 "width" => 320,
1297 "label" => "services",
1298 "sortable" => false
1299 ],
1300 [
1301 "prop" => "locations",
1302 "visible" => true,
1303 "width" => 320,
1304 "label" => "locations",
1305 "sortable" => false
1306 ],
1307 [
1308 "prop" => "employees",
1309 "visible" => true,
1310 "width" => 320,
1311 "label" => "employees",
1312 "sortable" => false
1313 ],
1314 [
1315 "prop" => "type",
1316 "visible" => true,
1317 "width" => 200,
1318 "label" => "type",
1319 "sortable" => false
1320 ],
1321 [
1322 "prop" => "status",
1323 "visible" => true,
1324 "width" => 160,
1325 "label" => "visibility",
1326 "sortable" => false
1327 ]
1328 ],
1329
1330 "financePaymentsPage" => [
1331 [
1332 "prop" => "id",
1333 "visible" => true,
1334 "width" => 80,
1335 "label" => "id",
1336 "sortable" => true
1337 ],
1338 [
1339 "prop" => "dateTime",
1340 "visible" => true,
1341 "width" => 160,
1342 "label" => "payment_date",
1343 "sortable" => true
1344 ],
1345 [
1346 "prop" => "customer",
1347 "visible" => true,
1348 "width" => 240,
1349 "label" => "customer",
1350 "sortable" => false,
1351 "required" => true
1352 ],
1353 [
1354 "prop" => "employees",
1355 "visible" => true,
1356 "width" => 240,
1357 "label" => "employees",
1358 "sortable" => false
1359 ],
1360 [
1361 "prop" => "booking",
1362 "visible" => true,
1363 "width" => 320,
1364 "label" => "booking",
1365 "sortable" => false
1366 ],
1367 [
1368 "prop" => "status",
1369 "visible" => true,
1370 "width" => 160,
1371 "label" => "status",
1372 "sortable" => true
1373 ],
1374 [
1375 "prop" => "amount",
1376 "visible" => true,
1377 "width" => 160,
1378 "label" => "amount",
1379 "sortable" => true,
1380 "required" => true
1381 ],
1382 [
1383 "prop" => "payment_method",
1384 "visible" => true,
1385 "width" => 160,
1386 "label" => "payment_method",
1387 "sortable" => false
1388 ],
1389 [
1390 "prop" => "location",
1391 "visible" => true,
1392 "width" => 320,
1393 "label" => "location",
1394 "sortable" => false
1395 ],
1396 ],
1397 "financeCouponsPage" => [
1398 [
1399 "prop" => "code",
1400 "visible" => true,
1401 "width" => 120,
1402 "label" => "code",
1403 "sortable" => false,
1404 "required" => true
1405 ],
1406 [
1407 "prop" => "discount",
1408 "visible" => true,
1409 "width" => 120,
1410 "label" => "discount_amount",
1411 "sortable" => true,
1412 "required" => true
1413 ],
1414 [
1415 "prop" => "deduction",
1416 "visible" => true,
1417 "width" => 120,
1418 "label" => "deduction",
1419 "sortable" => true
1420 ],
1421 [
1422 "prop" => "status",
1423 "visible" => true,
1424 "width" => 160,
1425 "label" => "visibility",
1426 "sortable" => false
1427 ],
1428 [
1429 "prop" => "start_date",
1430 "visible" => true,
1431 "width" => 240,
1432 "label" => "start_date",
1433 "sortable" => false
1434 ],
1435 [
1436 "prop" => "expiration_date",
1437 "visible" => true,
1438 "width" => 240,
1439 "label" => "expiration_date",
1440 "sortable" => false
1441 ],
1442 [
1443 "prop" => "service",
1444 "visible" => true,
1445 "width" => 320,
1446 "label" => "services",
1447 "sortable" => false
1448 ],
1449 [
1450 "prop" => "event",
1451 "visible" => true,
1452 "width" => 320,
1453 "label" => "events",
1454 "sortable" => false
1455 ],
1456 [
1457 "prop" => "package",
1458 "visible" => true,
1459 "width" => 320,
1460 "label" => "packages",
1461 "sortable" => false
1462 ],
1463 [
1464 "prop" => "usage_limit",
1465 "visible" => false,
1466 "width" => 120,
1467 "label" => "usage_limit",
1468 "sortable" => false
1469 ],
1470 [
1471 "prop" => "limit_per_customer",
1472 "visible" => false,
1473 "width" => 120,
1474 "label" => "red_limit_per_customer",
1475 "sortable" => false
1476 ],
1477 [
1478 "prop" => "times_used",
1479 "visible" => false,
1480 "width" => 120,
1481 "label" => "times_used",
1482 "sortable" => true
1483 ],
1484 ],
1485 "financeTaxesPage" => [
1486 [
1487 "prop" => "name",
1488 "visible" => true,
1489 "width" => 240,
1490 "label" => "name",
1491 "sortable" => true,
1492 "required" => true
1493 ],
1494 [
1495 "prop" => "type",
1496 "visible" => true,
1497 "width" => 120,
1498 "label" => "type",
1499 "sortable" => true
1500 ],
1501 [
1502 "prop" => "rate",
1503 "visible" => true,
1504 "width" => 80,
1505 "label" => "rate",
1506 "required" => true
1507 ],
1508 [
1509 "prop" => "status",
1510 "visible" => true,
1511 "width" => 160,
1512 "label" => "visibility",
1513 "sortable" => false
1514 ],
1515 [
1516 "prop" => "service",
1517 "visible" => true,
1518 "width" => 320,
1519 "label" => "services",
1520 "sortable" => false
1521 ],
1522 [
1523 "prop" => "event",
1524 "visible" => true,
1525 "width" => 320,
1526 "label" => "events",
1527 "sortable" => false
1528 ],
1529 [
1530 "prop" => "package",
1531 "visible" => true,
1532 "width" => 320,
1533 "label" => "packages",
1534 "sortable" => false
1535 ],
1536 [
1537 "prop" => "extra",
1538 "visible" => true,
1539 "width" => 320,
1540 "label" => "extras",
1541 "sortable" => false
1542 ],
1543
1544 ],
1545 "financeInvoicesPage" => [
1546 [
1547 "prop" => "invoiceNumber",
1548 "visible" => true,
1549 "width" => 160,
1550 "label" => "red_invoice_number",
1551 "sortable" => true,
1552 "required" => true
1553 ],
1554 [
1555 "prop" => "customer",
1556 "visible" => true,
1557 "width" => 240,
1558 "label" => "customer",
1559 "sortable" => false,
1560 "required" => true
1561 ],
1562 [
1563 "prop" => "dateTime",
1564 "visible" => true,
1565 "width" => 160,
1566 "label" => "red_invoice_date",
1567 "sortable" => true
1568 ],
1569 [
1570 "prop" => "employees",
1571 "visible" => true,
1572 "width" => 240,
1573 "label" => "employees",
1574 "sortable" => false
1575 ],
1576 [
1577 "prop" => "booking",
1578 "visible" => true,
1579 "width" => 320,
1580 "label" => "booking",
1581 "sortable" => false
1582 ],
1583 [
1584 "prop" => "status",
1585 "visible" => true,
1586 "width" => 160,
1587 "label" => "status",
1588 "sortable" => true
1589 ],
1590 [
1591 "prop" => "amount",
1592 "visible" => true,
1593 "width" => 160,
1594 "label" => "total",
1595 "sortable" => false
1596 ],
1597 ],
1598 ];
1599 }
1600
1601 /**
1602 * Update Page Column Settings for existing installations
1603 *
1604 * @param array $defaultSettings
1605 */
1606 private static function updatePageColumnSettings($defaultSettings)
1607 {
1608 $settingsService = new SettingsService(new SettingsStorage());
1609 $savedSettings = $settingsService->getCategorySettings('pageColumnSettings');
1610
1611 // If no saved settings exist, nothing to update
1612 if (!$savedSettings) {
1613 return;
1614 }
1615
1616 $needsUpdate = false;
1617 $updatedSettings = $savedSettings;
1618
1619 foreach ($defaultSettings as $pageKey => $defaultColumns) {
1620 // If page doesn't exist in saved settings, add it
1621 if (!isset($savedSettings[$pageKey])) {
1622 $updatedSettings[$pageKey] = $defaultColumns;
1623 $needsUpdate = true;
1624 continue;
1625 }
1626
1627 // Create a map of existing columns by prop for easy lookup, preserving user customizations
1628 $existingColumnsByProp = [];
1629 foreach ($savedSettings[$pageKey] as $column) {
1630 if (isset($column['prop'])) {
1631 $existingColumnsByProp[$column['prop']] = $column;
1632 }
1633 }
1634
1635 // Rebuild the columns array in the default order, preserving user customizations
1636 $mergedColumns = [];
1637 $addedColumns = [];
1638
1639 // First, add columns in the default order
1640 foreach ($defaultColumns as $defaultColumn) {
1641 if (isset($existingColumnsByProp[$defaultColumn['prop']])) {
1642 // Use existing column but merge missing properties from defaults
1643 $existingColumn = $existingColumnsByProp[$defaultColumn['prop']];
1644
1645 // Check if any properties from default are missing or different in existing column
1646 $columnNeedsUpdate = false;
1647 foreach ($defaultColumn as $key => $value) {
1648 if (!isset($existingColumn[$key])) {
1649 // Add missing property
1650 $existingColumn[$key] = $value;
1651 $columnNeedsUpdate = true;
1652 } elseif ($key === 'label' && $existingColumn[$key] !== $value) {
1653 // Update label if it has changed in defaults
1654 $existingColumn[$key] = $value;
1655 $columnNeedsUpdate = true;
1656 } elseif ($key === 'sortable' && $existingColumn[$key] !== $value) {
1657 // Update sortable if it has changed in defaults
1658 $existingColumn[$key] = $value;
1659 $columnNeedsUpdate = true;
1660 }
1661 }
1662
1663 if ($columnNeedsUpdate) {
1664 $needsUpdate = true;
1665 }
1666
1667 $mergedColumns[] = $existingColumn;
1668 $addedColumns[] = $defaultColumn['prop'];
1669 } else {
1670 // Add new column from defaults
1671 $mergedColumns[] = $defaultColumn;
1672 $addedColumns[] = $defaultColumn['prop'];
1673 $needsUpdate = true;
1674 }
1675 }
1676
1677 // Then, add any existing columns that are not in defaults (user-added columns)
1678 foreach ($existingColumnsByProp as $prop => $column) {
1679 if (!in_array($prop, $addedColumns)) {
1680 $mergedColumns[] = $column;
1681 }
1682 }
1683
1684 // Check if the order or content changed
1685 if ($mergedColumns !== $savedSettings[$pageKey]) {
1686 $updatedSettings[$pageKey] = $mergedColumns;
1687 $needsUpdate = true;
1688 }
1689 }
1690
1691 // Save updated settings if changes were made
1692 if ($needsUpdate) {
1693 $settingsService->setCategorySettings('pageColumnSettings', $updatedSettings);
1694 }
1695 }
1696
1697
1698 /**
1699 * Init Ics Settings
1700 */
1701 private static function initIcsSettings()
1702 {
1703 $settingsService = new SettingsService(new SettingsStorage());
1704
1705 $savedSettings = $settingsService->getCategorySettings('general');
1706
1707 $settings = [
1708 'sendIcsAttachment' => isset($savedSettings['sendIcsAttachment']) ? $savedSettings['sendIcsAttachment'] : false,
1709 'sendIcsAttachmentPending' => false,
1710 'description' => [
1711 'appointment' => '',
1712 'event' => '',
1713 'translations' => [
1714 'appointment' => null,
1715 'event' => null,
1716 ],
1717 ],
1718 ];
1719
1720 self::initSettings('ics', $settings);
1721 }
1722
1723 /**
1724 * Get Payments Settings
1725 *
1726 * @param array $savedSettings
1727 *
1728 * @return array
1729 */
1730 public static function getDefaultPaymentsSettings($savedSettings)
1731 {
1732 return [
1733 'currency' => 'USD',
1734 'symbol' => '$',
1735 'priceSymbolPosition' => 'before',
1736 'priceNumberOfDecimals' => 2,
1737 'priceSeparator' => 1,
1738 'hideCurrencySymbolFrontend' => false,
1739 'defaultPaymentMethod' => 'onSite',
1740 'onSite' => true,
1741 'couponsCaseInsensitive' => false,
1742 'paymentLinks' => [
1743 'enabled' => false,
1744 'changeBookingStatus' => false,
1745 'redirectUrl' => AMELIA_SITE_URL
1746 ],
1747 'taxes' => [
1748 'excluded' => true,
1749 ],
1750 'payPal' => [
1751 'enabled' => false,
1752 'sandboxMode' => false,
1753 'liveApiClientId' => '',
1754 'liveApiSecret' => '',
1755 'testApiClientId' => '',
1756 'testApiSecret' => '',
1757 'description' => [
1758 'enabled' => false,
1759 'appointment' => '',
1760 'package' => '',
1761 'event' => '',
1762 'cart' => '',
1763 ],
1764 ],
1765 'stripe' => [
1766 'enabled' => false,
1767 'testMode' => false,
1768 'livePublishableKey' => '',
1769 'liveSecretKey' => '',
1770 'testPublishableKey' => '',
1771 'testSecretKey' => '',
1772 'address' => false,
1773 'description' => [
1774 'enabled' => false,
1775 'appointment' => '',
1776 'package' => '',
1777 'event' => '',
1778 'cart' => '',
1779 ],
1780 'metaData' => [
1781 'enabled' => false,
1782 'appointment' => null,
1783 'package' => null,
1784 'event' => null,
1785 'cart' => '',
1786 ],
1787 'manualCapture' => false,
1788 'returnUrl' => '',
1789 'connect' => [
1790 'enabled' => false,
1791 'method' => 'transfer',
1792 'amount' => 0,
1793 'type' => 'percentage',
1794 'capabilities' => ['card_payments', 'transfers'],
1795 ],
1796 ],
1797 'wc' => [
1798 'enabled' => false,
1799 'productId' => '',
1800 'onSiteIfFree' => false,
1801 'page' => 'cart',
1802 'dashboard' => true,
1803 'checkoutData' => [
1804 'appointment' => '',
1805 'package' => '',
1806 'event' => '',
1807 'cart' => '',
1808 'translations' => [
1809 'appointment' => null,
1810 'event' => null,
1811 'package' => null,
1812 'cart' => '',
1813 ],
1814 ],
1815 'skipCheckoutGetValueProcessing' => isset($savedSettings['wc']['skipCheckoutGetValueProcessing']) ?
1816 $savedSettings['wc']['skipCheckoutGetValueProcessing'] : true,
1817 'skipGetItemDataProcessing' => !isset($savedSettings['wc']),
1818 'redirectPage' => 1,
1819 'bookMultiple' => false,
1820 'rules' =>
1821 isset($savedSettings['wc']['rules']) ? $savedSettings['wc']['rules'] : [
1822 'appointment' => [
1823 [
1824 'order' => 'pending',
1825 'booking' => 'pending',
1826 'payment' => 'pending',
1827 'update' => false,
1828 ],
1829 [
1830 'order' => 'on-hold',
1831 'booking' => 'default',
1832 'payment' => 'paid',
1833 'update' => true,
1834 ],
1835 [
1836 'order' => 'processing',
1837 'booking' => 'default',
1838 'payment' => 'paid',
1839 'update' => true,
1840 ],
1841 [
1842 'order' => 'completed',
1843 'booking' => 'default',
1844 'payment' => 'paid',
1845 'update' => true,
1846 ],
1847 [
1848 'order' => 'cancelled',
1849 'booking' => 'canceled',
1850 'payment' => 'pending',
1851 'update' => true,
1852 ],
1853 [
1854 'order' => 'failed',
1855 'booking' => 'canceled',
1856 'payment' => 'pending',
1857 'update' => true,
1858 ],
1859 ],
1860 'package' => [
1861 [
1862 'order' => 'on-hold',
1863 'booking' => 'approved',
1864 'payment' => 'paid',
1865 'update' => true,
1866 ],
1867 [
1868 'order' => 'processing',
1869 'booking' => 'approved',
1870 'payment' => 'paid',
1871 'update' => true,
1872 ],
1873 [
1874 'order' => 'completed',
1875 'booking' => 'approved',
1876 'payment' => 'paid',
1877 'update' => true,
1878 ],
1879 [
1880 'order' => 'cancelled',
1881 'booking' => 'canceled',
1882 'payment' => 'pending',
1883 'update' => true,
1884 ],
1885 [
1886 'order' => 'failed',
1887 'booking' => 'canceled',
1888 'payment' => 'pending',
1889 'update' => true,
1890 ],
1891 ],
1892 'event' => [
1893 [
1894 'order' => 'pending',
1895 'booking' => 'pending',
1896 'payment' => 'pending',
1897 'update' => false,
1898 ],
1899 [
1900 'order' => 'on-hold',
1901 'booking' => 'approved',
1902 'payment' => 'paid',
1903 'update' => true,
1904 ],
1905 [
1906 'order' => 'processing',
1907 'booking' => 'approved',
1908 'payment' => 'paid',
1909 'update' => true,
1910 ],
1911 [
1912 'order' => 'completed',
1913 'booking' => 'approved',
1914 'payment' => 'paid',
1915 'update' => true,
1916 ],
1917 [
1918 'order' => 'cancelled',
1919 'booking' => 'canceled',
1920 'payment' => 'pending',
1921 'update' => true,
1922 ],
1923 [
1924 'order' => 'failed',
1925 'booking' => 'canceled',
1926 'payment' => 'pending',
1927 'update' => true,
1928 ],
1929 ],
1930 ],
1931 ],
1932 'mollie' => [
1933 'enabled' => false,
1934 'testMode' => false,
1935 'liveApiKey' => '',
1936 'testApiKey' => '',
1937 'description' => [
1938 'enabled' => false,
1939 'appointment' => '',
1940 'package' => '',
1941 'event' => '',
1942 'cart' => '',
1943 ],
1944 'metaData' => [
1945 'enabled' => false,
1946 'appointment' => null,
1947 'package' => null,
1948 'event' => null,
1949 'cart' => '',
1950 ],
1951 'method' => [],
1952 'cancelBooking' => false
1953 ],
1954 'razorpay' => [
1955 'enabled' => false,
1956 'testMode' => false,
1957 'liveKeyId' => '',
1958 'liveKeySecret' => '',
1959 'testKeyId' => '',
1960 'testKeySecret' => '',
1961 'description' => [
1962 'enabled' => false,
1963 'appointment' => '',
1964 'package' => '',
1965 'event' => '',
1966 'cart' => '',
1967 ],
1968 'name' => [
1969 'enabled' => false,
1970 'appointment' => '',
1971 'package' => '',
1972 'event' => '',
1973 'cart' => '',
1974 ],
1975 'metaData' => [
1976 'enabled' => false,
1977 'appointment' => null,
1978 'package' => null,
1979 'event' => null,
1980 'cart' => '',
1981 ],
1982 ],
1983 'square' => [
1984 'enabled' => false,
1985 'locationId' => '',
1986 'accessToken' => '',
1987 'testMode' => false,
1988 'clientLiveId' => 'sq0idp-TtDyGP_2RfKYpFzrDqs0lw',
1989 'clientTestId' => 'sandbox-sq0idb-Wxnxasx1NMG_ZyvM--JV4Q',
1990 'countryCode' => '',
1991 'description' => [
1992 'enabled' => false,
1993 'appointment' => '',
1994 'package' => '',
1995 'event' => '',
1996 'cart' => ''
1997 ],
1998 'metaData' => [
1999 'enabled' => false,
2000 'appointment' => null,
2001 'package' => null,
2002 'event' => null,
2003 'cart' => null
2004 ],
2005 ],
2006 'barion' => [
2007 'enabled' => false,
2008 'sandboxMode' => false,
2009 'livePOSKey' => '',
2010 'sandboxPOSKey' => '',
2011 'payeeEmail' => '',
2012 'description' => [
2013 'enabled' => false,
2014 'appointment' => '',
2015 'package' => '',
2016 'event' => '',
2017 'cart' => '',
2018 ],
2019 'metaData' => [
2020 'enabled' => false,
2021 'appointment' => null,
2022 'package' => null,
2023 'event' => null,
2024 'cart' => null
2025 ],
2026 ],
2027 ];
2028 }
2029
2030 /**
2031 * Init Payments Settings
2032 */
2033 private static function initPaymentsSettings()
2034 {
2035 $settingsService = new SettingsService(new SettingsStorage());
2036
2037 $savedSettings = $settingsService->getCategorySettings('payments');
2038
2039 $settings = self::getDefaultPaymentsSettings($savedSettings);
2040
2041 self::initSettings('payments', $settings);
2042
2043 self::setNewSettingsToExistingSettings(
2044 'payments',
2045 [
2046 ['stripe', 'connect'],
2047 ['stripe', 'connect', 'capabilities'],
2048 ['stripe', 'description'],
2049 ['stripe', 'description', 'package'],
2050 ['stripe', 'description', 'cart'],
2051 ['stripe', 'metaData'],
2052 ['stripe', 'metaData', 'package'],
2053 ['stripe', 'metaData', 'cart'],
2054 ['stripe', 'manualCapture'],
2055 ['stripe', 'returnUrl'],
2056 ['stripe', 'address'],
2057 ['payPal', 'description'],
2058 ['payPal', 'description', 'package'],
2059 ['payPal', 'description', 'cart'],
2060 ['wc', 'onSiteIfFree'],
2061 ['wc', 'page'],
2062 ['wc', 'dashboard'],
2063 ['wc', 'skipCheckoutGetValueProcessing'],
2064 ['wc', 'skipGetItemDataProcessing'],
2065 ['wc', 'rules'],
2066 ['wc', 'redirectPage'],
2067 ['wc', 'bookMultiple'],
2068 ['wc', 'checkoutData'],
2069 ['wc', 'checkoutData', 'package'],
2070 ['wc', 'checkoutData', 'cart'],
2071 ['wc', 'checkoutData', 'translations'],
2072 ['wc', 'checkoutData', 'translations', 'appointment'],
2073 ['wc', 'checkoutData', 'translations', 'event'],
2074 ['wc', 'checkoutData', 'translations', 'package'],
2075 ['wc', 'checkoutData', 'translations', 'cart'],
2076 ['razorpay', 'name'],
2077 ['razorpay', 'description', 'cart'],
2078 ['razorpay', 'metaData', 'cart'],
2079 ['razorpay', 'name', 'cart'],
2080 ['mollie', 'description', 'cart'],
2081 ['mollie', 'metaData', 'cart'],
2082 ['mollie', 'cancelBooking'],
2083 ['square', 'enabled'],
2084 ['square', 'description', 'cart'],
2085 ['square', 'metaData', 'cart'],
2086 ['square', 'locationId'],
2087 ['square', 'accessToken'],
2088 ['square', 'testMode'],
2089 ['square', 'clientLiveId'],
2090 ['square', 'clientTestId'],
2091 ['square', 'countryCode'],
2092 ['barion', 'metaData'],
2093 ],
2094 $settings
2095 );
2096 }
2097
2098 /**
2099 * Init Purchase Code Settings
2100 */
2101 private static function initActivationSettings()
2102 {
2103 $settingsService = new SettingsService(new SettingsStorage());
2104
2105 $savedSettings = $settingsService->getCategorySettings('activation');
2106
2107 $isNewInstallation = empty($savedSettings);
2108
2109 $settings = [
2110 'showActivationSettings' => true,
2111 'active' => false,
2112 'purchaseCodeStore' => '',
2113 'envatoTokenEmail' => '',
2114 'version' => '',
2115 'deleteTables' => false,
2116 'showAmeliaPromoCustomizePopup' => true,
2117 'showAmeliaSurvey' => true,
2118 'showWelcomePage' => true,
2119 'stash' => false,
2120 'responseErrorAsConflict' => $savedSettings ? false : true,
2121 'hideTipsAndSuggestions' => false,
2122 'hideUnavailableFeatures' => false,
2123 'licence' => '',
2124 'disableUrlParams' => $savedSettings ? false : true,
2125 'enableThriveItems' => false,
2126 'customUrl' => [
2127 'enabled' => false,
2128 'pluginPath' => '/wp-content/plugins/ameliabooking/',
2129 'ajaxPath' => '/wp-admin/admin-ajax.php',
2130 'uploadsPath' => '',
2131 ],
2132 'v3RelativePath' => false,
2133 'v3AsyncLoading' => false,
2134 'premiumBannerVisibility' => true,
2135 'dismissibleBannerVisibility' => true,
2136 ];
2137
2138 self::initSettings('activation', $settings);
2139
2140 $savedSettings['showAmeliaPromoCustomizePopup'] = true;
2141
2142 $savedSettings['isNewInstallation'] = $isNewInstallation;
2143
2144 self::initSettings('activation', $savedSettings, true);
2145 }
2146
2147 /**
2148 * Init Labels Settings
2149 */
2150 private static function initLabelsSettings()
2151 {
2152 $settings = [
2153 'enabled' => true,
2154 'employee' => 'employee',
2155 'employees' => 'employees',
2156 'service' => 'service',
2157 'services' => 'services'
2158 ];
2159
2160 self::initSettings('labels', $settings);
2161 }
2162
2163 /**
2164 * Init Roles Settings
2165 *
2166 * @return array
2167 */
2168 public static function getDefaultRolesSettings()
2169 {
2170 $permissionChecker = new PermissionsChecker();
2171
2172 return [
2173 'allowConfigureSchedule' => false,
2174 'allowConfigureDaysOff' => false,
2175 'allowConfigureSpecialDays' => false,
2176 'allowConfigureServices' => false,
2177 'allowWriteAppointments' => false,
2178 'allowWriteCustomers' => false,
2179 'allowReadAllCustomers' => $permissionChecker->hasCapability(
2180 Entities::PROVIDER,
2181 'amelia_read_others_customers'
2182 ),
2183 'automaticallyCreateCustomer' => false,
2184 'inspectCustomerInfo' => false,
2185 'allowCustomerReschedule' => false,
2186 'allowCustomerCancelPackages' => true,
2187 'allowCustomerDeleteProfile' => false,
2188 'allowWriteEvents' => false,
2189 'allowAdminBookAtAnyTime' => false,
2190 'allowAdminBookOverApp' => false,
2191 'adminServiceDurationAsSlot' => false,
2192 'enabledHttpAuthorization' => true,
2193 'customerCabinet' => [
2194 'headerJwtSecret' => (new Token(null, 20))->getValue(),
2195 'urlJwtSecret' => (new Token(null, 20))->getValue(),
2196 'tokenValidTime' => 2592000,
2197 'pageUrl' => '',
2198 'loginEnabled' => true,
2199 'filterDate' => false,
2200 'translations' => [],
2201 'googleRecaptcha' => false,
2202 ],
2203 'providerCabinet' => [
2204 'headerJwtSecret' => (new Token(null, 20))->getValue(),
2205 'urlJwtSecret' => (new Token(null, 20))->getValue(),
2206 'tokenValidTime' => 2592000,
2207 'pageUrl' => '',
2208 'loginEnabled' => true,
2209 'filterDate' => false,
2210 'googleRecaptcha' => false,
2211 ],
2212 'urlAttachment' => [
2213 'enabled' => true,
2214 'headerJwtSecret' => (new Token(null, 20))->getValue(),
2215 'urlJwtSecret' => (new Token(null, 20))->getValue(),
2216 'tokenValidTime' => 2592000,
2217 'pageUrl' => '',
2218 'loginEnabled' => true,
2219 'filterDate' => false,
2220 ],
2221 'limitPerCustomerService' => [
2222 'enabled' => false,
2223 'numberOfApp' => 1,
2224 'timeFrame' => 'day',
2225 'period' => 1,
2226 'from' => 'bookingDate'
2227 ],
2228 'limitPerCustomerPackage' => [
2229 'enabled' => false,
2230 'numberOfApp' => 1,
2231 'timeFrame' => 'day',
2232 'period' => 1,
2233 ],
2234 'limitPerCustomerEvent' => [
2235 'enabled' => false,
2236 'numberOfApp' => 1,
2237 'timeFrame' => 'day',
2238 'period' => 1,
2239 'from' => 'bookingDate'
2240 ],
2241 'limitPerEmployee' => [
2242 'enabled' => false,
2243 'numberOfApp' => 1,
2244 'timeFrame' => 'day',
2245 'period' => 1,
2246 ],
2247 'providerBadges' => [
2248 'counter' => 3,
2249 'badges' => [
2250 [
2251 'id' => 1,
2252 'content' => 'Most Popular',
2253 'color' => '#316bff'
2254 ],
2255 [
2256 'id' => 2,
2257 'content' => 'Top Performer',
2258 'color' => '#06a192'
2259 ],
2260 [
2261 'id' => 3,
2262 'content' => 'Exclusive',
2263 'color' => '#facc15'
2264 ],
2265 ]
2266 ],
2267 ];
2268 }
2269
2270 /**
2271 * Init Roles Settings
2272 */
2273 private static function initRolesSettings()
2274 {
2275 $settings = self::getDefaultRolesSettings();
2276
2277 self::initSettings('roles', $settings);
2278
2279 self::setNewSettingsToExistingSettings(
2280 'roles',
2281 [
2282 ['customerCabinet', 'filterDate'],
2283 ['customerCabinet', 'translations'],
2284 ['customerCabinet', 'headerJwtSecret'],
2285 ['customerCabinet', 'urlJwtSecret'],
2286 ['customerCabinet', 'googleRecaptcha'],
2287 ['providerCabinet', 'headerJwtSecret'],
2288 ['providerCabinet', 'urlJwtSecret'],
2289 ['providerCabinet', 'googleRecaptcha'],
2290 ['urlAttachment', 'headerJwtSecret'],
2291 ['urlAttachment', 'urlJwtSecret'],
2292 ],
2293 $settings
2294 );
2295 }
2296
2297 /**
2298 * Get Appointments Settings
2299 *
2300 * @return array
2301 */
2302 public static function getDefaultAppointmentsSettings()
2303 {
2304 return [
2305 'isGloballyBusySlot' => false,
2306 'bookMultipleTimes' => false,
2307 'allowBookingIfPending' => true,
2308 'allowBookingIfNotMin' => true,
2309 'openedBookingAfterMin' => false,
2310 'cartPlaceholders' => '<!-- Content --><p>DateTime: %appointment_date_time%</p>',
2311 'cartPlaceholdersSms' => 'DateTime: %appointment_date_time%',
2312 'cartPlaceholdersCustomer' => '<!-- Content --><p>DateTime: %appointment_date_time%</p>',
2313 'cartPlaceholdersCustomerSms' => 'DateTime: %appointment_date_time%',
2314 'recurringPlaceholders' => 'DateTime: %appointment_date_time%',
2315 'recurringPlaceholdersSms' => 'DateTime: %appointment_date_time%',
2316 'recurringPlaceholdersCustomer' => 'DateTime: %appointment_date_time%',
2317 'recurringPlaceholdersCustomerSms' => 'DateTime: %appointment_date_time%',
2318 'packagePlaceholders' => 'DateTime: %appointment_date_time%',
2319 'packagePlaceholdersSms' => 'DateTime: %appointment_date_time%',
2320 'packagePlaceholdersCustomer' => 'DateTime: %appointment_date_time%',
2321 'packagePlaceholdersCustomerSms' => 'DateTime: %appointment_date_time%',
2322 'groupAppointmentPlaceholder' => 'Name: %customer_full_name%',
2323 'groupEventPlaceholder' => 'Name: %customer_full_name%',
2324 'groupAppointmentPlaceholderSms' => 'Name: %customer_full_name%',
2325 'groupEventPlaceholderSms' => 'Name: %customer_full_name%',
2326 'translations' => [
2327 'cartPlaceholdersCustomer' => null,
2328 'cartPlaceholdersCustomerSms' => null,
2329 'recurringPlaceholdersCustomer' => null,
2330 'recurringPlaceholdersCustomerSms' => null,
2331 'packagePlaceholdersCustomer' => null,
2332 'packagePlaceholdersCustomerSms' => null,
2333 'groupAppointmentPlaceholder' => 'Name: %customer_full_name%',
2334 'groupEventPlaceholder' => 'Name: %customer_full_name%',
2335 'groupAppointmentPlaceholderSms' => 'Name: %customer_full_name%',
2336 'groupEventPlaceholderSms' => 'Name: %customer_full_name%',
2337 ],
2338 'waitingListEvents' => [
2339 'addingMethod' => 'Manually'
2340 ],
2341 'qrCodeEvents' => [
2342 'enabled' => false,
2343 ],
2344 'waitingListAppointments' => [
2345 'enabled' => false,
2346 'redirectUrlDenied' => ''
2347 ],
2348 'pastDaysEvents' => 0,
2349 'employeeSelection' => 'random',
2350 'bringingAnyoneLogic' => 'additional',
2351 ];
2352 }
2353
2354 /**
2355 * Init Appointments Settings
2356 */
2357 private static function initAppointmentsSettings()
2358 {
2359 $settings = self::getDefaultAppointmentsSettings();
2360
2361 self::initSettings('appointments', $settings);
2362
2363 self::setNewSettingsToExistingSettings(
2364 'appointments',
2365 [
2366 ['translations', 'cartPlaceholdersCustomer'],
2367 ['translations', 'cartPlaceholdersCustomerSms'],
2368 ],
2369 $settings
2370 );
2371 }
2372
2373 /**
2374 * Init Web Hooks Settings
2375 */
2376 private static function initWebHooksSettings()
2377 {
2378 $settings = [];
2379
2380 self::initSettings('webHooks', $settings);
2381 }
2382
2383 /**
2384 * get Back Link Setting
2385 */
2386 private static function getBackLinkSetting()
2387 {
2388 $settingsService = new SettingsService(new SettingsStorage());
2389
2390 $backLinksLabels = [
2391 'Generated with Amelia - WordPress Booking Plugin',
2392 'Powered by Amelia - WordPress Booking Plugin',
2393 'Booking by Amelia - WordPress Booking Plugin',
2394 'Powered by Amelia - Appointment and Events Booking Plugin',
2395 'Powered by Amelia - Appointment and Event Booking Plugin',
2396 'Powered by Amelia - WordPress Booking Plugin',
2397 'Generated with Amelia - Appointment and Event Booking Plugin',
2398 'Booking Enabled by Amelia - Appointment and Event Booking Plugin',
2399 ];
2400
2401 $backLinksUrls = [
2402 'https://wpamelia.com/?utm_source=lite&utm_medium=websites&utm_campaign=powerdby',
2403 'https://wpamelia.com/demos/?utm_source=lite&utm_medium=website&utm_campaign=powerdby#Features-list',
2404 'https://wpamelia.com/pricing/?utm_source=lite&utm_medium=website&utm_campaign=powerdby',
2405 'https://wpamelia.com/documentation/?utm_source=lite&utm_medium=website&utm_campaign=powerdby',
2406 ];
2407
2408 return [
2409 'enabled' => $settingsService->getCategorySettings('general') === null,
2410 'label' => $backLinksLabels[rand(0, 7)],
2411 'url' => $backLinksUrls[rand(0, 3)],
2412 ];
2413 }
2414
2415 /**
2416 * Add new settings ti global parent settings
2417 *
2418 * @param string $category
2419 * @param array $pathsKeys
2420 * @param array $initSettings
2421 */
2422 private static function setNewSettingsToExistingSettings($category, $pathsKeys, $initSettings)
2423 {
2424 $settingsService = new SettingsService(new SettingsStorage());
2425
2426 $savedSettings = $settingsService->getCategorySettings($category);
2427
2428 $activationSettings = $settingsService->getCategorySettings('activation');
2429 $savedVersion = !empty($activationSettings['version']) ? $activationSettings['version'] : '0.0.0';
2430
2431 $setSettings = false;
2432
2433 foreach ($pathsKeys as $keys) {
2434 $current = &$savedSettings;
2435
2436 $currentInit = &$initSettings;
2437
2438 foreach ((array)$keys as $key) {
2439 if (!isset($current[$key])) {
2440 $current[$key] = !empty($currentInit[$key]) ? $currentInit[$key] : null;
2441
2442 $setSettings = true;
2443
2444 continue 2;
2445 }
2446
2447 // If the saved value is a JSON-encoded string but the new schema expects
2448 // a nested array (i.e. there are more keys to traverse), decode it so
2449 // that subsequent keys can be accessed without a PHP 8 TypeError.
2450 // This fix is only applied when upgrading from versions before 9.2
2451 if (version_compare($savedVersion, '9.2', '<') && is_string($current[$key])) {
2452 $decoded = json_decode($current[$key], true);
2453 if (is_array($decoded)) {
2454 $current[$key] = $decoded;
2455 $setSettings = true;
2456 } else {
2457 // Scalar string with no deeper path possible — skip this path.
2458 continue 2;
2459 }
2460 } elseif (!is_array($current[$key])) {
2461 // Boolean / int leaf where a nested array is expected — skip.
2462 continue 2;
2463 }
2464
2465 $current = &$current[$key];
2466
2467 $currentInit = &$currentInit[$key];
2468 }
2469 }
2470
2471 if ($setSettings) {
2472 self::initSettings($category, $savedSettings, true);
2473 }
2474 }
2475
2476 /**
2477 * Init Social Login Settings
2478 */
2479 private static function initSocialLoginSettings()
2480 {
2481 $settings = [
2482 'facebookAppId' => '',
2483 'facebookAppSecret' => '',
2484 ];
2485
2486 self::initSettings('socialLogin', $settings);
2487 }
2488
2489 /**
2490 * Init Features and Integrations Settings
2491 */
2492 private static function initFeaturesIntegrationsSettings()
2493 {
2494 $settingsService = new SettingsService(new SettingsStorage());
2495
2496 $saved = $settingsService->getAllSettingsCategorized();
2497
2498 $old = empty($saved['activation']['isNewInstallation']);
2499
2500 $starterAndUp = Licence::getLicence() === 'Developer' ||
2501 Licence::getLicence() === 'Pro' ||
2502 Licence::getLicence() === 'Basic' ||
2503 Licence::getLicence() === 'Starter';
2504
2505 $basicAndUp = Licence::getLicence() === 'Developer' || Licence::getLicence() === 'Pro' || Licence::getLicence() === 'Basic';
2506
2507 $proAndUp = Licence::getLicence() === 'Developer' || Licence::getLicence() === 'Pro';
2508
2509 $settings = [
2510 'googleCalendar' => [
2511 'enabled' => $old &&
2512 $basicAndUp &&
2513 !empty($saved['googleCalendar']['calendarEnabled']),
2514 ],
2515 'appleCalendar' => [
2516 'enabled' => $old &&
2517 $basicAndUp &&
2518 !empty($saved['appleCalendar']['clientID']) &&
2519 !empty($saved['appleCalendar']['clientSecret']),
2520 ],
2521 'outlookCalendar' => [
2522 'enabled' => $old &&
2523 $basicAndUp &&
2524 !empty($saved['outlookCalendar']['calendarEnabled']),
2525 ],
2526 'zoom' => [
2527 'enabled' => $old &&
2528 $basicAndUp &&
2529 !empty($saved['zoom']['accountId']) &&
2530 !empty($saved['zoom']['clientId']) &&
2531 !empty($saved['zoom']['clientSecret']),
2532 ],
2533 'webhooks' => [
2534 'enabled' => $basicAndUp,
2535 ],
2536 'facebookPixel' => [
2537 'enabled' => $old && $starterAndUp && !empty($saved['facebookPixel']['id']),
2538 ],
2539 'googleAnalytics' => [
2540 'enabled' => $old && $starterAndUp && !empty($saved['googleAnalytics']['id']),
2541 ],
2542 'lessonSpace' => [
2543 'enabled' => $old && $starterAndUp && !empty($saved['lessonSpace']['apiKey']),
2544 ],
2545 'recaptcha' => [
2546 'enabled' => $old &&
2547 $starterAndUp &&
2548 !empty($saved['general']['googleRecaptcha']['enabled']) &&
2549 !empty($saved['general']['googleRecaptcha']['siteKey']) &&
2550 !empty($saved['general']['googleRecaptcha']['secret']),
2551 ],
2552 'mollie' => [
2553 'enabled' => $old && $basicAndUp && !empty($saved['payments']['mollie']['enabled']),
2554 ],
2555 'wc' => [
2556 'enabled' => $old && $basicAndUp && !empty($saved['payments']['wc']['enabled']),
2557 ],
2558 'payPal' => [
2559 'enabled' => $old && $basicAndUp && !empty($saved['payments']['payPal']['enabled']),
2560 ],
2561 'stripe' => [
2562 'enabled' => $old && $basicAndUp && !empty($saved['payments']['stripe']['enabled']),
2563 ],
2564 'razorpay' => [
2565 'enabled' => $old && $basicAndUp && !empty($saved['payments']['razorpay']['enabled']),
2566 ],
2567 'square' => [
2568 'enabled' => $old && !empty($saved['payments']['square']['enabled']),
2569 ],
2570 'barion' => [
2571 'enabled' => $old && $basicAndUp && !empty($saved['payments']['barion']['enabled']),
2572 ],
2573 'packages' => [
2574 'enabled' => $proAndUp,
2575 ],
2576 'resources' => [
2577 'enabled' => $proAndUp,
2578 ],
2579 'customFields' => [
2580 'enabled' => $basicAndUp,
2581 ],
2582 'coupons' => [
2583 'enabled' => $old && $starterAndUp && !empty($saved['payments']['coupons']),
2584 ],
2585 'customNotifications' => [
2586 'enabled' => $basicAndUp,
2587 ],
2588 'tax' => [
2589 'enabled' => $basicAndUp && (!$old || !empty($saved['payments']['taxes']['enabled'])),
2590 ],
2591 'invoices' => [
2592 'enabled' => $basicAndUp,
2593 ],
2594 'whatsapp' => [
2595 'enabled' => $old &&
2596 $proAndUp &&
2597 !empty($saved['notifications']['whatsAppEnabled']) &&
2598 !empty($saved['notifications']['whatsAppPhoneID']) &&
2599 !empty($saved['notifications']['whatsAppAccessToken']) &&
2600 !empty($saved['notifications']['whatsAppBusinessID']),
2601 ],
2602 'recurringEvents' => [
2603 'enabled' => $basicAndUp,
2604 ],
2605 'tickets' => [
2606 'enabled' => $basicAndUp,
2607 ],
2608 'waitingList' => [
2609 'enabled' => $proAndUp && (!$old || !empty($saved['appointments']['waitingListEvents']['enabled'])),
2610 ],
2611 'waitingListAppointments' => [
2612 'enabled' => $proAndUp && (!$old || !empty($saved['appointments']['waitingListAppointments']['enabled'])),
2613 ],
2614 'customPricing' => [
2615 'enabled' => $basicAndUp,
2616 ],
2617 'recurringAppointments' => [
2618 'enabled' => $basicAndUp,
2619 ],
2620 'extras' => [
2621 'enabled' => $starterAndUp,
2622 ],
2623 'cart' => [
2624 'enabled' => $old && $proAndUp && !empty($saved['payments']['cart']),
2625 ],
2626 'timezones' => [
2627 'enabled' => $basicAndUp,
2628 ],
2629 'depositPayment' => [
2630 'enabled' => $basicAndUp,
2631 ],
2632 'noShowTag' => [
2633 'enabled' => $basicAndUp && (!$old || !empty($saved['roles']['enableNoShowTag'])),
2634 ],
2635 'apis' => [
2636 'enabled' => Licence::getLicence() === 'Developer',
2637 ],
2638 'buddyboss' => [
2639 'enabled' => $basicAndUp && $old,
2640 ],
2641 'employeeBadge' => [
2642 'enabled' => $basicAndUp,
2643 ],
2644 'mailchimp' => [
2645 'enabled' => $old && $basicAndUp && !empty($saved['mailchimp']['accessToken']),
2646 ],
2647 'googleSocialLogin' => [
2648 'enabled' => $old && $basicAndUp && !empty($saved['socialLogin']['enableGoogleLogin']),
2649 ],
2650 'facebookSocialLogin' => [
2651 'enabled' => $old && $basicAndUp && !empty($saved['socialLogin']['enableFacebookLogin']),
2652 ],
2653 'eTickets' => [
2654 'enabled' => $proAndUp && (!$old || !empty($saved['appointments']['qrCodeEvents']['enabled'])),
2655 ],
2656 'eventTags' => [
2657 'enabled' => $starterAndUp && (!$old || EventsTagsTable::hasTags()),
2658 ],
2659 ];
2660
2661 self::initSettings('featuresIntegrations', $settings);
2662 }
2663 }
2664