123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
- namespace Admin\Controller;
- use Common\Controller\AdminController;
- class IndexController extends AdminController {
- public function __construct(){
- parent::__construct();
- }
- public function index() {
-
-
- $flag = I('flag',1);
- $dayType = I('day_type',3);
- $startDate = I('start_date');
- $endDate = I('end_date');
- $dayList = array(
- 1=>array('startDate'=>date('Y-m-d'),'endDate'=>date('Y-m-d',strtotime('+1 day'))),
- 2=>array('startDate'=>date('Y-m-d',strtotime('-1 day')),'endDate'=>date('Y-m-d')),
- 3=>array('startDate'=>date('Y-m-d',strtotime('-7 day')),'endDate'=>date('Y-m-d')),
- 4=>array('startDate'=>date('Y-m-d',strtotime('-30 day')),'endDate'=>date('Y-m-d')),
- );
- if (empty($startDate)||empty($endDate)){
- $startDate = $dayList[$dayType]['startDate'];
- $endDate = $dayList[$dayType]['endDate'];
- }
- if ($flag==1){
- $startDate = $dayList[$dayType]['startDate'];
- $endDate = $dayList[$dayType]['endDate'];
- }
-
- $startTime = strtotime($startDate);
- $endTime = strtotime($endDate);
- if ($endTime<2){
- $this->error('结束时间错误');
- }
- //统计全部
- $info = M('Sta')->field('sum(sta_reg) reg,sum(sta_normal) normal,sum(sta_rank) rank,sum(sta_pve) pve')->find();
- //分天统计
- $condition = array('operate_dt'=>array('BETWEEN',array($startTime,$endTime+1)));
- $staRes = M('Sta')->where($condition)->field('sta_reg, sta_normal, sta_rank, sta_pve, operate_dt')->select();
- foreach ($staRes as $row){
- $staList[$row['operate_dt']] = array('reg'=>$row['sta_reg'], 'normal'=>$row['sta_normal'], 'rank'=>$row['sta_rank'], 'pve'=>$row['sta_pve']);
- }
- $xAxis = '';
- $yAxisReg = '';
- $yAxisPve = '';
- $yAxisRank = '';
- $yAxisNormal = '';
- for($i=$startTime;$i<=$endTime;$i=$i+86400){
- $xAxis .= "'".date('md',$i)."',";
- if (isset($staList[$i])){
- $yAxisPve .= $staList[$i]['pve'].',';
- $yAxisReg .= $staList[$i]['reg'].',';
- $yAxisRank .= $staList[$i]['rank'].',';
- $yAxisNormal .= $staList[$i]['normal'].',';
- }else{
- $yAxisPve .= '0,';
- $yAxisReg .= '0,';
- $yAxisRank .= '0,';
- $yAxisNormal .= '0,';
- }
- }
- $xAxis = substr($xAxis, 0, -1);
- $yAxisPve = substr($yAxisPve, 0, -1);
- $yAxisReg = substr($yAxisReg, 0, -1);
- $yAxisRank = substr($yAxisRank, 0, -1);
- $yAxisNormal = substr($yAxisNormal, 0, -1);
- $this->assign('info',$info);
- $this->assign('xAxis', $xAxis);
- $this->assign('yAxisPve',$yAxisPve);
- $this->assign('yAxisReg', $yAxisReg);
- $this->assign('yAxisRank', $yAxisRank);
- $this->assign('yAxisNormal', $yAxisNormal);
- $this->assign('dayType', $dayType);
- $this->assign('endDate',$endDate);
- $this->assign('startDate',$startDate);
- $this->display();
- }
-
- public function pwd(){
- $step = I('step','');
- $adminId = session('admin_id');
- $info = M('Admin')->where(array('admin_id'=>$adminId))->field('admin_account,admin_pwd')->find();
- if (empty($step)){
- $this->assign('info',$info);
- $this->display();
- }else if($step==2){
- $oldPwd = I('old_pwd');
- $newPwd = I('new_pwd');
- $newRepwd = I('new_repwd');
- if (mb_strlen($oldPwd,'UTF8')<6 || mb_strlen($oldPwd,'UTF8')>20){
- $this->error('旧密码长度6到20之间');
- }
- if (mb_strlen($newPwd,'UTF8')<6 || mb_strlen($newPwd,'UTF8')>20){
- $this->error('新密码长度6到20之间');
- }
- if ($newPwd!==$newRepwd){
- $this->error('两次输入的新密码不一致,请重新输入');
- }
- if ($info!=NULL && $info['admin_pwd']!=md5($info['admin_pwd'])){
- $this->error('输入的原密码有误,请重新输入');
- }
- M('Admin')->where(array('admin_id'=>$adminId))->save(array('admin_pwd'=>md5($newPwd)));
- $this->success('修改密码成功','/admin/index/index');
- }
- }
-
- }
|