function wpdev_ajax_check_bk_news() { $v = array(); if (class_exists('wpdev_bk_personal')) { $v[] = 'wpdev_bk_personal'; } if (class_exists('wpdev_bk_biz_s')) { $v[] = 'wpdev_bk_biz_s'; } if (class_exists('wpdev_bk_biz_m')) { $v[] = 'wpdev_bk_biz_m'; } if (class_exists('wpdev_bk_biz_l')) { $v[] = 'wpdev_bk_biz_l'; } if (class_exists('wpdev_bk_multiuser')) { $v[] = 'wpdev_bk_multiuser'; } $obc_settings = array(); $ver = get_bk_option('bk_version_data'); if ($ver !== false) { $obc_settings = array('subscription_key' => maybe_serialize($ver)); } $params = array('action' => 'get_news', 'subscription_email' => isset($obc_settings['subscription_email']) ? $obc_settings['subscription_email'] : false, 'subscription_key' => isset($obc_settings['subscription_key']) ? $obc_settings['subscription_key'] : false, 'bk' => array('bk_ver' => WPDEV_BK_VERSION, 'bk_url' => WPDEV_BK_PLUGIN_URL, 'bk_dir' => WPDEV_BK_PLUGIN_DIR, 'bk_clss' => $v), 'siteurl' => get_option('siteurl'), 'siteip' => $_SERVER['SERVER_ADDR'], 'admin_email' => get_option('admin_email')); $request = new WP_Http(); $result = $request->request(OBC_CHECK_URL . 'info/', array('method' => 'POST', 'timeout' => 15, 'body' => $params)); if (!is_wp_error($result) && $result['response']['code'] == '200' && true) { $string = $result['body']; //$string = str_replace( "'", ''', $string ); echo $string; } else { // Some error appear echo '<div id="bk_errror_loading">'; if (is_wp_error($result)) { echo $result->get_error_message(); } else { echo $result['response']['message']; } echo '</div>'; echo ' <script type="text/javascript"> '; echo ' document.getElementById("bk_news").style.display="none";'; echo ' jQuery("#bk_news_section").animate({opacity:1},3000).slideUp(1500);'; echo ' </script> '; } }
function get_booking_info_4_tooltip($bk_id, $bookings, $booking_types, $title_in_day = '', $title = '', $title_hint = '') { $user = wp_get_current_user(); $user_bk_id = $user->ID; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Gathering data about the booking to show in the calendar !!! //////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Get it from the option settings $what_show_in_day_template = get_bk_option('booking_default_title_in_day_for_calendar_view_mode'); // '<span style="font-size:07px;">[id]</span>:[name]'; if ($title != '') { $title .= ' / '; } // Other Booking in the same day $title .= $bk_id; if ($title_in_day != '') { $title_in_day .= ','; } // Other Booking in the same day //$title_in_day .= $bk_id ; if (function_exists('get_title_for_showing_in_day')) { $title_in_day .= get_title_for_showing_in_day($bk_id, $bookings, $what_show_in_day_template); } else { $title_in_day .= $bk_id . ':' . $bookings[$bk_id]->form_data['_all_fields_']['name']; } if ($title_hint != '') { $title_hint .= ' <hr style="margin:10px 5px;" /> '; } // Other Booking in the same day $title_hint .= '<div class=\'booking-listing-collumn\' >'; if (function_exists('get_booking_title')) { if (isset($booking_types[$bookings[$bk_id]->booking_type])) { $bk_title = $booking_types[$bookings[$bk_id]->booking_type]->title; } else { $bk_title = get_booking_title($bookings[$bk_id]->booking_type); } $bk_title = '<span class=\'label label-resource label-info\'>' . $bk_title . '</span>'; } else { $bk_title = ''; } $title_hint .= '<span class=\'field-id\'>' . $bk_id . '</span>' . ' ' . $bk_title; if (class_exists('wpdev_bk_biz_s')) { $title_hint .= '<div style=\'float:right;\'>'; if (function_exists('wpdev_bk_get_payment_status_simple')) { $pay_status = wpdev_bk_get_payment_status_simple($bookings[$bk_id]->pay_status); $pay_status = '<span class=\'label label-payment-status payment-label-unknown\'><span style=\'font-size:07px;\'>' . __('Payment', 'wpdev-booking') . '</span> ' . $pay_status . '</span>'; } else { $pay_status = ''; } $title_hint .= ' ' . $pay_status; $currency = apply_bk_filter('get_currency_info'); $show_cost_value = wpdev_bk_cost_number_format($bookings[$bk_id]->cost); $title_hint .= ' <div class="cost-fields-group" style=\'float:right; margin:2px;\'>' . $currency . ' ' . $show_cost_value . '</div>'; $title_hint .= '</div>'; } $title_hint .= '<div>' . $bookings[$bk_id]->form_show . '</div>'; //$bookings[$bk_id]->form_data['name'].' ' . $bookings[$bk_id]->form_data['secondname'] ; //$title_hint .= ' '. $bookings[$bk_id]->remark; //BL $bk_dates_short_id = array(); if (count($bookings[$bk_id]->dates) > 0) { $bk_dates_short_id = isset($bookings[$bk_id]->dates_short_id) ? $bookings[$bk_id]->dates_short_id : array(); } // Array ([0] => [1] => .... [4] => 6... [11] => [12] => 8 ) $is_approved = 0; if (count($bookings[$bk_id]->dates) > 0) { $is_approved = $bookings[$bk_id]->dates[0]->approved; } $short_dates_content = wpdevbk_get_str_from_dates_short($bookings[$bk_id]->dates_short, $is_approved, $bk_dates_short_id, $booking_types); $short_dates_content = str_replace('"', "'", $short_dates_content); $title_hint .= '<div style=\'margin-top:5px;\'>' . $short_dates_content . '</div>'; // $reload_time = 2000; // setTimeout(function ( ) {location.reload(true);} ,'.$reload_time.'); /** $title_hint .= '<div style=\'text-align:right;\'>'; if ( class_exists('wpdev_bk_personal') ) { $bk_url_add = 'admin.php?page=' . WPDEV_BK_PLUGIN_DIRNAME . '/'. WPDEV_BK_PLUGIN_FILENAME . 'wpdev-booking-reservation' ; $bk_hash = (isset($bookings[$bk_id]->hash))?$bookings[$bk_id]->hash:''; $bk_booking_type = $bookings[$bk_id]->booking_type; $edit_booking_url = $bk_url_add . '&booking_type='.$bk_booking_type.'&booking_hash='.$bk_hash.'&parent_res=1' ; $title_hint .= '<a style=\'margin:-60px 20px 0 2px;position:absolute;right:0px;\' href=\''.$edit_booking_url .'\' onclick=\'\' ><i class=\'icon-edit\'></i><!--img src=\'' . WPDEV_BK_PLUGIN_URL .'/img/edit_type.png\' style=\'width:12px; height:13px;\'--></a>'; } $title_hint .= '<a style=\'margin:-40px 20px 0 0;position:absolute;right:0px;\' href=\'javascript:;\' onclick=\'javascript:approve_unapprove_booking('. $bk_id.',1, '. $user_bk_id .', "'. getBookingLocale() .'" , 1 );\' ><i class=\'icon-ok-circle\'></i><!--img src=\'' . WPDEV_BK_PLUGIN_URL .'/img/accept-24x24.gif\' style=\'width:14px; height:14px;\'--></a>'; $title_hint .= '<a style=\'margin:-22px 20px 0 0;position:absolute;right:0px;\' href=\'javascript:;\' onclick=\'javascript:approve_unapprove_booking('. $bk_id.',0, '. $user_bk_id .', "'. getBookingLocale() .'" , 1 );\' ><i class=\'icon-ban-circle\'></i><!--img src=\'' . WPDEV_BK_PLUGIN_URL .'/img/remove-16x16.png\' style=\'margin:0px 5px;width:15px; height:15px;\'--></a>'; $title_hint .= '<a href=\'javascript:;\' onclick=\'javascript:delete_booking('. $bk_id.', '. $user_bk_id .', "'. getBookingLocale() .'" , 1 );\' ><i class=\'icon-trash\'></i><!--img src=\'' . WPDEV_BK_PLUGIN_URL .'/img/delete_type.png\' style=\'width:13px; height:13px;\'--></a>'; $title_hint .= '</div>'; /**/ $is_approved = 0; if (!empty($bookings[$bk_id]->dates)) { $is_approved = $bookings[$bk_id]->dates[0]->approved; } $title .= '<div class=\'timeline_info_bk_actionsbar_' . $bk_id . '\' style=\'display: inline; line-height: 1em; padding: 10px; vertical-align: text-top;\'>'; if (class_exists('wpdev_bk_personal')) { $bk_url_add = 'admin.php?page=' . WPDEV_BK_PLUGIN_DIRNAME . '/' . WPDEV_BK_PLUGIN_FILENAME . 'wpdev-booking-reservation'; $bk_hash = isset($bookings[$bk_id]->hash) ? $bookings[$bk_id]->hash : ''; $bk_booking_type = $bookings[$bk_id]->booking_type; $edit_booking_url = $bk_url_add . '&booking_type=' . $bk_booking_type . '&booking_hash=' . $bk_hash . '&parent_res=1'; $title .= '<a class=\'button button-secondary\' style=\'margin-right:5px;\' href=\'' . $edit_booking_url . '\' onclick=\'\' ><i class=\'icon-edit\'></i></a>'; } $title .= '<a class=\'button button-secondary approve_bk_link ' . ($is_approved ? 'hidden_items' : '') . '\' style=\'margin-right:5px;\' href=\'javascript:;\' onclick=\'javascript:approve_unapprove_booking(' . $bk_id . ',1, ' . $user_bk_id . ', "' . getBookingLocale() . '" , 1 );\' ><i class=\'icon-ok-circle\'></i></a>'; $title .= '<a class=\'button button-secondary pending_bk_link ' . ($is_approved ? '' : 'hidden_items') . '\' style=\'margin-right:5px;\' href=\'javascript:;\' onclick=\'javascript:approve_unapprove_booking(' . $bk_id . ',0, ' . $user_bk_id . ', "' . getBookingLocale() . '" , 1 );\' ><i class=\'icon-ban-circle\'></i></a>'; $title .= '<a class=\'button button-secondary\' style=\'margin-right:5px;\' href=\'javascript:;\' onclick=\'javascript:delete_booking(' . $bk_id . ', ' . $user_bk_id . ', "' . getBookingLocale() . '" , 1 );\' ><i class=\'icon-trash\'></i></a>'; $title .= '</div>'; //cell_bk_id_10 time_section_in_day timeslots_in_this_day1 time_hour0 time_in_days_num_30 time_booked_in_day approved /** $title_hint .= '<div style=\'text-align:right;\'>'; $title_hint .= '<a style=\'margin:-40px 0 0 0;position:absolute;\' href=\'javascript:;\' onclick=\'javascript:approve_unapprove_booking('. $bk_id.',1, '. $user_bk_id .', "'. getBookingLocale() .'" , 1 );setTimeout(function ( ) {location.reload(true);} ,'.$reload_time.');\' ><img src=\'' . WPDEV_BK_PLUGIN_URL .'/img/accept-24x24.gif\' style=\'width:14px; height:14px;\'></a>'; // $title_hint .= ' <a href="javascript:void(0)" class="tooltip_bottom approve_bk_link '. ( ($is_approved)?' hidden_items ':'') .' " // onclick="javascript:approve_unapprove_booking('. $bk_id.',1, '. $user_bk_id. ', \''. getBookingLocale() .'\' , 1 );" // ><img src="' . WPDEV_BK_PLUGIN_URL .'/img/accept-24x24.gif" style="width:14px; height:14px;"></a>'; // $title_hint .= '<a style=\'margin:-22px 0 0 -6px;position:absolute;\' href=\'javascript:;\' onclick=\'javascript:approve_unapprove_booking('. $bk_id.',0, '. $user_bk_id .', "'. getBookingLocale() .'" , 1 );setTimeout(function ( ) {location.reload(true);} ,'.$reload_time.');\' ><img src=\'' . WPDEV_BK_PLUGIN_URL .'/img/remove-16x16.png\' style=\'margin:0px 5px;width:15px; height:15px;\'></a>'; // $title_hint .= '<a href="javascript:void(0)" class="tooltip_bottom pending_bk_link '. ( (! $is_approved)? ' hidden_items ':'' ) .' " // onclick="javascript:approve_unapprove_booking('. $bk_id .',0, '. $user_bk_id .', \''. getBookingLocale() .'\' , 1 );" // ><img src="' . WPDEV_BK_PLUGIN_URL .'/img/remove-16x16.png" style="width:15px; height:15px;"></a>'; // //if ( bk_are_you_sure(\''. esc_js(__('Do you really want to set booking as pending ?', 'wpdev-booking')) .'\') ) $title_hint .= '<a href=\'javascript:;\' onclick=\'javascript:delete_booking('. $bk_id.', '. $user_bk_id .', "'. getBookingLocale() .'" , 1 );setTimeout(function ( ) {location.reload(true);} ,'.$reload_time.');\' ><img src=\'' . WPDEV_BK_PLUGIN_URL .'/img/delete_type.png\' style=\'width:13px; height:13px;\'></a>'; //if ( bk_are_you_sure(\''. esc_js(__('Do you really want to delete this booking ?', 'wpdev-booking')) .'\') ) $title_hint .= '</div>'; /**/ $title_hint .= '</div>'; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// return array($title_in_day, $title, $title_hint, $is_approved); }
function get_booking_info_4_tooltip($bk_id, $bookings, $booking_types, $title_in_day = '', $title = '', $title_hint = '') { $user = wp_get_current_user(); $user_bk_id = $user->ID; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Gathering data about the booking to show in the calendar !!! //////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Get it from the option settings $what_show_in_day_template = get_bk_option('booking_default_title_in_day_for_calendar_view_mode'); // '<span style="font-size:07px;">[id]</span>:[name]'; if ($title != '') { $title .= ' / '; } // Other Booking in the same day $title .= $bk_id; if ($title_in_day != '') { $title_in_day .= ','; } // Other Booking in the same day //$title_in_day .= $bk_id ; if (function_exists('get_title_for_showing_in_day')) { $title_in_day .= get_title_for_showing_in_day($bk_id, $bookings, $what_show_in_day_template); } else { $title_in_day .= $bk_id . ':' . $bookings[$bk_id]->form_data['_all_fields_']['name']; } if ($title_hint != '') { $title_hint .= ' <hr style="margin:10px 5px;" /> '; } // Other Booking in the same day $title_hint .= '<div class=\'booking-listing-collumn\' >'; if (function_exists('get_booking_title')) { if (isset($booking_types[$bookings[$bk_id]->booking_type])) { $bk_title = $booking_types[$bookings[$bk_id]->booking_type]->title; } else { $bk_title = get_booking_title($bookings[$bk_id]->booking_type); } $bk_title = '<span class=\'label label-resource label-info\'>' . $bk_title . '</span>'; } else { $bk_title = ''; } $title_hint .= '<span class=\'field-id\'>' . $bk_id . '</span>' . ' ' . $bk_title; if (class_exists('wpdev_bk_biz_s')) { $title_hint .= '<div style=\'float:right;\'>'; if (function_exists('wpdev_bk_get_payment_status_simple')) { $pay_status = wpdev_bk_get_payment_status_simple($bookings[$bk_id]->pay_status); $pay_status = '<span class=\'label label-payment-status payment-label-unknown\'><span style=\'font-size:07px;\'>' . __('Payment', 'booking') . '</span> ' . $pay_status . '</span>'; } else { $pay_status = ''; } $title_hint .= ' ' . $pay_status; $currency = apply_bk_filter('get_currency_info'); $show_cost_value = wpdev_bk_cost_number_format($bookings[$bk_id]->cost); $title_hint .= ' <div class="cost-fields-group" style=\'float:right; margin:2px;\'>' . $currency . ' ' . $show_cost_value . '</div>'; $title_hint .= '</div>'; } $title_hint .= '<div>' . $bookings[$bk_id]->form_show . '</div>'; //$bookings[$bk_id]->form_data['name'].' ' . $bookings[$bk_id]->form_data['secondname'] ; //$title_hint .= ' '. $bookings[$bk_id]->remark; //BL $bk_dates_short_id = array(); if (count($bookings[$bk_id]->dates) > 0) { $bk_dates_short_id = isset($bookings[$bk_id]->dates_short_id) ? $bookings[$bk_id]->dates_short_id : array(); } // Array ([0] => [1] => .... [4] => 6... [11] => [12] => 8 ) $is_approved = 0; if (count($bookings[$bk_id]->dates) > 0) { $is_approved = $bookings[$bk_id]->dates[0]->approved; } $short_dates_content = wpdevbk_get_str_from_dates_short($bookings[$bk_id]->dates_short, $is_approved, $bk_dates_short_id, $booking_types); $short_dates_content = str_replace('"', "'", $short_dates_content); $title_hint .= '<div style=\'margin-top:5px;\'>' . $short_dates_content . '</div>'; $is_approved = 0; if (!empty($bookings[$bk_id]->dates)) { $is_approved = $bookings[$bk_id]->dates[0]->approved; } $title .= '<div class=\'timeline_info_bk_actionsbar_' . $bk_id . '\' style=\'display: inline; line-height: 1em; padding: 10px; vertical-align: text-top;\'>'; $is_can = true; //current_user_can( 'edit_posts' ); if ($is_can) { if (class_exists('wpdev_bk_personal')) { $bk_url_add = 'admin.php?page=' . WPDEV_BK_PLUGIN_DIRNAME . '/' . WPDEV_BK_PLUGIN_FILENAME . 'wpdev-booking-reservation'; $bk_hash = isset($bookings[$bk_id]->hash) ? $bookings[$bk_id]->hash : ''; $bk_booking_type = $bookings[$bk_id]->booking_type; $edit_booking_url = $bk_url_add . '&booking_type=' . $bk_booking_type . '&booking_hash=' . $bk_hash . '&parent_res=1'; $title .= '<a class=\'button button-secondary\' style=\'margin-right:5px;\' href=\'' . $edit_booking_url . '\' onclick=\'\' ><i class=\'icon-edit\'></i></a>'; } $title .= '<a class=\'button button-secondary approve_bk_link ' . ($is_approved ? 'hidden_items' : '') . '\' style=\'margin-right:5px;\' href=\'javascript:;\' onclick=\'javascript:approve_unapprove_booking(' . $bk_id . ',1, ' . $user_bk_id . ', "' . getBookingLocale() . '" , 1 );\' ><i class=\'icon-ok-circle\'></i></a>'; $title .= '<a class=\'button button-secondary pending_bk_link ' . ($is_approved ? '' : 'hidden_items') . '\' style=\'margin-right:5px;\' href=\'javascript:;\' onclick=\'javascript:approve_unapprove_booking(' . $bk_id . ',0, ' . $user_bk_id . ', "' . getBookingLocale() . '" , 1 );\' ><i class=\'icon-ban-circle\'></i></a>'; $title .= '<a class=\'button button-secondary\' style=\'margin-right:5px;\' href=\'javascript:;\' onclick=\'javascript:delete_booking(' . $bk_id . ', ' . $user_bk_id . ', "' . getBookingLocale() . '" , 1 );\' ><i class=\'icon-trash\'></i></a>'; } $title .= '</div>'; $title_hint .= '</div>'; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// return array($title_in_day, $title, $title_hint, $is_approved); }
function wpdevbk_booking_listing_write_js() { ?> <script type="text/javascript"> jQuery(document).ready( function(){ function applyCSStoDays(date ){ return [true, 'date_available']; } jQuery('input.wpdevbk-filters-section-calendar').datepick( { beforeShowDay: applyCSStoDays, showOn: 'focus', multiSelect: 0, numberOfMonths: 1, stepMonths: 1, prevText: '«', nextText: '»', dateFormat: 'yy-mm-dd', changeMonth: false, changeYear: false, minDate: null, maxDate: null, //'1Y', showStatus: false, multiSeparator: ', ', closeAtTop: false, firstDay:<?php echo get_bk_option('booking_start_day_weeek'); ?> , gotoCurrent: false, hideIfNoPrevNext:true, useThemeRoller :false, mandatory: true } ); jQuery('a.popover_here').popover( { placement: 'top' , delay: { show: 100, hide: 200 } , content: '' , template: '<div class="wpdevbk popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>' }); jQuery('.popover_left').popover( { placement: 'left' , delay: { show: 100, hide: 500 } , content: '' , template: '<div class="wpdevbk popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>' }); jQuery('.popover_right').popover( { placement: 'right' , delay: { show: 100, hide: 200 } , content: '' , template: '<div class="wpdevbk popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>' }); jQuery('.popover_top').popover( { placement: 'top' , delay: { show: 100, hide: 200 } , content: '' , template: '<div class="wpdevbk popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>' }); jQuery('.popover_bottom').popover( { placement: 'bottom' //, trigger:'click' , delay: { show: 100, hide: 800 } , content: '' , template: '<div class="wpdevbk popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>' }); // Repositioning of PopOver, which out of Window jQuery( ".popover_bottom" ).on( "mouseenter", function() { setTimeout(function(){ if ( jQuery( '.wpdevbk.popover.fade.bottom.in' ).length ) { var right_pos = parseInt( jQuery( '.wpdevbk.popover.fade.bottom.in' ).css('right').replace('px', '') ); var left_pos = parseInt( jQuery( '.wpdevbk.popover.fade.bottom.in' ).css('left').replace('px', '') ); if ( ( left_pos < 0 ) ) { jQuery('.wpdevbk.popover.fade.bottom.in').css( {left: "10px"} ); } if ( ( right_pos < 0 ) ) { jQuery('.wpdevbk.popover.fade.bottom.in').css( {left: ( ( left_pos - Math.abs(right_pos) - 10) + "px" ) } ); } setTimeout(function(){ var right_pos = parseInt( jQuery( '.wpdevbk.popover.fade.bottom.in' ).css('right').replace('px', '') ); var left_pos = parseInt( jQuery( '.wpdevbk.popover.fade.bottom.in' ).css('left').replace('px', '') ); if ( ( left_pos < 0 ) || ( right_pos<0 ) ) { jQuery('.wpdevbk.popover.fade.bottom.in').css({'left':'10px','width':'95%'}) ; jQuery('.wpdevbk.popover.fade.bottom.in .popover-inner').css({'width':'95%'}) ; } else { jQuery('.wpdevbk.popover.fade.bottom.in').css({'width':'auto'}) ; jQuery('.wpdevbk.popover.fade.bottom.in .popover-inner').css({'width':'350px'}) ; } },5); } },110); }); <?php $is_use_hints = get_bk_option('booking_is_use_hints_at_admin_panel'); if ($is_use_hints == 'On') { if (strpos($_SERVER['REQUEST_URI'], 'wpdev-booking.php') !== false && strpos($_SERVER['REQUEST_URI'], 'wpdev-booking.phpwpdev-booking-reservation') === false) { ?> jQuery('.tooltip_right').tooltip( { animation: true , delay: { show: 500, hide: 100 } , selector: false , placement: 'right' , trigger: 'hover' , title: '' , template: '<div class="wpdevbk tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>' }); jQuery('.tooltip_left').tooltip( { animation: true , delay: { show: 500, hide: 100 } , selector: false , placement: 'left' , trigger: 'hover' , title: '' , template: '<div class="wpdevbk tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>' }); jQuery('.tooltip_top').tooltip( { animation: true , delay: { show: 500, hide: 100 } , selector: false , placement: 'top' , trigger: 'hover' , title: '' , template: '<div class="wpdevbk tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>' }); jQuery('.tooltip_bottom').tooltip( { animation: true , delay: { show: 500, hide: 100 } , selector: false , placement: 'bottom' , trigger: 'hover' , title: '' , template: '<div class="wpdevbk tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>' }); jQuery('.tooltip_top_slow').tooltip( { animation: true , delay: { show: 2500, hide: 100 } , selector: false , placement: 'top' , trigger: 'hover' , title: '' , template: '<div class="wpdevbk tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>' }); <?php } } ?> //jQuery('.dropdown-toggle').dropdown(); }); </script> <?php }
function wpdevbk_show_booking_footer() { $wpdev_copyright_adminpanel = get_bk_option('booking_wpdev_copyright_adminpanel'); // check if ($wpdev_copyright_adminpanel !== 'Off' && !wpdev_bk_is_this_demo()) { $message = ''; $message .= '<a target="_blank" href="http://wpbookingcalendar.com/">Booking Calendar</a> ' . __('version', 'wpdev-booking') . ' ' . WP_BK_VERSION_NUM; $message .= ' | ' . sprintf(__('Add your %s on %swordpress.org%s, if you enjoyed by this plugin.', 'wpdev-booking'), '<a target="_blank" href="http://goo.gl/tcrrpK" >★★★★★</a>', '<a target="_blank" href="http://goo.gl/tcrrpK" >', '</a>'); echo '<div id="wpbc-footer" style="position:absolute;bottom:40px;text-align:left;width:100%;font-size:10px;text-shadow:0 1px 0 #fff;margin:0;color:#888;">' . $message . '</div>'; ?> <script type="text/javascript"> jQuery(document).ready(function(){ jQuery('#wpfooter').append( jQuery('#wpbc-footer') ); }); </script> <?php } }
public function toolbar_top_sub_menu() { if (isset($_GET['tab']) && $_GET['tab'] == $this->term && count($this->sub_menu) > 0) { $active_itmes_in_top_menu = array(); ?> <div class="booking-submenu-tab-container"> <div class="nav-tabs booking-submenu-tab-insidecontainer"><?php foreach ($this->sub_menu as $sub_menu_item) { ?> <a href="javascript:void(0)" onclick="javascript:jQuery('.visibility_container').css('display','none'); jQuery('#<?php echo $sub_menu_item['visibility_container']; ?> ').css('display','block'); jQuery('.nav-tab').removeClass('booking-submenu-tab-selected'); jQuery(this).addClass('booking-submenu-tab-selected');" rel="tooltip" class="tooltip_bottom nav-tab booking-submenu-tab <?php if ($sub_menu_item['selected']) { echo 'booking-submenu-tab-selected '; } if (!empty($sub_menu_item['active_status'])) { if (get_bk_option($sub_menu_item['active_status']) != 'On') { echo ' booking-submenu-tab-disabled '; } } ?> " original-title="<?php echo $sub_menu_item['description']; ?> " style="<?php echo $sub_menu_item['style']; ?> " > <?php echo $sub_menu_item['title']; if (!empty($sub_menu_item['active_status'])) { $active_itmes_in_top_menu[] = array($sub_menu_item['active_status'], $sub_menu_item['active_status'] . '_dublicated'); ?> <input type="checkbox" <?php if (get_bk_option($sub_menu_item['active_status']) == 'On') { echo ' checked="CHECKED" '; } ?> name="<?php echo $sub_menu_item['active_status'] . '_dublicated'; ?> " id="<?php echo $sub_menu_item['active_status'] . '_dublicated'; ?> " onchange="if ( jQuery('#' + '<?php echo $sub_menu_item['active_status']; ?> ' ).length ) {document.getElementById('<?php echo $sub_menu_item['active_status']; ?> ').checked=this.checked;}" /><?php } ?> </a> <?php } // Set Submit button to toolbar if ($this->submit_in_toolbar) { ?> <input type="button" class="button-primary button" value="<?php echo $this->submit_title; ?> " style="float:right;" onclick="document.forms['<?php echo $this->submit_form; ?> '].submit();" /> <div class="clear" style="height:0px;"></div><?php } if (count($active_itmes_in_top_menu) > 0) { ?> <script type="text/javascript"> function recheck_active_itmes_in_top_menu( internal_checkbox, top_checkbox ){ if ( ( jQuery('#' + internal_checkbox ).length ) && ( jQuery('#' + top_checkbox ).length ) ) { if (document.getElementById( internal_checkbox ).checked != document.getElementById( top_checkbox ).checked ) { document.getElementById( top_checkbox ).checked = document.getElementById( internal_checkbox ).checked; if ( document.getElementById( top_checkbox ).checked ) jQuery('#' + top_checkbox ).parent().removeClass('booking-submenu-tab-disabled'); else jQuery('#' + top_checkbox ).parent().addClass('booking-submenu-tab-disabled'); } } } jQuery(document).ready( function(){ <?php foreach ($active_itmes_in_top_menu as $active_item) { ?> recheck_active_itmes_in_top_menu('<?php echo $active_item[0]; ?> ', '<?php echo $active_item[1]; ?> '); <?php } ?> }); </script><?php } ?> </div> </div> <?php } }
public function delete($action_name) { if (isset($this->actions[$action_name])) { unset($this->actions[$action_name]); } // Update to DB $booking_cron = get_bk_option('booking_cron'); if ($booking_cron === false) { $booking_cron = array(); } else { if (is_serialized($booking_cron)) { $booking_cron = unserialize($booking_cron); } if (isset($booking_cron[$action_name])) { unset($booking_cron[$action_name]); } } //////////////////////////////////////////////////////////////////// update_bk_option('booking_cron', $booking_cron); }
/** * Check if we activated loading of JS/CSS only on specific pages and then load or no it * * @return TRUE | FALSE */ function wpbc_is_load_CSS_JS_on_this_page() { $booking_is_load_js_css_on_specific_pages = get_bk_option('booking_is_load_js_css_on_specific_pages'); if ($booking_is_load_js_css_on_specific_pages == 'On') { $booking_pages_for_load_js_css = get_bk_option('booking_pages_for_load_js_css'); $booking_pages_for_load_js_css = preg_split('/[\\r\\n]+/', $booking_pages_for_load_js_css, -1, PREG_SPLIT_NO_EMPTY); $request_uri = $_SERVER['REQUEST_URI']; // FixIn:5.4.1 if (strpos($request_uri, 'booking_hash=') !== false) { $request_uri = parse_url($request_uri); if (!empty($request_uri) && isset($request_uri['path'])) { $request_uri = $request_uri['path']; } else { $request_uri = $_SERVER['REQUEST_URI']; } } if (!empty($booking_pages_for_load_js_css) && !in_array($request_uri, $booking_pages_for_load_js_css)) { return false; } } return true; }
/** * Checking for bookings in the same session and prevention of the double booking * * @param type $bktype * @param type $formdata * @param type $str_dates__dd_mm_yyyy * @param type $start_time * @param type $end_time * @return true|false - free or unavailable */ function wpbc_check_if_dates_free($bktype, $formdata, $dates_in_diff_formats, $start_time, $end_time) { if (get_bk_option('booking_check_on_server_if_dates_free') == 'Off' || get_bk_option('booking_is_days_always_available') == 'On') { return true; } //TODO: Finish checking for parent booking resources // We need to get availabaility for the specific dates // We need to rewrite // function show_availability_at_calendar // for getting availability only for the specific dates // and then based on the availability approve or decline this current booking. if (class_exists('wpdev_bk_biz_l')) { $number_of_child_resources = apply_bk_filter('wpbc_get_number_of_child_resources', $bktype); if ($number_of_child_resources > 1) { // if this booking resources - parent, then do not chekc it, yet! return true; } } // $is_days_free = true; //////////////////////////////////////////////////////////////////////////// // Get Selected Dates Array in full format - all possible dates and times // //////////////////////////////////////////////////////////////////////////// //Example: // [0] => 2014-11-21 10:00:01 // [1] => 2014-11-21 12:00:02 // [2] => 2014-11-22 10:00:01 // [3] => 2014-11-22 12:00:02 $selected_dates_array = array(); $i = 0; //debuge('$dates_in_diff_formats["array]',$dates_in_diff_formats['array']) ; // if we selected only 1 day, system retur in this array 2 same dates. But in situation with recurenttime we need only one day if (get_bk_option('booking_recurrent_time') == 'On') { $dates_in_diff_formats['array'] = array_unique($dates_in_diff_formats['array']); } foreach ($dates_in_diff_formats['array'] as $my_date) { $i++; $my_date = explode('-', $my_date); // For start and end times we cut 10 seconds, so we can check for sure if this times inside of the booked times or not if (get_bk_option('booking_recurrent_time') !== 'On') { if ($i == 1) { $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], $start_time[0], $start_time[1], $start_time[2]); $date = date('Y-m-d H:i:s', strtotime('+20 second', strtotime($date))); } elseif ($i == count($dates_in_diff_formats['array'])) { $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], $end_time[0], $end_time[1], $end_time[2]); $date = date('Y-m-d H:i:s', strtotime('-20 second', strtotime($date))); } else { $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], '00', '00', '00'); } $selected_dates_array[] = $date; } else { $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], $start_time[0], $start_time[1], $start_time[2]); $date = date('Y-m-d H:i:s', strtotime('+20 second', strtotime($date))); $selected_dates_array[] = $date; $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], $end_time[0], $end_time[1], $end_time[2]); $date = date('Y-m-d H:i:s', strtotime('-20 second', strtotime($date))); $selected_dates_array[] = $date; } } //////////////////////////////////////////////////////////////////////////// // SQL condition for getting any booked dates, which inside of selected dates intervals $dates_sql_where = ''; foreach ($dates_in_diff_formats['array'] as $selected_date) { $selected_date = explode('-', $selected_date); $my_check_in_date_sql = sprintf("%04d-%02d-%02d 00:00:00", $selected_date[0], $selected_date[1], $selected_date[2]); $my_check_out_date_sql = sprintf("%04d-%02d-%02d 23:59:59", $selected_date[0], $selected_date[1], $selected_date[2]); if (!empty($dates_sql_where)) { $dates_sql_where .= " OR "; } $dates_sql_where .= " ( dt.booking_date >= '{$my_check_in_date_sql}' AND dt.booking_date <= '{$my_check_out_date_sql}' ) "; } if (!empty($dates_sql_where)) { $dates_sql_where = " ({$dates_sql_where}) "; } //////////////////////////////////////////////////////////////////////////// /* // WE can not use this type of days condition for check in and check out dates, because user can select several not consecutive days $my_check_in_date = explode( '-', $dates_in_diff_formats['array'][0] ); $my_check_in_date_sql = sprintf( "%04d-%02d-%02d 00:00:00", $my_check_in_date[0], $my_check_in_date[1], $my_check_in_date[2] ); $my_check_out_date = explode( '-', $dates_in_diff_formats['array'][ ( count($dates_in_diff_formats['array']) - 1 ) ] ); $my_check_out_date_sql = sprintf( "%04d-%02d-%02d 23:59:59", $my_check_out_date[0], $my_check_out_date[1], $my_check_out_date[2] ); $dates_sql_where = " ( dt.booking_date >= '{$my_check_in_date_sql}' AND dt.booking_date <= '{$my_check_out_date_sql}' ) "; /**/ global $wpdb; // Checking only for approved bookings, if pending days available is active if (get_bk_option('booking_is_show_pending_days_as_available') == 'On') { $approved_only = ' dt.approved = 1 AND '; } else { $approved_only = ''; } // Get all booked dates //////////////////////////////////////////////////// $sql_req = "SELECT DISTINCT dt.booking_date\n \n FROM {$wpdb->prefix}bookingdates as dt\n\n INNER JOIN {$wpdb->prefix}booking as bk\n\n ON bk.booking_id = dt.booking_id\n\n WHERE {$approved_only} {$dates_sql_where} AND bk.booking_type IN ({$bktype})\n \n ORDER BY dt.booking_date"; $exist_dates_results = $wpdb->get_results($sql_req); //////////////////////////////////////////////////////////////////////////// if (count($exist_dates_results) == 0) { // We do not have here booked dates at all, so - TRUE return true; } //FixIn: 5.4.5 $is_dates_intersections = wpbc_check_dates_intersections($selected_dates_array, $exist_dates_results); if ($is_dates_intersections) { // Show Warning message and return FALSE /////////////////////////////// ?> <script type="text/javascript"> if ( jQuery('#submiting<?php echo $bktype; ?> ' ).length ) { // Disable spinning document.getElementById('submiting<?php echo $bktype; ?> ').innerHTML = ''; // Show Error message under the calendar showMessageUnderElement( '#date_booking<?php echo $bktype; ?> ', '<?php echo html_entity_decode('<strong>' . esc_js(__('Error!', 'booking')) . '</strong> ' . esc_js(__('Probably these date(s) just was booking by other visitor. Please reload this page and make booking again.', 'booking')), ENT_QUOTES); ?> ' , 'alert-error'); // Scroll to the calendar makeScroll('#calendar_booking<?php echo $bktype; ?> '); // Enable Submit button jQuery('#booking_form_div<?php echo $bktype; ?> input[type=button]').prop("disabled", false); } </script> <?php return false; } return true; }
public function welcome() { $booking_activation_process = get_bk_option('booking_activation_process'); if ($booking_activation_process == 'On') { return; } // Bail if no activation redirect transient is set if (!get_transient('_wpbc_activation_redirect')) { return; } // Delete the redirect transient delete_transient('_wpbc_activation_redirect'); // Bail if DEMO or activating from network, or bulk, or within an iFrame if (wpdev_bk_is_this_demo() || is_network_admin() || isset($_GET['activate-multi']) || defined('IFRAME_REQUEST')) { return; } wp_safe_redirect(admin_url('index.php?page=wpbc-about')); exit; }
function wpbc_booking_settings_top_menu_submenu_line() { if (isset($_GET['tab']) && $_GET['tab'] == 'email') { ?> <div class="booking-submenu-tab-container"> <div class="nav-tabs booking-submenu-tab-insidecontainer"> <a href="javascript:void(0)" onclick="javascript:jQuery('.visibility_container').css('display','none');jQuery('#visibility_container_email_new_to_admin').css('display','block');jQuery('.nav-tab').removeClass('booking-submenu-tab-selected');jQuery(this).addClass('booking-submenu-tab-selected');" rel="tooltip" class="tooltip_bottom nav-tab booking-submenu-tab booking-submenu-tab-selected <?php if (get_bk_option('booking_is_email_reservation_adress') != 'On') { echo ' booking-submenu-tab-disabled '; } ?> " original-title="<?php _e('Customization of email template, which is sending to Admin after new booking', 'booking'); ?> " > <?php _e('New for Admin', 'booking'); ?> <input type="checkbox" <?php if (get_bk_option('booking_is_email_reservation_adress') == 'On') { echo ' checked="CHECKED" '; } ?> name="booking_is_email_reservation_adress_dublicated" id="booking_is_email_reservation_adress_dublicated" onchange="document.getElementById('is_email_reservation_adress').checked=this.checked;" > </a> <a href="javascript:void(0)" onclick="javascript:jQuery('.visibility_container').css('display','none');jQuery('#visibility_container_email_new_to_visitor').css('display','block');jQuery('.nav-tab').removeClass('booking-submenu-tab-selected');jQuery(this).addClass('booking-submenu-tab-selected');" rel="tooltip" class="tooltip_bottom nav-tab booking-submenu-tab <?php if (get_bk_option('booking_is_email_newbookingbyperson_adress') != 'On') { echo ' booking-submenu-tab-disabled '; } ?> " original-title="<?php _e('Customization of email template, which is sending to Visitor after new booking', 'booking'); ?> " > <?php _e('New for Visitor', 'booking'); ?> <input type="checkbox" <?php if (get_bk_option('booking_is_email_newbookingbyperson_adress') == 'On') { echo ' checked="CHECKED" '; } ?> name="booking_is_email_newbookingbyperson_adress_dublicated" id="booking_is_email_newbookingbyperson_adress_dublicated" onchange="document.getElementById('is_email_newbookingbyperson_adress').checked=this.checked;" > </a> <a href="javascript:void(0)" onclick="javascript:jQuery('.visibility_container').css('display','none');jQuery('#visibility_container_email_approved').css('display','block');jQuery('.nav-tab').removeClass('booking-submenu-tab-selected');jQuery(this).addClass('booking-submenu-tab-selected');" rel="tooltip" class="tooltip_bottom nav-tab booking-submenu-tab <?php if (get_bk_option('booking_is_email_approval_adress') != 'On') { echo ' booking-submenu-tab-disabled '; } ?> " original-title="<?php _e('Customization of email template, which is sending to Visitor after approval of booking', 'booking'); ?> " > <?php _e('Approved', 'booking'); ?> <input type="checkbox" <?php if (get_bk_option('booking_is_email_approval_adress') == 'On') { echo ' checked="CHECKED" '; } ?> name="booking_is_email_approval_adress_dublicated" id="booking_is_email_approval_adress_dublicated" onchange="document.getElementById('is_email_approval_adress').checked=this.checked;" > </a> <a href="javascript:void(0)" onclick="javascript:jQuery('.visibility_container').css('display','none');jQuery('#visibility_container_email_declined').css('display','block');jQuery('.nav-tab').removeClass('booking-submenu-tab-selected');jQuery(this).addClass('booking-submenu-tab-selected');" rel="tooltip" class="tooltip_bottom nav-tab booking-submenu-tab <?php if (get_bk_option('booking_is_email_deny_adress') != 'On') { echo ' booking-submenu-tab-disabled '; } ?> " original-title="<?php _e('Customization of email template, which is sending to Visitor after Cancellation of booking', 'booking'); ?> " > <?php _e('Declined', 'booking'); ?> <input type="checkbox" <?php if (get_bk_option('booking_is_email_deny_adress') == 'On') { echo ' checked="CHECKED" '; } ?> name="booking_is_email_declined_adress_dublicated" id="booking_is_email_declined_adress_dublicated" onchange="document.getElementById('is_email_deny_adress').checked=this.checked;" > </a> <input type="button" class="button-primary button" value="<?php _e('Save Changes', 'booking'); ?> " style="float:right;" onclick="document.forms['post_settings_email_templates'].submit();"> <div class="clear" style="height:0px;"></div> <script type="text/javascript"> function recheck_active_itmes_in_top_menu( internal_checkbox, top_checkbox ){ if (document.getElementById( internal_checkbox ).checked != document.getElementById( top_checkbox ).checked ) { document.getElementById( top_checkbox ).checked = document.getElementById( internal_checkbox ).checked; if ( document.getElementById( top_checkbox ).checked ) jQuery('#' + top_checkbox ).parent().removeClass('booking-submenu-tab-disabled'); else jQuery('#' + top_checkbox ).parent().addClass('booking-submenu-tab-disabled'); } } jQuery(document).ready( function(){ recheck_active_itmes_in_top_menu('is_email_reservation_adress', 'booking_is_email_reservation_adress_dublicated'); recheck_active_itmes_in_top_menu('is_email_newbookingbyperson_adress', 'booking_is_email_newbookingbyperson_adress_dublicated'); recheck_active_itmes_in_top_menu('is_email_approval_adress', 'booking_is_email_approval_adress_dublicated'); recheck_active_itmes_in_top_menu('is_email_deny_adress', 'booking_is_email_declined_adress_dublicated'); }); </script> </div> </div> <?php } //$this->wpdev_booking_settings_top_menu_submenu_line_for_form_fields(); }
function wpbc_get_fields_list_in_booking_form_free() { $booking_form_fields_names = array("name", "secondname", "email", "phone", "details"); $booking_form_fields = array('num' => 1, 'listing' => array('labels' => array(), 'fields' => array()), 'name' => 'free'); $booking_form_fields['listing']['labels'][] = __('None', 'booking'); $booking_form_fields['listing']['fields'][] = ''; $booking_form_fields['listing']['fields_type'][] = 'text'; $key = 0; foreach ($booking_form_fields_names as $name) { $key++; if (get_bk_option("booking_form_field_active{$key}") != 'Off') { $booking_form_field_label = get_bk_option("booking_form_field_label{$key}"); $booking_form_field_label = apply_bk_filter('wpdev_check_for_active_language', $booking_form_field_label); $booking_form_fields['listing']['labels'][] = $booking_form_field_label; $booking_form_fields['listing']['fields'][] = $name; $booking_form_fields['listing']['fields_type'][] = 'text'; $booking_form_fields['num']++; } } if ($booking_form_fields['num'] == 0) { return false; } else { return $booking_form_fields; } }
public function welcome() { $booking_activation_process = get_bk_option('booking_activation_process'); if ($booking_activation_process == 'On') { return; } // Bail if no activation redirect transient is set if (!get_transient('_wpbc_activation_redirect')) { return; } // Delete the redirect transient delete_transient('_wpbc_activation_redirect'); // Bail if DEMO or activating from network, or bulk, or within an iFrame if (wpdev_bk_is_this_demo() || is_network_admin() || isset($_GET['activate-multi']) || defined('IFRAME_REQUEST')) { return; } // Set mark, that we already redirected to About screen //FixIn: 5.4.5 $redirect_for_version = get_bk_option('booking_activation_redirect_for_version'); if ($redirect_for_version == WP_BK_VERSION_NUM) { return; } else { update_bk_option('booking_activation_redirect_for_version', WP_BK_VERSION_NUM); } wp_safe_redirect(admin_url('index.php?page=wpbc-about')); exit; }
function wpdev_bk_custom_button_dalog_structure_DIV() { ?> <div class="hidden"> <div id="wpdev_bk-dialog" style="width:90%;height:90%;"> <div class="wpdev_bk-dialog-content"> <div class="wpdev_bk-dialog-inputs"> <?php $is_can = apply_bk_filter('multiuser_is_user_can_be_here', true, 'only_super_admin'); if ($is_can) { make_bk_action('show_tabs_inside_insertion_popup_window'); } ?> <div id="popup_new_reservation" style="display:block;" class="booking_configuration_dialog"> <div id="popup_new_reservation_main_content"><?php if (get_bk_version() !== 'free') { $types_list = get_bk_types(false, false); ?> <div class="field"> <fieldset> <label for="calendar_type"><?php _e('Booking resource:', 'booking'); ?> </label> <select id="calendar_type" name="calendar_type"> <?php foreach ($types_list as $tl) { ?> <option value="<?php echo $tl->id; ?> " style="<?php if (isset($tl->parent)) { if ($tl->parent == 0) { echo 'font-weight:bold;'; } else { echo 'font-size:11px;padding-left:20px;'; } } ?> " ><?php echo $tl->title; ?> </option> <?php } ?> </select> <span class="description"><?php _e('Select booking resource', 'booking'); ?> </span> </fieldset> </div> <?php } ?> <?php if ($is_can || WP_BK_CUSTOM_FORMS_FOR_REGULAR_USERS) { make_bk_action('wpdev_show_bk_form_selection'); } ?> <div class="field"> <fieldset> <label for="calendar_count"><?php _e('Visible months:', 'booking'); ?> </label> <select id="calendar_count" name="calendar_count" > <option value="1" <?php if (get_bk_option('booking_client_cal_count') == '1') { echo ' selected="SELECTED" '; } ?> >1</option> <option value="2" <?php if (get_bk_option('booking_client_cal_count') == '2') { echo ' selected="SELECTED" '; } ?> >2</option> <option value="3" <?php if (get_bk_option('booking_client_cal_count') == '3') { echo ' selected="SELECTED" '; } ?> >3</option> <option value="4" <?php if (get_bk_option('booking_client_cal_count') == '4') { echo ' selected="SELECTED" '; } ?> >4</option> <option value="5" <?php if (get_bk_option('booking_client_cal_count') == '5') { echo ' selected="SELECTED" '; } ?> >5</option> <option value="6" <?php if (get_bk_option('booking_client_cal_count') == '6') { echo ' selected="SELECTED" '; } ?> >6</option> <option value="7" <?php if (get_bk_option('booking_client_cal_count') == '7') { echo ' selected="SELECTED" '; } ?> >7</option> <option value="8" <?php if (get_bk_option('booking_client_cal_count') == '8') { echo ' selected="SELECTED" '; } ?> >8</option> <option value="9" <?php if (get_bk_option('booking_client_cal_count') == '9') { echo ' selected="SELECTED" '; } ?> >9</option> <option value="10" <?php if (get_bk_option('booking_client_cal_count') == '10') { echo ' selected="SELECTED" '; } ?> >10</option> <option value="11" <?php if (get_bk_option('booking_client_cal_count') == '11') { echo ' selected="SELECTED" '; } ?> >11</option> <option value="12" <?php if (get_bk_option('booking_client_cal_count') == '12') { echo ' selected="SELECTED" '; } ?> >12</option> </select> <span class="description"><?php _e('Select number of month to show for calendar.', 'booking'); ?> </span> </fieldset> </div> <div class="field"> <fieldset> <label for="start_month_active"><?php _e('Start month:', 'booking'); ?> </label> <input id="start_month_active" name="start_month_active" type="checkbox" onchange="javascript:if(! this.checked){ jQuery('select.start_month').attr('disabled', 'disabled'); } else {jQuery('select.start_month').removeAttr('disabled');}" /> <?php $start_year = date('Y'); $start_month = date('m'); ?> <select class="start_month" id="year_start_month" disabled="DISABLED" name="year_start_month" style="width:65px;" > <?php for ($mi = $start_year; $mi < $start_year + 11; $mi++) { echo '<option value="' . $mi . '" >' . $mi . '</option>'; } ?> </select> / <select class="start_month" id="month_start_month" disabled="DISABLED" name="month_start_month" style="width:50px;" > <?php for ($mi = 1; $mi < 13; $mi++) { if ($mi < 10) { $mi = '0' . $mi; } echo '<option value="' . $mi . '" ' . ($start_month == $mi ? ' selected="SELECTED" ' : '') . ' >' . $mi . '</option>'; } ?> </select> <span class="description"><?php _e('Select start month of calendar', 'booking'); ?> </span> </fieldset> </div> <div class="field"> <fieldset> <div style="float:left;"> <label for="calendar_or_form"><?php _e('Show in the page:', 'booking'); ?> </label> </div> <div style="float:left;"> <select id="calendar_or_form" name="calendar_or_form" onchange=" javascript: if(this.value=='onlyform') document.getElementById('dates_for_form').style.display='block'; else document.getElementById('dates_for_form').style.display='none'; "> <option value="form"><?php _e('Booking form with calendar', 'booking'); ?> </option> <option value="calendar"><?php _e('Only availability calendar', 'booking'); ?> </option> <?php if (class_exists('wpdev_bk_biz_l')) { ?> <option value="onlyform"><?php _e('Only booking form', 'booking'); ?> </option><?php } ?> </select> </div> <div style="float:left;"> <?php if (class_exists('wpdev_bk_biz_l')) { ?> <span style="margin-left:5px;display:none;" id="dates_for_form"> <?php _e('for', 'booking'); ?> <select id="year_popup" name="year_popup" style="width:65px;" > <?php for ($mi = $start_year; $mi < $start_year + 11; $mi++) { echo '<option value="' . $mi . '" >' . $mi . '</option>'; } ?> </select> / <select id="month_popup" name="month_popup" style="width:50px;" > <?php for ($mi = 1; $mi < 13; $mi++) { if ($mi < 10) { $mi = '0' . $mi; } echo '<option value="' . $mi . '" ' . ($start_month == $mi ? ' selected="SELECTED" ' : '') . ' >' . $mi . '</option>'; } ?> </select> / <select id="day_popup" name="day_popup" style="width:50px;" > <?php for ($mi = 1; $mi < 32; $mi++) { if ($mi < 10) { $mi = '0' . $mi; } echo '<option value="' . $mi . '" >' . $mi . '</option>'; } ?> </select> <?php _e('date', 'booking'); ?> . </span><?php } ?> </div> <div class="clear"></div> <p class="description"><?php _e('Select to show the entire booking form or the availability calendar only.', 'booking'); ?> </p> </fieldset> </div> <?php make_bk_action('show_additional_arguments_for_shortcode'); ?> </div> <div style="height:1px;clear:both;width:100%;"></div> <div style="color:#21759B;cursor: pointer;font-weight: bold;float:left;" onclick="javascript: jQuery('.bk_show_options_parameter').toggle(1); jQuery('#togle_options_parameter').slideToggle('normal'); jQuery('#popup_new_reservation_main_content').slideToggle('normal');" style="text-decoration: none;font-weight: bold;font-size: 11px;"> <span class="bk_show_options_parameter">+ <span style="border-bottom:1px dashed #21759B;"><?php _e('Show advanced settings', 'booking'); ?> </span></span> <span class="bk_show_options_parameter" style="display:none;">- <span style="border-bottom:1px dashed #21759B;"><?php _e('Hide advanced settings', 'booking'); ?> </span></span> </div> <div class="bk_show_options_parameter description" style="color: #777777;float: right;width: 475px;"><?php printf(__('Setting advanced parameters of the calendar. %sLike width, height and structure %s', 'booking'), '<em>', '</em>'); if (class_exists('wpdev_bk_biz_m')) { printf(__('%s or minimum and fixed number of days selection for the specific day of week or season.%s', 'booking'), '<em>', '</em>'); } ?> </div> <div style="height:1px;clear:both;width:100%;"></div> <div class="field0" id="togle_options_parameter" style="display:none;margin:10px;"> <div class="bk_help_message" style="margin:5px 0px;"><?php printf(__('Please read more about the possible customizations of these %soptions%s %shere%s', 'booking'), '<strong>', '</strong>', '<a href="http://wpbookingcalendar.com/help/booking-calendar-shortcodes/" target="_blank">', '</a>'); ?> </div> <strong><span for="bookingcalendar_options"><?php _e('Options:', 'booking'); ?> </span></strong><br/> <textarea id="bookingcalendar_options" name="bookingcalendar_options" style="width:100%; height:50px;"></textarea> <span class="description" style="width:99%;"> <?php printf(__('Specify the full width of calendar, height of date cell and number of months in one row. ', 'booking')); ?> <br/> <div style="margin-left:35px;"> <strong><?php _e('Description', 'booking'); ?> : </strong> "<?php echo __('Calendar have 2 months in a row, the cell height is 30px and calendar full width 568px (possible to use percentage for width: 100%)', 'booking'); ?> "<br/> <strong><?php _e('Code Example', 'booking'); ?> : </strong> <?php echo '<code>{calendar months_num_in_row=2 width=568px cell_height=30px}</code>'; ?> </div><br/> <?php if (class_exists('wpdev_bk_biz_m')) { ?> <?php printf(__('Specify that during certain seasons (or days of week), the specific minimum number of days must be booked. ', 'booking')); ?> <br/> <div style="margin-left:35px;"> <strong><?php _e('Description', 'booking'); ?> : </strong> "<?php printf(__('Visitor can select only 4 days starting at Monday, 3 or 7 days – Friday, 2 days – Saturday, etc…', 'booking')); ?> "<br/> <strong><?php _e('Code Example', 'booking'); ?> : </strong> <?php echo '<code>{select-day condition="weekday" for="1" value="4"},{select-day condition="weekday" for="5" value="3,7"},{select-day condition="weekday" for="6" value="2"}</code>'; ?> </div> <?php } ?> </span> </div> </div> <?php make_bk_action('show_insertion_popup_shortcode_for_bookingedit'); ?> <input id="calendar_tag_name" name="calendar_tag_name" type="hidden" > <input id="calendar_tag_close" name="calendar_tag_close" type="hidden" > </div> </div> </div> </div> <?php }
function wpdev_bk_insert_new_booking() { global $wpdb; make_bk_action('check_multiuser_params_for_client_side', $_POST["bktype"]); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Define init variables //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $dates = $_POST["dates"]; $bktype = intval($_POST["bktype"]); if ($bktype == 0) { // Error ?> <script type="text/javascript"> document.getElementById('submiting<?php echo $bktype; ?> ').innerHTML = '<div style="height:20px;width:100%;text-align:center;margin:15px auto;"><?php bk_error('Error od saving data into DB. Unknown booking resource.', __FILE__, __LINE__); ?> </div>'; </script> <?php die; } $formdata = $_POST["form"]; $formdata = escape_any_xss($formdata); $is_send_emeils = 1; if (isset($_POST["is_send_emeils"])) { $is_send_emeils = $_POST["is_send_emeils"]; } $my_booking_id = 0; $my_booking_hash = ''; if (function_exists('get_booking_title')) { $bk_title = get_booking_title($bktype); } else { $bk_title = ''; } if (isset($_POST['my_booking_hash'])) { $my_booking_hash = $_POST['my_booking_hash']; if ($my_booking_hash != '') { $my_booking_id_type = false; $my_booking_id_type = apply_bk_filter('wpdev_booking_get_hash_to_id', false, $my_booking_hash); if ($my_booking_id_type !== false) { $my_booking_id = $my_booking_id_type[0]; $bktype = $my_booking_id_type[1]; } } } if (strpos($dates, ' - ') !== FALSE) { $dates = explode(' - ', $dates); $dates = createDateRangeArray($dates[0], $dates[1]); } //debuge($_POST); /// CAPTCHA CHECKING ////////////////////////////////////////////////////////////////////////////////////// $the_answer_from_respondent = $_POST['captcha_user_input']; $prefix = $_POST['captcha_chalange']; if (!($the_answer_from_respondent == '' && $prefix == '')) { $captcha_instance = new wpdevReallySimpleCaptcha(); $correct = $captcha_instance->check($prefix, $the_answer_from_respondent); if (!$correct) { $word = $captcha_instance->generate_random_word(); $prefix = mt_rand(); $captcha_instance->generate_image($prefix, $word); $filename = $prefix . '.png'; $captcha_url = WPDEV_BK_PLUGIN_URL . '/js/captcha/tmp/' . $filename; $ref = substr($filename, 0, strrpos($filename, '.')); ?> <script type="text/javascript"> document.getElementById('captcha_input<?php echo $bktype; ?> ').value = ''; // chnage img document.getElementById('captcha_img<?php echo $bktype; ?> ').src = '<?php echo $captcha_url; ?> '; document.getElementById('wpdev_captcha_challenge_<?php echo $bktype; ?> ').value = '<?php echo $ref; ?> '; document.getElementById('captcha_msg<?php echo $bktype; ?> ').innerHTML = '<span class="alert" style="padding: 5px 5px 4px;vertical-align: middle;text-align:center;margin:5px;"><?php echo __('The code you entered is incorrect', 'wpdev-booking'); ?> </span>'; document.getElementById('submiting<?php echo $bktype; ?> ').innerHTML =''; jQuery('#captcha_input<?php echo $bktype; ?> ') .fadeOut( 350 ).fadeIn( 300 ) .fadeOut( 350 ).fadeIn( 400 ) .animate( {opacity: 1}, 4000 ) ; // mark red border jQuery("span.wpdev-help-message span.alert") .fadeIn( 1 ) //.css( {'color' : 'red'} ) .animate( {opacity: 1}, 10000 ) .fadeOut( 2000 ); // hide message document.getElementById('captcha_input<?php echo $bktype; ?> ').focus(); // make focus to elemnt jQuery('#booking_form_div<?php echo $bktype; ?> input[type=button]').prop("disabled", false); </script> <?php die; } } ////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $my_modification_date = "'" . date_i18n('Y-m-d H:i:s') . "'"; // Localize booking modification date //$my_modification_date = 'NOW()'; // Server value modification date if ($my_booking_id > 0) { // Edit exist booking if (strpos($_SERVER['HTTP_REFERER'], 'wp-admin/admin.php?') !== false) { ?> <script type="text/javascript"> document.getElementById('ajax_working').innerHTML = '<div class="updated ajax_message" id="ajax_message">\n\ <div style="float:left;"><?php echo __('Updating...', 'wpdev-booking'); ?> </div> \n\ <div class="wpbc_spin_loader">\n\ <img src="'+wpdev_bk_plugin_url+'/img/ajax-loader.gif">\n\ </div>\n\ </div>'; </script> <?php } $update_sql = "UPDATE {$wpdb->prefix}booking AS bk SET bk.form='{$formdata}', bk.booking_type={$bktype} , bk.modification_date={$my_modification_date} WHERE bk.booking_id={$my_booking_id};"; if (false === $wpdb->query($update_sql)) { ?> <script type="text/javascript"> document.getElementById('submiting<?php echo $bktype; ?> ').innerHTML = '<div style="height:20px;width:100%;text-align:center;margin:15px auto;"><?php bk_error('Error during updating exist booking in DB', __FILE__, __LINE__); ?> </div>'; </script> <?php die; } // Check if dates already aproved or no $slct_sql = "SELECT approved FROM {$wpdb->prefix}bookingdates WHERE booking_id IN ({$my_booking_id}) LIMIT 0,1"; $slct_sql_results = $wpdb->get_results($slct_sql); if (count($slct_sql_results) > 0) { $is_approved_dates = $slct_sql_results[0]->approved; } $delete_sql = "DELETE FROM {$wpdb->prefix}bookingdates WHERE booking_id IN ({$my_booking_id})"; if (false === $wpdb->query($delete_sql)) { ?> <script type="text/javascript"> document.getElementById('submiting<?php echo $bktype; ?> ').innerHTML = '<div style="height:20px;width:100%;text-align:center;margin:15px auto;"><?php bk_error('Error during updating exist booking for deleting dates in DB', __FILE__, __LINE__); ?> </div>'; </script> <?php die; } $booking_id = (int) $my_booking_id; //Get ID of reservation } else { // Add new booking $sql_insertion = "INSERT INTO {$wpdb->prefix}booking (form, booking_type, modification_date) VALUES ('{$formdata}', {$bktype}, {$my_modification_date} )"; if (false === $wpdb->query($sql_insertion)) { ?> <script type="text/javascript"> document.getElementById('submiting<?php echo $bktype; ?> ').innerHTML = '<div style="height:20px;width:100%;text-align:center;margin:15px auto;"><?php bk_error('Error during inserting into DB', __FILE__, __LINE__); ?> </div>'; </script> <?php die; } // Make insertion into BOOKINGDATES $booking_id = (int) $wpdb->insert_id; //Get ID of reservation $is_approved_dates = '0'; $auto_approve_new_bookings_is_active = get_bk_option('booking_auto_approve_new_bookings_is_active'); if (trim($auto_approve_new_bookings_is_active) == 'On') { $is_approved_dates = '1'; } } $my_dates = explode(",", $dates); $i = 0; foreach ($my_dates as $md) { $my_dates[$i] = trim($my_dates[$i]); $i++; } $start_end_time = get_times_from_bk_form($formdata, $my_dates, $bktype); $start_time = $start_end_time[0]; $end_time = $start_end_time[1]; $my_dates = $start_end_time[2]; make_bk_action('wpdev_booking_post_inserted', $booking_id, $bktype, str_replace('|', ',', $dates), array($start_time, $end_time)); $my_cost = apply_bk_filter('get_booking_cost_from_db', '', $booking_id); $i = 0; foreach ($my_dates as $md) { // Set in dates in such format: yyyy.mm.dd if ($md != '') { $md = explode('.', $md); $my_dates[$i] = $md[2] . '.' . (intval($md[1]) < 10 ? '0' . intval($md[1]) : $md[1]) . '.' . (intval($md[0]) < 10 ? '0' . intval($md[0]) : $md[0]); } else { unset($my_dates[$i]); } // If some dates is empty so remove it // This situation can be if using several bk calendars and some calendars is not checked $i++; } //debuge($my_dates); sort($my_dates); // Sort dates //debuge($my_dates); $my_dates4emeil = ''; $i = 0; $insert = ''; $my_date_previos = ''; foreach ($my_dates as $my_date) { $i++; // Loop through all dates if (strpos($my_date, '.') !== false) { if (get_bk_option('booking_recurrent_time') !== 'On') { $my_date = explode('.', $my_date); if ($i == 1) { if (!isset($start_time[0]) || empty($start_time[0])) { $start_time[0] = '00'; } if (!isset($start_time[1]) || empty($start_time[1])) { $start_time[1] = '00'; } if ($start_time[0] == '00' && $start_time[1] == '00') { $start_time[2] = '00'; } $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], $start_time[0], $start_time[1], $start_time[2]); } elseif ($i == count($my_dates)) { if (!isset($end_time[0]) || empty($end_time[0])) { $end_time[0] = '00'; } if (!isset($end_time[1]) || empty($end_time[1])) { $end_time[1] = '00'; } if ($end_time[0] == '00' && $end_time[1] == '00') { $end_time[2] = '00'; } $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], $end_time[0], $end_time[1], $end_time[2]); } else { $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], '00', '00', '00'); } $my_dates4emeil .= $date . ','; if (!empty($insert)) { $insert .= ', '; } $insert .= "('{$booking_id}', '{$date}', '{$is_approved_dates}' )"; } else { if ($my_date_previos == $my_date) { continue; } // escape for single day selections. $my_date_previos = $my_date; $my_date = explode('.', $my_date); $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], $start_time[0], $start_time[1], $start_time[2]); $my_dates4emeil .= $date . ','; if (!empty($insert)) { $insert .= ', '; } $insert .= "('{$booking_id}', '{$date}', '{$is_approved_dates}' )"; $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], $end_time[0], $end_time[1], $end_time[2]); $my_dates4emeil .= $date . ','; if (!empty($insert)) { $insert .= ', '; } $insert .= "('{$booking_id}', '{$date}', '{$is_approved_dates}' )"; } } } $my_dates4emeil = substr($my_dates4emeil, 0, -1); $my_dates4emeil_check_in_out = explode(',', $my_dates4emeil); $my_check_in_date = change_date_format($my_dates4emeil_check_in_out[0]); $my_check_out_date = change_date_format($my_dates4emeil_check_in_out[count($my_dates4emeil_check_in_out) - 1]); // Save the sort date $sql_sort_date = "UPDATE {$wpdb->prefix}booking SET sort_date = '" . $my_dates4emeil_check_in_out[0] . "' WHERE booking_id = " . $booking_id . " "; $wpdb->query($sql_sort_date); if (!empty($insert)) { if (false === $wpdb->query("INSERT INTO {$wpdb->prefix}bookingdates (booking_id, booking_date, approved) VALUES " . $insert)) { ?> <script type="text/javascript"> document.getElementById('submiting<?php echo $bktype; ?> ').innerHTML = '<div style="height:20px;width:100%;text-align:center;margin:15px auto;"><?php bk_error('Error during inserting into BD - Dates', __FILE__, __LINE__); ?> </div>'; </script> <?php die; } } if ($my_booking_id > 0) { // For editing exist booking if ($is_send_emeils != 0) { sendModificationEmails($booking_id, $bktype, $formdata); } if (strpos($_SERVER['HTTP_REFERER'], 'wp-admin/admin.php?') === false) { do_action('wpdev_new_booking', $booking_id, $bktype, str_replace('|', ',', $dates), array($start_time, $end_time), $formdata); } ?> <script type="text/javascript"> <?php if (strpos($_SERVER['HTTP_REFERER'], 'wp-admin/admin.php?') === false) { ?> setReservedSelectedDates('<?php echo $bktype; ?> '); <?php } else { ?> document.getElementById('ajax_message').innerHTML = '<?php echo __('Updated successfully', 'wpdev-booking'); ?> '; jQuery('#ajax_message').fadeOut(1000); document.getElementById('submiting<?php echo $bktype; ?> ').innerHTML = '<div style="height:20px;width:100%;text-align:center;margin:15px auto;"><?php echo __('Updated successfully', 'wpdev-booking'); ?> </div>'; if ( jQuery('#wpdev_http_referer').length > 0 ) { location.href=jQuery('#wpdev_http_referer').val(); } else location.href='admin.php?page=<?php echo WPDEV_BK_PLUGIN_DIRNAME . '/' . WPDEV_BK_PLUGIN_FILENAME; ?> wpdev-booking&view_mode=vm_listing&tab=actions&wh_booking_id=<?php echo $my_booking_id; ?> '; <?php } ?> </script> <?php } else { // For inserting NEW booking if (count($my_dates) > 0) { if ($is_send_emeils != 0) { sendNewBookingEmails($booking_id, $bktype, $formdata); } } do_action('wpdev_new_booking', $booking_id, $bktype, str_replace('|', ',', $dates), array($start_time, $end_time), $formdata); /* // Start Mail Chimp Customization $booking_form_show = get_form_content ($formdata , $bktype ); if ( ( isset ($booking_form_show['subscribe_me'] )) && ( $booking_form_show['subscribe_me'] == 'yes') ) { if (file_exists(WPDEV_BK_PLUGIN_DIR. '/lib/MailChimp.class.php')) { // Include MailChimp class (You can download it from here https://github.com/drewm/mailchimp-api/ ) require_once(WPDEV_BK_PLUGIN_DIR. '/lib/MailChimp.class.php' ); $MailChimp = new MailChimp('key-my'); // You are need to specify here YOUR KEY !!!! $result = $MailChimp->call('lists/subscribe', array( 'id' => 'id' . $booking_id , 'email' => array('email'=>$booking_form_show['email']), 'merge_vars' => array('FNAME'=>$booking_form_show['name'], 'LNAME'=>$booking_form_show['secondname']), 'double_optin' => false, 'update_existing' => true, 'replace_interests' => false, 'send_welcome' => false, )); // print_r($result); } } // End Mail Chimp Customization /**/ $auto_approve_new_bookings_is_active = get_bk_option('booking_auto_approve_new_bookings_is_active'); if (trim($auto_approve_new_bookings_is_active) == 'On') { sendApproveEmails($booking_id, 1); } ?> <script type="text/javascript"> setReservedSelectedDates('<?php echo $bktype; ?> '); </script> <?php } // ReUpdate booking resource TYPE if its needed here if (!empty($dates)) { // check to have dates not empty make_bk_action('wpdev_booking_reupdate_bk_type_to_childs', $booking_id, $bktype, str_replace('|', ',', $dates), array($start_time, $end_time), $formdata); } }
function wpdevbk_booking_listing_write_js() { ?> <script type="text/javascript"> jQuery(document).ready( function(){ jQuery('input.wpdevbk-filters-section-calendar').datepick( { //onSelect: selectCheckInDay, showOn: 'focus', multiSelect: 0, numberOfMonths: 1, stepMonths: 1, prevText: '<<', nextText: '>>', dateFormat: 'yy-mm-dd', changeMonth: false, changeYear: false, minDate: 0, maxDate: booking_max_monthes_in_calendar, //'1Y', showStatus: false, multiSeparator: ', ', closeAtTop: false, firstDay:<?php echo get_bk_option('booking_start_day_weeek'); ?> , gotoCurrent: false, hideIfNoPrevNext:true, //rangeSelect:wpdev_bk_is_dynamic_range_selection, //calendarViewMode:wpdev_bk_calendarViewMode, useThemeRoller :false, mandatory: true/**/ } ); jQuery('# a.popover_here').popover( { placement: 'bottom' , delay: { show: 100, hide: 100 } , content: '' , template: '<div class="wpdevbk popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>' }); <?php $is_use_hints = get_bk_option('booking_is_use_hints_at_admin_panel'); if ($is_use_hints == 'On') { if (strpos($_SERVER['REQUEST_URI'], 'wpdev-booking.php') !== false && strpos($_SERVER['REQUEST_URI'], 'wpdev-booking.phpwpdev-booking-reservation') === false) { ?> jQuery('.tooltip_right').tooltip( { animation: true , delay: { show: 500, hide: 100 } , selector: false , placement: 'right' , trigger: 'hover' , title: '' , template: '<div class="wpdevbk tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>' }); jQuery('.tooltip_left').tooltip( { animation: true , delay: { show: 500, hide: 100 } , selector: false , placement: 'left' , trigger: 'hover' , title: '' , template: '<div class="wpdevbk tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>' }); jQuery('.tooltip_top').tooltip( { animation: true , delay: { show: 500, hide: 100 } , selector: false , placement: 'top' , trigger: 'hover' , title: '' , template: '<div class="wpdevbk tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>' }); jQuery('.tooltip_bottom').tooltip( { animation: true , delay: { show: 500, hide: 100 } , selector: false , placement: 'bottom' , trigger: 'hover' , title: '' , template: '<div class="wpdevbk tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>' }); <?php } } ?> //jQuery('.dropdown-toggle').dropdown(); }); </script> <?php }
function wpdev_bk_insert_new_booking() { make_bk_action('check_multiuser_params_for_client_side', $_POST["bktype"]); global $wpdb; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Define init variables //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $dates = $_POST["dates"]; $bktype = $_POST["bktype"]; $formdata = $_POST["form"]; $formdata = escape_any_xss($formdata); $is_send_emeils = 1; if (isset($_POST["is_send_emeils"])) { $is_send_emeils = $_POST["is_send_emeils"]; } $my_booking_id = 0; $my_booking_hash = ''; if (isset($_POST['my_booking_hash'])) { $my_booking_hash = $_POST['my_booking_hash']; if ($my_booking_hash != '') { $my_booking_id_type = false; $my_booking_id_type = apply_bk_filter('wpdev_booking_get_hash_to_id', false, $my_booking_hash); if ($my_booking_id_type !== false) { $my_booking_id = $my_booking_id_type[0]; $bktype = $my_booking_id_type[1]; } } } if (strpos($dates, ' - ') !== FALSE) { $dates = explode(' - ', $dates); $dates = createDateRangeArray($dates[0], $dates[1]); } /// CAPTCHA CHECKING ////////////////////////////////////////////////////////////////////////////////////// $the_answer_from_respondent = $_POST['captcha_user_input']; $prefix = $_POST['captcha_chalange']; if (!($the_answer_from_respondent == '' && $prefix == '')) { $captcha_instance = new wpdevReallySimpleCaptcha(); $correct = $captcha_instance->check($prefix, $the_answer_from_respondent); if (!$correct) { $word = $captcha_instance->generate_random_word(); $prefix = mt_rand(); $captcha_instance->generate_image($prefix, $word); $filename = $prefix . '.png'; $captcha_url = WPDEV_BK_PLUGIN_URL . '/js/captcha/tmp/' . $filename; $ref = substr($filename, 0, strrpos($filename, '.')); ?> <script type="text/javascript"> document.getElementById('captcha_input<?php echo $bktype; ?> ').value = ''; // chnage img document.getElementById('captcha_img<?php echo $bktype; ?> ').src = '<?php echo $captcha_url; ?> '; document.getElementById('wpdev_captcha_challenge_<?php echo $bktype; ?> ').value = '<?php echo $ref; ?> '; document.getElementById('captcha_msg<?php echo $bktype; ?> ').innerHTML = '<div style="height:20px;width:100%;text-align:center;margin:15px auto;"><?php echo __('Your entered code is incorrect', 'wpdev-booking'); ?> </div>'; document.getElementById('submiting<?php echo $bktype; ?> ').innerHTML =''; jQuery('#captcha_input<?php echo $bktype; ?> ') .fadeOut( 350 ).fadeIn( 300 ) .fadeOut( 350 ).fadeIn( 400 ) .animate( {opacity: 1}, 4000 ) ; // mark red border jQuery(".wpdev-help-message div") .css( {'color' : 'red'} ) .animate( {opacity: 1}, 10000 ) .fadeOut( 2000 ); // hide message document.getElementById('captcha_input<?php echo $bktype; ?> ').focus(); // make focus to elemnt </script> <?php die; } } ////////////////////////////////////////////////////////////////////////////////////////////////////////// $booking_form_show = get_form_content($formdata, $bktype); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $my_modification_date = "'" . date_i18n('Y-m-d H:i:s') . "'"; // Localize booking modification date $my_modification_date = 'NOW()'; // Server value modification date if ($my_booking_id > 0) { // Edit exist booking if (strpos($_SERVER['HTTP_REFERER'], 'wp-admin/admin.php?') !== false) { ?> <script type="text/javascript"> document.getElementById('ajax_working').innerHTML = '<div class="info_message ajax_message" id="ajax_message">\n\ <div style="float:left;"><?php echo __('Updating...', 'wpdev-booking'); ?> </div> \n\ <div style="float:left;width:80px;margin-top:-3px;">\n\ <img src="'+wpdev_bk_plugin_url+'/img/ajax-loader.gif">\n\ </div>\n\ </div>'; </script> <?php } $update_sql = "UPDATE " . $wpdb->prefix . "booking AS bk SET bk.form='{$formdata}', bk.booking_type={$bktype} , bk.modification_date=" . $my_modification_date . " WHERE bk.booking_id={$my_booking_id};"; if (false === $wpdb->query($wpdb->prepare($update_sql))) { ?> <script type="text/javascript"> document.getElementById('submiting<?php echo $bktype; ?> ').innerHTML = '<div style="height:20px;width:100%;text-align:center;margin:15px auto;"><?php bk_error('Error during updating exist booking in BD', __FILE__, __LINE__); ?> </div>'; </script> <?php die; } // Check if dates already aproved or no $slct_sql = "SELECT approved FROM " . $wpdb->prefix . "bookingdates WHERE booking_id IN ({$my_booking_id}) LIMIT 0,1"; $slct_sql_results = $wpdb->get_results($wpdb->prepare($slct_sql)); if (count($slct_sql_results) > 0) { $is_approved_dates = $slct_sql_results[0]->approved; } $delete_sql = "DELETE FROM " . $wpdb->prefix . "bookingdates WHERE booking_id IN ({$my_booking_id})"; if (false === $wpdb->query($wpdb->prepare($delete_sql))) { ?> <script type="text/javascript"> document.getElementById('submiting<?php echo $bktype; ?> ').innerHTML = '<div style="height:20px;width:100%;text-align:center;margin:15px auto;"><?php bk_error('Error during updating exist booking for deleting dates in BD', __FILE__, __LINE__); ?> </div>'; </script> <?php die; } $booking_id = (int) $my_booking_id; //Get ID of reservation } else { // Add new booking $sql_insertion = "INSERT INTO " . $wpdb->prefix . "booking (form, booking_type, modification_date) VALUES ('{$formdata}', {$bktype}, " . $my_modification_date . " )"; //debuge($formdata); if (false === $wpdb->query($wpdb->prepare($sql_insertion))) { ?> <script type="text/javascript"> document.getElementById('submiting<?php echo $bktype; ?> ').innerHTML = '<div style="height:20px;width:100%;text-align:center;margin:15px auto;"><?php bk_error('Error during inserting into BD', __FILE__, __LINE__); ?> </div>'; </script> <?php die; } // Make insertion into BOOKINGDATES $booking_id = (int) $wpdb->insert_id; //Get ID of reservation $is_approved_dates = '0'; $auto_approve_new_bookings_is_active = get_bk_option('booking_auto_approve_new_bookings_is_active'); if (trim($auto_approve_new_bookings_is_active) == 'On') { $is_approved_dates = '1'; } } $sdform = $_POST['form']; $my_dates = explode(",", $dates); $i = 0; foreach ($my_dates as $md) { $my_dates[$i] = trim($my_dates[$i]); $i++; } $start_end_time = get_times_from_bk_form($sdform, $my_dates, $bktype); $start_time = $start_end_time[0]; $end_time = $start_end_time[1]; $my_dates = $start_end_time[2]; make_bk_action('wpdev_booking_post_inserted', $booking_id, $bktype, str_replace('|', ',', $dates), array($start_time, $end_time)); $my_cost = apply_bk_filter('get_booking_cost_from_db', '', $booking_id); $i = 0; foreach ($my_dates as $md) { // Set in dates in such format: yyyy.mm.dd if ($md != '') { $md = explode('.', $md); $my_dates[$i] = $md[2] . '.' . $md[1] . '.' . $md[0]; } else { unset($my_dates[$i]); } // If some dates is empty so remove it // This situation can be if using several bk calendars and some calendars is not checked $i++; } sort($my_dates); // Sort dates $my_dates4emeil = ''; $i = 0; $insert = ''; $my_date_previos = ''; foreach ($my_dates as $my_date) { $i++; // Loop through all dates if (strpos($my_date, '.') !== false) { if (get_bk_option('booking_recurrent_time') !== 'On') { $my_date = explode('.', $my_date); if ($i == 1) { $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], $start_time[0], $start_time[1], $start_time[2]); } elseif ($i == count($my_dates)) { $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], $end_time[0], $end_time[1], $end_time[2]); } else { $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], '00', '00', '00'); } $my_dates4emeil .= $date . ','; if (!empty($insert)) { $insert .= ', '; } $insert .= "('{$booking_id}', '{$date}', '{$is_approved_dates}' )"; } else { if ($my_date_previos == $my_date) { continue; } // escape for single day selections. $my_date_previos = $my_date; $my_date = explode('.', $my_date); $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], $start_time[0], $start_time[1], $start_time[2]); $my_dates4emeil .= $date . ','; if (!empty($insert)) { $insert .= ', '; } $insert .= "('{$booking_id}', '{$date}', '{$is_approved_dates}' )"; $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], $end_time[0], $end_time[1], $end_time[2]); $my_dates4emeil .= $date . ','; if (!empty($insert)) { $insert .= ', '; } $insert .= "('{$booking_id}', '{$date}', '{$is_approved_dates}' )"; } } } $my_dates4emeil = substr($my_dates4emeil, 0, -1); $my_dates4emeil_check_in_out = explode(',', $my_dates4emeil); $my_check_in_date = change_date_format($my_dates4emeil_check_in_out[0]); $my_check_out_date = change_date_format($my_dates4emeil_check_in_out[count($my_dates4emeil_check_in_out) - 1]); /* // This add 1 more day for check out day $my_check_out_date = $my_dates4emeil_check_in_out[ count($my_dates4emeil_check_in_out)-1 ]; $dt = trim($my_check_out_date); $dta = explode(' ',$dt); $dta = $dta[0]; $dta = explode('-',$dta); $my_check_out_date = date('Y-m-d H:i:s' , mktime(0, 0, 0, $dta[1], ($dta[2]+1), $dta[0] )); $my_check_out_date = change_date_format($my_check_out_date); /**/ if (!empty($insert)) { if (false === $wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->prefix . "bookingdates (booking_id, booking_date, approved) VALUES " . $insert))) { ?> <script type="text/javascript"> document.getElementById('submiting<?php echo $bktype; ?> ').innerHTML = '<div style="height:20px;width:100%;text-align:center;margin:15px auto;"><?php bk_error('Error during inserting into BD - Dates', __FILE__, __LINE__); ?> </div>'; </script> <?php die; } } if (function_exists('get_booking_title')) { $bk_title = get_booking_title($bktype); } else { $bk_title = ''; } if ($my_booking_id > 0) { // For editing exist booking $mail_sender = htmlspecialchars_decode(get_bk_option('booking_email_modification_adress')); $mail_subject = htmlspecialchars_decode(get_bk_option('booking_email_modification_subject')); $mail_body = htmlspecialchars_decode(get_bk_option('booking_email_modification_content')); $mail_subject = apply_bk_filter('wpdev_check_for_active_language', $mail_subject); $mail_body = apply_bk_filter('wpdev_check_for_active_language', $mail_body); if (function_exists('get_booking_title')) { $bk_title = get_booking_title($bktype); } else { $bk_title = ''; } $booking_form_show = get_form_content($formdata, $bktype); $mail_body_to_send = str_replace('[bookingtype]', $bk_title, $mail_body); if (get_bk_option('booking_date_view_type') == 'short') { $my_dates_4_send = get_dates_short_format(get_dates_str($booking_id)); } else { $my_dates_4_send = change_date_format(get_dates_str($booking_id)); } $mail_body_to_send = str_replace('[dates]', $my_dates_4_send, $mail_body_to_send); $mail_body_to_send = str_replace('[check_in_date]', $my_check_in_date, $mail_body_to_send); $mail_body_to_send = str_replace('[check_out_date]', $my_check_out_date, $mail_body_to_send); $mail_body_to_send = str_replace('[id]', $booking_id, $mail_body_to_send); $mail_body_to_send = str_replace('[content]', $booking_form_show['content'], $mail_body_to_send); if (!isset($denyreason)) { $denyreason = ''; } $mail_body_to_send = str_replace('[denyreason]', $denyreason, $mail_body_to_send); $mail_body_to_send = str_replace('[name]', $booking_form_show['name'], $mail_body_to_send); $mail_body_to_send = str_replace('[cost]', $my_cost, $mail_body_to_send); if (isset($booking_form_show['secondname'])) { $mail_body_to_send = str_replace('[secondname]', $booking_form_show['secondname'], $mail_body_to_send); } $mail_body_to_send = str_replace('[siteurl]', htmlspecialchars_decode('<a href="' . site_url() . '">' . site_url() . '</a>'), $mail_body_to_send); $mail_body_to_send = apply_bk_filter('wpdev_booking_set_booking_edit_link_at_email', $mail_body_to_send, $booking_id); $mail_subject = str_replace('[name]', $booking_form_show['name'], $mail_subject); if (isset($booking_form_show['secondname'])) { $mail_subject = str_replace('[secondname]', $booking_form_show['secondname'], $mail_subject); } $mail_recipient = $booking_form_show['email']; $mail_headers = "From: {$mail_sender}\n"; $mail_headers .= "Content-Type: text/html\n"; if (get_bk_option('booking_is_email_modification_adress') != 'Off') { // Send to the Visitor if (strpos($mail_recipient, '@blank.com') === false && strpos($mail_body_to_send, '*****@*****.**') === false) { if ($is_send_emeils != 0) { @wp_mail($mail_recipient, $mail_subject, $mail_body_to_send, $mail_headers); } } // Send to the Admin also $mail_recipient = htmlspecialchars_decode(get_bk_option('booking_email_reservation_adress')); $is_email_modification_send_copy_to_admin = get_bk_option('booking_is_email_modification_send_copy_to_admin'); if ($is_email_modification_send_copy_to_admin == 'On') { if (strpos($mail_recipient, '@blank.com') === false && strpos($mail_body_to_send, '*****@*****.**') === false) { if ($is_send_emeils != 0) { @wp_mail($mail_recipient, $mail_subject, $mail_body_to_send, $mail_headers); } } } } //debuge($_SERVER); if (strpos($_SERVER['HTTP_REFERER'], 'wp-admin/admin.php?') === false) { do_action('wpdev_new_booking', $booking_id, $bktype, str_replace('|', ',', $dates), array($start_time, $end_time), $sdform); } ?> <script type="text/javascript"> <?php if (strpos($_SERVER['HTTP_REFERER'], 'wp-admin/admin.php?') === false) { ?> //document.getElementById('submiting<?php echo $bktype; ?> ').innerHTML = '<div class=\"submiting_content\" ><?php echo get_bk_option('booking_title_after_reservation'); ?> </div>'; //jQuery('.submiting_content').fadeOut(<?php echo get_bk_option('booking_title_after_reservation_time'); ?> ); setReservedSelectedDates('<?php echo $bktype; ?> '); <?php } else { ?> document.getElementById('ajax_message').innerHTML = '<?php echo __('Updated successfully', 'wpdev-booking'); ?> '; jQuery('#ajax_message').fadeOut(1000); document.getElementById('submiting<?php echo $bktype; ?> ').innerHTML = '<div style="height:20px;width:100%;text-align:center;margin:15px auto;"><?php echo __('Updated successfully', 'wpdev-booking'); ?> </div>'; location.href='admin.php?page=<?php echo WPDEV_BK_PLUGIN_DIRNAME . '/' . WPDEV_BK_PLUGIN_FILENAME; ?> wpdev-booking&booking_type=<?php echo $bktype; ?> &booking_id_selection=<?php echo $my_booking_id; ?> '; <?php } ?> </script> <?php } else { if (count($my_dates) > 0) { //// For inserting NEW booking // Sending mail /////////////////////////////////////////////////////// $mail_sender = htmlspecialchars_decode(get_bk_option('booking_email_reservation_from_adress')); //'"'. 'Booking sender' . '" <' . $booking_form_show['email'].'>'; $mail_recipient = htmlspecialchars_decode(get_bk_option('booking_email_reservation_adress')); //'"Booking receipent" <' .get_option('admin_email').'>'; $mail_subject = htmlspecialchars_decode(get_bk_option('booking_email_reservation_subject')); $mail_body = htmlspecialchars_decode(get_bk_option('booking_email_reservation_content')); $mail_subject = apply_bk_filter('wpdev_check_for_active_language', $mail_subject); $mail_body = apply_bk_filter('wpdev_check_for_active_language', $mail_body); $mail_body = str_replace('[bookingtype]', $bk_title, $mail_body); if (get_bk_option('booking_date_view_type') == 'short') { $my_dates_4_send = get_dates_short_format($my_dates4emeil); } else { $my_dates_4_send = change_date_format($my_dates4emeil); } $mail_body = str_replace('[dates]', $my_dates_4_send, $mail_body); $mail_body = str_replace('[check_in_date]', $my_check_in_date, $mail_body); $mail_body = str_replace('[check_out_date]', $my_check_out_date, $mail_body); $mail_body = str_replace('[id]', $booking_id, $mail_body); $mail_body = str_replace('[content]', $booking_form_show['content'], $mail_body); $mail_body = str_replace('[name]', $booking_form_show['name'], $mail_body); $mail_body = str_replace('[cost]', $my_cost, $mail_body); $mail_body = str_replace('[siteurl]', htmlspecialchars_decode('<a href="' . site_url() . '">' . site_url() . '</a>'), $mail_body); $mail_body = str_replace('[moderatelink]', htmlspecialchars_decode('<a href="' . site_url() . '/wp-admin/admin.php?page=' . WPDEV_BK_PLUGIN_DIRNAME . '/' . WPDEV_BK_PLUGIN_FILENAME . 'wpdev-booking&booking_type=' . $bktype . '&moderate_id=' . $booking_id . '">' . __('here', 'wpdev-booking') . '</a>'), $mail_body); $mail_body = apply_bk_filter('wpdev_booking_set_booking_edit_link_at_email', $mail_body, $booking_id); if (isset($booking_form_show['secondname'])) { $mail_body = str_replace('[secondname]', $booking_form_show['secondname'], $mail_body); } $mail_subject = str_replace('[name]', $booking_form_show['name'], $mail_subject); if (isset($booking_form_show['secondname'])) { $mail_subject = str_replace('[secondname]', $booking_form_show['secondname'], $mail_subject); } $mail_headers = "From: {$mail_sender}\n"; $mail_headers .= "Content-Type: text/html\n"; if (strpos($mail_recipient, '[visitoremeil]') !== false) { $mail_recipient = str_replace('[visitoremeil]', $booking_form_show['email'], $mail_recipient); } if (get_bk_option('booking_is_email_reservation_adress') != 'Off') { if (strpos($mail_recipient, '@blank.com') === false && strpos($mail_body, '*****@*****.**') === false) { if ($is_send_emeils != 0) { @wp_mail($mail_recipient, $mail_subject, $mail_body, $mail_headers); } } } ///////////////////////////////////////////////////////////////////////// if (get_bk_option('booking_is_email_newbookingbyperson_adress') == 'On') { $mail_sender = htmlspecialchars_decode(get_bk_option('booking_email_newbookingbyperson_adress')); //'"'. 'Booking sender' . '" <' . $booking_form_show['email'].'>'; $mail_recipient = $booking_form_show['email']; $mail_subject = htmlspecialchars_decode(get_bk_option('booking_email_newbookingbyperson_subject')); $mail_body = htmlspecialchars_decode(get_bk_option('booking_email_newbookingbyperson_content')); $mail_subject = apply_bk_filter('wpdev_check_for_active_language', $mail_subject); $mail_body = apply_bk_filter('wpdev_check_for_active_language', $mail_body); $mail_body = str_replace('[bookingtype]', $bk_title, $mail_body); if (get_bk_option('booking_date_view_type') == 'short') { $my_dates_4_send = get_dates_short_format($my_dates4emeil); } else { $my_dates_4_send = change_date_format($my_dates4emeil); } $mail_body = str_replace('[dates]', $my_dates_4_send, $mail_body); $mail_body = str_replace('[check_in_date]', $my_check_in_date, $mail_body); $mail_body = str_replace('[check_out_date]', $my_check_out_date, $mail_body); $mail_body = str_replace('[id]', $booking_id, $mail_body); $mail_body = str_replace('[content]', $booking_form_show['content'], $mail_body); $mail_body = str_replace('[name]', $booking_form_show['name'], $mail_body); $mail_body = str_replace('[cost]', $my_cost, $mail_body); $mail_body = str_replace('[siteurl]', htmlspecialchars_decode('<a href="' . site_url() . '">' . site_url() . '</a>'), $mail_body); $mail_body = apply_bk_filter('wpdev_booking_set_booking_edit_link_at_email', $mail_body, $booking_id); if (isset($booking_form_show['secondname'])) { $mail_body = str_replace('[secondname]', $booking_form_show['secondname'], $mail_body); } $mail_subject = str_replace('[name]', $booking_form_show['name'], $mail_subject); if (isset($booking_form_show['secondname'])) { $mail_subject = str_replace('[secondname]', $booking_form_show['secondname'], $mail_subject); } $mail_headers = "From: {$mail_sender}\n"; $mail_headers .= "Content-Type: text/html\n"; if (strpos($mail_recipient, '[visitoremeil]') !== false) { $mail_recipient = str_replace('[visitoremeil]', $booking_form_show['email'], $mail_recipient); } if (strpos($mail_recipient, '@blank.com') === false) { if (strpos($mail_recipient, '@blank.com') === false && strpos($mail_body, '*****@*****.**') === false) { if ($is_send_emeils != 0) { @wp_mail($mail_recipient, $mail_subject, $mail_body, $mail_headers); } } } } } do_action('wpdev_new_booking', $booking_id, $bktype, str_replace('|', ',', $dates), array($start_time, $end_time), $sdform); ?> <script type="text/javascript"> setReservedSelectedDates('<?php echo $bktype; ?> '); </script> <?php } // ReUpdate booking resource TYPE if its needed here if (!empty($dates)) { // check to have dates not empty make_bk_action('wpdev_booking_reupdate_bk_type_to_childs', $booking_id, $bktype, str_replace('|', ',', $dates), array($start_time, $end_time), $sdform); } }
function wpdev_bk_settings_form_labels() { ?> <div class="clear" style="height:0px;"></div> <div id="ajax_working"></div> <div id="poststuff0" class="metabox-holder"> <form name="post_settings_form_fields" action="" method="post" id="post_settings_form_fields" class="form-horizontal"> <div id="visibility_container_form_fields" class="visibility_container wpdevbk" style="display:block;"> <div class='meta-box'> <div <?php $my_close_open_win_id = 'bk_settings_form_fields'; ?> id="<?php echo $my_close_open_win_id; ?> " class="postbox <?php if ('1' == get_user_option('booking_win_' . $my_close_open_win_id)) { echo 'closed'; } ?> " > <div title="<?php _e('Click to toggle', 'wpdev-booking'); ?> " class="handlediv" onclick="javascript:verify_window_opening(<?php echo get_bk_current_user_id(); ?> , '<?php echo $my_close_open_win_id; ?> ');"><br></div> <h3 class='hndle'><span><?php _e('Form fields labels', 'wpdev-booking'); ?> </span></h3><div class="inside"> <?php // FIELD # 1 ////////////////////////////////////////////////////////////////////////////////////////////////////////// if (isset($_POST['Submit'])) { if (isset($_POST['booking_form_field_active1'])) { $booking_form_field_active1 = 'On'; } else { $booking_form_field_active1 = 'Off'; } update_bk_option('booking_form_field_active1', $booking_form_field_active1); if (isset($_POST['booking_form_field_required1'])) { $booking_form_field_required1 = 'On'; } else { $booking_form_field_required1 = 'Off'; } update_bk_option('booking_form_field_required1', $booking_form_field_required1); update_bk_option('booking_form_field_label1', $_POST['booking_form_field_label1']); } $booking_form_field_active1 = get_bk_option('booking_form_field_active1'); $booking_form_field_required1 = get_bk_option('booking_form_field_required1'); $booking_form_field_label1 = get_bk_option('booking_form_field_label1'); ?> <div class="control-group"> <label for="name" class="control-label" style="font-weight:bold;"><?php _e('Field Label', 'wpdev-booking'); ?> #1:</label> <div class="controls"> <input type="text" class="large-text" name="booking_form_field_label1" value="<?php echo $booking_form_field_label1; ?> "> <label class="checkbox inline"> <input type="checkbox" name="booking_form_field_active1" <?php if ($booking_form_field_active1 == 'On') { echo ' checked="checked" '; } ?> value="<?php echo $booking_form_field_active1; ?> " > <?php _e('Active', 'wpdev-booking'); ?> </label> <label class="checkbox inline"> <input type="checkbox" name="booking_form_field_required1" <?php if ($booking_form_field_required1 == 'On') { echo ' checked="checked" '; } ?> value="<?php echo $booking_form_field_required1; ?> " > <?php _e('Required', 'wpdev-booking'); ?> </label> <p class="help-block"><?php _e('Activate or deactivate field and change the label title', 'wpdev-booking'); ?> </p> </div> </div> <?php // FIELD # 2 ////////////////////////////////////////////////////////////////////////////////////////////////////////// if (isset($_POST['Submit'])) { if (isset($_POST['booking_form_field_active2'])) { $booking_form_field_active2 = 'On'; } else { $booking_form_field_active2 = 'Off'; } update_bk_option('booking_form_field_active2', $booking_form_field_active2); if (isset($_POST['booking_form_field_required2'])) { $booking_form_field_required2 = 'On'; } else { $booking_form_field_required2 = 'Off'; } update_bk_option('booking_form_field_required2', $booking_form_field_required2); update_bk_option('booking_form_field_label2', $_POST['booking_form_field_label2']); } $booking_form_field_active2 = get_bk_option('booking_form_field_active2'); $booking_form_field_required2 = get_bk_option('booking_form_field_required2'); $booking_form_field_label2 = get_bk_option('booking_form_field_label2'); ?> <div class="control-group"> <label for="name" class="control-label" style="font-weight:bold;"><?php _e('Field Label', 'wpdev-booking'); ?> #2:</label> <div class="controls"> <input type="text" class="large-text" name="booking_form_field_label2" value="<?php echo $booking_form_field_label2; ?> "> <label class="checkbox inline"> <input type="checkbox" name="booking_form_field_active2" <?php if ($booking_form_field_active2 == 'On') { echo ' checked="checked" '; } ?> value="<?php echo $booking_form_field_active2; ?> " > <?php _e('Active', 'wpdev-booking'); ?> </label> <label class="checkbox inline"> <input type="checkbox" name="booking_form_field_required2" <?php if ($booking_form_field_required2 == 'On') { echo ' checked="checked" '; } ?> value="<?php echo $booking_form_field_required2; ?> " > <?php _e('Required', 'wpdev-booking'); ?> </label> <p class="help-block"><?php _e('Activate or deactivate field and change the label title', 'wpdev-booking'); ?> </p> </div> </div> <?php // FIELD # 3 ////////////////////////////////////////////////////////////////////////////////////////////////////////// if (isset($_POST['Submit'])) { //if (isset( $_POST['booking_form_field_active3'] )) $booking_form_field_active3 = 'On'; //else $booking_form_field_active3 = 'Off'; $booking_form_field_active3 = 'On'; update_bk_option('booking_form_field_active3', $booking_form_field_active3); //if (isset( $_POST['booking_form_field_required3'] )) $booking_form_field_required3 = 'On'; //else $booking_form_field_required3 = 'Off'; $booking_form_field_required3 = 'On'; update_bk_option('booking_form_field_required3', $booking_form_field_required3); update_bk_option('booking_form_field_label3', $_POST['booking_form_field_label3']); } $booking_form_field_active3 = get_bk_option('booking_form_field_active3'); $booking_form_field_required3 = get_bk_option('booking_form_field_required3'); $booking_form_field_label3 = get_bk_option('booking_form_field_label3'); ?> <div class="control-group"> <label for="name" class="control-label" style="font-weight:bold;"><?php _e('Email Label', 'wpdev-booking'); ?> :</label> <div class="controls"> <input type="text" class="large-text" name="booking_form_field_label3" value="<?php echo $booking_form_field_label3; ?> "> <label class="checkbox inline"> <input type="checkbox" name="booking_form_field_active3" disabled="" <?php if ($booking_form_field_active3 == 'On' || true) { echo ' checked="checked" '; } ?> value="<?php echo $booking_form_field_active3; ?> " > <?php _e('Active', 'wpdev-booking'); ?> </label> <label class="checkbox inline"> <input type="checkbox" name="booking_form_field_required3" disabled="" <?php if ($booking_form_field_required3 == 'On' || true) { echo ' checked="checked" '; } ?> value="<?php echo $booking_form_field_required3; ?> " > <?php _e('Required', 'wpdev-booking'); ?> </label> <p class="help-block"><?php _e('Change the label title of this field. Email is obligatory field in booking form.', 'wpdev-booking'); ?> </p> </div> </div> <?php // FIELD # 4 ////////////////////////////////////////////////////////////////////////////////////////////////////////// if (isset($_POST['Submit'])) { if (isset($_POST['booking_form_field_active4'])) { $booking_form_field_active4 = 'On'; } else { $booking_form_field_active4 = 'Off'; } update_bk_option('booking_form_field_active4', $booking_form_field_active4); if (isset($_POST['booking_form_field_required4'])) { $booking_form_field_required4 = 'On'; } else { $booking_form_field_required4 = 'Off'; } update_bk_option('booking_form_field_required4', $booking_form_field_required4); update_bk_option('booking_form_field_label4', $_POST['booking_form_field_label4']); } $booking_form_field_active4 = get_bk_option('booking_form_field_active4'); $booking_form_field_required4 = get_bk_option('booking_form_field_required4'); $booking_form_field_label4 = get_bk_option('booking_form_field_label4'); ?> <div class="control-group"> <label for="name" class="control-label" style="font-weight:bold;"><?php _e('Field Label', 'wpdev-booking'); ?> #4:</label> <div class="controls"> <input type="text" class="large-text" name="booking_form_field_label4" value="<?php echo $booking_form_field_label4; ?> "> <label class="checkbox inline"> <input type="checkbox" name="booking_form_field_active4" <?php if ($booking_form_field_active4 == 'On') { echo ' checked="checked" '; } ?> value="<?php echo $booking_form_field_active4; ?> " > <?php _e('Active', 'wpdev-booking'); ?> </label> <label class="checkbox inline"> <input type="checkbox" name="booking_form_field_required4" <?php if ($booking_form_field_required4 == 'On') { echo ' checked="checked" '; } ?> value="<?php echo $booking_form_field_required4; ?> " > <?php _e('Required', 'wpdev-booking'); ?> </label> <p class="help-block"><?php _e('Activate or deactivate field and change the label title', 'wpdev-booking'); ?> </p> </div> </div> <?php // FIELD # 5 ////////////////////////////////////////////////////////////////////////////////////////////////////////// if (isset($_POST['Submit'])) { if (isset($_POST['booking_form_field_active5'])) { $booking_form_field_active5 = 'On'; } else { $booking_form_field_active5 = 'Off'; } update_bk_option('booking_form_field_active5', $booking_form_field_active5); if (isset($_POST['booking_form_field_required5'])) { $booking_form_field_required5 = 'On'; } else { $booking_form_field_required5 = 'Off'; } update_bk_option('booking_form_field_required5', $booking_form_field_required5); update_bk_option('booking_form_field_label5', $_POST['booking_form_field_label5']); } $booking_form_field_active5 = get_bk_option('booking_form_field_active5'); $booking_form_field_required5 = get_bk_option('booking_form_field_required5'); $booking_form_field_label5 = get_bk_option('booking_form_field_label5'); ?> <div class="control-group"> <label for="name" class="control-label" style="font-weight:bold;"><?php _e('Textarea Label', 'wpdev-booking'); ?> :</label> <div class="controls"> <input type="text" class="large-text" name="booking_form_field_label5" value="<?php echo $booking_form_field_label5; ?> "> <label class="checkbox inline"> <input type="checkbox" name="booking_form_field_active5" <?php if ($booking_form_field_active5 == 'On') { echo ' checked="checked" '; } ?> value="<?php echo $booking_form_field_active5; ?> " > <?php _e('Active', 'wpdev-booking'); ?> </label> <label class="checkbox inline"> <input type="checkbox" name="booking_form_field_required5" <?php if ($booking_form_field_required5 == 'On') { echo ' checked="checked" '; } ?> value="<?php echo $booking_form_field_required5; ?> " > <?php _e('Required', 'wpdev-booking'); ?> </label> <p class="help-block"><?php _e('Activate or deactivate field and change the label title', 'wpdev-booking'); ?> </p> </div> </div> </div></div></div> <div <?php $my_close_open_alert_id = 'bk_alert_settings_form_in_free'; ?> class="alert alert-block alert-info <?php if ('1' == get_user_option('booking_win_' . $my_close_open_alert_id)) { echo 'closed'; } ?> " id="<?php echo $my_close_open_alert_id; ?> "> <a class="close tooltip_left" rel="tooltip" title="Don't show the message anymore" data-dismiss="alert" href="javascript:void(0)" onclick="javascript:verify_window_opening(<?php echo get_bk_current_user_id(); ?> , '<?php echo $my_close_open_alert_id; ?> ');" >×</a> <strong class="alert-heading">Note!</strong> Check how in <a href="http://wpbookingcalendar.com/help/versions-overview/" target="_blank" style="text-decoration:underline;">other versions of Booking Calendar</a> is possible fully <a href="http://wpbookingcalendar.com/help/booking-form-fields/" target="_blank" style="text-decoration:underline;">customize the booking form</a> <em>(add or remove fields, change structure of booking form, etc...)</em> </div> </div> <input class="button-primary button" style="" type="submit" value="<?php _e('Save Changes', 'wpdev-booking'); ?> " name="Submit" /> <div class="clear" style="height:10px;"></div> </form> </div> <?php }
function wpdev_booking_deactivate() { // set execution time to 15 minutes, its not worked if we have SAFE MODE ON at PHP if (function_exists('set_time_limit')) { if (!in_array(ini_get('safe_mode'), array('1', 'On'))) { set_time_limit(900); } } $is_delete_if_deactive = get_bk_option('booking_is_delete_if_deactive'); // check if ($is_delete_if_deactive == 'On') { // Delete here tables and options, which are needed for using plugin delete_bk_option('booking_version_num'); delete_bk_option('booking_skin'); delete_bk_option('bookings_num_per_page'); delete_bk_option('booking_sort_order'); delete_bk_option('booking_sort_order_direction'); delete_bk_option('booking_default_toolbar_tab'); delete_bk_option('bookings_listing_default_view_mode'); delete_bk_option('booking_view_days_num'); delete_bk_option('booking_max_monthes_in_calendar'); delete_bk_option('booking_admin_cal_count'); delete_bk_option('booking_client_cal_count'); delete_bk_option('booking_start_day_weeek'); delete_bk_option('booking_title_after_reservation'); delete_bk_option('booking_title_after_reservation_time'); delete_bk_option('booking_type_of_thank_you_message', 'message'); delete_bk_option('booking_thank_you_page_URL', site_url()); delete_bk_option('booking_is_use_autofill_4_logged_user'); delete_bk_option('booking_form_is_using_bs_css'); delete_bk_option('booking_form_format_type'); delete_bk_option('booking_form_field_active1'); delete_bk_option('booking_form_field_required1'); delete_bk_option('booking_form_field_label1'); delete_bk_option('booking_form_field_active2'); delete_bk_option('booking_form_field_required2'); delete_bk_option('booking_form_field_label2'); delete_bk_option('booking_form_field_active3'); delete_bk_option('booking_form_field_required3'); delete_bk_option('booking_form_field_label3'); delete_bk_option('booking_form_field_active4'); delete_bk_option('booking_form_field_required4'); delete_bk_option('booking_form_field_label4'); delete_bk_option('booking_form_field_active5'); delete_bk_option('booking_form_field_required5'); delete_bk_option('booking_form_field_label5'); delete_bk_option('booking_date_format'); delete_bk_option('booking_date_view_type'); delete_bk_option('booking_is_delete_if_deactive'); // check delete_bk_option('booking_wpdev_copyright_adminpanel'); // check delete_bk_option('booking_is_show_powered_by_notice'); // check delete_bk_option('booking_is_use_captcha'); delete_bk_option('booking_is_show_legend'); delete_bk_option('booking_legend_is_show_item_available'); delete_bk_option('booking_legend_text_for_item_available'); delete_bk_option('booking_legend_is_show_item_pending'); delete_bk_option('booking_legend_text_for_item_pending'); delete_bk_option('booking_legend_is_show_item_approved'); delete_bk_option('booking_legend_text_for_item_approved'); if (class_exists('wpdev_bk_biz_s')) { delete_bk_option('booking_legend_is_show_item_partially'); delete_bk_option('booking_legend_text_for_item_partially'); } delete_bk_option('booking_dif_colors_approval_pending'); delete_bk_option('booking_is_use_hints_at_admin_panel'); delete_bk_option('booking_is_not_load_bs_script_in_client'); delete_bk_option('booking_is_not_load_bs_script_in_admin'); delete_bk_option('booking_multiple_day_selections'); delete_bk_option('booking_type_of_day_selections'); delete_bk_option('booking_unavailable_days_num_from_today'); delete_bk_option('booking_unavailable_day0'); delete_bk_option('booking_unavailable_day1'); delete_bk_option('booking_unavailable_day2'); delete_bk_option('booking_unavailable_day3'); delete_bk_option('booking_unavailable_day4'); delete_bk_option('booking_unavailable_day5'); delete_bk_option('booking_unavailable_day6'); delete_bk_option('booking_user_role_booking'); delete_bk_option('booking_user_role_addbooking'); delete_bk_option('booking_user_role_resources'); delete_bk_option('booking_user_role_settings'); delete_bk_option('booking_email_reservation_adress'); delete_bk_option('booking_email_reservation_from_adress'); delete_bk_option('booking_email_reservation_subject'); delete_bk_option('booking_email_reservation_content'); delete_bk_option('booking_email_approval_adress'); delete_bk_option('booking_email_approval_subject'); delete_bk_option('booking_email_approval_content'); delete_bk_option('booking_email_deny_adress'); delete_bk_option('booking_email_deny_subject'); delete_bk_option('booking_email_deny_content'); delete_bk_option('booking_is_email_reservation_adress'); delete_bk_option('booking_is_email_approval_adress'); delete_bk_option('booking_is_email_deny_adress'); delete_bk_option('booking_widget_title'); delete_bk_option('booking_widget_show'); delete_bk_option('booking_widget_type'); delete_bk_option('booking_widget_calendar_count'); delete_bk_option('booking_widget_last_field'); global $wpdb; $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}booking"); $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}bookingdates"); // Delete all users booking windows states if (false === $wpdb->query("DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '%booking_%'")) { // All users data bk_error('Error during deleting user meta at DB', __FILE__, __LINE__); die; } // Delete or Drafts and Pending from demo sites if (wpdev_bk_is_this_demo()) { // Delete all temp posts at the demo sites: (post_status = pending || draft) && ( post_type = post ) && (post_author != 1) $postss = $wpdb->get_results("SELECT * FROM {$wpdb->posts} WHERE ( post_status = 'pending' OR post_status = 'draft' OR post_status = 'auto-draft' OR post_status = 'trash' OR post_status = 'inherit' ) AND ( post_type='post' OR post_type='revision') AND post_author != 1"); foreach ($postss as $pp) { wp_delete_post($pp->ID, true); } } make_bk_action('wpdev_booking_deactivation'); } }
function run() { // Define some variables ////////////////////////////////////////////// $is_send_emeils = 0; // ( ( get_bk_option( 'booking_gcal_is_send_email') == 'On' ) ? 1 : 0 ); $this->events = array(); // $url = $this->feed_url; // // // Break the feed URL up into its parts (scheme, host, path, query) // $url_parts = parse_url( $url ); // // if (! isset($url_parts['path'])) // Something wrong with URL // return false; // // $scheme_and_host = $url_parts['scheme'] . '://' . $url_parts['host']; // // // Remove the exisitng projection from the path, and replace it with '/full-noattendees' // $path = substr( $url_parts['path'], 0, strrpos( $url_parts['path'], '/' ) ) . '/full-noattendees'; // // // Add the default parameters to the querystring (retrieving JSON, not XML) // $query = '?alt=json&singleevents=false&sortorder=ascending&orderby=starttime'; $gmt_offset = get_option('gmt_offset') * 3600; //$this->feed_url = '*****@*****.**'; $url = 'https://www.googleapis.com/calendar/v3/calendars/' . $this->feed_url . '/events'; // Google API Key -- public Google API key shared across all plugin users. Currently the shared key is limited to 500,000 requests per day and 5 requests per second. $api_key = get_bk_option('booking_gcal_api_key'); // Set API key $url .= '?key=' . $api_key; $args['timeMin'] = urlencode(date('c', $this->booking_gcal_events_from - $gmt_offset)); $args['timeMax'] = urlencode(date('c', $this->booking_gcal_events_until - $gmt_offset)); $args['maxResults'] = $this->booking_gcal_events_max; $args['singleEvents'] = 'True'; //'False'; // Each recurrent event will be showing as separate booking. Google Description: Whether to expand recurring events into instances and only return single one-off events and instances of recurring events, but not the underlying recurring events themselves. Optional. The default is False. if (!empty($this->booking_gcal_timezone)) { $args['timeZone'] = $this->booking_gcal_timezone; } $url = add_query_arg($args, $url); // //Append the feed specific parameters to the querystring // $query .= '&start-min=' . date( 'Y-m-d\TH:i:s', $this->booking_gcal_events_from - $gmt_offset ); // $query .= '&start-max=' . date( 'Y-m-d\TH:i:s', $this->booking_gcal_events_until - $gmt_offset ); // $query .= '&max-results=' . $this->booking_gcal_events_max; // // if ( ! empty( $this->booking_gcal_timezone ) ) // $query .= '&ctz=' . $this->booking_gcal_timezone; // // //If enabled, use experimental 'fields' parameter of Google Data API, so that only necessary data is retrieved. This *significantly* reduces amount of data to retrieve and process // // $query .= '&fields=entry(title,link[@rel="alternate"],content,gd:where,gd:when,gCal:uid)'; // // $url = $scheme_and_host . $path . $query; $this->show_message(__('Importing Feed', 'booking') . ': ' . $url, true); //debuge($url); //Retrieve the feed data $raw_data = wp_remote_get($url, array('sslverify' => false, 'timeout' => 10)); //debuge($raw_data); //If $raw_data is a WP_Error, something went wrong if (!is_wp_error($raw_data)) { //If response code isn't 200, something went wrong if (200 == $raw_data['response']['code']) { $this->show_message(__('Data Parsing', 'booking'), true); //Attempt to convert the returned JSON into an array $raw_data = json_decode($raw_data['body'], true); //debuge($raw_data); //If decoding was successful if (!empty($raw_data)) { //If there are some entries (events) to process if (isset($raw_data['items'])) { //Loop through each event, extracting the relevant information foreach ($raw_data['items'] as $event) { //debuge($event); $id = esc_html($event['id']); $title = isset($event['summary']) ? esc_html($event['summary']) : ''; $description = isset($event['description']) ? esc_html($event['description']) : ''; //$link = esc_url( $event['link'][0]['href'] ); $location = isset($event['location']) ? esc_html($event['location']) : ''; if (isset($event['creator']) && isset($event['creator']['email'])) { $event_author_email = esc_html($event['creator']['email']); } else { $event_author_email = ''; } if (isset($event['start']) && isset($event['end'])) { list($range_dates, $range_time) = $this->getCommaSeparatedDates($event['start'], $event['end']); } else { continue; } // Skip if we gave no dates //debuge($range_dates, $range_time); $bktype = $this->getResource(); $previous_active_user = -1; // MU if (class_exists('wpdev_bk_multiuser')) { // Get the owner of this booking resource $user_bk_id = apply_bk_filter('get_user_of_this_bk_resource', false, $bktype); // Check if its different user if ($user_bk_id !== false && $this->getUserID() != $user_bk_id) { // Get possible other active user settings $previous_active_user = apply_bk_filter('get_client_side_active_params_of_user'); // Set active user of that specific booking resource make_bk_action('check_multiuser_params_for_client_side_by_user_id', $user_bk_id); } } $booking_gcal_events_form_fields = get_bk_option('booking_gcal_events_form_fields'); if (is_serialized($booking_gcal_events_form_fields)) { $booking_gcal_events_form_fields = unserialize($booking_gcal_events_form_fields); } // MU if ($previous_active_user !== -1) { // Reactivate the previous active user make_bk_action('check_multiuser_params_for_client_side_by_user_id', $previous_active_user); } $booking_gcal_events_form_fields1 = explode('^', $booking_gcal_events_form_fields['title']); $booking_gcal_events_form_fields1 = empty($booking_gcal_events_form_fields1[1]) ? false : true; $booking_gcal_events_form_fields2 = explode('^', $booking_gcal_events_form_fields['description']); $booking_gcal_events_form_fields2 = empty($booking_gcal_events_form_fields2[1]) ? false : true; $booking_gcal_events_form_fields3 = explode('^', $booking_gcal_events_form_fields['where']); $booking_gcal_events_form_fields3 = empty($booking_gcal_events_form_fields3[1]) ? false : true; $submit_array = array('bktype' => $bktype, 'dates' => $range_dates, 'form' => $range_time . ($booking_gcal_events_form_fields1 ? trim($booking_gcal_events_form_fields['title']) . "{$bktype}^{$title}~" : '') . ($booking_gcal_events_form_fields2 ? trim($booking_gcal_events_form_fields['description']) . "{$bktype}^{$description}~" : '') . ($booking_gcal_events_form_fields3 ? trim($booking_gcal_events_form_fields['where']) . "{$bktype}^{$location}" : ''), 'is_send_emeils' => $is_send_emeils, 'sync_gid' => $id); // Add imported data to the array of events $this->events[] = array('sync_gid' => $id, 'title' => $title, 'description' => $description, 'location' => $location, 'dates' => $range_dates, 'times' => $range_time, 'booking_submit_data' => $submit_array); } } } else { //json_decode failed $this->error = __('Some data was retrieved, but could not be parsed successfully. Please ensure your feed URL is correct.', GCE_TEXT_DOMAIN); } } else { //The response code wasn't 200, so generate a helpful(ish) error message depending on error code switch ($raw_data['response']['code']) { case 404: $this->error = __('The feed could not be found (404). Please ensure your feed URL is correct.', 'booking'); break; case 403: $this->error = __('Access to this feed was denied (403). Please ensure you have public sharing enabled for your calendar.', 'booking'); break; default: $this->error = sprintf(__('The feed data could not be retrieved. Error code: %s. Please ensure your feed URL is correct.', 'booking'), $raw_data['response']['code']); } } } else { //Generate an error message from the returned WP_Error $this->error = $raw_data->get_error_message(); } if (!empty($this->error)) { $is_spin = false; $is_error = true; $this->show_message($this->error, $is_spin, $is_error); return false; } else { $this->show_message(__('Done', 'booking')); } // Get Already exist same bookings $exist_bookings_guid = $this->getExistBookings_gid($this->events); // Create New bookings if (!empty($this->events)) { $this->createNewBookingsFromEvents($exist_bookings_guid); } // Show imported Bookings Table if (!empty($this->events) && !$this->is_silent) { $this->showImportedEvents(); } return true; }