/* ----------------------------------------------- Change Log and Features for Future Releases : ----------------------------------------------- M i n o r T O D O List: * Posibility to add at the booking bookmark how many days to select in range there. * Different rental lengths for different types of items. For example, Room 1 is only available to rent 1 day at a time and Room 2 is available to rent for either 1, 3 or 7 days. * if the user selects a Friday, Saturday or Sunday, it must be part of at least two days, but they can book single days on Monday, Tuesday, Wednesday and Thursday * Several range selections * Possible to not allow the booking before the paypal payment has been made, meaning, to entry in the booking calendar, no email, etc. before the payment has been confirmed via paypal * To deactivate the Pending option. If a customer books a particular date interval without paying, the booking request must be transfered for future payment, but must not block the calendar dates. Other visitors must be able to book these dates as long as the intial customer's payment has not come through * (Maybe at new CRM plugin) Google Calendar integration: it would be nice, someone books inserted into one of Google calendars of administraor, which is used to register all books. This way, it gets synchronized to desktop and iPhone as well * Send text messages after booking appointments, send Reminders via email and text messaging, SMS or text message option, to notify you immediately via your cell phone when you get a booking online * field type be created that only accepts numbers (auto-validates as number only) or have REGEX defined by user. * Add to Professional version posibility to set pending days for selection by other visitors, untill admin will not approve them. * Allow pending bookings to be chosen with an explanation that they will be on a waiting list in the event that the original booker cancels * * check posibility to include this payment system : https://www.nmi.com/ (its for Panama) * Paypal pro integration * Authorize . net support * Google checkout support * eway payment system support * 2co payment system * * Dependence cost from 2 parameters at same time: number of selected days and season of selection ) * Add checking to the email sending according errors ( it can be when PHP Mail function is not active at the SERVER ) * Season filtering by weeks numbers * Add description inside of input text fields inside of fields as grey text ??? * More good look of help info at the form fields customization page * Set posibility to login with user permission at MultiUser version * set required field phone for free version ??? * Id like this [select visitors "1" "2" "3" "4" “5”] to be dynamic. If there is 3 products free, I’d like to see [select visitors "1" "2" "3"] If there is 1 products free, I’d like to see [select visitors "1"] In the popup you can see price and product free so I imagine it’s possible to make selected visitors dynamic * Days cost view inside of calendar,unders the days numbers * booking manager pro - it would be much better if the booking manager displayed who had paid and who hadn't right now every order goes through with no way of identifying this * automated email to go out to people a couple of days prior to their reservation yet * set different times on different days, yet still have them show up on the same calendar * Fix to use the dynamic range / two mouse click selection, specifying 2 or more days minimum, it is quite easy to click only once, or click a third time and enter just one day. Add logic that would alert the user to the two day consecutive minimum IF they attempt to make a booking with less than the consecutive minimum and stop them going further * Add posibility to select booking resource from select box as a feature of booking calendar - no anymore JS tricks M a j o r T O D O List: * 2.8 Posibility to set Maximum days selections in a range days selection using 2 mouse buttons. Also posibility to set discreet numbers, like possible selection only 3, 7 and 14 days and so on. Add posibility to select only weeks (or may be other number of days). Its mean that can be selected only 7+7+7+... days. * * 2.8 HOTEL. Search functionality of available booking resource from all system. Example: Customer is shown a calendar Customer chooses day they wish the rental to start, hit "search" Table of items available to rent beginning THAT DAY come up customer selects desired rental customer is taken to the page with the reservation form for that rental item. * A user front end property search facility : (From Arrival Date – To Date) / No of bedrooms (or travellers) / Location. Search results would be a listed output each linking to a individual Page / Post where clients would have the opportunity to book available dates. * * ------------------------------------------------------- * Most of the time, your actual display is ok but, also quite often, many people wants to travel together and want to see in a nut shell what is available to quickly find when they can reserve together. * Therefore a linear summary calendar with the following format would be a very useful tool. Arrows would allow to go forth and back in the calendar. * A character would give the status: 0=not available, 1=available (in fact the number could be the number of persons that can stay in that resource ?), w= in a process of reservation * · Month June July August * · Ressource 01 02 03 03 05 06 07 08 09 10 11 … 01 02 03 04 … 01 02 03 04 … * · Ressource 1 0 0 1 1 1 1 1 1 1 w w * · Ressource 2 * Make categories for resources? I have like 70 resources, and it would be great if i could split the choices on different pages or in different categories. * --------------------------------------------------------------------------------------------------------------------------------------- = 2.8 = * Professional / Premium / Premium Plus / Hotel / MultiUser versions features: * * Features and issue fixings in All versions: * */ // // if (!function_exists ('debuge')) { function debuge() { $numargs = func_num_args(); $var = func_get_args(); $makeexit = is_bool($var[count($var)-1])?$var[count($var)-1]:false; echo "
";
        print_r ( $var );
        echo "
"; if ($makeexit) { echo '
' . get_num_queries(). '/' . timer_stop(0, 3) . 'qps
'; exit; } } } if (!function_exists ('bk_error')) { function bk_error( $msg , $file_name='', $line_num=''){ if (!defined('WPDEV_BK_VERSION')) $ver_num = 'Undefined yet'; else $ver_num = WPDEV_BK_VERSION ; $last_db_error = ''; global $EZSQL_ERROR; if (isset($EZSQL_ERROR[ (count($EZSQL_ERROR)-1)])) { $last_db_error2 = $EZSQL_ERROR[ (count($EZSQL_ERROR)-1)]; if ( (isset($last_db_error2['query'])) && (isset($last_db_error2['error_str'])) ) { $query = $last_db_error2['query']; $str = str_replace('','',$last_db_error2['error_str']); $str = str_replace('"','', $str ); $str = str_replace("'",'', $str ); $query = str_replace('"','', $query ); $query = str_replace("'",'', $query ); $str = htmlspecialchars( $str, ENT_QUOTES ); $query = htmlspecialchars( $query , ENT_QUOTES ); //$last_db_error = '

Last error: ['.$str.']
'.$query.'

