function uc_csv_add_new_report in Ubercart CSV 6.2
Same name and namespace in other branches
- 7.2 uc_csv.module \uc_csv_add_new_report()
1 string reference to 'uc_csv_add_new_report'
- uc_csv_menu in ./
uc_csv.module - implementation of hook_menu();
File
- ./
uc_csv.module, line 362
Code
function uc_csv_add_new_report($form_state, $report = NULL) {
// if no report is passed, then create the class so we do not get warnings
if ($report == NULL) {
$report = new stdClass();
}
// set up our form of properties for the report being sought.
$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['other'] = array(
'#type' => 'fieldset',
'#title' => t('Other 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'),
);
/* get a list of the order statuses available/created */
$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 = db_fetch_object($result)) {
$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['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,
);
$form['#redirect'] = array(
'admin/store/export/reports',
);
return $form;
}