.column-2 { float: left; width: 50%; border: 0; padding: 0 .5em 0 0; box-sizing: border-box; } .column-2.last { padding: 0 0 0 .5em; } @media screen and (max-width: 782px) { .column-2, .column-2.last { float: none; width: auto; padding: 0; } } '; } function activeHelper_liveHelp_mainLanguages() { global $activeHelper_liveHelp; if (!defined('WP_PLUGIN_DIR')) load_plugin_textdomain('activehelper_livehelp', $activeHelper_liveHelp['languagesDir']); else load_plugin_textdomain('activehelper_livehelp', false, $activeHelper_liveHelp['languagesDir']); } function activeHelper_liveHelp_mainInstall() { global $wpdb, $activeHelper_liveHelp; $is_installed = $wpdb->get_var(" SELECT COUNT(*) FROM {$wpdb->prefix}livehelp_domains "); $activeHelper_liveHelp['is_installed'] = $is_installed !== null; if (!$activeHelper_liveHelp['is_installed']) return activeHelper_liveHelp_install(); // Run an SQL to update Database $plugin_data = get_plugin_data( __FILE__ ); // Plugin version $plugin_version = $plugin_data['Version']; // Database version $database_version = $wpdb->get_var(" SELECT value FROM {$wpdb->prefix}livehelp_settings WHERE name = 'database_version' AND id_domain = '0' LIMIT 1 "); if (empty($database_version)) { $database_version = $plugin_version; $wpdb->query(" INSERT INTO {$wpdb->prefix}livehelp_settings (name, value, id_domain) VALUES ('database_version', '" . $plugin_version . "', 0); "); } if ( $plugin_version != $database_version ) { $new_database_version = activeHelper_liveHelp_updateDatabase($database_version, $plugin_version); $wpdb->query(" UPDATE {$wpdb->prefix}livehelp_settings SET value = '" . $new_database_version . "' WHERE name = 'database_version' AND id_domain = '0' LIMIT 1 "); } } function activeHelper_liveHelp_mainPost() { $pages = array( strtolower('activeHelper_liveHelp_domains') => 'activeHelper_liveHelp_domainsPost', strtolower('activeHelper_liveHelp_agents') => 'activeHelper_liveHelp_agentsPost', strtolower('activeHelper_liveHelp_welcome') => 'activeHelper_liveHelp_welcomePost', strtolower('activeHelper_liveHelp_monthlyChats') => 'activeHelper_liveHelp_monthlyChatsPost', strtolower('activeHelper_liveHelp_timeByChat') => 'activeHelper_liveHelp_timeByChatPost', strtolower('activeHelper_liveHelp_failedChats') => 'activeHelper_liveHelp_failedChatsPost', strtolower('activeHelper_liveHelp_unansweredChats') => 'activeHelper_liveHelp_unansweredChatsPost', strtolower('activeHelper_liveHelp_chatsByDepartment') => 'activeHelper_liveHelp_chatsByDepartmentPost', strtolower('activeHelper_liveHelp_chatsByCountry') => 'activeHelper_liveHelp_chatsByCountryPost', strtolower('activeHelper_liveHelp_chatsByKeyword') => 'activeHelper_liveHelp_chatsByKeywordPost', strtolower('activeHelper_liveHelp_offlineMessages') => 'activeHelper_liveHelp_offlineMessagesPost', strtolower('activeHelper_liveHelp_serverSettings') => 'activeHelper_liveHelp_serverSettingsPost', strtolower('activeHelper_liveHelp_about') => 'activeHelper_liveHelp_aboutPost', strtolower('activeHelper_liveHelp_restrictedCountries') => 'activeHelper_liveHelp_restrictedCountriesPost', strtolower('activehelper_livehelp_uninstall') => 'activehelper_livehelp_uninstallPost' ); if (!empty($_GET['page']) && isset($pages[$_GET['page']])) { if (empty($_REQUEST['action'])) $_REQUEST['action'] = 'list'; return $pages[$_GET['page']](); } } function activeHelper_liveHelp_mainMenu() { if (!function_exists('add_menu_page') || !function_exists('add_submenu_page')) return; // add block add_menu_page( 'LiveHelp System', // page title 'LiveHelp System', // menu title 'none', // type strtolower('activeHelper_liveHelp') // id ); add_submenu_page( strtolower('activeHelper_liveHelp'), // parent __('Dashboard', 'activehelper_livehelp') . ' ‹ ActiveHelper LiveHelp', // page title __('Dashboard', 'activehelper_livehelp'), // menu title 'manage_options', // type strtolower('activeHelper_liveHelp_welcome'), // id 'activeHelper_liveHelp_welcome' // callback ); add_submenu_page( strtolower('activeHelper_liveHelp'), // parent __('Manage domains', 'activehelper_livehelp') . ' ‹ ActiveHelper LiveHelp', // page title __('Manage domains', 'activehelper_livehelp'), // menu title 'manage_options', // type strtolower('activeHelper_liveHelp_domains'), // id 'activeHelper_liveHelp_domains' // callback ); add_submenu_page( strtolower('activeHelper_liveHelp'), // parent __('Manage agents', 'activehelper_livehelp') . ' ‹ ActiveHelper LiveHelp', // page title __('Manage agents', 'activehelper_livehelp'), // menu title 'manage_options', // type strtolower('activeHelper_liveHelp_agents'), // id 'activeHelper_liveHelp_agents' // callback ); add_submenu_page( strtolower('activeHelper_liveHelp'), // parent __('Monthly chats', 'activehelper_livehelp') . ' ‹ ActiveHelper LiveHelp', // page title __('Monthly chats', 'activehelper_livehelp'), // menu title 'manage_options', // type strtolower('activeHelper_liveHelp_monthlyChats'), // id 'activeHelper_liveHelp_monthlyChats' // callback ); add_submenu_page( strtolower('activeHelper_liveHelp'), // parent __('Time by chat', 'activehelper_livehelp') . ' ‹ ActiveHelper LiveHelp', // page title __('Time by chat', 'activehelper_livehelp'), // menu title 'manage_options', // type strtolower('activeHelper_liveHelp_timeByChat'), // id 'activeHelper_liveHelp_timeByChat' // callback ); add_submenu_page( strtolower('activeHelper_liveHelp'), // parent __('Failed chats', 'activehelper_livehelp') . ' ‹ ActiveHelper LiveHelp', // page title __('Failed chats', 'activehelper_livehelp'), // menu title 'manage_options', // type strtolower('activeHelper_liveHelp_failedChats'), // id 'activeHelper_liveHelp_failedChats' // callback ); add_submenu_page( strtolower('activeHelper_liveHelp'), // parent __('Unanswered chats', 'activehelper_livehelp') . ' ‹ ActiveHelper LiveHelp', // page title __('Unanswered chats', 'activehelper_livehelp'), // menu title 'manage_options', // type strtolower('activeHelper_liveHelp_unansweredChats'), // id 'activeHelper_liveHelp_unansweredChats' // callback ); add_submenu_page( strtolower('activeHelper_liveHelp'), // parent __('Chats by department', 'activehelper_livehelp') . ' ‹ ActiveHelper LiveHelp', // page title __('Chats by department', 'activehelper_livehelp'), // menu title 'manage_options', // type strtolower('activeHelper_liveHelp_chatsByDepartment'), // id 'activeHelper_liveHelp_chatsByDepartment' // callback ); add_submenu_page( strtolower('activeHelper_liveHelp'), // parent __('Chats by country', 'activehelper_livehelp') . ' ‹ ActiveHelper LiveHelp', // page title __('Chats by country', 'activehelper_livehelp'), // menu title 'manage_options', // type strtolower('activeHelper_liveHelp_chatsByCountry'), // id 'activeHelper_liveHelp_chatsByCountry' // callback ); add_submenu_page( strtolower('activeHelper_liveHelp'), // parent __('Chats by keyword', 'activehelper_livehelp') . ' ‹ ActiveHelper LiveHelp', // page title __('Chats by keyword', 'activehelper_livehelp'), // menu title 'manage_options', // type strtolower('activeHelper_liveHelp_chatsByKeyword'), // id 'activeHelper_liveHelp_chatsByKeyword' // callback ); add_submenu_page( strtolower('activeHelper_liveHelp'), // parent __('Offline messages', 'activehelper_livehelp') . ' ‹ ActiveHelper LiveHelp', // page title __('Offline messages', 'activehelper_livehelp'), // menu title 'manage_options', // type strtolower('activeHelper_liveHelp_offlineMessages'), // id 'activeHelper_liveHelp_offlineMessages' // callback ); add_submenu_page( strtolower('activeHelper_liveHelp'), // parent __('Server settings', 'activehelper_livehelp') . ' ‹ ActiveHelper LiveHelp', // page title __('Server settings', 'activehelper_livehelp'), // menu title 'manage_options', // type strtolower('activeHelper_liveHelp_serverSettings'), // id 'activeHelper_liveHelp_serverSettings' // callback ); add_submenu_page( strtolower('activeHelper_liveHelp'), // parent __('Not allowed countries', 'activehelper_livehelp') . ' ‹ ActiveHelper LiveHelp', // page title __('Not allowed countries', 'activehelper_livehelp'), // menu title 'manage_options', // type strtolower('activeHelper_liveHelp_restrictedCountries'), // id 'activeHelper_liveHelp_restrictedCountries' // callback ); add_submenu_page( strtolower('activeHelper_liveHelp'), // parent __('About', 'activehelper_livehelp') . ' ‹ ActiveHelper LiveHelp', // page title __('About', 'activehelper_livehelp'), // menu title 'manage_options', // type strtolower('activeHelper_liveHelp_about'), // id 'activeHelper_liveHelp_about' // callback ); add_submenu_page( strtolower('activeHelper_liveHelp'), // parent __('Uninstall', 'activehelper_livehelp') . ' ‹ ActiveHelper LiveHelp', // page title __('Uninstall', 'activehelper_livehelp'), // menu title 'manage_options', // type strtolower('activehelper_livehelp_uninstall'), // id 'activehelper_livehelp_uninstall' // callback ); } function activeHelper_liveHelp_welcomePost() { wp_enqueue_style('dashboard'); } function activeHelper_liveHelp_welcome() { global $wpdb, $activeHelper_liveHelp; $montly_chats = $wpdb->get_var(" SELECT count(*) chats FROM {$wpdb->prefix}livehelp_sessions where `datetime` between DATE_FORMAT(CURDATE(), '%Y-%m-01') and LAST_DAY(DATE_FORMAT(CURDATE(), '%Y-%m-%d')) "); $last_month_chats = $wpdb->get_var(" SELECT count(*) chats FROM {$wpdb->prefix}livehelp_sessions WHERE datetime >= DATE_FORMAT( CURRENT_DATE - INTERVAL 1 MONTH, '%Y/%m/01' ) AND datetime < DATE_FORMAT( CURRENT_DATE, '%Y/%m/01' ) "); $last_week_chats = $wpdb->get_var(" SELECT count(*) chats FROM {$wpdb->prefix}livehelp_sessions WHERE datetime >= DATE_SUB(DATE(NOW()), INTERVAL DAYOFWEEK(NOW())+6 DAY) AND datetime < DATE_SUB(DATE(NOW()), INTERVAL DAYOFWEEK(NOW())-1 DAY) "); $current_week_chats = $wpdb->get_var(" SELECT count(*) chats FROM {$wpdb->prefix}livehelp_sessions WHERE WEEK(datetime) = WEEK(CURRENT_DATE()) AND DAYOFWEEK(datetime) IN (1,2,3,4,5,6,7) "); $current_week_offline_messages = $wpdb->get_var(" SELECT COUNT(*) messages FROM {$wpdb->prefix}livehelp_offline_messages WHERE WEEK(datetime) = WEEK(CURRENT_DATE()) AND DAYOFWEEK(datetime) IN (1,2,3,4,5,6,7) "); $last_month_offline_messages = $wpdb->get_var(" SELECT COUNT(*) messages FROM {$wpdb->prefix}livehelp_offline_messages WHERE datetime >= DATE_FORMAT( CURRENT_DATE - INTERVAL 1 MONTH, '%Y/%m/01' ) AND datetime < DATE_FORMAT( CURRENT_DATE, '%Y/%m/01' ) "); $weekly_failed_chats = $wpdb->get_var(" SELECT COUNT(jls.id) FROM {$wpdb->prefix}livehelp_sessions jls WHERE WEEK(jls.datetime) = WEEK(CURRENT_DATE()) AND DAYOFWEEK(jls.datetime) IN (2,3,4,5,6) and jls.active <> 0 and jls.id not in (SELECT jlm.session FROM {$wpdb->prefix}livehelp_messages jlm where WEEK(jlm.datetime) = WEEK(CURRENT_DATE()) AND DAYOFWEEK(jlm.datetime) IN (2,3,4,5,6)) "); $weekly_unanswred_chats = $wpdb->get_var(" SELECT count(jls.id) FROM {$wpdb->prefix}livehelp_sessions jls WHERE WEEK(jls.datetime) = WEEK(CURRENT_DATE()) AND DAYOFWEEK(jls.datetime) IN (2,3,4,5,6) and jls.active = 0 "); $domains = $wpdb->get_var(" SELECT COUNT(*) FROM {$wpdb->prefix}livehelp_domains "); $agents = $wpdb->get_var(" SELECT COUNT(*) FROM {$wpdb->prefix}livehelp_users "); $departments = $wpdb->get_var(" SELECT COUNT(*) FROM ( SELECT department FROM {$wpdb->prefix}livehelp_users GROUP BY department ) AS t "); $chats = $wpdb->get_var(" SELECT COUNT(*) FROM {$wpdb->prefix}livehelp_sessions "); $chats_today = $wpdb->get_var(" SELECT COUNT(*) FROM {$wpdb->prefix}livehelp_sessions AS ls WHERE DATE_FORMAT(ls.datetime, '%m/%d/%Y') = DATE_FORMAT(now(), '%m/%d/%Y') "); $visitors_today = $wpdb->get_var(" SELECT COUNT(*) FROM {$wpdb->prefix}livehelp_requests AS ls WHERE DATE_FORMAT(ls.datetime, '%m/%d/%Y') = DATE_FORMAT(now(), '%m/%d/%Y') "); $latest_aggent = $wpdb->get_var(" SELECT username FROM {$wpdb->prefix}livehelp_users ORDER BY refresh DESC LIMIT 1 "); $oldest_aggent = $wpdb->get_var(" SELECT username FROM {$wpdb->prefix}livehelp_users ORDER BY refresh ASC LIMIT 1 "); $fail_chats = $wpdb->get_var(" SELECT COUNT(*) FROM {$wpdb->prefix}livehelp_messages AS lm RIGHT JOIN {$wpdb->prefix}livehelp_sessions AS ls ON (ls.id = lm.session) WHERE lm.username IS NULL AND lm.message IS NULL "); $avg_chat_rating = $wpdb->get_var(" SELECT IFNULL(AVG(rating), 0) FROM {$wpdb->prefix}livehelp_sessions WHERE rating != -1 "); $rowsdomains = $wpdb->get_results(" SELECT jld.name, COUNT(jls.id) AS value FROM {$wpdb->prefix}livehelp_sessions AS jls, {$wpdb->prefix}livehelp_domains AS jld WHERE jls.id_domain = jld.id_domain GROUP BY jls.id_domain LIMIT 5 ", ARRAY_A); $rowsagents = $wpdb->get_results(" SELECT jlu.username AS name, COUNT(jls.id) AS value FROM {$wpdb->prefix}livehelp_sessions AS jls, {$wpdb->prefix}livehelp_users AS jlu WHERE jls.id_user = jlu.id GROUP BY jlu.username LIMIT 5 ", ARRAY_A); $rowsagents_rating = $wpdb->get_results(" SELECT jlu.username AS name, IFNULL(AVG(IF(jls.rating = -1, NULL, jls.rating)), 0) AS value FROM {$wpdb->prefix}livehelp_sessions AS jls, {$wpdb->prefix}livehelp_users AS jlu WHERE jls.id_user = jlu.id GROUP BY jlu.username LIMIT 5 ", ARRAY_A); $rowuser_avg = $wpdb->get_results(" SELECT CONCAT(jls.username, ' (', jls.email, ')') AS name, COUNT(jls.id) AS value FROM {$wpdb->prefix}livehelp_sessions AS jls GROUP BY jls.email LIMIT 5 ", ARRAY_A); $rowsagents_duration = $wpdb->get_results(" SELECT t1.name, SEC_TO_TIME(SUM(TIME_TO_SEC(Time))) AS value FROM ( SELECT b.username AS name, TIMEDIFF(c.refresh, c.datetime) AS Time FROM {$wpdb->prefix}livehelp_users AS b, {$wpdb->prefix}livehelp_sessions AS c WHERE c.id_user = b.id AND DATE_FORMAT(c.datetime,'%Y%m%d') >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) AND DATE_FORMAT(c.datetime,'%Y%m%d') <= CURDATE() GROUP BY c.id ORDER BY CONCAT(b.firstname, ' ', b.lastname) ) AS t1 GROUP BY t1.name LIMIT 5 ", ARRAY_A); echo '