assign('title','统计信息'); if($op == 'index'){ $sql = "select sum(money) as cash,count(uid) as order_count from orders as a where dstatus=1"; $info = getonerecord($sql); $tpl->assign('info', $info); $tpl->assign('title','统计信息'); }elseif($op == 'echarts'){ header('content-type:application/json;charset=utf8'); $return['status'] = 1; //lastest one week $today_stamp = strtotime(date('Y-m-d')); $week = array(); for ($i=0; $i < 7; $i++) { $week[7-$i] = date('m-d', $today_stamp - 86400*$i); } ksort($week); $return['datas']['week'] = $week; $query = exec_db("SELECT * FROM day_count ORDER BY today DESC LIMIT 7"); $orders = array(); while ($row = mysqli_fetch_assoc($query)) { $orders[date('m-d',$row['today'])] = $row['orders_sum']; } //print_r($orders);exit; foreach ($week as $key=>$value) { $return['datas']['orders'][$value] = isset($orders[$value]) ? $orders[$value] : 0; } echo json_encode($return);exit; } $tpl->display("admin/{$ac}.html");