'activeHelper_liveHelp_unansweredChatsList' ); if (!empty($_REQUEST['action']) && isset($actions[$_REQUEST['action']])) return $actions[$_REQUEST['action']](); return $actions['list'](); } function activeHelper_liveHelp_unansweredChatsPost() { $actions = array( 'export' => 'activeHelper_liveHelp_unansweredChatsExportPost', 'list' => 'activeHelper_liveHelp_unansweredChatsListPost' ); if (!empty($_REQUEST['action']) && isset($actions[$_REQUEST['action']])) return $actions[$_REQUEST['action']](); if (empty($_REQUEST['action'])) return $actions['list'](); } function activeHelper_liveHelp_unansweredChatsExportPost() { global $wpdb, $activeHelper_liveHelp; $timeEnd = !empty($_REQUEST['export_end_date']) ? strtotime((string) $_REQUEST['export_end_date']) : time(); $timeStart = !empty($_REQUEST['export_start_date']) ? strtotime((string) $_REQUEST['export_start_date']) : mktime(0, 0, 0, date("n", $timeEnd) - 1, date("j", $timeEnd), date("Y", $timeEnd)); $unansweredChatsList = $wpdb->get_results(" SELECT jls.id , jls.username, jls.email , jls.server , jls.department , jls.datetime FROM {$wpdb->prefix}livehelp_sessions AS jls, {$wpdb->prefix}livehelp_messages AS jlm WHERE DATE_FORMAT(jls.datetime, '%Y%m%d') >= DATE_FORMAT('" . date("Y-m-d", $timeStart) . "', '%Y%m%d') AND DATE_FORMAT(jls.datetime, '%Y%m%d') <= DATE_FORMAT('" . date("Y-m-d", $timeEnd) . "', '%Y%m%d') AND jls.active = 0 and jls.id not in ( jlm.session ) group by jls.id order by jls.id desc", ARRAY_A); $export = '"id","username","email","department","server","Date"'; if (!empty($unansweredChatsList)) foreach ($unansweredChatsList as $unansweredChats) { $export .= "\n" . '"' . $unansweredChats['id'] . '","' . $unansweredChats['username'] . '","' . $unansweredChats['email'] . '","' . $unansweredChats['department'] . '","' . $unansweredChats['server'] . '","' . $unansweredChats['date'] . '"'; } header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Disposition: attachment; filename=LiveHelp_unansweredChats_" . date("Y-m-d", $timeStart) . "~" . date("Y-m-d", $timeEnd) . ".csv"); header("Content-Type: text/csv; text/comma-separated-values"); header("Content-Transfer-Encoding: binary"); echo $export; exit(); } function activeHelper_liveHelp_unansweredChatsListPost() { global $wpdb, $activeHelper_liveHelp; wp_enqueue_script('jquery'); wp_enqueue_script('jquery-ui-core'); wp_enqueue_script('jquery-ui-datepicker', $activeHelper_liveHelp['baseUrl'] . '/scripts/jquery.ui.datepicker.min.js', array('jquery', 'jquery-ui-core') ); wp_enqueue_style('jquery.ui.theme', $activeHelper_liveHelp['baseUrl'] . '/scripts/smoothness/jquery-ui-1.8.16.custom.css'); } function activeHelper_liveHelp_unansweredChatsList() { global $wpdb, $activeHelper_liveHelp; $timeEnd = !empty($_REQUEST['export_end_date']) ? strtotime((string) $_REQUEST['export_end_date']) : time(); $timeStart = !empty($_REQUEST['export_start_date']) ? strtotime((string) $_REQUEST['export_start_date']) : mktime(0, 0, 0, date("n", $timeEnd) - 1, date("j", $timeEnd), date("Y", $timeEnd)); $unansweredChatsList = $wpdb->get_results(" SELECT jls.id, jls.username , jls.email , jls.server , jls.department , jls.datetime FROM {$wpdb->prefix}livehelp_sessions AS jls, {$wpdb->prefix}livehelp_messages AS jlm WHERE DATE_FORMAT(jls.datetime, '%Y%m%d') >= DATE_FORMAT('" . date("Y-m-d", $timeStart) . "', '%Y%m%d') AND DATE_FORMAT(jls.datetime, '%Y%m%d') <= DATE_FORMAT('" . date("Y-m-d", $timeEnd) . "', '%Y%m%d') AND jls.active = 0 and jls.id not in ( jlm.session ) group by jls.id order by jls.id desc ", ARRAY_A); echo '

LiveHelp ยป ' . __('unanswered chats', 'activehelper_livehelp') . ' ' . __('export to CSV', 'activehelper_livehelp') . '

'; echo '
'; if (empty($unansweredChatsList)) echo ' '; else { $alternate = false; foreach ($unansweredChatsList as $unansweredChats) { echo ' '; $alternate = !$alternate; } } echo '
' . __('ID', 'activehelper_livehelp') . ' ' . __('Username', 'activehelper_livehelp') . ' ' . __('Email', 'activehelper_livehelp') . ' ' . __('Department', 'activehelper_livehelp') . ' ' . __('Domain name', 'activehelper_livehelp') . ' ' . __('Date', 'activehelper_livehelp') . '
' . __('ID', 'activehelper_livehelp') . ' ' . __('Username', 'activehelper_livehelp') . ' ' . __('Email', 'activehelper_livehelp') . ' ' . __('Department', 'activehelper_livehelp') . ' ' . __('Domain name', 'activehelper_livehelp') . ' ' . __('Date', 'activehelper_livehelp') . '

' . sprintf(__('No %s found.', 'activehelper_livehelp'), __('chats', 'activehelper_livehelp')) . '

' . $unansweredChats['id'] . ' ' . $unansweredChats['username'] . ' ' . $unansweredChats['email'] . ' ' . $unansweredChats['department'] . ' ' . $unansweredChats['server'] . ' ' . $unansweredChats['datetime'] . '
'; }