PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / trunk
Booking for Appointments and Events Calendar – Amelia vtrunk
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 month ago AppointmentsPlaceholderService.php 4 months ago BasicPackagePlaceholderService.php 6 months ago EventPlaceholderService.php 2 weeks ago PlaceholderService.php 2 weeks ago PlaceholderServiceInterface.php 6 months ago
AppointmentsPlaceholderService.php
192 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' => 'https://join_google_meet_link.com',
79 'lesson_space_url' => 'https://lessonspace.com/room-id',
80 'microsoft_teams_url' => 'https://join_microsoft_teams_link.com',
81 'appointment_duration' => $helperService->secondsToNiceDuration(1800),
82 'appointment_deposit_payment' => $helperService->getFormattedPrice(20),
83 'appointment_status' => BackendStrings::get('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 /** @noinspection MoreThanThreeArgumentsInspection */
96 /**
97 * @param array $data
98 * @param int $bookingKey
99 * @param string $type
100 * @param AbstractUser $customer
101 * @param array $allBookings
102 * @param bool $invoice
103 * @param string $notificationType
104 *
105 * @return array
106 *
107 * @throws ContainerException
108 * @throws NotFoundException
109 * @throws QueryExecutionException
110 * @throws InvalidArgumentException
111 */
112 public function getPlaceholdersData(
113 $data,
114 $bookingKey = null,
115 $type = null,
116 $customer = null,
117 $allBookings = null,
118 $invoice = false,
119 $notificationType = null
120 ) {
121 $providersData = [];
122
123 foreach ($data['recurring'] as $item) {
124 $providersData[$item['appointment']['providerId']][] = $item;
125 }
126
127 foreach ($providersData as $providerId => $providerAppointmentsData) {
128 $providersData[$providerId] = $this->getRecurringAppointmentsData(
129 array_merge($data, ['recurring' => $providerAppointmentsData]),
130 $bookingKey,
131 $type,
132 'cart',
133 0
134 );
135 }
136
137 return array_merge(
138 $this->getCompanyData($bookingKey !== null ? $data['bookings'][$bookingKey]['info'] : null),
139 $this->getCustomersData(
140 $data,
141 $type,
142 0,
143 $customer ?: UserFactory::create($data['customer'])
144 ),
145 $this->getRecurringAppointmentsData($data, $bookingKey, $type, 'cart'),
146 [
147 'icsFiles' => !empty($data['icsFiles']) ? $data['icsFiles'] : [],
148 'providersAppointments' => $providersData,
149 ]
150 );
151 }
152
153 /**
154 * @param array $entity
155 *
156 * @param string $subject
157 * @param string $body
158 * @param int $userId
159 * @return array
160 *
161 * @throws NotFoundException
162 * @throws QueryExecutionException
163 */
164 public function reParseContentForProvider($entity, $subject, $body, $userId)
165 {
166 $employeeSubject = $subject;
167
168 $employeeBody = $body;
169
170 foreach ($entity['recurring'] as $recurringData) {
171 if ($recurringData['appointment']['providerId'] === $userId) {
172 $employeeData = $this->getEmployeeData($recurringData['appointment']);
173
174 $employeeSubject = $this->applyPlaceholders(
175 $subject,
176 $employeeData
177 );
178
179 $employeeBody = $this->applyPlaceholders(
180 $body,
181 $employeeData
182 );
183 }
184 }
185
186 return [
187 'body' => $employeeBody,
188 'subject' => $employeeSubject,
189 ];
190 }
191 }
192