PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / 1.5.25
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution v1.5.25
2.4.0 2.3.0 2.2.5 2.2.0 2.1.2 2.1.1 trunk 1.10.0 1.10.01 1.10.02 1.5.0 1.5.01 1.5.02 1.5.1 1.5.10 1.5.20 1.5.21 1.5.22 1.5.23 1.5.24 1.5.25 1.6.0 1.7.0 1.7.1 1.7.2 All 33 releases
fluent-booking / app / Services / Integrations / Elementor / Widgets / FcalCalendarEvent.php

FcalCalendarEvent.php in Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution 1.5.25, at app/Services/Integrations/Elementor/Widgets/FcalCalendarEvent.php

414 lines 19.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentBooking\App\Services\Integrations\Elementor\Widgets;
4
5 use FluentBooking\App\Services\CalendarService;
6 use FluentBooking\App\Models\CalendarSlot;
7
8 class FcalCalendarEvent extends \Elementor\Widget_Base
9 {
10 /**
11 * Get widget name.
12 *
13 * @return string Widget name.
14 */
15 public function get_name()
16 {
17 return 'fluentbooking-calendar-event';
18 }
19
20 /**
21 * Get widget title.
22 *
23 * @return string Widget title.
24 */
25 public function get_title()
26 {
27 return esc_html__('Calendar Event', 'fluent-booking-pro');
28 }
29
30 /**
31 * Get widget icon.
32 *
33 * @return string Widget icon.
34 */
35 public function get_icon()
36 {
37 return 'fluent-booking-icon';
38 }
39
40 /**
41 * Get widget categories.
42 *
43 * @return array Widget categories.
44 */
45 public function get_categories()
46 {
47 return ['fluentbooking'];
48 }
49
50 /**
51 * Get widget keywords.
52 *
53 * @return array Widget keywords.
54 */
55 public function get_keywords()
56 {
57 return ['fluent', 'booking', 'calendar', 'event'];
58 }
59
60 /**
61 * Register FluentBooking widget controls.
62 *
63 * @access protected
64 */
65 protected function register_controls()
66 {
67
68 $this->start_controls_section(
69 'content_section',
70 [
71 'label' => esc_html__('Content', 'fluent-booking-pro'),
72 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
73 ]
74 );
75
76 $this->add_control(
77 'selected_event',
78 [
79 'label' => __('Select Event', 'fluent-booking-pro'),
80 'type' => 'fcal_group_select',
81 'options' => $this->getCalendarEvents()
82 ]
83 );
84
85 $this->add_control(
86 'event_hash',
87 [
88 'type' => \Elementor\Controls_Manager::HIDDEN,
89 'default' => '',
90 ]
91 );
92
93 $this->add_control(
94 'show_host_info',
95 [
96 'label' => __('Show Host Info', 'fluent-booking-pro'),
97 'type' => \Elementor\Controls_Manager::SWITCHER,
98 'label_on' => __('Show', 'fluent-booking-pro'),
99 'label_off' => __('Hide', 'fluent-booking-pro'),
100 'return_value' => 'yes',
101 'default' => 'yes',
102 ]
103 );
104
105 $this->add_control(
106 'select_theme',
107 [
108 'label' => __('Color Schema', 'fluent-booking-pro'),
109 'type' => \Elementor\Controls_Manager::SELECT,
110 'default' => 'light',
111 'options' => [
112 'light' => __('Light', 'fluent-booking-pro'),
113 'dark' => __('dark', 'fluent-booking-pro'),
114 'system-default' => __('System Default', 'fluent-booking-pro'),
115 ],
116 ]
117 );
118
119
120 $this->end_controls_section();
121
122 $this->styleSettings();
123 }
124
125 private function styleSettings()
126 {
127 $this->start_controls_section(
128 'content_style',
129 [
130 'label' => esc_html__('Style', 'fluent-booking-pro'),
131 'tab' => \Elementor\Controls_Manager::TAB_STYLE,
132 ]
133 );
134 $this->add_control('fcal_primary_color',
135 [
136 'label' => esc_html__('Primary Color', 'fluent-booking-pro'),
137 'type' => \Elementor\Controls_Manager::COLOR,
138 'selectors' => [
139 '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .calendar .day .is-today,
140 {{WRAPPER}} .fcal_slot_picker .fcal_spot_lists .fcal_spot.fcal_spot_selected .fcal_spot_name' => 'color: {{VALUE}}',
141 '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .calendar .day .is-today:before' => 'background: {{VALUE}}',
142 '{{WRAPPER}} .fcal_slot_picker .fcal_spot_lists .fcal_spot .fcal_spot_confirm' => 'background: {{VALUE}}',
143 '{{WRAPPER}} .calendar_nav .fcal_nav_active svg' => 'color: {{VALUE}}',
144 '{{WRAPPER}} .fcal_timezone_select .svelte-select.focused' => 'border-color: {{VALUE}} !important',
145 '{{WRAPPER}} .fcal_timezone_select .svelte-select .svelte-select-list .item.active' => 'border-color: {{VALUE}} !important',
146 '{{WRAPPER}} .fcal_slot_picker .fcal_spot_lists .fcal_spot.fcal_spot_selected' => 'border-color: {{VALUE}}',
147 '{{WRAPPER}} .fcal_slot_picker .fcal_spot_lists .fcal_spot:hover' => 'border-color: {{VALUE}}',
148 '{{WRAPPER}} .fcal_timezone_select .svelte-select .svelte-select-list .item.hover' => 'background: {{VALUE}} !important',
149 '{{WRAPPER}} .fcal_slot_picker .fcal_spot_lists .fcal_spot:before' => 'background: {{VALUE}} !important',
150 '{{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content input:focus' => 'border-color: {{VALUE}} !important',
151 '{{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content select:focus' => 'border-color: {{VALUE}} !important',
152 '{{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content textarea:focus' => 'border-color: {{VALUE}} !important',
153 '{{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item button' => 'border-color: {{VALUE}}; background: {{VALUE}};',
154 '{{WRAPPER}} span.fcal_host_badge' => 'color: {{VALUE}}',
155 '{{WRAPPER}} span.fcal_host_badge:before' => 'background: {{VALUE}}',
156 '{{WRAPPER}} .fcal_normal_booking_footer a' => 'color: {{VALUE}}',
157 '{{WRAPPER}} .fcal_timezone_select .svelte-select.list-open:before' => 'border-bottom-color: {{VALUE}}; border-left-color: {{VALUE}}',
158 '{{WRAPPER}} .fcal_loading_dates_inner .wrapper .cube' => 'background-color: {{VALUE}}',
159 '{{WRAPPER}} .fcal_calendar_inner .fcal_icon_item .fcal_multi_duration .fcal_duration.is_selected' => 'background-color: {{VALUE}}',
160 '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .calendar .day.day-enabled:hover span' => 'background-color: {{VALUE}}',
161 '{{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content .fcal_radio_group .fcal_radio_icon::before,
162 {{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .fcal_date_event_details .fcal_date_event_details_header .fcal_back button.fcal_svg:hover' => 'background: {{VALUE}}',
163 '{{WRAPPER}} .fcal_no_availability button' => 'background-color: {{VALUE}}',
164 '{{WRAPPER}} .fcal_slot button svg path' => 'stroke: {{VALUE}}',
165 '{{WRAPPER}} .fcal_slot_wrapper .fcal_back .fcal_back_btn:hover,
166 {{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content .fcal_radio_group input:checked ~ .fcal_radio_icon,
167 {{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content .fcal_custom_checkbox input:checked ~ .checkbox_mark,
168 {{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content .fcal_custom_checkbox input:focus ~ .checkbox_mark' => 'border-color: {{VALUE}}',
169 '{{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content .fcal_custom_checkbox input:checked ~ .checkbox_mark' => 'background: {{VALUE}}'
170 ],
171 ]
172 );
173 $this->add_control('fcal_border_color',
174 [
175 'label' => esc_html__('Border Color', 'fluent-booking-pro'),
176 'type' => \Elementor\Controls_Manager::COLOR,
177 'selectors' => [
178 '{{WRAPPER}} .fcal_calendar_inner .fcal_side' => 'border-right-color: {{VALUE}}',
179 '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .fcal_date_event_details .fcal_date_event_details_header' => 'border-bottom-color: {{VALUE}}',
180 '{{WRAPPER}} {{WRAPPER}} .fcal_payment_items table tbody td' => 'border-bottom-color: {{VALUE}} !important',
181 '{{WRAPPER}} .fcal_wrap .fcal_calendar_inner,
182 {{WRAPPER}} .fcal_slot_picker .fcal_slot_picker_header .fcal_slot_picker_header_action, {{WRAPPER}} .fcal_slot_picker .fcal_spot_lists .fcal_spot,
183 {{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content select,
184 {{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content textarea,
185 {{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content input,
186 {{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content .fcal_radio_group .fcal_radio_icon,
187 {{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content .fcal_custom_checkbox .checkbox_mark,
188 {{WRAPPER}} .fcal_payment_items table' => 'border-color: {{VALUE}}',
189 '{{WRAPPER}} .fcal_timezone_select .svelte-select,
190 {{WRAPPER}} .fcal_slot_picker .fcal_slot_picker_header .fcal_back .fcal_svg,
191 {{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .fcal_date_event_details .fcal_date_event_details_header .fcal_back button.fcal_svg' => 'border-color: {{VALUE}} !important'
192 ],
193 ]
194 );
195 $this->add_control(
196 'avatar-radius',
197 [
198 'label' => esc_html__('Avatar Radius', 'fluent-booking-pro'),
199 'type' => \Elementor\Controls_Manager::DIMENSIONS,
200 'size_units' => ['px', '%', 'em', 'rem', 'custom'],
201 'default' => [
202 'top' => 8,
203 'right' => 8,
204 'bottom' => 8,
205 'left' => 8,
206 'unit' => 'px',
207 'isLinked' => true,
208 ],
209 'selectors' => [
210 '{{WRAPPER}} .fcal_calendar_inner .fcal_side .fcal_author_avatar img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
211 ],
212 'condition' => [
213 'show_host_info' => 'yes',
214 ],
215 ]
216 );
217
218 $this->add_control(
219 'date-radius',
220 [
221 'label' => esc_html__('Date Radius', 'fluent-booking-pro'),
222 'type' => \Elementor\Controls_Manager::DIMENSIONS,
223 'size_units' => ['px', '%', 'em', 'rem', 'custom'],
224 'default' => [
225 'top' => 4,
226 'right' => 4,
227 'bottom' => 4,
228 'left' => 4,
229 'unit' => 'px',
230 'isLinked' => true,
231 ],
232 'selectors' => [
233 '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .calendar .day.day-enabled span' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
234 ],
235 ]
236 );
237
238 $this->add_control('enabled_date_background',
239 [
240 'label' => esc_html__('Enabled Date Background', 'fluent-booking-pro'),
241 'type' => \Elementor\Controls_Manager::COLOR,
242 'selectors' => [
243 '{{WRAPPER}} .fcal_payment_items table thead th' => 'background-color: {{VALUE}}',
244 '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .calendar .day.day-enabled span' => 'background-color: {{VALUE}}',
245 '{{WRAPPER}} .fcal_calendar_inner .fcal_icon_item .fcal_multi_duration .fcal_duration:not(.is_selected)' => 'background-color: {{VALUE}}',
246 ],
247 ]
248 );
249 $this->add_control('enabled_date_color',
250 [
251 'label' => esc_html__('Enabled Date Color', 'fluent-booking-pro'),
252 'type' => \Elementor\Controls_Manager::COLOR,
253 'selectors' => [
254 '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .calendar .day.day-enabled span' => 'color: {{VALUE}}',
255 ],
256 ]
257 );
258 $this->add_control('disabled_date_color',
259 [
260 'label' => esc_html__('Disabled Date Color', 'fluent-booking-pro'),
261 'type' => \Elementor\Controls_Manager::COLOR,
262 'selectors' => [
263 '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .calendar .day.day-disabled' => 'color: {{VALUE}}',
264 ],
265 ]
266 );
267
268 $this->end_controls_section();
269 }
270
271 private function getCalendarEvents()
272 {
273 $getCalendars = CalendarService::getCalendarOptionsByHost();
274
275 $formattedData = [];
276
277 if (empty($getCalendars)) {
278 return $formattedData;
279 }
280
281 foreach ($getCalendars as $calendar) {
282 $label = $calendar['label'];
283 $options = $calendar['options'];
284
285 $formattedData[$label] = [];
286 foreach ($options as $option) {
287 $formattedData[$label][$option['value']] = $option['label'];
288 }
289 }
290
291 return $formattedData;
292 }
293
294 private function getCalendarEvent($eventId, $eventHash)
295 {
296 $event = CalendarSlot::find($eventId);
297 if (!$event) {
298 $event = CalendarSlot::where('hash', $eventHash)->first();
299 }
300
301 if (!$event || !$event->calendar) {
302 return [];
303 }
304
305 $data = [
306 'id' => $event->id,
307 'title' => $event->title,
308 'description' => $event->description,
309 'user_profile' => $event->calendar->getAuthorProfile(),
310 'location_icon_html' => $event->defaultLocationHtml(),
311 'durations' => $event->getAvailableDurations()
312 ];
313 return $data;
314 }
315
316 /**
317 * Render currency widget output on the frontend.
318 *
319 * @access protected
320 */
321 protected function render()
322 {
323 $settings = $this->get_settings_for_display();
324
325 if (empty($settings['selected_event']) && empty($settings['event_hash'])) {
326 echo __('Please select an event', 'fluent-booking-pro');
327 return;
328 }
329
330 $selectedEventId = $settings['selected_event'] ?? null;
331
332 $eventHash = $settings['event_hash'] ?? '';
333
334 $selectedEvent = $this->getCalendarEvent($selectedEventId, $eventHash);
335
336 if (empty($selectedEvent['id'])) {
337 echo __('Calendar event not found', 'fluent-booking-pro');
338 return;
339 }
340
341 $hideHost = ($settings['show_host_info'] == 'yes') ? 'no' : 'yes';
342
343 $shortcode = sprintf(
344 '[fluent_booking id="%s" theme="%s" disable_author="%s" hash="%s"]',
345 $selectedEvent['id'],
346 $settings['select_theme'],
347 $hideHost,
348 $eventHash
349 );
350
351 $shortcode_output = $shortcode;
352
353 if (\Elementor\Plugin::$instance->editor->is_edit_mode()) : ?>
354 <style>
355 .fcal_calendar_inner .fcal_side {
356 width: 300px;
357 min-width: 300px;
358 }
359 .fcal_calendar_inner .fcal_date_wrapper .calendar-container > img {
360 max-width: 370px;
361 width: 100%;
362 display: block;
363 }
364 </style>
365 <div class="fcal_wrap">
366 <div class="fcal_calendar_inner">
367 <?php if ($hideHost == 'no') : ?>
368 <div class="fcal_side">
369 <div class="fcal_slot_wrapper">
370 <div class="fcal_author">
371 <div class="fcal_author_avatar">
372 <img src="<?php echo esc_url($selectedEvent['user_profile']['avatar']); ?>" alt="<?php echo esc_attr($selectedEvent['user_profile']['name']) ?>">
373 </div>
374 <div class="fcal_author_name"><?php echo esc_html($selectedEvent['user_profile']['name']); ?></div>
375 </div>
376 <div class="fcal_slot_info">
377 <h1 class="fcal_slot_heading"><?php echo esc_html($selectedEvent['title']); ?></h1>
378 <div class="slot_timing fcal_icon_item">
379 <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none"><path d="M16.5 9C16.5 13.14 13.14 16.5 9 16.5C4.86 16.5 1.5 13.14 1.5 9C1.5 4.86 4.86 1.5 9 1.5C13.14 1.5 16.5 4.86 16.5 9Z" stroke="#445164" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"></path><path d="M11.7825 11.3849L9.45753 9.99745C9.05253 9.75745 8.72253 9.17995 8.72253 8.70745V5.63245" stroke="#445164" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"></path></svg>
380 <div class="fcal_multi_duration">
381 <?php foreach ($selectedEvent['durations'] as $duration) { ?>
382 <span class="fcal_duration"><?php echo esc_html($duration); ?> </span>
383 <?php } ?>
384 </div>
385 </div>
386 <?php echo wp_kses_post($selectedEvent['location_icon_html']); ?>
387 </div>
388 <div class="fcal_slot_description"><p><?php echo esc_html($selectedEvent['description']); ?></p></div>
389 </div>
390 </div>
391 <?php endif; ?>
392
393 <div class="fcal_date_wrapper">
394 <div class="fcal_day_picker_wrap">
395 <div class="calendar-container">
396 <img src="<?php echo FLUENT_BOOKING_URL .'/assets/images/fcal-calendar.png' ?>" alt="calendar">
397 </div>
398 </div>
399 </div>
400 </div>
401 </div>
402 <?php else :
403 echo $shortcode_output;
404 endif;
405
406 }
407
408 public function content_template()
409 {
410
411 }
412
413 }
414