Booking Calendar plugin. Profesional verion can export bookings to CSV, print bookings, have advanced filter. Version: 1.1 Author: wpdevelop Author URI: http://www.wpdevelop.com */ /* T O D O P L A N of W O R K : * * 2. Notes for customers and orders - Pro * 3. Actions: delete - Pro * 1. Email sending - Pro * 2. Notification emails - Pro * */ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 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;} } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Internal plugin action system ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (true) { global $wpdev_crm_action, $wpdev_crm_filter; function add_crm_filter($filter_type, $filter) { global $wpdev_crm_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_crm_filter) ) if ( is_array($wpdev_crm_filter[$filter_type]) ) $wpdev_crm_filter[$filter_type][]= $args; else $wpdev_crm_filter[$filter_type]= array($args); else $wpdev_crm_filter = array( $filter_type => array( $args ) ) ; } function remove_crm_filter($filter_type, $filter) { global $wpdev_crm_filter; if ( isset($wpdev_crm_filter[$filter_type]) ) { for ($i = 0; $i < count($wpdev_crm_filter[$filter_type]); $i++) { if ( $wpdev_crm_filter[$filter_type][$i][0] == $filter ) { $wpdev_crm_filter[$filter_type][$i] = null; return; } } } } function apply_crm_filter($filter_type) { global $wpdev_crm_filter; $args = array(); for ( $a = 1; $a < func_num_args(); $a++ ) $args[] = func_get_arg($a); $value = $args[0]; if ( is_array($wpdev_crm_filter) ) if ( isset($wpdev_crm_filter[$filter_type]) ) foreach ($wpdev_crm_filter[$filter_type] as $filter) { $filter_func = array_shift($filter); $parameter = $args; $value = call_user_func_array($filter_func,$parameter ); } return $value; } function make_crm_action($action_type) { global $wpdev_crm_action; $args = array(); for ( $a = 1; $a < func_num_args(); $a++ ) $args[] = func_get_arg($a); //$value = $args[0]; if ( is_array($wpdev_crm_action) ) if ( isset($wpdev_crm_action[$action_type]) ) foreach ($wpdev_crm_action[$action_type] as $action) { $action_func = array_shift($action); $parameter = $action; call_user_func_array($action_func,$args ); } } function add_crm_action($action_type, $action) { global $wpdev_crm_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_crm_action) ) if ( is_array($wpdev_crm_action[$action_type]) ) $wpdev_crm_action[$action_type][]= $args; else $wpdev_crm_action[$action_type]= array($args); else $wpdev_crm_action = array( $action_type => array( $args ) ) ; } function remove_crm_action($action_type, $action) { global $wpdev_crm_action; if ( isset($wpdev_crm_action[$action_type]) ) { for ($i = 0; $i < count($wpdev_crm_action[$action_type]); $i++) { if ( $wpdev_crm_action[$action_type][$i][0] == $action ) { $wpdev_crm_action[$action_type][$i] = null; return; } } } } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Get header info from this file, just for compatibility with WordPress 2.8 and older versions. function get_file_data_crm_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; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Define all our CONSTANTS and other... $wpdev_booking_module_for_orders = false; function wpdev_crm_define_static() { if (!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_crm_wpdev( __FILE__, $default_headers, 'plugin' ); if (!defined('WPDEV_CRM_VERSION')) define('WPDEV_CRM_VERSION', $plugin_data['Version'] ); // 0.1 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_CRM_PLUGIN_FILENAME')) define('WPDEV_CRM_PLUGIN_FILENAME', basename( __FILE__ ) ); // menu-compouser.php if (!defined('WPDEV_CRM_PLUGIN_DIRNAME')) define('WPDEV_CRM_PLUGIN_DIRNAME', plugin_basename(dirname(__FILE__)) ); // menu-compouser if (!defined('WPDEV_CRM_PLUGIN_DIR')) define('WPDEV_CRM_PLUGIN_DIR', WP_PLUGIN_DIR.'/'.WPDEV_CRM_PLUGIN_DIRNAME ); // Z:\home\test.wpdevelop.com\www/wp-content/plugins/menu-compouser if (!defined('WPDEV_CRM_PLUGIN_URL')) define('WPDEV_CRM_PLUGIN_URL', WP_PLUGIN_URL.'/'.WPDEV_CRM_PLUGIN_DIRNAME ); // http://test.wpdevelop.com/wp-content/plugins/menu-compouser // Load modules, if they exist if (file_exists(WPDEV_CRM_PLUGIN_DIR. '/modules/booking-module.php')) { require_once(WPDEV_CRM_PLUGIN_DIR. '/modules/booking-module.php' ); global $wpdev_booking_module_for_orders; if ( class_exists('wpdev_booking_module_for_orders')) { $wpdev_booking_module_for_orders = new wpdev_booking_module_for_orders(); } } if (file_exists(WPDEV_CRM_PLUGIN_DIR. '/include/wpdev-pro.php')) { require_once(WPDEV_CRM_PLUGIN_DIR. '/include/wpdev-pro.php' ); } if ( ! loadLocale_crm() ) { loadLocale_crm('en_US'); } //loadLocale_crm('ru_RU'); // Localization } // Load locale function loadLocale_crm($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" $mofile = WPDEV_BK_PLUGIN_DIR .'/languages/'.str_replace('.php','',WPDEV_CRM_PLUGIN_FILENAME).'-'.$locale.'.mo'; if (file_exists($mofile)) return load_textdomain(str_replace('.php','',WPDEV_CRM_PLUGIN_FILENAME), $mofile); else return false; } return false; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Getting Ajax requests ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if ( isset( $_POST['ajax_action_crm'] ) ) { define('DOING_AJAX', true); require_once( dirname(__FILE__) . '/../../../wp-load.php' ); @header('Content-Type: text/html; charset=' . get_option('blog_charset')); wpdev_crm_define_static(); if ( class_exists('wpdev_crm_pro')) { $wpdev_crm_pro_in_ajax = new wpdev_crm_pro(); } wpdev_crm_ajax_responder(); } wpdev_crm_define_static(); if (!class_exists('wpdev_crm')) { class wpdev_crm { var $wpdev_crm_pro; var $wpdev_booking_module_for_orders; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Constructor //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function wpdev_crm() { if ( class_exists('wpdev_crm_pro')) { $this->wpdev_crm_pro = new wpdev_crm_pro(); } else { $this->wpdev_crm_pro = false; } // Add settings top line before all other menu items. add_crm_action('wpdev_crm_settings_show_top_line', array($this, 'show_settings_menu_top_line')); add_crm_action('wpdev_crm_settings_show_content', array(&$this, 'show_settings_menu_content')); add_crm_action('wpdev_crm_orders_show_content', array(&$this, 'show_orders_content')); add_crm_action('wpdev_crm_customers_show_content', array(&$this, 'show_customers_content')); // Create admin menu add_action('admin_menu', array(&$this, 'add_new_admin_menu')); // Add settings link at the plugin page add_filter('plugin_action_links', array(&$this, 'plugin_links'), 10, 2 ); // Install / Uninstall register_activation_hook( __FILE__, array(&$this,'wpdev_crm_activate' )); register_deactivation_hook( __FILE__, array(&$this,'wpdev_crm_deactivate' )); wp_enqueue_script( 'jquery-ui-dialog' ); wp_enqueue_style( 'wpdev-bk-jquery-ui', WPDEV_CRM_PLUGIN_URL. '/css/jquery-ui.css', array(), 'wpdev-bk', 'screen' ); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ADMIN MENU SECTIONS /////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function add_new_admin_menu(){ $users_roles = array(get_option( 'wpdev_crm_user_role_orders' ), get_option( 'wpdev_crm_user_role_customers' ), get_option( 'wpdev_crm_user_role_settings' ) ); //$users_roles = array('administrator','administrator','administrator'); for ($i = 0 ; $i < count($users_roles) ; $i++) { 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( __('Orders', 'wpdev-crm'), __('Orders', 'wpdev-crm'), $users_roles[0], __FILE__ . 'wpdev-crm', array(&$this, 'on_show_crm_page_orders'), WPDEV_CRM_PLUGIN_URL . '/img/crm-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-crm',__('Customers', 'wpdev-crm'), __('Customers', 'wpdev-crm'), $users_roles[1], __FILE__ .'wpdev-crm-customers', array(&$this, 'on_show_crm_page_customers') ); add_action("admin_print_scripts-" . $pagehook2 , array( &$this, 'on_add_admin_js_files')); /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // S E T T I N G S /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $pagehook3 = add_submenu_page(__FILE__ . 'wpdev-crm',__('Settings', 'wpdev-crm'), __('Settings', 'wpdev-crm'), $users_roles[2], __FILE__ .'wpdev-crm-settings', array(&$this, 'on_show_crm_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-crm'][0][0] = __('Orders', 'wpdev-crm'); } //Orders function on_show_crm_page_orders(){ $this->on_show_page_adminmenu('wpdev-crm','/img/crm-48x48.png', __('Orders', 'wpdev-crm'),1); } //Customers function on_show_crm_page_customers(){ $this->on_show_page_adminmenu('wpdev-crm-customers','/img/crm-48x48.png', __('Customers', 'wpdev-crm'),2); } //Settings function on_show_crm_page_settings(){ $this->on_show_page_adminmenu('wpdev-crm-settings','/img/crm-48x48.png', __('Settings', 'wpdev-crm'),3); } //Show content function on_show_page_adminmenu($html_id, $icon, $title, $content_type) { ?>

