PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / 1.5.23
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution v1.5.23
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.23, at app/Services/Integrations/Elementor/Widgets/FcalCalendarEvent.php

403 lines 19.5 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 'show_host_info',
87 [
88 'label' => __('Show Host Info', 'fluent-booking-pro'),
89 'type' => \Elementor\Controls_Manager::SWITCHER,
90 'label_on' => __('Show', 'fluent-booking-pro'),
91 'label_off' => __('Hide', 'fluent-booking-pro'),
92 'return_value' => 'yes',
93 'default' => 'yes',
94 ]
95 );
96
97 $this->add_control(
98 'select_theme',
99 [
100 'label' => __('Color Schema', 'fluent-booking-pro'),
101 'type' => \Elementor\Controls_Manager::SELECT,
102 'default' => 'light',
103 'options' => [
104 'light' => __('Light', 'fluent-booking-pro'),
105 'dark' => __('dark', 'fluent-booking-pro'),
106 'system-default' => __('System Default', 'fluent-booking-pro'),
107 ],
108 ]
109 );
110
111
112 $this->end_controls_section();
113
114 $this->styleSettings();
115 }
116
117 private function styleSettings()
118 {
119 $this->start_controls_section(
120 'content_style',
121 [
122 'label' => esc_html__('Style', 'fluent-booking-pro'),
123 'tab' => \Elementor\Controls_Manager::TAB_STYLE,
124 ]
125 );
126 $this->add_control('fcal_primary_color',
127 [
128 'label' => esc_html__('Primary Color', 'fluent-booking-pro'),
129 'type' => \Elementor\Controls_Manager::COLOR,
130 'selectors' => [
131 '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .calendar .day .is-today,
132 {{WRAPPER}} .fcal_slot_picker .fcal_spot_lists .fcal_spot.fcal_spot_selected .fcal_spot_name' => 'color: {{VALUE}}',
133 '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .calendar .day .is-today:before' => 'background: {{VALUE}}',
134 '{{WRAPPER}} .fcal_slot_picker .fcal_spot_lists .fcal_spot .fcal_spot_confirm' => 'background: {{VALUE}}',
135 '{{WRAPPER}} .calendar_nav .fcal_nav_active svg' => 'color: {{VALUE}}',
136 '{{WRAPPER}} .fcal_timezone_select .svelte-select.focused' => 'border-color: {{VALUE}} !important',
137 '{{WRAPPER}} .fcal_timezone_select .svelte-select .svelte-select-list .item.active' => 'border-color: {{VALUE}} !important',
138 '{{WRAPPER}} .fcal_slot_picker .fcal_spot_lists .fcal_spot.fcal_spot_selected' => 'border-color: {{VALUE}}',
139 '{{WRAPPER}} .fcal_slot_picker .fcal_spot_lists .fcal_spot:hover' => 'border-color: {{VALUE}}',
140 '{{WRAPPER}} .fcal_timezone_select .svelte-select .svelte-select-list .item.hover' => 'background: {{VALUE}} !important',
141 '{{WRAPPER}} .fcal_slot_picker .fcal_spot_lists .fcal_spot:before' => 'background: {{VALUE}} !important',
142 '{{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content input:focus' => 'border-color: {{VALUE}} !important',
143 '{{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content select:focus' => 'border-color: {{VALUE}} !important',
144 '{{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content textarea:focus' => 'border-color: {{VALUE}} !important',
145 '{{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item button' => 'border-color: {{VALUE}}; background: {{VALUE}};',
146 '{{WRAPPER}} span.fcal_host_badge' => 'color: {{VALUE}}',
147 '{{WRAPPER}} span.fcal_host_badge:before' => 'background: {{VALUE}}',
148 '{{WRAPPER}} .fcal_normal_booking_footer a' => 'color: {{VALUE}}',
149 '{{WRAPPER}} .fcal_timezone_select .svelte-select.list-open:before' => 'border-bottom-color: {{VALUE}}; border-left-color: {{VALUE}}',
150 '{{WRAPPER}} .fcal_loading_dates_inner .wrapper .cube' => 'background-color: {{VALUE}}',
151 '{{WRAPPER}} .fcal_calendar_inner .fcal_icon_item .fcal_multi_duration .fcal_duration.is_selected' => 'background-color: {{VALUE}}',
152 '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .calendar .day.day-enabled:hover span' => 'background-color: {{VALUE}}',
153 '{{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content .fcal_radio_group .fcal_radio_icon::before,
154 {{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .fcal_date_event_details .fcal_date_event_details_header .fcal_back button.fcal_svg:hover' => 'background: {{VALUE}}',
155 '{{WRAPPER}} .fcal_no_availability button' => 'background-color: {{VALUE}}',
156 '{{WRAPPER}} .fcal_slot button svg path' => 'stroke: {{VALUE}}',
157 '{{WRAPPER}} .fcal_slot_wrapper .fcal_back .fcal_back_btn:hover,
158 {{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content .fcal_radio_group input:checked ~ .fcal_radio_icon,
159 {{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content .fcal_custom_checkbox input:checked ~ .checkbox_mark,
160 {{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content .fcal_custom_checkbox input:focus ~ .checkbox_mark' => 'border-color: {{VALUE}}',
161 '{{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content .fcal_custom_checkbox input:checked ~ .checkbox_mark' => 'background: {{VALUE}}'
162 ],
163 ]
164 );
165 $this->add_control('fcal_border_color',
166 [
167 'label' => esc_html__('Border Color', 'fluent-booking-pro'),
168 'type' => \Elementor\Controls_Manager::COLOR,
169 'selectors' => [
170 '{{WRAPPER}} .fcal_calendar_inner .fcal_side' => 'border-right-color: {{VALUE}}',
171 '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .fcal_date_event_details .fcal_date_event_details_header' => 'border-bottom-color: {{VALUE}}',
172 '{{WRAPPER}} {{WRAPPER}} .fcal_payment_items table tbody td' => 'border-bottom-color: {{VALUE}} !important',
173 '{{WRAPPER}} .fcal_wrap .fcal_calendar_inner,
174 {{WRAPPER}} .fcal_slot_picker .fcal_slot_picker_header .fcal_slot_picker_header_action, {{WRAPPER}} .fcal_slot_picker .fcal_spot_lists .fcal_spot,
175 {{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content select,
176 {{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content textarea,
177 {{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content input,
178 {{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content .fcal_radio_group .fcal_radio_icon,
179 {{WRAPPER}} .fcal_booking_form_wrap .fcal_booking_form .fcal_form_item .fcal_input_content .fcal_custom_checkbox .checkbox_mark,
180 {{WRAPPER}} .fcal_payment_items table' => 'border-color: {{VALUE}}',
181 '{{WRAPPER}} .fcal_timezone_select .svelte-select,
182 {{WRAPPER}} .fcal_slot_picker .fcal_slot_picker_header .fcal_back .fcal_svg,
183 {{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'
184 ],
185 ]
186 );
187 $this->add_control(
188 'avatar-radius',
189 [
190 'label' => esc_html__('Avatar Radius', 'fluent-booking-pro'),
191 'type' => \Elementor\Controls_Manager::DIMENSIONS,
192 'size_units' => ['px', '%', 'em', 'rem', 'custom'],
193 'default' => [
194 'top' => 8,
195 'right' => 8,
196 'bottom' => 8,
197 'left' => 8,
198 'unit' => 'px',
199 'isLinked' => true,
200 ],
201 'selectors' => [
202 '{{WRAPPER}} .fcal_calendar_inner .fcal_side .fcal_author_avatar img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
203 ],
204 'condition' => [
205 'show_host_info' => 'yes',
206 ],
207 ]
208 );
209
210 $this->add_control(
211 'date-radius',
212 [
213 'label' => esc_html__('Date Radius', 'fluent-booking-pro'),
214 'type' => \Elementor\Controls_Manager::DIMENSIONS,
215 'size_units' => ['px', '%', 'em', 'rem', 'custom'],
216 'default' => [
217 'top' => 4,
218 'right' => 4,
219 'bottom' => 4,
220 'left' => 4,
221 'unit' => 'px',
222 'isLinked' => true,
223 ],
224 'selectors' => [
225 '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .calendar .day.day-enabled span' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
226 ],
227 ]
228 );
229
230 $this->add_control('enabled_date_background',
231 [
232 'label' => esc_html__('Enabled Date Background', 'fluent-booking-pro'),
233 'type' => \Elementor\Controls_Manager::COLOR,
234 'selectors' => [
235 '{{WRAPPER}} .fcal_payment_items table thead th' => 'background-color: {{VALUE}}',
236 '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .calendar .day.day-enabled span' => 'background-color: {{VALUE}}',
237 '{{WRAPPER}} .fcal_calendar_inner .fcal_icon_item .fcal_multi_duration .fcal_duration:not(.is_selected)' => 'background-color: {{VALUE}}',
238 ],
239 ]
240 );
241 $this->add_control('enabled_date_color',
242 [
243 'label' => esc_html__('Enabled Date Color', 'fluent-booking-pro'),
244 'type' => \Elementor\Controls_Manager::COLOR,
245 'selectors' => [
246 '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .calendar .day.day-enabled span' => 'color: {{VALUE}}',
247 ],
248 ]
249 );
250 $this->add_control('disabled_date_color',
251 [
252 'label' => esc_html__('Disabled Date Color', 'fluent-booking-pro'),
253 'type' => \Elementor\Controls_Manager::COLOR,
254 'selectors' => [
255 '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .calendar .day.day-disabled' => 'color: {{VALUE}}',
256 ],
257 ]
258 );
259
260 $this->end_controls_section();
261 }
262
263 private function getCalendarEvents()
264 {
265 $getCalendars = CalendarService::getCalendarOptionsByHost();
266
267 $formattedData = [];
268
269 if (empty($getCalendars)) {
270 return $formattedData;
271 }
272
273 foreach ($getCalendars as $calendar) {
274 $label = $calendar['label'];
275 $options = $calendar['options'];
276
277 $formattedData[$label] = [];
278 foreach ($options as $option) {
279 $formattedData[$label][$option['value']] = $option['label'];
280 }
281 }
282
283 return $formattedData;
284 }
285
286 private function getCurrentCalendar($eventId)
287 {
288 if (empty($eventId)) {
289 return [];
290 }
291 $event = CalendarSlot::query()->findOrFail($eventId);
292 if (empty($event)) {
293 return [];
294 }
295
296 $data = [
297 'title' => $event->title,
298 'description' => $event->description,
299 'user_profile' => $event->calendar->getAuthorProfile(),
300 'location_icon_html' => $event->defaultLocationHtml(),
301 'durations' => $event->getAvailableDurations()
302 ];
303 return $data;
304 }
305
306 /**
307 * Render currency widget output on the frontend.
308 *
309 * @access protected
310 */
311 protected function render()
312 {
313 $settings = $this->get_settings_for_display();
314
315 if (!empty($settings['selected_event'])) :
316
317 $selectedEvent = $this->getCurrentCalendar($settings['selected_event']);
318
319 $hideHost = ($settings['show_host_info'] == 'yes') ? 'no' : 'yes';
320
321 $shortcode = sprintf(
322 '[fluent_booking id="%s" theme="%s" disable_author="%s"]',
323 $settings['selected_event'],
324 $settings['select_theme'],
325 $hideHost
326 );
327
328 $shortcode_output = $shortcode;
329
330 if (\Elementor\Plugin::$instance->editor->is_edit_mode()) : ?>
331 <!-- Output for editor -->
332 <style>
333 .fcal_calendar_inner .fcal_side {
334 width: 300px;
335 min-width: 300px;
336 }
337 .fcal_calendar_inner .fcal_date_wrapper .calendar-container > img {
338 max-width: 370px;
339 width: 100%;
340 display: block;
341 }
342 </style>
343 <div class="fcal_wrap">
344 <?php if (!empty($settings['selected_event'])) : ?>
345 <div class="fcal_calendar_inner">
346 <?php if ($hideHost == 'no') : ?>
347 <div class="fcal_side">
348 <div class="fcal_slot_wrapper">
349 <div class="fcal_author">
350 <div class="fcal_author_avatar">
351 <img src="<?php echo esc_url($selectedEvent['user_profile']['avatar']); ?>" alt="<?php echo esc_attr($selectedEvent['user_profile']['name']) ?>">
352 </div>
353 <div class="fcal_author_name"><?php echo esc_html($selectedEvent['user_profile']['name']); ?></div>
354 </div>
355 <div class="fcal_slot_info">
356 <h1 class="fcal_slot_heading"><?php echo esc_html($selectedEvent['title']); ?></h1>
357 <div class="slot_timing fcal_icon_item">
358 <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>
359 <div class="fcal_multi_duration">
360 <?php foreach ($selectedEvent['durations'] as $duration) { ?>
361 <span class="fcal_duration"><?php echo esc_html($duration); ?> </span>
362 <?php } ?>
363 </div>
364 </div>
365 <?php echo wp_kses_post($selectedEvent['location_icon_html']); ?>
366 </div>
367 <div class="fcal_slot_description"><p><?php echo esc_html($selectedEvent['description']); ?></p></div>
368 </div>
369 </div>
370 <?php endif; ?>
371
372 <div class="fcal_date_wrapper">
373 <div class="fcal_day_picker_wrap">
374 <div class="calendar-container">
375 <img src="<?php echo FLUENT_BOOKING_URL .'/assets/images/fcal-calendar.png' ?>" alt="calendar">
376 </div>
377 </div>
378 </div>
379 </div>
380 <?php
381 else:
382 ?>
383 <div class="fcal_empty"><?php esc_html_e('Please Select the Event', 'fluent-booking-pro'); ?></div>
384 <?php
385 endif; ?>
386 </div>
387 <?php else :
388 echo $shortcode_output;
389 endif;
390
391 else :
392 echo __('Please select an event', 'fluent-booking-pro');
393 endif;
394
395 }
396
397 public function content_template()
398 {
399
400 }
401
402 }
403