You are here

function uc_report_help in Ubercart 8.4

Implements hook_help().

File

uc_report/uc_report.module, line 21
Displays reports on sales, customers, and products to store admin.

Code

function uc_report_help($route_name, RouteMatchInterface $route_match) {
  $output = '';
  $route = \Drupal::routeMatch()
    ->getRouteName();

  //if (substr($route, 0, 10) == 'uc_report.') {
  if (strncmp($route_name, 'uc_report', 9) === 0) {
    $include_statuses = $include_offset = FALSE;

    // Include order status info?
    if (strpos($route_name, '/admin/store/reports/sales/year') === 0) {
      $include_statuses = TRUE;
    }
    else {
      switch ($route_name) {
        case 'uc_report.customers':
        case 'uc_report.products':
        case 'uc_report.sales':
          $include_statuses = TRUE;
          break;
      }
    }

    // Include timezone offset info?
    if (!strncmp($route_name, '/admin/store/reports/sales', 25)) {
      $include_offset = TRUE;
    }

    // Generate message for the path we're at.
    $output .= '<p>';
    switch ($route_name) {
      case 'uc_report.customers':
        $output .= t("The following are total orders, products, sales, and average order totals for each store customer. Clicking on the header links will toggle a descending or ascending order for that column. Clicking on a customer's name will take you to a detailed list of orders that customer has made. Clicking on a customers username will take you to their account page.");
        break;
      case 'uc_report.products':
        $output .= t('The table lists each product listed in the store, its amount sold, how many times it has been viewed, revenue it has produced, and gross profit it has generated. If you do not see the number of views you must enable the Statistics module on the <a href=":url">module administration page</a>.', [
          ':url' => Url::fromRoute('system.modules_list')
            ->toString(),
        ]);
        break;
      case 'uc_report.sales':
        $output .= t('These are the sales for the last two days, average sales for the month, and the projected sales for the rest of the month. Further down the list you will see other sales statistics.');
        break;
      case 'uc_report.sales_custom_report':
        $output .= t('Expand the fieldset below to customize the date range of this report, the statuses of orders displayed, and product display options.');
        break;
    }
    if (strpos($route_name, 'admin/store/reports/sales/year') === 0) {
      $year = $arg[5] ? $arg[5] : \Drupal::service('date.formatter')
        ->format(\Drupal::time()
        ->getRequestTime(), 'custom', "Y");
      $output .= t('This is the monthly break down of sales for the year @year. Clicking on each link will take you to a list of orders during that month.', [
        '@year' => $year,
      ]);
    }
    $output .= '</p>';

    // Include the statuses/offset as needed.
    if ($include_offset) {
      $output .= "<p>" . t('All reports are your local timezone, which is <b>@timezone</b>.', [
        '@timezone' => date_default_timezone_get(),
      ]) . "</p>";
    }
    if ($include_statuses) {
      $statuses = [];
      foreach (uc_report_order_statuses() as $status) {
        $statuses[] = SafeMarkup::checkPlain(OrderStatus::load($status)
          ->label());
      }
      $order_statuses = t('<b>Order statuses used:</b> @statuses', [
        '@statuses' => implode(', ', array_filter($statuses)),
      ]);
      $output .= "<p>{$order_statuses}</p>";
    }
  }
  return $output;
}