@@ -12,88 +12,88 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | class GetPaid_Reports_Report { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @var array |
|
| 17 | - */ |
|
| 18 | - public $views; |
|
| 15 | + /** |
|
| 16 | + * @var array |
|
| 17 | + */ |
|
| 18 | + public $views; |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Class constructor. |
|
| 22 | - * |
|
| 23 | - */ |
|
| 24 | - public function __construct() { |
|
| 20 | + /** |
|
| 21 | + * Class constructor. |
|
| 22 | + * |
|
| 23 | + */ |
|
| 24 | + public function __construct() { |
|
| 25 | 25 | |
| 26 | - $this->views = array( |
|
| 26 | + $this->views = array( |
|
| 27 | 27 | |
| 28 | 28 | 'items' => array( |
| 29 | - 'label' => __( 'Items', 'invoicing' ), |
|
| 30 | - 'class' => 'GetPaid_Reports_Report_Items', |
|
| 31 | - ), |
|
| 29 | + 'label' => __( 'Items', 'invoicing' ), |
|
| 30 | + 'class' => 'GetPaid_Reports_Report_Items', |
|
| 31 | + ), |
|
| 32 | 32 | |
| 33 | - 'gateways' => array( |
|
| 34 | - 'label' => __( 'Payment Methods', 'invoicing' ), |
|
| 35 | - 'class' => 'GetPaid_Reports_Report_Gateways', |
|
| 36 | - ), |
|
| 33 | + 'gateways' => array( |
|
| 34 | + 'label' => __( 'Payment Methods', 'invoicing' ), |
|
| 35 | + 'class' => 'GetPaid_Reports_Report_Gateways', |
|
| 36 | + ), |
|
| 37 | 37 | |
| 38 | - 'discounts' => array( |
|
| 39 | - 'label' => __( 'Discount Codes', 'invoicing' ), |
|
| 40 | - 'class' => 'GetPaid_Reports_Report_Discounts', |
|
| 41 | - ), |
|
| 38 | + 'discounts' => array( |
|
| 39 | + 'label' => __( 'Discount Codes', 'invoicing' ), |
|
| 40 | + 'class' => 'GetPaid_Reports_Report_Discounts', |
|
| 41 | + ), |
|
| 42 | 42 | |
| 43 | 43 | ); |
| 44 | 44 | |
| 45 | - $this->views = apply_filters( 'wpinv_report_views', $this->views ); |
|
| 46 | - |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * Retrieves the current range. |
|
| 51 | - * |
|
| 52 | - */ |
|
| 53 | - public function get_range() { |
|
| 54 | - $valid_ranges = $this->get_periods(); |
|
| 55 | - |
|
| 56 | - if ( isset( $_GET['date_range'] ) && array_key_exists( $_GET['date_range'], $valid_ranges ) ) { |
|
| 57 | - return sanitize_key( $_GET['date_range'] ); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - return '7_days'; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Returns an array of date ranges. |
|
| 65 | - * |
|
| 66 | - * @return array |
|
| 67 | - */ |
|
| 68 | - public function get_periods() { |
|
| 69 | - |
|
| 70 | - $periods = array( |
|
| 71 | - 'today' => __( 'Today', 'invoicing' ), |
|
| 72 | - 'yesterday' => __( 'Yesterday', 'invoicing' ), |
|
| 73 | - 'week' => __( 'This week', 'invoicing' ), |
|
| 74 | - 'last_week' => __( 'Last week', 'invoicing' ), |
|
| 75 | - '7_days' => __( 'Last 7 days', 'invoicing' ), |
|
| 76 | - 'month' => __( 'This month', 'invoicing' ), |
|
| 77 | - 'last_month' => __( 'Last month', 'invoicing' ), |
|
| 78 | - '30_days' => __( 'Last 30 days', 'invoicing' ), |
|
| 79 | - 'quarter' => __( 'This Quarter', 'invoicing' ), |
|
| 80 | - 'last_quarter' => __( 'Last Quarter', 'invoicing' ), |
|
| 81 | - 'year' => __( 'This year', 'invoicing' ), |
|
| 82 | - 'last_year' => __( 'Last Year', 'invoicing' ), |
|
| 83 | - 'custom' => __( 'Custom Date Range', 'invoicing' ), |
|
| 84 | - ); |
|
| 85 | - |
|
| 86 | - return apply_filters( 'getpaid_earning_periods', $periods ); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * Displays the range selector. |
|
| 91 | - * |
|
| 92 | - */ |
|
| 93 | - public function display_range_selector() { |
|
| 94 | - |
|
| 95 | - $range = $this->get_range(); |
|
| 96 | - ?> |
|
| 45 | + $this->views = apply_filters( 'wpinv_report_views', $this->views ); |
|
| 46 | + |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * Retrieves the current range. |
|
| 51 | + * |
|
| 52 | + */ |
|
| 53 | + public function get_range() { |
|
| 54 | + $valid_ranges = $this->get_periods(); |
|
| 55 | + |
|
| 56 | + if ( isset( $_GET['date_range'] ) && array_key_exists( $_GET['date_range'], $valid_ranges ) ) { |
|
| 57 | + return sanitize_key( $_GET['date_range'] ); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + return '7_days'; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Returns an array of date ranges. |
|
| 65 | + * |
|
| 66 | + * @return array |
|
| 67 | + */ |
|
| 68 | + public function get_periods() { |
|
| 69 | + |
|
| 70 | + $periods = array( |
|
| 71 | + 'today' => __( 'Today', 'invoicing' ), |
|
| 72 | + 'yesterday' => __( 'Yesterday', 'invoicing' ), |
|
| 73 | + 'week' => __( 'This week', 'invoicing' ), |
|
| 74 | + 'last_week' => __( 'Last week', 'invoicing' ), |
|
| 75 | + '7_days' => __( 'Last 7 days', 'invoicing' ), |
|
| 76 | + 'month' => __( 'This month', 'invoicing' ), |
|
| 77 | + 'last_month' => __( 'Last month', 'invoicing' ), |
|
| 78 | + '30_days' => __( 'Last 30 days', 'invoicing' ), |
|
| 79 | + 'quarter' => __( 'This Quarter', 'invoicing' ), |
|
| 80 | + 'last_quarter' => __( 'Last Quarter', 'invoicing' ), |
|
| 81 | + 'year' => __( 'This year', 'invoicing' ), |
|
| 82 | + 'last_year' => __( 'Last Year', 'invoicing' ), |
|
| 83 | + 'custom' => __( 'Custom Date Range', 'invoicing' ), |
|
| 84 | + ); |
|
| 85 | + |
|
| 86 | + return apply_filters( 'getpaid_earning_periods', $periods ); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * Displays the range selector. |
|
| 91 | + * |
|
| 92 | + */ |
|
| 93 | + public function display_range_selector() { |
|
| 94 | + |
|
| 95 | + $range = $this->get_range(); |
|
| 96 | + ?> |
|
| 97 | 97 | |
| 98 | 98 | <form method="get" class="getpaid-filter-earnings float-right"> |
| 99 | 99 | <?php getpaid_hidden_field( 'page', isset( $_GET['page'] ) ? wpinv_clean( $_GET['page'] ) : 'wpinv-reports' ); ?> |
@@ -115,14 +115,14 @@ discard block |
||
| 115 | 115 | </form> |
| 116 | 116 | |
| 117 | 117 | <?php |
| 118 | - } |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - /** |
|
| 121 | - * Displays the reports tab. |
|
| 122 | - * |
|
| 123 | - */ |
|
| 124 | - public function display() { |
|
| 125 | - ?> |
|
| 120 | + /** |
|
| 121 | + * Displays the reports tab. |
|
| 122 | + * |
|
| 123 | + */ |
|
| 124 | + public function display() { |
|
| 125 | + ?> |
|
| 126 | 126 | |
| 127 | 127 | <div class="mt-4" style="max-width: 1200px;"> |
| 128 | 128 | |
@@ -202,16 +202,16 @@ discard block |
||
| 202 | 202 | |
| 203 | 203 | <?php |
| 204 | 204 | |
| 205 | - } |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | - /** |
|
| 208 | - * Displays the left side. |
|
| 209 | - * |
|
| 210 | - */ |
|
| 211 | - public function display_left() { |
|
| 212 | - $graphs = wpinv_get_report_graphs(); |
|
| 207 | + /** |
|
| 208 | + * Displays the left side. |
|
| 209 | + * |
|
| 210 | + */ |
|
| 211 | + public function display_left() { |
|
| 212 | + $graphs = wpinv_get_report_graphs(); |
|
| 213 | 213 | |
| 214 | - ?> |
|
| 214 | + ?> |
|
| 215 | 215 | |
| 216 | 216 | <?php foreach ( $graphs as $key => $graph ) : ?> |
| 217 | 217 | <div class="row mb-4"> |
@@ -230,35 +230,35 @@ discard block |
||
| 230 | 230 | |
| 231 | 231 | <?php |
| 232 | 232 | |
| 233 | - } |
|
| 234 | - |
|
| 235 | - /** |
|
| 236 | - * Retrieves the download url. |
|
| 237 | - * |
|
| 238 | - */ |
|
| 239 | - public function get_download_url( $graph, $file_type ) { |
|
| 240 | - |
|
| 241 | - return wp_nonce_url( |
|
| 242 | - add_query_arg( |
|
| 243 | - array( |
|
| 244 | - 'getpaid-admin-action' => 'download_graph', |
|
| 245 | - 'file_type' => urlencode( $file_type ), |
|
| 246 | - 'graph' => urlencode( $graph ), |
|
| 247 | - ) |
|
| 248 | - ), |
|
| 249 | - 'getpaid-nonce', |
|
| 250 | - 'getpaid-nonce' |
|
| 251 | - ); |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + /** |
|
| 236 | + * Retrieves the download url. |
|
| 237 | + * |
|
| 238 | + */ |
|
| 239 | + public function get_download_url( $graph, $file_type ) { |
|
| 240 | + |
|
| 241 | + return wp_nonce_url( |
|
| 242 | + add_query_arg( |
|
| 243 | + array( |
|
| 244 | + 'getpaid-admin-action' => 'download_graph', |
|
| 245 | + 'file_type' => urlencode( $file_type ), |
|
| 246 | + 'graph' => urlencode( $graph ), |
|
| 247 | + ) |
|
| 248 | + ), |
|
| 249 | + 'getpaid-nonce', |
|
| 250 | + 'getpaid-nonce' |
|
| 251 | + ); |
|
| 252 | 252 | |
| 253 | - } |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | - /** |
|
| 256 | - * Displays the right side. |
|
| 257 | - * |
|
| 258 | - */ |
|
| 259 | - public function display_right() { |
|
| 255 | + /** |
|
| 256 | + * Displays the right side. |
|
| 257 | + * |
|
| 258 | + */ |
|
| 259 | + public function display_right() { |
|
| 260 | 260 | |
| 261 | - ?> |
|
| 261 | + ?> |
|
| 262 | 262 | |
| 263 | 263 | <?php foreach ( $this->views as $key => $view ) : ?> |
| 264 | 264 | <div class="row mb-4"> |
@@ -287,10 +287,10 @@ discard block |
||
| 287 | 287 | </div> |
| 288 | 288 | <div class="card-body"> |
| 289 | 289 | <?php |
| 290 | - $class = $view['class']; |
|
| 291 | - $class = new $class(); |
|
| 292 | - $class->display_stats(); |
|
| 293 | - ?> |
|
| 290 | + $class = $view['class']; |
|
| 291 | + $class = new $class(); |
|
| 292 | + $class->display_stats(); |
|
| 293 | + ?> |
|
| 294 | 294 | </div> |
| 295 | 295 | </div> |
| 296 | 296 | </div> |
@@ -299,67 +299,67 @@ discard block |
||
| 299 | 299 | |
| 300 | 300 | <?php |
| 301 | 301 | |
| 302 | - } |
|
| 303 | - |
|
| 304 | - /** |
|
| 305 | - * Returns a list of report cards. |
|
| 306 | - * |
|
| 307 | - */ |
|
| 308 | - public function get_cards() { |
|
| 309 | - |
|
| 310 | - $cards = array( |
|
| 311 | - 'total_sales' => array( |
|
| 312 | - 'description' => __( 'Gross sales in the period.', 'invoicing' ), |
|
| 313 | - 'label' => __( 'Gross Revenue', 'invoicing' ), |
|
| 314 | - ), |
|
| 315 | - 'net_sales' => array( |
|
| 316 | - 'description' => __( 'Net sales in the period.', 'invoicing' ), |
|
| 317 | - 'label' => __( 'Net Revenue', 'invoicing' ), |
|
| 318 | - ), |
|
| 319 | - 'average_sales' => array( |
|
| 320 | - 'description' => __( 'Average net daily/monthly sales.', 'invoicing' ), |
|
| 321 | - 'label' => __( 'Avg. Net Sales', 'invoicing' ), |
|
| 322 | - ), |
|
| 323 | - 'average_total_sales' => array( |
|
| 324 | - 'description' => __( 'Average gross daily/monthly sales.', 'invoicing' ), |
|
| 325 | - 'label' => __( 'Avg. Gross Sales', 'invoicing' ), |
|
| 326 | - ), |
|
| 327 | - 'total_invoices' => array( |
|
| 328 | - 'description' => __( 'Number of paid invoices.', 'invoicing' ), |
|
| 329 | - 'label' => __( 'Paid Invoices', 'invoicing' ), |
|
| 330 | - ), |
|
| 331 | - 'total_items' => array( |
|
| 332 | - 'description' => __( 'Number of items purchased.', 'invoicing' ), |
|
| 333 | - 'label' => __( 'Purchased Items', 'invoicing' ), |
|
| 334 | - ), |
|
| 335 | - 'refunded_items' => array( |
|
| 336 | - 'description' => __( 'Number of items refunded.', 'invoicing' ), |
|
| 337 | - 'label' => __( 'Refunded Items', 'invoicing' ), |
|
| 338 | - ), |
|
| 339 | - 'total_tax' => array( |
|
| 340 | - 'description' => __( 'Total charged for taxes.', 'invoicing' ), |
|
| 341 | - 'label' => __( 'Tax', 'invoicing' ), |
|
| 342 | - ), |
|
| 343 | - 'total_refunded_tax' => array( |
|
| 344 | - 'description' => __( 'Total refunded for taxes.', 'invoicing' ), |
|
| 345 | - 'label' => __( 'Refunded Tax', 'invoicing' ), |
|
| 346 | - ), |
|
| 347 | - 'total_fees' => array( |
|
| 348 | - 'description' => __( 'Total fees charged.', 'invoicing' ), |
|
| 349 | - 'label' => __( 'Fees', 'invoicing' ), |
|
| 350 | - ), |
|
| 351 | - 'total_refunds' => array( |
|
| 352 | - 'description' => __( 'Total of refunded invoices.', 'invoicing' ), |
|
| 353 | - 'label' => __( 'Refunded', 'invoicing' ), |
|
| 354 | - ), |
|
| 355 | - 'total_discount' => array( |
|
| 356 | - 'description' => __( 'Total of discounts used.', 'invoicing' ), |
|
| 357 | - 'label' => __( 'Discounted', 'invoicing' ), |
|
| 358 | - ), |
|
| 359 | - ); |
|
| 360 | - |
|
| 361 | - return apply_filters( 'wpinv_report_cards', $cards ); |
|
| 362 | - } |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + /** |
|
| 305 | + * Returns a list of report cards. |
|
| 306 | + * |
|
| 307 | + */ |
|
| 308 | + public function get_cards() { |
|
| 309 | + |
|
| 310 | + $cards = array( |
|
| 311 | + 'total_sales' => array( |
|
| 312 | + 'description' => __( 'Gross sales in the period.', 'invoicing' ), |
|
| 313 | + 'label' => __( 'Gross Revenue', 'invoicing' ), |
|
| 314 | + ), |
|
| 315 | + 'net_sales' => array( |
|
| 316 | + 'description' => __( 'Net sales in the period.', 'invoicing' ), |
|
| 317 | + 'label' => __( 'Net Revenue', 'invoicing' ), |
|
| 318 | + ), |
|
| 319 | + 'average_sales' => array( |
|
| 320 | + 'description' => __( 'Average net daily/monthly sales.', 'invoicing' ), |
|
| 321 | + 'label' => __( 'Avg. Net Sales', 'invoicing' ), |
|
| 322 | + ), |
|
| 323 | + 'average_total_sales' => array( |
|
| 324 | + 'description' => __( 'Average gross daily/monthly sales.', 'invoicing' ), |
|
| 325 | + 'label' => __( 'Avg. Gross Sales', 'invoicing' ), |
|
| 326 | + ), |
|
| 327 | + 'total_invoices' => array( |
|
| 328 | + 'description' => __( 'Number of paid invoices.', 'invoicing' ), |
|
| 329 | + 'label' => __( 'Paid Invoices', 'invoicing' ), |
|
| 330 | + ), |
|
| 331 | + 'total_items' => array( |
|
| 332 | + 'description' => __( 'Number of items purchased.', 'invoicing' ), |
|
| 333 | + 'label' => __( 'Purchased Items', 'invoicing' ), |
|
| 334 | + ), |
|
| 335 | + 'refunded_items' => array( |
|
| 336 | + 'description' => __( 'Number of items refunded.', 'invoicing' ), |
|
| 337 | + 'label' => __( 'Refunded Items', 'invoicing' ), |
|
| 338 | + ), |
|
| 339 | + 'total_tax' => array( |
|
| 340 | + 'description' => __( 'Total charged for taxes.', 'invoicing' ), |
|
| 341 | + 'label' => __( 'Tax', 'invoicing' ), |
|
| 342 | + ), |
|
| 343 | + 'total_refunded_tax' => array( |
|
| 344 | + 'description' => __( 'Total refunded for taxes.', 'invoicing' ), |
|
| 345 | + 'label' => __( 'Refunded Tax', 'invoicing' ), |
|
| 346 | + ), |
|
| 347 | + 'total_fees' => array( |
|
| 348 | + 'description' => __( 'Total fees charged.', 'invoicing' ), |
|
| 349 | + 'label' => __( 'Fees', 'invoicing' ), |
|
| 350 | + ), |
|
| 351 | + 'total_refunds' => array( |
|
| 352 | + 'description' => __( 'Total of refunded invoices.', 'invoicing' ), |
|
| 353 | + 'label' => __( 'Refunded', 'invoicing' ), |
|
| 354 | + ), |
|
| 355 | + 'total_discount' => array( |
|
| 356 | + 'description' => __( 'Total of discounts used.', 'invoicing' ), |
|
| 357 | + 'label' => __( 'Discounted', 'invoicing' ), |
|
| 358 | + ), |
|
| 359 | + ); |
|
| 360 | + |
|
| 361 | + return apply_filters( 'wpinv_report_cards', $cards ); |
|
| 362 | + } |
|
| 363 | 363 | |
| 364 | 364 | |
| 365 | 365 | |