' ; else echo '

' ; ?>

content_of_crm_orders(); break; case 2: $this->content_of_crm_customers(); break; case 3: $this->content_of_crm_settings(); break; default: break; } ?>
0) $start_just_page = $_GET['wpdev_page_num']; $cont_on_page = get_option( 'wpdev_crm_rows_per_page_orders' ); if (isset($_GET['show_all_records'])) if ($_GET['show_all_records']=='1') $cont_on_page = 'all'; if ($cont_on_page == 'all') {$cont_on_page = '10000'; $start_just_page = '0'; } $start_page = ((int) $start_just_page) * ((int) $cont_on_page); $sort_array_tags = array('date','id','customer','order_date','type','cost','email','internal_filter'); $table_sort_tags = array('','ordr.order_id','ordr.customer_id','ordr.order_date','ordr.type','ordr.cost','custmr.email','ordr.internal_filters'); $sort_tag_for_table =''; // Set TYPE of SORTING : dates, id, customer, order_date, type, cost $sorted_structure = array(); $sort_type = 'id'; $sort_order = 'DESC'; $ii=0; if (isset($_GET['wpdev_sort_order'])) { // CHECK S O R T T A Gs foreach ($sort_array_tags as $sort_tag) { if ($_GET['wpdev_sort_order'] == $sort_tag) { $sort_type = $sort_tag; $sort_order = 'ASC'; $sort_tag_for_table = $table_sort_tags[$ii] ; } if ($_GET['wpdev_sort_order'] == ($sort_tag . '_desc') ) { $sort_type = $sort_tag; $sort_order = 'DESC';$sort_tag_for_table = $table_sort_tags[$ii] ; } $ii++; } } if ($sort_tag_for_table !=='') $sort_tag_for_table .= ' ' . $sort_order . ', '; $booking_date_view_type = get_option( 'booking_date_view_type'); // Get data from Booking Plugin according hided dates 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 '; } $sort_url = ''; $arr_desc = ''; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $where = ''; if (isset($_GET['wpdev_filter_customer'])) { if ( $_GET['wpdev_filter_customer'] != '0') { if ($where !== '') { $where .= ' AND '; } $where .= ' custmr.customer_id = '. $_GET['wpdev_filter_customer'] . ' '; } } // TODO: add here filter and set it to pro $where = apply_crm_filter('wpdev_where_filter', $where); /*// Pro functionality ////////////////////////////////////////////////////////////////////////////// if (isset($_GET['wpdev_filter_order_type'])) { if ( ( $_GET['wpdev_filter_order_type'] !== '' ) && ( $_GET['wpdev_filter_order_type'] != '0' ) ) { if ($where !== '') { $where .= ' AND '; } $where .= ' ordr.internal_filters1 = '. $_GET['wpdev_filter_order_type'] . ' '; } } if (isset($_GET['wpdev_filter_bk_dates_start'])) { if ( ( $_GET['wpdev_filter_bk_dates_start'] !== '' ) && ( $_GET['wpdev_filter_bk_dates_start'] != '0' ) ) { if ($where !== '') { $where .= ' AND '; } $my_date = explode('-',$_GET['wpdev_filter_bk_dates_start']); $my_date = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], '00', '00', '00' ); $where .= ' ordr.internal_filters2 > \''. $my_date . '\' '; } } if (isset($_GET['wpdev_filter_bk_dates_fin'])) { if ( ( $_GET['wpdev_filter_bk_dates_fin'] !== '' ) && ( $_GET['wpdev_filter_bk_dates_fin'] != '0' ) ) { if ($where !== '') { $where .= ' AND '; } $my_date = explode('-',$_GET['wpdev_filter_bk_dates_fin']); $my_date = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], '23', '59', '59' ); $where .= ' ordr.internal_filters3 < \''. $my_date . '\' '; } } if (isset($_GET['wpdev_filter_cost_start'])) { if ( ($_GET['wpdev_filter_cost_start'] +0) > 0 ) { if ($where !== '') { $where .= ' AND '; } $where .= ' ordr.cost > '. $_GET['wpdev_filter_cost_start'] . ' '; } } if (isset($_GET['wpdev_filter_cost_fin'])) { if ( ($_GET['wpdev_filter_cost_fin'] +0) > 0 ) { if ($where !== '') { $where .= ' AND '; } $where .= ' ordr.cost < '. $_GET['wpdev_filter_cost_fin'] . ' '; } }/**/ /////////////////////////////////////////////////////////////////////////////////////////////////// //debuge($where); if ($where !== '') $where = ' WHERE ' . $where; //Set here order by some field $sql = "SELECT count(ordr.order_id) as cnt FROM ".$wpdb->prefix ."wpdev_crm_orders as ordr INNER JOIN ".$wpdb->prefix ."wpdev_crm_customers as custmr ON ordr.customer_id = custmr.customer_id " . $where ." ORDER BY ".$sort_tag_for_table." ordr.order_id DESC"; $result = $wpdb->get_results( $sql ); $togather_pages = ceil($result[0]->cnt / ((int) $cont_on_page)); $sql = "SELECT * FROM ".$wpdb->prefix ."wpdev_crm_orders as ordr INNER JOIN ".$wpdb->prefix ."wpdev_crm_customers as custmr ON ordr.customer_id = custmr.customer_id " . $where ." ORDER BY ".$sort_tag_for_table." ordr.order_id DESC LIMIT " .$start_page . "," . $cont_on_page; // debuge($sql); $result = $wpdb->get_results( $sql ); // debuge($result); ?> type); $order_type = 0; // C O N T E N T if (isset($my_type['booking'])) { // C O N T E N T if ( function_exists ('get_form_content')) { // Booking $content = get_form_content($res->order_info, $my_type['booking']); $order_type = $my_type['booking']; $result_structure[$ns]['content'] = str_replace('
', '', $content['content']); $result_structure[$ns]['content'] = str_replace('
', '', $result_structure[$ns]['content']); } else { $result_structure[$ns]['content'] = __( 'Booking Calendar plugin is not installed. This plugin is requred Booking Calendar for this type of records. ', 'wpdev-crm'); } } else $result_structure[$ns]['content'] = $res->order_info; // SOME OTHER ORDERS if ($content) // D A T E S if (isset($content['_all_'])) { if (isset($content['_all_']['booking_dates'])) { $my_dates = explode(',',$content['_all_']['booking_dates']); sort($my_dates); $result_structure[$ns]['dates'] = $my_dates; if ($wpdev_booking_module_for_orders!== false) $result_structure[$ns]['short_dates'] = $wpdev_booking_module_for_orders->get_booking_short_days($my_dates); } if (isset($content['_all_']['email' . $my_type['booking'] ])) { $result_structure[$ns]['email'] = $content['_all_']['email' . $my_type['booking'] ]; } $result_structure[$ns]['all'] = $content['_all_']; // A l l b o o k i n g d a t a } $result_structure[$ns]['id'] = $res->order_id; // I D $result_structure[$ns]['customer'] = $res->second_name . ' ' .$res->name; // C u s t o m e r $result_structure[$ns]['customer_id'] = $res->customer_id ; // C u s t o m e r ID $result_structure[$ns]['order_date'] = $res->order_date; // O r d e r D a t e $result_structure[$ns]['type'] = $order_type; // O r d e r T y p e if ( class_exists('wpdev_bk_premium')) $result_structure[$ns]['cost']= $res->cost; // O r d e r C o s t } //debuge($result_structure, $sort_type); // S O R T process 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 'email': if ( ! empty($sorted_structure[$value['email']])) $sorted_structure[$value['email'] . (time() * rand()) ] = $value; else $sorted_structure[$value['email']] = $value; break; case 'customer': $my_index = strtolower( str_replace(' ','',$value[ $sort_type ]) ); if ( ! empty($sorted_structure[$my_index])) $sorted_structure[$my_index . (time() * rand()) ] = $value; else $sorted_structure[strtolower($my_index)] = $value; break; case 'order_date': $my_index = strtolower( str_replace(' ','',$value[ $sort_type ]) ); if ( ! empty($sorted_structure[$my_index])) $sorted_structure[$my_index . (time() * rand()) ] = $value; else $sorted_structure[strtolower($my_index)] = $value; break; case 'id': $my_index = strtolower( str_replace(' ','',$value[ $sort_type ]) ); if ( ! empty($sorted_structure[$my_index])) $sorted_structure[$my_index . (time() * rand()) ] = $value; else $sorted_structure[strtolower($my_index)] = $value; break; case 'type': $my_index = strtolower( str_replace(' ','',$value[ $sort_type ]) ); if ( ! empty($sorted_structure[$my_index])) $sorted_structure[$my_index . (time() * rand()) ] = $value; else $sorted_structure[strtolower($my_index)] = $value; break; case 'cost': $my_index = strtolower( str_replace(' ','',$value[ $sort_type ]) ); if ( ! empty($sorted_structure[$my_index])) $sorted_structure[$my_index . (time() * rand()) ] = $value; else $sorted_structure[strtolower($my_index)] = $value; break; // Check booking here //case 'email': if ( ! empty($sorted_structure[$value['all']['email' . $value['type'] ]])) $sorted_structure[$value['all']['email' . $value['type'] ] . (time() * rand()) ] = $value; else $sorted_structure[strtolower($value['all']['email' . $value['type'] ])] = $value; break; default: $sorted_structure[$value['id']] = $value; break; } //debuge($sorted_structure); } // if ($sort_order == 'DESC') krsort($sorted_structure ); // else ksort($sorted_structure ); $alternative_color = ''; $summ_togather = 0; // L o o p A l l R O W S foreach ($sorted_structure as $sort_element) { if ( $alternative_color == '') {$alternative_color = ' class="alternative_color" ';} else { $alternative_color = '';} ?> style="border-right:1px solid #ccc;text-align:center;"> style="border-right:1px solid #ccc;font-size:11px;">
$bkdate) { $date_class = ( date('m', mysql2date('U',$bkdate)) + 0 ) . '-' . ( date('d', mysql2date('U',$bkdate)) + 0 ) . '-' . ( date('Y', mysql2date('U',$bkdate)) + 0 ); ?> ">
'; $short_days = $sort_element['short_dates']; //if ($wpdev_booking_module_for_orders!== false) $wpdev_booking_module_for_orders->get_booking_short_days($my_dates); if ( isset($short_days)) // SHORT DAYS ECHO foreach ($short_days[0] as $bkdate) { //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 '' . apply_filters('wpdev_bk_get_showing_date_format', mysql2date('U', $bkdate )) . ''; //echo apply_bk_filter('filter_subtype_num','',$bk['booking_type'], $bk['id'], $bkdate); echo ' '; } else { // echo separator echo ''.$bkdate.' ' ; } } ?>
style="border-right:1px solid #ccc;">'; echo $sort_element['customer']; $current_customer = $sort_element['customer']; ?> style="border-right:1px solid #ccc;">' , $title , ''; } ?> style="border-right:1px solid #ccc;padding:0px 5px 0px 5px;"> "> >
0 ) { ?> style="border-top:1px solid #777;font-size: 15px;">
');"> (',''); ?> ');"> , ');"> )
');"> ');"> ');"> ');">
 


