You are here

function uc_reports_help in Ubercart 7.3

Same name and namespace in other branches
  1. 5 uc_reports/uc_reports.module \uc_reports_help()
  2. 6.2 uc_reports/uc_reports.module \uc_reports_help()

Implements hook_help().

File

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

Code

function uc_reports_help($path, $arg) {
  $output = '';
  if (strncmp($path, 'admin/store/reports/', 20) === 0) {
    $include_statuses = $include_offset = FALSE;

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

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

    // Generate message for the path we're at.
    $output .= '<p>';
    switch ($path) {
      case 'admin/store/reports/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 'admin/store/reports/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>.', array(
          '!url' => url('admin/modules'),
        ));
        break;
      case 'admin/store/reports/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 'admin/store/reports/sales/custom':
        $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($path, 'admin/store/reports/sales/year') === 0) {
      $year = $arg[5] ? $arg[5] : format_date(REQUEST_TIME, '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.', array(
        '@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>.', array(
        '!timezone' => date_default_timezone_get(),
      )) . "</p>";
    }
    if ($include_statuses) {
      $statuses = array();
      foreach (uc_reports_order_statuses() as $status) {
        $statuses[] = db_query("SELECT title FROM {uc_order_statuses} WHERE order_status_id = :id", array(
          ':id' => $status,
        ))
          ->fetchField();
      }
      $order_statuses = t('<b>Order statuses used:</b> @statuses', array(
        '@statuses' => implode(', ', array_filter($statuses)),
      ));
      $output .= "<p>{$order_statuses}</p>";
    }
  }
  return $output;
}