我在 yii 中使用完整日历,但是当我将事件设置超过一天(多天事件)时,完整日历不显示任何事件,但是当我设置时它将显示事件它只有一天,实际上我想显示一个学生一个月的出勤率。(如果学生缺席它只是通过我的控制器它将显示一种颜色和另一个当前,当我设置一个时它没有显示任何输出当天出现,另一天缺席,另一天出现在一个月内,但如果我设置了一个案例,即缺席/出席/仅在一个月内离开,则会显示输出。
<?php $this->widget('ext.Efullcalendar.EFullCalendar', array(
'themeCssFile'=>'cupertino/theme.css',
'htmlOptions'=>array(
// you can scale it down as well, try 80%
//'onload'=>'.fullCalendar( "gotoDate", "12-12-2016" )'
),
'options'=>array(
'header'=>array(
'left'=>'prev,next,today',
'center'=>'title',
'right'=>'month,agendaWeek,agendaDay',
),
'events'=>$events // URL to get event
)));
?>
$.ajax({
success: function(events){
$('#yw0').fullCalendar('removeEvents');
$('#yw0').fullCalendar('addEventSource', events);
},
type: 'get',
url: '<?php echo $this->createUrl('renderattendance');?>',
cache: false,
data: {
year: year,
month: month,
},
dataType: 'json',
});
{
$month=$_GET['month'];
$year=$_GET['year'];
} $noofdays=cal_days_in_month(CAL_GREGORIAN,$month,$year);
$student_model=$this->loadModel();
$student_id=$student_model->id;
$events=array();
$att_array=Attendance::getParentAttendanceMonth($student_id,$month,$year);
//$att_array[]=array('date'=>'2016-09-01','f'=>'present');
//$att_array[]=array('date'=>'2016-09-02','f'=>'absent');//print_r($att_array);die;
foreach($att_array as $i=>$att)
{
switch($att->present)
{
case Attendance::ABSENT:
{
$events[$i]['title']='absent';
$events[$i]['start']=$att['date'];
$events[$i]['color']='#FA0000';
break;
}
case Attendance::PRESENT:
{
$events[$i]['title']='present';
$events[$i]['start']=$att['date'];
$events[$i]['color']='#43E8A6';
break;
}
case Attendance::LEAVE:
{
$events[$i]['title']='leave';
$events[$i]['start']=$att['date'];
$events[$i]['color']='#949fef';
break;
}
default:
{
$events[$i]['title']='n-a';
$events[$i]['start']=$att['date'];
$events[$i]['color']='#999999';
break;
}
}
echo CJSON::encode($events);
}
}