PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / 2.3.0
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution v2.3.0
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 / FcalBookings.php

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

449 lines 16.9 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\Models\Calendar;
6
7 class FcalBookings extends \Elementor\Widget_Base
8 {
9
10 /**
11 * Get widget name.
12 *
13 * @return string Widget name.
14 */
15 public function get_name()
16 {
17 return 'fluentbooking-bookings';
18 }
19
20 /**
21 * Get widget title.
22 *
23 * @return string Widget title.
24 */
25 public function get_title()
26 {
27 return esc_html__('Bookings', 'fluent-booking');
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'),
72 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
73 ]
74 );
75 $this->add_control(
76 'selected_calendars',
77 [
78 'label' => esc_html__('Select Calendars', 'fluent-booking'),
79 'type' => \Elementor\Controls_Manager::SELECT2,
80 'label_block' => true,
81 'multiple' => true,
82 'description' => esc_html__('Left empty to show the bookings for all calendars', 'fluent-booking'),
83 'options' => $this->getCalendars(),
84 ]
85 );
86 $this->add_control(
87 'booking_title',
88 [
89 'label' => esc_html__('Title', 'fluent-booking'),
90 'type' => \Elementor\Controls_Manager::TEXT,
91 'label_block' => true,
92 'default' => esc_html__('My Bookings', 'fluent-booking'),
93 'placeholder' => esc_html__('Type your title here', 'fluent-booking'),
94 ]
95 );
96 $this->add_control(
97 'no_bookings_title',
98 [
99 'label' => esc_html__('No Booking Title', 'fluent-booking'),
100 'type' => \Elementor\Controls_Manager::TEXT,
101 'label_block' => true,
102 'default' => esc_html__('No bookings found', 'fluent-booking'),
103 'placeholder' => esc_html__('Type your title here', 'fluent-booking'),
104 ]
105 );
106
107 $this->add_control(
108 'default_period',
109 [
110 'label' => esc_html__('Default Period', 'fluent-booking'),
111 'type' => \Elementor\Controls_Manager::SELECT,
112 'default' => 'all',
113 'options' => [
114 'all' => esc_html__('All', 'fluent-booking'),
115 'upcoming' => esc_html__('Upcoming', 'fluent-booking'),
116 'completed' => esc_html__('Completed', 'fluent-booking'),
117 'cancelled' => esc_html__('Cancelled', 'fluent-booking'),
118 'pending' => esc_html__('Pending', 'fluent-booking')
119 ],
120 ]
121 );
122 $this->add_control(
123 'show_filter',
124 [
125 'label' => esc_html__('Show Filter', 'fluent-booking'),
126 'type' => \Elementor\Controls_Manager::SWITCHER,
127 'label_on' => esc_html__('Show', 'fluent-booking'),
128 'label_off' => esc_html__('Hide', 'fluent-booking'),
129 'return_value' => 'yes',
130 'default' => 'yes',
131 ]
132 );
133 $this->add_control(
134 'show_pagination',
135 [
136 'label' => esc_html__('Show Pagination', 'fluent-booking'),
137 'type' => \Elementor\Controls_Manager::SWITCHER,
138 'label_on' => esc_html__('Show', 'fluent-booking'),
139 'label_off' => esc_html__('Hide', 'fluent-booking'),
140 'return_value' => 'yes',
141 'default' => 'yes',
142 ]
143 );
144 $this->add_control(
145 'per_page',
146 [
147 'label' => esc_html__('Per Page', 'fluent-booking'),
148 'type' => \Elementor\Controls_Manager::SLIDER,
149 'range' => [
150 'px' => [
151 'min' => 1,
152 'max' => 100,
153 'step' => 1,
154 ]
155 ],
156 'default' => [
157 'size' => 10,
158 ],
159 ]
160 );
161
162 $this->end_controls_section();
163
164 }
165
166 private function getCalendars()
167 {
168 $calendars = Calendar::with(['events' => function ($query) {
169 $query->where('status', 'active');
170 }])->where('status', 'active')->get();
171
172 $formattedValue = [];
173
174 if (empty($calendars)) {
175 return $formattedValue;
176 }
177
178 foreach ($calendars as $calendar) {
179 $formattedValue[$calendar->id] = $calendar->title;
180 }
181
182 return $formattedValue;
183 }
184
185
186 /**
187 * Render currency widget output on the frontend.
188 *
189 * @access protected
190 */
191 protected function render()
192 {
193 $settings = $this->get_settings_for_display();
194
195 $filter = ($settings['show_filter'] == 'yes') ? 'show' : 'hide';
196 $pagination = ($settings['show_pagination'] == 'yes') ? 'show' : 'hide';
197
198 $calendarIds = (!empty($settings['selected_calendars'])) ? implode(',', $settings['selected_calendars']) : 'all';
199
200
201 $calendar_ids = esc_attr($calendarIds);
202 $period = esc_attr($settings['default_period']);
203 $filter = esc_attr($filter);
204 $pagination = esc_attr($pagination);
205 $per_page = esc_attr($settings['per_page']['size']);
206 $no_bookings = esc_attr($settings['no_bookings_title']);
207 $title = esc_attr($settings['booking_title']);
208
209 $shortcode = sprintf(
210 '[fluent_booking_lists calendar_ids="%s" period="%s" filter="%s" pagination="%s" per_page="%s" no_bookings="%s" title="%s"]',
211 $calendar_ids,
212 $period,
213 $filter,
214 $pagination,
215 $per_page,
216 $no_bookings,
217 $title
218 );
219
220 $shortcode_output = do_shortcode($shortcode);
221
222 if (\Elementor\Plugin::$instance->editor->is_edit_mode()) :
223 // Output for editor
224 ?>
225 <style>
226 .fcal_container {
227 pointer-events: none;
228 }
229 .fcal_container .fcal_booking_header {
230 display: flex;
231 justify-content: space-between;
232 align-items: center;
233 }
234 .fcal_container .fcal_booking_header .fcal_booking_header_actions form {
235 display: inline-flex;
236 gap: 0.5rem;
237 align-items: center;
238 background: #fff;
239 border: 1px solid #e5e7eb;
240 border-radius: 5px;
241 padding: 5px;
242 }
243 .fcal_container .fcal_booking_header .fcal_booking_header_actions form .fcal_radio_btn {
244 position: relative;
245 overflow: hidden;
246 cursor: pointer;
247 }
248 .fcal_container .fcal_booking_header .fcal_booking_header_actions form .fcal_radio_btn input {
249 position: absolute;
250 left: 0;
251 top: 0;
252 width: 100%;
253 height: 100%;
254 z-index: 1;
255 cursor: pointer;
256 opacity: 0;
257 }
258 .fcal_container .fcal_booking_header .fcal_booking_header_actions form .fcal_radio_btn label {
259 display: block;
260 border-radius: 8px;
261 padding: 7px 10px;
262 color: #606266;
263 font-size: 0.875rem;
264 font-weight: 500;
265 }
266 .fcal_container .fcal_booking_header .fcal_booking_header_actions form .fcal_radio_btn input:checked ~ label {
267 background: #e5e7eb;
268 border-radius: 5px !important;
269 box-shadow: none;
270 color: #374151;
271 }
272 .fcal_container .fcal_all_bookings .fcal_bookings .fcal_booking_wrapper {
273 background: #fff;
274 border: 1px solid #eaecf0;
275 border-radius: 8px;
276 }
277 .fcal_container .fcal_all_bookings .fcal_bookings .fcal_booking_wrapper .fcal_booking:last-child {
278 border-bottom: none;
279 }
280 .fcal_container .fcal_all_bookings .fcal_bookings .fcal_booking_wrapper .fcal_booking {
281 border-bottom: 1px solid #eaecf0;
282 position: relative;
283 cursor: pointer;
284 }
285 .fcal_container .fcal_all_bookings .fcal_bookings .fcal_booking_wrapper .fcal_booking .fcal_spot_line {
286 align-items: center;
287 -moz-column-gap: 15px;
288 column-gap: 15px;
289 display: flex;
290 justify-content: space-between;
291 padding: 15px 25px;
292 position: relative;
293 transition: 0.1s;
294 }
295 .fcal_container .fcal_all_bookings .fcal_bookings .fcal_booking_wrapper .fcal_booking .fcal_spot_line .fcal_spot_timing {
296 align-items: center;
297 display: flex;
298 flex-wrap: wrap;
299 color: #777;
300 font-weight: 500;
301 font-size: 14px;
302 line-height: 20px;
303 gap: 2px;
304 max-width: 180px;
305 min-width: 180px;
306 }
307 .fcal_container .fcal_all_bookings .fcal_bookings .fcal_booking_wrapper .fcal_booking .fcal_spot_line .fcal_spot_timing .fcal_booking_date {
308 color: #111827;
309 }
310 .fcal_container .fcal_all_bookings .fcal_bookings .fcal_booking_wrapper .fcal_booking .fcal_spot_line .fcal_spot_timing p {
311 margin: 0;
312 font-size: 14px;
313 }
314 .fcal_container .fcal_all_bookings .fcal_bookings .fcal_booking_wrapper .fcal_booking .fcal_spot_line .fcal_spot_desc {
315 align-items: flex-start;
316 display: flex;
317 flex-direction: column;
318 margin-right: auto;
319 }
320 .fcal_container .fcal_all_bookings .fcal_bookings .fcal_booking_wrapper .fcal_booking .fcal_spot_line .fcal_spot_desc .fcal_spot_title {
321 color: #445164;
322 font-size: 15px;
323 font-weight: 400;
324 line-height: 20px;
325 margin: 0;
326 }
327 .fcal_container .fcal_all_bookings .fcal_bookings .fcal_booking_wrapper .fcal_booking .fcal_spot_line .fcal_spot_desc .fcal_spot_desc_sub_info {
328 align-items: center;
329 display: flex;
330 flex-wrap: wrap;
331 gap: 6px;
332 margin-top: 8px;
333 }
334 .fcal_container .fcal_all_bookings .fcal_bookings .fcal_booking_wrapper .fcal_booking .fcal_spot_line .fcal_spot_desc .fcal_spot_desc_sub_info .fcal_spot_period_status,
335 .fcal_container .fcal_all_bookings .fcal_bookings .fcal_booking_wrapper .fcal_booking .fcal_spot_line .fcal_spot_desc .fcal_spot_desc_sub_info .fcal_spot_payment_status{
336 background: rgba(38, 83, 199, 0.1);
337 border-radius: 4px;
338 color: #306ae0;
339 display: inline-block;
340 font-size: 12px;
341 font-weight: 500;
342 margin: 0;
343 padding: 2px 10px;
344 }
345 .fcal_container .fcal_all_bookings .fcal_bookings .fcal_booking_wrapper .fcal_booking .fcal_spot_line .fcal_spot_desc .fcal_spot_desc_sub_info .fcal_spot_payment_status.paid {
346 background: #e8f5f1;
347 color: #16896b;
348 }
349 .fcal_container .fcal_all_bookings .fcal_bookings .fcal_booking_wrapper .fcal_booking .fcal_spot_line .fcal_spot_desc .fcal_spot_desc_sub_info .fcal_spot_payment_status.pending, .fcal_container .fcal_all_bookings .fcal_bookings .fcal_booking_wrapper .fcal_booking .fcal_spot_line .fcal_spot_desc .fcal_spot_desc_sub_info .fcal_spot_payment_status.refunded, .fcal_container .fcal_all_bookings .fcal_bookings .fcal_booking_wrapper .fcal_booking .fcal_spot_line .fcal_spot_desc .fcal_spot_desc_sub_info .fcal_spot_payment_status.partially-refunded {
350 background: #FDE8CD;
351 color: #F58E07;
352 }
353 .fcal_container .fcal_all_bookings .fcal_bookings .fcal_booking_wrapper .fcal_booking .fcal_spot_line .fcal_spot_actions {
354 display: flex;
355 gap: 0.5rem;
356 align-self: center;
357 }
358 .fcal_container .fcal_plain_btn {
359 border: 1px solid #d6dae1;
360 border-radius: 8px;
361 color: #1b2533;
362 font-size: 14px;
363 height: auto;
364 line-height: 1;
365 padding: 8px 16px;
366 background: transparent;
367 transition: 0.2s;
368 }
369 .fcal_container .fcal_pagination {
370 justify-content: flex-end;
371 text-align: right;
372 align-items: center;
373 color: #303133;
374 display: flex;
375 font-size: 0.875rem;
376 font-weight: 400;
377 white-space: nowrap;
378 margin-top: 0.5rem;
379 padding: 0;
380 }
381 .fcal_container .fcal_pagination form select {
382 display: flex;
383 align-items: center;
384 margin-left: 1rem;
385 border: 1px solid #d6dae1;
386 border-radius: 8px;
387 color: #1b2533;
388 height: 2rem;
389 line-height: 1;
390 padding: 0.25rem;
391 transition: 0.2s;
392 cursor: pointer;
393 }
394 .fcal_container .fcal_pagination .fcal_btn {
395 color: #303133;
396 text-decoration: none;
397 background-color: transparent;
398 margin-left: 1rem;
399 }
400 .fcal_container .fcal_pagination .fcal_btn.prev {
401 padding: 0 1rem;
402 }
403 .fcal_container .fcal_pagination .fcal_btn.disabled {
404 color: #c0c4cc;
405 cursor: not-allowed;
406 }
407 .fcal_container .fcal_pagination .fcal_pager {
408 align-items: center;
409 display: flex;
410 font-size: 0;
411 list-style: none;
412 margin: 0;
413 padding: 0;
414 }
415 .fcal_container .fcal_pagination .fcal_pager li {
416 border-radius: 8px;
417 height: 2rem;
418 transition: 0.2s;
419 background: #fff;
420 border: none;
421 box-sizing: border-box;
422 color: #303133;
423 font-size: 0.875rem;
424 display: flex;
425 align-items: center;
426 justify-content: center;
427 text-align: center;
428 line-height: 2rem;
429 min-width: 2rem;
430 padding: 0 4px;
431 cursor: pointer;
432 }
433 .fcal_container .fcal_pagination .fcal_pager li.active {
434 background: #306ae0;
435 color: #fff;
436 }
437 </style>
438
439 <?php
440 endif;
441 echo $shortcode_output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
442 }
443
444 public function content_template()
445 {
446
447 }
448 }
449