html-report-by-date.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. * Admin View: Report by Date (with date filters)
  4. *
  5. * @package WooCommerce/Admin/Reporting
  6. */
  7. if ( ! defined( 'ABSPATH' ) ) {
  8. exit; // Exit if accessed directly.
  9. }
  10. ?>
  11. <div id="poststuff" class="woocommerce-reports-wide">
  12. <div class="postbox">
  13. <?php if ( 'custom' === $current_range && isset( $_GET['start_date'], $_GET['end_date'] ) ) : ?>
  14. <h3 class="screen-reader-text">
  15. <?php
  16. /* translators: 1: start date 2: end date */
  17. printf(
  18. esc_html__( 'From %1$s to %2$s', 'woocommerce' ),
  19. esc_html( wc_clean( wp_unslash( $_GET['start_date'] ) ) ),
  20. esc_html( wc_clean( wp_unslash( $_GET['end_date'] ) ) )
  21. );
  22. ?>
  23. </h3>
  24. <?php else : ?>
  25. <h3 class="screen-reader-text"><?php echo esc_html( $ranges[ $current_range ] ); ?></h3>
  26. <?php endif; ?>
  27. <div class="stats_range">
  28. <?php $this->get_export_button(); ?>
  29. <ul>
  30. <?php
  31. foreach ( $ranges as $range => $name ) {
  32. echo '<li class="' . ( $current_range == $range ? 'active' : '' ) . '"><a href="' . esc_url( remove_query_arg( array( 'start_date', 'end_date' ), add_query_arg( 'range', $range ) ) ) . '">' . esc_html( $name ) . '</a></li>';
  33. }
  34. ?>
  35. <li class="custom <?php echo ( 'custom' === $current_range ) ? 'active' : ''; ?>">
  36. <?php esc_html_e( 'Custom:', 'woocommerce' ); ?>
  37. <form method="GET">
  38. <div>
  39. <?php
  40. // Maintain query string.
  41. foreach ( $_GET as $key => $value ) {
  42. if ( is_array( $value ) ) {
  43. foreach ( $value as $v ) {
  44. echo '<input type="hidden" name="' . esc_attr( sanitize_text_field( $key ) ) . '[]" value="' . esc_attr( sanitize_text_field( $v ) ) . '" />';
  45. }
  46. } else {
  47. echo '<input type="hidden" name="' . esc_attr( sanitize_text_field( $key ) ) . '" value="' . esc_attr( sanitize_text_field( $value ) ) . '" />';
  48. }
  49. }
  50. ?>
  51. <input type="hidden" name="range" value="custom" />
  52. <input type="text" size="11" placeholder="yyyy-mm-dd" value="<?php echo ( ! empty( $_GET['start_date'] ) ) ? esc_attr( wp_unslash( $_GET['start_date'] ) ) : ''; ?>" name="start_date" class="range_datepicker from" autocomplete="off" /><?php //@codingStandardsIgnoreLine ?>
  53. <span>&ndash;</span>
  54. <input type="text" size="11" placeholder="yyyy-mm-dd" value="<?php echo ( ! empty( $_GET['end_date'] ) ) ? esc_attr( wp_unslash( $_GET['end_date'] ) ) : ''; ?>" name="end_date" class="range_datepicker to" autocomplete="off" /><?php //@codingStandardsIgnoreLine ?>
  55. <button type="submit" class="button" value="<?php esc_attr_e( 'Go', 'woocommerce' ); ?>"><?php esc_html_e( 'Go', 'woocommerce' ); ?></button>
  56. <?php wp_nonce_field( 'custom_range', 'wc_reports_nonce', false ); ?>
  57. </div>
  58. </form>
  59. </li>
  60. </ul>
  61. </div>
  62. <?php if ( empty( $hide_sidebar ) ) : ?>
  63. <div class="inside chart-with-sidebar">
  64. <div class="chart-sidebar">
  65. <?php if ( $legends = $this->get_chart_legend() ) : ?>
  66. <ul class="chart-legend">
  67. <?php foreach ( $legends as $legend ) : ?>
  68. <?php // @codingStandardsIgnoreStart ?>
  69. <li style="border-color: <?php echo $legend['color']; ?>" <?php if ( isset( $legend['highlight_series'] ) ) echo 'class="highlight_series ' . ( isset( $legend['placeholder'] ) ? 'tips' : '' ) . '" data-series="' . esc_attr( $legend['highlight_series'] ) . '"'; ?> data-tip="<?php echo isset( $legend['placeholder'] ) ? $legend['placeholder'] : ''; ?>">
  70. <?php echo $legend['title']; ?>
  71. </li>
  72. <?php // @codingStandardsIgnoreEnd ?>
  73. <?php endforeach; ?>
  74. </ul>
  75. <?php endif; ?>
  76. <ul class="chart-widgets">
  77. <?php foreach ( $this->get_chart_widgets() as $widget ) : ?>
  78. <li class="chart-widget">
  79. <?php if ( $widget['title'] ) : ?>
  80. <h4><?php echo esc_html( $widget['title'] ); ?></h4>
  81. <?php endif; ?>
  82. <?php call_user_func( $widget['callback'] ); ?>
  83. </li>
  84. <?php endforeach; ?>
  85. </ul>
  86. </div>
  87. <div class="main">
  88. <?php $this->get_main_chart(); ?>
  89. </div>
  90. </div>
  91. <?php else : ?>
  92. <div class="inside">
  93. <?php $this->get_main_chart(); ?>
  94. </div>
  95. <?php endif; ?>
  96. </div>
  97. </div>