require DIR_WS_CLASSES . FILENAME_ORDERS_TRACKING;
$sr = new sales_report($srView, $startDate, $endDate, $srSort, $srStatus, $srFilter);
$startDate = $sr->startDate;
$endDate = $sr->endDate;
if ($srExp == 2) {
    $file_created = $sr->DownloadFile($srStatus, $startDate, $endDate, $srDownload, $srCustomer, $srDelivery, $srSeparator, $srBilling);
    if ($file_created == 'true') {
        header('Content-type: application/x-octet-stream');
        header('Content-disposition: attachment; filename=orders.csv');
        readfile(DIR_FS_ADMIN . 'orders.csv');
        unlink(DIR_FS_ADMIN . 'orders.csv');
    }
} elseif ($srExp == 3) {
    $OrderFilterString = 'order by date, orders_id, store_id';
    $StatusFilterString = '';
    $file_created = $sr->DownloadOrdersFile($srStatus, $startDate, $endDate, $srDownload, $StatusFilterString, $OrderFilterString);
    if ($file_created == 'true') {
        header('Content-type: application/x-octet-stream');
        header('Content-disposition: attachment; filename=orders.html');
        readfile(DIR_FS_ADMIN . 'orders.html');
        unlink(DIR_FS_ADMIN . 'orders.html');
    }
}
if ($srExp < 2) {
    // not for csv export
    ?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php 
    echo HTML_PARAMS;
    ?>
>