View source
<?php
function uc_csv_menu() {
$items = array();
$items['admin/store/export'] = array(
'title' => t('CSV Export'),
'description' => t('Export Settings'),
'page callback' => 'drupal_get_form',
'page arguments' => array(
'uc_csv_settings',
),
'access callback' => 'uc_csv_both_perms',
'type' => MENU_NORMAL_ITEM,
'weight' => -1,
);
$items['admin/store/export/index'] = array(
'title' => t('Export Report Settings'),
'description' => t('Set up the reports you want to export.'),
'page callback' => 'uc_csv_report_grid',
'access callback' => 'user_access',
'access arguments' => array(
'administer ubercart csv export settings',
),
'weight' => -25,
'type' => MENU_LOCAL_TASK,
);
$items['admin/store/export/settings'] = array(
'title' => t('Settings'),
'description' => t('Export Settings'),
'page callback' => 'drupal_get_form',
'page arguments' => array(
'uc_csv_settings',
),
'access callback' => 'uc_csv_both_perms',
'type' => MENU_NORMAL_ITEM,
'weight' => -30,
);
$items['admin/store/export/create'] = array(
'title' => t('Create New Report'),
'description' => t('Add a new export report.'),
'page callback' => 'drupal_get_form',
'page arguments' => array(
'uc_csv_add_new_report',
),
'access callback' => 'user_access',
'access arguments' => array(
'administer ubercart csv export settings',
),
'weight' => -20,
'type' => MENU_LOCAL_TASK,
);
$items['admin/store/export/execute'] = array(
'title' => t('Export Report'),
'description' => t('Select report to export.'),
'page callback' => 'drupal_get_form',
'page arguments' => array(
'uc_csv_select_report_to_export',
),
'access callback' => 'uc_csv_both_perms',
'weight' => -15,
'type' => MENU_LOCAL_TASK,
);
$items['admin/store/export/reports/update/%uc_csv_report_id'] = array(
'title' => t('Update Report'),
'description' => t('Update an existing report'),
'page callback' => 'drupal_get_form',
'page arguments' => array(
'uc_csv_add_new_report',
5,
),
'access callback' => 'user_access',
'access arguments' => array(
'administer ubercart csv export settings',
),
'type' => MENU_CALLBACK,
);
$items['admin/store/export/reports/delete/%uc_csv_report_id'] = array(
'title' => t('Delete Report'),
'description' => t('Delete an existing export report.'),
'page callback' => 'drupal_get_form',
'page arguments' => array(
'uc_csv_delete_report',
5,
),
'access callback' => 'user_access',
'access arguments' => array(
'administer ubercart csv export settings',
),
'type' => MENU_CALLBACK,
);
return $items;
}
function uc_csv_both_perms() {
return user_access('administer ubercart csv export settings') || user_access('export ubercart reports as csv files');
}
function uc_csv_permission() {
return array(
'administer ubercart csv export settings' => array(
'title' => 'Administer CSV Export Settings',
),
'export ubercart reports as csv files' => array(
'title' => 'Allow report exports as CSV files',
),
);
}
function uc_csv_report_id_load($id) {
if (is_numeric($id)) {
$result = db_query("SELECT * FROM {uc_csv_reports} WHERE rid=:rid;", array(
':rid' => $id,
));
$report = $result
->fetchObject();
if (isset($report->report_name) && $report->report_name) {
return $report;
}
else {
drupal_set_message('Unable to load the requested report. Please report this error with a snapshot of your uc_csv_reports table', 'error');
return FALSE;
}
}
else {
return FALSE;
}
}
function uc_csv_settings($form, &$form_state) {
$form['uc_csv_enable_cron'] = array(
'#type' => 'checkbox',
'#title' => t('Enable cron tasks when cron job is run.'),
'#description' => t('Check this if you want the reports to export when crons are run on the intervals below.'),
'#default_value' => variable_get('uc_csv_enable_cron', FALSE),
);
$form['uc_csv_report_interval'] = array(
'#type' => 'select',
'#title' => t('Report export intervals'),
'#description' => t('If cron is enabled, the reports will be exported at the following intervals.'),
'#default_value' => variable_get('uc_csv_report_interval', 86400),
'#options' => array(
'3600' => t('Hourly'),
'10800' => t('Every Three Hours'),
'21600' => t('Every Six Hours'),
'43200' => t('Every Twelve Hours'),
'86400' => t('Once per day'),
),
);
return system_settings_form($form);
}
function uc_csv_cron() {
if (variable_get('uc_csv_report_last_export', 0) == 0) {
variable_set('uc_csv_report_last_export', time() - 3600);
}
if (variable_get('uc_csv_enable_cron', FALSE) == 1) {
if (variable_get('uc_csv_report_last_export', 0) < time() - variable_get('uc_csv_report_interval', 86400)) {
$result = db_query("SELECT * FROM {uc_csv_reports} WHERE email_enable=:email_enable", array(
':email_enable' => 1,
));
while ($report = $result
->fetchObject()) {
$form = array();
$form_state['values']['rid'] = $report->rid;
uc_csv_select_report_to_export_submit($form, $form_state, FALSE, NULL);
}
variable_set('uc_csv_report_last_export', time());
}
}
}
function uc_csv_report_grid() {
$i = 0;
$rows = array();
$header = array(
array(
'data' => t('Export Name'),
),
array(
'data' => t('Last Exported'),
'style' => 'text-align: center;',
),
array(
'data' => t('Last Order ID'),
'style' => 'text-align: center;',
),
array(
'data' => t('Actions'),
'style' => 'text-align: center;',
),
);
$result = db_query('SELECT * FROM {uc_csv_reports} ORDER BY report_name ASC');
while ($data = $result
->fetchObject()) {
if ($data->track < 1) {
$data->last_order_id = 'N/A';
}
$row = array();
$row[] = $data->report_name;
$row[] = array(
'data' => $data->last_exported,
'style' => 'text-align: center;',
);
$row[] = array(
'data' => $data->last_order_id,
'style' => 'text-align: center;',
);
$row[] = array(
'data' => l(t('Edit'), 'admin/store/export/reports/update/' . $data->rid) . ' | ' . l(t('Delete'), 'admin/store/export/reports/delete/' . $data->rid),
'style' => 'text-align: center;',
);
$rows[] = $row;
}
if (count($rows) == 0) {
$rows = array(
array(
'data' => array(
array(
'align' => 'center',
'colspan' => 4,
'data' => t('THERE ARE CURRENTLY NO CONFIGURED EXPORT REPORTS'),
),
),
),
);
}
$output = theme('table', array(
'header' => $header,
'rows' => $rows,
));
return $output;
}
function uc_csv_select_report_to_export_submit($form, &$form_state, $report = NULL) {
global $language;
if (empty($report)) {
$result = db_query("SELECT * FROM {uc_csv_reports} WHERE rid=:rid;", array(
':rid' => $form_state['values']['rid'],
));
$report = $result
->fetchObject();
$report->volatile = FALSE;
}
$order = uc_csv_generate_report($report);
if (!empty($report->track) && empty($report->volatile)) {
$result = db_query('SELECT MAX(order_id) AS order_id FROM {uc_orders}');
$odata = $result
->fetchObject();
$max_order = $odata->order_id;
$result = db_query("UPDATE {uc_csv_reports} \n SET last_order_id=:last_order_id, last_exported=:last_exported\n WHERE rid=:rid;", array(
':last_order_id' => $max_order,
':last_exported' => date('Y-m-d H:i:s', time()),
':rid' => $form_state['values']['rid'],
));
}
$file_name = uc_csv_clean_filename($report->report_name);
$file_name = $report->file_type ? $file_name . '.csv' : $file_name . ".xls";
if (!empty($report->email_enable)) {
$contents = _uc_csv_prepare_report($report, $order);
$from = variable_get('site_mail', ini_get('sendmail_from'));
$site_name = variable_get('site_name');
$boundary = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$boundary}x";
$email_content = theme('uc_csv_attached_report', array(
'report' => $report,
'boundary' => $mime_boundary,
'contents' => $contents,
'filename' => $file_name,
'filesize' => strlen($contents),
));
$params = array(
'body' => $email_content,
'subject' => t('Ubercart Export Report: ') . $report->report_name . ' on ' . date('m/d/Y'),
'boundary' => $mime_boundary,
);
$result = drupal_mail('uc_csv', 'uc_csv_key', $report->email_address, $language, $params, $from, TRUE);
if (!drupal_is_cli() || !function_exists('drush_main')) {
if (!_uc_csv_is_cron_running()) {
drupal_set_message(t('Ubercart Export Report: ') . $report->report_name . ' on ' . date('m/d/Y') . ' ' . t('sent'));
}
}
else {
drush_log(dt('Ubercart Export Report: ') . $report->report_name . ' on ' . date('m/d/Y') . ' ' . dt('sent'), 'ok');
}
}
else {
$contents = _uc_csv_prepare_report($report, $order);
if (drupal_is_cli() && function_exists('drush_main')) {
return array(
'contents' => $contents,
'report' => $report,
);
}
if ($report->file_type == 'csv') {
header('Content-Type: text/x-csv');
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Disposition: inline; filename="' . $file_name . '"');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
echo $contents;
exit;
}
else {
$encoding = $contents['encoding'];
$contents = $contents['contents'];
header("Content-Type: application/vnd.ms-excel; charset=" . $encoding);
header('Content-Disposition: inline; filename="' . $file_name . '"');
echo $contents;
exit;
}
}
}
function _uc_csv_prepare_report($report, $order) {
if ($report->file_type == 'csv') {
$headers = implode(',', $order['headers']) . "\n";
$source = NULL;
foreach ($order['order_data'] as $order) {
$csv_array = array();
foreach ($order as $cell) {
$csv_array[] = $cell;
}
$csv = fopen('php://temp/maxmemory:' . 1 * 1024 * 1024, 'r+');
fputcsv($csv, $csv_array);
rewind($csv);
$source = stream_get_contents($csv);
fclose($csv);
$source .= "\n";
}
return $headers . $source;
}
elseif ($report->file_type == 'xls') {
module_load_include('inc', 'uc_csv', 'inc/excel-export');
$xls = new Excel_XML('UTF-8', FALSE, $report->report_name);
$data = array(
$order['headers'],
);
foreach ($order['order_data'] as $line) {
$set = array();
foreach ($line as $key => $value) {
$set[] = $value;
}
$data[] = $set;
}
$xls
->addArray($data);
$contents = $xls->generateXML;
return $contents;
}
return FALSE;
}
function uc_csv_add_new_report($form, &$form_state) {
$report = $form_state['build_info']['args'];
if ($report == array()) {
$report = new stdClass();
$report->rid = $report->report_name = $report->shipping_address = NULL;
$report->billing_address = $report->products = $report->orderby = NULL;
$report->track = $report->file_type = $report->email_enable = $report->email_address = NULL;
}
else {
$report = $report[0];
}
$form = array();
$form['rid'] = array(
'#type' => 'hidden',
'#default_value' => $report->rid,
);
$form['export_options'] = array(
'#type' => 'fieldset',
'#title' => t('Export Options'),
'#weight' => 2,
'#collapsible' => TRUE,
);
$form['status_options'] = array(
'#type' => 'fieldset',
'#title' => t('Order Statuses to Export'),
'#weight' => 3,
'#collapsible' => TRUE,
);
$form['email'] = array(
'#type' => 'fieldset',
'#title' => t('Email Options'),
'#weight' => 4,
'#collapsible' => TRUE,
);
$form['other'] = array(
'#type' => 'fieldset',
'#title' => t('Report Email Options'),
'#weight' => 4,
'#collapsible' => TRUE,
);
$form['report_name'] = array(
'#type' => 'textfield',
'#title' => t('Report Name'),
'#default_value' => $report->report_name,
'#max_length' => 96,
'#required' => TRUE,
'#weight' => 1,
);
$default_options = array();
if ($report->shipping_address) {
$default_options[] = 'shipping';
}
if ($report->billing_address) {
$default_options[] = 'billing';
}
if ($report->products) {
$default_options[] = 'products';
}
$form['export_options']['options'] = array(
'#type' => 'checkboxes',
'#title' => t('Export Options'),
'#default_value' => $default_options,
'#options' => array(
'shipping' => t('Shipping Address'),
'billing' => t('Billing Address'),
'products' => t('Products'),
),
'#description' => t('Select the information you want exported in your report'),
);
$statuses = array();
if (isset($report->statuses) && $report->statuses) {
$default_statuses = unserialize($report->statuses);
}
else {
$default_statuses = array();
}
$result = db_query("SELECT order_status_id,title,state\n FROM {uc_order_statuses}\n ORDER BY weight ASC");
while ($sdata = $result
->fetchObject()) {
$statuses[$sdata->order_status_id] = $sdata->title;
}
$form['status_options']['statuses'] = array(
'#type' => 'checkboxes',
'#title' => t('Order Statuses to Export'),
'#default_value' => $default_statuses,
'#options' => $statuses,
'#description' => t('Select the order statuses to be exported in this report.'),
);
$form['email']['email_enable'] = array(
'#type' => 'checkbox',
'#title' => t('Check if you would like to have generated reports emailed as opposed to downloaded on generation.'),
'#description' => t('This is especially useful for when you have cron or drush generated emails that you do not want to have to deal with retrieving. Emails will be sent to the email address configured in this report.'),
'#default_value' => $report->email_enable,
);
$form['email']['email_address'] = array(
'#type' => 'textfield',
'#title' => t('Email address where you wish the report to be send to.'),
'#default_value' => $report->email_address,
);
$form['other']['orderby'] = array(
'#type' => 'select',
'#title' => t('Order By'),
'#default_value' => $report->orderby,
'#options' => array(
'order_id' => 'Order ID',
'last_name' => 'Customer Last Name',
),
'#description' => t('How you would like your report sorted.'),
);
$form['other']['track'] = array(
'#type' => 'select',
'#title' => t('Track Last Exported Orders'),
'#default_value' => $report->track,
'#options' => array(
'0' => 'No',
'1' => 'Yes',
),
'#description' => t('Select Yes if you would like for each export to be progressive instead of all inclusive.'),
);
$form['other']['file_type'] = array(
'#type' => 'select',
'#title' => t('Type of File To Export'),
'#default_value' => $report->file_type,
'#options' => array(
'csv' => 'CSV (Comma Separated Values)',
'xls' => 'Microsoft Excel XML Export',
),
'#description' => t('The type of file to be exported. Use Excel if trying to export data with special characters (foreign language) in it.'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Update Report Options'),
'#weight' => 5,
);
return $form;
}
function uc_csv_add_new_report_submit($form, $form_state) {
$shipping = $form_state['values']['options']['shipping'] ? 1 : 0;
$billing = $form_state['values']['options']['billing'] ? 1 : 0;
$products = $form_state['values']['options']['products'] ? 1 : 0;
$rdata = array(
'report_name' => $form_state['values']['report_name'],
'shipping_address' => $shipping,
'billing_address' => $billing,
'products' => $products,
'orderby' => $form_state['values']['orderby'],
'file_type' => $form_state['values']['file_type'],
'statuses' => serialize($form_state['values']['statuses']),
'track' => $form_state['values']['track'],
'email_enable' => $form_state['values']['email_enable'],
'email_address' => $form_state['values']['email_address'],
);
if (empty($form_state['values']['rid'])) {
$extra = array(
'last_exported' => date('Y-m-d H:i:s'),
'last_order_id' => 0,
);
$wdata = array_merge($rdata, $extra);
$result = drupal_write_record('uc_csv_reports', $wdata);
}
else {
$extra = array(
'rid' => $form_state['values']['rid'],
);
$wdata = array_merge($rdata, $extra);
$result = drupal_write_record('uc_csv_reports', $wdata, 'rid');
}
if ($result == TRUE) {
drupal_set_message("Report successfully saved");
}
else {
drupal_set_message("Your report could not be saved. Please submit a bug report", 'error');
}
drupal_goto('admin/store/export/reports');
}
function uc_csv_select_report_to_export($form_state) {
$options = array();
$reports = FALSE;
$result = db_query('SELECT * FROM {uc_csv_reports} ORDER BY report_name ASC;');
while ($ldata = $result
->fetchObject()) {
$reports = TRUE;
$options[$ldata->rid] = $ldata->report_name;
}
if ($reports == TRUE) {
$form = array();
$form['rid'] = array(
'#type' => 'select',
'#title' => 'Select the report that you would like export',
'#options' => $options,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Export Selected Report'),
);
return $form;
}
else {
drupal_set_message(t('Unable to get list of available reports.'));
drupal_goto('admin/store/export/reports');
}
}
function uc_csv_delete_report($form_state, $report) {
$form = array();
$form['rid'] = array(
'#type' => 'hidden',
'#value' => $report->rid,
);
$form['report_name'] = array(
'#type' => 'hidden',
'#value' => $report->report_name,
);
return confirm_form($form, t('Are you sure you wish to delete the %report export report?', array(
'%report' => $report->report_name,
)), 'admin/store/export/index', t('This action cannot be undone.'), t('Delete'), t('Cancel'));
}
function uc_csv_delete_report_submit($form, $form_state) {
db_query("DELETE FROM {uc_csv_reports} WHERE rid=:rid", array(
':rid' => (int) $form_state['values']['rid'],
));
drupal_set_message(t('%report report successfully deleted', array(
'%report' => $form_state['values']['report_name'],
)));
drupal_goto('admin/store/export/index');
}
function uc_csv_clean_filename($str, $replace = array(), $delimiter = '-') {
setlocale(LC_ALL, 'en_US.UTF8');
if (!empty($replace)) {
$str = str_replace((array) $replace, ' ', $str);
}
$clean = iconv('UTF-8', 'ASCII//TRANSLIT', $str);
$clean = preg_replace("/[^a-zA-Z0-9\\/_|+ -]/", '', $clean);
$clean = strtolower(trim($clean, '-'));
$clean = preg_replace("/[\\/_|+ -]+/", $delimiter, $clean);
return $clean;
}
function uc_csv_generate_report($report) {
$statuses = array();
foreach (unserialize($report->statuses) as $key => $value) {
if ($value != '0') {
$statuses[] = $value;
}
}
$selects = array();
$country = array();
$zone = array();
$headers = array(
'order_id',
'last_name',
'first_name',
'email_address',
'order_total',
'product_count',
);
$result = db_query("SELECT country_id,country_name FROM {uc_countries}");
while ($sdata = $result
->fetchObject()) {
$country[$sdata->country_id] = $sdata->country_name;
}
$result = db_query("SELECT zone_id,zone_code FROM {uc_zones}");
$date_range = NULL;
if (isset($report->start_date) && $report->start_date) {
$start_date = strtotime($report->start_date);
$date_range = 'AND created >= ' . $start_date . ' ';
}
if (isset($report->end_date) && $report->end_date) {
$end_date = strtotime($report->end_date);
if (!empty($date_range)) {
$date_range .= 'AND created <= ' . $end_date . ' ';
}
else {
$date_range = 'AND created <= ' . $end_date . ' ';
}
}
while ($sdata = $result
->fetchObject()) {
$zone[$sdata->zone_id] = $sdata->zone_code;
}
if ($report->shipping_address == 1) {
$selects[] = 'o.delivery_first_name,o.delivery_last_name,o.delivery_phone,o.delivery_company,o.delivery_street1,o.delivery_street2,o.delivery_city,o.delivery_zone,o.delivery_postal_code,o.delivery_country';
$headers = array_merge($headers, array(
'shipping_first_name',
'shipping_last_name',
'shipping_phone',
'shipping_company',
'shipping_street1',
'shipping_street2',
'shipping_city',
'shipping_state',
'shipping_zipcode',
'shipping_country',
));
}
if ($report->billing_address == 1) {
$selects[] = 'o.billing_phone,o.billing_company,o.billing_street1,o.billing_street2,o.billing_city,o.billing_zone,o.billing_postal_code,o.billing_country';
$headers = array_merge($headers, array(
'billing_phone',
'billing_company',
'billing_street1',
'billing_street2',
'billing_city',
'billing_state',
'billing_zipcode',
'billing_country',
));
}
if ($report->products == 1) {
$headers = array_merge($headers, array(
'products',
'tax',
'shipping',
'weight',
));
}
if ($report->orderby == 'orderid') {
$orderby = 'o.order_id ASC';
}
elseif ($report->orderby == 'last_name') {
$orderby = 'o.billing_last_name ASC';
}
else {
$orderby = 'o.order_id ASC, o.billing_last_name ASC';
}
if (count($selects) > 0) {
$sel = ',' . join(',', $selects);
}
else {
$sel = NULL;
}
if (isset($report->track) && $report->track < 1) {
$report->last_order_id = 0;
}
$complete_order = array();
$result = db_query("SELECT o.order_id, o.billing_last_name, o.billing_first_name, o.primary_email,o.order_total, o.product_count" . $sel . "\n FROM {uc_orders} o\n WHERE o.order_id > :order_id && o.order_status IN ('" . join("','", $statuses) . "') " . $date_range . "\n ORDER BY " . $orderby, array(
':order_id' => $report->last_order_id,
));
while ($order = $result
->fetchObject()) {
if ($report->shipping_address == 1) {
$order->delivery_zone = $zone[$order->delivery_zone];
$order->delivery_country = $country[$order->delivery_country];
}
if ($report->billing_address == 1) {
$order->billing_zone = $zone[$order->billing_zone];
$order->billing_country = $country[$order->billing_country];
}
if ($report->products == 1) {
$product = NULL;
$calc_attribute = array();
$total_weight = 0;
$presults = db_query("SELECT model, title, qty, price, data, weight\n FROM {uc_order_products} \n WHERE order_id=:order_id", array(
':order_id' => $order->order_id,
));
while ($pdata = $presults
->fetchObject()) {
$total_weight += $pdata->weight;
$data = unserialize($pdata->data);
if (isset($data['attributes']) && is_array($data['attributes'])) {
foreach ($data['attributes'] as $key => $attribute) {
foreach ($attribute as $display_attribute) {
$calc_attribute[] = $key . ": " . $display_attribute;
}
}
}
if (count($calc_attribute) > 0) {
$title = $pdata->title . " - " . join(',', $calc_attribute);
}
else {
$title = $pdata->title;
}
$product .= $pdata->qty . ' - ' . $title . ' (' . $pdata->model . '): $' . number_format($pdata->price, 2) . 'ea.';
}
$order->products = $product;
$stResult = db_query("SELECT amount AS sales_tax\n FROM {uc_order_line_items}\n WHERE order_id = :order_id\n AND type=:type", array(
':order_id' => $order->order_id,
':type' => 'tax',
));
$stdata = $stResult
->fetchObject();
$order->sales_tax = isset($stdata->sales_tax) ? $stdata->sales_tax : "N/A";
$stResult = db_query("SELECT amount AS shipping\n FROM {uc_order_line_items}\n WHERE order_id = :order_id\n AND type=:type", array(
':order_id' => $order->order_id,
':type' => 'shipping',
));
$stdata = $stResult
->fetchObject();
$order->shipping = isset($stdata->shipping) ? $stdata->shipping : "N/A";
$order->weight = $total_weight;
}
$complete_order[] = (array) $order;
}
return array(
'order_data' => $complete_order,
'headers' => $headers,
);
}
function _uc_csv_save_report(&$report, $contents, $file_name) {
if (drupal_is_cli() && function_exists('drush_main')) {
file_put_contents($file_name, $contents);
$report->filepath = getcwd() . '/' . $file_name;
drush_log('File successfully saved.', 'ok');
}
else {
if (!file_exists(drupal_realpath('public://uc-csv-reports/'))) {
drupal_mkdir('public://uc-csv-reports/');
}
$destination = 'public://uc-csv-reports/' . $file_name;
$filepath = file_unmanaged_save_data($contents, $destination, FILE_EXISTS_REPLACE);
if ($filepath != FALSE) {
$report->filepath = $filepath;
}
else {
$report->filepath = FALSE;
drupal_set_message('File could not be saved or assigned.', 'error');
}
}
}
function uc_csv_mail($key, &$message, $params) {
if ($key == 'uc_csv_key') {
$headers = array(
'MIME-Version' => '1.0',
'Content-Type' => 'multipart/mixed; boundary="' . $params['boundary'] . '"',
'Content-Transfer-Encoding' => '8Bit',
'X-Mailer' => 'Drupal',
);
foreach ($headers as $key => $value) {
$message['headers'][$key] = $value;
}
$message['subject'] = t($params['subject']);
$message['body'][] = $params['body'];
}
}
function uc_csv_theme($existing, $type, $theme, $path) {
return array(
'uc_csv_attached_report' => array(
'template' => 'uc-csv-attached-report',
'arguments' => array(
'report' => NULL,
'boundary' => NULL,
'contents' => NULL,
'filename' => NULL,
'filesize' => NULL,
),
),
'uc_csv_help_page' => array(
'template' => 'uc-csv-help-page',
'arguments' => array(
'create_new_report' => NULL,
),
),
);
}
function _uc_csv_is_cron_running() {
if (!lock_acquire('cron', 240.0)) {
return TRUE;
}
else {
lock_release('cron');
return FALSE;
}
}
function uc_csv_help($path, $args) {
switch ($path) {
case 'admin/help#uc_csv':
$create_new_report = l('Create New Report', 'admin/store/export/create');
return theme('uc_csv_help_page', array(
'create_new_report' => $create_new_report,
));
break;
}
}