You are here

public function Reports::subreport_intervals in Ubercart 8.4

Returns a list of timespans for subreports over that report's time span.

To be used with a given time span for a report and specified interval for subreports.

Parameters

$start: A UNIX timestamp representing the time to start the report.

$end: A UNIX timestamp representing the time to end the report.

$interval: Text representing the time span of the subreport (e.g. 'day', 'week').

Return value

An array of keyed arrays with the following values:

  • start: The starting point of the sub report.
  • end: The ending point of the sub report.
1 call to Reports::subreport_intervals()
Reports::customSales in uc_report/src/Controller/Reports.php
Displays the custom sales report form and table.

File

uc_report/src/Controller/Reports.php, line 1047

Class

Reports
Provides reports for Ubercart.

Namespace

Drupal\uc_report\Controller

Code

public function subreport_intervals($start, $report_end, $interval) {
  $subreports = [];
  while ($start < $report_end) {
    $end = strtotime('+1 ' . $interval, $start) - 1;
    $subreports[] = [
      'start' => $start,
      'end' => min($end, $report_end),
    ];
    $start = $end + 1;
  }
  return $subreports;
}