=== modified file 'uc_reports/uc_reports.admin.inc' --- uc_reports/uc_reports.admin.inc 2009-03-16 13:41:39 +0000 +++ uc_reports/uc_reports.admin.inc 2009-04-16 15:03:37 +0000 @@ -71,6 +71,11 @@ break; } + $context = array( + 'revision' => 'formatted', + 'location' => 'customer-report', + ); + $customers = pager_query($sql . tablesort_sql($header), $page_size, 0, $sql_count); while ($customer = db_fetch_array($customers)) { @@ -80,8 +85,8 @@ $customer_name = $customer['name']; $orders = (!empty($customer['orders']) ? $customer['orders'] : 0); $products = (!empty($customer['products']) ? $customer['products'] : 0); - $total_revenue = uc_currency_format($customer['total']); - $average_revenue = uc_currency_format($customer['average']); + $total_revenue = uc_price($customer['total'], $context); + $average_revenue = uc_price($customer['average'], $context); $rows[] = array( array('data' => $customer_number), array('data' => $name, 'nowrap' => 'nowrap'), @@ -173,15 +178,20 @@ $sql_count = "SELECT COUNT(n.nid) FROM $sql_tables WHERE $sql_conditions"; + $context = array( + 'revision' => 'formatted', + 'location' => 'products-report', + ); + $products = pager_query("SELECT $sql_vars FROM $sql_tables WHERE $sql_conditions GROUP BY n.nid, n.title" . tablesort_sql($header), $page_size, 0, $sql_count); while ($product = db_fetch_array($products)) { $product_cell = l($product['title'], 'node/'. ($product['nid'])); $product_csv = $product['title']; $sold_cell = (empty($product['sold'])) ? 0 : $product['sold']; $sold_csv = $sold_cell; - $revenue_cell = uc_currency_format((empty($product['revenue'])) ? 0 : $product['revenue']); + $revenue_cell = uc_price((empty($product['revenue'])) ? 0 : $product['revenue'], $context); $revenue_csv = $revenue_cell; - $gross_cell = uc_currency_format((empty($product['gross'])) ? 0 : $product['gross']); + $gross_cell = uc_price((empty($product['gross'])) ? 0 : $product['gross'], $context); $gross_csv = $gross_cell; $row = array( @@ -206,6 +216,7 @@ $csv_rows[] = $csv_row; if (module_exists('uc_attribute')) { + $context['location'] = 'product-attribute-report'; // Get the SKUs from this product. $models = _uc_reports_product_get_skus($product['nid']); // Add the product breakdown rows @@ -217,10 +228,14 @@ $product_csv = " $model"; $breakdown_sold = ((!empty($sold)) ? $sold : 0); $sold_csv = ((!empty($sold)) ? $sold : 0); - $breakdown_revenue = (uc_currency_format((!empty($revenue)) ? $revenue : 0)); - $revenue_csv = (uc_currency_format((!empty($revenue)) ? $revenue : 0)); - $breakdown_gross = (uc_currency_format((!empty($gross)) ? $gross : 0)); - $gross_csv = (uc_currency_format((!empty($gross)) ? $gross : 0)); + + $context['revision'] = 'themed'; + $breakdown_revenue = uc_price((!empty($revenue)) ? $revenue : 0, $context); + $breakdown_gross = uc_price((!empty($gross)) ? $gross : 0, $context); + + $context['revision'] = 'formatted'; + $revenue_csv = uc_price((!empty($revenue)) ? $revenue : 0, $context); + $gross_csv = uc_price((!empty($gross)) ? $gross : 0, $context); $row = array( 'data' => array( @@ -398,11 +413,15 @@ // Calculate and add today's sales summary to the report table. $today = _uc_reports_get_sales($today_start); + $context = array( + 'location' => 'sales-report-summary', + ); + $rows[] = array( l(t('Today, !date', array('!date' => format_date($today_start, 'custom', $format, 0))), 'admin/store/orders/search/results/0/0/0/0/0/0/'. $today_start .'/'. $today_end), $today['total'], - uc_currency_format($today['income']), - uc_currency_format($today['average']), + uc_price($today['income'], $context), + uc_price($today['average'], $context), ); // Calculate and add yesterday's sales summary to the report table. @@ -411,8 +430,8 @@ $rows[] = array( l(t('Yesterday, !date', array('!date' => format_date($today_start - 86400, 'custom', $format, 0))), 'admin/store/orders/search/results/0/0/0/0/0/0/'. ($today_start - 86400) .'/'. ($today_end - 86400)), $yesterday['total'], - uc_currency_format($yesterday['income']), - uc_currency_format($yesterday['average']), + uc_price($yesterday['income'], $context), + uc_price($yesterday['average'], $context), ); // Get the sales report for the month. @@ -423,8 +442,8 @@ $rows[] = array( l(t('Month-to-date, @month', array('@month' => $month_title)), 'admin/store/orders/search/results/0/0/0/0/0/0/'. $month_start .'/'. $month_end), $month['total'], - uc_currency_format($month['income']), - uc_currency_format($month['average']), + uc_price($month['income'], $context), + uc_price($month['average'], $context), ); // Calculate the daily averages for the month. @@ -442,7 +461,7 @@ $rows[] = array( t('Daily average for @month', array('@month' => $month_title)), $daily_orders, - uc_currency_format($daily_revenue), + uc_price($daily_revenue, $context), '', ); @@ -453,7 +472,7 @@ $rows[] = array( t('Projected totals for @date', array('@date' => $month_title)), round($month['total'] + ($daily_orders * $remaining_days), 2), - uc_currency_format(round($month['income'] + ($daily_revenue * $remaining_days), 2)), + uc_price(round($month['income'] + ($daily_revenue * $remaining_days), 2), $context), '', ); @@ -464,7 +483,7 @@ $header = array(array('data' => t('Statistics'), 'width' => '50%'), ''); $rows = array( - array(array('data' => t('Grand total sales')), array('data' => uc_currency_format(db_result(db_query("SELECT SUM(order_total) FROM {uc_orders} WHERE order_status IN $order_statuses"))))), + array(array('data' => t('Grand total sales')), array('data' => uc_price(db_result(db_query("SELECT SUM(order_total) FROM {uc_orders} WHERE order_status IN $order_statuses")))), $context), array(array('data' => t('Customers total')), array('data' => db_result(db_query("SELECT COUNT(DISTINCT uid) FROM {uc_orders} WHERE order_status IN $order_statuses")))), array(array('data' => t('New customers today')), array('data' => db_result(db_query("SELECT COUNT(DISTINCT uid) FROM {uc_orders} WHERE order_status IN $order_statuses AND %d >= created AND created >= %d", $today_end, $today_start)))), array(array('data' => t('Online customers')), array('data' => db_result(db_query("SELECT COUNT(DISTINCT s.uid) FROM {sessions} as s LEFT JOIN {uc_orders} as o ON s.uid = o.uid WHERE s.uid > 0 AND o.order_status IN $order_statuses")))), @@ -527,6 +546,11 @@ // Build the header to the CSV export. $csv_rows = array(array(t('Month'), t('Number of orders'), t('Total revenue'), t('Average order'))); + $context = array( + 'revision' => 'formatted', + 'location' => 'sales-year-report', + ); + // For each month of the year... for ($i = 1; $i <= 12; $i++) { // Calculate the start and end timestamps for the month in local time. @@ -548,16 +572,16 @@ $rows[] = array( l(gmdate('M Y', $month_start), 'admin/store/orders/search/results/0/0/0/0/0/0/'. $month_start .'/'. $month_end), $month_sales['total'], - uc_currency_format($month_sales['income']), - uc_currency_format($month_average), + uc_price($month_sales['income'], $context), + uc_price($month_average, $context), ); // Add the data to the CSV export. $csv_rows[] = array( gmdate('M Y', $month_start), $month_sales['total'], - uc_currency_format($month_sales['income']), - uc_currency_format($month_average), + uc_price($month_sales['income'], $context), + uc_price($month_average, $context), ); } @@ -580,16 +604,16 @@ $rows[] = array( l(t('Total @year', array('@year' => $year)), 'admin/store/orders/search/results/0/0/0/0/0/0/'. $year_start .'/'. $year_end), $year_sales['total'], - uc_currency_format($year_sales['income']), - uc_currency_format($year_average), + uc_price($year_sales['income'], $context), + uc_price($year_average, $context), ); // Add the total data to the CSV export. $csv_rows[] = array( t('Total @year', array('@year' => $year)), $year_sales['total'], - uc_currency_format($year_sales['income']), - uc_currency_format($year_average), + uc_price($year_sales['income'], $context), + uc_price($year_average, $context), ); // Cache the CSV export. @@ -672,6 +696,11 @@ // Grab the subreports based on the date range and the report breakdown. $subreports = _uc_reports_subreport_intervals($args['start_date'], $args['end_date'], $args['length']); + $context = array( + 'revision' => 'formatted', + 'location' => 'sales-custom-report', + ); + // Loop through the subreports and build the report table. foreach ($subreports as $subreport) { $product_data = ''; @@ -722,7 +751,7 @@ array('data' => $date, 'nowrap' => 'nowrap'), empty($order_data) ? '0' : $order_data, empty($product_data) ? '0' : $product_data, - uc_currency_format($revenue_count), + uc_price($revenue_count, $context), ); // Add the data to the CSV export. @@ -730,7 +759,7 @@ $date, empty($order_csv) ? '0' : $order_csv, empty($product_csv) ? '0' : $product_csv, - uc_currency_format($revenue_count), + uc_price($revenue_count, $context), ); } @@ -744,7 +773,7 @@ t('Total'), $order_total, $product_total, - uc_currency_format($revenue_total), + uc_price($revenue_total, $context), ); // Add the total data to the CSV export. @@ -752,7 +781,7 @@ t('Total'), $order_total, $product_total, - uc_currency_format($revenue_total), + uc_price($revenue_total, $context), ); // Cache the CSV export.