function uc_reports_store_csv in Ubercart 7.3
Same name and namespace in other branches
- 5 uc_reports/uc_reports.module \uc_reports_store_csv()
- 6.2 uc_reports/uc_reports.module \uc_reports_store_csv()
Stores a CSV file for a report in Drupal's cache to be retrieved later.
Parameters
$report_id: A unique string that identifies the report of the CSV file.
$rows: The rows (table header included) that make CSV file.
Return value
An array containing the values need to build URL that return the CSV file of the report and the CSV data itself.
7 calls to uc_reports_store_csv()
- uc_reports_customers in uc_reports/
uc_reports.admin.inc - Displays the customer report.
- uc_reports_products in uc_reports/
uc_reports.admin.inc - Displays the product reports.
- uc_reports_products_custom in uc_reports/
uc_reports.admin.inc - Displays the custom product report.
- uc_reports_sales_custom in uc_reports/
uc_reports.admin.inc - Displays the custom sales report form and table.
- uc_reports_sales_year in uc_reports/
uc_reports.admin.inc - Displays the yearly sales report form and table.
File
- uc_reports/
uc_reports.admin.inc, line 1281 - Reports administration menu items.
Code
function uc_reports_store_csv($report_id, $rows) {
global $user;
$csv_output = '';
$user_id = empty($user->uid) ? session_id() : $user->uid;
foreach ($rows as $row) {
foreach ($row as $index => $column) {
$row[$index] = '"' . str_replace('"', '""', $column) . '"';
}
$csv_output .= implode(',', $row) . "\n";
}
cache_set('uc_reports_' . $report_id . '_' . $user_id, $csv_output, 'cache', REQUEST_TIME + 86400);
return array(
'user' => $user_id,
'report' => $report_id,
'csv' => $csv_output,
);
}