| 1 |
<?php /** |
| 2 |
* @version 1.1 |
| 3 |
* @package Any |
| 4 |
* @category Toolbar for Availability page. UI Elements for Admin Panel |
| 5 |
* @author wpdevelop |
| 6 |
* |
| 7 |
* @web-site http://oplugins.com/ |
| 8 |
* @email info@oplugins.com |
| 9 |
* |
| 10 |
* @modified 2022-11-18 |
| 11 |
*/ |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit, if accessed directly |
| 14 |
|
| 15 |
//////////////////////////////////////////////////////////////////////////////// |
| 16 |
// T o o l b a r s |
| 17 |
//////////////////////////////////////////////////////////////////////////////// |
| 18 |
|
| 19 |
|
| 20 |
/** |
| 21 |
* Show top toolbar on Booking Listing page |
| 22 |
* |
| 23 |
* @param $escaped_search_request_params - escaped search request parameters array |
| 24 |
*/ |
| 25 |
function wpbc_ajx_availability__toolbar( $escaped_search_request_params ) { |
| 26 |
|
| 27 |
wpbc_clear_div(); |
| 28 |
|
| 29 |
// Toolbar //////////////////////////////////////////////////////////////// |
| 30 |
|
| 31 |
$default_param_values = WPBC_AJX__Availability::get__request_values__default(); |
| 32 |
|
| 33 |
$selected_tab = $escaped_search_request_params['ui_usr__availability_selected_toolbar']; |
| 34 |
|
| 35 |
?><div id="toolbar_booking_availability" class="wpbc_ajx_toolbar"><?php |
| 36 |
|
| 37 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 38 |
// Info |
| 39 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 40 |
?><div><?php //Required for bottom border radius in container |
| 41 |
|
| 42 |
?><div class="ui_container ui_container_toolbar ui_container_mini ui_container_info ui_container_filter_row_1" style="<?php echo ( 'info' == $selected_tab ) ? 'display: flex' : 'display: none' ?>;"><?php |
| 43 |
|
| 44 |
// Here will be composed template with real HTML |
| 45 |
?><div class="ui_group" id="wpbc_hidden_template__select_booking_resource" ><?php // array( 'class' => 'group_nowrap' ) // Elements at Several or One Line |
| 46 |
// Resource select-box here. Defined as template at: private function template_toolbar_select_booking_resource(){ |
| 47 |
?></div><?php |
| 48 |
|
| 49 |
?><div class="ui_group" id="wpbc_toolbar_dates_hint"><?php // array( 'class' => 'group_nowrap' ) // Elements at Several or One Line |
| 50 |
|
| 51 |
wpbc_ajx_avy__ui__info( $escaped_search_request_params, $default_param_values ); |
| 52 |
|
| 53 |
?></div><?php |
| 54 |
|
| 55 |
?></div><?php |
| 56 |
|
| 57 |
?></div><?php //Required for bottom border radius in container |
| 58 |
|
| 59 |
|
| 60 |
// <editor-fold defaultstate="collapsed" desc=" C a l e n d a r S e t t i n g s " > |
| 61 |
|
| 62 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 63 |
// C a l e n d a r S e t t i n g s |
| 64 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 65 |
|
| 66 |
?><div class="ui_container ui_container_toolbar ui_container_small ui_container_options ui_container_actions_row_1" style="<?php echo ( 'calendar_settings' == $selected_tab ) ? 'display: flex' : 'display: none' ?>;"><?php |
| 67 |
|
| 68 |
?><div class="ui_group"><?php |
| 69 |
|
| 70 |
?><div class="ui_element"><?php |
| 71 |
wpbc_avy__ui__toolbar_erase_availability_button(); |
| 72 |
?></div><?php |
| 73 |
|
| 74 |
?></div><?php |
| 75 |
|
| 76 |
?><div class="ui_group" id="wpbc_template__select_month_number_in_row"><?php |
| 77 |
// FixIn: 10.8.1.5. |
| 78 |
?></div><?php |
| 79 |
|
| 80 |
?><div class="ui_group" style="flex:1 1 auto;"><?php |
| 81 |
|
| 82 |
// Reset Button |
| 83 |
?><div class="ui_element" style="margin-left: auto;"><?php |
| 84 |
wpbc_avy__ui__toolbar_reset_button(); |
| 85 |
?></div><?php |
| 86 |
|
| 87 |
?></div><?php |
| 88 |
|
| 89 |
?></div><?php |
| 90 |
// </editor-fold> |
| 91 |
|
| 92 |
|
| 93 |
?></div><?php |
| 94 |
} |
| 95 |
|
| 96 |
|
| 97 |
/** |
| 98 |
* Costs Min - Max |
| 99 |
* |
| 100 |
* @param $escaped_search_request_params - escaped search request parameters array |
| 101 |
* @param $defaults - default parameters values |
| 102 |
*/ |
| 103 |
function wpbc_ajx_avy__ui__info( $escaped_search_request_params, $defaults ){ |
| 104 |
|
| 105 |
$params_addon = array( |
| 106 |
'type' => 'span' |
| 107 |
/* translators: 1: ... */ |
| 108 |
, 'html' => sprintf( __( '%1$sSelect days%2$s in calendar then select %3$sAvailable%4$s / %5$sUnavailable%6$s status and click %7$sApply%8$s availability button.', 'booking' ) |
| 109 |
, '<strong>', ' </strong>' |
| 110 |
, '<strong> ', ' </strong>' |
| 111 |
, '<strong> ', ' </strong>' |
| 112 |
, '<strong> ', ' </strong>' |
| 113 |
) |
| 114 |
//, 'icon' => array( 'icon_font' => 'wpbc_icn_info_outline', 'position' => 'left', 'icon_img' => '' ) |
| 115 |
, 'class' => 'wpbc_help_text' |
| 116 |
, 'style' => 'height:auto;' |
| 117 |
//, 'hint' => array( 'title' => __('Filter bookings by booking dates' ,'booking') , 'position' => 'top' ) |
| 118 |
, 'attr' => array() |
| 119 |
); |
| 120 |
|
| 121 |
?><div class="ui_element"><?php |
| 122 |
|
| 123 |
wpbc_flex_addon( $params_addon ); |
| 124 |
|
| 125 |
?></div><?php |
| 126 |
?><script type="text/javascript"> |
| 127 |
|
| 128 |
jQuery(document).ready(function(){ |
| 129 |
|
| 130 |
jQuery( '.wpbc_ajx_availability_container' ).on( 'wpbc_page_content_loaded', function ( event, ajx_data_arr, ajx_search_params, ajx_cleaned_params ){ |
| 131 |
wpbc_blink_element('.wpbc_help_text', 4, 350); |
| 132 |
jQuery( '.wpbc_ajx_availability_container' ).off( 'wpbc_page_content_loaded' ); |
| 133 |
} ); |
| 134 |
|
| 135 |
} ); |
| 136 |
</script> <?php |
| 137 |
|
| 138 |
} |
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
//////////////////////////////////////////////////////////////////////////////// |
| 143 |
// T e m p l a t e s UI |
| 144 |
//////////////////////////////////////////////////////////////////////////////// |
| 145 |
|
| 146 |
function wpbc_ajx_avy__ui__available_radio(){ |
| 147 |
|
| 148 |
$booking_action = 'set_days_availability'; |
| 149 |
|
| 150 |
$el_id = 'ui_btn_avy__' . $booking_action . '__available'; |
| 151 |
|
| 152 |
//if ( ! wpbc_is_user_can( $booking_action, wpbc_get_current_user_id() ) ) { return false; } |
| 153 |
|
| 154 |
wpbc_flex_vertical_color( array( 'vertical_line' => 'border-left: 4px solid #11be4c;' ) ); // Green line |
| 155 |
|
| 156 |
?><span class="wpbc_ui_control wpbc_ui_button <?php echo esc_attr( $el_id . '__outer_button' ); ?>" style="padding-right: 8px;"><?php |
| 157 |
$params_radio = array( |
| 158 |
'id' => $el_id // HTML ID of element |
| 159 |
, 'name' => $booking_action |
| 160 |
, 'label' => array( 'title' => __('Available' ,'booking') , 'position' => 'right' ) |
| 161 |
, 'style' => 'margin:1px 0 0;' // CSS of select element |
| 162 |
, 'class' => 'wpbc_radio__set_days_availability' // CSS Class of select element |
| 163 |
, 'disabled' => false |
| 164 |
, 'attr' => array() // Any additional attributes, if this radio | checkbox element |
| 165 |
, 'legend' => '' // aria-label parameter |
| 166 |
, 'value' => 'available' // Some Value from options array that selected by default |
| 167 |
, 'selected' => !false // Selected or not |
| 168 |
//, 'onfocus' => "console.log( 'ON FOCUS:', jQuery( this ).is(':checked') , 'in element:' , jQuery( this ) );" // JavaScript code |
| 169 |
//, 'onchange' => "console.log( 'ON CHANGE:', jQuery( this ).val() , 'in element:' , jQuery( this ) );" // JavaScript code |
| 170 |
); |
| 171 |
wpbc_flex_radio( $params_radio ); |
| 172 |
|
| 173 |
?></span><?php |
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
} |
| 179 |
|
| 180 |
|
| 181 |
function wpbc_ajx_avy__ui__unavailable_radio(){ |
| 182 |
|
| 183 |
|
| 184 |
$booking_action = 'set_days_availability'; |
| 185 |
|
| 186 |
$el_id = 'ui_btn_avy__' . $booking_action . '__unavailable'; |
| 187 |
|
| 188 |
//if ( ! wpbc_is_user_can( $booking_action, wpbc_get_current_user_id() ) ) { return false; } |
| 189 |
|
| 190 |
wpbc_flex_vertical_color( array( 'vertical_line' => 'border-left: 4px solid #e43939;' ) ); // Green line |
| 191 |
|
| 192 |
?><span class="wpbc_ui_control wpbc_ui_button <?php echo esc_attr( $el_id . '__outer_button' ); ?>" style="padding-right: 8px;"><?php |
| 193 |
$params_radio = array( |
| 194 |
'id' => $el_id // HTML ID of element |
| 195 |
, 'name' => $booking_action |
| 196 |
, 'label' => array( 'title' => __('Unavailable' ,'booking') , 'position' => 'right' ) |
| 197 |
, 'style' => 'margin:1px 0 0;' // CSS of select element |
| 198 |
, 'class' => 'wpbc_radio__set_days_availability' // CSS Class of select element |
| 199 |
, 'disabled' => false |
| 200 |
, 'attr' => array() // Any additional attributes, if this radio | checkbox element |
| 201 |
, 'legend' => '' // aria-label parameter |
| 202 |
, 'value' => 'unavailable' // Some Value from options array that selected by default |
| 203 |
, 'selected' => !false // Selected or not |
| 204 |
//, 'onfocus' => "console.log( 'ON FOCUS:', jQuery( this ).is(':checked') , 'in element:' , jQuery( this ) );" // JavaScript code |
| 205 |
//, 'onchange' => "console.log( 'ON CHANGE:', jQuery( this ).val() , 'in element:' , jQuery( this ) );" // JavaScript code |
| 206 |
); |
| 207 |
wpbc_flex_radio( $params_radio ); |
| 208 |
|
| 209 |
?></span><?php |
| 210 |
|
| 211 |
} |
| 212 |
|
| 213 |
|
| 214 |
function wpbc_ajx_avy__ui__availability_apply_btn(){ |
| 215 |
|
| 216 |
$el_id = 'wpbc_availability_apply_btn'; |
| 217 |
|
| 218 |
$params_button = array( |
| 219 |
'type' => 'button' |
| 220 |
, 'title' => __( 'Apply', 'booking' ) // Title of the button |
| 221 |
, 'hint' => '' // , 'hint' => array( 'title' => __('Select status' ,'booking') , 'position' => 'bottom' ) |
| 222 |
, 'link' => 'javascript:void(0)' // Direct link or skip it |
| 223 |
, 'action' => //"console.log( 'ON CLICK:', jQuery( '[name=\"set_days_availability\"]:checked' ).val() , jQuery( 'textarea[id^=\"date_booking\"]' ).val() );" // Some JavaScript to execure, for example run the function |
| 224 |
" wpbc_ajx_availability__send_request_with_params( { |
| 225 |
'do_action': 'set_availability' |
| 226 |
, 'dates_availability': jQuery( '[name=\"set_days_availability\"]:checked' ).val() |
| 227 |
, 'dates_selection': jQuery( 'textarea[id^=\"date_booking\"]' ).val() |
| 228 |
, 'ui_clicked_element_id': '{$el_id}' |
| 229 |
} ); |
| 230 |
wpbc_button_enable_loading_icon( this ); |
| 231 |
wpbc_admin_show_message_processing( '' ); |
| 232 |
" |
| 233 |
, 'class' => 'wpbc_ui_button_primary' // wpbc_ui_button | wpbc_ui_button_primary |
| 234 |
//, 'icon_position' => 'left' // Position of icon relative to Text: left | right |
| 235 |
, 'icon' => array( |
| 236 |
'icon_font' => 'wpbc_icn_check', // 'wpbc_icn_check_circle_outline', |
| 237 |
'position' => 'left', |
| 238 |
'icon_img' => '' |
| 239 |
) |
| 240 |
, 'style' => '' // Any CSS class here |
| 241 |
, 'mobile_show_text' => false // Show or hide text, when viewing on Mobile devices (small window size). |
| 242 |
, 'attr' => array( 'id' => $el_id ) |
| 243 |
); |
| 244 |
|
| 245 |
wpbc_flex_button( $params_button ); |
| 246 |
} |
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
/** |
| 251 |
* Reset button - init to default options |
| 252 |
* |
| 253 |
*/ |
| 254 |
function wpbc_avy__ui__toolbar_reset_button(){ |
| 255 |
|
| 256 |
$params = array( |
| 257 |
'type' => 'button' , |
| 258 |
'title' => __( 'Reset', 'booking' ) . ' ', // Title of the button |
| 259 |
'hint' => array( 'title' => __( 'Reset selected options to default values', 'booking' ), 'position' => 'top' ), // Hint |
| 260 |
'link' => 'javascript:void(0)', // Direct link or skip it |
| 261 |
'action' => "wpbc_ajx_availability__send_request_with_params( { |
| 262 |
'do_action': 'make_reset' |
| 263 |
} ); |
| 264 |
wpbc_button_enable_loading_icon( this );", // JavaScript |
| 265 |
'icon' => array( |
| 266 |
'icon_font' => 'wpbc_icn_settings_backup_restore', //'wpbc_icn_rotate_left', |
| 267 |
'position' => 'left', |
| 268 |
'icon_img' => '' |
| 269 |
), |
| 270 |
'class' => 'wpbc_ui_button', // '' | 'wpbc_ui_button_primary' |
| 271 |
'style' => '', // Any CSS class here |
| 272 |
'mobile_show_text' => true, // Show or hide text, when viewing on Mobile devices (small window size). |
| 273 |
'attr' => array() |
| 274 |
); |
| 275 |
|
| 276 |
wpbc_flex_button( $params ); |
| 277 |
|
| 278 |
} |
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
function wpbc_avy__ui__toolbar_erase_availability_button(){ |
| 283 |
|
| 284 |
$booking_action = 'erase_availability'; |
| 285 |
|
| 286 |
$el_id = 'ui_btn_' . $booking_action; |
| 287 |
|
| 288 |
// if ( ! wpbc_is_user_can( $booking_action, wpbc_get_current_user_id() ) ) { |
| 289 |
// return false; |
| 290 |
// } |
| 291 |
|
| 292 |
$params = array( |
| 293 |
'type' => 'button' , |
| 294 |
'title' => __( 'Reset availability', 'booking' ) . ' ', // Title of the button |
| 295 |
'hint' => array( 'title' => __( 'Remove all unavailable dates for this calendar', 'booking' ), 'position' => 'top' ), // Hint |
| 296 |
'link' => 'javascript:void(0)', // Direct link or skip it |
| 297 |
'action' => "if ( wpbc_are_you_sure('" . esc_attr( __( 'Do you really want to do this ?', 'booking' ) ) . "') ) { |
| 298 |
wpbc_ajx_availability__send_request_with_params( { |
| 299 |
'do_action': '{$booking_action}', |
| 300 |
'ui_clicked_element_id': '{$el_id}' |
| 301 |
} ); |
| 302 |
wpbc_button_enable_loading_icon( this ); |
| 303 |
}" , |
| 304 |
'icon' => array( |
| 305 |
'icon_font' => 'wpbc_icn_close', |
| 306 |
'position' => 'right', |
| 307 |
'icon_img' => '' |
| 308 |
), |
| 309 |
'class' => 'wpbc_ui_button_danger', // '' | 'wpbc_ui_button_primary' |
| 310 |
'style' => '', // Any CSS class here |
| 311 |
'mobile_show_text' => true, // Show or hide text, when viewing on Mobile devices (small window size). |
| 312 |
'attr' => array( 'id' => $el_id ) |
| 313 |
); |
| 314 |
|
| 315 |
wpbc_flex_button( $params ); |
| 316 |
} |