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