Viewing file: v_rptRis113_11.php (18.43 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
ini_set("memory_limit", $this->config->item('rg_memory_limit'));
define('FPDF_FONTPATH',$this->config->item('path_application').'/font/');
//$this->load->library('fpdf_thai');
class FPDF2File extends FPDF
{
var $f;
function Open($file)
{
if(FPDF_VERSION<'1.53')
$this->Error('Version 1.53 or above is required by this extension');
$this->f=fopen($file,'wb');
if(!$this->f)
$this->Error('Unable to create output file: '.$file);
parent::Open();
$this->_putheader();
}
function Image($file,$x,$y,$w=0,$h=0,$type='',$link='')
{
if(!isset($this->images[$file]))
{
//Retrieve only meta-information
$a=getimagesize($file);
if($a===false)
$this->Error('Missing or incorrect image file: '.$file);
$this->images[$file]=array('w'=>$a[0],'h'=>$a[1],'type'=>$a[2],'i'=>count($this->images)+1);
}
parent::Image($file,$x,$y,$w,$h,$type,$link);
}
function Output()
{
if($this->state<3)
$this->Close();
}
function _endpage()
{
parent::_endpage();
//Write page to file
$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
$p=($this->compress) ? gzcompress($this->buffer) : $this->buffer;
$this->_newobj();
$this->_out('<<'.$filter.'/Length '.strlen($p).'>>');
$this->_putstream($p);
$this->_out('endobj');
$this->buffer='';
}
function _newobj()
{
$this->n++;
$this->offsets[$this->n]=ftell($this->f);
$this->_out($this->n.' 0 obj');
}
function _out($s)
{
if($this->state==2)
$this->buffer.=$s."\n";
else
fwrite($this->f,$s."\n",strlen($s)+1);
}
function _putimages()
{
$mqr=get_magic_quotes_runtime();
set_magic_quotes_runtime(0);
$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
reset($this->images);
while(list($file,$info)=each($this->images))
{
//Load image
if($info['type']==2)
$info=$this->_parsejpg($file);
elseif($info['type']==3)
$info=$this->_parsepng($file);
elseif($info['type']==1 && method_exists($this,'_parsegif'))
$info=$this->_parsegif($file);
else
$this->Error('Unsupported image type: '.$file);
//Put it into file
$this->_newobj();
$this->images[$file]['n']=$this->n;
$this->_out('<</Type /XObject');
$this->_out('/Subtype /Image');
$this->_out('/Width '.$info['w']);
$this->_out('/Height '.$info['h']);
if($info['cs']=='Indexed')
$this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]');
else
{
$this->_out('/ColorSpace /'.$info['cs']);
if($info['cs']=='DeviceCMYK')
$this->_out('/Decode [1 0 1 0 1 0 1 0]');
}
$this->_out('/BitsPerComponent '.$info['bpc']);
if(isset($info['f']))
$this->_out('/Filter /'.$info['f']);
if(isset($info['parms']))
$this->_out($info['parms']);
if(isset($info['trns']) && is_array($info['trns']))
{
$trns='';
for($i=0;$i<count($info['trns']);$i++)
$trns.=$info['trns'][$i].' '.$info['trns'][$i].' ';
$this->_out('/Mask ['.$trns.']');
}
$this->_out('/Length '.strlen($info['data']).'>>');
$this->_putstream($info['data']);
unset($info['data']);
$this->_out('endobj');
//Palette
if($info['cs']=='Indexed')
{
$this->_newobj();
$pal=($this->compress) ? gzcompress($info['pal']) : $info['pal'];
$this->_out('<<'.$filter.'/Length '.strlen($pal).'>>');
$this->_putstream($pal);
$this->_out('endobj');
}
}
set_magic_quotes_runtime($mqr);
}
function _putpages()
{
$nb=$this->page;
if($this->DefOrientation=='P')
{
$wPt=$this->fwPt;
$hPt=$this->fhPt;
}
else
{
$wPt=$this->fhPt;
$hPt=$this->fwPt;
}
//Page objects
for($n=1;$n<=$nb;$n++)
{
$this->_newobj();
$this->_out('<</Type /Page');
$this->_out('/Parent 1 0 R');
if(isset($this->OrientationChanges[$n]))
$this->_out(sprintf('/MediaBox [0 0 %.2f %.2f]',$hPt,$wPt));
$this->_out('/Resources 2 0 R');
if(isset($this->PageLinks[$n]))
{
//Links
$annots='/Annots [';
foreach($this->PageLinks[$n] as $pl)
{
$rect=sprintf('%.2f %.2f %.2f %.2f',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]);
$annots.='<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] ';
if(is_string($pl[4]))
$annots.='/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>';
else
{
$l=$this->links[$pl[4]];
$h=isset($this->OrientationChanges[$l[0]]) ? $wPt : $hPt;
$annots.=sprintf('/Dest [%d 0 R /XYZ 0 %.2f null]>>',2+$nb+$l[0],$h-$l[1]*$this->k);
}
}
$this->_out($annots.']');
}
$this->_out('/Contents '.(2+$n).' 0 R>>');
$this->_out('endobj');
}
//Page root
$this->offsets[1]=ftell($this->f);
$this->_out('1 0 obj');
$this->_out('<</Type /Pages');
$kids='/Kids [';
for($n=1;$n<=$nb;$n++)
$kids.=(2+$nb+$n).' 0 R ';
$this->_out($kids.']');
$this->_out('/Count '.$nb);
$this->_out(sprintf('/MediaBox [0 0 %.2f %.2f]',$wPt,$hPt));
$this->_out('>>');
$this->_out('endobj');
}
function _putresources()
{
$this->_putfonts();
$this->_putimages();
//Resource dictionary
$this->offsets[2]=ftell($this->f);
$this->_out('2 0 obj');
$this->_out('<<');
$this->_putresourcedict();
$this->_out('>>');
$this->_out('endobj');
}
function _putcatalog()
{
$this->_out('/Type /Catalog');
$this->_out('/Pages 1 0 R');
$n=3+$this->page;
if($this->ZoomMode=='fullpage')
$this->_out('/OpenAction ['.$n.' 0 R /Fit]');
elseif($this->ZoomMode=='fullwidth')
$this->_out('/OpenAction ['.$n.' 0 R /FitH null]');
elseif($this->ZoomMode=='real')
$this->_out('/OpenAction ['.$n.' 0 R /XYZ null null 1]');
elseif(!is_string($this->ZoomMode))
$this->_out('/OpenAction ['.$n.' 0 R /XYZ null null '.($this->ZoomMode/100).']');
if($this->LayoutMode=='single')
$this->_out('/PageLayout /SinglePage');
elseif($this->LayoutMode=='continuous')
$this->_out('/PageLayout /OneColumn');
elseif($this->LayoutMode=='two')
$this->_out('/PageLayout /TwoColumnLeft');
}
function _enddoc()
{
$this->_putpages();
$this->_putresources();
//Info
$this->_newobj();
$this->_out('<<');
$this->_putinfo();
$this->_out('>>');
$this->_out('endobj');
//Catalog
$this->_newobj();
$this->_out('<<');
$this->_putcatalog();
$this->_out('>>');
$this->_out('endobj');
//Cross-ref
$o=ftell($this->f);
$this->_out('xref');
$this->_out('0 '.($this->n+1));
$this->_out('0000000000 65535 f ');
for($i=1;$i<=$this->n;$i++)
$this->_out(sprintf('%010d 00000 n ',$this->offsets[$i]));
//Trailer
$this->_out('trailer');
$this->_out('<<');
$this->_puttrailer();
$this->_out('>>');
$this->_out('startxref');
$this->_out($o);
$this->_out('%%EOF');
$this->state=3;
fclose($this->f);
}
}
class PDF extends FPDF {
var $cfgClgLogo;
var $cfgClgName;
var $cfgSiteName;
var $lSignature;
var $mSignature;
var $rSignature;
var $lPos;
var $mPos;
var $rPos;
var $qu_lSignature;
var $qu_mSignature;
var $qu_rSignature;
//Page header
function Header() {
//Logo
$this->Image($this->cfgClgLogo,10,3,18,15);
//AngsanaNew bold 15
$this->SetFont('AngsanaNew','B',15);
//Move to the right
$this->SetY(7);
$this->SetX(30);
//Title
$this->Cell(0,0,$this->cfgClgName,0,0,'L');
$this->SetX(-10);
$this->SetFontSize(12);
$this->Cell(0,0,'RIS113',0,0,'R');
$this->Ln(7);
$this->SetX(30);
$this->SetFontSize(15);
$this->Cell(0,0,$this->cfgSiteName,0,0,'L');
//Draw line
$this->SetLineWidth(0.4);
$this->Line(10,19,200,19);
}
//Page footer
function Footer() {
$y_axis = 272;
$this->SetY($y_axis);
$this->SetX(15);
$this->Cell(60,0,($this->lSignature && $this->lPos) ? '..................................................' : '',0,0,'C');
$this->Cell(60,0,($this->mSignature && $this->mPos) ? '..................................................' : '',0,0,'C');
$this->Cell(60,0,($this->rSignature && $this->rPos) ? '..................................................' : '',0,0,'C');
$y_axis = $y_axis + 5;
$this->SetY($y_axis);
$this->SetX(15);
$this->Cell(60,0,($this->lSignature && $this->lPos) ? '('.iconv('UTF-8','CP874',$this->qu_lSignature).')' : '',0,0,'C');
$this->Cell(60,0,($this->mSignature && $this->mPos) ? '('.iconv('UTF-8','CP874',$this->qu_mSignature).')' : '',0,0,'C');
$this->Cell(60,0,($this->rSignature && $this->rPos) ? '('.iconv('UTF-8','CP874',$this->qu_rSignature).')' : '',0,0,'C');
$y_axis = $y_axis + 5;
$tmpLPos = explode('^', $this->lPos);
$tmpMPos = explode('^', $this->mPos);
$tmpRPos = explode('^', $this->rPos);
$this->SetY($y_axis);
$this->SetX(15);
$this->Cell(60,0,($this->lSignature && $this->lPos) ? iconv('UTF-8','CP874',$tmpLPos[0]) : '',0,0,'C');
$this->Cell(60,0,($this->mSignature && $this->mPos) ? iconv('UTF-8','CP874',$tmpMPos[0]) : '',0,0,'C');
$this->Cell(60,0,($this->rSignature && $this->rPos) ? iconv('UTF-8','CP874',$tmpRPos[0]) : '',0,0,'C');
$y_axis = $y_axis + 5;
$this->SetY($y_axis);
$this->SetX(15);
$this->Cell(60,0,($this->lSignature && $this->lPos && isset($tmpLPos[1])) ? iconv('UTF-8','CP874',$tmpLPos[1]) : '',0,0,'C');
$this->Cell(60,0,($this->mSignature && $this->mPos && isset($tmpMPos[1])) ? iconv('UTF-8','CP874',$tmpMPos[1]) : '',0,0,'C');
$this->Cell(60,0,($this->rSignature && $this->rPos && isset($tmpRPos[1])) ? iconv('UTF-8','CP874',$tmpRPos[1]) : '',0,0,'C');
//Position at 3.0 cm from bottom
$this->SetLineWidth(0.4);
$this->Line(10,290,200,290);
//Arial italic 8
$this->SetY(-3);
//Page number
$this->Cell(0,0,'หน้า '.$this->PageNo().'/{nb}',0,0,'R');
$this->SetY(-3);
//$this->Cell(10);
$this->Cell(0,0,'วันที่พิมพ์ : '.date("d/m/y H:i"),0,0,'L');
}
} //End class
//Create new pdf file
$pdf=new PDF();
$pdf->lSignature = $lSignature;
$pdf->lPos = $lPos;
$pdf->mSignature = $mSignature;
$pdf->mPos = $mPos;
$pdf->rSignature = $rSignature;
$pdf->rPos = $rPos;
$pdf->qu_lSignature = $qu_lSignature;
$pdf->qu_mSignature = $qu_mSignature;
$pdf->qu_rSignature = $qu_rSignature;
$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();
//$pdf->Open(base_url().$this->config->item('rg_docPdf'));
//$pdf->Open($this->config->item('rg_docPdf'));
//echo "<br>".$this->config->item('rg_docPdf');
//die();
//Disable automatic page break
$pdf->SetAutoPageBreak(false);
//Set initial y axis position per page
$y_axis_initial = 45;
//Set initial x position of table
$x_axis_initial = 20;
//Set Row Height
$row_height = 5;
if ( $rs_std->num_rows() > 0) {
foreach($rs_std->result() as $row) {
$pdf->AddPage();
$pdf->SetFont('AngsanaNew','B',15);
$pdf->SetX(105);
$pdf->SetY(22);
if($tmId)
$pdf->Cell(0,0,'รายงานผลการเรียนนักศึกษารายภาคการศึกษา',0,0,'C');
else
$pdf->Cell(0,0,'รายงานผลการเรียนนักศึกษารายปีการศึกษา',0,0,'C');
$pdf->Ln(5);
$pdf->SetFontSize(13);
$pdf->Cell(0,0,'หลักสูตร '.iconv('UTF-8','CP874',$row->curName).' ระดับ '.iconv('UTF-8','CP874',$row->levelName).' รุ่นที่ '.iconv('UTF-8','CP874',$row->genNo),0,0,'C');
$pdf->Ln(5);
if($tmId)
$pdf->Cell(0,0,'ภาคการศึกษาที่ '.$tmId.' ปีการศึกษา '.$acY,0,0,'C');
else
$pdf->Cell(0,0,'ปีการศึกษา '.$acY,0,0,'C');
$pdf->Ln(5);
$pdf->Cell(0,0,'รหัสนักศึกษา '.iconv('UTF-8','CP874',$row->stdCode).' ชื่อ-สกุลนักศึกษา '.iconv('UTF-8','CP874',$row->prefixName).iconv('UTF-8','CP874',$row->stdName).' '.iconv('UTF-8','CP874',$row->stdSurname),0,0,'C');
$pdf->Ln(5);
$pdf->Cell(0,0,'เจ้าของทุน '.iconv('UTF-8','CP874',$row->soName).' จังหวัด '.iconv('UTF-8','CP874',$row->soPrv),0,0,'C');
//print column titles for the actual page
$pdf->SetFillColor(232,232,232);
$pdf->SetFontSize(12);
$pdf->SetY($y_axis_initial);
$pdf->SetX($x_axis_initial);
$pdf->Cell(20,5,'รหัสวิชา',1,0,'C',1);
$pdf->Cell(110,5,'รายวิชา',1,0,'C',1);
$pdf->Cell(20,5,'หน่วยกิต',1,0,'C',1);
$pdf->Cell(20,5,'ระดับคะแนน',1,0,'C',1);
$y_axis = $y_axis_initial + $row_height;
if($tmId!='') {
$rs_rd = $rd->getRegistDetailsByStdIdAcYTmId($row->stdId, $acY,$tmId);
if ( $rs_rd->num_rows() > 0) {
foreach($rs_rd->result() as $row_rd) {
$pdf->SetFont('AngsanaNew','',12);
$pdf->SetY($y_axis);
$pdf->SetX($x_axis_initial);
$pdf->Cell(20,5,iconv('UTF-8','CP874',$row_rd->crsCode),1,0,'C');
$pdf->Cell(110,5,iconv('UTF-8','CP874',$row_rd->crsName),1,0,'L');
$pdf->Cell(20,5,iconv('UTF-8','CP874',$row_rd->crsUnit),1,0,'C');
if ($row_rd->coDeclareStatus == 'Y') {
$pdf->Cell(20,5,iconv('UTF-8','CP874',$row_rd->rdGrade),1,0,'C');
} else {
$pdf->Cell(20,5,'',1,0,'C');
}
//Go to next row
$y_axis = $y_axis + $row_height;
}
}
}else {
$rs_tm = $tm->qryTm();
if ( $rs_tm->num_rows() > 0) {
foreach($rs_tm->result() as $row_tm) {
$k = 0;
$rs_rd = $rd->getRegistDetailsByStdIdAcYTmId($row->stdId, $acY,$row_tm->tmId);
if ( $rs_rd->num_rows() > 0) {
foreach($rs_rd->result() as $row_rd2) {
if(!$k) {
$pdf->SetFont('AngsanaNew','B',12);
$pdf->SetY($y_axis);
$pdf->SetX($x_axis_initial);
$pdf->Cell(20,5,'',1,0,'C');
$pdf->Cell(110,5,iconv('UTF-8','CP874',$row_tm->tmName),1,0,'C');
$pdf->Cell(20,5,'',1,0,'C');
$pdf->Cell(20,5,'',1,0,'C');
$y_axis = $y_axis + $row_height;
}
$pdf->SetFont('AngsanaNew','',12);
$pdf->SetY($y_axis);
$pdf->SetX($x_axis_initial);
$pdf->Cell(20,5,iconv('UTF-8','CP874',$row_rd2->crsCode),1,0,'C');
$pdf->Cell(110,5,iconv('UTF-8','CP874',$row_rd2->crsName),1,0,'L');
$pdf->Cell(20,5,iconv('UTF-8','CP874',$row_rd2->crsUnit),1,0,'C');
if ($row_rd2->coDeclareStatus == 'Y') {
$pdf->Cell(20,5,iconv('UTF-8','CP874',$row_rd2->rdGrade),1,0,'C');
} else {
$pdf->Cell(20,5,'',1,0,'C');
}
//Go to next row
$y_axis = $y_axis + $row_height;
if($k == $rs_rd->num_rows()-1) {
$cond = array('ssmStdId' => $row->stdId,
'ssmAcY' => $acY,
'ssmTmId' => $row_tm->tmId);
$qu_ssm2 = $ssm->qrySsm($cond);
if ($qu_ssm2->num_rows()) {
$row_ssm2 = $qu_ssm2->row();
$gpa = iconv('UTF-8','CP874',$row_ssm2->ssmGPA);
$ssmCreditPoint = iconv('UTF-8','CP874',$row_ssm2->ssmCreditPoint);
$ssmGPAX = iconv('UTF-8','CP874',$row_ssm2->ssmGPAX);
$ssmSumCreditPoint = iconv('UTF-8','CP874',$row_ssm2->ssmSumCreditPoint);
} else {
$gpa = 0;
$ssmCreditPoint = '';
$ssmGPAX = 0;
$ssmSumCreditPoint = '';
}
$pdf->SetFont('AngsanaNew','B',12);
$pdf->SetY($y_axis);
$pdf->SetX($x_axis_initial);
$pdf->Cell(20,5,'',1,0,'C');
$tmpDivision = $rd->GetAllFDivisorGPAX($row->stdId,$acY,$row_tm->tmId);
if($tmpDivision==0)
$pdf->Cell(110,5,'หน่วยกิต: '.$ssmCreditPoint.' คะแนนเฉลี่ย: '.number_format($gpa, 2).' หน่วยกิตสะสม: '.$ssmSumCreditPoint.' คะแนนเฉลี่ยสะสม: '.number_format(0, 2),1,0,'C');
else
$pdf->Cell(110,5,'หน่วยกิต: '.$ssmCreditPoint.' คะแนนเฉลี่ย: '.number_format($gpa, 2).' หน่วยกิตสะสม: '.$ssmSumCreditPoint.' คะแนนเฉลี่ยสะสม: '.number_format(($rd->getDividendGPAX($row->stdId,$acY,$row_tm->tmId) / $rd->GetAllFDivisorGPAX($row->stdId,$acY,$row_tm->tmId)), 2),1,0,'C');
$pdf->Cell(20,5,'',1,0,'C');
$pdf->Cell(20,5,'',1,0,'C');
$y_axis = $y_axis + $row_height;
}
$k++;
}
}
}
$tmId = $row_tm->tmId;
}
}
$y_axis = $y_axis + $row_height;
$cond = array('ssmStdId' => $row->stdId,
'ssmAcY' => $acY,
'ssmTmId' => $tmId);
$qu_ssm = $ssm->qrySsm($cond);
if ($qu_ssm->num_rows()) {
$row_ssm = $qu_ssm->row();
$gpa = iconv('UTF-8','CP874',$row_ssm->ssmGPA);
$ssmCreditPoint = iconv('UTF-8','CP874',$row_ssm->ssmCreditPoint);
$ssmGPAX = iconv('UTF-8','CP874',$row_ssm->ssmGPAX);
$ssmSumCreditPoint = iconv('UTF-8','CP874',$row_ssm->ssmSumCreditPoint);
} else {
$gpa = 0;
$ssmCreditPoint = '';
$ssmGPAX = 0;
$ssmSumCreditPoint = '';
}
$pdf->SetFont('AngsanaNew','',12);
$pdf->SetY($y_axis);
$pdf->SetX($x_axis_initial);
if($tmId) {
$pdf->Cell(90,0,'คะแนนเฉลี่ยรายภาคการศึกษา : '.number_format($gpa, 2),0,0,'L');
$pdf->Cell(0,0,'รวมหน่วยกิตรายภาคการศึกษา : '.$ssmCreditPoint,0,0,'L');
} else {
$tmpDivision = $rd->GetAllFDivisorAYRGPAX($row->stdId,$acY);
if($tmpDivision==0)
$pdf->Cell(90,0,'คะแนนเฉลี่ยตลอดปีการศึกษา : '.number_format(0, 2),0,0,'L');
else
$pdf->Cell(90,0,'คะแนนเฉลี่ยตลอดปีการศึกษา : '.number_format(($rd->GetDividendAYRGPA($row->stdId,$acY) / $rd->GetAllFDivisorAYRGPAX($row->stdId,$acY) ), 2),0,0,'L');
$pdf->Cell(0,0,'รวมหน่วยกิตตลอดปีการศึกษา : '.$ssm->GetSumCreditPointByStIdAndAcY($row->stdId,$acY),0,0,'L');
}
$pdf->Ln(5);
$pdf->SetX($x_axis_initial);
$pdf->Cell(90,0,'คะแนนเฉลี่ยสะสมตลอดหลักสูตร : '.number_format($ssmGPAX, 2),0,0,'L');
$pdf->Cell(0,0,'รวมหน่วยกิตสะสมตลอดหลักสูตร : '.$ssm->GetSumCreditPointByStId($row->stdId),0,0,'L');
$y_axis = $y_axis + ($row_height * 2.5);
$pdf->SetFont('AngsanaNew','',12);
$pdf->SetY($y_axis);
$pdf->SetX($x_axis_initial);
$pdf->Cell(0,0,'หมายเหตุ',0,0,'L');
$y_axis = $y_axis + $row_height;
$i = 0;
$rs_grd = $grd->qryGtpId($row->curGtpId);
if($rs_grd->num_rows()>0){
foreach($rs_grd->result() as $row_grd) {
if(($i%5) == 0) {
$pdf->SetY($y_axis);
$pdf->SetX($x_axis_initial);
$y_axis = $y_axis + $row_height;
}
$pdf->Cell(35,0,iconv('UTF-8','CP874',$row_grd->grdGrade).' : '.iconv('UTF-8','CP874',$row_grd->grdDescription),0,0,'L');
$i++;
}
}
} //End foreach
} else {
$pdf->AddPage();
$pdf->SetFontSize(18);
$pdf->Cell(105);
$pdf->SetY(27);
$pdf->Cell(0,0,'ไม่มีข้อมูล...',0,0,'C');
}
//Create file
$pdf->Output();
set_time_limit(30);
?>
<!-- <meta http-equiv="refresh" content="0; URL=<?php //echo base_url().$this->config->item('rg_docPdf');?>"> -->
|