PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.20
Booking for Appointments and Events Calendar – Amelia v1.2.20
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 1 year ago EventPlaceholderService.php 1 year ago PlaceholderService.php 1 year ago PlaceholderServiceInterface.php 1 year ago
AppointmentsPlaceholderService.php
194 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 'microsoft_teams_url' => $type === 'email' ?
82 '<a href="#">' . BackendStrings::getCommonStrings()['microsoft_teams_join'] . '</a>' : 'https://join_microsoft_teams_link.com',
83 'appointment_duration' => $helperService->secondsToNiceDuration(1800),
84 'appointment_deposit_payment' => $helperService->getFormattedPrice(20),
85 'appointment_status' => BackendStrings::getCommonStrings()['approved'],
86 'category_name' => 'Category Name',
87 'service_description' => 'Service Description',
88 'reservation_description' => 'Service Description',
89 'service_duration' => $helperService->secondsToNiceDuration(5400),
90 'service_name' => 'Service Name',
91 'reservation_name' => 'Service Name',
92 'service_price' => $helperService->getFormattedPrice(100),
93 'service_extras' => 'Extra1, Extra2, Extra3'
94 ];
95 }
96
97 /** @noinspection MoreThanThreeArgumentsInspection */
98 /**
99 * @param array $data
100 * @param int $bookingKey
101 * @param string $type
102 * @param AbstractUser $customer
103 * @param array $allBookings
104 * @param bool $invoice
105 * @param string $notificationType
106 *
107 * @return array
108 *
109 * @throws ContainerException
110 * @throws NotFoundException
111 * @throws QueryExecutionException
112 * @throws InvalidArgumentException
113 */
114 public function getPlaceholdersData(
115 $data,
116 $bookingKey = null,
117 $type = null,
118 $customer = null,
119 $allBookings = null,
120 $invoice = false,
121 $notificationType = null
122 ) {
123 $providersData = [];
124
125 foreach ($data['recurring'] as $item) {
126 $providersData[$item['appointment']['providerId']][] = $item;
127 }
128
129 foreach ($providersData as $providerId => $providerAppointmentsData) {
130 $providersData[$providerId] = $this->getRecurringAppointmentsData(
131 array_merge($data, ['recurring' => $providerAppointmentsData]),
132 $bookingKey,
133 $type,
134 'cart',
135 0
136 );
137 }
138
139 return array_merge(
140 $this->getCompanyData($bookingKey !== null ? $data['bookings'][$bookingKey]['info'] : null),
141 $this->getCustomersData(
142 $data,
143 $type,
144 0,
145 $customer ?: UserFactory::create($data['customer'])
146 ),
147 $this->getRecurringAppointmentsData($data, $bookingKey, $type, 'cart'),
148 [
149 'icsFiles' => !empty($data['icsFiles']) ? $data['icsFiles'] : [],
150 'providersAppointments' => $providersData,
151 ]
152 );
153 }
154
155 /**
156 * @param array $entity
157 *
158 * @param string $subject
159 * @param string $body
160 * @param int $userId
161 * @return array
162 *
163 * @throws NotFoundException
164 * @throws QueryExecutionException
165 */
166 public function reParseContentForProvider($entity, $subject, $body, $userId)
167 {
168 $employeeSubject = $subject;
169
170 $employeeBody = $body;
171
172 foreach ($entity['recurring'] as $recurringData) {
173 if ($recurringData['appointment']['providerId'] === $userId) {
174 $employeeData = $this->getEmployeeData($recurringData['appointment']);
175
176 $employeeSubject = $this->applyPlaceholders(
177 $subject,
178 $employeeData
179 );
180
181 $employeeBody = $this->applyPlaceholders(
182 $body,
183 $employeeData
184 );
185 }
186 }
187
188 return [
189 'body' => $employeeBody,
190 'subject' => $employeeSubject,
191 ];
192 }
193 }
194