= '7') {
$d['time'] = $year['year'] . '-07-01';
} else {
$d['time'] = $year['year'] . '-01-01';
}
$header = TEXT_REPORT_HEADER_FROM_SEMIYEAR;
break;
case 'annually':
$year_query = mysql_query("SELECT year(now()) as year");
$year = mysql_fetch_array($year_query, MYSQL_ASSOC);
$d['time'] = $year['year'] . '-01-01';
$header = TEXT_REPORT_HEADER_FROM_YEAR;
break;
}
if (isset($_GET['date']) && ($_GET['date'] == 'yes')) {
$header = TEXT_REPORT_BETWEEN_DAYS . $_GET['sdate'] . ' and ' . $_GET['edate'] . ': ';
$order_query = mysql_query("select orders_id from orders where date_purchased > '" . $_GET['sdate'] . "' and date_purchased < '" . $_GET['edate'] . "' order by orders_id asc");
} else {
if ($_GET['report_id'] != '1') {
$header_date_query = mysql_query("SELECT DATE_FORMAT('" . $d['time'] . "', '%W, %M %d, %Y') as date");
$header_date = mysql_fetch_array($header_date_query, MYSQL_ASSOC);
$header .= $header_date['date'];
$order_query = mysql_query("select orders_id from orders where date_purchased > '" . $d['time'] . "' and date_purchased < now() order by orders_id asc");
} else {
$order_query = mysql_query("select orders_id from orders order by orders_id asc");
}
}
$o = array();
while ($order = mysql_fetch_array($order_query, MYSQL_ASSOC)) {
$o[] = $order['orders_id'];
}
//echo '
| |
';
$page_contents .= '| '. TEXT_TOTAL_ITEMS_SOLD . $total_items_sold . ' |
';
$page_contents .= '| '. TEXT_SALES_AMOUNT . $currencies->format($total_price) . ' |
';
$page_contents .= '| '. TEXT_TOTAL_COST . $currencies->format($total_cost) . ' |
';
$page_contents .= '| '. TEXT_TOTAL_GROSS_PROFIT . $currencies->format(($total_price - $total_cost)) . ' |
';
$page_contents .= '| |
';
$contents2 .= '| '. TEXT_TOTAL_ITEMS_SOLD .' | ' . $total_items_sold . ' |
'.
'| '. TEXT_SALES_AMOUNT .' | ' . $currencies->format($total_price) . ' |
'.
'| '. TEXT_TOTAL_COST .' | ' . $currencies->format($total_cost) . ' |
'.
'| '. TEXT_TOTAL_GROSS_PROFIT .' | ' . $currencies->format(($total_price - $total_cost)) . ' |
';
$csv_data .= "\n\n";
$csv_data .= TEXT_TOTAL_ITEMS_SOLD . "\t" . $total_items_sold . "\n" .
TEXT_SALES_AMOUNT . "\t" . $currencies->format($total_price) . "\n" .
TEXT_TOTAL_COST . "\t" . $currencies->format($total_cost) . "\n" .
TEXT_TOTAL_GROSS_PROFIT . "\t" . $currencies->format(($total_price - $total_cost)) . "\n";
if (isset($_GET['action']) && ($_GET['action'] == 'export')) {
/********************************************
Set the automatic download section
/********************************************/
/*header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=" . $_GET['file'] . ".xls");
header("Pragma: no-cache");
header("Expires: 0");
print "$csv_header\n$csv_data";
exit();*/
/*header("Content-Type: application/vnd.ms-excel");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");*/
$time_query = tep_db_query("select CURDATE() as time");
$time = tep_db_fetch_array($time_query);
if (isset($_GET['date']) && ($_GET['date'] == 'yes')) {
$filename = $time['time'] . "__-__" . $_GET['sdate'] . '_-_' . $_GET['edate'];
} else {
$filename = $time['time'] . "__-__" . $_GET['report_id'];
}
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=" . $filename . ".xls");
header("Pragma: no-cache");
header("Expires: 0");
$t='
|
' . $header. '
|
| |
|
'. TEXT_ORDER_ID .'
|
'. TEXT_ITEMS_SOLD .'
|
'. TEXT_SALES_AMOUNT .'
|
'. TEXT_COST .'
|
'. TEXT_GROSS_PROFIT .'
|
'
. $test .
'
| |
'
. $contents2 .
'
| |
| This report was generated by Margin Report. An Eclyptiq contribution for osCommerce ms2.2. |
';
print "$t";
exit();
}
$page_contents .= '| ' . tep_draw_form('report', FILENAME_MARGIN_REPORT2, '', 'get') . TEXT_SHOW . ' ';
$options = array();
$options[] = array('id' => 'all', 'text' => TEXT_SELECT_REPORT);
$options[] = array('id' => 'daily', 'text' => TEXT_SELECT_REPORT_DAILY);
$options[] = array('id' => 'weekly', 'text' => TEXT_SELECT_REPORT_WEEKLY);
$options[] = array('id' => 'monthly', 'text' => TEXT_SELECT_REPORT_MONTHLY);
$options[] = array('id' => 'quarterly', 'text' => TEXT_SELECT_REPORT_QUARTERLY);
$options[] = array('id' => 'semiannually', 'text' => TEXT_SELECT_REPORT_SEMIANNUALLY);
$options[] = array('id' => 'annually', 'text' => TEXT_SELECT_REPORT_ANNUALLY);
$page_contents .= tep_draw_pull_down_menu('report_id', $options, (isset($HTTP_GET_VARS['report_id']) ? $HTTP_GET_VARS['report_id'] : '1'), 'onchange="this.form.submit()"');
$page_contents .= ' |
| |
';
$page_contents .= ' |
';
$page_contents .= '| |
';
$page_contents .= '| ' . tep_draw_form('export_to_file_by_date', FILENAME_MARGIN_REPORT2, 'get', '') . tep_draw_hidden_field('action', 'export') . tep_draw_hidden_field('date', 'yes') . TEXT_QUERY_DATES.' |
|
';
?>
>