Viewing file:      v_rptRis203PDF.php (5.36 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,10,6,18,15);
         //AngsanaNew bold 15
         $this->SetFont('AngsanaNew','B',15);
         //Move to the right
         $this->SetY(10);
         $this->SetX(30);
         //Title
         $this->Cell(0,0,$this->cfgClgName,0,0,'L');
         $this->SetX(-10);
         $this->SetFontSize(12);
         $this->Cell(0,0,'RIS203',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,22,290,22);
     }
 
     //Page footer
     function Footer() {
         //Position at 3.0 cm from bottom
         $this->SetLineWidth(0.4);
         $this->Line(10,196,290,196);
         $this->SetY(-10);
         $this->SetFont('AngsanaNew','',14);
         //Page number
         $this->Cell(0,0,'˹éÒ '.$this->PageNo().'/{nb}',0,0,'R');
         $this->SetY(-10);
         $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);
 
 //Add first page
 $pdf->AddPage();
 
 //set initial y axis position per page
 $y_axis_initial = 47;
 
 //set initial x axis position of table
 $x_axis_initial = 25;
 
 //Set Row Height
 $row_height = 6;
 
 if ($qu_tcf->num_rows()) {
     $row = $qu_tcf->row();
     $tmcAcY = $row->tmcAcY;
 } else {
     $tmcAcY = "";
 }
 
 if ($qu_cur->num_rows()) {
     $row = $qu_cur->row();
     $curName = $row->curName;
     $elvName = $row->levelName;
 } else {
     $curName = "";
     $elvName = "";
 }
 
 if ($rs_std->num_rows()) {
     $row = $rs_std->row();
     $genNo = $row->genNo;
     $stdSyId = $row->stdSyId;
 } else {
     $curName = "";
     $genNo = "";
     $stdSyId = "";
 }
 
 //initialize counter
 $i = 0;
 $r = 1;
 
 //Set maximum rows per page
 $max = 20;
 
 if ($rs_std->num_rows()) {
 
     $pdf->SetFont('AngsanaNew','B',18);
     $pdf->SetX(105);
     $pdf->SetY(27);
     $pdf->Cell(0,0,'ÊÃØ»¢éÍÁÙŹѡÈÖ¡ÉÒ',0,0,'C');
     $pdf->Ln(7);
     $pdf->SetFontSize(16);
     $pdf->Cell(0,0,'»ÃШӻաÒÃÈÖ¡ÉÒ '.iconv('UTF-8','TIS-620',$tmcAcY),0,0,'C');
     $pdf->Ln(7);
     $pdf->Cell(0,0,'ËÅÑ¡Êٵà'.iconv('UTF-8','TIS-620',$curName).'  ÃдѺ '.iconv('UTF-8','TIS-620',$elvName).'  ÃØè¹·Õè '.iconv('UTF-8','TIS-620',$genNo).'  ªÑé¹»Õ·Õè '.$stdSyId,0,0,'C');
 
     //print column titles for the actual page
 
     $pdf->SetFillColor(232,232,232);
     $pdf->SetFontSize(14);
     $pdf->SetY($y_axis_initial);
     $pdf->SetX($x_axis_initial);
     $pdf->Cell(5,6,'·Õè',1,0,'C',1);
     $pdf->Cell(20,6,'ÃËÑʹѡÈÖ¡ÉÒ',1,0,'C',1);
     $pdf->Cell(50,6,'ª×èÍ - Ê¡ØÅ',1,0,'C',1);
     $pdf->Cell(100,6,'à¨éҢͧ·Ø¹',1,0,'C',1);
     $pdf->Cell(20,6,'¨Ñ§ËÇÑ´',1,0,'C',1);
     $pdf->Cell(33,6,'»ÃÐàÀ··Ø¹',1,0,'C',1);
     $pdf->Cell(20,6,'ËÁÒÂà˵Ø',1,0,'C',1);
 
     $y_axis = $y_axis_initial + $row_height;
 
 
     foreach ($rs_std->result() as $row) {
         //If the current row is the last one, create new page and print column title
         //If the current row is the last one, create new page and print column title
         if($i == $max) {
             $pdf->AddPage();
 
             $pdf->SetFont('AngsanaNew','B',18);
             $pdf->SetX(105);
             $pdf->SetY(27);
             $pdf->Cell(0,0,'ÊÃØ»¢éÍÁÙŹѡÈÖ¡ÉÒ',0,0,'C');
             $pdf->Ln(7);
             $pdf->SetFontSize(16);
             $pdf->Cell(0,0,'   »ÃШӻաÒÃÈÖ¡ÉÒ '.iconv('UTF-8','TIS-620',$tmcAcY),0,0,'C');
             $pdf->Ln(7);
             $pdf->Cell(0,0,'ËÅÑ¡Êٵà'.iconv('UTF-8','TIS-620',$curName).'  ÃдѺ '.iconv('UTF-8','TIS-620',$elvName).'  ÃØè¹·Õè '.iconv('UTF-8','TIS-620',$genNo).'  ªÑé¹»Õ·Õè '.$stdSyId,0,0,'C');
 
             //print column titles for the current page
             $pdf->SetFillColor(232,232,232);
             $pdf->SetFont('AngsanaNew','B',14);
             $pdf->SetY($y_axis_initial);
             $pdf->SetX($x_axis_initial);
             $pdf->Cell(5,6,'·Õè',1,0,'C',1);
             $pdf->Cell(20,6,'ÃËÑʹѡÈÖ¡ÉÒ',1,0,'C',1);
             $pdf->Cell(50,6,'ª×èÍ - Ê¡ØÅ',1,0,'C',1);
             $pdf->Cell(100,6,'à¨éҢͧ·Ø¹',1,0,'C',1);
             $pdf->Cell(20,6,'¨Ñ§ËÇÑ´',1,0,'C',1);
             $pdf->Cell(33,6,'»ÃÐàÀ··Ø¹',1,0,'C',1);
             $pdf->Cell(20,6,'ËÁÒÂà˵Ø',1,0,'C',1);
             
             //Go to next row
             $y_axis = $y_axis_initial + $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(5,6,$r,1,0,'C');
         $pdf->Cell(20,6,iconv('UTF-8','TIS-620',$row->stdCode),1,0,'C');
         $pdf->Cell(50,6,iconv('UTF-8','TIS-620',$row->prefixName).iconv('UTF-8','TIS-620',$row->stdName).' '.iconv('UTF-8','TIS-620',$row->stdSurname),1,0,'L');
         $pdf->Cell(100,6,iconv('UTF-8','TIS-620',$row->soName),1,0,'L');
         $pdf->Cell(20,6,iconv('UTF-8','TIS-620',$row->provinceName),1,0,'L');
         $pdf->Cell(33,6,iconv('UTF-8','TIS-620',$row->etName),1,0,'L');
         $pdf->Cell(20,6,'',1,0,'L');
 
         //Go to next row
         $y_axis = $y_axis + $row_height;
         $i = $i + 1;
         $r = $r + 1;
     } //End while
 
     //Create file
     $pdf->Output();
 
 } else {
     $pdf->SetFontSize(18);
     $pdf->Cell(105);
     $pdf->SetY(27);
     $pdf->Cell(0,0,'äÁèÁÕ¢éÍÁÙÅ...',0,0,'C');
     $pdf->Output();
 }
 
 $pdf->Output();
 ?>
  |