← All changes
|
includes/chat-sessions/reports/view/reporting-highlights.php
+373
-442
8.5.6
→
8.8.0
View file →
| @@ -1,442 +1,373 @@ | ||
| 1 | -<?php if ( ! defined( 'ABSPATH' ) ) { exit; } ?> | |
| 2 | -<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous"> | |
| 3 | - | |
| 4 | -<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css" integrity="sha384-4LISF5TTJX/fLmGSxO53rV4miRxdg84mZsxmO8Rx5jGtp/LbrixFETvWa5a6sESd" crossorigin="anonymous"> | |
| 5 | - | |
| 6 | -<link href="<?php echo esc_url( QCLD_wpCHATBOT_HISTORY_PLUGIN_URL . '/reports/view/assets/style.css' ); ?>" rel="stylesheet"> | |
| 7 | - | |
| 8 | -<main id="main" class="main clearfix"> | |
| 9 | - | |
| 10 | - <div class="pagetitle"> | |
| 11 | - <h1>Bot - Reporting Dashboard</h1> | |
| 12 | - </div><!-- End Page Title --> | |
| 13 | - | |
| 14 | - <section class="section dashboard"> | |
| 15 | - <div class="row"> | |
| 16 | - | |
| 17 | - <!-- Left side columns --> | |
| 18 | - <div class="col-lg-12"> | |
| 19 | - <div class="row"> | |
| 20 | - | |
| 21 | - <!-- Card 1 --> | |
| 22 | - <div class="col-xxl-4 col-md-6"> | |
| 23 | - <div class="card info-card sales-card"> | |
| 24 | - | |
| 25 | - <div class="card-body"> | |
| 26 | - <h5 class="card-title">Total Conversations</span></h5> | |
| 27 | - | |
| 28 | - <div class="d-flex align-items-center"> | |
| 29 | - <div class="card-icon rounded-circle d-flex align-items-center justify-content-center"> | |
| 30 | - <i class="bi bi-wechat"></i> | |
| 31 | - </div> | |
| 32 | - <div class="ps-3"> | |
| 33 | - <h6> | |
| 34 | - <?php echo intval( botreports_get_total_conversation_count() ); ?> | |
| 35 | - </h6> | |
| 36 | - <span class="text-success small pt-1 fw-bold"> | |
| 37 | - <?php echo intval( botreports_get_todays_conversation_count() ); ?> | |
| 38 | - </span> | |
| 39 | - <span class="text-muted small pt-2 ps-1">Today</span>, | |
| 40 | - <span class="text-success small pt-1 fw-bold"> | |
| 41 | - <?php echo intval( botreports_get_weeks_conversation_count() ); ?> | |
| 42 | - </span> | |
| 43 | - <span class="text-muted small pt-2 ps-1">Last Week</span> | |
| 44 | - | |
| 45 | - </div> | |
| 46 | - </div> | |
| 47 | - </div> | |
| 48 | - | |
| 49 | - </div> | |
| 50 | - </div><!-- End Card 1 --> | |
| 51 | - <!-- Card 1 --> | |
| 52 | -<div class="col-xxl-4 col-md-6"> | |
| 53 | - <div class="card info-card sales-card feedback-card" data-type="like" style="cursor:pointer;"> | |
| 54 | - <div class="card-body"> | |
| 55 | - <h5 class="card-title">Positive Feedback</h5> | |
| 56 | - <div class="d-flex align-items-center"> | |
| 57 | - <div class="card-icon rounded-circle d-flex align-items-center justify-content-center"> | |
| 58 | - <i class="bi bi-hand-thumbs-up"></i> | |
| 59 | - </div> | |
| 60 | - <div class="ps-3"> | |
| 61 | - <h6><?php echo intval( wpbot_get_report_stats_count()['likes'] ); ?></h6> | |
| 62 | - </div> | |
| 63 | - </div> | |
| 64 | - </div> | |
| 65 | - </div> | |
| 66 | -</div> | |
| 67 | - | |
| 68 | -<div class="col-xxl-4 col-md-6"> | |
| 69 | - <div class="card info-card sales-card feedback-card" data-type="dislike" style="cursor:pointer;"> | |
| 70 | - <div class="card-body"> | |
| 71 | - <h5 class="card-title">Negative Feedback</h5> | |
| 72 | - <div class="d-flex align-items-center"> | |
| 73 | - <div class="card-icon rounded-circle d-flex align-items-center justify-content-center"> | |
| 74 | - <i class="bi bi-hand-thumbs-down"></i> | |
| 75 | - </div> | |
| 76 | - <div class="ps-3"> | |
| 77 | - <h6><?php echo intval( wpbot_get_report_stats_count()['dislikes'] ); ?></h6> | |
| 78 | - </div> | |
| 79 | - </div> | |
| 80 | - </div> | |
| 81 | - </div> | |
| 82 | -</div> | |
| 83 | -<div id="feedback-results" style="margin-top:30px;"></div> | |
| 84 | - | |
| 85 | - | |
| 86 | - | |
| 87 | - <!-- Card 2 --> | |
| 88 | - <div class="col-xxl-4 col-md-6"> | |
| 89 | - <div class="card info-card sales-card"> | |
| 90 | - | |
| 91 | - <div class="card-body"> | |
| 92 | - <h5 class="card-title">Conversations in Last 30 Days</span></h5> | |
| 93 | - | |
| 94 | - <div class="d-flex align-items-center"> | |
| 95 | - <div class="card-icon rounded-circle d-flex align-items-center justify-content-center"> | |
| 96 | - <i class="bi bi-bar-chart-steps"></i> | |
| 97 | - </div> | |
| 98 | - <div class="ps-3"> | |
| 99 | - <h6> | |
| 100 | - <?php echo intval( botreports_get_last30days_conversation_count() ); ?> | |
| 101 | - </h6> | |
| 102 | - </div> | |
| 103 | - </div> | |
| 104 | - </div> | |
| 105 | - | |
| 106 | - </div> | |
| 107 | - </div><!-- End Card 2 --> | |
| 108 | - | |
| 109 | - <!-- Card 3 --> | |
| 110 | - <div class="col-xxl-4 col-md-6"> | |
| 111 | - <div class="card info-card sales-card"> | |
| 112 | - | |
| 113 | - <div class="card-body"> | |
| 114 | - <h5 class="card-title">Average Daily Conversation</span></h5> | |
| 115 | - | |
| 116 | - <div class="d-flex align-items-center"> | |
| 117 | - <div class="card-icon rounded-circle d-flex align-items-center justify-content-center"> | |
| 118 | - <i class="bi bi-bar-chart"></i> | |
| 119 | - </div> | |
| 120 | - <div class="ps-3"> | |
| 121 | - <h6><?php echo esc_html( botreports_get_last30days_conversation_average() ); ?></h6> | |
| 122 | - <span class="text-muted small">In</span> | |
| 123 | - <span class="text-success small pt-1 fw-bold">Last 30</span> | |
| 124 | - <span class="text-muted small pt-2 ps-1">Days</span> | |
| 125 | - </div> | |
| 126 | - </div> | |
| 127 | - </div> | |
| 128 | - | |
| 129 | - </div> | |
| 130 | - </div><!-- End Card 3 --> | |
| 131 | - | |
| 132 | - <?php | |
| 133 | - echo '<pre>'; | |
| 134 | - botreports_get_last30days_conversation_density(); | |
| 135 | - echo '</pre>'; | |
| 136 | - ?> | |
| 137 | - | |
| 138 | - <!-- Reports: Conversation Density Chart --> | |
| 139 | - <div class="col-lg-12"> | |
| 140 | - <div class="card" style="max-width: 100% !important;"> | |
| 141 | - <div class="card-body"> | |
| 142 | - <h5 class="card-title">Conversation Density Chart</h5> | |
| 143 | - | |
| 144 | - <!-- Area Chart --> | |
| 145 | - <div id="areaChart" style="min-height: 365px;"> | |
| 146 | - <div id="apexchartsa0c3a8xu" class="apexcharts-canvas apexchartsa0c3a8xu apexcharts-theme-light"> | |
| 147 | - | |
| 148 | - </div> | |
| 149 | - <div class="apexcharts-menu"> | |
| 150 | - <div class="apexcharts-menu-item exportSVG" title="Download SVG">Download SVG</div> | |
| 151 | - <div class="apexcharts-menu-item exportPNG" title="Download PNG">Download PNG</div> | |
| 152 | - <div class="apexcharts-menu-item exportCSV" title="Download CSV">Download CSV</div> | |
| 153 | - </div> | |
| 154 | - </div> | |
| 155 | - | |
| 156 | - <?php | |
| 157 | - | |
| 158 | - $densityTable = botreports_get_last30days_conversation_density(); | |
| 159 | - | |
| 160 | - $dates = array(); | |
| 161 | - $conversation_count_in_date = array(); | |
| 162 | - | |
| 163 | - foreach ( $densityTable as $data ) { | |
| 164 | - array_push( $dates, $data->CONVERSATION_DATE ); | |
| 165 | - array_push( $conversation_count_in_date, $data->CONVERSATION_NUM ); | |
| 166 | - } | |
| 167 | - | |
| 168 | - ?> | |
| 169 | - | |
| 170 | - <script> | |
| 171 | - document.addEventListener("DOMContentLoaded", () => { | |
| 172 | - const series = { | |
| 173 | - "monthDataSeries1": { | |
| 174 | - "count": <?php echo json_encode( $conversation_count_in_date ); ?>, | |
| 175 | - "dates": <?php echo json_encode( $dates ); ?>, | |
| 176 | - }, | |
| 177 | - } | |
| 178 | - new ApexCharts(document.querySelector("#areaChart"), { | |
| 179 | - series: [{ | |
| 180 | - name: "Conversation Count: ", | |
| 181 | - data: series.monthDataSeries1.count | |
| 182 | - }], | |
| 183 | - chart: { | |
| 184 | - type: 'bar', | |
| 185 | - height: 350, | |
| 186 | - zoom: { | |
| 187 | - enabled: false | |
| 188 | - } | |
| 189 | - }, | |
| 190 | - plotOptions: { | |
| 191 | - bar: { | |
| 192 | - horizontal: false | |
| 193 | - } | |
| 194 | - }, | |
| 195 | - dataLabels: { | |
| 196 | - enabled: true | |
| 197 | - }, | |
| 198 | - labels: series.monthDataSeries1.dates, | |
| 199 | - xaxis: { | |
| 200 | - type: 'datetime', | |
| 201 | - }, | |
| 202 | - yaxis: { | |
| 203 | - opposite: true | |
| 204 | - }, | |
| 205 | - legend: { | |
| 206 | - horizontalAlign: 'left' | |
| 207 | - } | |
| 208 | - }).render(); | |
| 209 | - }); | |
| 210 | - </script> | |
| 211 | - <!-- End Area Chart --> | |
| 212 | - | |
| 213 | - </div> | |
| 214 | - </div> | |
| 215 | - </div><!-- End Reports: Conversation Density Chart --> | |
| 216 | - | |
| 217 | - <!-- Recent Conversations --> | |
| 218 | - <div class="col-lg-12 clearfix"> | |
| 219 | - <div class="card" style="max-width: 100% !important;"> | |
| 220 | - | |
| 221 | - <div class="card-body"> | |
| 222 | - <h5 class="card-title">Recent 5 Conversations</span></h5> | |
| 223 | - | |
| 224 | - <?php | |
| 225 | - | |
| 226 | - $results = botreports_get_last5_conversations(); | |
| 227 | - | |
| 228 | - $numberOfRecords = count( $results ); | |
| 229 | - | |
| 230 | - if ( $numberOfRecords > 0 ) : | |
| 231 | - | |
| 232 | - ?> | |
| 233 | - | |
| 234 | - <table class="table table table-hover"> | |
| 235 | - <thead> | |
| 236 | - <tr class="first-row text-center table-primary"> | |
| 237 | - <th scope="col">#</th> | |
| 238 | - <th scope="col">Date & Time</th> | |
| 239 | - <th scope="col">Session ID</th> | |
| 240 | - <th scope="col">User Interaction Count</th> | |
| 241 | - <th scope="col">Action</th> | |
| 242 | - </tr> | |
| 243 | - </thead> | |
| 244 | - <tbody> | |
| 245 | - | |
| 246 | - <?php | |
| 247 | - | |
| 248 | - $counter = count( $results ) === 5 ? 5 : count( $results ); | |
| 249 | - | |
| 250 | - foreach ( $results as $result ) { | |
| 251 | - | |
| 252 | - ?> | |
| 253 | - | |
| 254 | - <tr class="text-center"> | |
| 255 | - <th scope="row"> | |
| 256 | - <a href="<?php echo esc_url( admin_url( "admin.php?page=wbcs-botsessions-page&userid={$result->user_id}" ) ); ?>"> | |
| 257 | - <?php echo esc_html( $counter ); ?> | |
| 258 | - </a> | |
| 259 | - </th> | |
| 260 | - <td><?php echo esc_html( date( 'd M, Y g:i A', strtotime( $result->date ) ) ); ?></td> | |
| 261 | - <td><?php echo esc_html( $result->session_id ); ?></td> | |
| 262 | - <td><?php echo intval( get_user_interaction_count( $result->conversation ) ); ?></td> | |
| 263 | - <td> | |
| 264 | - <a href="<?php echo esc_url( admin_url( "admin.php?page=wbcs-botsessions-page&userid={$result->user_id}" ) ); ?>" class="btn btn-primary"> | |
| 265 | - <i class="bi bi-eyeglasses"></i> View Chat | |
| 266 | - </a> | |
| 267 | - </td> | |
| 268 | - </tr> | |
| 269 | - | |
| 270 | - <?php | |
| 271 | - | |
| 272 | - --$counter; | |
| 273 | - | |
| 274 | - } | |
| 275 | - | |
| 276 | - ?> | |
| 277 | - | |
| 278 | - | |
| 279 | - </tbody> | |
| 280 | - | |
| 281 | - </table> | |
| 282 | - | |
| 283 | - <?php else : ?> | |
| 284 | - | |
| 285 | - <div class="alert alert-info">No chat records were found in the database.</div> | |
| 286 | - | |
| 287 | - <?php endif; ?> | |
| 288 | - | |
| 289 | - </div> | |
| 290 | - | |
| 291 | - </div> | |
| 292 | - </div><!-- End Recent Conversations --> | |
| 293 | - <!-- Reports Conversations --> | |
| 294 | - <div class="col-lg-12 clearfix"> | |
| 295 | - <div class="card" style="max-width: 100% !important;"> | |
| 296 | - | |
| 297 | - <div class="card-body"> | |
| 298 | - <h5 class="card-title">Conversations Reports</span></h5> | |
| 299 | - | |
| 300 | - <?php | |
| 301 | - | |
| 302 | - $reports_count = wpbot_get_report_stats_count()['reports_only']; | |
| 303 | - | |
| 304 | - | |
| 305 | - | |
| 306 | - if ( $reports_count > 0 ) : | |
| 307 | - | |
| 308 | - ?> | |
| 309 | - | |
| 310 | - <table class="table table table-hover"> | |
| 311 | - <thead> | |
| 312 | - <tr class="first-row text-center table-primary"> | |
| 313 | - <th scope="col">#</th> | |
| 314 | - <th scope="col">Id</th> | |
| 315 | - <th scope="col">Email</th> | |
| 316 | - <th scope="col">Message</th> | |
| 317 | - <th scope="col">Report Text</th> | |
| 318 | - <th scope="col">Date</th> | |
| 319 | - </tr> | |
| 320 | - </thead> | |
| 321 | - <tbody> | |
| 322 | - | |
| 323 | - <?php | |
| 324 | - $rests = wpbot_get_reports_list(); | |
| 325 | - $counter = count( $rests ) === 5 ? 5 : count( $rests ); | |
| 326 | - | |
| 327 | - foreach ( $rests as $report ) { | |
| 328 | - $meta = maybe_unserialize( $report['meta_info'] ); | |
| 329 | - $email = isset($meta['email']) ? $meta['email'] : ''; | |
| 330 | - $report_text = isset($meta['report_text']) ? $meta['report_text'] : ''; | |
| 331 | - ?> | |
| 332 | - | |
| 333 | - <tr class="text-center"> | |
| 334 | - <th scope="row"> | |
| 335 | - <a href="<?php echo esc_url( admin_url( "admin.php?page=wbcs-botsessions-page&userid={$result->user_id}" ) ); ?>"> | |
| 336 | - <?php echo esc_html( $counter ); ?> | |
| 337 | - </a> | |
| 338 | - </th> | |
| 339 | - <td><?php echo esc_html( $report['id'] ); ?></td> | |
| 340 | - <td><?php echo esc_html( $email ); ?></td> | |
| 341 | - <td><?php echo esc_html( $report['message'] ); ?></td> | |
| 342 | - <td><?php echo esc_html( $report_text ); ?></td> | |
| 343 | - <td><?php echo esc_html( $report['created_at'] ); ?></td> | |
| 344 | - </tr> | |
| 345 | - | |
| 346 | - <?php | |
| 347 | - | |
| 348 | - --$counter; | |
| 349 | - | |
| 350 | - } | |
| 351 | - | |
| 352 | - ?> | |
| 353 | - | |
| 354 | - | |
| 355 | - </tbody> | |
| 356 | - | |
| 357 | - </table> | |
| 358 | - | |
| 359 | - <?php else : ?> | |
| 360 | - | |
| 361 | - <div class="alert alert-info">No chat records were found in the database.</div> | |
| 362 | - | |
| 363 | - <?php endif; ?> | |
| 364 | - | |
| 365 | - </div> | |
| 366 | - | |
| 367 | - </div> | |
| 368 | - </div><!-- End Reports Conversations --> | |
| 369 | - | |
| 370 | - </div> | |
| 371 | - | |
| 372 | - <a href="<?php echo esc_url( admin_url( 'admin.php?page=wbcs-botsessions-page' ) ); ?>" class="btn btn-primary"> | |
| 373 | - <i class="bi bi-gear-wide-connected me-1"></i> Manage All Conversations | |
| 374 | - </a> | |
| 375 | - | |
| 376 | - <button id="wpbot-clear-feedback" class="btn btn-danger"><i class="bi bi-trash me-1"></i>Clear All Feedback</button> | |
| 377 | - <div id="wpbot-clear-feedback-msg"></div> | |
| 378 | - | |
| 379 | - </div><!-- End Left side columns --> | |
| 380 | - | |
| 381 | - </div> | |
| 382 | - </section> | |
| 383 | - | |
| 384 | - </main><!-- End #main --> | |
| 385 | - | |
| 386 | - <script src="<?php echo esc_url( QCLD_wpCHATBOT_HISTORY_PLUGIN_URL . '/reports/view/assets/apexcharts.min.js' ); ?>"></script> | |
| 387 | - <script> | |
| 388 | - jQuery(document).ready(function($) { | |
| 389 | - $(".feedback-card").on("click", function() { | |
| 390 | - let type = $(this).data("type"); | |
| 391 | - $("#feedback-results").html("<p>Loading...</p>"); | |
| 392 | - | |
| 393 | - $.post(ajaxurl, { | |
| 394 | - action: "wpbot_get_feedback_ajax", | |
| 395 | - feedback_type: type | |
| 396 | - }, function(response) { | |
| 397 | - if (response.success) { | |
| 398 | - $("#feedback-results").html(response.data.html); | |
| 399 | - } else { | |
| 400 | - $("#feedback-results").html("<p>No results found.</p>"); | |
| 401 | - } | |
| 402 | - }); | |
| 403 | - }); | |
| 404 | -}); | |
| 405 | -jQuery(document).on("click", ".wpbot-page-link", function(e) { | |
| 406 | - e.preventDefault(); | |
| 407 | - | |
| 408 | - let page = jQuery(this).data("page"); | |
| 409 | - let type = jQuery(this).data("type"); | |
| 410 | - | |
| 411 | - jQuery.post(ajaxurl, { | |
| 412 | - action: "wpbot_get_feedback_ajax", | |
| 413 | - feedback_type: type, | |
| 414 | - page: page | |
| 415 | - }, function(response) { | |
| 416 | - if (response.success) { | |
| 417 | - jQuery("#feedback-results").html(response.data.html); | |
| 418 | - } | |
| 419 | - }); | |
| 420 | -}); | |
| 421 | -jQuery(document).on("click", "#wpbot-clear-feedback", function (e) { | |
| 422 | - console.log('kardi'); | |
| 423 | - e.preventDefault(); | |
| 424 | - | |
| 425 | - if (!confirm("Are you sure you want to delete all feedback?")) { | |
| 426 | - return; | |
| 427 | - } | |
| 428 | - | |
| 429 | - jQuery.post(ajaxurl, { | |
| 430 | - action: "wpbot_clear_all_feedback" | |
| 431 | - }, function (response) { | |
| 432 | - if (response.success) { | |
| 433 | - jQuery("#wpbot-clear-feedback-msg").text(response.data.message).css("color", "green"); | |
| 434 | - // Optionally reload counters | |
| 435 | - location.reload(); | |
| 436 | - } else { | |
| 437 | - jQuery("#wpbot-clear-feedback-msg").text(response.data.message).css("color", "red"); | |
| 438 | - } | |
| 439 | - }); | |
| 440 | -}); | |
| 441 | - | |
| 442 | -</script> | |
| 1 | +<?php if ( ! defined( 'ABSPATH' ) ) { exit; } ?> | |
| 2 | + | |
| 3 | +<main id="main" class="main clearfix wpbot-reports-dashboard"> | |
| 4 | + | |
| 5 | + <div class="pagetitle"> | |
| 6 | + <h1><?php echo esc_html__( 'Bot - Reporting Dashboard', 'chatbot' ); ?></h1> | |
| 7 | + </div><!-- End Page Title --> | |
| 8 | + | |
| 9 | + <section class="section dashboard"> | |
| 10 | + <div class="row"> | |
| 11 | + | |
| 12 | + <!-- Left side columns --> | |
| 13 | + <div class="col-lg-12"> | |
| 14 | + <div class="row"> | |
| 15 | + | |
| 16 | + <!-- Card 1 --> | |
| 17 | + <div class="col-xxl-4 col-md-6"> | |
| 18 | + <div class="card info-card sales-card"> | |
| 19 | + | |
| 20 | + <div class="card-body"> | |
| 21 | + <h5 class="card-title">Total Conversations</span></h5> | |
| 22 | + | |
| 23 | + <div class="d-flex align-items-center"> | |
| 24 | + <div class="card-icon rounded-circle d-flex align-items-center justify-content-center"> | |
| 25 | + <i class="bi bi-wechat"></i> | |
| 26 | + </div> | |
| 27 | + <div class="ps-3"> | |
| 28 | + <h6> | |
| 29 | + <?php echo intval( botreports_get_total_conversation_count() ); ?> | |
| 30 | + </h6> | |
| 31 | + <span class="text-success small pt-1 fw-bold"> | |
| 32 | + <?php echo intval( botreports_get_todays_conversation_count() ); ?> | |
| 33 | + </span> | |
| 34 | + <span class="text-muted small pt-2 ps-1">Today</span>, | |
| 35 | + <span class="text-success small pt-1 fw-bold"> | |
| 36 | + <?php echo intval( botreports_get_weeks_conversation_count() ); ?> | |
| 37 | + </span> | |
| 38 | + <span class="text-muted small pt-2 ps-1">Last Week</span> | |
| 39 | + | |
| 40 | + </div> | |
| 41 | + </div> | |
| 42 | + </div> | |
| 43 | + | |
| 44 | + </div> | |
| 45 | + </div><!-- End Card 1 --> | |
| 46 | + <!-- Card 1 --> | |
| 47 | +<div class="col-xxl-4 col-md-6"> | |
| 48 | + <div class="card info-card sales-card feedback-card feedback-card--like" data-type="like" style="cursor:pointer;"> | |
| 49 | + <div class="card-body"> | |
| 50 | + <h5 class="card-title">Positive Feedback</h5> | |
| 51 | + <div class="d-flex align-items-center"> | |
| 52 | + <div class="card-icon rounded-circle d-flex align-items-center justify-content-center"> | |
| 53 | + <i class="bi bi-hand-thumbs-up"></i> | |
| 54 | + </div> | |
| 55 | + <div class="ps-3"> | |
| 56 | + <h6><?php echo intval( wpbot_get_report_stats_count()['likes'] ); ?></h6> | |
| 57 | + </div> | |
| 58 | + </div> | |
| 59 | + </div> | |
| 60 | + </div> | |
| 61 | +</div> | |
| 62 | + | |
| 63 | +<div class="col-xxl-4 col-md-6"> | |
| 64 | + <div class="card info-card sales-card feedback-card feedback-card--dislike" data-type="dislike" style="cursor:pointer;"> | |
| 65 | + <div class="card-body"> | |
| 66 | + <h5 class="card-title">Negative Feedback</h5> | |
| 67 | + <div class="d-flex align-items-center"> | |
| 68 | + <div class="card-icon rounded-circle d-flex align-items-center justify-content-center"> | |
| 69 | + <i class="bi bi-hand-thumbs-down"></i> | |
| 70 | + </div> | |
| 71 | + <div class="ps-3"> | |
| 72 | + <h6><?php echo intval( wpbot_get_report_stats_count()['dislikes'] ); ?></h6> | |
| 73 | + </div> | |
| 74 | + </div> | |
| 75 | + </div> | |
| 76 | + </div> | |
| 77 | +</div> | |
| 78 | +<div id="feedback-results" class="col-12" style="margin-top:8px;"></div> | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + <!-- Card 2 --> | |
| 83 | + <div class="col-xxl-4 col-md-6"> | |
| 84 | + <div class="card info-card sales-card"> | |
| 85 | + | |
| 86 | + <div class="card-body"> | |
| 87 | + <h5 class="card-title">Conversations in Last 30 Days</span></h5> | |
| 88 | + | |
| 89 | + <div class="d-flex align-items-center"> | |
| 90 | + <div class="card-icon rounded-circle d-flex align-items-center justify-content-center"> | |
| 91 | + <i class="bi bi-bar-chart-steps"></i> | |
| 92 | + </div> | |
| 93 | + <div class="ps-3"> | |
| 94 | + <h6> | |
| 95 | + <?php echo intval( botreports_get_last30days_conversation_count() ); ?> | |
| 96 | + </h6> | |
| 97 | + </div> | |
| 98 | + </div> | |
| 99 | + </div> | |
| 100 | + | |
| 101 | + </div> | |
| 102 | + </div><!-- End Card 2 --> | |
| 103 | + | |
| 104 | + <!-- Card 3 --> | |
| 105 | + <div class="col-xxl-4 col-md-6"> | |
| 106 | + <div class="card info-card sales-card"> | |
| 107 | + | |
| 108 | + <div class="card-body"> | |
| 109 | + <h5 class="card-title">Average Daily Conversation</span></h5> | |
| 110 | + | |
| 111 | + <div class="d-flex align-items-center"> | |
| 112 | + <div class="card-icon rounded-circle d-flex align-items-center justify-content-center"> | |
| 113 | + <i class="bi bi-bar-chart"></i> | |
| 114 | + </div> | |
| 115 | + <div class="ps-3"> | |
| 116 | + <h6><?php echo esc_html( botreports_get_last30days_conversation_average() ); ?></h6> | |
| 117 | + <span class="text-muted small">In</span> | |
| 118 | + <span class="text-success small pt-1 fw-bold">Last 30</span> | |
| 119 | + <span class="text-muted small pt-2 ps-1">Days</span> | |
| 120 | + </div> | |
| 121 | + </div> | |
| 122 | + </div> | |
| 123 | + | |
| 124 | + </div> | |
| 125 | + </div><!-- End Card 3 --> | |
| 126 | + | |
| 127 | + <!-- Reports: Conversation Density Chart --> | |
| 128 | + <div class="col-lg-12"> | |
| 129 | + <div class="card wpbot-report-panel" style="max-width: 100% !important;"> | |
| 130 | + <div class="card-body"> | |
| 131 | + <h5 class="card-title">Conversation Density Chart</h5> | |
| 132 | + | |
| 133 | + <!-- Area Chart --> | |
| 134 | + <div id="areaChart" style="min-height: 365px;"></div> | |
| 135 | + | |
| 136 | + <?php | |
| 137 | + | |
| 138 | + $densityTable = botreports_get_last30days_conversation_density(); | |
| 139 | + | |
| 140 | + $dates = array(); | |
| 141 | + $conversation_count_in_date = array(); | |
| 142 | + | |
| 143 | + foreach ( $densityTable as $data ) { | |
| 144 | + array_push( $dates, $data->CONVERSATION_DATE ); | |
| 145 | + array_push( $conversation_count_in_date, $data->CONVERSATION_NUM ); | |
| 146 | + } | |
| 147 | + | |
| 148 | + ?> | |
| 149 | + | |
| 150 | + <script> | |
| 151 | + document.addEventListener("DOMContentLoaded", () => { | |
| 152 | + const series = { | |
| 153 | + "monthDataSeries1": { | |
| 154 | + "count": <?php echo wp_json_encode( $conversation_count_in_date ); ?>, | |
| 155 | + "dates": <?php echo wp_json_encode( $dates ); ?>, | |
| 156 | + }, | |
| 157 | + } | |
| 158 | + new ApexCharts(document.querySelector("#areaChart"), { | |
| 159 | + series: [{ | |
| 160 | + name: "Conversation Count", | |
| 161 | + data: series.monthDataSeries1.count | |
| 162 | + }], | |
| 163 | + chart: { | |
| 164 | + type: 'bar', | |
| 165 | + height: 350, | |
| 166 | + fontFamily: '"DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif', | |
| 167 | + zoom: { | |
| 168 | + enabled: false | |
| 169 | + } | |
| 170 | + }, | |
| 171 | + colors: ['#5B4E96'], | |
| 172 | + plotOptions: { | |
| 173 | + bar: { | |
| 174 | + horizontal: false, | |
| 175 | + borderRadius: 6, | |
| 176 | + columnWidth: '55%' | |
| 177 | + } | |
| 178 | + }, | |
| 179 | + dataLabels: { | |
| 180 | + enabled: true, | |
| 181 | + style: { colors: ['#5B4E96'] } | |
| 182 | + }, | |
| 183 | + labels: series.monthDataSeries1.dates, | |
| 184 | + xaxis: { | |
| 185 | + type: 'datetime', | |
| 186 | + }, | |
| 187 | + yaxis: { | |
| 188 | + opposite: true | |
| 189 | + }, | |
| 190 | + grid: { | |
| 191 | + borderColor: '#e4e0f2', | |
| 192 | + strokeDashArray: 4 | |
| 193 | + }, | |
| 194 | + legend: { | |
| 195 | + horizontalAlign: 'left' | |
| 196 | + } | |
| 197 | + }).render(); | |
| 198 | + }); | |
| 199 | + </script> | |
| 200 | + <!-- End Area Chart --> | |
| 201 | + | |
| 202 | + </div> | |
| 203 | + </div> | |
| 204 | + </div><!-- End Reports: Conversation Density Chart --> | |
| 205 | + | |
| 206 | + <!-- Recent Conversations --> | |
| 207 | + <div class="col-lg-12 clearfix"> | |
| 208 | + <div class="card wpbot-report-panel" style="max-width: 100% !important;"> | |
| 209 | + | |
| 210 | + <div class="card-body"> | |
| 211 | + <h5 class="card-title">Recent 5 Conversations</h5> | |
| 212 | + | |
| 213 | + <?php | |
| 214 | + | |
| 215 | + $results = botreports_get_last5_conversations(); | |
| 216 | + | |
| 217 | + $numberOfRecords = count( $results ); | |
| 218 | + | |
| 219 | + if ( $numberOfRecords > 0 ) : | |
| 220 | + | |
| 221 | + ?> | |
| 222 | + | |
| 223 | + <table class="table table-hover wpbot-report-table"> | |
| 224 | + <thead> | |
| 225 | + <tr class="first-row text-center"> | |
| 226 | + <th scope="col">#</th> | |
| 227 | + <th scope="col">Date & Time</th> | |
| 228 | + <th scope="col">Session ID</th> | |
| 229 | + <th scope="col">Interaction Count</th> | |
| 230 | + <th scope="col">Action</th> | |
| 231 | + </tr> | |
| 232 | + </thead> | |
| 233 | + <tbody> | |
| 234 | + | |
| 235 | + <?php | |
| 236 | + | |
| 237 | + $counter = count( $results ) === 5 ? 5 : count( $results ); | |
| 238 | + | |
| 239 | + foreach ( $results as $result ) { | |
| 240 | + | |
| 241 | + ?> | |
| 242 | + | |
| 243 | + <tr class="text-center"> | |
| 244 | + <th scope="row"> | |
| 245 | + <a href="<?php echo esc_url( admin_url( "admin.php?page=wbcs-botsessions-page&userid={$result->user_id}" ) ); ?>"> | |
| 246 | + <?php echo esc_html( $counter ); ?> | |
| 247 | + </a> | |
| 248 | + </th> | |
| 249 | + <td><?php echo esc_html( gmdate( 'd M, Y g:i A', strtotime( $result->date ) ) ); ?></td> | |
| 250 | + <td><?php echo esc_html( $result->session_id ); ?></td> | |
| 251 | + <td><?php echo intval( get_user_interaction_count( $result->conversation ) ); ?></td> | |
| 252 | + <td> | |
| 253 | + <a href="<?php echo esc_url( admin_url( "admin.php?page=wbcs-botsessions-page&userid={$result->user_id}" ) ); ?>" class="btn btn-primary"> | |
| 254 | + <i class="bi bi-eyeglasses"></i> View Chat | |
| 255 | + </a> | |
| 256 | + </td> | |
| 257 | + </tr> | |
| 258 | + | |
| 259 | + <?php | |
| 260 | + | |
| 261 | + --$counter; | |
| 262 | + | |
| 263 | + } | |
| 264 | + | |
| 265 | + ?> | |
| 266 | + | |
| 267 | + | |
| 268 | + </tbody> | |
| 269 | + | |
| 270 | + </table> | |
| 271 | + | |
| 272 | + <?php else : ?> | |
| 273 | + | |
| 274 | + <div class="alert alert-info">No chat records were found in the database.</div> | |
| 275 | + | |
| 276 | + <?php endif; ?> | |
| 277 | + | |
| 278 | + </div> | |
| 279 | + | |
| 280 | + </div> | |
| 281 | + </div><!-- End Recent Conversations --> | |
| 282 | + <!-- Reports Conversations --> | |
| 283 | + <div class="col-lg-12 clearfix"> | |
| 284 | + <div class="card wpbot-report-panel" style="max-width: 100% !important;"> | |
| 285 | + | |
| 286 | + <div class="card-body"> | |
| 287 | + <h5 class="card-title">Conversations Reports</h5> | |
| 288 | + | |
| 289 | + <?php | |
| 290 | + | |
| 291 | + $reports_count = wpbot_get_report_stats_count()['reports_only']; | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + if ( $reports_count > 0 ) : | |
| 296 | + | |
| 297 | + ?> | |
| 298 | + | |
| 299 | + <table class="table table-hover wpbot-report-table"> | |
| 300 | + <thead> | |
| 301 | + <tr class="first-row text-center"> | |
| 302 | + <th scope="col">#</th> | |
| 303 | + <th scope="col">Id</th> | |
| 304 | + <th scope="col">Email</th> | |
| 305 | + <th scope="col">Message</th> | |
| 306 | + <th scope="col">Report Text</th> | |
| 307 | + <th scope="col">Date</th> | |
| 308 | + </tr> | |
| 309 | + </thead> | |
| 310 | + <tbody> | |
| 311 | + | |
| 312 | + <?php | |
| 313 | + $rests = wpbot_get_reports_list(); | |
| 314 | + $counter = count( $rests ) === 5 ? 5 : count( $rests ); | |
| 315 | + | |
| 316 | + foreach ( $rests as $report ) { | |
| 317 | + $meta = maybe_unserialize( $report['meta_info'] ); | |
| 318 | + $email = isset($meta['email']) ? $meta['email'] : ''; | |
| 319 | + $report_text = isset($meta['report_text']) ? $meta['report_text'] : ''; | |
| 320 | + ?> | |
| 321 | + | |
| 322 | + <tr class="text-center"> | |
| 323 | + <th scope="row"> | |
| 324 | + <?php echo esc_html( $counter ); ?> | |
| 325 | + </th> | |
| 326 | + <td><?php echo esc_html( $report['id'] ); ?></td> | |
| 327 | + <td><?php echo esc_html( $email ); ?></td> | |
| 328 | + <td><?php echo esc_html( $report['message'] ); ?></td> | |
| 329 | + <td><?php echo esc_html( $report_text ); ?></td> | |
| 330 | + <td><?php echo esc_html( $report['created_at'] ); ?></td> | |
| 331 | + </tr> | |
| 332 | + | |
| 333 | + <?php | |
| 334 | + | |
| 335 | + --$counter; | |
| 336 | + | |
| 337 | + } | |
| 338 | + | |
| 339 | + ?> | |
| 340 | + | |
| 341 | + | |
| 342 | + </tbody> | |
| 343 | + | |
| 344 | + </table> | |
| 345 | + | |
| 346 | + <?php else : ?> | |
| 347 | + | |
| 348 | + <div class="alert alert-info">No chat records were found in the database.</div> | |
| 349 | + | |
| 350 | + <?php endif; ?> | |
| 351 | + | |
| 352 | + </div> | |
| 353 | + | |
| 354 | + </div> | |
| 355 | + </div><!-- End Reports Conversations --> | |
| 356 | + | |
| 357 | + </div> | |
| 358 | + | |
| 359 | + <div class="wpbot-report-actions"> | |
| 360 | + <a href="<?php echo esc_url( admin_url( 'admin.php?page=wbcs-botsessions-page' ) ); ?>" class="btn btn-primary"> | |
| 361 | + <i class="bi bi-gear-wide-connected me-1"></i> Manage All Conversations | |
| 362 | + </a> | |
| 363 | + | |
| 364 | + <button id="wpbot-clear-feedback" class="btn btn-danger"><i class="bi bi-trash me-1"></i>Clear All Feedback</button> | |
| 365 | + <div id="wpbot-clear-feedback-msg"></div> | |
| 366 | + </div> | |
| 367 | + | |
| 368 | + </div><!-- End Left side columns --> | |
| 369 | + | |
| 370 | + </div> | |
| 371 | + </section> | |
| 372 | + | |
| 373 | + </main><!-- End #main --> | |