| 1 |
<?php if ( ! defined( 'ABSPATH' ) ) { exit; } ?> |
| 2 |
|
| 3 |
<?php |
| 4 |
global $wpdb; |
| 5 |
|
| 6 |
$tableuser = $wpdb->prefix . 'wpbot_user'; |
| 7 |
$tableconversation = $wpdb->prefix . 'wpbot_conversation'; |
| 8 |
$table_user_sql = '`' . esc_sql( $tableuser ) . '`'; |
| 9 |
$table_conv_sql = '`' . esc_sql( $tableconversation ) . '`'; |
| 10 |
$userid = isset( $_GET['userid'] ) ? absint( wp_unslash( $_GET['userid'] ) ) : 0; // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 11 |
|
| 12 |
$userinfo = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$table_user_sql} WHERE id = %d", $userid ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter |
| 13 |
|
| 14 |
$delurl = wp_nonce_url( admin_url( 'admin.php?page=wbcs-botsessions-page&userid=' . $userinfo->id . '&act=delete' ), 'wpcs_delete_session_' . $userinfo->id ); |
| 15 |
|
| 16 |
$export = wp_nonce_url( admin_url( 'admin-post.php?action=wpbot_conversations.csv&user_id=' . $userid ), 'wpbot_conversations_csv' ); |
| 17 |
|
| 18 |
wp_register_style( 'qcld-wp-chatbot-history-style', QCLD_wpCHATBOT_HISTORY_PLUGIN_URL . '/css/history-style.css', '', QCLD_wpCHATBOT_VERSION, 'screen' ); |
| 19 |
wp_enqueue_style( 'qcld-wp-chatbot-history-style' ); |
| 20 |
?> |
| 21 |
|
| 22 |
<div class="wpbot-session-details-page"> |
| 23 |
<div class="sld_menu_title qcld_session_history_result wpbot-session-meta-card"> |
| 24 |
<div class="wpbot-session-meta-card__header"> |
| 25 |
<h2><?php echo esc_html__( 'Session Details', 'chatbot' ); ?></h2> |
| 26 |
<div class="wpbot-session-meta-card__actions"> |
| 27 |
<a href="<?php echo esc_url( $delurl ); ?>" class="btn btn-danger" onclick="return confirm('Are you sure?')"> |
| 28 |
<?php echo esc_html__( 'Delete', 'chatbot' ); ?> |
| 29 |
</a> |
| 30 |
<a href="<?php echo esc_url( $export ); ?>" class="btn btn-primary"> |
| 31 |
<?php echo esc_html__( 'Export', 'chatbot' ); ?> |
| 32 |
</a> |
| 33 |
</div> |
| 34 |
</div> |
| 35 |
|
| 36 |
<div class="wpbot-session-meta-grid"> |
| 37 |
<div class="wpbot-session-meta-item"> |
| 38 |
<span class="wpbot-session-meta-item__label"><?php echo esc_html__( 'Session ID', 'chatbot' ); ?></span> |
| 39 |
<span class="wpbot-session-meta-item__value"><?php echo ( $userinfo->session_id != '' ) ? esc_html( $userinfo->session_id ) : '---'; ?></span> |
| 40 |
</div> |
| 41 |
<div class="wpbot-session-meta-item"> |
| 42 |
<span class="wpbot-session-meta-item__label"><?php echo esc_html__( 'User Name', 'chatbot' ); ?></span> |
| 43 |
<span class="wpbot-session-meta-item__value"><?php echo esc_html( $userinfo->name ? $userinfo->name : '---' ); ?></span> |
| 44 |
</div> |
| 45 |
<div class="wpbot-session-meta-item"> |
| 46 |
<span class="wpbot-session-meta-item__label"><?php echo esc_html__( 'User Email', 'chatbot' ); ?></span> |
| 47 |
<span class="wpbot-session-meta-item__value"><?php echo ( $userinfo->email != '' ) ? esc_html( $userinfo->email ) : '---'; ?></span> |
| 48 |
</div> |
| 49 |
<div class="wpbot-session-meta-item"> |
| 50 |
<span class="wpbot-session-meta-item__label"><?php echo esc_html__( 'Phone Number', 'chatbot' ); ?></span> |
| 51 |
<span class="wpbot-session-meta-item__value"><?php echo ( $userinfo->phone != '' ) ? esc_html( $userinfo->phone ) : '---'; ?></span> |
| 52 |
</div> |
| 53 |
<div class="wpbot-session-meta-item"> |
| 54 |
<span class="wpbot-session-meta-item__label"><?php echo esc_html__( 'Date and Time', 'chatbot' ); ?></span> |
| 55 |
<span class="wpbot-session-meta-item__value"><?php echo esc_html( gmdate( 'M d, Y h:i:s A', strtotime( $userinfo->date ) ) ); ?></span> |
| 56 |
</div> |
| 57 |
</div> |
| 58 |
</div> |
| 59 |
|
| 60 |
<?php |
| 61 |
$result = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$table_conv_sql} WHERE user_id = %d", $userid ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared |
| 62 |
|
| 63 |
if ( ! empty( $result ) ) : |
| 64 |
|
| 65 |
$qcld_wb_chatbot_theme = get_option( 'qcld_wb_chatbot_theme' ); |
| 66 |
|
| 67 |
if ( file_exists( QCLD_wpCHATBOT_PLUGIN_DIR_PATH . '/templates/' . $qcld_wb_chatbot_theme . '/style.css' ) ) { |
| 68 |
wp_register_style( 'qcld-wp-chatbot-style', QCLD_wpCHATBOT_PLUGIN_URL . '/templates/' . $qcld_wb_chatbot_theme . '/style.css', '', QCLD_wpCHATBOT_VERSION, 'screen' ); |
| 69 |
wp_enqueue_style( 'qcld-wp-chatbot-style' ); |
| 70 |
} |
| 71 |
|
| 72 |
wp_enqueue_style( 'qcld-wp-chatbot-jquery-ui' ); |
| 73 |
wp_register_style( 'qcld-wp-chatbot-jquery-ui', QCLD_wpCHATBOT_HISTORY_PLUGIN_URL . '/css/jqueryui.css', '', '', 'screen' ); |
| 74 |
wp_register_style( 'qcld-wp-chatbot-common-style', QCLD_wpCHATBOT_PLUGIN_URL . '/css/common-style.css', '', QCLD_wpCHATBOT_VERSION, 'screen' ); |
| 75 |
wp_enqueue_style( 'qcld-wp-chatbot-common-style' ); |
| 76 |
?> |
| 77 |
|
| 78 |
<div class="single-chat-container-wrapper wpbot-session-chat-card"> |
| 79 |
<div class="wpbot-session-chat-card__header"> |
| 80 |
<h3><?php echo esc_html__( 'Chat Messages', 'chatbot' ); ?></h3> |
| 81 |
<a href="<?php echo esc_url( admin_url( 'admin.php?page=wbcs-botsessions-page' ) ); ?>" class="btn btn-primary wpbot-session-back-btn"> |
| 82 |
<?php echo esc_html__( 'Conversation List', 'chatbot' ); ?> |
| 83 |
</a> |
| 84 |
</div> |
| 85 |
<div class="wp-chatbot-messages-wrapper"> |
| 86 |
<?php |
| 87 |
$allowed_html = array_merge( |
| 88 |
wp_kses_allowed_html( 'post' ), |
| 89 |
array( |
| 90 |
'div' => array( |
| 91 |
'class' => true, |
| 92 |
'id' => true, |
| 93 |
'style' => true, |
| 94 |
'data-*' => true, |
| 95 |
), |
| 96 |
'span' => array( |
| 97 |
'class' => true, |
| 98 |
'id' => true, |
| 99 |
'style' => true, |
| 100 |
'data-*' => true, |
| 101 |
), |
| 102 |
'ul' => array( 'class' => true ), |
| 103 |
'li' => array( 'class' => true ), |
| 104 |
'img' => array( |
| 105 |
'src' => true, |
| 106 |
'alt' => true, |
| 107 |
'class' => true, |
| 108 |
'style' => true, |
| 109 |
), |
| 110 |
) |
| 111 |
); |
| 112 |
echo wp_kses( htmlspecialchars_decode( $result->conversation ), $allowed_html ); |
| 113 |
?> |
| 114 |
</div> |
| 115 |
</div> |
| 116 |
|
| 117 |
<button type="button" class="wpbot-reply-fab" id="wpbot_reply_fab" aria-expanded="false" aria-controls="wpbot_reply_panel"> |
| 118 |
|
| 119 |
<span><?php echo esc_html__( 'Reply via Email', 'chatbot' ); ?></span> |
| 120 |
</button> |
| 121 |
|
| 122 |
<div class="wpbot-reply-panel" id="wpbot_reply_panel" hidden> |
| 123 |
<div class="wpbot-reply-panel__header"> |
| 124 |
<h4><?php echo esc_html__( 'Reply via Email', 'chatbot' ); ?></h4> |
| 125 |
<button type="button" class="wpbot-reply-panel__close" id="wpbot_reply_panel_close" aria-label="<?php esc_attr_e( 'Close', 'chatbot' ); ?>">×</button> |
| 126 |
</div> |
| 127 |
<div class="wpbot-reply-panel__body"> |
| 128 |
<?php if ( ! empty( $userinfo->email ) ) : ?> |
| 129 |
<div class="email-reply-container"> |
| 130 |
<p class="wpbot-reply-panel__to"><?php echo esc_html__( 'To:', 'chatbot' ); ?> <strong><?php echo esc_html( $userinfo->email ); ?></strong></p> |
| 131 |
<div class="form-group mb-3"> |
| 132 |
<label for="reply_subject" class="form-label"><?php echo esc_html__( 'Subject', 'chatbot' ); ?></label> |
| 133 |
<input type="text" id="reply_subject" class="form-control" placeholder="<?php esc_attr_e( 'Reply to your chat session', 'chatbot' ); ?>"> |
| 134 |
</div> |
| 135 |
<div class="form-group mb-3"> |
| 136 |
<label for="reply_message" class="form-label"><?php echo esc_html__( 'Message', 'chatbot' ); ?></label> |
| 137 |
<textarea id="reply_message" class="form-control" rows="4" placeholder="<?php esc_attr_e( 'Type your reply here...', 'chatbot' ); ?>"></textarea> |
| 138 |
</div> |
| 139 |
<button type="button" class="btn btn-primary" id="btn_send_reply_email" data-email="<?php echo esc_attr( $userinfo->email ); ?>"><?php echo esc_html__( 'Send Reply', 'chatbot' ); ?></button> |
| 140 |
</div> |
| 141 |
<?php else : ?> |
| 142 |
<p class="wpbot-reply-panel__warning"><?php echo esc_html__( 'No user email available for this session.', 'chatbot' ); ?></p> |
| 143 |
<?php endif; ?> |
| 144 |
<div class="forward-session-wrapper"> |
| 145 |
<input type="hidden" id="details_session_id" value="<?php echo esc_attr( $userinfo->session_id ); ?>"> |
| 146 |
<input type="email" id="details_session_email" class="form-control" placeholder="<?php esc_attr_e( 'Enter email to forward session details', 'chatbot' ); ?>"> |
| 147 |
<span class="btn btn-secondary forward_session"><?php echo esc_html__( 'Forward Session', 'chatbot' ); ?></span> |
| 148 |
</div> |
| 149 |
</div> |
| 150 |
</div> |
| 151 |
|
| 152 |
<script> |
| 153 |
(function () { |
| 154 |
var fab = document.getElementById('wpbot_reply_fab'); |
| 155 |
var panel = document.getElementById('wpbot_reply_panel'); |
| 156 |
var closeBtn = document.getElementById('wpbot_reply_panel_close'); |
| 157 |
if (!fab || !panel) { |
| 158 |
return; |
| 159 |
} |
| 160 |
function openPanel() { |
| 161 |
panel.hidden = false; |
| 162 |
panel.classList.add('is-open'); |
| 163 |
fab.setAttribute('aria-expanded', 'true'); |
| 164 |
fab.classList.add('is-active'); |
| 165 |
} |
| 166 |
function closePanel() { |
| 167 |
panel.classList.remove('is-open'); |
| 168 |
fab.setAttribute('aria-expanded', 'false'); |
| 169 |
fab.classList.remove('is-active'); |
| 170 |
window.setTimeout(function () { |
| 171 |
if (!panel.classList.contains('is-open')) { |
| 172 |
panel.hidden = true; |
| 173 |
} |
| 174 |
}, 220); |
| 175 |
} |
| 176 |
fab.addEventListener('click', function () { |
| 177 |
if (panel.classList.contains('is-open')) { |
| 178 |
closePanel(); |
| 179 |
} else { |
| 180 |
openPanel(); |
| 181 |
} |
| 182 |
}); |
| 183 |
if (closeBtn) { |
| 184 |
closeBtn.addEventListener('click', closePanel); |
| 185 |
} |
| 186 |
document.addEventListener('keydown', function (e) { |
| 187 |
if (e.key === 'Escape' && panel.classList.contains('is-open')) { |
| 188 |
closePanel(); |
| 189 |
} |
| 190 |
}); |
| 191 |
})(); |
| 192 |
</script> |
| 193 |
<?php endif; ?> |
| 194 |
</div> |
| 195 |
|