Booking Calendar v.2.1'); ?>

', 'Booking Calendar Standard',''); ?>
adv_html_to_csv($out1); $dir_relative = ''; //$b['host'] . dirname ( $b['path'] ); $dir = $_SERVER['DOCUMENT_ROOT'] .$dir_relative ; //$b['host'] . dirname ( $b['path'] ); $fp = fopen( $dir . '/' . 'file.csv' , 'w' ); $search = array ("']*?>.*?'si","'<[\/\!]*?[^<>]*?>'si","'([\r\n])[\s]+'","'&(quot|#34);'i","'&(amp|#38);'i","'&(lt|#60);'i","'&(gt|#62);'i","'&(nbsp|#160);'i","'&(iexcl|#161);'i","'&(cent|#162);'i","'&(pound|#163);'i","'&(copy|#169);'i","'&#(\d+);'e"); $replace = array ("","","\\1","\"","&","<",">"," ",chr(161),chr(162),chr(163),chr(169),"chr(\\1)"); $csv = preg_replace($search, $replace, $csv); fwrite($fp, $csv); //foreach ($csv as $line) { fputcsv($fp, split(',', $line)); } fclose($fp); //debuge($csv);/**/ ?>
0) $start_just_page = $_GET['wpdev_page_num']; $cont_on_page = get_option( 'wpdev_crm_rows_per_page_customers' ); $start_page = ((int) $start_just_page) * ((int) $cont_on_page); $sort_array_tags = array( 'id','name','email','phone','adress','city','country','orders_num'); $table_sort_tags = array( 'custmr.customer_id','custmr.second_name','custmr.email','custmr.phone','custmr.adress','custmr.city','custmr.country','cnt'); $sort_tag_for_table =''; // Set TYPE of SORTING : dates, id, customer, order_date, type, cost $sorted_structure = array(); $sort_type = 'id'; $sort_order = 'DESC'; $ii=0; if (isset($_GET['wpdev_sort_order'])) { // CHECK S O R T T A Gs foreach ($sort_array_tags as $sort_tag) { if ($_GET['wpdev_sort_order'] == $sort_tag) { $sort_type = $sort_tag; $sort_order = 'ASC'; $sort_tag_for_table = $table_sort_tags[$ii] ; } if ($_GET['wpdev_sort_order'] == ($sort_tag . '_desc') ) { $sort_type = $sort_tag; $sort_order = 'DESC';$sort_tag_for_table = $table_sort_tags[$ii] ; } $ii++; } } if ($sort_tag_for_table !=='') $sort_tag_for_table .= ' ' . $sort_order . ', '; $sort_url = ''; $arr_desc = ''; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Set here order by some field $sql = "SELECT count(custmr.customer_id) as cnt FROM ".$wpdb->prefix ."wpdev_crm_customers as custmr ORDER BY ".$sort_tag_for_table." custmr.customer_id DESC"; $result = $wpdb->get_results( $sql ); $togather_pages = ceil($result[0]->cnt / ((int) $cont_on_page)); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // S Q L $sql = "SELECT custmr.*, count(ordr.order_id) as cnt FROM ".$wpdb->prefix ."wpdev_crm_customers as custmr INNER JOIN ".$wpdb->prefix ."wpdev_crm_orders as ordr ON ordr.customer_id = custmr.customer_id GROUP by customer_id ORDER BY ".$sort_tag_for_table." custmr.customer_id DESC LIMIT " .$start_page . "," . $cont_on_page ; $result = $wpdb->get_results( $sql ); $alternative_color = ''; ?>

