好的,所以我尝试使用codeigniter创建一个日历,并且提要是出勤记录,我尝试使用bootstrap设计样式以使其看起来更好。 之前的记录正在显示,但某些记录尤其是最近的日期未显示。我尝试显示查询结果并显示记录,但日历中的日期为空
这里是日历模型
class Calendar_model extends CI_Model {
var $conf;
public function __construct()
{
parent::__construct();
$this->conf = array(
'start_day' => 'monday',
'show_next_prev' => true,
'next_prev_url' => base_url() . 'employee/employee_attendance'
);
$this->conf['template'] = '
{table_open}<table border="0" cellpadding="0" cellspacing="0" class="calendar table">{/table_open}
{heading_row_start}<tr>{/heading_row_start}
{heading_previous_cell}<th><a href="{previous_url}"><button class="btn btn-primary btn-sm col-lg-7" title="Previous Month"><span class="glyphicon glyphicon-arrow-left"></span></button></span></a></th>{/heading_previous_cell}
{heading_title_cell}<th class="text-center"colspan="{colspan}">{heading}</th>{/heading_title_cell}
{heading_next_cell}<th><a href="{next_url}"><button class="btn btn-primary btn-sm col-lg-7 col-lg-offset-5" title="Previous Month"><span class="glyphicon glyphicon-arrow-right"></span></button></span></a></th>{/heading_next_cell}
{heading_row_end}</tr>{/heading_row_end}
{week_row_start}<tr>{/week_row_start}
{week_day_cell}<td>{week_day}</td>{/week_day_cell}
{week_row_end}</tr>{/week_row_end}
{cal_row_start}<tr class="days">{/cal_row_start}
{cal_cell_start}<td class="day">{/cal_cell_start}
{cal_cell_content}
<div class="day_num present">{day}</div>
<div class="content present" id="present">
<div class="text-center">
<span class="label label-default" style="display:block; width:80%;">{content}
</div>
</div>
{/cal_cell_content}
{cal_cell_content_today}
<div class="day_num highlight">{day}</div>
<div class="content">{content}</div>
{/cal_cell_content_today}
{cal_cell_no_content}<div class="day_num">{day}</div>{/cal_cell_no_content}
{cal_cell_no_content_today}<div class="day_num highlight">{day}</div>{/cal_cell_no_content_today}
{cal_cell_blank} {/cal_cell_blank}
{cal_cell_end}</td>{/cal_cell_end}
{cal_row_end}</tr>{/cal_row_end}
{table_close}</table>{/table_close}
';
}
function get_calendar_data($year, $month, $username) {
$this->db->like('date', "$year-$month-", 'after');
$query = $this->db->get_where('attendance',array('username'=>$username, 'status'=> 'present'));
if($query->num_rows() > 0){
foreach($query->result() as $row){
$data[substr($row->date,8,2)] = $row->login_time.'</span><span class="label label-danger" style="display: block; width: 80%;">'.$row->logout_time.'</span><span class="label label-warning" style="display:block; width:80%;">'.$row->accumulated_time.'mins </span>';
}
return $data;
}
}
function generate ($year, $month) {
$this->load->library('calendar', $this->conf);
$username = $this->session->userdata('username');
$cal_data = $this->get_calendar_data($year, $month, $username);
return $this->calendar->generate($year, $month, $cal_data);
}
}
这里是screeshots
之前日期的数据:http://s2.postimg.org/tray4d3rd/Capture.png
最近的日期不是:http://s1.postimg.org/tr09y389b/image.png
他们是所有日期,所以我不确定为什么有些数据不存在 提前谢谢。