statistics-time.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. defined('ABSPATH') || exit;
  3. ?>
  4. <div class="row">
  5. <div class="col-md-6">
  6. <h3><?php _e('Subscriptions by month (max 12 months)', 'newsletter') ?></h3>
  7. <?php
  8. $months = $wpdb->get_results("select count(*) as c, concat(year(created), '-', date_format(created, '%m')) as d from " . NEWSLETTER_USERS_TABLE . " where status='C' group by concat(year(created), '-', date_format(created, '%m')) order by d desc limit 12");
  9. ?>
  10. <table class="widefat">
  11. <thead>
  12. <tr>
  13. <th><?php _e('Year and month', 'newsletter') ?></th>
  14. <th><?php _e('Total', 'newsletter') ?></th>
  15. </tr>
  16. </thead>
  17. <?php foreach ($months as &$day) { ?>
  18. <tr>
  19. <td><?php echo $day->d; ?></td>
  20. <td><?php echo $day->c; ?></td>
  21. </tr>
  22. <?php } ?>
  23. </table>
  24. </div>
  25. <div class="col-md-6">
  26. <h3><?php _e('Subscriptions by day (max 90 days)', 'newsletter') ?></h3>
  27. <?php
  28. $list = $wpdb->get_results("select count(*) as c, date(created) as d from " . NEWSLETTER_USERS_TABLE . " where status='C' group by date(created) order by d desc limit 90");
  29. ?>
  30. <table class="widefat">
  31. <thead>
  32. <tr>
  33. <th><?php _e('Date', 'newsletter') ?></th>
  34. <th><?php _e('Total', 'newsletter') ?></th>
  35. </tr>
  36. </thead>
  37. <?php foreach ($list as $day) { ?>
  38. <tr>
  39. <td><?php echo $day->d; ?></td>
  40. <td><?php echo $day->c; ?></td>
  41. </tr>
  42. <?php } ?>
  43. </table>
  44. </div>
  45. </div>