Server IP : 172.24.0.40 / Your IP : 216.73.216.10 Web Server : Apache System : Linux dbweb26.ust.edu.ph 4.18.0-513.5.1.el8_9.x86_64 #1 SMP Fri Sep 29 05:21:10 EDT 2023 x86_64 User : apache ( 48) PHP Version : 8.2.18 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/medicine.dbweb26.goldcopy/public_html/wp-content/plugins/newsletter/users/ |
Upload File : |
<?php defined('ABSPATH') || exit; ?> <div style="height: 300px;"> <canvas id="tnp-users-chart-days"></canvas> </div> <div style="height: 300px;"> <canvas id="tnp-users-chart-months"></canvas> </div> <div class="row"> <div class="col-md-6"> <?php $dt = new DateTime(); $dt->setTime(12, 0, 0)->setDate((int) date('Y'), (int) date('m'), 1); $i = new DateInterval('P1M'); $months = []; for ($x = 1; $x <= 24; $x++) { $months[] = $dt->format('Y-m'); $dt->sub($i); } $months = array_reverse($months); $list = $wpdb->get_results("select concat(year(created), '-', date_format(created, '%m')) as d, count(*) as c from " . NEWSLETTER_USERS_TABLE . " where status='C' group by concat(year(created), '-', date_format(created, '%m')) order by d desc limit 24", OBJECT_K); $dataMonths = []; foreach ($months as $month) { $dataMonths[] = isset($list[$month]) ? $list[$month]->c : 0; } ?> <?php /* <table class="widefat"> <thead> <tr> <th><?php _e('Year and month', 'newsletter') ?></th> <th><?php _e('Total', 'newsletter') ?></th> </tr> </thead> <?php foreach ($months as $month) { ?> <tr> <td><?php echo $month; ?></td> <td><?php echo isset($list[$month]) ? $list[$month]->c : 0; ?></td> </tr> <?php } ?> </table> */?> </div> <div class="col-md-6"> <?php $dt = new DateTime(); $dt->setTime(12, 0, 0); $i = new DateInterval('P1D'); $days = []; for ($x = 1; $x <= 90; $x++) { $days[] = $dt->format('Y-m-d'); $dt->sub($i); } $days = array_reverse($days); $list = $wpdb->get_results("select date(created) as d, count(*) as c from " . NEWSLETTER_USERS_TABLE . " where status='C' group by date(created) order by d desc limit 90", OBJECT_K); $dataDays = []; foreach ($days as $day) { $dataDays[] = isset($list[$day]) ? $list[$day]->c : 0; } ?> <?php /* <table class="widefat"> <thead> <tr> <th><?php _e('Date', 'newsletter') ?></th> <th><?php _e('Total', 'newsletter') ?></th> </tr> </thead> <?php for ($i = 0; $i < count($days); $i++) { ?> <tr> <td><?php echo $days[$i]; ?></td> <td><?php echo $dataDays[$i] ?></td> </tr> <?php } ?> </table> */?> </div> </div> <script> const dataDays = { labels: <?php echo wp_json_encode($days) ?>, datasets: [{ label: 'By day', borderColor: '#3498DB', borderWidth: 1, data: <?php echo wp_json_encode($dataDays) ?>, }] }; const dataMonths = { labels: <?php echo wp_json_encode($months) ?>, datasets: [{ label: 'By month', borderColor: '#3498DB', borderWidth: 1, data: <?php echo wp_json_encode($dataMonths) ?>, }] }; jQuery(function () { const myChart = new Chart( document.getElementById('tnp-users-chart-days'), { type: 'line', data: dataDays, options: { maintainAspectRatio: false, scales: { yAxes: [{ ticks: { beginAtZero: true } }] } } } ); const myChartMonths = new Chart( document.getElementById('tnp-users-chart-months'), { type: 'line', data: dataMonths, options: { maintainAspectRatio: false, scales: { yAxes: [{ ticks: { beginAtZero: true } }] } } } ); }); </script>