function wplc_pro_admin_display_history() { global $wpdb; global $wplc_tblname_chats; $results = $wpdb->get_results("\n\tSELECT *\n\tFROM {$wplc_tblname_chats}\n WHERE `status` = 1\n ORDER BY `timestamp` DESC\n\t"); echo "\n <form method=\"post\" >\n <input type=\"submit\" value=\"" . __('Delete History', 'wplivechat') . "\" class='button' name=\"wplc-delete-chat-history\" /><br /><br />\n </form>\n\n <table class=\"wp-list-table widefat fixed \" cellspacing=\"0\">\n\t<thead>\n\t<tr>\n\t\t<th scope='col' id='wplc_id_colum' class='manage-column column-id sortable desc' style=''><span>" . __("Date", "wplivechat") . "</span></th>\n <th scope='col' id='wplc_name_colum' class='manage-column column-name_title sortable desc' style=''><span>" . __("Name", "wplivechat") . "</span></th>\n <th scope='col' id='wplc_email_colum' class='manage-column column-email' style=\"\">" . __("Email", "wplivechat") . "</th>\n <th scope='col' id='wplc_url_colum' class='manage-column column-url' style=\"\">" . __("URL", "wplivechat") . "</th>\n <th scope='col' id='wplc_status_colum' class='manage-column column-status' style=\"\">" . __("Status", "wplivechat") . "</th>\n <th scope='col' id='wplc_action_colum' class='manage-column column-action sortable desc' style=\"\"><span>" . __("Action", "wplivechat") . "</span></th>\n </tr>\n\t</thead>\n <tbody id=\"the-list\" class='list:wp_list_text_link'>\n "; if (!$results) { echo "<tr><td></td><td>" . __("No chats available at the moment", "wplivechat") . "</td></tr>"; } else { foreach ($results as $result) { unset($trstyle); unset($actions); $url = admin_url('admin.php?page=wplivechat-menu&action=history&cid=' . $result->id); $actions = "<a href='{$url}' class='button' title='" . __('View Chat History', 'wplivechat') . "' target='_BLANK' id=''>" . __('View Chat History', 'wplivechat') . "</a>"; $trstyle = "style='height:30px;'"; echo "<tr id=\"record_" . $result->id . "\" {$trstyle}>"; echo "<td class='chat_id column-chat_d'>" . $result->timestamp . "</td>"; echo "<td class='chat_name column_chat_name' id='chat_name_" . $result->id . "'><img src=\"http://www.gravatar.com/avatar/" . md5($result->email) . "?s=40\" /> " . $result->name . "</td>"; echo "<td class='chat_email column_chat_email' id='chat_email_" . $result->id . "'><a href='mailto:" . $result->email . "' title='Email " . ".{$result->email}." . "'>" . $result->email . "</a></td>"; echo "<td class='chat_name column_chat_url' id='chat_url_" . $result->id . "'>" . $result->url . "</td>"; echo "<td class='chat_status column_chat_status' id='chat_status_" . $result->id . "'><strong>" . wplc_return_status($result->status) . "</strong></td>"; echo "<td class='chat_action column-chat_action' id='chat_action_" . $result->id . "'>{$actions}</td>"; echo "</tr>"; } } echo "</table>"; }
function wplc_hook_control_chat_history() { global $wpdb; global $wplc_tblname_chats; if (isset($_GET['wplc_action']) && $_GET['wplc_action'] == 'remove_cid') { if (isset($_GET['cid'])) { if (isset($_GET['wplc_confirm'])) { //Confirmed - delete $delete_sql = "\n DELETE FROM {$wplc_tblname_chats}\n WHERE `id` = '" . intval($_GET['cid']) . "'\n AND (`status` = 1 OR `status` = 8) \n "; $wpdb->query($delete_sql); if ($wpdb->last_error) { echo "<div class='update-nag' style='margin-top: 0px;margin-bottom: 5px;'>\n " . __("Error: Could not delete chat", "wp-livechat") . "<br>\n </div>"; } else { echo "<div class='update-nag' style='margin-top: 0px;margin-bottom: 5px;border-color:#67d552;'>\n " . __("Chat Deleted", "wp-livechat") . "<br>\n </div>"; } } else { //Prompt echo "<div class='update-nag' style='margin-top: 0px;margin-bottom: 5px;'>\n " . __("Are you sure you would like to delete this chat?", "wp-livechat") . "<br>\n <a class='button' href='?page=wplivechat-menu-history&wplc_action=remove_cid&cid=" . $_GET['cid'] . "&wplc_confirm=1''>" . __("Yes", "wp-livechat") . "</a> <a class='button' href='?page=wplivechat-menu-history'>" . __("No", "wp-livechat") . "</a>\n </div>"; } } } $results = $wpdb->get_results("\n SELECT *\n FROM {$wplc_tblname_chats}\n WHERE `status` = 1 OR `status` = 8\n ORDER BY `timestamp` DESC\n "); echo "\n <form method=\"post\" >\n <input type=\"submit\" value=\"" . __('Delete History', 'wplivechat') . "\" class='button' name=\"wplc-delete-chat-history\" /><br /><br />\n </form>\n\n <table class=\"wp-list-table widefat fixed \" cellspacing=\"0\">\n <thead>\n <tr>\n <th scope='col' id='wplc_id_colum' class='manage-column column-id sortable desc' style=''><span>" . __("Date", "wplivechat") . "</span></th>\n <th scope='col' id='wplc_name_colum' class='manage-column column-name_title sortable desc' style=''><span>" . __("Name", "wplivechat") . "</span></th>\n <th scope='col' id='wplc_email_colum' class='manage-column column-email' style=\"\">" . __("Email", "wplivechat") . "</th>\n <th scope='col' id='wplc_url_colum' class='manage-column column-url' style=\"\">" . __("URL", "wplivechat") . "</th>\n <th scope='col' id='wplc_status_colum' class='manage-column column-status' style=\"\">" . __("Status", "wplivechat") . "</th>\n <th scope='col' id='wplc_action_colum' class='manage-column column-action sortable desc' style=\"\"><span>" . __("Action", "wplivechat") . "</span></th>\n </tr>\n </thead>\n <tbody id=\"the-list\" class='list:wp_list_text_link'>\n "; if (!$results) { echo "<tr><td></td><td>" . __("No chats available at the moment", "wplivechat") . "</td></tr>"; } else { foreach ($results as $result) { unset($trstyle); unset($actions); $url = admin_url('admin.php?page=wplivechat-menu&action=history&cid=' . $result->id); $url2 = admin_url('admin.php?page=wplivechat-menu&action=download_history&type=csv&cid=' . $result->id); $url3 = "?page=wplivechat-menu-history&wplc_action=remove_cid&cid=" . $result->id; $actions = "\n <a href='{$url}' class='button' title='" . __('View Chat History', 'wplivechat') . "' target='_BLANK' id=''><i class='fa fa-eye'></i></a> <a href='{$url2}' class='button' title='" . __('Download Chat History', 'wplivechat') . "' target='_BLANK' id=''><i class='fa fa-download'></i></a> <a href='{$url3}' class='button'><i class='fa fa-trash-o'></i></a> \n "; $trstyle = "style='height:30px;'"; echo "<tr id=\"record_" . $result->id . "\" {$trstyle}>"; echo "<td class='chat_id column-chat_d'>" . $result->timestamp . "</td>"; echo "<td class='chat_name column_chat_name' id='chat_name_" . $result->id . "'><img src=\"//www.gravatar.com/avatar/" . md5($result->email) . "?s=40\" /> " . $result->name . "</td>"; echo "<td class='chat_email column_chat_email' id='chat_email_" . $result->id . "'><a href='mailto:" . $result->email . "' title='Email " . ".{$result->email}." . "'>" . $result->email . "</a></td>"; echo "<td class='chat_name column_chat_url' id='chat_url_" . $result->id . "'>" . esc_url($result->url) . "</td>"; echo "<td class='chat_status column_chat_status' id='chat_status_" . $result->id . "'><strong>" . wplc_return_status($result->status) . "</strong></td>"; echo "<td class='chat_action column-chat_action' id='chat_action_" . $result->id . "'>{$actions}</td>"; echo "</tr>"; } } echo "</table>"; }