当我的报告中有1个日期时,报告正在运行。但是当我添加另一个日期(数据)时,报告显示错误。我不知道在哪里找到它。
以下是报告控制器的代码:
public function index()
{
$data["nav"]="4";
$this->load->model('report_model');
if ($this->session->userdata('position')=="Professor")
{
$data["records"]=$this->db->query("select * from tblclass WHERE CID IN (select CID from tblseatplan) AND AID=". $this->session->userdata('id'));
$this->load->view('report_view', $data);
}
else if($this->session->userdata('position')=="Department Chair")
{
$AID=$this->session->userdata('id');
$account = $this->db->query("select * from tblaccount WHERE AID='$AID'");
foreach($account->result() as $row){
$department = $row->Department;
}
$data["records"]=$this->db->query("select * from tblclass WHERE CID IN (select CID from tblseatplan) AND Course_Code_Section LIKE '%$department%'");
$this->load->view('access_department_chair_view', $data);
}
}
public function attendanceReport()
{
$this->load->library('Pdf');
$this->load->library('Pdf');
$pdf=new Pdf('L', 'mm', 'A4', true, 'UTF-8', false);
$pdf->SetTitle('Technological Institute of the Philippines');
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetAutoPageBreak(true, 15);
$pdf->SetAuthor('Author');
$pdf->SetDisplayMode('real', 'default');
$pdf->AddPage("L");
$CID=$this->input->post("CID");
$period=$this->input->post("period");
$dates=$this->db->query("SELECT date_check FROM tblattendance WHERE CID='$CID' AND period='$period'
GROUP BY date_check ORDER BY date_check ASC");
$students=$this->db->query("SELECT a.SID, s.Student FROM tblattendance a
LEFT JOIN tblstudent s ON a.SID=s.SID
WHERE a.CID='$CID' AND a.period='$period'
GROUP BY a.SID ORDER BY a.date_check ASC");
$class=$this->db->query("SELECT c.*, a.First_Name, a.Last_Name FROM tblclass c
LEFT JOIN tblaccount a ON c.AID=a.AID WHERE c.CID='$CID'");
foreach($students->result() as $s)
{
$sSID = $s->SID;
$student_at = $this->db->query("SELECT status FROM tblattendance
WHERE CID='$CID' AND period='$period' AND SID='$sSID'
ORDER BY date_check ASC");
}
foreach ($class->result() as $r)
{
$course=$r->Course_Code_Section;
$schedule=$r->Day_Time;
$schoolYear=$r->School_Year_Semester;
$prof_fn=$r->First_Name;
$prof_ln=$r->Last_Name;
}
$records=$this->db->query("SELECT s.Student,
(SELECT COUNT(*) FROM tblattendance WHERE SID=.s.SID AND CID=s.CID) as meetings,
(SELECT COUNT(*) FROM tblattendance WHERE SID=.s.SID AND period='$period' AND CID=s.CID AND status='present') as present,
(SELECT COUNT(*) FROM tblattendance WHERE SID=.s.SID AND period='$period' AND CID=s.CID AND status='absent') as absent,
(SELECT COUNT(*) FROM tblattendance WHERE SID=.s.SID AND period='$period' AND CID=s.CID AND status='late') as late FROM tblstudent s WHERE s.CID='$CID'");
$note="";
$report_header = '<span class="tcenter">' . strtoupper($note) . '</span><br/><br/>';
$report_header .= '<table style="width: 100%;border-collapse: collapse;">
<tr>
<th style="text-align: center;"><b>TECHNOLOGICAL INSTITUTE OF THE PHILIPPINES</b></th>
</tr>
<tr>
<th style="text-align: center;">MANILA</th>
</tr>
<tr>
<th style="text-align: center;"><b> </b></th>
</tr>
<tr>
<th style="text-align: center;"><b>STUDENT ATTENDANCE MONITORING SHEET</b></th>
</tr>
<tr>
<th style="text-align: center;">SCHOOL YEAR-SEMESTER: ' . $schoolYear . '</th>
</tr>
<tr>
<th style="text-align: center;">PERIOD: ' . ucwords($period) . '</th>
</tr>
<tr>
<th style="text-align: center;"><b> </b></th>
</tr>
<tr>
<th style="text-align: left;">COURSE CODE-SECTION: ' . $course . '</th>
</tr>
<tr>
<th style="text-align: left;">SCHEDULE: ' . $schedule . '</th>
</tr>
<tr>
<th style="text-align: left;">PROFESSOR: ' . $prof_fn . ' ' . $prof_ln . '</th>
</tr>
<tr>
<th style="text-align: center;"><b> </b></th>
</tr>
<tr>
<th style="text-align: center;"><b> </b></th>
</tr>
</table>';
$report_header .= '<table style="text-align: center;">
<tr style="font-size:8pt;">
<td style="border: 0.5px solid #808080;width: 20%; "><strong>NAME</strong>
<table>
';
$report_header .= '</table></td>';
foreach($dates->result() as $d)
{
$report_header .= '<td style="border: 0.5px solid #808080; width: 6%;">' . $d->date_check . '</td>
<td style="border: 0.5px solid #808080; width: 6%;"><strong>NO. OF DAYS PRESENT</strong></td>
<td style="border: 0.5px solid #808080; width: 6%;"><strong>NO. OF DAYS ABSENT</strong></td>
<td style="border: 0.5px solid #808080; width: 6%;"><strong>NO. OF DAYS LATE</strong></td>
<td style="border: 0.5px solid #808080; width: 15%;"><strong>REMARKS</strong></td>
</tr>
';
}
foreach($student_at->result() as $sat)
{
foreach ($records->result() as $row)
{
$report_header .= '<tr style="font-size:8pt;">
<td style="border: 0.5px solid #808080; width: 20%">' . $row->Student . '</td>
<td style="border: 0.5px solid #808080; width: 6%;">' . strtoupper($sat->status[0]).'</td>
<td style="border: 0.5px solid #808080; width: 6%;">' . $row->present .'</td>
<td style="border: 0.5px solid #808080; width: 6%;">' . $row->absent .'</td>
<td style="border: 0.5px solid #808080; width: 6%;">' . $row->late .'</td>
<td style="border: 0.5px solid #808080; width: 15%;"></td>
</tr>
';
}
}
$report_header .= '<tr>
<td style="border: 0.5px solid #808080;"> </td>';
$report_header .= '</tr>';
$report_footer='</table>
<div class="rt2">
</div>
</body>
</html>';
$report="";
$pdf->writeHTML($report_header . $report . $report_footer, true, false, true, false, '');
$pdf->Output('Attendance Report.pdf', 'I');
}
}
以下是仅有1个日期的工作报告的屏幕截图。
这是我输入2日期时的错误。