<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015~2016 http://ilunhui.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 网蝈蝈 <245539558@qq.com>
// +----------------------------------------------------------------------

namespace Admin\Controller;
use Think\Controller;
use Common\Controller\AuthController;
use Think\Auth;

class IndexController extends AuthController {
	
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         佛祖保佑       永无BUG
*/
	
    public function index(){

    	if (empty($_SESSION['aid'])){
    		$this->redirect('Login/login');
    	}
      $where['time']=date("Y-m-d",mktime(0,0,0,date('m'),date('d'),date('Y')));
      $signList=M("sign")->where($where)->count();
    	$info = array(
  			'PCTYPE'=>PHP_OS,
  			'RUNTYPE'=>$_SERVER["SERVER_SOFTWARE"],
  			'ONLOAD'=>ini_get('upload_max_filesize'),
  			'ThinkPHPTYE'=>THINK_VERSION,
        'sign'=>$signList,
    	);
      
    	$this->assign('info',$info);
	    $this->display();
       
    }

    public function NumberStatistics(){
        $yue=$_REQUEST['yue'];
        $data=self::mFristAndLast('',$yue);
        $thismonth_start=$data['firstday'];
        $thismonth_end=$data['lastday'];
        $where['deltime'] = array('between',"$thismonth_start,$thismonth_end");
        $where['admin_status']=0;
        $delCount = M('admin')->where($where)->count();
        $addwhere['createtime'] = array('between',"$thismonth_start,$thismonth_end");
        $addCount = M('admin')->where($addwhere)->count();
        echo  $delCount.','.$addCount;
    }
  static function mFristAndLast($y = "", $m = ""){
    if ($y == "") $y = date("Y");
    if ($m == "") $m = date("m");
    $m = sprintf("%02d", intval($m));

    //填充字符串长度
    $y = str_pad(intval($y), 4, "0", STR_PAD_RIGHT);


    $m > 12 || $m < 1 ? $m = 1 : $m = $m;
    $firstday = strtotime($y . $m . "01000000");
    $firstdaystr = date("Y-m-01", $firstday);
    $lastday = strtotime(date('Y-m-d 23:59:59',   strtotime("$firstdaystr +1 month -1 day")));

    return array(
        "firstday" => $firstday,
        "lastday" => $lastday
    );
}
}