萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> php編程 >> php開發ebay店鋪管理系統

php開發ebay店鋪管理系統

   一、主程序/admin/erp_ebay_order_stats.php

 代碼如下  


define('IN_ECS', true);
 
require(dirname(__FILE__) . '/includes/init.php');
require_once(ROOT_PATH . 'languages/' .$_CFG['lang']. '/admin/erp_ebay_statistic.php');
$smarty->assign('lang', $_LANG);
 
/* act操作項的初始化 */
if (empty($_REQUEST['act']))
{
    $_REQUEST['act'] = 'view';
}
else
{
    $_REQUEST['act'] = trim($_REQUEST['act']);
}
 
if ($_REQUEST['act'] == 'view')
{
 
    admin_priv('order_stats'); //檢查權限
 
    $is_multi = empty($_POST['is_multi']) ? false : true;
 
    /* 時間參數 */
    if (isset($_POST['start_date']) && !empty($_POST['end_date']))
    {
        $start_date = local_strtotime($_POST['start_date']);
        $end_date = local_strtotime($_POST['end_date']);
    }
    else
    {
        $today  = local_strtotime(local_date('Y-m-d'));
        $start_date = $today - 86400 * 14;
        $end_date   = $today;
    }
 
    $start_date_arr = array();
    $end_date_arr = array();
    if(!empty($_POST['year_month']))
    {
        $tmp = $_POST['year_month'];
 
        for ($i = 0; $i < count($tmp); $i++)
        {
            if (!empty($tmp[$i]))
            {
                $tmp_time = local_strtotime($tmp[$i] . '-1');
                //echo $tmp_time;
                $start_date_arr[] = $tmp_time;
                $end_date_arr[]   = local_strtotime($tmp[$i] . '-' . date('t', $tmp_time));
 
                //echo local_strtotime($tmp[$i] . '-' . date('t', $tmp_time));
            }
        }
    }
    else
    {
        $tmp_time = local_strtotime(local_date('Y-m-d'));
        $start_date_arr[] = local_strtotime(local_date('Y-m') . '-1');
        $end_date_arr[]   = local_strtotime(local_date('Y-m') . '-31');;
    }
 
    /* ------------------------------------- */
    /* -- 綜合訂單量
    /* ------------------------------------- */
    $max = 0;
 
    if(!$is_multi)
    {
        $general_xml = "<graph caption='$_LANG[general_stats]' shownames='1' showvalues='1' decimalPrecision='0' yaxisminvalue='0' yaxismaxvalue='%d' animation='1' outCnvBaseFontSize='12' baseFontSize='12' xaxisname='$_LANG[date]' yaxisname='$_LANG[order_count]' >";
 
        $sql = "SELECT FLOOR((created_time - $start_date) / (24 * 3600)) AS sn, created_time, COUNT(*) AS order_count".
                " FROM " .$ecs->table('erp_ebay_order').
                " WHERE ebay_status = 'Complete' AND created_time >= '$start_date' AND created_time <= " .($end_date + 86400).
                " GROUP BY sn";
        $res = $db->query($sql);
 
        $key = 0;
 
        while ($val = $db->fetchRow($res))
        {
            $val['order_date'] = gmdate('m-d',$val['created_time'] +  $timezone * 3600 + 86400);
            $general_xml .= "<set name='$val[order_date]' value='$val[order_count]' color='" .chart_color($key). "' />";
            if ($val['order_count'] > $max)
            {
                $max = $val['order_count'];
            }
            $key++;
        }
 
        $general_xml .= '</graph>';
        $general_xml  = sprintf($general_xml, $max);
    }
    else
    {
        $general_xml = "<graph caption='$_LANG[general_stats]' lineThickness='1' showValues='0' formatNumberScale='0' anchorRadius='2'   divLineAlpha='20' divLineColor='CC3300' divLineIsDashed='1' sh

copyright © 萬盛學電腦網 all rights reserved