customer_id ) { $alternative_color = ' class="selected_row_color" '; } ?> 0 ) { ?>
"> "> "> "> "> "> "> ">
>customer_id; ?> > second_name . ' ' . $result[$i]->name; ?> >email; ?> >phone; ?> >adress; ?> >city; ?> >country; ?> > cnt; ?> > ' . $type_items[ $bk['booking_type'] ] . ''; ?> ' /> ' /> "; make_CRM_action('show_remark_editing_field',$bk['id'],$bk,"height:1px;padding:0px;margin:0px;border:none;"); ?>
 


Booking Calendar v.2.1'); ?>

', 'Booking Calendar Standard',''); ?>
settings_general_content(); switch ($_GET['tab']) { case 'main': $this->settings_general_content(); break; case 'pro': $this->settings_advanced_content(); break; case 'buy': if ( ($version == 'free') ) { ?>
showBuyWidow(); ?>


',''); ?>

',''); ?>
+

value="" name="is_delete_if_deactive"/>
value="" name="wpdev_copyright"/>
showBuyWidow(); ?>

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

Donate Buy PRO version

:

Plugin page
WordPress Extend

show_help(true); ?>

()
()
()
()
$119
Professional
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; } // Adds Settings link to plugins settings function plugin_links($links, $file) { $this_plugin = plugin_basename(__FILE__); if ($file == $this_plugin) { $settings_link = ''.__("Settings", 'wpdev-crm').''; $settings_link2 = ''.__("Buy", 'wpdev-crm').' Pro'; array_unshift($links, $settings_link2); array_unshift($links, $settings_link); } return $links; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // J a v a S c r i p t //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Files and CSS - print only at the admin pages of this plugin function on_add_admin_js_files(){ add_action('admin_head', array(&$this, 'print_JS_CSS' ), 1); } // Direct Write JS and CSS /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function print_JS_CSS(){ ?> prefix ."booking ( form, booking_type, cost ) VALUES ( '".$form."', ".$bk_type .", ".rand(0,1000)." ) ;"; $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); } } // Activate function wpdev_crm_activate(){ 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('wpdev_crm_orders') ) { // Cehck if tables not exist yet $wp_queries[] = "CREATE TABLE ".$wpdb->prefix ."wpdev_crm_orders ( order_id bigint(20) unsigned NOT NULL auto_increment, order_info text NOT NULL default '', customer_id bigint(10) NOT NULL default 1, type text NOT NULL default '', cost FLOAT(7,2) NOT NULL DEFAULT 0.00, tags bigint(10) NOT NULL default 1, order_date datetime NOT NULL default '0000-00-00 00:00:00', remark TEXT NOT NULL DEFAULT '', internal_id bigint(10) NOT NULL default 0, internal_filters text NOT NULL default '', internal_filters1 text NOT NULL default '', internal_filters2 datetime NOT NULL default '0000-00-00 00:00:00', internal_filters3 datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (order_id) ) $charset_collate;"; } if ( ! $this->is_table_exists('wpdev_crm_customers') ) { // Cehck if tables not exist yet $wp_queries[] = "CREATE TABLE ".$wpdb->prefix ."wpdev_crm_customers ( customer_id bigint(20) unsigned NOT NULL auto_increment, name varchar(255) NOT NULL default '', second_name varchar(255) NOT NULL default '', email varchar(255) NOT NULL default '', phone varchar(255) NOT NULL default '', adress text NOT NULL default '', city varchar(255) NOT NULL default '', country varchar(255) NOT NULL default '', info text NOT NULL default '', comments text NOT NULL default '', tags bigint(10) NOT NULL default 1, customer_date datetime NOT NULL default '0000-00-00 00:00:00', remark TEXT NOT NULL DEFAULT '', PRIMARY KEY (customer_id) ) $charset_collate;"; } if (count($wp_queries)>0) // Execute all SQL foreach ($wp_queries as $wp_q) $wpdb->query($wp_q); if ( strpos($_SERVER['SCRIPT_FILENAME'],'ordersplugin.onlinebookingcalendar.com') !== FALSE ) { $this->setDefaultInitialValues(); $this->setDefaultInitialValues(3); $this->setDefaultInitialValues(9); wpdev_import_booking_crm_ajax(true); } add_option( 'wpdev_crm_is_delete_if_deactive' , 'Off' ); add_option( 'wpdev_crm_copyright' , 'Off' ); add_option( 'wpdev_crm_user_role_orders', 'subscriber' ); add_option( 'wpdev_crm_user_role_customers', 'subscriber' ); add_option( 'wpdev_crm_user_role_settings', 'subscriber' ); add_option( 'wpdev_crm_rows_per_page_customers', '25' ); add_option( 'wpdev_crm_rows_per_page_orders', '25' ); make_crm_action('wpdev_crm_activation'); } // Deactivate function wpdev_crm_deactivate(){ $is_delete_if_deactive = get_option( 'wpdev_crm_is_delete_if_deactive' ); // check if ($is_delete_if_deactive == 'On') { delete_option( 'wpdev_crm_is_delete_if_deactive'); delete_option( 'wpdev_crm_copyright' ); delete_option( 'wpdev_crm_user_role_orders' ); delete_option( 'wpdev_crm_user_role_customers' ); delete_option( 'wpdev_crm_user_role_settings' ); delete_option( 'wpdev_crm_rows_per_page_customers' ); delete_option( 'wpdev_crm_rows_per_page_orders' ); global $wpdb; $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'wpdev_crm_orders'); $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'wpdev_crm_customers'); make_crm_action('wpdev_crm_deactivation'); } } } } $wpdev_crm = new wpdev_crm(); // Ajax response //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function wpdev_crm_ajax_responder() { global $wpdb; if (!function_exists ('adebug')) { function adebug() { $var = func_get_args(); echo "
"; print_r ( $var ); echo "
"; } } $action = $_POST['ajax_action_crm']; switch ( $action ) : case 'IMPORT_BOOKINGS': if (function_exists ('wpdev_import_booking_crm_ajax')) wpdev_import_booking_crm_ajax(); die(); case 'EXPORT_BOOKINGS' : if (function_exists ('wpdev_export_booking_crm_ajax')) wpdev_export_booking_crm_ajax(); die(); case 'EXPORT_ALL_BOOKINGS' : if (function_exists ('wpdev_export_booking_all_crm_ajax')) wpdev_export_booking_all_crm_ajax(); die(); default: if (function_exists ('wpdev_pro_crm_ajax')) wpdev_pro_crm_ajax(); die(); endswitch; } ?>