<?php
/*
$Id: orders.php,v 1.112 2003/06/29 22:50:52 hpdl Exp $
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
Released under the GNU General Public License
*/
/*/////////////////////////////////////////////////////////*/
/* Mindsparx Admin created by Janne.k @ www.mindsparx.org */
/*/////////////////////////////////////////////////////////*/
require('includes/application_top.php');
require(DIR_WS_CLASSES . 'currencies.php');
$currencies = new currencies();
$orders_statuses = array();
$orders_status_array = array();
$orders_status_query = tep_db_query("select orders_status_id, orders_status_name from " . TABLE_ORDERS_STATUS . " where language_id = '" . (int)$languages_id . "'");
while ($orders_status = tep_db_fetch_array($orders_status_query)) {
$orders_statuses[] = array('id' => $orders_status['orders_status_id'],
'text' => $orders_status['orders_status_name']);
$orders_status_array[$orders_status['orders_status_id']] = $orders_status['orders_status_name'];
}
$action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
if (tep_not_null($action)) {
switch ($action) {
case 'update_order':
$oID = tep_db_prepare_input($HTTP_GET_VARS['oID']);
$status = tep_db_prepare_input($HTTP_POST_VARS['status']);
$comments = tep_db_prepare_input($HTTP_POST_VARS['comments']);
$order_updated = false;
$check_status_query = tep_db_query("select customers_name, customers_email_address, orders_status, date_purchased from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'");
$check_status = tep_db_fetch_array($check_status_query);
if ( ($check_status['orders_status'] != $status) || tep_not_null($comments)) {
tep_db_query("update " . TABLE_ORDERS . " set orders_status = '" . tep_db_input($status) . "', last_modified = now() where orders_id = '" . (int)$oID . "'");
$customer_notified = '0';
if (isset($HTTP_POST_VARS['notify']) && ($HTTP_POST_VARS['notify'] == 'on')) {
$notify_comments = '';
if (isset($HTTP_POST_VARS['notify_comments']) && ($HTTP_POST_VARS['notify_comments'] == 'on')) {
$notify_comments = sprintf(EMAIL_TEXT_COMMENTS_UPDATE, $comments) . "\n\n";
}
$email = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' . tep_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $oID, 'SSL') . "\n" . EMAIL_TEXT_DATE_ORDERED . ' ' . tep_date_long($check_status['date_purchased']) . "\n\n" . $notify_comments . sprintf(EMAIL_TEXT_STATUS_UPDATE, $orders_status_array[$status]);
tep_mail($check_status['customers_name'], $check_status['customers_email_address'], EMAIL_TEXT_SUBJECT, $email, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
$customer_notified = '1';
}
tep_db_query("insert into " . TABLE_ORDERS_STATUS_HISTORY . " (orders_id, orders_status_id, date_added, customer_notified, comments) values ('" . (int)$oID . "', '" . tep_db_input($status) . "', now(), '" . tep_db_input($customer_notified) . "', '" . tep_db_input($comments) . "')");
$order_updated = true;
}
if ($order_updated == true) {
$messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success');
} else {
$messageStack->add_session(WARNING_ORDER_NOT_UPDATED, 'warning');
}
tep_redirect(tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('action')) . 'action=edit'));
break;
case 'deleteconfirm':
$oID = tep_db_prepare_input($HTTP_GET_VARS['oID']);
tep_remove_order($oID, $HTTP_POST_VARS['restock']);
tep_redirect(tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('oID', 'action'))));
break;
}
}
if (($action == 'edit') && isset($HTTP_GET_VARS['oID'])) {
$oID = tep_db_prepare_input($HTTP_GET_VARS['oID']);
$orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'");
$order_exists = true;
if (!tep_db_num_rows($orders_query)) {
$order_exists = false;
$messageStack->add(sprintf(ERROR_ORDER_DOES_NOT_EXIST, $oID), 'error');
}
}
include(DIR_WS_CLASSES . 'order.php');
?>
<?php
$action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
$error = false;
$processed = false;
if (tep_not_null($action)) {
switch ($action) {
case 'update':
$customers_id = tep_db_prepare_input($HTTP_GET_VARS['cID']);
$customers_firstname = tep_db_prepare_input($HTTP_POST_VARS['customers_firstname']);
$customers_lastname = tep_db_prepare_input($HTTP_POST_VARS['customers_lastname']);
$customers_email_address = tep_db_prepare_input($HTTP_POST_VARS['customers_email_address']);
$customers_telephone = tep_db_prepare_input($HTTP_POST_VARS['customers_telephone']);
$customers_fax = tep_db_prepare_input($HTTP_POST_VARS['customers_fax']);
$customers_newsletter = tep_db_prepare_input($HTTP_POST_VARS['customers_newsletter']);
$customers_gender = tep_db_prepare_input($HTTP_POST_VARS['customers_gender']);
$customers_dob = tep_db_prepare_input($HTTP_POST_VARS['customers_dob']);
$default_address_id = tep_db_prepare_input($HTTP_POST_VARS['default_address_id']);
$entry_street_address = tep_db_prepare_input($HTTP_POST_VARS['entry_street_address']);
$entry_suburb = tep_db_prepare_input($HTTP_POST_VARS['entry_suburb']);
$entry_postcode = tep_db_prepare_input($HTTP_POST_VARS['entry_postcode']);
$entry_city = tep_db_prepare_input($HTTP_POST_VARS['entry_city']);
$entry_country_id = tep_db_prepare_input($HTTP_POST_VARS['entry_country_id']);
$entry_company = tep_db_prepare_input($HTTP_POST_VARS['entry_company']);
$entry_state = tep_db_prepare_input($HTTP_POST_VARS['entry_state']);
if (isset($HTTP_POST_VARS['entry_zone_id'])) $entry_zone_id = tep_db_prepare_input($HTTP_POST_VARS['entry_zone_id']);
if (strlen($customers_firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) {
$error = true;
$entry_firstname_error = true;
} else {
$entry_firstname_error = false;
}
if (strlen($customers_lastname) < ENTRY_LAST_NAME_MIN_LENGTH) {
$error = true;
$entry_lastname_error = true;
} else {
$entry_lastname_error = false;
}
if (ACCOUNT_DOB == 'true') {
if (checkdate(substr(tep_date_raw($customers_dob), 4, 2), substr(tep_date_raw($customers_dob), 6, 2), substr(tep_date_raw($customers_dob), 0, 4))) {
$entry_date_of_birth_error = false;
} else {
$error = true;
$entry_date_of_birth_error = true;
}
}
if (strlen($customers_email_address) < ENTRY_EMAIL_ADDRESS_MIN_LENGTH) {
$error = true;
$entry_email_address_error = true;
} else {
$entry_email_address_error = false;
}
if (!tep_validate_email($customers_email_address)) {
$error = true;
$entry_email_address_check_error = true;
} else {
$entry_email_address_check_error = false;
}
if (strlen($entry_street_address) < ENTRY_STREET_ADDRESS_MIN_LENGTH) {
$error = true;
$entry_street_address_error = true;
} else {
$entry_street_address_error = false;
}
if (strlen($entry_postcode) < ENTRY_POSTCODE_MIN_LENGTH) {
$error = true;
$entry_post_code_error = true;
} else {
$entry_post_code_error = false;
}
if (strlen($entry_city) < ENTRY_CITY_MIN_LENGTH) {
$error = true;
$entry_city_error = true;
} else {
$entry_city_error = false;
}
if ($entry_country_id == false) {
$error = true;
$entry_country_error = true;
} else {
$entry_country_error = false;
}
if (ACCOUNT_STATE == 'true') {
if ($entry_country_error == true) {
$entry_state_error = true;
} else {
$zone_id = 0;
$entry_state_error = false;
$check_query = tep_db_query("select count(*) as total from " . TABLE_ZONES . " where zone_country_id = '" . (int)$entry_country_id . "'");
$check_value = tep_db_fetch_array($check_query);
$entry_state_has_zones = ($check_value['total'] > 0);
if ($entry_state_has_zones == true) {
$zone_query = tep_db_query("select zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$entry_country_id . "' and zone_name = '" . tep_db_input($entry_state) . "'");
if (tep_db_num_rows($zone_query) == 1) {
$zone_values = tep_db_fetch_array($zone_query);
$entry_zone_id = $zone_values['zone_id'];
} else {
$error = true;
$entry_state_error = true;
}
} else {
if ($entry_state == false) {
$error = true;
$entry_state_error = true;
}
}
}
}
if (strlen($customers_telephone) < ENTRY_TELEPHONE_MIN_LENGTH) {
$error = true;
$entry_telephone_error = true;
} else {
$entry_telephone_error = false;
}
$check_email = tep_db_query("select customers_email_address from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($customers_email_address) . "' and customers_id != '" . (int)$customers_id . "'");
if (tep_db_num_rows($check_email)) {
$error = true;
$entry_email_address_exists = true;
} else {
$entry_email_address_exists = false;
}
if ($error == false) {
$sql_data_array = array('customers_firstname' => $customers_firstname,
'customers_lastname' => $customers_lastname,
'customers_email_address' => $customers_email_address,
'customers_telephone' => $customers_telephone,
'customers_fax' => $customers_fax,
'customers_newsletter' => $customers_newsletter);
if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $customers_gender;
if (ACCOUNT_DOB == 'true') $sql_data_array['customers_dob'] = tep_date_raw($customers_dob);
tep_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', "customers_id = '" . (int)$customers_id . "'");
tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set customers_info_date_account_last_modified = now() where customers_info_id = '" . (int)$customers_id . "'");
if ($entry_zone_id > 0) $entry_state = '';
$sql_data_array = array('entry_firstname' => $customers_firstname,
'entry_lastname' => $customers_lastname,
'entry_street_address' => $entry_street_address,
'entry_postcode' => $entry_postcode,
'entry_city' => $entry_city,
'entry_country_id' => $entry_country_id);
if (ACCOUNT_COMPANY == 'true') $sql_data_array['entry_company'] = $entry_company;
if (ACCOUNT_SUBURB == 'true') $sql_data_array['entry_suburb'] = $entry_suburb;
if (ACCOUNT_STATE == 'true') {
if ($entry_zone_id > 0) {
$sql_data_array['entry_zone_id'] = $entry_zone_id;
$sql_data_array['entry_state'] = '';
} else {
$sql_data_array['entry_zone_id'] = '0';
$sql_data_array['entry_state'] = $entry_state;
}
}
tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', "customers_id = '" . (int)$customers_id . "' and address_book_id = '" . (int)$default_address_id . "'");
tep_redirect(tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $customers_id));
} else if ($error == true) {
$cInfo = new objectInfo($HTTP_POST_VARS);
$processed = true;
}
break;
case 'deleteconfirm':
$customers_id = tep_db_prepare_input($HTTP_GET_VARS['cID']);
if (isset($HTTP_POST_VARS['delete_reviews']) && ($HTTP_POST_VARS['delete_reviews'] == 'on')) {
$reviews_query = tep_db_query("select reviews_id from " . TABLE_REVIEWS . " where customers_id = '" . (int)$customers_id . "'");
while ($reviews = tep_db_fetch_array($reviews_query)) {
tep_db_query("delete from " . TABLE_REVIEWS_DESCRIPTION . " where reviews_id = '" . (int)$reviews['reviews_id'] . "'");
}
tep_db_query("delete from " . TABLE_REVIEWS . " where customers_id = '" . (int)$customers_id . "'");
} else {
tep_db_query("update " . TABLE_REVIEWS . " set customers_id = null where customers_id = '" . (int)$customers_id . "'");
}
tep_db_query("delete from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customers_id . "'");
tep_db_query("delete from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customers_id . "'");
tep_db_query("delete from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . (int)$customers_id . "'");
tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customers_id . "'");
tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customers_id . "'");
tep_db_query("delete from " . TABLE_WHOS_ONLINE . " where customer_id = '" . (int)$customers_id . "'");
tep_redirect(tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action'))));
break;
default:
$customers_query = tep_db_query("select c.customers_id, c.customers_gender, c.customers_firstname, c.customers_lastname, c.customers_dob, c.customers_email_address, a.entry_company, a.entry_street_address, a.entry_suburb, a.entry_postcode, a.entry_city, a.entry_state, a.entry_zone_id, a.entry_country_id, c.customers_telephone, c.customers_fax, c.customers_newsletter, c.customers_default_address_id from " . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " a on c.customers_default_address_id = a.address_book_id where a.customers_id = c.customers_id and c.customers_id = '" . (int)$HTTP_GET_VARS['cID'] . "'");
$customers = tep_db_fetch_array($customers_query);
$cInfo = new objectInfo($customers);
}
}
//Code to Check Backup Count
//$handle = opendir(DIR_FS_BACKUP."/ravi");
if ($handle = @opendir(DIR_FS_BACKUP))
{
$count = 0;
//loop through the directory
$year="1900"; //please dont change this value
$dayofyear="0"; //please dont change this value
$lastbackupdate="";
while (($filename = readdir($handle)) !== false)
{
//evaluate each entry, removing the . & .. entries
if (($filename != ".") && ($filename != ".."))
{
$fileyear=date("Y", filemtime(DIR_FS_BACKUP.$filename));
if($fileyear > $year)
{
$filedayofyear=date("z", filemtime(DIR_FS_BACKUP.$filename));
$year=$fileyear;
$dayofyear=$filedayofyear;
$lastbackupdate=date("m/d/Y", filemtime(DIR_FS_BACKUP.$filename));
}
elseif($fileyear==$year)
{
$filedayofyear=date("z", filemtime(DIR_FS_BACKUP.$filename));
if($filedayofyear > $dayofyear)
{
$lastbackupdate=date("m/d/Y", filemtime(DIR_FS_BACKUP.$filename));
$dayofyear=$filedayofyear;
}
}
$count++;
}
}
}//dir check if
else
{$count=0;$lastbackupdate="";}
define('BACKUP_COUNT',$count);
define('LAST_BACKUP_DATE',$lastbackupdate);
// Langauge code
/* $languages = tep_get_languages();
$languages_array = array();
$languages_selected = DEFAULT_LANGUAGE;
for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
$languages_array[] = array('id' => $languages[$i]['code'],
'text' => $languages[$i]['name']);
if ($languages[$i]['directory'] == $language) {
$languages_selected = $languages[$i]['code'];
}
}*/
// Langauge code EOF
// Get admin name
$my_account_query = tep_db_query ("select a.admin_id, a.admin_firstname, a.admin_lastname, a.admin_email_address, a.admin_created, a.admin_modified, a.admin_logdate, a.admin_lognum, g.admin_groups_name from " . TABLE_ADMIN . " a, " . TABLE_ADMIN_GROUPS . " g where a.admin_id= " . $login_id . " and g.admin_groups_id= " . $login_groups_id . "");
$myAccount = tep_db_fetch_array($my_account_query);
define('STORE_ADMIN_NAME',$myAccount['admin_firstname'] . ' ' . $myAccount['admin_lastname']);
define('TEXT_WELCOME','Welcome <strong>' . STORE_ADMIN_NAME . '</strong> to <strong>' . STORE_NAME . '</strong> Administration!');
// Admin Name EOF
// Store Status code
if (DOWN_FOR_MAINTENANCE == 'false'){
$store_status = '<font color="#009900">Active</font>';
} else {
$store_status = '<font color="#FF0000">Maintanace</font>';
}
// Store Status Code EOF
//Affiliate Count Code
$affiliate_query = tep_db_query("select count(affiliate_id) as affiliatecnt from " . TABLE_AFFILIATE_AFFILIATE);
$affiliatecount = tep_db_fetch_array($affiliate_query);
define('AFFILIATE_COUNT',$affiliatecount['affiliatecnt']);
$affiliate_query = tep_db_query('SELECT round(sum( sales.affiliate_value),2) AS affiliate,
round(sum( ( sales.affiliate_value * sales.affiliate_percent ) / 100),2) AS commission
FROM ' . TABLE_AFFILIATE_SALES . ' sales
left join ' . TABLE_ORDERS . ' o on sales.affiliate_orders_id = o.orders_id
where o.orders_id is not null
and affiliate_id != 0
and sales.affiliate_billing_status = 0
and o.orders_status = ' . AFFILIATE_PAYMENT_ORDER_MIN_STATUS . '
');
$affiliatecount = tep_db_fetch_array($affiliate_query);
$affiliatesales=$affiliatecount['affiliate'];
if($affiliatesales==""){$affiliatesales=0;}
$affiliatecomm=$affiliatecount['commission'];
if($affiliatecomm==""){$affiliatecomm=0;}
define('AFFILIATE_SALES_AMOUNT',$affiliatesales);
define('AFFILIATE_COMMISSION_AMOUNT',$affiliatecomm);
//Category Count Code
$category_query = tep_db_query("select count(categories_id) as catcnt from " . TABLE_CATEGORIES);
$categorycount = tep_db_fetch_array($category_query);
define('CATEGORY_COUNT',$categorycount['catcnt']);
//Product Count Code
$product_query = tep_db_query("select count(products_id) as productcnt from " . TABLE_PRODUCTS);
$productcount = tep_db_fetch_array($product_query);
define('PRODUCT_COUNT',$productcount['productcnt']);
//Product Out of Stock Count Code
$product_query = tep_db_query("select count(products_id) as productcnt_1 from " . TABLE_PRODUCTS." where products_quantity<=0");
$productcount_1 = tep_db_fetch_array($product_query);
define('PRODUCT_OUT_OF_STOCK_COUNT',$productcount_1['productcnt_1']);
//ActiveProduct Count Code
$product_query = tep_db_query("select count(products_id) as productcnt_2 from " . TABLE_PRODUCTS." where products_status=1");
$productcount_2 = tep_db_fetch_array($product_query);
define('ACTIVE_PRODUCT_COUNT',$productcount_2['productcnt_2']);
//Review Count Code
$review_query = tep_db_query("select count(reviews_id) as reviewcnt from " . TABLE_REVIEWS);
$reviewcount = tep_db_fetch_array($review_query);
define('REVIEW_COUNT',$reviewcount['reviewcnt']);
//Customer Count Code
$customer_query = tep_db_query("select count(customers_id) as customercnt from " . TABLE_CUSTOMERS);
$customercount = tep_db_fetch_array($customer_query);
define('CUSTOMER_COUNT',$customercount['customercnt']);
//Customer Subscribed Count Code
$customer_query = tep_db_query("select count(customers_id) as customercnt from " . TABLE_CUSTOMERS." where customers_newsletter=1");
$customercount = tep_db_fetch_array($customer_query);
define('CUSTOMER_SUBSCRIBED_COUNT',$customercount['customercnt']);
//LINK_CATEGORIE Count Code
$link_categories_query = tep_db_query("select count(link_categories_id) as link_categoriescnt from " . TABLE_LINK_CATEGORIES);
$link_categoriescount = tep_db_fetch_array($link_categories_query);
define('LINK_CATEGORIES_COUNT',$link_categoriescount['link_categoriescnt']);
//LINKS Count Code
$link_query = tep_db_query("select count(links_id) as linkcnt from " . TABLE_LINKS);
$linkcount = tep_db_fetch_array($link_query);
define('LINKS_COUNT',$linkcount['linkcnt']);
//LINKS Count Code
$linkapproved_query = tep_db_query("select count(links_id) as linkapprovedcnt from " . TABLE_LINKS." where links_status=1");
$linkapprovedcount = tep_db_fetch_array($linkapproved_query);
define('LINKS_APPROVAL_COUNT',$linkapprovedcount['linkapprovedcnt']);
//Language Count Code
$langcount_query = tep_db_query("select count(languages_id ) as langcnt from " . TABLE_LANGUAGES);
$langcount = tep_db_fetch_array($langcount_query);
define('LANGUAGE_COUNT',$langcount['langcnt']);
//Currencies Count Code
$currcount_query = tep_db_query("select count(currencies_id) as currcnt from " . TABLE_CURRENCIES);
$currcount = tep_db_fetch_array($currcount_query);
define('CURRENCIES_COUNT',$currcount['currcnt']);
//Tax Zone Code
$zones="";
$zone_query = tep_db_query("SELECT distinct geo_zone_name, tax_rate,b.geo_zone_id
FROM ".TABLE_ZONES_TO_GEO_ZONES." a, ".TABLE_GEO_ZONES." b, ".TABLE_TAX_RATES." c
where a.geo_zone_id = b.geo_zone_id
and a.geo_zone_id = tax_zone_id");
$tax_contents="";
while ($zone_list = tep_db_fetch_array($zone_query)) {
$tax_contents.="<li>".$zone_list['geo_zone_name'].' ('.$zone_list['tax_rate'].'%)'."</li><br />";
//Getting Further Zone Names
$subzone_query=tep_db_query("SELECT countries_name, zone_name
from ".TABLE_ZONES_TO_GEO_ZONES." a, ".TABLE_COUNTRIES." d, ".TABLE_ZONES." e
WHERE d.countries_id = a.zone_country_id AND e.zone_id = a.zone_id AND geo_zone_id = ".$zone_list['geo_zone_id']."
ORDER BY countries_name, zone_name");
while ($subzone_list = tep_db_fetch_array($subzone_query))
{
$tax_contents.=" -".$subzone_list['countries_name'].':'.$subzone_list['zone_name']."<br />";
}
}
//TEmplate Check code
$template_query = tep_db_query("select configuration_id, configuration_title, configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'DEFAULT_TEMPLATE'");
$template = tep_db_fetch_array($template_query);
$store_template = $template['configuration_value'] ;
// Template Check Code EOF
// Order Query
$orders_contents = '';
$orders_status_query = tep_db_query("select orders_status_name, orders_status_id from " . TABLE_ORDERS_STATUS . " where language_id = '" . $languages_id . "'");
while ($orders_status = tep_db_fetch_array($orders_status_query)) {
$orders_pending_query = tep_db_query("select count(*) as count from " . TABLE_ORDERS . " where orders_status = '" . $orders_status['orders_status_id'] . "'");
$orders_pending = tep_db_fetch_array($orders_pending_query);
if (tep_admin_check_boxes(FILENAME_ORDERS, 'sub_boxes') == true) {
$orders_contents .= '<li><a class="adminLink" href="' . tep_href_link(FILENAME_ORDERS, 'selected_box=customers&status=' . $orders_status['orders_status_id']) . '">' . $orders_status['orders_status_name'] . '</a> : ' . $orders_pending['count'] . "\n" . '<br />' ;
} else {
$orders_contents .= '' . $orders_status['orders_status_name'] . ': ' . $orders_pending['count'] . '<br />';
}
}
// Order Query EOF
?>
<?php
/*
$Id: whos_online.php,v 1.32 2003/06/29 22:50:52 hpdl Exp $
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
Released under the GNU General Public License
*/
$xx_mins_ago = (time() - 900);
$currencies = new currencies();
// remove entries that have expired
tep_db_query("delete from " . TABLE_WHOS_ONLINE . " where time_last_click < '" . $xx_mins_ago . "'");
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr>
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php //require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
</table></td>
<!-- body_text //-->
<td width="100%" valign="top">
<!-- body_text_eof //-->
</tr>
</table>
</table></td>
<!-- body_text_eof //-->
</tr>
</table>
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr>
<td ></td></tr>
</table>
<div id="centertabb">
<!-- body_text //-->
<div id="gauche">
<div id="cpanel">
<div style="float: left;">
<div class="icon">
<a href="categories.php">
<img src="images/adminfirstpage/categories.png" alt="Gestion catégories et produits" border="0"> <br /><span>Catégories et produits</span></a>
</div>
</div>
<div style="float: left;">
<div class="icon">
<a href="products_multi.php">
<img src="images/adminfirstpage/copierdeplacerproduits.png" alt="Gestion des produits" border="0"> <br /><span>Deplacer/copier/supprimer des produits</span></a>
</div>
</div>
<div style="float: left;">
<div class="icon">
<a href="quick_updates.php">
<img src="images/adminfirstpage/miseajourrapide.png" alt="Mise a jour rapide" border="0"> <br /><span>Mise a jour rapide des produits</span></a>
</div>
</div>
<div style="float: left;">
<div class="icon">
<a href="orders.php">
<img src="images/adminfirstpage/listingcommandes.png" alt="Listing commandes" border="0"> <br /><span>Listing des commandes</span></a>
</div>
</div>
<div style="float: left;">
<div class="icon">
<a href="stats_products_orders.php">
<img src="images/adminfirstpage/ordersdetail.png" alt="Détails des commandes" border="0"> <br /><span>Commande en détails</span></a>
</div>
</div>
<div style="float: left;">
<div class="icon">
<a href="customers.php">
<img src="images/adminfirstpage/listeclients.png" alt="Listin clients" border="0"> <br /><span>Afficher les clients</span></a>
</div>
</div>
<div style="float: left;">
<div class="icon">
<?php
$template_id_select_query = tep_db_query("select template_id from " . TABLE_TEMPLATE . " where template_name = '" . DEFAULT_TEMPLATE . "'");
$template_id_select = tep_db_fetch_array($template_id_select_query);
?>
<a href="infobox_configuration.php?gID=<?php echo $template_id_select[template_id] ;?>">
<img src="images/adminfirstpage/gestionboxes.png" alt="Gestion des boxes" border="0"> <br /><span>Gestion des boxes</span></a>
</div>
</div>
<div style="float: left;">
<div class="icon">
<a href="pages.php">
<img src="images/adminfirstpage/gestiondepages.png" alt="Gestion des pages" border="0"> <br /><span>Gestion des pages</span></a>
</div>
</div>
<div style="float: left;">
<div class="icon">
<a href="admin_members.php">
<img src="images/adminfirstpage/utilisateursadmin.png" alt="Gestion des utilisateurs" border="0"> <br /><span>Gestion des utilisateurs</span></a>
</div>
</div>
<div style="float: left;">
<div class="icon">
<a href="configuration.php?gID=1">
<img src="images/adminfirstpage/configeneral.png" alt="Configuration" border="0"> <br /><span>Configuration</span></a>
</div>
</div>
<div style="clear: left;">
<iframe src="statistics.php" height="450" width="100%" scrolling="no" frameborder="0"></iframe>
</div>
</div>
</div>
<div id="droite">
<div class="demo">
<div id="accordion">
<h3><a href="#">Informations Rapides</a></h3>
<div>
<p> <tr>
<td valign="middle"><table border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td ><div class="text2" style="padding:5px;"><span class="pageHeading"><?php echo WELCOME_BACK; ?> <?php echo (tep_session_is_registered('admin') ? '' . $admin['username'] . ' ' : ''); ?></span><br /><br />
<?php
$customers_query = tep_db_query("select count(*) as count from " . TABLE_CUSTOMERS);
$customers = tep_db_fetch_array($customers_query);
$products_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS . " where products_status = '1'");
$products = tep_db_fetch_array($products_query);
$reviews_query = tep_db_query("select count(*) as count from " . TABLE_REVIEWS);
$reviews = tep_db_fetch_array($reviews_query);
echo TEXT5 . ' ' . $customers['count'] . ' ' . TEXT6 . ' ' . $products['count'] . ' ' . TEXT7 . ' ' . $reviews['count']. ' ' . TEXT8;
?><hr style="color:#E3E3E3" size="1">
<?php
if ($HTTP_GET_VARS['page'] > 1) $rows = $HTTP_GET_VARS['page'] * 20 - 20;
$products_query_raw = "select p.products_id, p.products_quantity, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . $languages_id. "' and p.products_quantity <= " . STOCK_REORDER_LEVEL . " group by pd.products_id order by pd.products_name ASC";
$products_query = tep_db_query($products_query_raw);
while ($products = tep_db_fetch_array($products_query)) {
$rows++;
}
?>
<?php
// order summary
$orders_contents = '';
$orders_status_query = tep_db_query("select orders_status_name, orders_status_id from " . TABLE_ORDERS_STATUS . " where language_id = '" . (int)$languages_id . "'");
while ($orders_status = tep_db_fetch_array($orders_status_query)) {
$orders_query = tep_db_query("select count(*) as qty from " . TABLE_ORDERS . " where orders_status = '" . (int)$orders_status['orders_status_id'] . "'");
$orders_row = tep_db_fetch_array($orders_query);
$orders_contents .= '<a class="text2" href="' . tep_href_link(FILENAME_ORDERS, 'selected_box=customers&status=' . (int)$orders_status['orders_status_id']) . '">' . tep_db_prepare_input($orders_status['orders_status_name']) . '</a>: ' . number_format($orders_row['qty']) . ', ';
}
$orders_contents = substr($orders_contents, 0, -2);
$query_new = tep_db_query("select count(*) as qty from " . TABLE_ORDERS . " where to_days(date_purchased) = to_days(now()) "); $line_new = tep_db_fetch_array($query_new);
echo '' . sprintf(TEXT_SUMMARY_INFO_ORDERS, $orders_contents, number_format($line_new['qty'])) . '<br /><hr style="color:#E3E3E3" size="1">';
// order total summary
$orders_contents_total = '';
if(!is_object($currencies)){include_once(DIR_WS_CLASSES . 'currencies.php'); $currencies = new currencies();}
$orders_status_query = tep_db_query("select orders_status_name, orders_status_id from " . TABLE_ORDERS_STATUS . " where language_id = '" . (int)$languages_id . "'");
while ($orders_status = tep_db_fetch_array($orders_status_query)) {
unset($oTot, $temp);
$orders_query = tep_db_query("select o.currency, sum(ot.value) as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id) where o.orders_status = '" . (int)$orders_status['orders_status_id'] . "' and ot.class = 'ot_total' group by 1 order by 1");
while($row = tep_db_fetch_array($orders_query)){$oTot[$row['currency']] += $row['order_total'];}
if(is_array($oTot)){
foreach($oTot as $key => $value){$temp .= $currencies->format($value, false, $key) . ',';}
$temp = '' . substr($temp, 0, -1) . '';
}else{
$temp = '' . $currencies->format(0, false) . '';
}
$orders_contents_total .= '<a class="text2" href="' . tep_href_link(FILENAME_ORDERS, 'selected_box=customers&status=' . (int)$orders_status['orders_status_id']) . '">' . tep_db_prepare_input($orders_status['orders_status_name']) . '</a>: ' . $temp . ', ';
}
$orders_contents_total = substr($orders_contents_total, 0, -2);
$orders_query = tep_db_query("select o.currency, sum(ot.value) as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id) where to_days(o.date_purchased) = to_days(now()) and ot.class = 'ot_total' group by 1 order by 1");
unset($oTot, $temp); while($row = tep_db_fetch_array($orders_query)){$oTot[$row['currency']] += $row['order_total'];}
if(is_array($oTot)){
foreach($oTot as $key => $value){$temp .= $currencies->format($value, false, $key) . ',';}
$temp = '' . substr($temp, 0, -1) . '';
}else{
$temp = '' . $currencies->format(0, false) . '';
}
echo '' . sprintf(TEXT_SUMMARY_INFO_ORDERS_TOTAL, $orders_contents_total, $temp) . '<br /><hr style="color:#E3E3E3" size="1">';
?>
<?php
if ($rows != 0){?>
<?php echo STOCK_TEXT_WARNING1 ?><?php echo $rows; ?> <?php echo STOCK_TEXT_WARNING2 ?> "<a class="text2" href="<?php echo tep_href_link(FILENAME_STATS_LOW_STOCK, 'selected_box=reports')?>"><?php echo BOX_REPORTS_STOCK_LEVEL ?></a>" <?php echo STOCK_TEXT_WARNING3 ?>
<?php } ?>
<?php
if ($rows == 0){?>
<?php echo STOCK_TEXT_OK1 ?> "<a class="text2" href="<?php echo tep_href_link(FILENAME_STATS_LOW_STOCK, 'selected_box=reports')?>"><?php echo BOX_REPORTS_STOCK_LEVEL ?></a>" <?php echo STOCK_TEXT_OK2 ?>
<?php } ?>
</div></td>
</tr>
</table></td>
</p>
</div>
<h3><a href="#">Informations générales</a></h3>
<div>
<p><fieldset>
<legend> <?php echo BLOCK_TITLE_STORE_INFO;?> (<a href="<?php echo tep_href_link(FILENAME_CONFIGURATION,'gID=1','NONSSL');?>"><?php echo TEXT_MANAGE;?></a>) <a class="helpLink" href="?" ><?php echo BLOCK_HELP_STORE_INFO;?>', this, event, '250px'); return false">[?]</a></legend>
<ul>
<li><?php echo BLOCK_CONTENT_STORE_INFO_STORE_NAME . ' : ' . STORE_NAME;?> </li>
<li><?php echo BLOCK_CONTENT_STORE_INFO_STORE_STATUS;?> : <a class="helpLink" href="?" ><?php echo BLOCK_HELP_STORE_STATUS;?>', this, event, '250px'); return false"><strong><?php echo $store_status;?></strong></a> </li>
<li><?php echo BLOCK_CONTENT_STORE_INFO_STORE_EMAIL . ' : ' . STORE_OWNER_EMAIL_ADDRESS;?> </li>
<li><?php echo BLOCK_CONTENT_STORE_INFO_STORE_TEMPLATE . ' : ' . $store_template;?></li>
<li><?php echo BLOCK_CONTENT_STORE_INFO_STORE_LANGUAGE . ' : ' . DEFAULT_LANGUAGE.' ('.LANGUAGE_COUNT;?> Installées) </li>
<li><?php echo BLOCK_CONTENT_STORE_INFO_STORE_CURRENCY . ' : ' . DEFAULT_CURRENCY.' ('.CURRENCIES_COUNT;?> Installées) </li>
<li><?php echo BLOCK_CONTENT_STORE_INFO_STORE_BACKUPS.' : '.BACKUP_COUNT;?> (Dernière <?php echo LAST_BACKUP_DATE?>) <a href="<?php echo tep_href_link(FILENAME_BACKUP);?>" ><?php echo BLOCK_HELP_STORE_BACKUP;?>', this, event, '180px'); return false"><font color="#FF0000">[!]</font></a></li>
</ul>
</fieldset>
<br /><fieldset>
<legend><?php echo BLOCK_TITLE_REPORTS;?> <a class="helpLink" href="?" ><?php echo BLOCK_HELP_REPORTS;?>', this, event, '250px'); return false">[?]</strong></a></legend>
<ul>
<li><a class="adminLink" href="<?php echo tep_href_link(FILENAME_STATS_PRODUCTS_VIEWED,'selected_box=reports','NONSSL');?>"><?php echo BLOCK_CONTENT_REPORTS_PRODUCTS_VIEWED;?></a></li>
<li><a class="adminLink" href="<?php echo tep_href_link(FILENAME_STATS_PRODUCTS_PURCHASED,'selected_box=reports','NONSSL');?>"><?php echo BLOCK_CONTENT_REPORTS_PRODUCTS_PURCHASED;?></a></li>
<li><a class="adminLink" href="<?php echo tep_href_link(FILENAME_STATS_CUSTOMERS,'selected_box=reports','NONSSL');?>"><?php echo BLOCK_CONTENT_REPORTS_CUSTOMER_ORDERS_TOTAL;?></a></li>
<li><a class="adminLink" href="<?php echo tep_href_link(FILENAME_STATS_MONTHLY_SALES,'selected_box=reports','NONSSL');?>"><?php echo BLOCK_CONTENT_REPORTS_MONTHLY_SALES_TAX;?></a></li>
</ul>
</fieldset></p>
</div>
<h3><a href="#">Produits / commentaires</a></h3>
<div>
<p><fieldset>
<legend> <?php echo BLOCK_TITLE_PRODUCTS;?> (<a href="<?php echo tep_href_link(FILENAME_CATEGORIES,'selected_box=catalog','NONSSL');?>"><?php echo TEXT_MANAGE;?></a><a href="#"></a>) <a class="helpLink" href="?" ><?php echo BLOCK_HELP_PRODUCTS;?>', this, event, '250px'); return false">[?]</strong></a></legend>
<ul>
<li><?php echo BLOCK_CONTENT_PRODUCTS_CATEGORIES.' : '.CATEGORY_COUNT;?></li>
<li><?php echo BLOCK_CONTENT_PRODUCTS_TOTAL_PRODUCTS.' : '.PRODUCT_COUNT;?></li>
<li><?php echo BLOCK_CONTENT_PRODUCTS_ACTIVE.' : '.ACTIVE_PRODUCT_COUNT;?></li>
<li><?php echo BLOCK_CONTENT_PRODUCTS_NOSTOCK.' : '.PRODUCT_OUT_OF_STOCK_COUNT;?></li>
</ul>
</fieldset><fieldset>
<legend><?php echo BLOCK_TITLE_REVIEWS;?> (<a href="<?php echo tep_href_link(FILENAME_REVIEWS,'selected_box=catalog','NONSSL');?>"><?php echo TEXT_MANAGE;?></a>) <a class="helpLink" href="?" ><?php echo BLOCK_HELP_REVIEWS;?>', this, event, '250px'); return false">[?]</strong></a></legend>
<ul>
<li><?php echo BLOCK_CONTENT_REVIEWS_TOTAL_REVIEWS.' : '.REVIEW_COUNT;?></li>
<!-- <li><?php echo BLOCK_CONTENT_REVIEWS_WAITING_APPROVAL;?>: 2 </li> -->
</ul>
</fieldset></p>
</div>
<h3><a href="#">Top 10 produits</a></h3>
<div>
<table width="360" border="0" align="center" cellpadding="4" cellspacing="0" class="text">
<?php
if (isset($HTTP_GET_VARS['page']) && ($HTTP_GET_VARS['page'] > 1)) $rows = $HTTP_GET_VARS['page'] * MAX_DISPLAY_SEARCH_RESULTS - MAX_DISPLAY_SEARCH_RESULTS;
$rows = 0;
$products_query_raw = "select p.products_id, pd.products_name, pd.products_viewed, l.name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_LANGUAGES . " l where p.products_id = pd.products_id and l.languages_id = pd.language_id order by pd.products_viewed DESC";
$products_split = new splitPageResults($HTTP_GET_VARS['page'], 10, $products_query_raw, $products_query_numrows);
$products_query = tep_db_query($products_query_raw);
while ($products = tep_db_fetch_array($products_query)) {
$rows++;
if (strlen($rows) < 2) {
$rows = '0' . $rows;
}
?>
<tr ><?php echo tep_href_link(FILENAME_CATEGORIES, 'action=new_product_preview&read=only&pID=' . $products['products_id'] . '&origin=' . FILENAME_STATS_PRODUCTS_VIEWED . '?page=' . $HTTP_GET_VARS['page'], 'NONSSL'); ?>'">
<td style="border-bottom:solid 1px; border-color:#e3e3e3;" class="dataTableContent"><?php echo $rows; ?>.</td>
<td style="border-bottom:solid 1px; border-color: #e3e3e3;" class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'action=new_product_preview&read=only&pID=' . $products['products_id'] . '&origin=' . FILENAME_STATS_PRODUCTS_VIEWED . '?page=' . $HTTP_GET_VARS['page'], 'NONSSL') . '">' . $products['products_name'] . '</a> (' . $products['name'] . ')'; ?></td>
<td style="border-bottom:solid 1px; border-color:#e3e3e3;" class="dataTableContent" align="center"><?php echo $products['products_viewed']; ?> </td>
</tr>
<?php
}
?>
</table>
<!-- body_text_eof //-->
</div>
</div>
</div><!-- End demo -->
<div style="display: none;" class="demo-description">
<p>
<fieldset>
<legend><?php echo BLOCK_TITLE_CUSTOMERS;?> (<a href="<?php echo tep_href_link(FILENAME_CREATE_ACCOUNT,'selected_box=customers','NONSSL');?>"><?php echo TEXT_ADD;?></a> / <a href="<?php echo tep_href_link(FILENAME_CUSTOMERS,'selected_box=customers','NONSSL');?>"><?php echo TEXT_VIEW;?></a>) <a class="helpLink" href="?" ><?php echo BLOCK_HELP_CUSTOMERS;?>', this, event, '250px'); return false">[?]</strong></a></legend>
<ul>
<li><?php echo BLOCK_CONTENT_CUSTOMERS_TOTAL.' : '.CUSTOMER_COUNT;?></li>
<li><?php echo BLOCK_CONTENT_CUSTOMERS_SUBSCRIBED.' : '.CUSTOMER_SUBSCRIBED_COUNT;?></li>
</ul>
</fieldset>
</p>
</div><!-- End demo-description -->
</div>
</div>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>