'; $last_db_error = $str ; if ( WP_BK_DEBUG_MODE ) $last_db_error .= '::'.$query.''; } } echo $msg . '
[F:' . str_replace( dirname( $file_name ) , '' , $file_name ). "|L:" . $line_num . "|V:" . $ver_num . "|DB:" . $last_db_error ."] " ; } } //
// global $wpdev_bk_action, $wpdev_bk_filter; if (!function_exists ('add_bk_filter')) { function add_bk_filter($filter_type, $filter) { global $wpdev_bk_filter; $args = array(); if ( is_array($filter) && 1 == count($filter) && is_object($filter[0]) ) // array(&$this) $args[] =& $filter[0]; else $args[] = $filter; for ( $a = 2; $a < func_num_args(); $a++ ) $args[] = func_get_arg($a); if ( is_array($wpdev_bk_filter) ) if ( isset($wpdev_bk_filter[$filter_type]) ) { if ( is_array($wpdev_bk_filter[$filter_type]) ) $wpdev_bk_filter[$filter_type][]= $args; else $wpdev_bk_filter[$filter_type]= array($args); } else $wpdev_bk_filter[$filter_type]= array($args); else $wpdev_bk_filter = array( $filter_type => array( $args ) ) ; } } if (!function_exists ('remove_bk_filter')) { function remove_bk_filter($filter_type, $filter) { global $wpdev_bk_filter; if ( isset($wpdev_bk_filter[$filter_type]) ) { for ($i = 0; $i < count($wpdev_bk_filter[$filter_type]); $i++) { if ( $wpdev_bk_filter[$filter_type][$i][0] == $filter ) { $wpdev_bk_filter[$filter_type][$i] = null; return; } } } } } if (!function_exists ('apply_bk_filter')) { function apply_bk_filter($filter_type) { global $wpdev_bk_filter; $args = array(); for ( $a = 1; $a < func_num_args(); $a++ ) $args[] = func_get_arg($a); if ( count($args) > 0 ) $value = $args[0]; else $value = false; if ( is_array($wpdev_bk_filter) ) if ( isset($wpdev_bk_filter[$filter_type]) ) foreach ($wpdev_bk_filter[$filter_type] as $filter) { $filter_func = array_shift($filter); $parameter = $args; $value = call_user_func_array($filter_func,$parameter ); } return $value; } } if (!function_exists ('make_bk_action')) { function make_bk_action($action_type) { global $wpdev_bk_action; $args = array(); for ( $a = 1; $a < func_num_args(); $a++ ) $args[] = func_get_arg($a); //$value = $args[0]; if ( is_array($wpdev_bk_action) ) if ( isset($wpdev_bk_action[$action_type]) ) foreach ($wpdev_bk_action[$action_type] as $action) { $action_func = array_shift($action); $parameter = $action; call_user_func_array($action_func,$args ); } } } if (!function_exists ('add_bk_action')) { function add_bk_action($action_type, $action) { global $wpdev_bk_action; $args = array(); if ( is_array($action) && 1 == count($action) && is_object($action[0]) ) // array(&$this) $args[] =& $action[0]; else $args[] = $action; for ( $a = 2; $a < func_num_args(); $a++ ) $args[] = func_get_arg($a); if ( is_array($wpdev_bk_action) ) if ( isset($wpdev_bk_action[$action_type]) ) { if ( is_array($wpdev_bk_action[$action_type]) ) $wpdev_bk_action[$action_type][]= $args; else $wpdev_bk_action[$action_type]= array($args); } else $wpdev_bk_action[$action_type]= array($args); else $wpdev_bk_action = array( $action_type => array( $args ) ) ; } } if (!function_exists ('remove_bk_action')) { function remove_bk_action($action_type, $action) { global $wpdev_bk_action; if ( isset($wpdev_bk_action[$action_type]) ) { for ($i = 0; $i < count($wpdev_bk_action[$action_type]); $i++) { if ( $wpdev_bk_action[$action_type][$i][0] == $action ) { $wpdev_bk_action[$action_type][$i] = null; return; } } } } } // Work with Booking Oprions ////////////////////////////////////////////////// if (!function_exists ('get_bk_option')) { // Get function get_bk_option( $option, $default = false ) { $u_value = apply_bk_filter('wpdev_bk_get_option', 'no-values' , $option, $default ); if ( $u_value !== 'no-values' ) return $u_value; return get_option( $option, $default ); } } if (!function_exists ('update_bk_option')) { // Update function update_bk_option ( $option, $newvalue ) { $u_value = apply_bk_filter('wpdev_bk_update_option', 'no-values' , $option, $newvalue ); if ( $u_value !== 'no-values' ) return $u_value; return update_option($option, $newvalue); } } if (!function_exists ('delete_bk_option')) { // Dekete function delete_bk_option ( $option ) { $u_value = apply_bk_filter('wpdev_bk_delete_option', 'no-values' , $option ); if ( $u_value !== 'no-values' ) return $u_value; return delete_option($option ); } } if (!function_exists ('add_bk_option')) { // Add function add_bk_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) { $u_value = apply_bk_filter('wpdev_bk_add_option', 'no-values' , $option, $value, $deprecated, $autoload ); if ( $u_value !== 'no-values' ) return $u_value; return add_option( $option, $value , $deprecated , $autoload ); } } //////////////////////////////////////////////////////////////////////////////// // // // Get header info from this file, just for compatibility with WordPress 2.8 and older versions ////////////////////////////////////// if (!function_exists ('get_file_data_wpdev')) { function get_file_data_wpdev( $file, $default_headers, $context = '' ) { // We don't need to write to the file, so just open for reading. $fp = fopen( $file, 'r' ); // Pull only the first 8kiB of the file in. $file_data = fread( $fp, 8192 ); // PHP will close file handle, but we are good citizens. fclose( $fp ); if( $context != '' ) { $extra_headers = array();//apply_filters( "extra_$context".'_headers', array() ); $extra_headers = array_flip( $extra_headers ); foreach( $extra_headers as $key=>$value ) { $extra_headers[$key] = $key; } $all_headers = array_merge($extra_headers, $default_headers); } else { $all_headers = $default_headers; } foreach ( $all_headers as $field => $regex ) { preg_match( '/' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, ${$field}); if ( !empty( ${$field} ) ) ${$field} = trim(preg_replace("/\s*(?:\*\/|\?>).*/", '', ${$field}[1] )); else ${$field} = ''; } $file_data = compact( array_keys( $all_headers ) ); return $file_data; } } // D e f i n e S T A T I C ////////////////////////////////////////////////////////////////////////////////////////////////// if (!defined('WP_BK_DEBUG_MODE')) define('WP_BK_DEBUG_MODE', false ); if (!function_exists ('wpdev_bk_define_static')) { function wpdev_bk_define_static() { if ( (! isset( $_GET['merchant_return_link'] ) ) && (! isset( $_GET['payed_booking'] ) ) && (!function_exists ('get_option') ) ) { die('You do not have permission to direct access to this file !!!'); } $default_headers = array( 'Name' => 'Plugin Name', 'PluginURI' => 'Plugin URI', 'Version' => 'Version', 'Description' => 'Description', 'Author' => 'Author', 'AuthorURI' => 'Author URI', 'TextDomain' => 'Text Domain', 'DomainPath' => 'Domain Path' ); $plugin_data = get_file_data_wpdev( __FILE__, $default_headers, 'plugin' ); if (!defined('WP_CONTENT_DIR')) define('WP_CONTENT_DIR', ABSPATH . 'wp-content'); // Z:\home\test.wpdevelop.com\www/wp-content if (!defined('WP_CONTENT_URL')) define('WP_CONTENT_URL', get_option('siteurl') . '/wp-content'); // http://test.wpdevelop.com/wp-content if (!defined('WP_PLUGIN_DIR')) define('WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins'); // Z:\home\test.wpdevelop.com\www/wp-content/plugins if (!defined('WP_PLUGIN_URL')) define('WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins'); // http://test.wpdevelop.com/wp-content/plugins if (!defined('WPDEV_BK_PLUGIN_FILENAME')) define('WPDEV_BK_PLUGIN_FILENAME', basename( __FILE__ ) ); // menu-compouser.php if (!defined('WPDEV_BK_PLUGIN_DIRNAME')) define('WPDEV_BK_PLUGIN_DIRNAME', plugin_basename(dirname(__FILE__)) ); // menu-compouser if (!defined('WPDEV_BK_PLUGIN_DIR')) define('WPDEV_BK_PLUGIN_DIR', WP_PLUGIN_DIR.'/'.WPDEV_BK_PLUGIN_DIRNAME ); // Z:\home\test.wpdevelop.com\www/wp-content/plugins/menu-compouser if (!defined('WPDEV_BK_PLUGIN_URL')) define('WPDEV_BK_PLUGIN_URL', WP_PLUGIN_URL.'/'.WPDEV_BK_PLUGIN_DIRNAME ); // http://test.wpdevelop.com/wp-content/plugins/menu-compouser $version_type = ''; if (!defined('WPDEV_BK_VERSION')) define('WPDEV_BK_VERSION', $version_type.$plugin_data['Version'] ); // 0.1 require_once(WPDEV_BK_PLUGIN_DIR. '/js/captcha/captcha.php' ); if (file_exists(WPDEV_BK_PLUGIN_DIR. '/include/wpdev-pro.php')) { require_once(WPDEV_BK_PLUGIN_DIR. '/include/wpdev-pro.php' ); } if ( ! loadLocale() ) { loadLocale('en_US'); } $locale = get_locale(); //$locale = 'fr_FR'; loadLocale($locale); // Localization if ($locale != 'en_US') { global $l10n; //Recheck translation files according ' sign if (isset($l10n['wpdev-booking'])) foreach ($l10n['wpdev-booking']->entries as $key=>$tr_obj) { $new_translation = str_replace("'","\\'",$tr_obj->translations); $l10n['wpdev-booking']->entries[$key]->translations = $new_translation; } } } } // Load locale ////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (!function_exists ('loadLocale')) { function loadLocale($locale = '') { // Load locale, if not so the load en_EN default locale from folder "languages" files like "this_file_file_name-ru_RU.po" and "this_file_file_name-ru_RU.mo" if ( empty( $locale ) ) $locale = get_locale(); if ( !empty( $locale ) ) { //Filenames like this "microstock-photo-ru_RU.po", "microstock-photo-de_DE.po" at folder "languages" $domain = str_replace('.php','',WPDEV_BK_PLUGIN_FILENAME) ; $mofile = WPDEV_BK_PLUGIN_DIR .'/languages/'.$domain.'-'.$locale.'.mo'; if (file_exists($mofile)) { //return load_textdomain($domain , $mofile); // Depricated $plugin_rel_path = WPDEV_BK_PLUGIN_DIRNAME .'/languages' ; return load_plugin_textdomain( $domain , false, $plugin_rel_path ) ; } else return false; } return false; } } // // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Getting Ajax requests ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if ( isset( $_POST['ajax_action'] ) ) { define('DOING_AJAX', true); require_once( dirname(__FILE__) . '/../../../wp-load.php' ); @header('Content-Type: text/html; charset=' . get_option('blog_charset')); wpdev_bk_define_static(); if ( class_exists('wpdev_bk_pro')) { $wpdev_bk_pro_in_ajax = new wpdev_bk_pro(); } wpdev_bk_ajax_responder(); } if ( ( isset( $_GET['payed_booking'] ) ) || ( isset( $_GET['merchant_return_link'])) ) { require_once( dirname(__FILE__) . '/../../../wp-load.php' ); @header('Content-Type: text/html; charset=' . get_option('blog_charset')); wpdev_bk_define_static(); if ( class_exists('wpdev_bk_pro')) { $wpdev_bk_pro_in_ajax = new wpdev_bk_pro(); } if (function_exists ('wpdev_bk_update_pay_status')) wpdev_bk_update_pay_status(); die; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // wpdev_bk_define_static(); // if (!class_exists('wpdev_booking')) { class wpdev_booking { // var $icon_button_url; var $prefix; var $settings; var $wpdev_bk_pro; var $captcha_instance; function wpdev_booking() { // Add settings top line before all other menu items. add_bk_action('wpdev_booking_settings_top_menu', array($this, 'settings_menu_top_line')); add_bk_action('wpdev_booking_settings_show_content', array(&$this, 'settings_menu_content')); $this->captcha_instance = new wpdevReallySimpleCaptcha(); $this->prefix = 'wpdev_bk'; $this->settings = array( 'custom_buttons' =>array(), 'custom_buttons_func_name_from_js_file' => 'set_bk_buttons', //Edit this name at the JS file of custom buttons 'custom_editor_button_row'=>1 ); $this->icon_button_url = WPDEV_BK_PLUGIN_URL . '/img/calendar-16x16.png'; if ( class_exists('wpdev_bk_pro')) { $this->wpdev_bk_pro = new wpdev_bk_pro(); } else { $this->wpdev_bk_pro = false; } // Create admin menu add_action('admin_menu', array(&$this, 'add_new_admin_menu')); // Client side print JSS add_action('wp_head',array(&$this, 'client_side_print_booking_head')); // Add custom buttons add_action( 'init', array(&$this,'add_custom_buttons') ); add_action( 'admin_head', array(&$this,'insert_wpdev_button')); // add_action( 'wp_footer', array(&$this,'wp_footer') ); add_action( 'admin_footer', array(&$this,'print_js_at_footer') ); // User defined add_action( 'wpdev_bk_add_calendar', array(&$this,'add_calendar_action') ,10 , 2); add_action( 'wpdev_bk_add_form', array(&$this,'add_booking_form_action') ,10 , 2); add_filter( 'wpdev_bk_get_form', array(&$this,'get_booking_form_action') ,10 , 2); add_filter( 'wpdev_bk_get_showing_date_format', array(&$this,'get_showing_date_format') ,10 , 1); add_filter( 'wpdev_bk_is_next_day', array(&$this,'is_next_day') ,10 , 2); add_bk_filter( 'wpdev_booking_table', array(&$this, 'booking_table')); add_bk_action('show_footer_at_booking_page', array(&$this, 'show_footer_at_booking_page')); add_bk_filter( 'get_script_for_calendar', array(&$this, 'get_script_for_calendar')); // Get script for calendar activation // S H O R T C O D E - Booking add_shortcode('booking', array(&$this, 'booking_shortcode')); add_shortcode('bookingcalendar', array(&$this, 'booking_calendar_only_shortcode')); add_shortcode('bookingform', array(&$this, 'bookingform_shortcode')); add_shortcode('bookingedit', array(&$this, 'bookingedit_shortcode')); // Add settings link at the plugin page add_filter('plugin_action_links', array(&$this, 'plugin_links'), 10, 2 ); // Add widjet add_action( 'init', array(&$this,'add_booking_widjet') ); // Install / Uninstall register_activation_hook( __FILE__, array(&$this,'wpdev_booking_activate' )); register_deactivation_hook( __FILE__, array(&$this,'wpdev_booking_deactivate' )); add_filter('upgrader_post_install', array(&$this, 'install_in_bulk_upgrade'), 10, 2); // Upgrade during bulk upgrade of plugins add_bk_action('wpdev_booking_activate_user', array(&$this, 'wpdev_booking_activate')); if ( ( strpos($_SERVER['REQUEST_URI'],'wpdev-booking.phpwpdev-booking')!==false) && ( strpos($_SERVER['REQUEST_URI'],'wpdev-booking.phpwpdev-booking-reservation')===false ) ) { if (defined('WP_ADMIN')) if (WP_ADMIN === true) wp_enqueue_script( 'jquery-ui-dialog' ); wp_enqueue_style( 'wpdev-bk-jquery-ui', WPDEV_BK_PLUGIN_URL. '/css/jquery-ui.css', array(), 'wpdev-bk', 'screen' ); } // add_filter( 'site_transient_update_plugins', array(&$this, 'plugin_non_update'), 10, 1 ); // donot show update for Professional active plugin // add_action( 'after_plugin_row', array(&$this,'after_plugin_row'),10,3 ); // add_filter( 'plugin_row_meta', array(&$this, 'plugin_row_meta'), 10, 4 ); // donot show update for Professional active plugin } // // // Functions for using at future versions: update info of plugin at the plugins section. function plugin_row_meta($plugin_meta, $plugin_file, $plugin_data, $context) { if ($plugin_file =='booking/wpdev-booking.php') { debuge('Ha ha', $plugin_meta, $plugin_file, $plugin_data, $context); // Echo plugin description here return $plugin_meta; } else return $plugin_meta; } function after_plugin_row($plugin_file, $plugin_data, $context) { if ($plugin_file =='booking/wpdev-booking.php') { ?>
Please check updates of Paid versions here.
response as $key=>$version_value) { //debuge($key, $version_value->new_version ); if( strpos($key, 'wpdev-booking.php') !== false ) { unset($value->response[$key]); break; } } //debuge($value); return $value; } // Adds Settings link to plugins settings function plugin_links($links, $file) { $this_plugin = plugin_basename(__FILE__); if ($file == $this_plugin) { $settings_link = ''.__("Settings", 'wpdev-booking').''; $settings_link2 = ''.__("Buy", 'wpdev-booking').' Pro'; array_unshift($links, $settings_link2); array_unshift($links, $settings_link); } return $links; } //
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ADMIN MENU SECTIONS /////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function add_new_admin_menu() { $users_roles = array(get_bk_option( 'booking_user_role_booking' ), get_bk_option( 'booking_user_role_addbooking' ), get_bk_option( 'booking_user_role_settings' ) ); for ($i = 0 ; $i < count($users_roles) ; $i++) { if ( $users_roles[$i] == 'administrator' ) $users_roles[$i] = 'activate_plugins'; if ( $users_roles[$i] == 'editor' ) $users_roles[$i] = 'publish_pages'; if ( $users_roles[$i] == 'author' ) $users_roles[$i] = 'publish_posts'; if ( $users_roles[$i] == 'contributor' ) $users_roles[$i] = 'edit_posts'; if ( $users_roles[$i] == 'subscriber') $users_roles[$i] = 'read'; //if ( $users_roles[$i] == 'administrator' ) $users_roles[$i] = 10; //if ( $users_roles[$i] == 'editor' ) $users_roles[$i] = 7; //if ( $users_roles[$i] == 'author' ) $users_roles[$i] = 2; //if ( $users_roles[$i] == 'contributor' ) $users_roles[$i] = 1; //if ( $users_roles[$i] == 'subscriber') $users_roles[$i] = 0; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // M A I N B O O K I N G /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $pagehook1 = add_menu_page( __('Reservation services', 'wpdev-booking'), __('Booking', 'wpdev-booking'), $users_roles[0], __FILE__ . 'wpdev-booking', array(&$this, 'on_show_booking_page_main'), WPDEV_BK_PLUGIN_URL . '/img/calendar-16x16.png' ); add_action("admin_print_scripts-" . $pagehook1 , array( &$this, 'on_add_admin_js_files')); /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // A D D R E S E R V A T I O N /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $pagehook2 = add_submenu_page(__FILE__ . 'wpdev-booking',__('Add booking', 'wpdev-booking'), __('Add booking', 'wpdev-booking'), $users_roles[1], __FILE__ .'wpdev-booking-reservation', array(&$this, 'on_show_booking_page_addbooking') ); add_action("admin_print_scripts-" . $pagehook2 , array( &$this, 'client_side_print_booking_head')); /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // S E T T I N G S /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $pagehook3 = add_submenu_page(__FILE__ . 'wpdev-booking',__('Booking settings customizations', 'wpdev-booking'), __('Settings', 'wpdev-booking'), $users_roles[2], __FILE__ .'wpdev-booking-option', array(&$this, 'on_show_booking_page_settings') ); add_action("admin_print_scripts-" . $pagehook3 , array( &$this, 'on_add_admin_js_files')); /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // global $submenu, $menu; // Change Title of the Main menu inside of submenu // this is make error in roleswhen we have first autor and then admin and admin roles // $submenu[plugin_basename( __FILE__ ) . 'wpdev-booking'][0][0] = __('Booking calendar', 'wpdev-booking'); } //Booking function on_show_booking_page_main() { $this->on_show_page_adminmenu('wpdev-booking','/img/calendar-48x48.png', __('Reservation services', 'wpdev-booking'),1); } //Add resrvation function on_show_booking_page_addbooking() { $this->on_show_page_adminmenu('wpdev-booking-reservation','/img/add-1-48x48.png', __('Add booking', 'wpdev-booking'),2); } //Settings function on_show_booking_page_settings() { $this->on_show_page_adminmenu('wpdev-booking-option','/img/application-48x48.png', __('Booking settings customizations', 'wpdev-booking'),3); } //Show content function on_show_page_adminmenu($html_id, $icon, $title, $content_type) { ?>

' ; else echo '

' ; ?>

content_of_booking_page(); break; case 2: $this->content_of_reservation_page(); break; case 3: $this->content_of_settings_page(); break; default: break; } ?> // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // C u s t o m b u t t o n s /////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // C u s t o m b u t t o n s ///////////////////////////////////////////////////////////////////// function add_custom_buttons() { // Don't bother doing this stuff if the current user lacks permissions if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) return; // Add only in Rich Editor mode if ( ( in_array( basename($_SERVER['PHP_SELF']), array('post-new.php', 'page-new.php', 'post.php', 'page.php') ) ) /*&& ( get_user_option('rich_editing') == 'true')*/ ) { //content_wpdev_bk_booking_insert // 'content_' . $this->$prefix . '_' . $type $this->settings['custom_buttons'] = array( 'booking_insert' => array( 'hint' => __('Insert booking calendar', 'wpdev-booking'), 'title'=> __('Booking calendar', 'wpdev-booking'), 'img'=> $this->icon_button_url, 'js_func_name_click' => 'booking_click', 'bookmark' => 'booking', 'class' => 'bookig_buttons', 'is_close_bookmark' =>0 ) ); add_filter("mce_external_plugins", array(&$this, "mce_external_plugins")); // add_action( 'admin_head', array(&$this, 'add_custom_button_function') ); add_action( 'edit_form_advanced', array(&$this, 'add_custom_button_function') ); add_action( 'edit_page_form', array(&$this, 'add_custom_button_function') ); if ( 1 == $this->settings['custom_editor_button_row'] ) add_filter( 'mce_buttons', array(&$this, 'mce_buttons') ); else add_filter( 'mce_buttons_' . $this->settings['custom_editor_button_row'] , array(&$this, 'mce_buttons') ); add_action( 'admin_head', array(&$this, 'custom_button_dialog_CSS') ); add_action( 'admin_footer', array(&$this, 'custom_button_dalog_structure_DIV') ); wp_enqueue_script( 'jquery-ui-dialog' ); wp_enqueue_style( 'wpdev-bk-jquery-ui', WPDEV_BK_PLUGIN_URL. '/css/jquery-ui.css', array(), 'wpdev-bk', 'screen' ); //wp_enqueue_style( $this->prefix . '-jquery-ui',WPDEV_BK_PLUGIN_URL. '/js/custom_buttons/jquery-ui.css', array(), $this->prefix, 'screen' ); } } // Add button code to the tiny editor function insert_wpdev_button() { if ( count($this->settings['custom_buttons']) > 0) { ?> prefix . '_quicktags'] = WPDEV_BK_PLUGIN_URL.'/js/custom_buttons/editor_plugin.js'; return $plugins; } // Add the custom TinyMCE buttons function mce_buttons( $buttons ) { //array_push( $buttons, "separator", 'wpdev_booking_insert', "separator" ); array_push( $buttons, "separator"); foreach ( $this->settings['custom_buttons'] as $type => $strings ) { array_push( $buttons, $this->prefix . '_' . $type ); } return $buttons; } // Add the old style buttons to the non-TinyMCE editor views and output all of the JS for the button function + dialog box function add_custom_button_function() { $buttonshtml = ''; $datajs=''; foreach ( $this->settings['custom_buttons'] as $type => $props ) { $buttonshtml .= ''; $datajs.= " wpdev_bk_Data['$type'] = {\n"; $datajs.= ' title: "' . $this->js_escape( $props['title'] ) . '",' . "\n"; $datajs.= ' tag: "' . $this->js_escape( $props['bookmark'] ) . '",' . "\n"; $datajs.= ' tag_close: "' . $this->js_escape( $props['is_close_bookmark'] ) . '",' . "\n"; $datajs.= ' cal_count: "' . get_bk_option( 'booking_client_cal_count' ) . '"' . "\n"; $datajs.= "\n };\n"; } ?> used to display the dialog box function custom_button_dalog_structure_DIV() { ?>
// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // S U P P O R T F U N C T I O N S /////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Get array of images - icons inside of this directory function dirList ($directories) { // create an array to hold directory list $results = array(); if (is_string($directories)) $directories = array($directories); foreach ($directories as $dir) { $directory = WPDEV_BK_PLUGIN_DIR . $dir ; // create a handler for the directory $handler = @opendir($directory); if ($handler !== false) { // keep going until all files in directory have been read while ($file = readdir($handler)) { // if $file isn't this directory or its parent, // add it to the results array if ($file != '.' && $file != '..' && ( strpos($file, '.css' ) !== false ) ) $results[] = array($file, WPDEV_BK_PLUGIN_URL . $dir . $file, ucfirst(strtolower( str_replace('.css', '', $file))) ); } // tidy up: close the handler closedir($handler); } } // done! return $results; } // WordPress' js_escape() won't allow <, >, or " -- instead it converts it to an HTML entity. This is a "fixed" function that's used when needed. function js_escape($text) { $safe_text = addslashes($text); $safe_text = preg_replace('/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes($safe_text)); $safe_text = preg_replace("/\r?\n/", "\\n", addslashes($safe_text)); $safe_text = str_replace('\\\n', '\n', $safe_text); return apply_filters('js_escape', $safe_text, $text); } // Check if table exist function is_table_exists( $tablename ) { global $wpdb; if (strpos($tablename, $wpdb->prefix) ===false) $tablename = $wpdb->prefix . $tablename ; $sql_check_table = " SELECT COUNT(*) AS count FROM information_schema.tables WHERE table_schema = '". DB_NAME ."' AND table_name = '" . $tablename . "'"; $res = $wpdb->get_results($sql_check_table); return $res[0]->count; } // Check if table exist function is_field_in_table_exists( $tablename , $fieldname) { global $wpdb; if (strpos($tablename, $wpdb->prefix) ===false) $tablename = $wpdb->prefix . $tablename ; $sql_check_table = "SHOW COLUMNS FROM " . $tablename ; $res = $wpdb->get_results($sql_check_table); foreach ($res as $fld) { if ($fld->Field == $fieldname) return 1; } return 0; } // Get version function get_version(){ $version = 'free'; if (class_exists('wpdev_bk_pro')) $version = 'pro'; if (class_exists('wpdev_bk_premium')) $version = 'premium'; if (class_exists('wpdev_bk_premium_plus')) $version = 'premium_plus'; if (class_exists('wpdev_bk_hotel')) $version = 'hotel'; return $version; } // Check if nowday is tommorow from previosday function is_next_day($nowday, $previosday) { if ( empty($previosday) ) return false; $nowday_d = (date('m.d.Y', mysql2date('U', $nowday )) ); $prior_day = (date('m.d.Y', mysql2date('U', $previosday )) ); if ($prior_day == $nowday_d) return true; // if its the same date $previos_array = (date('m.d.Y', mysql2date('U', $previosday )) ); $previos_array = explode('.',$previos_array); $prior_day = date('m.d.Y' , mktime(0, 0, 0, $previos_array[0], ($previos_array[1]+1), $previos_array[2] )); if ($prior_day == $nowday_d) return true; // zavtra else return false; // net } // Change date format function get_showing_date_format($mydate ) { $date_format = get_bk_option( 'booking_date_format'); if ($date_format == '') $date_format = "d.m.Y"; $time_format = get_bk_option( 'booking_time_format'); if ( $time_format !== false ) { $time_format = ' ' . $time_format; $my_time = date('H:i:s' , $mydate); if ($my_time == '00:00:00') $time_format=''; } else $time_format=''; // return date($date_format . $time_format , $mydate); return date_i18n($date_format,$mydate) .'' . date_i18n($time_format , $mydate).''; } // // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // B O O K I N G s A D M I N F U N C T I O N s /////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Write Admin booking table function booking_table($approved = 0, $bk_type = 'not_set', $is_show_table_header = true, $is_show_link_2_bk_res = false ) { global $wpdb; //////debuge($approved , $bk_type ); if ($bk_type === 'not_set') $bk_type = $this->get_default_type(); $sql = "SELECT * FROM ".$wpdb->prefix ."booking as bk INNER JOIN ".$wpdb->prefix ."bookingdates as dt ON bk.booking_id = dt.booking_id WHERE approved = $approved AND dt.booking_date >= CURDATE() "; if ($bk_type!=0) $sql .= " AND bk.booking_type = ". $bk_type .""; $sql .= apply_bk_filter('get_sql_4_dates_from_other_types', '' , $bk_type, $approved ); // Select bk ID from other TYPES, if they partly exist inside of DATES $sql .= " ORDER BY bk.booking_id DESC, dt.booking_date ASC "; $result = $wpdb->get_results( $sql ); //debuge($result) ; /////////////////////////////////////////////////////////////////// //transforms results into structure $result_structure = array(); $old_id = ''; $ns = -1; $last_date = $last_show_date = ''; foreach ($result as $res) { if ($old_id == $res->booking_id ) { // add only dates $result_structure[$ns]['dates'][] = $res->booking_date; if (isset( $res->type_id )) $result_structure[$ns]['type_id'][] = $res->type_id; else $result_structure[$ns]['type_id'][] = '' ; } else { // new record $ns++; $old_id = $res->booking_id; $result_structure[$ns]['dates'][] = $res->booking_date; if (isset($res->type_id)) $result_structure[$ns]['type_id'][] = $res->type_id; else $result_structure[$ns]['type_id'][] = ''; $result_structure[$ns]['id'] = $res->booking_id; $cont = get_form_content($res->form, $res->booking_type);//$bk_type); $search = array ("'()+'si","'()+'si","'()+'si"); $replace = array ("  ","   ","   "); $cont['content'] = preg_replace($search, $replace, $cont['content']); $result_structure[$ns]['form'] = $cont; if (isset($res->remark)) $result_structure[$ns]['remark'] = $res->remark; else $result_structure[$ns]['remark'] = ''; if (isset($res->pay_status)) $result_structure[$ns]['pay_status'] = $res->pay_status; else $result_structure[$ns]['pay_status'] = ''; if (isset($res->cost)) $result_structure[$ns]['cost'] = $res->cost; else $result_structure[$ns]['cost'] = ''; $result_structure[$ns]['booking_type'] = $res->booking_type; if (isset($res->hash)) $result_structure[$ns]['hash'] = $res->hash; else $result_structure[$ns]['hash'] = ''; if (isset($res->pay_request)) $result_structure[$ns]['pay_request'] = $res->pay_request; else $result_structure[$ns]['pay_request'] = 0; } } /////////////////////////////////////////////////////////////////// // Get short days foreach ($result_structure as $key=>$res) { $last_day = ''; $last_show_day = ''; $short_days = array(); $short_days_type_id = array(); foreach ($res['dates'] as $dte) { if (empty($last_day)) { // First date $short_days[]= $dte; $last_show_day = $dte; } else { // All other days if ( $this->is_next_day( $dte ,$last_day) ) { if ($last_show_day != '-') $short_days[]= '-'; $last_show_day = '-'; } else { if ($last_show_day !=$last_day) $short_days[]= $last_day; $short_days[]= ','; $short_days[]= $dte; $last_show_day = $dte; } } $last_day = $dte; } if($last_show_day != $dte) $short_days[]= $dte; $result_structure[$key]['short_days'] = $short_days; for ($sd = 0; $sd < count($short_days); $sd++) { for ($ad = 0; $ad < count($res['dates']); $ad++) { if ( $short_days[$sd] == $res['dates'][$ad] ) $short_days_type_id[$sd] = $res['type_id'][$ad]; else $short_days_type_id[$sd] = false; } } $result_structure[$key]['short_days_type_id'] = $short_days_type_id; } /////////////////////////////////////////////////////////////////// // Sort this structure $sorted_structure = array(); // Sort type if (isset($_GET['booking_sort_order'])) { if ($_GET['booking_sort_order'] == 'date') { $sort_type = 'date'; $sort_order = 'ASC'; } if ($_GET['booking_sort_order'] == 'date_desc') { $sort_type = 'date'; $sort_order = 'DESC'; } if ($_GET['booking_sort_order'] == 'id') { $sort_type = 'id'; $sort_order = 'ASC'; } if ($_GET['booking_sort_order'] == 'id_desc') { $sort_type = 'id'; $sort_order = 'DESC'; } if ($_GET['booking_sort_order'] == 'name') { $sort_type = 'name'; $sort_order = 'ASC'; } if ($_GET['booking_sort_order'] == 'name_desc') { $sort_type = 'name'; $sort_order = 'DESC'; } if ($_GET['booking_sort_order'] == 'email') { $sort_type = 'email'; $sort_order = 'ASC'; } if ($_GET['booking_sort_order'] == 'email_desc') { $sort_type = 'email'; $sort_order = 'DESC'; } if ($_GET['booking_sort_order'] == 'visitors') { $sort_type = 'visitors'; $sort_order = 'ASC'; } if ($_GET['booking_sort_order'] == 'visitors_desc') { $sort_type = 'visitors'; $sort_order = 'DESC'; } } else { $sort_type = 'id'; $sort_order = 'DESC'; } //debuge('$result_structure',$result_structure); foreach ($result_structure as $key=>$value) { switch ($sort_type) { case 'date': if ( ! empty($sorted_structure[$value['dates'][0]])) $sorted_structure[$value['dates'][0] . (time() * rand()) ] = $value; else $sorted_structure[$value['dates'][0]] = $value; break; case 'name': if ( ! empty($sorted_structure[$value['form']['name']])) $sorted_structure[$value['form']['name'] . (time() * rand()) ] = $value; else $sorted_structure[strtolower($value['form']['name'])] = $value; break; case 'email': if ( ! empty($sorted_structure[$value['form']['email']])) $sorted_structure[$value['form']['email'] . (time() * rand()) ] = $value; else $sorted_structure[strtolower($value['form']['email'])] = $value; break; case 'visitors': if ( ! empty($sorted_structure[$value['form']['visitors']])) $sorted_structure[$value['form']['visitors'] . (time() * rand()) ] = $value; else $sorted_structure[$value['form']['visitors']] = $value; break; case 'id': default: $sorted_structure[$value['id']] = $value; break; } } //debuge('$sorted_structure',$sorted_structure); die; if ($sort_order == 'DESC') krsort($sorted_structure ); else ksort($sorted_structure ); //debuge($sorted_structure) ; $old_id = ''; $alternative_color = ''; if ($approved == 0) { $outColor = '#FFBB45'; $outColorClass = '0'; } if ($approved == 1) { $outColor = '#99bbee'; $outColorClass = '1'; } $booking_date_view_type = get_bk_option( 'booking_date_view_type'); if ($booking_date_view_type == 'short') { $wide_days_class = ' hide_dates_view '; $short_days_class = ''; } else { $wide_days_class = ''; $short_days_class = ' hide_dates_view '; } if (count($sorted_structure)>0) { $sort_url = ' ↓ '; $arr_desc = ''; $arr_asc = ''; $arr_desc = ''; ?> > wpdev_bk_pro !== false ) { $types_list = $this->wpdev_bk_pro->get_booking_types(); foreach ($types_list as $type_item) { $type_items[ $type_item->id ] = $type_item->title; } } //debuge($sorted_structure) ; foreach ($sorted_structure as $bk) { if ($bk_type==0) if ( ! isset( $type_items[ $bk['booking_type'] ] ) ) { continue; } if(isset($_GET['moderate_id'])) { if ($bk['id'] !== $_GET['moderate_id']) { if ( $alternative_color == '') $alternative_color = ' class="alternative_color moderate_blend" '; else $alternative_color = ' class="moderate_blend" '; } } else { if ( $alternative_color == '') $alternative_color = ' class="alternative_color" '; else $alternative_color = ''; } // debuge($bk);die; ?> >
"> ('; if (isset($_GET['booking_sort_order'])) { if ($_GET['booking_sort_order']=='name') $srt_url_tp='name_desc'; else $srt_url_tp='name'; } else $srt_url_tp='name'; echo $sort_url.$srt_url_tp.'">Name' . " " ; if ($_GET['booking_sort_order']=='name') { echo $arr_asc; } if ($_GET['booking_sort_order']=='name_desc') { echo $arr_desc; } if (isset($_GET['booking_sort_order'])) { if ($_GET['booking_sort_order']=='email') $srt_url_tp='email_desc'; else $srt_url_tp='email'; } else $srt_url_tp='email'; echo $sort_url.$srt_url_tp.'"> Email'. " " ; if ($_GET['booking_sort_order']=='email') { echo $arr_asc; } if ($_GET['booking_sort_order']=='email_desc') { echo $arr_desc; } // if (isset($_GET['booking_sort_order'])){ if ($_GET['booking_sort_order']=='visitors') $srt_url_tp='visitors_desc'; else $srt_url_tp='visitors';} // else $srt_url_tp='visitors'; // echo $sort_url.$srt_url_tp.'"> Visitor number' . " " ;if ($_GET['booking_sort_order']=='visitors') {echo $arr_asc;} if ($_GET['booking_sort_order']=='visitors_desc') {echo $arr_desc;} echo ")"; ?> ">
> /> style="text-align:center;" > >
style="text-align:center;" >
$bkdate) { $ad++; $date_class = ( date('m', mysql2date('U',$bkdate)) + 0 ) . '-' . ( date('d', mysql2date('U',$bkdate)) + 0 ) . '-' . ( date('Y', mysql2date('U',$bkdate)) + 0 ); ?> ">','#ff0000');" onmouseout="javascript:highlightDay('','');" >get_showing_date_format( mysql2date('U',$bkdate) );?>
'; // SHORT DAYS ECHO $sd = -1; foreach ($bk['short_days'] as $bkdate) { $sd++; //echo $bkdate; continue; if ((trim($bkdate) != ',') && (trim($bkdate) != '-')) { //eco date $date_class = ( date('m', mysql2date('U',$bkdate)) + 0 ) . '-' . ( date('d', mysql2date('U',$bkdate)) + 0 ) . '-' . ( date('Y', mysql2date('U',$bkdate)) + 0 ); echo '' . $this->get_showing_date_format( mysql2date('U',$bkdate) ) . ''; // These days belong to other resource make_bk_action('show_diferent_bk_resource_of_this_date', $bk['short_days_type_id'][$sd], $bk['booking_type'], $bk_type, $type_items, $outColorClass ); //echo apply_bk_filter('filter_subtype_num','',$bk['booking_type'], $bk['id'], $bkdate); echo ' '; } else { // echo separator echo ''.$bkdate.' ' ; } } ?>
style="text-align:center;" > ' . $type_items[ $bk['booking_type'] ] . ''; if( $this->wpdev_bk_pro !== false ) { ?> wpdev-booking-reservation&booking_type=&booking_hash=&parent_res=1";'>' /> ' /> wpdev_bk_pro !== false ) { ?> ").style.display=="block") document.getElementById("remark_row").style.display="none"; else document.getElementById("remark_row").style.display="block"; '>' /> ' /> "; make_bk_action('show_remark_editing_field',$bk['id'],$bk,"height:1px;padding:0px;margin:0px;border:none;"); ?>
0 ) $bk_type_additional = $bk_type .',' . implode(',', $additional_bk_types); else $bk_type_additional = $bk_type; global $wpdb; $dates_array = $time_array = array(); if ($approved == 'admin_blank') { $sql_req = "SELECT DISTINCT dt.booking_date FROM ".$wpdb->prefix ."bookingdates as dt INNER JOIN ".$wpdb->prefix ."booking as bk ON bk.booking_id = dt.booking_id WHERE dt.booking_date >= CURDATE() AND bk.booking_type IN ($bk_type_additional) AND bk.form like '%admin@blank.com%' ORDER BY dt.booking_date" ; $dates_approve = $wpdb->get_results( $sql_req ); }else { if ($approved == 'all') $sql_req = apply_bk_filter('get_bk_dates_sql', "SELECT DISTINCT dt.booking_date FROM ".$wpdb->prefix ."bookingdates as dt INNER JOIN ".$wpdb->prefix ."booking as bk ON bk.booking_id = dt.booking_id WHERE dt.booking_date >= CURDATE() AND bk.booking_type IN ($bk_type_additional) ORDER BY dt.booking_date", $bk_type_additional, 'all' ); else $sql_req = apply_bk_filter('get_bk_dates_sql', "SELECT DISTINCT dt.booking_date FROM ".$wpdb->prefix ."bookingdates as dt INNER JOIN ".$wpdb->prefix ."booking as bk ON bk.booking_id = dt.booking_id WHERE dt.approved = $approved AND dt.booking_date >= CURDATE() AND bk.booking_type IN ($bk_type_additional) ORDER BY dt.booking_date", $bk_type_additional, $approved ); $dates_approve = apply_bk_filter('get_bk_dates', $wpdb->get_results( $sql_req ), $approved, 0,$bk_type ); } //debuge($sql_req, $dates_approve); // loop with all dates which is selected by someone foreach ($dates_approve as $my_date) { $my_date = explode(' ',$my_date->booking_date); $my_dt = explode('-',$my_date[0]); $my_tm = explode(':',$my_date[1]); array_push( $dates_array , $my_dt ); array_push( $time_array , $my_tm ); } return array($dates_array,$time_array); // $dates_array; } // Generate booking CAPTCHA fields for booking form function createCapthaContent($bk_tp) { if ( get_bk_option( 'booking_is_use_captcha' ) !== 'On' ) return ''; else { $this->captcha_instance->cleanup(1); $word = $this->captcha_instance->generate_random_word(); $prefix = mt_rand(); $this->captcha_instance->generate_image($prefix, $word); $filename = $prefix . '.png'; $captcha_url = WPDEV_BK_PLUGIN_URL . '/js/captcha/tmp/' .$filename; $html = ''; $html .= 'captcha'; $ref = substr($filename, 0, strrpos($filename, '.')); $html = '' . $html . '
'; return $html; } } // Get default Booking resource function get_default_type() { if( $this->wpdev_bk_pro !== false ) { if (( isset( $_GET['booking_type'] ) ) && ($_GET['booking_type'] != '')) $bk_type = $_GET['booking_type']; else $bk_type = $this->wpdev_bk_pro->get_default_booking_resource_id(); } else $bk_type =1; return $bk_type; } //
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // A D M I N M E N U P A G E S //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // CONTENT OF THE ADMIN PAGE function content_of_booking_page () { $is_can = apply_bk_filter('multiuser_is_user_can_be_here', true, 'check_for_active_users'); if (! $is_can) return false; if ( ! isset($_GET['booking_sort_order']) ) { $booking_sort_order = get_bk_option( 'booking_sort_order'); $booking_sort_order_direction = get_bk_option( 'booking_sort_order_direction'); if ( $booking_sort_order == 'date') { $sort_type = 'date'; if( $booking_sort_order_direction == 'DESC') { $sort_type .= '_desc'; } } if ( $booking_sort_order == 'id') { $sort_type = 'id'; if( $booking_sort_order_direction == 'DESC') { $sort_type .= '_desc'; } } if ( $booking_sort_order == 'name') { $sort_type = 'name'; if( $booking_sort_order_direction == 'DESC') { $sort_type .= '_desc'; } } if ( $booking_sort_order == 'email') { $sort_type = 'email'; if( $booking_sort_order_direction == 'DESC') { $sort_type .= '_desc'; } } $_GET['booking_sort_order']=$sort_type; } if ( ! isset($_GET['booking_type']) ) { $default_booking_resource = get_bk_option( 'booking_default_booking_resource'); if ((isset($default_booking_resource)) && ($default_booking_resource !== false)) { $_GET['booking_type']= $default_booking_resource; //debuge($default_booking_resource); // Check if this resource parent and has some additional childs if so then assign to parent_res=1 make_bk_action('check_if_bk_res_parent_with_childs_set_parent_res', $default_booking_resource ); } } if ( isset($_GET['booking_type']) ) { $is_can = apply_bk_filter('multiuser_is_user_can_be_here', true, $_GET['booking_type']); if ( !$is_can) { return ; } } ?>
wpdev_bk_pro !== false ) $this->wpdev_bk_pro->booking_types_pages(); else { /* ?>
' .__('Standard', 'wpdev-booking') . ''; ?>
' . '+ ' .__('Add new booking resource', 'wpdev-booking') . ''; ?>
+ '.__('Add new booking resource', 'wpdev-booking').'
'; // echo ''; //echo '
'; } ?>
wpdev_bk_pro !== false )) { make_bk_action('show_all_bookings_at_one_page' ); return; } if ( ( isset( $_GET['parent_res'] ) ) && ($_GET['parent_res']=='1') && ( $this->get_version() == 'hotel' )) { make_bk_action('show_all_bookings_for_parent_resource', $_GET['booking_type'] ); return; } if ( ! isset( $_GET['booking_type'] ) ) if ( class_exists('wpdev_bk_multiuser')) { // If MultiUser so $bk_multiuser = apply_bk_filter('get_default_bk_resource_for_user',false); if ($bk_multiuser == false) return; } ?>
get_default_type(); make_bk_action('show_subtype_filter',$bk_type); ?>

booking_table(0); $user = wp_get_current_user(); $user_bk_id = $user->ID; ?>

'; printf(__('%sThere are no reservations.%s Please, press this %s button, when you edit %sposts%s or %spage%s. %sAfter entering booking you can wait for making reservation by somebody or you can make reservation %shere%s.', 'wpdev-booking'), '', '
', '', '', '', '', '', '
', '', '' ); echo '
'; } ?>
padding:2px 1px 2px 7px; text-shadow:-1px 1px 0 #FFFFFF;">

booking_table(1); ?>
show_footer_at_booking_page(); if( $this->wpdev_bk_pro == false ) $support_links = ''; else $support_links = ''; ?> '; echo '
'; echo ''; if( $this->wpdev_bk_pro !== false ) $this->wpdev_bk_pro->booking_types_pages('noedit'); echo '
'; $bk_type = $this->get_default_type(); if (isset($_GET['booking_type'])) { $is_can = apply_bk_filter('multiuser_is_user_can_be_here', true, $_GET['booking_type'] ); if ( !$is_can) { return ; } } echo '
'; do_action('wpdev_bk_add_form',$bk_type, get_bk_option( 'booking_client_cal_count')); ?>
'; } //content of S E T T I N G S page - actions runs function content_of_settings_page () { $is_can = apply_bk_filter('multiuser_is_user_can_be_here', true, 'check_for_active_users'); if (! $is_can) return false; make_bk_action('wpdev_booking_settings_top_menu'); ?>
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // S E T T I N G S S U P P O R T F U N C T I O N S //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Show top line menu function settings_menu_top_line() { $version = $this->get_version(); if (! isset($_GET['tab'])) $_GET['tab'] = ''; $selected_title = $_GET['tab']; $is_only_icons = ! true; if (! isset($_GET['tab'])) $_GET['tab'] = 'form'; if ($is_only_icons) echo ''; ?>
\n\ '.__('Features','wpdev-booking').' |\n\ '.__('Live Demos','wpdev-booking').' |\n\ '.__('FAQ','wpdev-booking').' |\n\ '.__('Contact','wpdev-booking').' |\n\ '.__('Buy','wpdev-booking').'\n\
'; else $support_links = ''; ?> get_version(); if ( strpos($_SERVER['HTTP_HOST'],'onlinebookingcalendar.com') !== FALSE ) $version = 'free'; if ( ! isset($_GET['tab']) ) { $is_can = apply_bk_filter('multiuser_is_user_can_be_here', true, 'only_super_admin'); if ($is_can) { $this->settings_general_content(); return; } else { // Multiuser first page for common user page $_GET['tab'] = 'form'; return; } } switch ($_GET['tab']) { case 'main': $this->settings_general_content(); return; break; case '': $this->settings_general_content(); return; break; case 'upgrade': if ( ( ($version !== 'free') && ($version !== 'hotel') ) || (($version === 'hotel') && (class_exists('wpdev_bk_hotel') === false) ) ) $this->showUpgradeWindow($version); break ; case 'buy': if ($version == 'free') $this->showBuyWidow(); break ; /*case 'faq' : ?>
...
wpdev_bk_pro !== false ) return; return $this->show_help(); } // Show window for upgrading function showUpgradeWindow($version) { if ( strpos($_SERVER['SCRIPT_FILENAME'],'onlinebookingcalendar.com') === FALSE ) { ?>
id="" class="gdrgrid postbox " >

Upgrade to Premium / Premium Plus / Hotel Edtion

You can make upgrade to the Booking Calendar Premium or Premium Plus or Hotel Edition:

Booking Calendar Premium features:

• Bookings for specific time in a day
Week booking or any other day range selection bookings
Online payment (PayPal and Sage payment support)
Payment requests Posibility to send payment requests to visitors
Cost editing Posibility to direct cost editing by administrator

Booking Calendar Premium Plus features:

Several booking forms Customization of fields for several forms
Season filter flexible definition of days
Availability. Set for each booking resource (un)avalaible days.
Rates. Set higher costs for peak season or discounts for specific days.
Additional costs. Set additional costs, which will depends from selection in dropdown lists or checkboxes.
Advanced costs. Set costs, which will depends from number of selected days for booking.

Booking Calendar Hotel Edition features:

Multiple booking at the same day. Day will be availbale untill all items (rooms) are not reserved.
"Capacity" of day depends from number of visitors Selection of visitor number will apply to the capacity of selected day(s).

Upgrade

Upgrade

Upgrade

12) $admin_cal_count = 12; if (1*$admin_cal_count< 1) $admin_cal_count = 1; update_bk_option( 'booking_admin_cal_count' , $admin_cal_count ); if (1*$client_cal_count>12) $client_cal_count = 12; if (1*$client_cal_count< 1) $client_cal_count = 1; update_bk_option( 'booking_client_cal_count' , $client_cal_count ); update_bk_option( 'booking_start_day_weeek' , $start_day_weeek ); update_bk_option( 'booking_title_after_reservation' , $new_booking_title ); update_bk_option( 'booking_title_after_reservation_time' , $new_booking_title_time ); update_bk_option( 'booking_type_of_thank_you_message' , $type_of_thank_you_message ); update_bk_option( 'booking_thank_you_page_URL' , $thank_you_page_URL ); update_bk_option( 'booking_date_format' , $booking_date_format ); update_bk_option( 'booking_date_view_type' , $booking_date_view_type); // if (isset( $is_dif_colors_approval_pending )) $is_dif_colors_approval_pending = 'On'; // else $is_dif_colors_approval_pending = 'Off'; // update_bk_option( 'booking_dif_colors_approval_pending' , $is_dif_colors_approval_pending ); if (isset( $is_use_hints_at_admin_panel )) $is_use_hints_at_admin_panel = 'On'; else $is_use_hints_at_admin_panel = 'Off'; update_bk_option( 'booking_is_use_hints_at_admin_panel' , $is_use_hints_at_admin_panel ); if (isset( $multiple_day_selections )) $multiple_day_selections = 'On'; else $multiple_day_selections = 'Off'; update_bk_option( 'booking_multiple_day_selections' , $multiple_day_selections ); //////////////////////////////////////////////////////////////////////////////////////////////////////////// if (isset( $unavailable_day0 )) $unavailable_day0 = 'On'; else $unavailable_day0 = 'Off'; update_bk_option( 'booking_unavailable_day0' , $unavailable_day0 ); if (isset( $unavailable_day1 )) $unavailable_day1 = 'On'; else $unavailable_day1 = 'Off'; update_bk_option( 'booking_unavailable_day1' , $unavailable_day1 ); if (isset( $unavailable_day2 )) $unavailable_day2 = 'On'; else $unavailable_day2 = 'Off'; update_bk_option( 'booking_unavailable_day2' , $unavailable_day2 ); if (isset( $unavailable_day3 )) $unavailable_day3 = 'On'; else $unavailable_day3 = 'Off'; update_bk_option( 'booking_unavailable_day3' , $unavailable_day3 ); if (isset( $unavailable_day4 )) $unavailable_day4 = 'On'; else $unavailable_day4 = 'Off'; update_bk_option( 'booking_unavailable_day4' , $unavailable_day4 ); if (isset( $unavailable_day5 )) $unavailable_day5 = 'On'; else $unavailable_day5 = 'Off'; update_bk_option( 'booking_unavailable_day5' , $unavailable_day5 ); if (isset( $unavailable_day6 )) $unavailable_day6 = 'On'; else $unavailable_day6 = 'Off'; update_bk_option( 'booking_unavailable_day6' , $unavailable_day6 ); //////////////////////////////////////////////////////////////////////////////////////////////////////////// if (isset( $is_delete_if_deactive )) $is_delete_if_deactive = 'On'; else $is_delete_if_deactive = 'Off'; update_bk_option( 'booking_is_delete_if_deactive' , $is_delete_if_deactive ); if (isset( $wpdev_copyright )) $wpdev_copyright = 'On'; else $wpdev_copyright = 'Off'; update_bk_option( 'booking_wpdev_copyright' , $wpdev_copyright ); //////////////////////////////////////////////////////////////////////////////////////////////////////////// if (isset( $is_use_captcha )) $is_use_captcha = 'On'; else $is_use_captcha = 'Off'; update_bk_option( 'booking_is_use_captcha' , $is_use_captcha ); if (isset( $is_show_legend )) $is_show_legend = 'On'; else $is_show_legend = 'Off'; update_bk_option( 'booking_is_show_legend' , $is_show_legend ); } else { $booking_skin = get_bk_option( 'booking_skin'); $email_reservation_adress = get_bk_option( 'booking_email_reservation_adress') ; $max_monthes_in_calendar = get_bk_option( 'booking_max_monthes_in_calendar' ); $booking_sort_order = get_bk_option( 'booking_sort_order'); $booking_sort_order_direction = get_bk_option( 'booking_sort_order_direction'); $admin_cal_count = get_bk_option( 'booking_admin_cal_count' ); $new_booking_title= get_bk_option( 'booking_title_after_reservation' ); $new_booking_title_time= get_bk_option( 'booking_title_after_reservation_time' ); $type_of_thank_you_message = get_bk_option( 'booking_type_of_thank_you_message' ); //= 'message'; = 'page'; $thank_you_page_URL = get_bk_option( 'booking_thank_you_page_URL' ); //= 'message'; = 'page'; $booking_date_format = get_bk_option( 'booking_date_format'); $booking_date_view_type = get_bk_option( 'booking_date_view_type'); $client_cal_count = get_bk_option( 'booking_client_cal_count' ); $start_day_weeek = get_bk_option( 'booking_start_day_weeek' ); // $is_dif_colors_approval_pending = get_bk_option( 'booking_dif_colors_approval_pending' ); $is_use_hints_at_admin_panel = get_bk_option( 'booking_is_use_hints_at_admin_panel' ); $multiple_day_selections = get_bk_option( 'booking_multiple_day_selections' ); $is_delete_if_deactive = get_bk_option( 'booking_is_delete_if_deactive' ); // check $wpdev_copyright = get_bk_option( 'booking_wpdev_copyright' ); // check $is_use_captcha = get_bk_option( 'booking_is_use_captcha' ); // check $is_show_legend = get_bk_option( 'booking_is_show_legend' ); // check $unavailable_day0 = get_bk_option( 'booking_unavailable_day0' ); $unavailable_day1 = get_bk_option( 'booking_unavailable_day1' ); $unavailable_day2 = get_bk_option( 'booking_unavailable_day2' ); $unavailable_day3 = get_bk_option( 'booking_unavailable_day3' ); $unavailable_day4 = get_bk_option( 'booking_unavailable_day4' ); $unavailable_day5 = get_bk_option( 'booking_unavailable_day5' ); $unavailable_day6 = get_bk_option( 'booking_unavailable_day6' ); $user_role_booking = get_bk_option( 'booking_user_role_booking' ); $user_role_addbooking = get_bk_option( 'booking_user_role_addbooking' ); $user_role_settings = get_bk_option( 'booking_user_role_settings' ); } if (empty($type_of_thank_you_message)) $type_of_thank_you_message = 'message'; ?>
id="" class="postbox " >


','');?>

value="" name="is_use_hints_at_admin_panel"/>
value="" name="wpdev_copyright"/>
id="" class="postbox " >

dirList( array( '/css/skins/', '/include/skins/' ) ); ?>

value="" name="multiple_day_selections"/>
+
id="" class="postbox " >


value="" name="is_use_captcha"/>

value="" name="is_show_legend"/>
+
id="" class="postbox " >

"; echo " ' . date_i18n( $format ) . "    \n"; } echo '
'; echo '';?> ','');?>
show_help(); ?>
get_version(); if ( strpos($_SERVER['HTTP_HOST'],'onlinebookingcalendar.com') !== FALSE ) $version = 'free'; if ($version == 'free') $this->showBuyWidow(); if ( ($version !== 'free') && ($version!== 'hotel') ) { $this->showUpgradeWindow($version); } ?>
id="" class="gdrgrid postbox " >

:

Booking Calendar

id="" class="gdrgrid postbox " >

id="" class="postbox " >

+
id="" class="postbox " >


value="" name="is_delete_if_deactive"/>

Professional / Premium / Premium + / Hotel Ed. versions

:
()
()
()
()
()
()
()
()
()
()
()
()
()
()
$119
link
get_version(); if (( ! isset($_GET['tab']) ) || (empty($_GET['tab'])) ) $tab = 'main'; else $tab = $_GET['tab'] ; if ( ($version == 'free') && ($tab != 'buy') ){ echo '
'; ?>

','', '','','','','',''); ?>

','','','', '',''); ?>

','' , '',''); ?>

','' , '',''); ?>

','','','','','','','','',''); ?>

', '', '', '', '', '' ); ?>

Features:

  • Creation of sites, where can be several property owners (users) at the same time. Each owner will see only his booking resources and bookings. Posibility to make independent customization of forms fields, emails, payments and so on for each owner.
  • Posibility to Activate and Deactivate wordpress users for using Booking system
  • Independent, seperate configuration of form fields for each active non super booking admin user
  • Independent, seperate configuration of email templates for each active non super booking admin user
  • Independent, seperate configuration of costs and payments options for each active non super booking admin user
  • Independent, seperate configuration of rates, advanced cost management and season availability for each active non super booking admin user

Features:

  • Flexible configuration of booking form fields, for showing at client side
       [Premium, Premium Plus and Hotel Edition versions support fields for entering or selection time of booking]
  • Configuration of "content" data, which is showen at emails and pending and approved tables at this page

Features. Flexible configuration of email templates:

  • Email template for sending to admin after new reservation is done [ Support: Professional, Premium, Premium Plus and Hotel Edition versions]
  • Email template for sending to person after new reservation is done [ Support: Professional, Premium, Premium Plus and Hotel Edition versions]
  • Email template for sending to person after approval of booking [ Support: Professional, Premium, Premium Plus and Hotel Edition versions]
  • Email template for sending to person after cancellation of booking [ Support: Professional, Premium, Premium Plus and Hotel Edition versions]
  • Email template for sending to person after modification of booking [ Support: Professional, Premium, Premium Plus and Hotel Edition versions]
  • Email template for sending payment request to person [ Support: Premium, Premium Plus and Hotel Edition versions]

Features.

  • Setting cost (per day/per night/fixed) for each booking resource [ Support: Premium, Premium Plus and Hotel Edition versions]
  • Configuration of Paypal and Sage payment system [ Support: Premium, Premium Plus and Hotel Edition versions]
  • Configuration of additional cost, which is depended from selection at selectboxes or checkboxes. [ Support: Premium Plus and Hotel Edition versions]

Features.

  • Configuration of dates availability, based on season filter settings. [ Support: Premium Plus and Hotel Edition versions]
  • Configuration of rates (diferent costs), based on season filter settings. [ Support: Premium Plus and Hotel Edition versions]
  • Configuration of cost, which is depends from number of selected days for booking. [ Support: Premium Plus and Hotel Edition versions]

  • Coupon discount systems - a way to have discounts. Customers can enter a promo code and they get some discounts [ Support: Hotel Edition version]

Features.

  • Configuration of capacity, for booking resources. Several bookings at the same day, even at the same time for same booking resource. [ Hotel Edition only !]

Features.

  • Configuration of season filter, which is used at the rates and availability systems. [ Support: Premium Plus and Hotel Edition versions]

Features.

  • Setting URL for booking editing or cancellation by visitor [ Support: Professional, Premium, Premium Plus and Hotel Edition versions]
  • Setting default booking resource for auto open at booking page [ Support: Professional, Premium, Premium Plus and Hotel Edition versions]

  • Setting time format [ Support: Premium, Premium Plus and Hotel Edition versions]
  • Setting range selections (week selections or any other number of days)[ Support: Premium, Premium Plus and Hotel Edition versions]
  • Setting fixed time for booking form [ Support: Premium, Premium Plus and Hotel Edition versions]

  • Showing day cost at calendar [ Support: Premium Plus and Hotel Edition versions]

  • Showing availability (capacity) of days at calendar [ Support: Hotel Edition version]
  • Setting capacity dependence from number of visitors selection at booking form [ Support: Hotel Edition version]
'; ?>
// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // S I D E B A R W I D G E T ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Add widjet controlls function booking_widget_control() { if (isset($_POST['booking_widget_title'] )) { update_bk_option( 'booking_widget_title', htmlspecialchars($_POST['booking_widget_title'])); update_bk_option( 'booking_widget_show', $_POST['booking_widget_show']); if( $this->wpdev_bk_pro !== false ) { update_bk_option( 'booking_widget_type', $_POST['booking_widget_type']); } update_bk_option( 'booking_widget_calendar_count', $_POST['booking_widget_calendar_count']); $booking_widget_last_field = htmlspecialchars($_POST['booking_widget_last_field']); $booking_widget_last_field = str_replace('\"', "'" , $booking_widget_last_field); $booking_widget_last_field = str_replace("\'", "'" , $booking_widget_last_field); update_bk_option( 'booking_widget_last_field', $booking_widget_last_field ); } $booking_widget_title = get_bk_option( 'booking_widget_title'); $booking_widget_show = get_bk_option( 'booking_widget_show'); if( $this->wpdev_bk_pro !== false ) { $booking_widget_type = get_bk_option( 'booking_widget_type'); } else $booking_widget_type=1; $booking_widget_calendar_count = get_bk_option( 'booking_widget_calendar_count'); $booking_widget_last_field = get_bk_option( 'booking_widget_last_field'); ?>



wpdev_bk_pro !== false ) { $types_list = $this->wpdev_bk_pro->get_booking_types(); //debuge($types_list); ?>





','
'); ?>

'widget_wpdev_booking', 'description' => __( "Display Booking.", 'wpdev-booking') ); wp_register_sidebar_widget('wpdev_booking_widget', __('Booking', 'wpdev-booking'), 'show_booking_widget_php4', $widget_options); wp_register_widget_control('wpdev_booking_widget', __('Booking settings', 'wpdev-booking'), array(&$this, 'booking_widget_control') ); } //
// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // J S & C S S F I L E S & V a r i a b l e s ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // add hook for printing scripts only at this plugin page function on_add_admin_js_files() { // Write inline scripts and CSS at HEAD add_action('admin_head', array(&$this, 'head_print_js_css_admin' ), 1); } // HEAD for ADMIN page function head_print_js_css_admin() { $this->print_js_css(1); } // Head of Client side - including JS Ajax function function client_side_print_booking_head() { // Write calendars script $this->print_js_css(0); } // Write copyright notice if its saved function wp_footer() { if ( ( get_bk_option( 'booking_wpdev_copyright' ) == 'On' ) && (! defined('WPDEV_COPYRIGHT')) ) { printf(__('%sPowered by wordpress plugins developed by %s', 'wpdev-booking'),'','www.wpdevelop.com','&'); define('WPDEV_COPYRIGHT', 1 ); } } //JS at footer in Admin Panel - Booking page function print_js_at_footer() { if ( ( strpos($_SERVER['REQUEST_URI'],'wpdev-booking.phpwpdev-booking')!==false) && ( strpos($_SERVER['REQUEST_URI'],'wpdev-booking.phpwpdev-booking-reservation')===false ) ) { $additional_bk_types = array(); $bk_resources = array(array('id'=>$this->get_default_type())); if (isset($_GET['booking_type'])) if ($_GET['booking_type']=='-1') if( $this->wpdev_bk_pro !== false ) $bk_resources = $this->wpdev_bk_pro->get_booking_types(); if (isset($_GET['parent_res'])) if (($_GET['parent_res']=='1') && ( $this->get_version() == 'hotel' )) { $bk_resources = apply_bk_filter('get_bk_resources_in_hotel' ); } foreach ($bk_resources as $value) { if (gettype($value) == 'array') $bk_type = $value['id']; else $bk_type = $value->id; if ( strpos($bk_type,';') !== false ) { $additional_bk_types = explode(';',$bk_type); $bk_type = $additional_bk_types[0]; } // $bk_type = $this->get_default_type(); // Previos value $my_boook_type = $bk_type ; $start_script_code = ""; $start_script_code = apply_filters('wpdev_booking_calendar', $start_script_code , $my_boook_type); echo $start_script_code; } //TODO: HERE_EDITED } $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) ) { ?> // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // C L I E N T S I D E & H O O K S //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Get scripts for calendar activation function get_script_for_calendar($bk_type, $additional_bk_types, $my_selected_dates_without_calendar, $my_boook_count ){ $my_boook_type = $bk_type; $start_script_code = ""; //$start_script_code .= ""; return $start_script_code; } // Get code of the legend here function get_legend(){ $my_result = ''; if (get_bk_option( 'booking_is_show_legend' ) == 'On') { //TODO: check here according legend $my_result .= '
'; $my_result .= '
- '.__('Available','wpdev-booking') .'
'; $my_result .= '
#
- '.__('Booked','wpdev-booking') .'
'; $my_result .= '
#
- '.__('Pending','wpdev-booking') .'
'; if ($this->wpdev_bk_pro !== false) if ($this->wpdev_bk_pro->wpdev_bk_premium !== false) $my_result .= '
#
- '.__('Partially booked','wpdev-booking') .'
'; $my_result .= '
'; } return $my_result; } // Get form function get_booking_form($my_boook_type) { $my_form = '

'.__('First Name (required)', 'wpdev-booking').':

'.__('Last Name (required)', 'wpdev-booking').':

'.__('Email (required)', 'wpdev-booking').':

'.__('Phone', 'wpdev-booking').':

'.__('Details', 'wpdev-booking').':

'; $my_form .= '

[captcha]

'; $my_form .= '

'; return $my_form; } // Get booking form function get_booking_form_action($my_boook_type=1,$my_boook_count=1, $my_booking_form = 'standard') { $res = $this->add_booking_form_action($my_boook_type,$my_boook_count, 0, $my_booking_form ); return $res; } //Show booking form from action call - wpdev_bk_add_form function add_booking_form_action($bk_type =1, $cal_count =1, $is_echo = 1, $my_booking_form = 'standard', $my_selected_dates_without_calendar = '') { $is_booking_resource_exist = apply_bk_filter('wpdev_is_booking_resource_exist',true, $bk_type, $is_echo ); if (! $is_booking_resource_exist) { if ( $is_echo ) echo ''; return ''; } make_bk_action('check_multiuser_params_for_client_side', $bk_type ); $additional_bk_types = array(); if ( strpos($bk_type,';') !== false ) { $additional_bk_types = explode(';',$bk_type); $bk_type = $additional_bk_types[0]; } if (isset($_GET['booking_hash'])) { $my_booking_id_type = apply_bk_filter('wpdev_booking_get_hash_to_id',false, $_GET['booking_hash'] ); if ($my_booking_id_type != false) if ($my_booking_id_type[1]=='') { $my_result = __('Wrong booking hash in URL. Probably its expired.','wpdev-booking'); if ( $is_echo ) echo $my_result; else return $my_result; return; } } if ($bk_type == '') { $my_result = __('Booking resource type is not defined. Its can be, when at the URL is wrong booking hash.','wpdev-booking'); if ( $is_echo ) echo $my_result; else return $my_result; return; } $start_script_code = $this->get_script_for_calendar($bk_type, $additional_bk_types, $my_selected_dates_without_calendar, $cal_count ); $my_result = ' ' . $this->get__client_side_booking_content($bk_type, $my_booking_form, $my_selected_dates_without_calendar ) . ' ' . $start_script_code ; $my_result = apply_filters('wpdev_booking_form', $my_result , $bk_type); make_bk_action('finish_check_multiuser_params_for_client_side', $bk_type ); if ( $is_echo ) echo $my_result; else return $my_result; } //Show only calendar from action call - wpdev_bk_add_calendar function add_calendar_action($bk_type =1, $cal_count =1, $is_echo = 1) { make_bk_action('check_multiuser_params_for_client_side', $bk_type ); $additional_bk_types = array(); if ( strpos($bk_type,';') !== false ) { $additional_bk_types = explode(';',$bk_type); $bk_type = $additional_bk_types[0]; } if (isset($_GET['booking_hash'])) { $my_booking_id_type = apply_bk_filter('wpdev_booking_get_hash_to_id',false, $_GET['booking_hash'] ); if ($my_booking_id_type != false) if ($my_booking_id_type[1]=='') { $my_result = __('Wrong booking hash in URL. Probably its expired.','wpdev-booking'); if ( $is_echo ) echo $my_result; else return $my_result; return; } } $start_script_code = $this->get_script_for_calendar($bk_type, $additional_bk_types, '' , $cal_count ); $my_result = '
' . '
 
' ; $my_result .= $this->get_legend(); // Get Legend code here $my_result .= ' ' . $start_script_code ; $my_result = apply_filters('wpdev_booking_calendar', $my_result , $bk_type); make_bk_action('finish_check_multiuser_params_for_client_side', $bk_type ); if ( $is_echo ) echo $my_result; else return $my_result; } // Get content at client side of C A L E N D A R function get__client_side_booking_content($my_boook_type = 1 , $my_booking_form = 'standard', $my_selected_dates_without_calendar = '') { $nl = '
'; // New line if ($my_selected_dates_without_calendar=='') { $calendar = '
 
'; if( $this->wpdev_bk_pro == false ) $calendar .= '
Powered by Booking Calendar
'; $calendar .= ''; // Calendar code } else { $calendar = ''; $calendar .= ''; // Calendar code } $calendar .= $this->get_legend(); // Get Legend code here $form = '
'; if( $this->wpdev_bk_pro !== false ) $form .= $this->wpdev_bk_pro->get_booking_form($my_boook_type, $my_booking_form); // Get booking form else $form .= $this->get_booking_form($my_boook_type); // Insert calendar into form if ( strpos($form, '[calendar]') !== false ) $form = str_replace('[calendar]', $calendar ,$form); else $form = $calendar . $nl . $form ; $form = apply_bk_filter('wpdev_check_for_additional_calendars_in_form', $form, $my_boook_type ); if ( strpos($form, '[captcha]') !== false ) { $captcha = $this->createCapthaContent($my_boook_type); $form =str_replace('[captcha]', $captcha ,$form); } $form = apply_filters('wpdev_booking_form_content', $form , $my_boook_type); // Add booking type field $form .= '
'; $submitting = '
'; $res = $form . $submitting; $my_random_id = time() * rand(0,1000); $my_random_id = 'form_id'. $my_random_id; //name="booking_form'.$my_boook_type.'" $return_form = '
' . $res . '
'; if ($my_selected_dates_without_calendar == '' ) { // Check according already shown Booking Calendar and set do not visible of it $return_form .= ''; } return $return_form; } //
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // S H O R T C O D E S //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Replace MARK at post with content at client side ----- [booking nummonths='1' type='1'] function booking_shortcode($attr) { if (isset($_GET['booking_hash'])) return __('You need to use special shortcode [bookingedit] for booking editing.','wpdev-booking'); $my_boook_count = get_bk_option( 'booking_client_cal_count' ); $my_boook_type = 1; $my_booking_form = 'standard'; if ( isset( $attr['nummonths'] ) ) { $my_boook_count = $attr['nummonths']; } if ( isset( $attr['type'] ) ) { $my_boook_type = $attr['type']; } if ( isset( $attr['form_type'] ) ) { $my_booking_form = $attr['form_type']; } if ( isset( $attr['agregate'] ) ) { $additional_bk_types = $attr['agregate']; $my_boook_type .= ';'.$additional_bk_types; } $res = $this->add_booking_form_action($my_boook_type,$my_boook_count, 0 , $my_booking_form ); return $res; } // Replace MARK at post with content at client side ----- [booking nummonths='1' type='1'] function booking_calendar_only_shortcode($attr) { $my_boook_count = get_bk_option( 'booking_client_cal_count' ); $my_boook_type = 1; if ( isset( $attr['nummonths'] ) ) { $my_boook_count = $attr['nummonths']; } if ( isset( $attr['type'] ) ) { $my_boook_type = $attr['type']; } if ( isset( $attr['agregate'] ) ) { $additional_bk_types = $attr['agregate']; $my_boook_type .= ';'.$additional_bk_types; } $res = $this->add_calendar_action($my_boook_type,$my_boook_count, 0 ); return $res; } // Show only booking form, with already selected dates function bookingform_shortcode($attr) { $my_boook_type = 1; $my_booking_form = 'standard'; $my_boook_count = 1; $my_selected_dates_without_calendar = ''; if ( isset( $attr['type'] ) ) { $my_boook_type = $attr['type']; } if ( isset( $attr['form_type'] ) ) { $my_booking_form = $attr['form_type']; } if ( isset( $attr['selected_dates'] ) ) { $my_selected_dates_without_calendar = $attr['selected_dates']; } //$my_selected_dates_without_calendar = '20.08.2010, 29.08.2010'; $res = $this->add_booking_form_action($my_boook_type,$my_boook_count, 0 , $my_booking_form, $my_selected_dates_without_calendar ); return $res; } // Show booking form for editing function bookingedit_shortcode($attr) { $my_boook_count = get_bk_option( 'booking_client_cal_count' ); $my_boook_type = 1; $my_booking_form = 'standard'; if ( isset( $attr['nummonths'] ) ) { $my_boook_count = $attr['nummonths']; } if ( isset( $attr['type'] ) ) { $my_boook_type = $attr['type']; } if ( isset( $attr['form_type'] ) ) { $my_booking_form = $attr['form_type']; } if (isset($_GET['booking_hash'])) { $my_booking_id_type = apply_bk_filter('wpdev_booking_get_hash_to_id',false, $_GET['booking_hash'] ); if ($my_booking_id_type !== false) { $my_edited_bk_id = $my_booking_id_type[0]; $my_boook_type = $my_booking_id_type[1]; if ($my_boook_type == '') return __('Wrong booking hash in URL. Probably hash is expired.','wpdev-booking'); } else { return __('Wrong booking hash in URL. Probably hash is expired.','wpdev-booking'); } } else { return __('You do not set any parameters for booking editing','wpdev-booking'); } $res = $this->add_booking_form_action($my_boook_type,$my_boook_count, 0 , $my_booking_form ); if (isset($_GET['booking_pay'])) { // Payment form $res .= apply_bk_filter('wpdev_get_payment_form',$my_edited_bk_id, $my_boook_type ); } return $res; } // // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// A C T I V A T I O N A N D D E A C T I V A T I O N O F T H I S P L U G I N //////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Activate function wpdev_booking_activate() { if ( strpos($_SERVER['HTTP_HOST'],'onlinebookingcalendar.com') !== FALSE ) add_bk_option( 'booking_admin_cal_count' ,'3'); else add_bk_option( 'booking_admin_cal_count' ,'2'); add_bk_option( 'booking_skin', WPDEV_BK_PLUGIN_URL . '/css/skins/traditional.css'); add_bk_option( 'booking_sort_order','id'); add_bk_option( 'booking_sort_order_direction', 'ASC'); add_bk_option( 'booking_max_monthes_in_calendar', '1y'); add_bk_option( 'booking_client_cal_count', '1' ); add_bk_option( 'booking_start_day_weeek' ,'0'); add_bk_option( 'booking_title_after_reservation' , sprintf(__('Thank you for your online reservation. %s We will send confirmation of your booking as soon as possible.', 'wpdev-booking'), '
') ); add_bk_option( 'booking_title_after_reservation_time' , '7000' ); add_bk_option( 'booking_type_of_thank_you_message' , 'message' ); add_bk_option( 'booking_thank_you_page_URL' , get_option('siteurl') ); add_bk_option( 'booking_date_format' , get_option('date_format') ); add_bk_option( 'booking_date_view_type', 'short'); // short / wide if ( strpos($_SERVER['HTTP_HOST'],'onlinebookingcalendar.com') !== FALSE ) add_bk_option( 'booking_is_delete_if_deactive' ,'On'); // check else add_bk_option( 'booking_is_delete_if_deactive' ,'Off'); // check add_bk_option( 'booking_dif_colors_approval_pending' , 'On' ); add_bk_option( 'booking_is_use_hints_at_admin_panel' , 'On' ); add_bk_option( 'booking_multiple_day_selections' , 'On'); add_bk_option( 'booking_unavailable_day0' ,'Off'); add_bk_option( 'booking_unavailable_day1' ,'Off'); add_bk_option( 'booking_unavailable_day2' ,'Off'); add_bk_option( 'booking_unavailable_day3' ,'Off'); add_bk_option( 'booking_unavailable_day4' ,'Off'); add_bk_option( 'booking_unavailable_day5' ,'Off'); add_bk_option( 'booking_unavailable_day6' ,'Off'); if ( ( strpos($_SERVER['SCRIPT_FILENAME'],'onlinebookingcalendar.com') !== FALSE ) || ( strpos($_SERVER['HTTP_HOST'],'onlinebookingcalendar.com') !== FALSE ) ) { add_bk_option( 'booking_user_role_booking', 'subscriber' ); add_bk_option( 'booking_user_role_addbooking', 'subscriber' ); add_bk_option( 'booking_user_role_settings', 'subscriber' ); } else { add_bk_option( 'booking_user_role_booking', 'editor' ); add_bk_option( 'booking_user_role_addbooking', 'editor' ); add_bk_option( 'booking_user_role_settings', 'administrator' ); } $blg_title = get_option('blogname'); $blg_title = str_replace('"', '', $blg_title); $blg_title = str_replace("'", '', $blg_title); add_bk_option( 'booking_email_reservation_adress', htmlspecialchars('"Booking system" <' .get_option('admin_email').'>')); add_bk_option( 'booking_email_reservation_from_adress', htmlspecialchars('"Booking system" <' .get_option('admin_email').'>')); add_bk_option( 'booking_email_reservation_subject',__('New reservation', 'wpdev-booking')); add_bk_option( 'booking_email_reservation_content',htmlspecialchars(sprintf(__('You need to approve new reservation %s for: %s Person detail information:%s Currently new booking is waiting for approval. Please visit the moderation panel%sThank you, %s', 'wpdev-booking'),'[bookingtype]','[dates]

','
[content]

',' [moderatelink]

',$blg_title.'
[siteurl]'))); add_bk_option( 'booking_email_approval_adress',htmlspecialchars('"Booking system" <' .get_option('admin_email').'>')); add_bk_option( 'booking_email_approval_subject',__('Your reservation has been approved', 'wpdev-booking')); if( $this->wpdev_bk_pro !== false ) add_bk_option( 'booking_email_approval_content',htmlspecialchars(sprintf(__('Your reservation %s for: %s has been approved.%sYou can edit this booking at this page: %s Thank you, %s', 'wpdev-booking'),'[bookingtype]','[dates]','

[content]

', '[visitorbookingediturl]

' , $blg_title.'
[siteurl]'))); else add_bk_option( 'booking_email_approval_content',htmlspecialchars(sprintf(__('Your reservation %s for: %s has been approved.%sThank you, %s', 'wpdev-booking'),'[bookingtype]','[dates]','

[content]

',$blg_title.'
[siteurl]'))); add_bk_option( 'booking_email_deny_adress',htmlspecialchars('"Booking system" <' .get_option('admin_email').'>')); add_bk_option( 'booking_email_deny_subject',__('Your reservation has been declined', 'wpdev-booking')); add_bk_option( 'booking_email_deny_content',htmlspecialchars(sprintf(__('Your reservation %s for: %s has been canceled. %sThank you, %s', 'wpdev-booking'),'[bookingtype]','[dates]','

[denyreason]

[content]

',$blg_title.'
[siteurl]'))); add_bk_option( 'booking_is_email_reservation_adress', 'On' ); add_bk_option( 'booking_is_email_approval_adress', 'On' ); add_bk_option( 'booking_is_email_deny_adress', 'On' ); add_bk_option( 'booking_widget_title', __('Booking form', 'wpdev-booking') ); add_bk_option( 'booking_widget_show', 'booking_form' ); add_bk_option( 'booking_widget_type', '1' ); add_bk_option( 'booking_widget_calendar_count', '1'); add_bk_option( 'booking_widget_last_field',''); add_bk_option( 'booking_wpdev_copyright','Off' ); add_bk_option( 'booking_is_use_captcha' , 'Off' ); add_bk_option( 'booking_is_show_legend' , 'Off' ); // Create here tables which is needed for using plugin global $wpdb; $charset_collate = ''; //if ( $wpdb->has_cap( 'collation' ) ) { if ( ! empty($wpdb->charset) ) $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; if ( ! empty($wpdb->collate) ) $charset_collate .= " COLLATE $wpdb->collate"; //} $wp_queries = array(); if ( ! $this->is_table_exists('booking') ) { // Cehck if tables not exist yet $simple_sql = "CREATE TABLE ".$wpdb->prefix ."booking ( booking_id bigint(20) unsigned NOT NULL auto_increment, form text , booking_type bigint(10) NOT NULL default 1, PRIMARY KEY (booking_id) ) $charset_collate;"; $wpdb->query($simple_sql); } elseif ($this->is_field_in_table_exists('booking','form') == 0) { $wp_queries[] = "ALTER TABLE ".$wpdb->prefix ."booking ADD form TEXT AFTER booking_id"; //$wpdb->query($simple_sql); } if ($this->is_field_in_table_exists('booking','modification_date') == 0) { $wp_queries[] = "ALTER TABLE ".$wpdb->prefix ."booking ADD modification_date datetime AFTER booking_id"; //$wpdb->query($simple_sql); } if ( ! $this->is_table_exists('bookingdates') ) { // Cehck if tables not exist yet $simple_sql = "CREATE TABLE ".$wpdb->prefix ."bookingdates ( booking_id bigint(20) unsigned NOT NULL, booking_date datetime NOT NULL default '0000-00-00 00:00:00', approved bigint(20) unsigned NOT NULL default 0 ) $charset_collate;"; $wpdb->query($simple_sql); if( $this->wpdev_bk_pro == false ) { $wp_queries[] = "INSERT INTO ".$wpdb->prefix ."booking ( form ) VALUES ( 'text^name1^Jony~text^secondname1^Smith~text^email1^example-free@wpdevelop.com~text^phone1^8(038)458-77-77~textarea^details1^Reserve a room with sea view' );"; } } if (count($wp_queries)>0) { foreach ($wp_queries as $wp_q) $wpdb->query($wp_q); if( $this->wpdev_bk_pro == false ) { $temp_id = $wpdb->insert_id; $wp_queries_sub = "INSERT INTO ".$wpdb->prefix ."bookingdates ( booking_id, booking_date ) VALUES ( ". $temp_id .", CURDATE()+ INTERVAL 2 day ), ( ". $temp_id .", CURDATE()+ INTERVAL 3 day ), ( ". $temp_id .", CURDATE()+ INTERVAL 4 day );"; $wpdb->query($wp_queries_sub); } } // if( $this->wpdev_bk_pro !== false ) $this->wpdev_bk_pro->pro_activate(); make_bk_action('wpdev_booking_activation'); //$this->setDefaultInitialValues(); } // Deactivate function wpdev_booking_deactivate() { $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_skin'); delete_bk_option( 'booking_sort_order'); delete_bk_option( 'booking_sort_order_direction'); 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' , get_option('siteurl') ); 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' ); // check delete_bk_option( 'booking_is_use_captcha' ); delete_bk_option( 'booking_is_show_legend' ); delete_bk_option( 'booking_dif_colors_approval_pending' ); delete_bk_option( 'booking_is_use_hints_at_admin_panel' ); delete_bk_option( 'booking_multiple_day_selections' ); 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_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_win_%'") ) { // Only WIN 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 ( ( strpos($_SERVER['SCRIPT_FILENAME'],'onlinebookingcalendar.com') !== FALSE ) || ( strpos($_SERVER['HTTP_HOST'],'onlinebookingcalendar.com') !== FALSE ) ) { // 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 setDefaultInitialValues($evry_one = 1) { global $wpdb; $names = array( 'Jacob', 'Michael', 'Daniel', 'Anthony', 'William', 'Emma', 'Sophia', 'Kamila', 'Isabella', 'Jack', 'Daniel', 'Matthew', 'Olivia', 'Emily', 'Grace', 'Jessica', 'Joshua', 'Harry', 'Thomas', 'Oliver', 'Jack' ); $second_names = array( 'Smith', 'Johnson', 'Widams', 'Brown', 'Jones', 'Miller', 'Davis', 'Garcia', 'Rodriguez', 'Wilyson', 'Gonzalez', 'Gomez', 'Taylor', 'Bron', 'Wilson', 'Davies', 'Robinson', 'Evans', 'Walker', 'Jackson', 'Clarke' ); $city = array( 'New York', 'Los Angeles', 'Chicago', 'Houston', 'Phoenix', 'San Antonio', 'San Diego', 'San Jose', 'Detroit', 'San Francisco', 'Jacksonville', 'Austin', 'London', 'Birmingham', 'Leeds', 'Glasgow', 'Sheffield', 'Bradford', 'Edinburgh', 'Liverpool', 'Manchester' ); $adress = array( '30 Mortensen Avenue', '144 Hitchcock Rd', '222 Lincoln Ave', '200 Lincoln Ave', '65 West Alisal St', '426 Work St', '65 West Alisal Street', '159 Main St', '305 Jonoton Avenue', '423 Caiptown Rd', '34 Linoro Ave', '50 Voro Ave', '15 East St', '226 Middle St', '35 West Town Street', '59 Other St', '50 Merci Ave', '15 Dolof St', '226 Gordon St', '35 Sero Street', '59 Exit St' ); $country = array( 'US' ,'US' ,'US' ,'US' ,'US' ,'US' ,'US' ,'US' ,'US' ,'US' ,'US' ,'US' ,'UK','UK','UK','UK','UK','UK','UK','UK','UK' ); $info = array( ' ' ,' ' ,' ' ,' ' ,' ' ,' ' ,' ' ,' ' ,' ' ,' ' ,' ' ,' ' ,' ',' ',' ',' ',' ',' ',' ',' ',' ' ); for ($i = 0; $i < count($names); $i++) { if ( ($i % $evry_one) !==0 ) { continue; } $bk_type = rand(1,4); $form = 'text^starttime'.$bk_type.'^0'.rand(0,9).':'.rand(10,59).'~'. 'text^endtime'.$bk_type.'^'.rand(13,23).':'.rand(10,59).'~'. 'text^name'.$bk_type.'^'.$names[$i].'~'. 'text^secondname'.$bk_type.'^'.$second_names[$i].'~'. 'text^email'.$bk_type.'^'.$second_names[$i].'.example@wpdevelop.com~'. 'text^address'.$bk_type.'^'.$adress[$i].'~'. 'text^city'.$bk_type.'^'.$city[$i].'~'. 'text^postcode'.$bk_type.'^'.rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).'~'. 'text^country'.$bk_type.'^'.$country[$i].'~'. 'text^phone'.$bk_type.'^'.rand(0,9).rand(0,9).rand(0,9).'-'.rand(0,9).rand(0,9).'-'.rand(0,9).rand(0,9).'~'. 'select-one^visitors'.$bk_type.'^'.rand(0,9).'~'. 'checkbox^children'.$bk_type.'[]^false~'. 'textarea^details'.$bk_type.'^'.$info[$i]; $wp_bk_querie = "INSERT INTO ".$wpdb->prefix ."booking ( form, booking_type, cost, hash ) VALUES ( '".$form."', ".$bk_type .", ".rand(0,1000).", MD5('". time() . '_' . rand(1000,1000000)."') ) ;"; $wpdb->query($wp_bk_querie); $temp_id = $wpdb->insert_id; $wp_queries_sub = "INSERT INTO ".$wpdb->prefix ."bookingdates ( booking_id, booking_date ) VALUES ( ". $temp_id .", CURDATE()+ INTERVAL ".(2*$i*$evry_one+2)." day ), ( ". $temp_id .", CURDATE()+ INTERVAL ".(2*$i*$evry_one+3)." day ), ( ". $temp_id .", CURDATE()+ INTERVAL ".(2*$i*$evry_one+4)." day );"; $wpdb->query($wp_queries_sub); } } // Upgrade during bulk upgrade of plugins function install_in_bulk_upgrade( $return, $hook_extra ){ if ( is_wp_error($return) ) return $return; if (isset($hook_extra)) if (isset($hook_extra['plugin'])) { $file_name = basename( __FILE__ ); $pos = strpos( $hook_extra['plugin'] , trim($file_name) ); if ($pos !== false) { $this->wpdev_booking_activate(); } } return $return; } //
} } //
$wpdev_bk = new wpdev_booking(); // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // S u p p o r t f u n c t i o n s /////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function get_bk_current_user_id() { $user = wp_get_current_user(); return ( isset( $user->ID ) ? (int) $user->ID : 0 ); } // Get form content for table function get_booking_form_show() { return '
'.__('First Name', 'wpdev-booking').':[name]
'.__('Last Name', 'wpdev-booking').':[secondname]
'.__('Email', 'wpdev-booking').':[email]
'.__('Phone', 'wpdev-booking').':[phone]
'.__('Details', 'wpdev-booking').':
[details]
'; } // Parse form content function get_form_content ($formdata, $bktype =-1 , $booking_form_show ='' ) { if ($bktype == -1) { if (function_exists('get__default_type')) $bktype = get__default_type(); else $bktype=1; } if ($booking_form_show==='') { if (function_exists ('get_booking_title')) $booking_form_show = get_bk_option( 'booking_form_show' ); else $booking_form_show = get_booking_form_show(); } //debuge($booking_form_show, $formdata, $bktype); $formdata_array = explode('~',$formdata); $formdata_array_count = count($formdata_array); $email_adress=''; $name_of_person = ''; $coupon_code = ''; $secondname_of_person = ''; $visitors_count = 1; $select_box_selected_items = array(); $check_box_selected_items = array(); $all_fields_array = array(); $checkbox_values=array(); for ( $i=0 ; $i < $formdata_array_count ; $i++) { $elemnts = explode('^',$formdata_array[$i]); //debuge($elemnts); $type = $elemnts[0]; $element_name = $elemnts[1]; $value = $elemnts[2]; $count_pos = strlen( $bktype ); //debuge(substr( $elemnts[1], 0, -1*$count_pos )) ; $type_name = $elemnts[1]; $type_name = str_replace('[]','',$type_name); if ($bktype == substr( $type_name, -1*$count_pos ) ) $type_name = substr( $type_name, 0, -1*$count_pos ); // $type_name = str_replace($bktype,'',$elemnts[1]); if ( ($type_name == 'email') || ($type == 'email') ) $email_adress = $value; if ( ($type_name == 'coupon') || ($type == 'coupon') ) $coupon_code = $value; if ( ($type_name == 'name') || ($type == 'name') ) $name_of_person = $value; if ( ($type_name == 'secondname') || ($type == 'secondname') ) $secondname_of_person = $value; if ( ($type_name == 'visitors') || ($type == 'visitors') ) $visitors_count = $value; if ($type == 'checkbox') { if ($value == 'true') { $value = __('yes', 'wpdev-booking'); } if ($value == 'false') { $value = __('no', 'wpdev-booking'); } if ( ($value !='') && ( $value != __('no', 'wpdev-booking') ) ) if ( ( isset($checkbox_value[ str_replace('[]','',(string) $element_name) ]) ) && ( is_array($checkbox_value[ str_replace('[]','',(string) $element_name) ]) ) ) { $checkbox_value[ str_replace('[]','',(string) $element_name) ][] = $value; } else { if ($value != __('yes', 'wpdev-booking') ) $checkbox_value[ str_replace('[]','',(string) $element_name) ] = array($value); else $checkbox_value[ str_replace('[]','',(string) $element_name) ] = 'checkbox'; } $value = $value .' ' . '['. $type_name .']'; } if ($type == 'select-one') { // add all select box selected items to return array $select_box_selected_items[$type_name] = $value; } if ( ($type == 'checkbox') && (isset($checkbox_value)) ) { $all_fields_array[ str_replace('[]','',(string) $element_name) ] = $checkbox_value[ str_replace('[]','',(string) $element_name) ]; $check_box_selected_items[$type_name] = $checkbox_value[ str_replace('[]','',(string) $element_name) ]; } else $all_fields_array[ str_replace('[]','',(string) $element_name) ] = $value; $booking_form_show = str_replace( '['. $type_name .']', $value ,$booking_form_show); } // Remove all shortcodes, which is not replaced early. $booking_form_show = preg_replace ('/[\s]{0,}\[[a-zA-Z0-9.,-_]{0,}\][\s]{0,}/', '', $booking_form_show); $return_array = array('content' => $booking_form_show, 'email' => $email_adress, 'name' => $name_of_person, 'secondname' => $secondname_of_person , 'visitors' => $visitors_count ,'coupon'=>$coupon_code ,'_all_' => $all_fields_array ) ; foreach ($select_box_selected_items as $key=>$value) { if (! isset($return_array[$key])) { $return_array[$key] = $value; } } foreach ($check_box_selected_items as $key=>$value) { if (! isset($return_array[$key])) { $return_array[$key] = $value; } } //debuge($return_array); return $return_array ; } // this function is fixing bug with PHP4 - "Fatal error: Nesting level too deep - recursive dependency" function show_booking_widget_php4($args) { extract($args); $booking_widget_title = get_bk_option( 'booking_widget_title'); $booking_widget_show = get_bk_option( 'booking_widget_show'); $booking_widget_type = get_bk_option( 'booking_widget_type'); if ($booking_widget_type === false) $booking_widget_type=1; $booking_widget_calendar_count = get_bk_option( 'booking_widget_calendar_count'); $booking_widget_last_field = get_bk_option( 'booking_widget_last_field'); echo $before_widget; if (isset($_GET['booking_hash'])) { _e('You need to use special shortcode [bookingedit] for booking editing.','wpdev-booking'); echo $after_widget; return; } if ($booking_widget_title != '') echo $before_title . htmlspecialchars_decode($booking_widget_title) . $after_title; echo "
"; if ($booking_widget_show == 'booking_form') { do_action('wpdev_bk_add_form', $booking_widget_type , $booking_widget_calendar_count); } else { do_action('wpdev_bk_add_calendar', $booking_widget_type , $booking_widget_calendar_count); } if ($booking_widget_last_field !== '') echo '
' . htmlspecialchars_decode($booking_widget_last_field); echo "
"; echo $after_widget; } // Change date format function change_date_format( $mydates ) { $mydates = explode(',',$mydates); $mydates_result = ''; $date_format = get_bk_option( 'booking_date_format'); $time_format = get_bk_option( 'booking_time_format'); if ( $time_format !== false ) $time_format = ' ' . $time_format; else $time_format=''; if ($date_format == '') $date_format = "d.m.Y"; foreach ($mydates as $dt) { $dt = trim($dt); $dta = explode(' ',$dt); $tms = $dta[1]; $tms = explode(':' , $tms); $dta = $dta[0]; $dta = explode('-',$dta); $date_format_now = $date_format . $time_format; if ($tms == array('00','00','00')) $date_format_now = $date_format; // H M S M D Y $mydates_result .= date_i18n($date_format_now, mktime($tms[0], $tms[1], $tms[2], $dta[1], $dta[2], $dta[0])) . ', '; } return substr($mydates_result,0,-2); } // Get dates 4 emeil function get_dates_str ($approved_id_str) { global $wpdb; $dates_approve = $wpdb->get_results( "SELECT DISTINCT booking_date FROM ".$wpdb->prefix ."bookingdates WHERE booking_id IN ($approved_id_str) ORDER BY booking_date" ); $dates_str = ''; // loop with all dates which is selected by someone foreach ($dates_approve as $my_date) { if ($dates_str != '') $dates_str .= ', '; $dates_str .= $my_date->booking_date;//$my_date[1] . '.' .$my_date[2] . '.' . $my_date[0]; } return $dates_str; } // check if AM/PM exist and replace it to havemilitary format function get_time_array_checked_on_AMPM($start_time) { $start_time = trim($start_time); $start_time_plus = 0; if ( strpos( strtolower( $start_time) ,'am' ) !== false ) { $start_time = str_replace('am', '', $start_time ); $start_time = str_replace('AM', '', $start_time ); } if ( strpos( strtolower( $start_time) ,'pm' ) !== false ) { $start_time = str_replace('pm', '', $start_time ); $start_time = str_replace('PM', '', $start_time ); $start_time_plus = 12; } $start_time = explode(':',trim($start_time)); $start_time[0] = $start_time[0] + $start_time_plus; $start_time[1] = $start_time[1] + 0; if ($start_time[0] < 10 ) $start_time[0] = '0' . $start_time[0]; if ($start_time[1] < 10 ) $start_time[1] = '0' . $start_time[1]; return $start_time; } // Get start and end time from booking form data function get_times_from_bk_form($sdform, $my_dates, $bktype){ $start_time = $end_time = '00:00:00'; if ( strpos($sdform,'rangetime' . $bktype ) !== false ) { // Get START TIME From form request $pos1 = strpos($sdform,'rangetime' . $bktype ); // Find start time pos $pos1 = strpos($sdform,'^',$pos1)+1; // Find TIME pos $pos2 = strpos($sdform,'~',$pos1); // Find TIME length if ($pos2 === false) $pos2 = strlen($sdform); $pos2 = $pos2-$pos1; $range_time = substr( $sdform, $pos1,$pos2) ; $range_time = explode('-',$range_time); $start_time = get_time_array_checked_on_AMPM( trim($range_time[0]) ); $start_time[2]='01'; $end_time = get_time_array_checked_on_AMPM( trim($range_time[1]) ); $end_time[2]='02'; //$start_time = explode(':',trim($range_time[0])); //$start_time[2]='01'; //$end_time = explode(':',trim($range_time[1])); //$end_time[2]='02'; if ( count($my_dates) == 1 ) { // add end date if someone select only 1 day with time range $my_dates[]=$my_dates[0]; } } else { if ( strpos($sdform,'starttime' . $bktype ) !== false ) { // Get START TIME From form request $pos1 = strpos($sdform,'starttime' . $bktype ); // Find start time pos $pos1 = strpos($sdform,'^',$pos1)+1; // Find TIME pos $pos2 = strpos($sdform,'~',$pos1); // Find TIME length if ($pos2 === false) $pos2 = strlen($sdform); $pos2 = $pos2-$pos1; $start_time = substr( $sdform, $pos1,$pos2) ; $start_time = explode(':',$start_time); $start_time[2]='01'; } else $start_time = explode(':',$start_time); if ( strpos($sdform,'endtime' . $bktype ) !== false ) { // Get END TIME From form request $pos1 = strpos($sdform,'endtime' . $bktype ); // Find start time pos $pos1 = strpos($sdform,'^',$pos1)+1; // Find TIME pos $pos2 = strpos($sdform,'~',$pos1); // Find TIME length if ($pos2 === false) $pos2 = strlen($sdform); $pos2 = $pos2-$pos1; $end_time = substr( $sdform, $pos1,$pos2) ; if ( count($my_dates) == 1 ) { // add end date if someone select only 1 day with time range $my_dates[]=$my_dates[0]; } $end_time = explode(':',$end_time); $end_time[2]='02'; } else $end_time = explode(':',$end_time); if ( strpos($sdform,'durationtime' . $bktype ) !== false ) { // Get END TIME From form request $pos1 = strpos($sdform,'durationtime' . $bktype ); // Find start time pos $pos1 = strpos($sdform,'^',$pos1)+1; // Find TIME pos $pos2 = strpos($sdform,'~',$pos1); // Find TIME length if ($pos2 === false) $pos2 = strlen($sdform); $pos2 = $pos2-$pos1; $end_time = substr( $sdform, $pos1,$pos2) ; if ( count($my_dates) == 1 ) { // add end date if someone select only 1 day with time range $my_dates[]=$my_dates[0]; } $end_time = explode(':',$end_time); // Here we are get start time and add duration for end time $new_end_time = mktime($start_time[0], $start_time[1]); $new_end_time = $new_end_time + $end_time[0]*60*60 + $end_time[1]*60; $end_time = date('H:i',$new_end_time); $end_time = explode(':',$end_time); $end_time[2]='02'; } } return array($start_time, $end_time, $my_dates ); } // Check if dates in range format and fix it to the coma seperated dates function createDateRangeArray($strDateFrom,$strDateTo) { $aryRange=array(); $strDateFrom = explode('.', $strDateFrom); $strDateTo = explode('.', $strDateTo); $iDateFrom=mktime(1,0,0, ($strDateFrom[1]+0), ($strDateFrom[0]+0),($strDateFrom[2]+0)); $iDateTo=mktime(1,0,0,($strDateTo[1]+0), ($strDateTo[0]+0), ($strDateTo[2]+0)); if ($iDateTo>=$iDateFrom) { array_push($aryRange,date('d.m.Y',$iDateFrom)); // first entry while ($iDateFrom<$iDateTo) { $iDateFrom+=86400; // add 24 hours array_push($aryRange,date('d.m.Y',$iDateFrom)); } } $aryRange = implode(', ', $aryRange); return $aryRange; } // Check if nowday is tommorow from previosday function is_next_day($nowday, $previosday) { $nowday_d = (date('m.d.Y', mysql2date('U', $nowday )) ); $prior_day = (date('m.d.Y', mysql2date('U', $previosday )) ); if ($prior_day == $nowday_d) return true; // if its the same date $previos_array = (date('m.d.Y', mysql2date('U', $previosday )) ); $previos_array = explode('.',$previos_array); $prior_day = date('m.d.Y' , mktime(0, 0, 0, $previos_array[0], ($previos_array[1]+1), $previos_array[2] )); if ($prior_day == $nowday_d) return true; // zavtra else return false; // net } // Get days in short format view function get_dates_short_format( $days ) { // $days - string with comma seperated dates $days = explode(',', $days); $previosday = false; $result_string = ''; $last_show_day = ''; foreach ($days as $day) { $is_fin_at_end = false; if ($previosday !== false) { // Not first day if ( is_next_day($day, $previosday) ) { $previosday = $day; // Set previos day for next loop $is_fin_at_end = true; } else { if ($last_show_day !== $previosday) { // check if previos day was show or no $result_string .= ' - ' . change_date_format($previosday); // assign in needed format this day } $result_string .= ', ' . change_date_format($day); // assign in needed format this day $previosday = $day; // Set previos day for next loop $last_show_day = $day; } } else { // First day $result_string = change_date_format($day); // assign in needed format first day $last_show_day = $day; $previosday = $day; // Set previos day for next loop } } if ($is_fin_at_end) { $result_string .= ' - ' . change_date_format($day); } // assign in needed format this day return $result_string; } function sendApproveEmails($approved_id_str, $is_send_emeils){ global $wpdb; $sql = "SELECT * FROM ".$wpdb->prefix ."booking as bk WHERE bk.booking_id IN ($approved_id_str)"; $result = $wpdb->get_results( $sql ); //debuge($result); $mail_sender = htmlspecialchars_decode( get_bk_option( 'booking_email_approval_adress') ) ; //'"'. 'Booking sender' . '" <' . $booking_form_show['email'].'>'; $mail_subject = htmlspecialchars_decode( get_bk_option( 'booking_email_approval_subject') ); $mail_body = htmlspecialchars_decode( get_bk_option( 'booking_email_approval_content') ); foreach ($result as $res) { //debuge($res) ; // Sending mail /////////////////////////////////////////////////////// if (function_exists ('get_booking_title')) $bk_title = get_booking_title( $res->booking_type ); else $bk_title = ''; //debuge($bk_title); $booking_form_show = get_form_content ($res->form, $res->booking_type); //debuge($booking_form_show); make_bk_action('booking_aproved', $res, $booking_form_show); $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($res->booking_id) ); else $my_dates_4_send = change_date_format(get_dates_str($res->booking_id)); //debuge($my_dates_4_send); $my_dates4emeil_check_in_out = explode(',',get_dates_str($res->booking_id)); $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 ] ); $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]',$res->booking_id , $mail_body_to_send); $mail_body_to_send = str_replace('[content]', $booking_form_show['content'], $mail_body_to_send); $mail_body_to_send = str_replace('[name]', $booking_form_show['name'], $mail_body_to_send); if (isset($res->cost)) $mail_body_to_send = str_replace('[cost]', $res->cost, $mail_body_to_send); $mail_body_to_send = str_replace('[siteurl]', htmlspecialchars_decode( '' . get_option('siteurl') . ''), $mail_body_to_send); $mail_body_to_send = apply_bk_filter('wpdev_booking_set_booking_edit_link_at_email', $mail_body_to_send, $res->booking_id ); if ( isset($booking_form_show['secondname']) ) $mail_body_to_send = str_replace('[secondname]', $booking_form_show['secondname'], $mail_body_to_send); $mail_subject1 = $mail_subject; $mail_subject1 = str_replace('[name]', $booking_form_show['name'], $mail_subject1); if ( isset($booking_form_show['secondname']) ) $mail_subject1 = str_replace('[secondname]', $booking_form_show['secondname'], $mail_subject1); $mail_recipient = $booking_form_show['email']; $mail_headers = "From: $mail_sender\n"; $mail_headers .= "Content-Type: text/html\n"; //debuge($mail_recipient, $mail_subject1, $mail_body_to_send, $mail_headers); //debuge(get_bk_option( 'booking_is_email_approval_adress' )); if (get_bk_option( 'booking_is_email_approval_adress' ) != 'Off') if ($is_send_emeils != 0 ) if ( ( strpos($mail_recipient,'@blank.com') === false ) && ( strpos($mail_body_to_send,'admin@blank.com') === false ) ) @wp_mail($mail_recipient, $mail_subject1, $mail_body_to_send, $mail_headers); // Send to the Admin also $mail_recipient = htmlspecialchars_decode( get_bk_option( 'booking_email_reservation_adress') ); $is_email_approval_send_copy_to_admin = get_bk_option( 'booking_is_email_approval_send_copy_to_admin' ); //debuge($mail_recipient, $is_email_approval_send_copy_to_admin) ; if ( $is_email_approval_send_copy_to_admin == 'On') if ( ( strpos($mail_recipient,'@blank.com') === false ) && ( strpos($mail_body_to_send,'admin@blank.com') === false ) ) if ($is_send_emeils != 0 ) @wp_mail($mail_recipient, $mail_subject1, $mail_body_to_send, $mail_headers); ///////////////////////////////////////////////////////////////////////// //debuge(';Fin') ;die; } //die; } function sendDeclineEmails($approved_id_str, $is_send_emeils, $denyreason = '') { global $wpdb; $sql = "SELECT * FROM ".$wpdb->prefix ."booking as bk WHERE bk.booking_id IN ($approved_id_str)"; $result = $wpdb->get_results( $sql ); $mail_sender = htmlspecialchars_decode( get_bk_option( 'booking_email_deny_adress') ) ; $mail_subject = htmlspecialchars_decode( get_bk_option( 'booking_email_deny_subject') ); $mail_body = htmlspecialchars_decode( get_bk_option( 'booking_email_deny_content') ); foreach ($result as $res) { // Sending mail /////////////////////////////////////////////////////// if (function_exists ('get_booking_title')) $bk_title = get_booking_title( $res->booking_type ); else $bk_title = ''; $booking_form_show = get_form_content ($res->form, $res->booking_type); $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($res->booking_id) ); else $my_dates_4_send = change_date_format(get_dates_str($res->booking_id)); $my_dates4emeil_check_in_out = explode(',',get_dates_str($res->booking_id)); $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 ] ); $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]',$res->booking_id , $mail_body_to_send); $mail_body_to_send = str_replace('[content]', $booking_form_show['content'], $mail_body_to_send); $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); if (isset($res->cost)) $mail_body_to_send = str_replace('[cost]', $res->cost, $mail_body_to_send); $mail_body_to_send = str_replace('[siteurl]', htmlspecialchars_decode( '' . get_option('siteurl') . ''), $mail_body_to_send); $mail_body_to_send = apply_bk_filter('wpdev_booking_set_booking_edit_link_at_email', $mail_body_to_send, $res->booking_id ); if ( isset($booking_form_show['secondname']) ) $mail_body_to_send = str_replace('[secondname]', $booking_form_show['secondname'], $mail_body_to_send); $mail_subject1 = $mail_subject; $mail_subject1 = str_replace('[name]', $booking_form_show['name'], $mail_subject1); if ( isset($booking_form_show['secondname']) ) $mail_subject1 = str_replace('[secondname]', $booking_form_show['secondname'], $mail_subject1); $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_deny_adress' ) != 'Off') if ($is_send_emeils != 0 ) if ( ( strpos($mail_recipient,'@blank.com') === false ) && ( strpos($mail_body_to_send,'admin@blank.com') === false ) ) @wp_mail($mail_recipient, $mail_subject1, $mail_body_to_send, $mail_headers); // Send to the Admin also $mail_recipient = htmlspecialchars_decode( get_bk_option( 'booking_email_reservation_adress') ); $is_email_deny_send_copy_to_admin = get_bk_option( 'booking_is_email_deny_send_copy_to_admin' ); if ( $is_email_deny_send_copy_to_admin == 'On') if ( ( strpos($mail_recipient,'@blank.com') === false ) && ( strpos($mail_body_to_send,'admin@blank.com') === false ) ) if ($is_send_emeils != 0 ) @wp_mail($mail_recipient, $mail_subject1, $mail_body_to_send, $mail_headers); ///////////////////////////////////////////////////////////////////////// } } //
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // A J A X R e s p o n d e r Real Ajax with jWPDev sender /////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function wpdev_bk_ajax_responder() { global $wpdb; $action = $_POST['ajax_action']; switch ( $action ) : case 'INSERT_INTO_TABLE': $dates = $_POST[ "dates" ]; $bktype = $_POST[ "bktype" ]; make_bk_action('check_multiuser_params_for_client_side', $bktype ); $formdata = $_POST["form"]; if (isset($_POST["is_send_emeils"])) $is_send_emeils = $_POST["is_send_emeils"]; else $is_send_emeils = 1; $my_booking_id = 0;//(int) $_POST["my_booking_id"]; $my_booking_hash = ''; if (isset($_POST['my_booking_hash'])) { $my_booking_hash = $_POST['my_booking_hash']; //debuge($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]; } } } $is_approved_dates = '0'; 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, '.')); ?> 0) { // Edit exist booking if ( strpos($_SERVER['HTTP_REFERER'],'wp-admin/admin.php?') !==false ) { ?> prefix ."booking AS bk SET bk.form='$formdata', bk.booking_type=$bktype , bk.modification_date=NOW() WHERE bk.booking_id=$my_booking_id;"; if ( false === $wpdb->query( $update_sql ) ) { ?> 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 ) ) { ?> prefix ."booking (form, booking_type, modification_date) VALUES ('$formdata', $bktype, NOW() )" ; if ( false === $wpdb->query( $sql_insertion ) ) { ?> insert_id; //Get ID of reservation } $sdform = $_POST['form']; $my_dates = explode(", ",$dates); $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 $md = explode('.',$md); $my_dates[$i] = $md[2] . '.' . $md[1] . '.' . $md[0] ; $i++; } sort($my_dates); // Sort dates $my_dates4emeil = ''; $i=0; $insert=''; foreach ($my_dates as $my_date) { $i++; // Loop through all dates if (strpos($my_date,'.')!==false) { $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' )"; } } $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("INSERT INTO ".$wpdb->prefix ."bookingdates (booking_id, booking_date, approved) VALUES " . $insert) ) { ?> 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') ); 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); $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( '' . get_option('siteurl') . ''), $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,'admin@blank.com') === 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,'admin@blank.com') === 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 ); } ?> '; $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_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( '' . get_option('siteurl') . ''), $mail_body); $mail_body = str_replace('[moderatelink]', htmlspecialchars_decode( '' . __('here','wpdev-booking') . ''), $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,'admin@blank.com') === 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_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( '' . get_option('siteurl') . ''), $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,'admin@blank.com') === 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 ); ?> 0) && ($approved_id !==false)) { $approved_id_str = join( ',', $approved_id); if ( false === $wpdb->query( "UPDATE ".$wpdb->prefix ."bookingdates SET approved = '1' WHERE booking_id IN ($approved_id_str)") ) { ?> 0) && ($approved_id !=false) && ($approved_id !='')) { $approved_id_str = join( ',', $approved_id); sendDeclineEmails($approved_id_str, $is_send_emeils,$denyreason); if ( false === $wpdb->query( "DELETE FROM ".$wpdb->prefix ."bookingdates WHERE booking_id IN ($approved_id_str)") ) { ?> query( "DELETE FROM ".$wpdb->prefix ."booking WHERE booking_id IN ($approved_id_str)") ) { ?> ?>