PluginProbe
Booking Calendar / 10.10.1
Booking Calendar v10.10.1
11.8.4 11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 10.11 All 204 releases
booking / includes / page-form-simple / page-form-simple.php

page-form-simple.php in Booking Calendar 10.10.1, at includes/page-form-simple/page-form-simple.php

1,479 lines 76.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php /**
2 * @version 1.0
3 * @package Booking Calendar
4 * @category Booking Form Settings
5 * @author wpdevelop
6 *
7 * @web-site https://wpbookingcalendar.com/
8 * @email [email protected]
9 *
10 * @modified 2016-03-23
11 */
12
13 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
14
15 require_once( WPBC_PLUGIN_DIR . '/includes/page-form-simple/form_simple__toolbar_free.php' );
16 require_once( WPBC_PLUGIN_DIR . '/includes/page-form-simple/form_simple__submit.php' );
17 require_once( WPBC_PLUGIN_DIR . '/includes/page-form-simple/form_simple__timeslots.php' ); // Timeslots Generator
18 require_once( WPBC_PLUGIN_DIR . '/includes/page-form-simple/form_simple__preview.php' ); // Preview
19 require_once( WPBC_PLUGIN_DIR . '/includes/page-form-simple/form_simple__preview_templates.php' ); // Templates - Simple Booking Form
20 require_once( WPBC_PLUGIN_DIR . '/includes/page-form-simple/form_simple__auto_show_timeslots.php' ); // Auto Load Time Slots -- Editing or Adding form
21
22 /**
23 * Show Content
24 * Update Content
25 * Define Slug
26 * Define where to show
27 */
28 class WPBC_Page_SettingsFormFieldsFree extends WPBC_Page_Structure {
29
30 /** Need define some filters */
31 public function __construct() {
32
33
34
35
36 /**
37 * We need to update these fields after usual update process :
38 * 'booking_form'
39 * 'booking_form_show'
40 * 'booking_form_visual'
41 */
42 add_bk_action( 'wpbc_other_versions_activation', array( $this, 'activate' ) ); // Activate
43 add_bk_action( 'wpbc_other_versions_deactivation', array( $this, 'deactivate' ) ); // Deactivate
44
45 parent::__construct();
46 }
47
48 public function in_page() {
49 return 'wpbc-settings';
50 }
51
52 public function tabs() {
53
54 $tabs = array();
55
56 $tabs[ 'form' ] = array(
57 'title' => __( 'Booking Form', 'booking') // Title of TAB
58 , 'page_title'=> __( 'Fields Settings', 'booking') // Title of Page
59 , 'hint' => __( 'Customize fields in booking form', 'booking') // Hint
60 //, 'link' => '' // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link
61 //, 'position' => '' // 'left' || 'right' || ''
62 //, 'css_classes'=> '' // CSS class(es)
63 //, 'icon' => '' // Icon - link to the real PNG img
64 , 'font_icon' => 'wpbc_icn_dashboard _customize dashboard rtt draw' // CSS definition of forn Icon
65 //, 'default' => false // Is this tab activated by default or not: true || false.
66 //, 'disabled' => false // Is this tab disbaled: true || false.
67 //, 'hided' => false // Is this tab hided: true || false.
68 , 'subtabs' => array()
69 );
70
71 if ( ! class_exists( 'wpdev_bk_personal' ) ) // FixIn: 8.1.1.12.
72 $tabs[ 'upgrade-link' ] = array(
73 'title' => __('Free vs Pro','booking') // Title of TAB
74 , 'hint' => __('Upgrade to higher versions', 'booking') // Hint
75 //, 'page_title' => __('Upgrade', 'booking') // Title of Page
76 , 'link' => 'https://wpbookingcalendar.com/features/' // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link
77 , 'position' => 'right' // 'left' || 'right' || ''
78 //, 'css_classes' => '' // CSS class(es)
79 //, 'icon' => '' // Icon - link to the real PNG img
80 , 'font_icon' => 'wpbc_icn_redeem'// CSS definition of forn Icon
81 //, 'default' => false // Is this tab activated by default or not: true || false.
82 //, 'subtabs' => array()
83 );
84
85 return $tabs;
86 }
87
88
89 public function content() {
90 $this->css();
91
92 // Define Notices Section and show some static messages, if needed
93 do_action( 'wpbc_hook_settings_page_header', 'form_field_free_settings');
94
95 if ( ! wpbc_is_mu_user_can_be_here('activated_user') ) return false; // Check if MU user activated, otherwise show Warning message.
96 //if ( ! wpbc_is_mu_user_can_be_here('only_super_admin') ) return false; // User is not Super admin, so exit. Basically its was already checked at the bottom of the PHP file, just in case.
97
98
99 // -------------------------------------------------------------------------------------------------------------
100 // Submit
101 // -------------------------------------------------------------------------------------------------------------
102 $submit_form_name = 'wpbc_form_field_free'; // Define form name
103 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
104 if ( isset( $_POST[ 'is_form_sbmitted_' . $submit_form_name ] ) ) {
105 // Nonce checking {Return false if invalid, 1 if generated between, 0-12 hours ago, 2 if generated between 12-24 hours ago. }
106 $nonce_gen_time = check_admin_referer( 'wpbc_settings_page_' . $submit_form_name ); // Its stop show anything on submitting, if it's not refear to the original page
107
108 wpbc_simple_form__page_save_submit(); // Save Changes
109 }
110
111 echo '<span class="wpdevelop">';
112 wpbc_js_for_bookings_page(); // JavaScript: Tooltips, Popover, Datepick (js & css) //////////////////
113 echo '</span>';
114
115
116 // -------------------------------------------------------------------------------------------------------------
117 // Content
118 // -------------------------------------------------------------------------------------------------------------
119 ?><div class="clear"></div>
120 <div class="wpbc_settings_flex_container"><?php
121
122 $this->left_navigation_menu_template();
123
124 ?><div class="wpbc_settings_flex_container_right"><?php
125
126 // This div required for hiding toolbar, if clicked items in Left Nav Bar.
127 ?><div id="wpbc_settings__custom_booking_forms_fields__toolbar" class="wpbc_container_hide__on_left_nav_click" style="margin:0 0 25px;"><?php
128
129 wpbc_simple_form__toolbar_free();
130
131 ?></div><?php
132
133
134 ?><form name="<?php echo esc_attr( $submit_form_name ); ?>" id="<?php echo esc_attr( $submit_form_name ); ?>" action="" method="post" style="width:100%;"><?php
135 ?><span class="metabox-holder"><?php
136 // N o n c e field, and key for checking S u b m i t
137 wp_nonce_field( 'wpbc_settings_page_' . $submit_form_name );
138
139 ?><input type="hidden" name="is_form_sbmitted_<?php echo esc_attr( $submit_form_name ); ?>" id="is_form_sbmitted_<?php echo esc_attr( $submit_form_name ); ?>" value="1" /><?php
140 ?><input type="hidden" name="form_visible_section" id="form_visible_section" value="" /><?php
141 ?><input type="hidden" name="reset_to_default_form" id="reset_to_default_form" value="" /><?php
142 ?><input type="hidden" name="booking_form_structure_type" id="booking_form_structure_type" value="<?php echo esc_attr( get_bk_option( 'booking_form_structure_type' ) ); ?>" /><?php
143
144 ?><div id="wpbc_settings__form_fields_metabox" class="wpbc_container_hide__on_left_nav_click"><?php
145
146 $this->content_section__form_fields();
147
148 ?></div><?php
149
150 wpbc_open_meta_box_section( 'wpbc_settings__form_layout', __('Form Layout', 'booking'), array( 'is_section_visible_after_load' => false, 'is_show_minimize' => false, 'css_class'=>'postbox wpbc_container_hide__on_left_nav_click' ) );
151 $this->content_section__form_layout();
152 wpbc_close_meta_box_section();
153
154 $is_can = apply_bk_filter( 'multiuser_is_user_can_be_here', true, 'only_super_admin' );
155 if ( $is_can ) {
156 wpbc_open_meta_box_section( 'wpbc_settings__form_theme', __('Color Theme', 'booking'), array( 'is_section_visible_after_load' => false, 'is_show_minimize' => false, 'css_class'=>'postbox wpbc_container_hide__on_left_nav_click' ) );
157
158 $this->content_section__form_color_theme();
159
160 ?><table class="form-table"><tbody><tr valign="top" class="wpbc_tr_booking_form_skins"><th scope="row"></th><td><fieldset><?php
161
162 ?><div class="wpbc_widget wpbc_widget_color_skins">
163 <div class="wpbc_widget_content wpbc_ajx_toolbar wpbc_no_background" style="margin:0 0 20px;">
164 <div class="ui_container" ><?php
165
166 $this->content_section__calendar_skin();
167
168 $this->content_section__time_picker_skin();
169
170 ?></div></div></div><?php
171
172 ?></fieldset></td></tr></tbody></table><?php
173
174 wpbc_close_meta_box_section();
175
176
177 wpbc_open_meta_box_section( 'wpbc_settings__form_options', __('Form Options', 'booking'), array( 'is_section_visible_after_load' => false, 'is_show_minimize' => false, 'css_class'=>'postbox wpbc_container_hide__on_left_nav_click' ) );
178 $this->content_section__form_options();
179 wpbc_close_meta_box_section();
180 }
181 ?></span><?php
182 // -----------------------------------------------------------------------------------------------------
183 // Save button
184 // -----------------------------------------------------------------------------------------------------
185 ?><div class="clear" style="height:5px;"></div>
186 <input type="submit" value="<?php esc_attr_e('Save Changes','booking'); ?>" class="button button-primary wpbc_submit_button wpbc_submit_button_trigger" />
187 </form>
188 <?php
189 //wpbc_show_preview__form();
190 ?>
191 </div>
192 </div><?php
193
194
195 wpbc_show_preview__form();
196
197 // Define templates and write JavaScript for Timeslots in ../generator-timeslots.php
198 do_action( 'wpbc_hook_settings_page_footer', 'form_field_free_settings' );
199
200 }
201
202
203 public function left_navigation_menu_template(){
204
205 ?>
206 <div class="wpbc_settings_flex_container_left wpbc_settings_flex_container_can_collapse">
207
208 <div class="wpbc_settings_navigation_column">
209 <div id="wpbc_settings__form_fields_tab" class="wpbc_settings_navigation_item wpbc_settings_navigation_item_active">
210 <a onclick="javascript:wpbc_navigation_click_show_section(this,'#wpbc_settings__form_fields_metabox,#wpbc_settings__custom_booking_forms_fields__toolbar', '.wpbc_container_hide__on_left_nav_click' );" href="javascript:void(0);">
211 <span><?php esc_html_e( 'Form Fields', 'booking' ); ?></span>
212 <i class="tooltip_right wpbc_set_nav__right_icon menu_icon icon-1x wpbc_icn_format_align_left" data-original-title="<?php echo esc_attr( __( 'Form Fields', 'booking' ) ); ?>"></i>
213 </a>
214 </div>
215 <div id="wpbc_settings__form_layout_tab" class="wpbc_settings_navigation_item">
216 <a onclick="javascript:wpbc_navigation_click_show_section(this,'#wpbc_settings__form_layout_metabox', '.wpbc_container_hide__on_left_nav_click' );" href="javascript:void(0);">
217 <span><?php esc_html_e( 'Form Layout', 'booking' ); ?></span>
218 <i class="tooltip_right wpbc_set_nav__right_icon menu_icon icon-1x wpbc_icn_dashboard" data-original-title="<?php echo esc_attr( __( 'Form Layout', 'booking' ) ); ?>"></i>
219 </a>
220 </div><?php
221
222 $is_can = apply_bk_filter( 'multiuser_is_user_can_be_here', true, 'only_super_admin' );
223 if ( $is_can ) {
224
225 ?><div id="wpbc_settings__form_theme_tab" class="wpbc_settings_navigation_item">
226 <a onclick="javascript:wpbc_navigation_click_show_section(this,'#wpbc_settings__form_theme_metabox', '.wpbc_container_hide__on_left_nav_click' );" href="javascript:void(0);">
227 <span><?php esc_html_e( 'Color Theme', 'booking' ); ?></span>
228 <i class="tooltip_right wpbc_set_nav__right_icon menu_icon icon-1x wpbc_icn_format_color_text 00wpbc-bi-pencil" data-original-title="<?php echo esc_attr( __( 'Color Theme', 'booking' ) ); ?>"></i>
229 </a>
230 </div>
231 <div id="wpbc_settings__form_options_tab" class="wpbc_settings_navigation_item">
232 <a onclick="javascript:wpbc_navigation_click_show_section(this,'#wpbc_settings__form_options_metabox', '.wpbc_container_hide__on_left_nav_click' );" href="javascript:void(0);">
233 <span><?php esc_html_e( 'Options', 'booking' ); ?></span>
234 <i class="tooltip_right wpbc_set_nav__right_icon menu_icon icon-1x wpbc_icn_tune" data-original-title="<?php echo esc_attr( __( 'Options', 'booking' ) ); ?>"></i>
235 </a>
236 </div><?php
237
238 }
239 ?><div id="wpbc_settings__form_options_tab" class="wpbc_settings_navigation_item wpbc_navigation_top_border0">
240 <a onclick="javascript:wpbc_navigation_click_show_section(this,'#wpbc_settings__form_preview_metabox', '.wpbc_container_hide__on_left_nav_click000' );" href="javascript:void(0);">
241 <span><?php esc_html_e( 'Preview', 'booking' ); ?></span>
242 <i class="tooltip_right wpbc_set_nav__right_icon menu_icon icon-1x wpbc-bi-eye" data-original-title="<?php echo esc_attr( __( 'Preview', 'booking' ) ); ?>"></i>
243 </a>
244 </div>
245 <div id="wpbc_settings__form_options_tab" class="wpbc_settings_navigation_item wpbc_navigation_sub_item0 wpbc_navigation_top_border">
246 <a onclick="javascript:jQuery(this).parents('.wpbc_settings_flex_container_can_collapse').toggleClass('wpbc_container_collapsed');
247 jQuery( this ).find('.wpbc_icon_for_collapse').removeClass('wpbc_icn_chevron_left wpbc_icn_chevron_right');
248 if (jQuery(this).parents('.wpbc_settings_flex_container_can_collapse').hasClass('wpbc_container_collapsed')){
249 jQuery( this ).find('.wpbc_icon_for_collapse').addClass('wpbc_icn_chevron_right');
250 } else {
251 jQuery( this ).find('.wpbc_icon_for_collapse').addClass('wpbc_icn_chevron_left');
252 }
253 jQuery( this ).blur();
254 "
255 href="javascript:void(0);" style="font-weight: 400;font-size:0.94em;">
256 <span><?php esc_html_e( 'Collapse menu', 'booking' ); ?></span>
257 <i class="wpbc_set_nav__right_icon menu_icon icon-1x wpbc_icn_chevron_left tooltip_right wpbc_icon_for_collapse"
258 data-original-title="<?php echo esc_attr( __( 'Collapse menu', 'booking' ) ); ?>"
259 style="margin-top:0;"></i>
260 </a>
261 </div>
262 </div>
263 </div>
264 <?php
265 }
266
267
268 public function content_section__form_fields(){
269
270 // Fields Generator
271 ?>
272 <span class="metabox_wpbc_form_field_free_generator" style="display:none;">
273 <div class="clear"></div>
274 <span class="metabox-holder">
275 <div class="wpbc_settings_row " >
276 <?php
277 wpbc_open_meta_box_section( 'wpbc_form_field_free_generator', __('Form Field Configuration', 'booking') );
278
279 $this->fields_generator_section();
280
281 wpbc_close_meta_box_section();
282 ?>
283 </div>
284 </span>
285 </span>
286 <?php
287
288 // Content
289 ?>
290 <div class="clear" style="margin-bottom:10px;"></div>
291 <div class="metabox-holder">
292 <?php
293
294 // Get Form Fields
295 $booking_form_structure = wpbc_simple_form__db__get_visual_form_structure(); // Get saved or Import form fields from OLD Free version
296
297 $this->show_booking_form_fields_table( $booking_form_structure );
298 ?>
299 </div>
300 <div class="clear" style="height:10px;"></div>
301 <?php
302
303 }
304
305
306 public function content_section__form_layout(){
307
308 $default_options_values = wpbc_get_default_options();
309 ?><table class="form-table"><?php
310
311 $field_value_or_default = ( empty( get_bk_option( 'booking_form_structure_type' ) ) ? $default_options_values['booking_form_structure_type'] : get_bk_option( 'booking_form_structure_type' ) );
312
313 $field_options = array( // Associated array of titles and values
314 'optgroup_sf_s' => array(
315 'optgroup' => true
316 , 'close' => false
317 , 'title' => '&nbsp;' . __('Standard Forms' ,'booking')
318 )
319 // FixIn: 10.7.1.7.
320 , 'wizard_2columns' => array(
321 'title' => __('Wizard (several steps)', 'booking')
322 , 'id' => ''
323 , 'name' => ''
324 , 'style' => ''
325 , 'class' => ''
326 , 'disabled' => false
327 , 'selected' => false
328 , 'attr' => array()
329 )
330 , 'wizard_services_a' => array(
331 'title' => __( 'Wizard (Steps Timline)', 'booking' )
332 , 'id' => ''
333 , 'name' => ''
334 , 'style' => ''
335 , 'class' => ''
336 , 'disabled' => false
337 , 'selected' => false
338 , 'attr' => array()
339 )
340 , 'vertical' => array(
341 'title' => __('Form under calendar', 'booking')
342 , 'id' => ''
343 , 'name' => ''
344 , 'style' => ''
345 , 'class' => ''
346 , 'disabled' => false
347 , 'selected' => false
348 , 'attr' => array()
349 )
350 , 'form_right' => array(
351 'title' => __('Form at right side of calendar', 'booking')
352 , 'id' => ''
353 , 'name' => ''
354 , 'style' => ''
355 , 'class' => ''
356 , 'disabled' => false
357 , 'selected' => false
358 , 'attr' => array()
359 )
360 , 'form_center' => array(
361 'title' => __('Form and calendar are centered', 'booking')
362 , 'id' => ''
363 , 'name' => ''
364 , 'style' => ''
365 , 'class' => ''
366 , 'disabled' => false
367 , 'selected' => false
368 , 'attr' => array()
369 )
370
371 , 'optgroup_sf_e' => array( 'optgroup' => true, 'close' => true )
372 // , 'optgroup_help_tips_s' => array(
373 // 'optgroup' => true
374 // , 'close' => false
375 // , 'title' => '&nbsp;' . __('Advanced Forms' ,'booking')
376 // )
377 // , 'form_2_columns' => array(
378 // 'title' => __('2 Columns', 'booking')
379 // , 'id' => ''
380 // , 'name' => ''
381 // , 'style' => ''
382 // , 'class' => ''
383 // , 'disabled' => true
384 // , 'selected' => false
385 // , 'attr' => array()
386 // )
387 // , 'optgroup_help_tips_e' => array( 'optgroup' => true, 'close' => true )
388
389 );
390
391 WPBC_Settings_API::field_select_row_static( 'booking_form_structure_type__select'
392 , array(
393 'type' => 'select'
394 , 'title' => __('Form Layout', 'booking')
395 , 'label' => ''
396 , 'disabled' => false
397 , 'disabled_options' => array()
398 , 'multiple' => false
399
400 , 'description' => ''
401 , 'description_tag' => 'span'
402
403 , 'group' => 'form_layout'
404 , 'tr_class' => ''
405 , 'class' => ''
406 , 'css' => 'width:auto;max-width:100%;'
407 , 'only_field' => false
408 , 'attr' => array()
409
410 , 'value' => $field_value_or_default
411 , 'options' => $field_options
412 , 'attr' => array( 'onchange' => "javascript: if( 'wizard_2columns' === jQuery( this ).val() ) { jQuery( '#booking_form_layout_width' ).val( '100' ); jQuery( '#booking_form_layout_width_px_pr' ).val( '%' ); jQuery( '#booking_form_layout_max_cols' ).val( '2' ); } "
413 . " if( 'wizard_services_a' === jQuery( this ).val() ) { jQuery( '#booking_form_layout_width' ).val( '100' ); jQuery( '#booking_form_layout_width_px_pr' ).val( '%' ); jQuery( '#booking_form_layout_max_cols' ).val( '2' ); } "
414 . " if( 'vertical' === jQuery( this ).val() ) { jQuery( '#booking_form_layout_max_cols' ).val( '2' ); jQuery( '#booking_form_layout_width' ).val( '100' ); jQuery( '#booking_form_layout_width_px_pr' ).val( '%' ); } "
415 . " if( 'form_right' === jQuery( this ).val() ) { jQuery( '#booking_form_layout_max_cols' ).val( '1' ); jQuery( '#booking_form_layout_width' ).val( '440' ); jQuery( '#booking_form_layout_width_px_pr' ).val( 'px' ); } "
416 . " if( 'form_center' === jQuery( this ).val() ) { jQuery( '#booking_form_layout_max_cols' ).val( '1' ); jQuery( '#booking_form_layout_width' ).val( '440' ); jQuery( '#booking_form_layout_width_px_pr' ).val( 'px' ); } "
417 )
418 )
419 );
420
421
422 $field_value_or_default = ( empty( get_bk_option( 'booking_form_layout_max_cols' ) ) ? $default_options_values['booking_form_layout_max_cols'] : get_bk_option( 'booking_form_layout_max_cols' ) );
423 WPBC_Settings_API::field_select_row_static( 'booking_form_layout_max_cols'
424 , array(
425 'type' => 'select'
426 , 'title' => __( 'Columns', 'booking' )
427 , 'label' => ''
428 , 'disabled' => false
429 , 'disabled_options' => array()
430 , 'multiple' => false
431
432 , 'description' => __('Set number of columns in booking form','booking')
433 , 'description_tag' => 'span'
434
435 , 'group' => 'form_layout'
436 , 'tr_class' => ''
437 , 'class' => ''
438 , 'css' => 'width:auto;max-width:100%;'
439 , 'only_field' => false
440 , 'attr' => array()
441
442 , 'value' => $field_value_or_default
443 , 'options' => array( 1 => 1, 2 => 2, 3 => 3 )
444 //, 'attr' => array( 'onchange' => "javascript: if( 'wizard_2columns' === jQuery( this ).val() ) { jQuery( '#booking_form_layout_width' ).val( '100' ); jQuery( '#booking_form_layout_width_px_pr' ).find( 'option' ).prop( 'selected', false ); jQuery( '#booking_form_layout_width_px_pr' ).val( '%' ); } " )
445 )
446 );
447
448
449 $id = 'booking_form_layout';
450 ?><tr class="wpbc_tr_<?php echo esc_attr( $id ); ?>_size__select">
451 <th scope="row" style="vertical-align: middle;">
452 <label for="wpbc_booking_width" class="wpbc-form-text"><?php esc_html_e('Form Width:', 'booking'); ?></label>
453 </th>
454 <td class=""><fieldset style="display: flex;flex-flow: row wrap;justify-content: flex-start;align-items: center;"><?php
455
456 $field_name = $id . '_width'; // 100
457 WPBC_Settings_API::field_text_row_static( $field_name
458 , array(
459 'type' => 'text'
460 , 'placeholder' => '100'
461 , 'class' => ''
462 , 'css' => 'width:5em;'
463 , 'only_field' => true
464 , 'attr' => array()
465 , 'value' => ( empty( get_bk_option( $field_name ) ) ? $default_options_values[ $field_name ] : get_bk_option( $field_name ) )
466 )
467 );
468 $field_name = $id . '_width_px_pr'; // %
469 WPBC_Settings_API::field_select_row_static( $field_name
470 , array(
471 'type' => 'select'
472 , 'multiple' => false
473 , 'class' => ''
474 , 'css' => 'width:4em;'
475 , 'only_field' => true
476 , 'attr' => array()
477 , 'options' => array( 'px' => 'px', '%' => '%' )
478 , 'value' => ( empty( get_bk_option( $field_name ) ) ? $default_options_values[ $field_name ] : get_bk_option( $field_name ) )
479 )
480 );
481 ?><span class="description"> <?php esc_html_e('Set width of calendar' ,'booking'); ?></span></fieldset></td>
482 </tr><?php
483
484
485 ?></table>
486 <script type="text/javascript">
487 jQuery('select[name=\"booking_form_structure_type__select\"]').on( 'change', function(){
488 var selected_val = jQuery('#booking_form_structure_type__select').val();
489 jQuery('#booking_form_structure_type').val( selected_val );
490 } );
491 </script><?php
492 }
493
494
495 public function content_section__form_color_theme(){
496
497 $default_options_values = wpbc_get_default_options();
498
499 ?><table class="form-table"><?php
500
501 $field_name = 'booking_form_theme';
502 $field_params = array(
503 'type' => 'select'
504 , 'default' => $default_options_values[ $field_name ] //'Off'
505 , 'title' => __('Color Theme' ,'booking')
506 , 'description' => __('Select a color theme for your booking form that matches the look of your website.' ,'booking')
507 // . '<div class="wpbc-general-settings-notice wpbc-settings-notice notice-info">'
508 // . __('When you select a color theme, it also change the calendar and time-slot picker skins to match your choice. Customize these options separately as needed.' ,'booking')
509 // .'</div>'
510 , 'options' => array(
511 '' => __( 'Light', 'booking' ),
512 'wpbc_theme_dark_1' => __( 'Dark', 'booking' )
513 )
514 , 'group' => 'form'
515 , 'value' => ( empty( get_bk_option( $field_name ) ) ? $default_options_values[ $field_name ] : get_bk_option( $field_name ) ),
516 'attr' => array( 'onchange' => "javascript: wpbc_on_change__form_color_theme( this );" )
517
518 );
519
520 WPBC_Settings_API::field_select_row_static( $field_name, $field_params );
521
522 ?></table><?php
523 ?><script type="text/javascript">
524 function wpbc_on_change__form_color_theme( _this ){
525 var wpbc_cal_dark_skin_path;
526 if ( 'wpbc_theme_dark_1' == jQuery( _this ).val() ){
527 jQuery( '.wpbc_center_preview,.wpbc_container.wpbc_container_booking_form' ).addClass( 'wpbc_theme_dark_1' );
528 wpbc_cal_dark_skin_path = '<?php echo esc_url( WPBC_PLUGIN_URL ); ?>/css/skins/24_9__dark_1.css';
529 jQuery( '#ui_btn_cstm__set_calendar_skin' ).find( 'option' ).prop( 'selected', false );
530 jQuery( '#ui_btn_cstm__set_calendar_skin' ).find( 'option[value="' + wpbc_cal_dark_skin_path + '"]' ).prop( 'selected', true ).trigger( 'change' );
531 wpbc_cal_dark_skin_path = '<?php echo esc_url( WPBC_PLUGIN_URL ); ?>/css/time_picker_skins/black.css';
532 jQuery( '#ui_btn_cstm__set_time_picker_skin' ).find( 'option' ).prop( 'selected', false );
533 jQuery( '#ui_btn_cstm__set_time_picker_skin' ).find( 'option[value="' + wpbc_cal_dark_skin_path + '"]' ).prop( 'selected', true ).trigger( 'change' );
534 } else {
535 jQuery( '.wpbc_center_preview,.wpbc_container.wpbc_container_booking_form' ).removeClass( 'wpbc_theme_dark_1' );
536 wpbc_cal_dark_skin_path = '<?php echo esc_url( WPBC_PLUGIN_URL ); ?>/css/skins/24_9__light_square_1.css';
537 jQuery( '#ui_btn_cstm__set_calendar_skin' ).find( 'option' ).prop( 'selected', false );
538 jQuery( '#ui_btn_cstm__set_calendar_skin' ).find( 'option[value="' + wpbc_cal_dark_skin_path + '"]' ).prop( 'selected', true ).trigger( 'change' );
539 wpbc_cal_dark_skin_path = '<?php echo esc_url( WPBC_PLUGIN_URL ); ?>/css/time_picker_skins/light__24_8.css';
540 jQuery( '#ui_btn_cstm__set_time_picker_skin' ).find( 'option' ).prop( 'selected', false );
541 jQuery( '#ui_btn_cstm__set_time_picker_skin' ).find( 'option[value="' + wpbc_cal_dark_skin_path + '"]' ).prop( 'selected', true ).trigger( 'change' );
542 }
543 }
544 </script><?php
545 }
546
547
548 public function content_section__calendar_skin(){
549
550 ?><script type="text/javascript">
551 jQuery( document ).ready( function (){
552
553 // Calendar skin
554 var template__var = wp.template( 'wpbc_ajx_widget_change_calendar_skin' );
555
556 jQuery( '.wpbc_widget_color_skins .ui_container' ).append(
557
558 template__var({ 'ajx_cleaned_params': {
559 'customize_plugin__booking_skin': '<?php echo esc_js( get_bk_option( 'booking_skin' ) ); ?>',
560 }
561 })
562 );
563 } );
564 </script><?php
565 }
566
567
568 public function content_section__time_picker_skin(){
569
570 ?><script type="text/javascript">
571 jQuery( document ).ready( function (){
572 // Time Picker
573 var template__var = wp.template( 'wpbc_ajx_widget_change_time_picker' );
574
575 jQuery( '.wpbc_widget_color_skins .ui_container' ).append(
576
577 template__var({ 'ajx_cleaned_params': {
578 'customize_plugin__time_picker_skin': '<?php echo esc_js( get_bk_option( 'booking_timeslot_picker_skin' ) ); ?>'
579 }
580 })
581 );
582 } );
583 </script><?php
584 }
585
586
587 public function content_section__form_options(){
588
589 $default_options_values = wpbc_get_default_options();
590
591 ?><table class="form-table"><?php
592
593 $field_name = 'booking_is_use_autofill_4_logged_user';
594 $field_params = array(
595 'type' => 'checkbox'
596 , 'default' => $default_options_values[ $field_name ] //'Off'
597 , 'title' => __('Auto-fill fields' ,'booking')
598 , 'label' => __('Check the box to activate auto-fill form fields for logged in users.' ,'booking')
599 , 'description' => ''
600 , 'group' => 'form'
601 , 'value' => ( empty( get_bk_option( $field_name ) ) ? $default_options_values[ $field_name ] : get_bk_option( $field_name ) )
602 );
603 WPBC_Settings_API::field_checkbox_row_static( $field_name, $field_params );
604
605
606 $field_name = 'booking_timeslot_picker';
607 $field_params = array(
608 'type' => 'checkbox'
609 , 'default' => $default_options_values[ $field_name ] //'Off'
610 , 'title' => __('Time picker for time slots' ,'booking')
611 , 'label' => __('Show time slots as a time picker instead of a select box.' ,'booking')
612 , 'description' => ''
613 , 'group' => 'time_slots'
614 , 'tr_class' => 'wpbc_timeslot_picker'
615 , 'value' => ( empty( get_bk_option( $field_name ) ) ? $default_options_values[ $field_name ] : get_bk_option( $field_name ) )
616 );
617 WPBC_Settings_API::field_checkbox_row_static( $field_name, $field_params );
618
619 ?></table><?php
620
621 ?><div style="display: flex;flex-flow: row wrap;justify-content: flex-end;align-items: center;font-size: 10px;">
622 <div style="margin-right: 1em;font-weight: 600;"><?php esc_html_e('Global Settings','booking'); ?>: </div>
623 <i style="margin-right: 5px;<?php echo ( get_bk_option( 'booking_is_use_captcha' ) === 'On' ) ? 'color: #036aab' : ''; ?>"
624 class="wpbc_set_nav__right_icon menu_icon icon-1x <?php echo ( get_bk_option( 'booking_is_use_captcha' ) === 'On' ) ? 'wpbc-bi-toggle2-on wpbc_set_nav__icon_on' : 'wpbc-bi-toggle2-off'; ?>"
625 ></i><a href="<?php echo esc_url( wpbc_get_settings_url() ) . '&scroll_to_section=wpbc_general_settings_form_tab'; ?>">
626 <span ><?php
627 esc_html_e( 'CAPTCHA', 'booking' );
628 echo ' ';
629 echo esc_html( get_bk_option( 'booking_is_use_captcha' ) );
630 ?></span>
631 </a>
632 </div><?php
633 }
634
635
636 private function help_notice__show_time_fields_once() {
637
638 ?>
639 <div class="wpbc-settings-notice notice-error notice-helpful-info0" style="margin: 0 0 30px;">
640 <?php
641 echo '<strong>';
642 esc_html_e( 'Error', 'booking' );
643 echo '!</strong>&nbsp;&nbsp;';
644
645 /* translators: 1: ... */
646 echo wp_kses_post( __( 'You can either use the time slots field or the start time and duration time fields, but not both. If you choose to use the start time and duration time fields, make sure to use them together.', 'booking' ) );
647 ?>
648 </div>
649 <?php
650 }
651
652 private function help_notice__show_missed_time_fields() {
653
654 ?>
655 <div class="wpbc-settings-notice notice-error notice-helpful-info0" style="margin: 0 0 30px;">
656 <?php
657 echo '<strong>';
658 esc_html_e( 'Error', 'booking' );
659 echo '!</strong>&nbsp;&nbsp;';
660
661 /* translators: 1: ... */
662 echo wp_kses_post( __( 'You must use both the start time field and the duration time field together.', 'booking' ) );
663 ?>
664 </div>
665 <?php
666 }
667
668 private function is_exist_duplicated_time_fields( $visual_form_structure ) {
669
670 $time_fields_arr = array();
671 foreach ( $visual_form_structure as $field_arr ) {
672 if (
673 ( isset( $field_arr['active'] ) ) &&
674 ( isset( $field_arr['name'] ) ) &&
675 ( 'on' === strtolower( $field_arr['active'] ) ) &&
676 ( in_array( $field_arr['name'], array(
677 'rangetime',
678 'durationtime',
679 'starttime',
680 'endtime',
681 ), true ) ) ) {
682 $time_fields_arr[] = $field_arr['name'];
683 }
684 }
685
686 if ( in_array( 'rangetime', $time_fields_arr, true ) ) {
687
688 if ( count( $time_fields_arr ) > 1 ) {
689 return 'duplicated_time_fields';
690 }
691
692 } else {
693
694 if ( count( $time_fields_arr ) === 1 ) {
695 return 'missed_time_fields';
696 }
697 }
698
699 return 'ok';
700 }
701
702 /**
703 * Show Fields Table */
704 private function show_booking_form_fields_table( $booking_form_structure ) {
705
706 $booking_form_structure = maybe_unserialize( $booking_form_structure );
707
708 $skip_obligatory_field_types =array();// array( 'calendar', 'submit', 'captcha' );
709
710 $obligatory_field_types = array( 'calendar', 'submit', 'email' );
711 if ( ! wpbc_is_mu_user_can_be_here( 'only_super_admin' ) ) {
712 $obligatory_field_types[] = 'captcha';
713 }
714
715
716 if ( 'duplicated_time_fields' === $this->is_exist_duplicated_time_fields( $booking_form_structure ) ) {
717 $this->help_notice__show_time_fields_once();
718 }
719 if ( 'missed_time_fields' === $this->is_exist_duplicated_time_fields( $booking_form_structure ) ) {
720 $this->help_notice__show_missed_time_fields();
721 }
722
723 ?><table class="widefat wpbc_input_table sortable wpdevelop wpbc_table_form_free" cellspacing="0" cellpadding="0"> <?php //FixIn: 10.1.2.2 style="flex:0 1 49.9%;"> ?>
724 <thead>
725 <tr>
726 <th class="sort"><span class="wpbc_icn_swap_vert" aria-hidden="true"></span></th>
727 <th class="field_active"><?php echo esc_js( __('Active', 'booking') ); ?></th>
728 <th class="field_label"><?php echo esc_js( __('Field Label', 'booking') ); ?></th>
729 <th class="field_required"><?php echo esc_js( __('Required', 'booking') ); ?></th>
730 <!--th class="field_options"><?php echo esc_js( __('Type', 'booking') ) . ' | ' . esc_js( __('Name', 'booking') ); ?></th-->
731 <th class="field_actions"><?php echo esc_js( __('Actions', 'booking') ); ?></th>
732 </tr>
733 </thead>
734 <tbody class="wpbc_form_fields_body">
735 <?php
736
737 $i=0;
738
739 foreach ( $booking_form_structure as $form_field ) {
740
741 $defaults = array(
742 'type' => 'text'
743 , 'name' => 'unique_name'
744 , 'obligatory' => 'Off'
745 , 'active' => 'On'
746 , 'required' => 'Off'
747 , 'label' => ''
748 , 'value' => ''
749 );
750 $form_field = wp_parse_args( $form_field, $defaults );
751
752 if( ! in_array( $form_field['type'], $skip_obligatory_field_types ) ) {
753
754 $i++;
755
756 $row = '<tr class="account">';
757
758 $row .= '<td class="sort"><span class="wpbc_icn_drag_indicator" aria-hidden="true"></span></td>';
759
760 // Flex Toggle
761 if ( 1 ) {
762 ob_start();
763 $is_checked = ( $form_field['active'] === 'On' );
764 $field_id = 'wpbc_on_off_' . 'active_' . intval( microtime( true ) ) . '_' . wp_rand( 1, 1000 );
765 $field_name = 'form_field_active[' . $i . ']';
766 $field_value = esc_attr( $form_field['active'] );
767 $params_checkbox = array(
768 'id' => $field_id // HTML ID of element
769 , 'name' => $field_name
770 , 'label' => array( 'title' => '', 'position' => 'right' )
771 , 'toggle_style' => '' // CSS of select element
772 , 'class' => 'wpbc_visible_but_out_screen ' // CSS Class of select element
773 , 'disabled' => ''
774 , 'attr' => array( 'autocomplete' => 'off' ) // Any additional attributes, if this radio | checkbox element
775 , 'legend' => '' //wp_kses_post( $field_title ) // aria-label parameter
776 , 'value' => $field_value // Some Value from options array that selected by default
777 , 'selected' => $is_checked // Selected or not
778 //, 'onchange' => "jQuery( this ).parents('.wpbc_searchable_on_off').find('.wpbc_label_on_off').hide();jQuery( this ).parents('.wpbc_searchable_on_off').find( jQuery( this ).is(':checked') ? '.wpbc_label_on' : '.wpbc_label_off' ).show();" // JavaScript code
779 //, 'onfocus' => "console.log( 'ON FOCUS:', jQuery( this ).is(':checked') , 'in element:' , jQuery( this ) );" // JavaScript code
780 //, 'hint' => array( 'title' => __('Send email notification to customer about this operation' ,'booking') , 'position' => 'top' )
781 );
782 wpbc_flex_toggle( $params_checkbox );
783 $flex_toggle = ob_get_clean();
784 }
785
786 $row .= '<td class="field_active"><div class="wpbc_align_vertically">'
787 . ( ( ( $form_field['obligatory'] != 'On' ) && ( ! in_array( $form_field['type'], $obligatory_field_types ) ) )
788 ? $flex_toggle
789 // ? '<input type="checkbox" name="form_field_active[' . $i . ']" value="' . esc_attr( $form_field['active'] ) . '" ' . checked( $form_field['active'], 'On' , false ) . ' autocomplete="off" />'
790 : '' )
791
792 .'</div></td>';
793 $row .= '<td class="field_label"><div class="wpbc_align_vertically">'
794 . '<legend class="screen-reader-text"><span>' . esc_attr( $form_field['label'] ) . '</span></legend>'
795 .'<input type="text"
796 name="form_field_label[' . $i . ']"
797 value="' . esc_attr( $form_field['label'] ) . '"
798 class="regular-text"
799 placeholder="' . ( ( $form_field['name'] == 'calendar' ) ? __( 'Select date(s)', 'booking' ) : esc_attr( $form_field['label'] ) ) . '"
800 autocomplete="off"
801 /> ';
802 if (
803 ( in_array( $form_field['name'], array( 'calendar', 'submit', 'captcha', 'rangetime', 'durationtime', 'starttime', 'endtime' ), true ) )
804 || ( in_array( $form_field['type'], array( 'calendar' ) ) )
805 ){
806 $css_label = 'wpbc_label_approved';
807 $css_label = (( $form_field['name'] == 'calendar' ) || ( $form_field['type'] == 'calendar' )) ? 'wpbc_label_deleted_resource' : $css_label;
808 $css_label = ( $form_field['name'] == 'submit' ) ? 'wpbc_label_resource' : $css_label;
809 $css_label = ( $form_field['name'] == 'captcha' ) ? 'wpbc_label_pending' : $css_label;
810 $css_label = ( in_array( $form_field['name'], array( 'rangetime', 'durationtime', 'starttime', 'endtime' ), true ) ) ? 'wpbc_label_approved' : $css_label;
811
812 $row .= '<div class="field_type_name_description"><div class="field_type_name_value wpbc_label '.$css_label.'" style="text-transform: uppercase;padding: 0 1em;">';
813
814 if ( ( $form_field['name'] == 'calendar' ) ||
815 ( $form_field['type'] == 'calendar' ) ) { $row .= __( 'Calendar', 'booking' );
816 } else if ( $form_field['name'] == 'rangetime' ) { $row .= __( 'Time Slots', 'booking' );
817 } else if ( $form_field['name'] == 'durationtime' ) { $row .= __( 'Duration Time', 'booking' ) . ' / ' . __( 'Service Duration', 'booking' );
818 } else if ( $form_field['name'] == 'starttime' ) { $row .= __( 'Start Time', 'booking' );
819 } else if ( $form_field['name'] == 'endtime' ) { $row .= __( 'End Time', 'booking' );
820 } else if ( $form_field['name'] == 'submit' ) { $row .= $form_field['name'] . ' ' . __( 'Button', 'booking' );
821 } else { $row .= $form_field['name'];
822 }
823 $row .= '</div></div>';
824 } else {
825 $row .= '<div class="field_type_name_description">
826 ' . __( 'Type', 'booking' ) . ': <div class="field_type_name_value">' . $form_field['type'] . '</div>
827 <span class="field_type_name_separator">|</span>
828 ' . __( 'Name', 'booking' ) . ': <div class="field_type_name_value">' . $form_field['name'] . '</div>
829 </div>';
830 }
831 $row .= '<input type="hidden" value="'. esc_attr( ( 'select' == $form_field['type'] ) ? 'selectbox' : $form_field['type'] ) . '" name="form_field_type[' . $i . ']" autocomplete="off" />'
832 . '<input type="hidden" value="'. esc_attr( $form_field['name'] ) . '" name="form_field_name[' . $i . ']" autocomplete="off" />'
833 . '<input type="hidden" value="'. esc_attr( $form_field['value'] ) . '" name="form_field_value[' . $i . ']" autocomplete="off" />'
834 .'</div></td>';
835
836 //FixIn: TimeFreeGenerator
837 $is_show_required_checkbox = true;
838 if ( ( $form_field['obligatory'] == 'On' ) || ( in_array( $form_field['type'], $obligatory_field_types ) ) ) {
839 $is_show_required_checkbox = false;
840 }
841 if ( isset( $form_field['if_exist_required'] ) && ( $form_field['if_exist_required'] == 'On' ) ) {
842 $is_show_required_checkbox = false;
843 }
844
845 // Flex Toggle
846 if ( 1 ) {
847 ob_start();
848 $is_checked = ( $form_field['required'] === 'On' );
849 $field_id = 'wpbc_on_off_' . 'required_' . intval( microtime( true ) ) . '_' . wp_rand( 1, 1000 );
850 $field_name = 'form_field_required[' . $i . ']';
851 $field_value = esc_attr( $form_field['required'] );
852 $params_checkbox = array(
853 'id' => $field_id // HTML ID of element
854 , 'name' => $field_name
855 , 'label' => array( 'title' => '', 'position' => 'right' )
856 , 'toggle_style' => '' // CSS of select element
857 , 'class' => 'wpbc_visible_but_out_screen ' // CSS Class of select element
858 , 'disabled' => ''
859 , 'attr' => array( 'autocomplete' => 'off' ) // Any additional attributes, if this radio | checkbox element
860 , 'legend' => '' //wp_kses_post( $field_title ) // aria-label parameter
861 , 'value' => $field_value // Some Value from options array that selected by default
862 , 'selected' => $is_checked // Selected or not
863 //, 'onchange' => "jQuery( this ).parents('.wpbc_searchable_on_off').find('.wpbc_label_on_off').hide();jQuery( this ).parents('.wpbc_searchable_on_off').find( jQuery( this ).is(':checked') ? '.wpbc_label_on' : '.wpbc_label_off' ).show();" // JavaScript code
864 //, 'onfocus' => "console.log( 'ON FOCUS:', jQuery( this ).is(':checked') , 'in element:' , jQuery( this ) );" // JavaScript code
865 //, 'hint' => array( 'title' => __('Send email notification to customer about this operation' ,'booking') , 'position' => 'top' )
866 );
867 wpbc_flex_toggle( $params_checkbox );
868 $flex_toggle = ob_get_clean();
869 }
870 $row .= '<td class="field_required"><div class="wpbc_align_vertically">'
871 . ( $is_show_required_checkbox ? $flex_toggle : '' )
872 // ( $is_show_required_checkbox ? '<input type="checkbox" name="form_field_required[' . $i . ']" value="' . esc_attr( $form_field['required'] ) . '" ' . checked( $form_field['required'], 'On' , false ) . ' autocomplete="off" />' : '' )
873 .'</div></td>';
874 // $row .= '<td class="field_options"><div class="wpbc_align_vertically">'
875 // . '<input type="text" disabled="DISABLED" value="'. '' . $form_field['type']. ' | ' . $form_field['name'] . '" autocomplete="off" />'
876 // .'</div></td>';
877 $row .= '<td class="field_actions">';
878 if ( ( $form_field['obligatory'] != 'On' ) && ( ! in_array( $form_field['type'], array( 'captcha' ) ) ) ) {
879 //TODO: refactor here: 2024-05-31 23:15
880 $row .= '<a href="javascript:void(0)" onclick="javascript:wpbc_start_edit_form_field(' . $i . ');" class="tooltip_top button-secondary button" title="'.__('Edit' ,'booking').'"><i class="wpbc_icn_draw"></i></a>';
881 $row .= '<a href="javascript:void(0)" class="tooltip_top button-secondary button delete_bk_link" title="'.__('Remove' ,'booking').'"><i class="wpbc_icn_close"></i></a>';
882 //TODO: refactor here: 2024-05-31 23:15
883 /*
884 ob_start();
885 ?>
886 <div class="wpbc_ajx_toolbar wpbc_no_background" style="margin:0;">
887 <div class="ui_container ui_container_small">
888 <div class="ui_group ui_group__search_url">
889 <?php
890 wpbc_ajx__ui__all_or_new( array(), array('wh_what_bookings'=>'new') );
891
892 echo '<div class="ui_element" style="margin:0 5px 0 -10px"><a href="javascript:void(0)" onclick="javascript:wpbc_start_edit_form_field(' . $i . ');" class="wpbc_ui_control wpbc_ui_button wpbc_ui_button tooltip_top " title="'.__('Edit' ,'booking').'"><i class="wpbc_icn_draw"></i></a></div>';
893 echo '<div class="ui_element"><a href="javascript:void(0)" class="wpbc_ui_control wpbc_ui_button wpbc_ui_button tooltip_top button delete_bk_link" title="'.__('Remove' ,'booking').'"><i class="wpbc_icn_close"></i></a></div>';
894
895 ?></div></div></div><?php
896 $elemnt = ob_get_clean();
897 $row .= $elemnt;
898 */
899 }
900 $row .= '</td>';
901
902 $row .= '</tr>';
903 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
904 echo $row;
905 }
906 }
907
908 ?>
909 </tbody>
910 <?php /* ?>
911 <tfoot>
912 <tr>
913 <th colspan="6">
914 <a href="#" class="remove_rows button"><?php esc_html_e( 'Remove selected field' ,'booking'); ?></a>
915 </th>
916 </tr>
917 </tfoot>
918 <?php /**/ ?>
919 </table><?php
920
921
922 }
923
924
925 /** CSS for this page */
926 private function css() {
927 ?>
928 <style type="text/css">
929 /* toolbar fix */
930 .wpdevelop .visibility_container .control-group {
931 margin: 2px 8px 3px 0; /* margin: 0 8px 5px 0; */ /* FixIn: 9.5.4.8 */
932 }
933 /* Selectbox element in toolbar */
934 .visibility_container select optgroup{
935 color:#999;
936 vertical-align: middle;
937 font-style: italic;
938 font-weight: 400;
939 }
940 .visibility_container select option {
941 padding:5px;
942 font-weight: 600;
943 }
944 .visibility_container select optgroup option{
945 padding: 5px 20px;
946 color:#555;
947 font-weight: 600;
948 }
949 #wpbc_create_new_custom_form_name_fields {
950 width: 360px;
951 display:none;
952 }
953 @media (max-width: 399px) {
954 #wpbc_create_new_custom_form_name_fields {
955 width: 100%;
956 }
957 }
958 </style>
959 <?php
960 wpbc_timeslots_free_css(); //FixIn: TimeFreeGenerator
961 }
962
963
964 // -----------------------------------------------------------------------------------------------------------------
965 // Generators
966 // -----------------------------------------------------------------------------------------------------------------
967 /** Sections with Add New Fields forms */
968 private function fields_generator_section() {
969 ?>
970 <div class="wpbc_field_generator wpbc_field_generator_info">
971 <?php
972
973 echo
974 '<p><strong>' . esc_html__('Shortcodes' ,'booking') . '.</strong> '
975 . wp_kses_post( sprintf(__('You can generate the form fields for your form (at the left side) by selection specific field in the above selectbox.' ,'booking'),'<code><strong>[email* email]</strong></code>'))
976 /* translators: 1: ... */
977 .'<br/>' . wp_kses_post( sprintf( __( 'Please read more about the booking form fields configuration %1$shere%2$s.', 'booking' ),'<a href="https://wpbookingcalendar.com/faq/booking-form-fields/" target="_blank">', '</a>') )
978
979 . '</p><p><strong>' . esc_html__('Default Form Templates' ,'booking') . '.</strong> ' .
980 /* translators: 1: ... */
981 wp_kses_post( sprintf( __( 'You can reset your active form template by selecting default %1$sform template%2$s at the top toolbar. Please select the form template and click on %3$sReset%4$s button for resetting only active form (Booking Form or Content of Booking Fields form). Click on %5$sBoth%6$s button if you want to reset both forms: Booking Form and Content of Booking Fields form.', 'booking' )
982 ,'<strong>','</strong>'
983 ,'<strong>','</strong>'
984 ,'<strong>','</strong>'
985 ) )
986 .'</p>';
987 ?>
988 </div>
989 <div class="wpbc_field_generator wpbc_field_generator_text">
990 <?php
991
992 $this->generate_field(
993 'text_field_generator'
994 , array(
995 'active' => true
996 , 'required' => true
997 , 'label' => true
998 , 'name' => true
999 , 'value' => false
1000 , 'type' => 'text'
1001 )
1002 );
1003 ?>
1004 </div>
1005 <div class="wpbc_field_generator wpbc_field_generator_textarea">
1006 <?php
1007
1008 $this->generate_field(
1009 'textarea_field_generator'
1010 , array(
1011 'active' => true
1012 , 'required' => true
1013 , 'label' => true
1014 , 'name' => true
1015 , 'value' => false
1016 , 'type' => 'textarea'
1017 )
1018 );
1019 ?>
1020 </div>
1021 <div class="wpbc_field_generator wpbc_field_generator_select wpbc_field_generator_selectbox">
1022 <?php
1023 $this->generate_field(
1024 'selectbox_field_generator'
1025 , array(
1026 'active' => true
1027 , 'required' => true
1028 , 'label' => true
1029 , 'name' => true
1030 , 'value' => true
1031 , 'type' => 'selectbox'
1032 )
1033 );
1034 ?>
1035 </div>
1036 <div class="wpbc_field_generator wpbc_field_generator_checkbox">
1037 <?php
1038
1039 $this->generate_field(
1040 'checkbox_field_generator'
1041 , array(
1042 'active' => true
1043 , 'required' => true
1044 , 'label' => true
1045 , 'name' => true
1046 , 'value' => false
1047 , 'type' => 'checkbox'
1048 )
1049 );
1050 ?>
1051 </div>
1052 <?php
1053 //FixIn: TimeFreeGenerator
1054 ?>
1055 <div class="wpbc_field_generator wpbc_field_generator_rangetime">
1056 <?php
1057
1058 $this->generate_field(
1059 'rangetime_field_generator'
1060 , array(
1061 'active' => true
1062 , 'required' => true
1063 , 'label' => true
1064 , 'name' => true
1065 , 'value' => true
1066 , 'type' => 'selectbox'
1067
1068 , 'required_attr' => array( 'disabled' => true
1069 , 'value' => 'On'
1070 )
1071 , 'label_attr' => array( 'placeholder' => __( 'Time Slots', 'booking' )
1072 , 'value' => __( 'Time Slots', 'booking' )
1073 )
1074 , 'name_attr' => array( 'disabled' => true
1075 , 'placeholder' => 'rangetime'
1076 , 'value' => 'rangetime'
1077 )
1078 , 'value_attr' => array( 'value' => "10:00 AM - 12:00 PM@@10:00 - 12:00\n12:00 PM - 02:00 PM@@12:00 - 14:00\n13:00 - 14:00\n11:00 - 15:00\n14:00 - 16:00\n16:00 - 18:00\n18:00 - 20:00"
1079 , 'attr' => array(
1080 'placeholder' => "10:00 AM - 12:00 PM@@10:00 - 12:00\n12:00 PM - 02:00 PM@@12:00 - 14:00\n13:00 - 14:00\n11:00 - 15:00\n14:00 - 16:00\n16:00 - 18:00\n18:00 - 20:00"
1081 )
1082 , 'rows' => 8
1083 , 'cols' => 37
1084 )
1085 )
1086 );
1087 ?>
1088 </div>
1089 <?php
1090
1091 // FixIn: 10.10.1.4.
1092 ?>
1093 <div class="wpbc_field_generator wpbc_field_generator_durationtime">
1094 <?php
1095 // __( 'Start Time', 'booking' ) . ' / ' . __( 'Duration Time', 'booking' ), .
1096 $this->generate_field(
1097 'durationtime_field_generator',
1098 array(
1099 'active' => true,
1100 'required' => true,
1101 'label' => true,
1102 'name' => true,
1103 'value' => true,
1104 'type' => 'selectbox',
1105 'required_attr' => array(
1106 'disabled' => true,
1107 'value' => 'On',
1108 ),
1109 'label_attr' => array(
1110 'placeholder' => __( 'Duration Time', 'booking' ),
1111 'value' => __( 'Duration Time', 'booking' ),
1112 ),
1113 'name_attr' => array(
1114 'disabled' => true,
1115 'placeholder' => 'durationtime',
1116 'value' => 'durationtime',
1117 ),
1118 'value_attr' => array(
1119 'value' => "Service A (15 min)@@00:15\nService B (20 min)@@00:20\nService C (30 min)@@00:30\nService D (1 hour)@@01:00\nService E (2 hours)@@02:00",
1120 'attr' => array(
1121 'placeholder' => "Service A (15 min)@@00:15\nService B (20 min)@@00:20\nService C (30 min)@@00:30\nService D (1 hour)@@01:00\nService E (2 hours)@@02:00",
1122 ),
1123 'rows' => 8,
1124 'cols' => 37,
1125 ),
1126 )
1127 );
1128 ?>
1129 </div>
1130 <?php
1131
1132
1133 // FixIn: 10.10.1.5.
1134 ?>
1135 <div class="wpbc_field_generator wpbc_field_generator_starttime">
1136 <?php
1137 // __( 'Start Time', 'booking' ) . ' / ' . __( 'Duration Time', 'booking' ), .
1138 $this->generate_field(
1139 'starttime_field_generator',
1140 array(
1141 'active' => true,
1142 'required' => true,
1143 'label' => true,
1144 'name' => true,
1145 'value' => true,
1146 'type' => 'selectbox',
1147 'required_attr' => array(
1148 'disabled' => true,
1149 'value' => 'On',
1150 ),
1151 'label_attr' => array(
1152 'placeholder' => __( 'Start Time', 'booking' ),
1153 'value' => __( 'Start Time', 'booking' ),
1154 ),
1155 'name_attr' => array(
1156 'disabled' => true,
1157 'placeholder' => 'starttime',
1158 'value' => 'starttime',
1159 ),
1160 'value_attr' => array(
1161 'value' => "10:00 AM@@10:00\n10:30 AM@@10:30\n11:00 AM@@11:00\n11:30 AM@@11:30\n12:00 PM@@12:00\n12:30 PM@@12:30\n1:00 PM@@13:00\n1:30 PM@@13:30\n2:00 PM@@14:00\n2:30 PM@@14:30\n3:00 PM@@15:00\n3:30 PM@@15:30\n4:00 PM@@16:00\n4:30 PM@@16:30\n5:00 PM@@17:00\n5:30 PM@@17:30\n6:00 PM@@18:00",
1162 'attr' => array(
1163 'placeholder' => "10:00 AM@@10:00\n10:30 AM@@10:30\n11:00 AM@@11:00\n11:30 AM@@11:30\n12:00 PM@@12:00\n12:30 PM@@12:30\n1:00 PM@@13:00\n1:30 PM@@13:30\n2:00 PM@@14:00\n2:30 PM@@14:30\n3:00 PM@@15:00\n3:30 PM@@15:30\n4:00 PM@@16:00\n4:30 PM@@16:30\n5:00 PM@@17:00\n5:30 PM@@17:30\n6:00 PM@@18:00",
1164 ),
1165 'rows' => 8,
1166 'cols' => 37,
1167 ),
1168 )
1169 );
1170 ?>
1171 </div>
1172 <?php
1173
1174
1175 // FixIn: 10.10.1.5.
1176 ?>
1177 <div class="wpbc_field_generator wpbc_field_generator_endtime">
1178 <?php
1179 // __( 'Start Time', 'booking' ) . ' / ' . __( 'Duration Time', 'booking' ), .
1180 $this->generate_field(
1181 'endtime_field_generator',
1182 array(
1183 'active' => true,
1184 'required' => true,
1185 'label' => true,
1186 'name' => true,
1187 'value' => true,
1188 'type' => 'selectbox',
1189 'required_attr' => array(
1190 'disabled' => true,
1191 'value' => 'On',
1192 ),
1193 'label_attr' => array(
1194 'placeholder' => __( 'End Time', 'booking' ),
1195 'value' => __( 'End Time', 'booking' ),
1196 ),
1197 'name_attr' => array(
1198 'disabled' => true,
1199 'placeholder' => 'endtime',
1200 'value' => 'endtime',
1201 ),
1202 'value_attr' => array(
1203 'value' => "10:00 AM@@10:00\n10:30 AM@@10:30\n11:00 AM@@11:00\n11:30 AM@@11:30\n12:00 PM@@12:00\n12:30 PM@@12:30\n1:00 PM@@13:00\n1:30 PM@@13:30\n2:00 PM@@14:00\n2:30 PM@@14:30\n3:00 PM@@15:00\n3:30 PM@@15:30\n4:00 PM@@16:00\n4:30 PM@@16:30\n5:00 PM@@17:00\n5:30 PM@@17:30\n6:00 PM@@18:00",
1204 'attr' => array(
1205 'placeholder' => "10:00 AM@@10:00\n10:30 AM@@10:30\n11:00 AM@@11:00\n11:30 AM@@11:30\n12:00 PM@@12:00\n12:30 PM@@12:30\n1:00 PM@@13:00\n1:30 PM@@13:30\n2:00 PM@@14:00\n2:30 PM@@14:30\n3:00 PM@@15:00\n3:30 PM@@15:30\n4:00 PM@@16:00\n4:30 PM@@16:30\n5:00 PM@@17:00\n5:30 PM@@17:30\n6:00 PM@@18:00",
1206 ),
1207 'rows' => 8,
1208 'cols' => 37,
1209 ),
1210 )
1211 );
1212 ?>
1213 </div>
1214 <?php
1215
1216
1217 // Close button.
1218 ?>
1219 <div class="wpbc_field_generator wpbc_field_generator_info_advanced">
1220 <div class="clear" style="margin-top:20px;"></div>
1221 <a onclick="javascript:wpbc_hide_fields_generators();" href="javascript:void(0)" style="margin: 0 15px;" class="button button"><i class="menu_icon icon-1x wpbc_icn_visibility_off"></i>&nbsp;
1222 <?php
1223 esc_html_e( 'Close', 'booking' );
1224 ?>
1225 </a>
1226 </div>
1227 <?php
1228 }
1229
1230
1231
1232 /**
1233 * General Fields Generator
1234 *
1235 * @param $field_name
1236 * @param $field_options
1237 *
1238 * @return void
1239 */
1240 private function generate_field( $field_name = 'some_field_name', $field_options = array() ) {
1241
1242 $defaults = array(
1243 'active' => true
1244 , 'required' => true
1245 , 'label' => true
1246 , 'name' => true
1247 , 'value' => true
1248 //FixIn: TimeFreeGenerator (inside of form fields edited, as well)
1249 , 'required_attr' => array( 'disabled' => false
1250 , 'value' => 'Off'
1251 )
1252 , 'label_attr' => array( 'placeholder' => __('First Name', 'booking')
1253 , 'value' => ''
1254 )
1255 , 'name_attr' => array( 'disabled' => false
1256 , 'placeholder' => 'first_name'
1257 , 'value' => ''
1258 )
1259 , 'value_attr' => array( 'value' => ''
1260 , 'attr' => array( 'placeholder' => "1\n2\n3\n4" )
1261 , 'rows' => 8
1262 , 'cols' => 37
1263 )
1264 );
1265 $field_options = wp_parse_args( $field_options, $defaults );
1266
1267 ?><table class="form-table"><?php
1268
1269 if ( $field_options['active'] )
1270 WPBC_Settings_API::field_checkbox_row_static( $field_name . '_active'
1271 , array(
1272 'type' => 'checkbox'
1273 , 'title' => __('Active', 'booking')
1274 , 'label' => __('Show / hide field in booking form', 'booking')
1275 , 'disabled' => false
1276 , 'class' => ''
1277 , 'css' => ''
1278 , 'type' => 'checkbox'
1279 , 'description' => ''
1280 , 'attr' => array()
1281 , 'group' => 'general'
1282 , 'tr_class' => ''
1283 , 'only_field' => false
1284 , 'is_new_line' => true
1285 , 'description_tag' => 'span'
1286 , 'value' => 'On'
1287 )
1288 , true
1289 );
1290 if ( $field_options['required'] )
1291 WPBC_Settings_API::field_checkbox_row_static( $field_name . '_required'
1292 , array(
1293 'type' => 'checkbox'
1294 , 'title' => __('Required', 'booking')
1295 , 'label' => __('Set field as required', 'booking')
1296 , 'disabled' => $field_options[ 'required_attr' ][ 'disabled' ] //false
1297 , 'class' => ''
1298 , 'css' => ''
1299 , 'type' => 'checkbox'
1300 , 'description' => ''
1301 , 'attr' => array()
1302 , 'group' => 'general'
1303 , 'tr_class' => ''
1304 , 'only_field' => false
1305 , 'is_new_line' => true
1306 , 'description_tag' => 'span'
1307 , 'value' => $field_options[ 'required_attr' ][ 'value' ] //'Off'
1308 )
1309 , true
1310 );
1311 if ( $field_options['label'] )
1312 WPBC_Settings_API::field_text_row_static( $field_name . '_label'
1313 , array(
1314 'type' => 'text'
1315 , 'title' => __('Label', 'booking')
1316 , 'disabled' => false
1317 , 'class' => ''
1318 , 'css' => ''
1319 , 'placeholder' => $field_options[ 'label_attr' ][ 'placeholder' ] //'First Name'
1320 , 'description' => ''//__('Enter field label', 'booking')
1321 , 'group' => 'general'
1322 , 'tr_class' => ''
1323 , 'only_field' => false
1324 , 'description_tag' => 'p'
1325 , 'value' => $field_options[ 'label_attr' ][ 'value' ] //''
1326 , 'attr' => array(
1327 'oninput' => "javascript:this.onchange();"
1328 , 'onpaste' => "javascript:this.onchange();"
1329 , 'onkeypress'=> "javascript:this.onchange();"
1330 , 'onchange' => "javascript:if ( ! jQuery('#".$field_name . '_name'."').is(':disabled') ) { jQuery('#".$field_name . '_name'."').val(jQuery(this).val() );} wpbc_check_typed_name('".$field_name."');"
1331 )
1332 )
1333 , true
1334 );
1335 if ( $field_options['name'] )
1336 WPBC_Settings_API::field_text_row_static( $field_name . '_name'
1337 , array(
1338 'type' => 'text'
1339 , 'title' => __('Name', 'booking') . ' *'
1340 , 'disabled' => $field_options[ 'name_attr' ][ 'disabled' ] //false
1341 , 'class' => ''
1342 , 'css' => ''
1343 , 'placeholder' => $field_options[ 'name_attr' ][ 'placeholder' ] //'first_name'
1344 /* translators: 1: ... */
1345 , 'description' => sprintf( __( 'Type only %1$sunique field name%2$s, that is not using in form', 'booking' ), '<strong>', '</strong>' )
1346 , 'group' => 'general'
1347 , 'tr_class' => ''
1348 , 'only_field' => false
1349 , 'description_tag' => 'p'
1350 , 'value' => $field_options[ 'name_attr' ][ 'value' ] //''
1351 , 'attr' => array(
1352 'oninput' => "javascript:this.onchange();"
1353 , 'onpaste' => "javascript:this.onchange();"
1354 , 'onkeypress'=> "javascript:this.onchange();"
1355 , 'onchange' => "javascript:wpbc_check_typed_name('".$field_name."');"
1356
1357 )
1358
1359 )
1360 , true
1361 );
1362 if ( $field_options['value'] )
1363 WPBC_Settings_API::field_textarea_row_static( $field_name . '_value'
1364 , array(
1365
1366 'title' => __('Values', 'booking')
1367 , 'disabled' => false
1368 , 'class' => ''
1369 , 'css' => ''
1370 , 'placeholder' => ''
1371 , 'description' => __('Enter dropdown options. One option per line.', 'booking') //. '<br>'
1372 //. (( 'durationtime_field_generator' !== $field_options['name'] ) ? '' : __( 'The option format is "Title@@Time Duration," where "Title" is usually the service name and "Time Duration" is defined in the format HH:MM (HH = hours from 00 to 23, MM = minutes from 00 to 59).', 'booking' ))
1373 //. (( 'starttime_field_generator' !== $field_options['name'] ) ? '' : __( 'The option format is "Title@@Time," where "Title" is any text (typically the time in AM/PM format) and "Time" is defined in the 24-hour format (HH:MM), where HH = hours (00 to 23) and MM = minutes (00 to 59).', 'booking' ))
1374 , 'group' => 'general'
1375 , 'tr_class' => ''
1376 , 'only_field' => false
1377 , 'description_tag' => 'p'
1378 , 'value' => $field_options[ 'value_attr' ][ 'value' ] // ''
1379 , 'attr' => $field_options[ 'value_attr' ][ 'attr' ] //array( 'placeholder' => "1\n2\n3\n4" ) //Override Placeholder value, because of escaping \n symbols
1380 , 'rows' => $field_options[ 'value_attr' ][ 'rows' ] //2
1381 , 'cols' => $field_options[ 'value_attr' ][ 'cols' ] //37
1382 , 'show_in_2_cols' => false
1383 , 'attr' => array(
1384 'oninput' => "javascript:this.onchange();"
1385 , 'onpaste' => "javascript:this.onchange();"
1386 , 'onkeypress'=> "javascript:this.onchange();"
1387 , 'onchange' => "javascript:wpbc_check_typed_values('".$field_name."');"
1388 )
1389 )
1390 , true
1391 );
1392 do_action( 'wpbc_settings_form_page_after_values', $field_name, $field_options ); //FixIn: TimeFreeGenerator
1393
1394 ?>
1395 <tr><th colspan="2" style="border-bottom:1px solid #eee;padding:10px 0 0;"></th></tr>
1396
1397 <tr class="wpbc_add_field_row">
1398 <th colspan="2" class="wpdevelop">
1399 <a onclick="javascript:wpbc_add_field ( '<?php echo esc_attr( $field_name ); ?>', '<?php echo esc_attr( $field_options['type'] ); ?>' );"
1400 href="javascript:void(0)"
1401 style=""
1402 class="button button-primary"><i class="menu_icon icon-1x wpbc_icn_add _circle_outline"></i>&nbsp;&nbsp;<?php esc_html_e( 'Add New Field' ,'booking'); ?></a>
1403 &nbsp;&nbsp;
1404 <a onclick="javascript:wpbc_hide_fields_generators();"
1405 href="javascript:void(0)"
1406 style=""
1407 class="button button"><i class="menu_icon icon-1x wpbc_icn_close"></i>&nbsp;&nbsp;<?php esc_html_e( 'Cancel' ,'booking'); ?></a>
1408 </th>
1409 </tr>
1410
1411 <tr class="wpbc_edit_field_row">
1412 <th colspan="2" class="wpdevelop">
1413 <a onclick="javascript:wpbc_finish_edit_form_field ( '<?php echo esc_attr( $field_name ); ?>', '<?php echo esc_attr( $field_options['type'] ); ?>' );"
1414 href="javascript:void(0)"
1415 style=""
1416 class="button button-primary"><i class="menu_icon icon-1x wpbc_icn_draw"></i>&nbsp;&nbsp;<?php esc_html_e( 'Save Changes' ,'booking'); ?></a>
1417 &nbsp;&nbsp;
1418 <a onclick="javascript:wpbc_hide_fields_generators();"
1419 href="javascript:void(0)"
1420 style=""
1421 class="button button"><i class="menu_icon icon-1x wpbc_icn_close"></i>&nbsp;&nbsp;<?php esc_html_e( 'Cancel' ,'booking'); ?></a>
1422 </th>
1423 </tr>
1424
1425 </table><?php
1426 }
1427
1428
1429 // <editor-fold defaultstate="collapsed" desc=" Activate | Deactivate " >
1430
1431 public function activate() {
1432
1433 add_bk_option( 'booking_form', wpbc_simple_form__get_booking_form__as_shortcodes() );
1434 add_bk_option( 'booking_form_show', wpbc_simple_form__get_form_show__as_shortcodes() );
1435 add_bk_option( 'booking_form_visual', wpbc_simple_form__visual__get_default_form() );
1436 }
1437
1438 public function deactivate() {
1439
1440 delete_bk_option( 'booking_form' );
1441 delete_bk_option( 'booking_form_show' );
1442 delete_bk_option( 'booking_form_visual');
1443 }
1444
1445 // </editor-fold>
1446 }
1447
1448 add_action('wpbc_menu_created', array( new WPBC_Page_SettingsFormFieldsFree() , '__construct') ); // Executed after creation of Menu
1449
1450
1451
1452 // =====================================================================================================================
1453 // Load JS files at specific pages only
1454 // =====================================================================================================================
1455
1456 /**
1457 * Load JS files.
1458 *
1459 * @param $hook 'post.php' | 'wp-booking-calendar3_page_wpbc-resources'
1460 *
1461 * @return void
1462 */
1463 function wpbc_register_js__page_form_simple( $hook ) {
1464
1465 if (
1466 ( isset( $_REQUEST['page'] ) ) && ( 'wpbc-settings' === $_REQUEST['page'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
1467 && ( isset( $_REQUEST['tab'] ) ) && ( 'form' === $_REQUEST['tab'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
1468 ) {
1469
1470 // wpbc_load_js__required_for_modals();
1471 // wpbc_load_js__required_for_media_upload();
1472
1473 wp_enqueue_script( 'wpbc_simple_form', wpbc_plugin_url( '/includes/page-form-simple/_src/wpbc_simple_form.js' ), array( 'wpbc_all' ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) );
1474 // wp_enqueue_script( 'wpbc-admin-support', wpbc_plugin_url( '/core/any/js/admin-support.js' ), array( 'jquery' ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) ); // Required for sending dismiss requests
1475 }
1476 }
1477
1478 add_action( 'admin_enqueue_scripts', 'wpbc_register_js__page_form_simple' );
1479