后台 报表统计--财务统计--左上角7天 30天功能失效
给出一些代码:
class ReportController extends BaseController{
public $begin;
public $end;
public function _initialize(){
parent::_initialize();
$timegap = I('timegap');
$gap = I('gap',7);
if($timegap){
$gap = explode(' - ', $timegap);
$begin = $gap[0];
$end = $gap[1];
}else{
if ($gap == 7) {
$lastweek = date('Y-m-d',strtotime("-1 week"));//7天前
$begin = I('begin',$lastweek);
$end = I('end',date('Y-m-d'));
}elseif($gap == 30){
$lastweek = date('Y-m-d',strtotime("-1 month"));//30天前
$begin = I('begin',$lastweek);
$end = I('end',date('Y-m-d'));
}else{
$lastweek = date('Y-m-d',strtotime("-1 month"));//30天前
$begin = I('begin',$lastweek);
$end = I('end',date('Y-m-d'));
}
}
$this->begin = strtotime($begin);
$this->end = strtotime($end);
$this->assign('gap',$gap);//这里修改了
$this->assign('timegap',date('Y-m-d',$this->begin).' - '.date('Y-m-d',$this->end));
//$this->begin = strtotime($begin);
//$this->end = strtotime($end);
}
………………
对应视图
<form action="" method="post">
<div class="col-xs-3">
<a class="btn <eq name="gap" value="7">btn-primary<else/>btn-default</eq>margin" href="{:U('Report/index',array('gap'=>7))}">最近7天</a>
<a class="btn <eq name="gap" value="30">btn-primary<else/>btn-default</eq>margin" href="{:U('Report/index',array('gap'=>30))}">最近30天</a>
</div>
<div class="col-xs-5">
<div class="input-group margin">
<div class="input-group-addon"> 选择时间 <i class="fa fa-calendar"></i> </div>
<input type="text" class="form-control pull-right" name="timegap" value="{$timegap}" id="start_time">
</div>
</div>
<div class="col-xs-1">
<input class="btn btn-block btn-info margin" type="submit" value="确定">
</div>
</form>