Viewing file: v_rptRis201.php (11.43 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
define('FPDF_FONTPATH',$this->config->item('path_application').'/font/');
//$this->load->library('fpdf_thai');
class PDF extends FPDF {
var $cfgClgLogo;
var $cfgClgName;
var $cfgSiteName;
//Page header
function Header() {
//Logo
$this->Image($this->cfgClgLogo,5,6,18,15);
//AngsanaNew bold 15
$this->SetFont('AngsanaNew','B',15);
//Move to the right
$this->SetY(10);
$this->SetX(25);
//Title
$this->Cell(0,0,$this->cfgClgName,0,0,'L');
$this->SetX(-10);
$this->SetFontSize(12);
$this->Cell(0,0,'RIS201',0,0,'R');
$this->Ln(7);
$this->SetX(25);
$this->SetFontSize(15);
$this->Cell(0,0,$this->cfgSiteName,0,0,'L');
//Draw line
$this->SetLineWidth(0.4);
$this->Line(5,22,291,22);
}
//Page footer
function Footer() {
//Position at 3.0 cm from bottom
$this->SetLineWidth(0.4);
$this->Line(5,196,291,196);
$this->SetY(-10);
$this->SetFont('AngsanaNew','',14);
//Page number
$this->Cell(0,0,'หน้า '.$this->PageNo().'/{nb}',0,0,'R');
$this->SetX(5);
$this->Cell(0,0,'วันที่พิมพ์ : '.date("d/m/y H:i"),0,0,'L');
}
} //End class
//Create new pdf file
$pdf=new PDF('L');
$pdf->cfgClgLogo = $this->config->item('rg_upload_picture').$cfgClgLogo;
$pdf->cfgClgName = iconv('UTF-8','TIS-620',$cfgClgName);
$pdf->cfgSiteName = iconv('UTF-8','TIS-620',$cfgSiteName);
//Set thai font.
$pdf->SetThaiFont();
$pdf->AliasNbPages();
//Open file.
$pdf->Open();
//Disable automatic page break
$pdf->SetAutoPageBreak(false);
//Set margin page.
$pdf->SetLeftMargin(20);
$pdf->SetRightMargin(20);
//Set initial y axis position per page
$y_axis_initial = 40;
//Set initial x axis position per page
$x_axis_initial = 5;
//Set Row Height
$row_height = 6;
if ($qu_tcf->num_rows()) {
$row = $qu_tcf->row();
$tmcAcY = $row->tmcAcY;
} else {
$tmcAcY = "";
}
//Add first page
$pdf->AddPage();
$pdf->SetX(150);
$pdf->SetY(27);
$pdf->SetFont('AngsanaNew','B',18);
$pdf->Cell(0,0,'รายงานสรุปยอดนักศึกษาแยกตามหลักสูตร',0,0,'C');
$pdf->Ln(7);
$pdf->SetFontSize(16);
$pdf->Cell(0,0,'ปีการศึกษา '.$tmcAcY,0,0,'C');
$pdf->SetY($y_axis_initial);
$pdf->SetX($x_axis_initial);
$pdf->SetFillColor(232,232,232);
$pdf->Cell(88,18,'หลักสูตร',1,0,'C',1);
$pdf->SetFontSize(14);
$syNumRow = $rs_sty->num_rows();
if ($syNumRow){
foreach ($rs_sty->result() as $row1) {
$pdf->Cell(36,6,'ปี '.$row1->syId.' / ปี พ.ศ. ที่เข้า',1,0,'C',1);
}
$pdf->Cell(36,6,'รวม',1,0,'C',1);
$pdf->Cell(18,6,'รวม',1,0,'C',1);
}
$y_axis = $y_axis_initial + $row_height;
$pdf->SetXY($x_axis_initial+88,$y_axis);
for($sy=1; $sy<=$syNumRow+1; $sy++) {
$pdf->Cell(18,6,'ชาย',1,0,'C',1);
$pdf->Cell(18,6,'หญิง',1,0,'C',1);
}
$pdf->Cell(9,12,'ปกติ',1,0,'C',1);
$pdf->Cell(9,12,'พิเศษ',1,0,'C',1);
$y_axis = $y_axis + $row_height;
$pdf->SetXY($x_axis_initial+88,$y_axis);
for($sy=1; $sy<=($syNumRow+1)*2; $sy++) {
$pdf->Cell(9,6,'ปกติ',1,0,'C',1);
$pdf->Cell(9,6,'พิเศษ',1,0,'C',1);
}
$y_axis = $y_axis + $row_height;
//initialize counter
$i = 0;
$r = 1;
//Set maximum rows per page
$max = 20;
if ($rs_cur->num_rows()) {
foreach ($rs_cur->result() as $row) {
if ($i == $max) {
$pdf->AddPage();
$pdf->SetX(150);
$pdf->SetY(27);
$pdf->SetFont('AngsanaNew','B',18);
$pdf->Cell(0,0,'รายงานสรุปยอดนักศึกษาแยกตามหลักสูตร',0,0,'C');
$pdf->Ln(7);
$pdf->SetFontSize(16);
$pdf->Cell(0,0,'ปีการศึกษา '.$tmcAcY,0,0,'C');
$pdf->SetY($y_axis_initial);
$pdf->SetX($x_axis_initial);
$pdf->SetFillColor(232,232,232);
$pdf->Cell(88,18,'หลักสูตร',1,0,'C',1);
$pdf->SetFontSize(14);
$syNumRow = $rs_sty->num_rows();
if ($syNumRow){
foreach ($rs_sty->result as $row2) {
$pdf->Cell(36,6,'ปี '.$row2->syId.' / ปี พ.ศ. ที่เข้า',1,0,'C',1);
}
$pdf->Cell(36,6,'รวม',1,0,'C',1);
$pdf->Cell(18,6,'รวม',1,0,'C',1);
}
$y_axis = $y_axis_initial + $row_height;
$pdf->SetXY($x_axis_initial+88,$y_axis);
for($sy=1; $sy<=$syNumRow+1; $sy++) {
$pdf->Cell(18,6,'ชาย',1,0,'C',1);
$pdf->Cell(18,6,'หญิง',1,0,'C',1);
}
$pdf->Cell(9,12,'ปกติ',1,0,'C',1);
$pdf->Cell(9,12,'พิเศษ',1,0,'C',1);
$y_axis = $y_axis + $row_height;
$pdf->SetXY($x_axis_initial+88,$y_axis);
for($sy=1; $sy<=($syNumRow+1)*2; $sy++) {
$pdf->Cell(9,6,'ปกติ',1,0,'C',1);
$pdf->Cell(9,6,'พิเศษ',1,0,'C',1);
}
$y_axis = $y_axis + $row_height;
//Set $i variable to 0 (first row)
$i = 0;
}
$pdf->SetFont('AngsanaNew','',14);
$pdf->SetY($y_axis);
$pdf->SetX($x_axis_initial);
$pdf->Cell(88,6,$r.'. '.iconv('UTF-8','TIS-620',$row->levelName),1,0,'L');
for($sy=1; $sy<=(($syNumRow+1)*4)+2; $sy++)
$pdf->Cell(9,6,'',1,0,'C');
//Go to next row
$y_axis = $y_axis + $row_height;
$i = $i + 1;
$c = 1;
// $curCon = array('curElvId' => $row->levelId , 'curStatus' => 'Y');
// $rs_cur2 = $cur->qryCur($curCon,'','');
$curCon = array('curElvId' => $row->levelId , 'curStatus' => 'Y', 'stdSstId' => 1 );
$order = array( 'curId' => '' );
$group = array( 'curId' => 'curId' );
$rs_cur2 = $cur->qryCurJoinStd($curCon, $order,$group);
//echo $cur->db->last_query(); die();
if ($rs_cur2->num_rows()) {
foreach ($rs_cur2->result() as $row_cur) {
if ($i == $max) {
$pdf->AddPage();
$pdf->SetX(150);
$pdf->SetY(27);
$pdf->SetFont('AngsanaNew','B',18);
$pdf->Cell(0,0,'รายงานสรุปยอดนักศึกษาแยกตามหลักสูตร',0,0,'C');
$pdf->Ln(7);
$pdf->SetFontSize(16);
$pdf->Cell(0,0,'ปีการศึกษา '.$tmcAcY,0,0,'C');
$pdf->SetY($y_axis_initial);
$pdf->SetX($x_axis_initial);
$pdf->SetFillColor(232,232,232);
$pdf->Cell(88,18,'หลักสูตร',1,0,'C',1);
$pdf->SetFontSize(14);
$syNumRow = $rs_sty->num_rows();
if ($syNumRow){
foreach ($rs_sty->result as $row3) {
$pdf->Cell(36,6,'ปี '.$row3->syId.' / ปี พ.ศ. ที่เข้า',1,0,'C',1);
}
$pdf->Cell(36,6,'รวม',1,0,'C',1);
$pdf->Cell(18,6,'รวม',1,0,'C',1);
}
$y_axis = $y_axis_initial + $row_height;
$pdf->SetXY($x_axis_initial+88,$y_axis);
for($sy=1; $sy<=$syNumRow+1; $sy++) {
$pdf->Cell(18,6,'ชาย',1,0,'C',1);
$pdf->Cell(18,6,'หญิง',1,0,'C',1);
}
$pdf->Cell(9,12,'ปกติ',1,0,'C',1);
$pdf->Cell(9,12,'พิเศษ',1,0,'C',1);
$y_axis = $y_axis + $row_height;
$pdf->SetXY($x_axis_initial+88,$y_axis);
for($sy=1; $sy<=($syNumRow+1)*2; $sy++) {
$pdf->Cell(9,6,'ปกติ',1,0,'C',1);
$pdf->Cell(9,6,'พิเศษ',1,0,'C',1);
}
$y_axis = $y_axis + $row_height;
//Set $i variable to 0 (first row)
$i = 0;
}
$pdf->SetFont('AngsanaNew','',14);
$pdf->SetY($y_axis);
$pdf->SetX($x_axis_initial);
$pdf->Cell(88,6,$r.'.'.$c.' '.substr(iconv('UTF-8','TIS-620',$row_cur->curName), 0, 55),1,0,'L');
for($sy=1; $sy<=$syNumRow; $sy++) {
if ($rs_ett->num_rows()) {
foreach ($rs_ett->result() as $row_ett) {
$stdCon = array('stdCurId' => $row_cur->curId, 'stdSyId' => $sy,'stdEtId' => $row_ett->etId , 'sdtSex' => 'M' , 'stdSstId' => 1 );
$pdf->Cell(9,6,$std->qryStdCountStdId($stdCon),1,0,'R');
}
foreach ($rs_ett->result() as $row_ett) {
$stdCon = array('stdCurId' => $row_cur->curId, 'stdSyId' => $sy,'stdEtId' => $row_ett->etId , 'sdtSex' => 'F' , 'stdSstId' => 1 );
$pdf->Cell(9,6,$std->qryStdCountStdId($stdCon),1,0,'R');
}
}
}
if ($rs_ett->num_rows()) {
foreach ($rs_ett->result() as $row_ett) {
$stdCon = array('stdCurId' => $row_cur->curId, 'stdEtId' => $row_ett->etId , 'sdtSex' => 'M' , 'stdSstId' => 1 );
$pdf->Cell(9,6,$std->qryStdCountStdId($stdCon),1,0,'R');
}
foreach ($rs_ett->result() as $row_ett) {
$stdCon = array('stdCurId' => $row_cur->curId, 'stdEtId' => $row_ett->etId , 'sdtSex' => 'F' , 'stdSstId' => 1 );
$pdf->Cell(9,6,$std->qryStdCountStdId($stdCon),1,0,'R');
}
foreach ($rs_ett->result() as $row_ett) {
$stdCon = array('stdCurId' => $row_cur->curId, 'stdEtId' => $row_ett->etId , 'stdSstId' => 1 );
$pdf->Cell(9,6,$std->qryStdCountStdId($stdCon),1,0,'R');
}
}
//Go to next row
$y_axis = $y_axis + $row_height;
$i = $i + 1;
$c = $c + 1;
} //end loop
}
$r = $r + 1;
} //end loop
//If the current row is the last one, create new page and print column title
if ($i == $max) {
$pdf->AddPage();
$pdf->SetX(150);
$pdf->SetY(27);
$pdf->SetFont('AngsanaNew','B',18);
$pdf->Cell(0,0,'รายงานสรุปยอดนักศึกษาแยกตามหลักสูตร',0,0,'C');
$pdf->Ln(7);
$pdf->SetFontSize(16);
$pdf->Cell(0,0,'ปีการศึกษา '.$tmcAcY,0,0,'C');
$pdf->SetY($y_axis_initial);
$pdf->SetX($x_axis_initial);
$pdf->SetFillColor(232,232,232);
$pdf->Cell(88,18,'หลักสูตร',1,0,'C',1);
$pdf->SetFontSize(14);
$syNumRow = $rs_sty->num_rows();
if ($syNumRow){
foreach ($rs_sty->result as $row3) {
$pdf->Cell(36,6,'ปี '.$row3->syId.' / ปี พ.ศ. ที่เข้า',1,0,'C',1);
}
$pdf->Cell(36,6,'รวม',1,0,'C',1);
$pdf->Cell(18,6,'รวม',1,0,'C',1);
}
$y_axis = $y_axis_initial + $row_height;
$pdf->SetXY($x_axis_initial+88,$y_axis);
for($sy=1; $sy<=$syNumRow+1; $sy++) {
$pdf->Cell(18,6,'ชาย',1,0,'C',1);
$pdf->Cell(18,6,'หญิง',1,0,'C',1);
}
$pdf->Cell(9,12,'ปกติ',1,0,'C',1);
$pdf->Cell(9,12,'พิเศษ',1,0,'C',1);
$y_axis = $y_axis + $row_height;
$pdf->SetXY($x_axis_initial+88,$y_axis);
for($sy=1; $sy<=($syNumRow+1)*2; $sy++) {
$pdf->Cell(9,6,'ปกติ',1,0,'C',1);
$pdf->Cell(9,6,'พิเศษ',1,0,'C',1);
}
$y_axis = $y_axis + $row_height;
//Set $i variable to 0 (first row)
$i = 0;
}
$pdf->SetY($y_axis);
$pdf->SetX($x_axis_initial);
$pdf->Cell(88,6,'รวม',1,0,'C');
for($sy=1; $sy<=$syNumRow; $sy++) {
if ($rs_ett->num_rows()) {
foreach ($rs_ett->result() as $row_ett) {
$stdCon = array('stdSyId' => $sy,'stdEtId' => $row_ett->etId , 'sdtSex' => 'M' , 'stdSstId' => 1 );
$pdf->Cell(9,6,$std->qryStdCountStdId($stdCon),1,0,'R');
}
foreach ($rs_ett->result() as $row_ett) {
$stdCon = array('stdSyId' => $sy,'stdEtId' => $row_ett->etId , 'sdtSex' => 'F' , 'stdSstId' => 1 );
$pdf->Cell(9,6,$std->qryStdCountStdId($stdCon),1,0,'R');
}
}
}
if ($rs_ett->num_rows()) {
foreach ($rs_ett->result() as $row_ett) {
$stdCon = array('stdEtId' => $row_ett->etId , 'sdtSex' => 'M' , 'stdSstId' => 1 );
$pdf->Cell(9,6,$std->qryStdCountStdId($stdCon),1,0,'R');
}
foreach ($rs_ett->result() as $row_ett) {
$stdCon = array('stdEtId' => $row_ett->etId , 'sdtSex' => 'F' , 'stdSstId' => 1 );
$pdf->Cell(9,6,$std->qryStdCountStdId($stdCon),1,0,'R');
}
foreach ($rs_ett->result() as $row_ett) {
$stdCon = array('stdEtId' => $row_ett->etId , 'stdSstId' => 1 );
$pdf->Cell(9,6,$std->qryStdCountStdId($stdCon),1,0,'R');
}
}
$y_axis = $y_axis + $row_height;
$pdf->Text(20,$pdf->GetY()+14,'หมายเหตุ');
$pdf->Text(30,$pdf->GetY()+21,'ปกติ = นักศึกษาที่รับตามแผนของ สบช.');
$pdf->Text(30,$pdf->GetY()+28,'พิเศษ = นักศึกษาที่รับ On top และอื่นๆ');
//Create file
$pdf->Output();
} else {
echo "<font face='Microsoft Sans Serif' color='red'><b>ไม่มีข้อมูล...</b></font>";
echo "<meta http-equiv='refresh' content='1; URL=adminIndex.php?mm=1'>";
}
//Create file
$pdf->Output();
?>
|