PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.11
Booking for Appointments and Events Calendar – Amelia v1.2.11
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 / Application / Services / Placeholder / AppointmentsPlaceholderService.php
ameliabooking / src / Application / Services / Placeholder Last commit date
AppointmentPlaceholderService.php 1 year ago AppointmentsPlaceholderService.php 1 year ago BasicPackagePlaceholderService.php 2 years ago EventPlaceholderService.php 1 year ago PlaceholderService.php 1 year ago PlaceholderServiceInterface.php 1 year ago
AppointmentsPlaceholderService.php
182 lines
1 <?php
2 /**
3 * @copyright © TMS-Plugins. All rights reserved.
4 * @licence See LICENCE.md for license details.
5 */
6
7 namespace AmeliaBooking\Application\Services\Placeholder;
8
9 use AmeliaBooking\Application\Services\Helper\HelperService;
10 use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException;
11 use AmeliaBooking\Domain\Entity\User\AbstractUser;
12 use AmeliaBooking\Domain\Factory\User\UserFactory;
13 use AmeliaBooking\Domain\Services\Settings\SettingsService;
14 use AmeliaBooking\Infrastructure\Common\Exceptions\NotFoundException;
15 use AmeliaBooking\Infrastructure\Common\Exceptions\QueryExecutionException;
16 use AmeliaBooking\Infrastructure\WP\Translations\BackendStrings;
17 use Interop\Container\Exception\ContainerException;
18
19 /**
20 * Class AppointmentsPlaceholderService
21 *
22 * @package AmeliaBooking\Application\Services\Placeholder
23 */
24 class AppointmentsPlaceholderService extends AppointmentPlaceholderService
25 {
26 /**
27 *
28 * @return array
29 *
30 * @throws ContainerException
31 */
32 public function getEntityPlaceholdersDummyData($type)
33 {
34 /** @var SettingsService $settingsService */
35 $settingsService = $this->container->get('domain.settings.service');
36
37 /** @var HelperService $helperService */
38 $helperService = $this->container->get('application.helper.service');
39
40 $companySettings = $settingsService->getCategorySettings('company');
41
42 $dateFormat = $settingsService->getSetting('wordpress', 'dateFormat');
43 $timeFormat = $settingsService->getSetting('wordpress', 'timeFormat');
44
45 $timestamp = date_create()->getTimestamp();
46
47 $this->getPlaceholdersData(
48 [
49 'recurring' => [],
50 ],
51 null,
52 $type,
53 [
54 'firstName' => 'John Doe',
55 'lastName' => 'John Doe',
56 'email' => 'johndoe@example.com',
57 'phone' => '(555) 555-1234',
58 ],
59 false
60 );
61
62
63 return [
64 'appointment_id' => '1',
65 'appointment_date' => date_i18n($dateFormat, $timestamp),
66 'appointment_date_time' => date_i18n($dateFormat . ' ' . $timeFormat, $timestamp),
67 'appointment_start_time' => date_i18n($timeFormat, $timestamp),
68 'appointment_end_time' => date_i18n($timeFormat, date_create('1 hour')->getTimestamp()),
69 'appointment_notes' => 'Appointment note',
70 'appointment_price' => $helperService->getFormattedPrice(100),
71 'payment_due_amount' => $helperService->getFormattedPrice(80),
72 'appointment_cancel_url' => 'http://cancel_url.com',
73 'zoom_join_url' => $type === 'email' ?
74 '<a href="#">' . BackendStrings::getCommonStrings()['zoom_click_to_join'] . '</a>' : 'https://join_zoom_link.com',
75 'zoom_host_url' => $type === 'email' ?
76 '<a href="#">' . BackendStrings::getCommonStrings()['zoom_click_to_start'] . '</a>' : 'https://start_zoom_link.com',
77 'google_meet_url' => $type === 'email' ?
78 '<a href="#">' . BackendStrings::getCommonStrings()['google_meet_join'] . '</a>' : 'https://join_google_meet_link.com',
79 'lesson_space_url' => $type === 'email' ?
80 '<a href="#">' . BackendStrings::getCommonStrings()['lesson_space_join'] . '</a>' : 'https://lessonspace.com/room-id',
81 'appointment_duration' => $helperService->secondsToNiceDuration(1800),
82 'appointment_deposit_payment' => $helperService->getFormattedPrice(20),
83 'appointment_status' => BackendStrings::getCommonStrings()['approved'],
84 'category_name' => 'Category Name',
85 'service_description' => 'Service Description',
86 'reservation_description' => 'Service Description',
87 'service_duration' => $helperService->secondsToNiceDuration(5400),
88 'service_name' => 'Service Name',
89 'reservation_name' => 'Service Name',
90 'service_price' => $helperService->getFormattedPrice(100),
91 'service_extras' => 'Extra1, Extra2, Extra3'
92 ];
93 }
94
95 /**
96 * @param array $data
97 * @param int $bookingKey
98 * @param string $type
99 * @param AbstractUser $customer
100 * @param null $allBookings
101 * @return array
102 *
103 * @throws ContainerException
104 * @throws NotFoundException
105 * @throws QueryExecutionException
106 * @throws InvalidArgumentException
107 */
108 public function getPlaceholdersData($data, $bookingKey = null, $type = null, $customer = null, $allBookings = null)
109 {
110 $providersData = [];
111
112 foreach ($data['recurring'] as $item) {
113 $providersData[$item['appointment']['providerId']][] = $item;
114 }
115
116 foreach ($providersData as $providerId => $providerAppointmentsData) {
117
118 $providersData[$providerId] = $this->getRecurringAppointmentsData(
119 array_merge($data, ['recurring' => $providerAppointmentsData]),
120 $bookingKey,
121 $type,
122 'cart',
123 0
124 );
125 }
126
127 return array_merge(
128 $this->getCompanyData($bookingKey !== null ? $data['bookings'][$bookingKey]['info'] : null),
129 $this->getCustomersData(
130 $data,
131 $type,
132 0,
133 $customer ?: UserFactory::create($data['customer'])
134 ),
135 $this->getRecurringAppointmentsData($data, $bookingKey, $type, 'cart'),
136 [
137 'icsFiles' => !empty($data['icsFiles']) ? $data['icsFiles'] : [],
138 'providersAppointments' => $providersData,
139 ]
140 );
141 }
142
143 /**
144 * @param array $entity
145 *
146 * @param string $subject
147 * @param string $body
148 * @param int $userId
149 * @return array
150 *
151 * @throws NotFoundException
152 * @throws QueryExecutionException
153 */
154 public function reParseContentForProvider($entity, $subject, $body, $userId)
155 {
156 $employeeSubject = $subject;
157
158 $employeeBody = $body;
159
160 foreach ($entity['recurring'] as $recurringData) {
161 if ($recurringData['appointment']['providerId'] === $userId) {
162 $employeeData = $this->getEmployeeData($recurringData['appointment']);
163
164 $employeeSubject = $this->applyPlaceholders(
165 $subject,
166 $employeeData
167 );
168
169 $employeeBody = $this->applyPlaceholders(
170 $body,
171 $employeeData
172 );
173 }
174 }
175
176 return [
177 'body' => $employeeBody,
178 'subject' => $employeeSubject,
179 ];
180 }
181 }
182