Viewing file:      v_rptRis109PDF.php (7.41 KB)      -rwxr-xr-x Select action/file-type:    (+) |   (+) |   (+) | Code (+) | Session (+) |   (+) | SDB (+) |   (+) |   (+) |   (+) |   (+) |   (+) |
 
<?php
 define('FPDF_FONTPATH',$this->config->item('path_application').'/font/');
 
 class PDF extends FPDF
 {
     //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,'RIS109',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,286,19);
      }
 
     //Page footer
     function Footer(){
         //Position at 3.0 cm from bottom
         $this->SetLineWidth(0.4);
         $this->Line(10,199,286,199);
         //Arial italic 8
         $this->SetY(-7);
         $this->SetFont('AngsanaNew','',14);
         //Page number
         $this->Cell(0,0,'หน้า '.$this->PageNo().'/{nb}',0,0,'R');
         $this->SetY(-7);
         //$this->Cell(10);
         $this->Cell(0,0,'วันที่พิมพ์ : '.date("d/m/y H:i"),0,0,'L');
     }
 }
 //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 = 50;
 
 //Set initial x position of table
 $x_axis_initial = 10;
 
 //Set Row Height
 $row_height = 6;
 
 //--------------------------------------------------------
 if($qu_co->num_rows()) {
     $row = $qu_co->row();
     $timeTable = iconv('UTF-8','TIS-620',$row->dyName);
 
     $prd->prdId = $row->ttPrdFrTime;
     $prd->get_by_key(TRUE);
     if(isset($prd->prdFrTime)){
         list($hh, $mm, $ii) = preg_split('[:]', $prd->prdFrTime);
         $timeTable .= ' '.iconv('UTF-8','TIS-620',$hh).'.'.iconv('UTF-8','TIS-620',$mm);
     }
 
     $prd->prdId = $row->ttPrdToTime;
     $prd->get_by_key(TRUE);
     if(isset($prd->prdFrTime)){
         list($hh, $mm, $ii) = preg_split('[:]', $prd->prdToTime);
         $timeTable .= '-'.iconv('UTF-8','TIS-620',$hh).'.'.iconv('UTF-8','TIS-620',$mm).' น.';
     }
 
     if(!(isset($prd->prdFrTime) && isset($prd->prdFrTime))) {
         $timeTable = ".-. น.";
     }
     
     $midDate = $finalDate = '-';
 
     $esCon = array('esCoId' => $row->coId, 'esExamType' => 'M');
     $qu_es = $es->qryEs($esCon);
     if($qu_es->num_rows()){ 
         $row_es = $qu_es->first_row();
         $midDate = fullDate2($row_es->esDate);
     }
 
     $esCon = array('esCoId' => $row->coId, 'esExamType' => 'F');
     $qu_es = $es->qryEs($esCon);
     if($qu_es->num_rows()){ 
         $row_es = $qu_es->first_row();
         $finalDate = fullDate2($row_es->esDate);
     }
 } else $timeTable = $midDate = $finalDate = '-';
 $pdf->SetFont('AngsanaNew','B',18);
 $pdf->SetX(105);
 $pdf->SetY(24);
 $pdf->Cell(0,0,'รายชื่อนักศึกษาในรายวิชาที่สอน',0,0,'C');
 $pdf->Ln(7);
 $pdf->SetFontSize(16);
 $pdf->Cell(0,0,'รหัสวิชา '.iconv('UTF-8','TIS-620',$row->crsCode).'   รายวิชา '.iconv('UTF-8','TIS-620',$row->crsName).'   หน่วยกิต '.$row->crsUnit,0,0,'C');
 $pdf->Ln(7);
 $pdf->Cell(0,0,'ภาคการศึกษาที่ '.$tmId.'   ปีการศึกษา '.$acY,0,0,'C');
 $pdf->Ln(7);
 $pdf->Cell(0,0,'วันเวลาที่เรียน '.$timeTable.'   วันที่สอบกลางภาค '.iconv('UTF-8','TIS-620',$midDate).'   วันที่สอบปลายภาค '.iconv('UTF-8','TIS-620',$finalDate),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(12,12,'ลำดับที่',1,0,'C',1);
 $pdf->Cell(23,12,'รหัสนักศึกษา',1,0,'C',1);
 $pdf->Cell(68,12,'ชื่อ-สกุล',1,0,'C',1);
 $pdf->Cell(30,12,'สถานภาพนักศึกษา',1,0,'C',1);
 $pdf->Cell(128,6,'สัปดาห์ที่',1,0,'C',1);
 $pdf->Cell(15,12,'หมายเหตุ',1,0,'C',1);
 
 $y_axis = $y_axis_initial + $row_height;
 
 $pdf->SetY($y_axis);
 $pdf->SetX($x_axis_initial+133);
 $pdf->Cell(8,6,'1',1,0,'C',1);
 $pdf->Cell(8,6,'2',1,0,'C',1);
 $pdf->Cell(8,6,'3',1,0,'C',1);
 $pdf->Cell(8,6,'4',1,0,'C',1);
 $pdf->Cell(8,6,'5',1,0,'C',1);
 $pdf->Cell(8,6,'6',1,0,'C',1);
 $pdf->Cell(8,6,'7',1,0,'C',1);
 $pdf->Cell(8,6,'8',1,0,'C',1);
 $pdf->Cell(8,6,'9',1,0,'C',1);
 $pdf->Cell(8,6,'10',1,0,'C',1);
 $pdf->Cell(8,6,'11',1,0,'C',1);
 $pdf->Cell(8,6,'12',1,0,'C',1);
 $pdf->Cell(8,6,'13',1,0,'C',1);
 $pdf->Cell(8,6,'14',1,0,'C',1);
 $pdf->Cell(8,6,'15',1,0,'C',1);
 $pdf->Cell(8,6,'16',1,0,'C',1);
 
 $y_axis = $y_axis + $row_height;
 
 //initialize counter
 $i = 0;
 $r = 1;
 
 //Set maximum rows per page
 $max = 20;
 
 $i = 0;    
 if($rs_rd->num_rows()){
   foreach($rs_rd->result() as $row_rd){
     if($i == $max) {
         $i = 0;
         $pdf->AddPage();
 
         $pdf->SetFont('AngsanaNew','B',18);
         $pdf->SetX(105);
         $pdf->SetY(24);
         $pdf->Cell(0,0,'รายชื่อนักศึกษาในรายวิชาที่สอน',0,0,'C');
         $pdf->Ln(7);
         $pdf->SetFontSize(16);
 
         $pdf->Cell(0,0,'รหัสวิชา '.iconv('UTF-8','TIS-620',$row->crsCode).'   รายวิชา '.iconv('UTF-8','TIS-620',$row->crsName).'   หน่วยกิต '.$row->crsUnit,0,0,'C');
         $pdf->Ln(7);
         $pdf->Cell(0,0,'ภาคการศึกษาที่ '.$tmId.'   ปีการศึกษา '.$acY,0,0,'C');
         $pdf->Ln(7);
         $pdf->Cell(0,0,'วันเวลาที่เรียน '.$timeTable.'   วันที่สอบกลางภาค '.$midDate.'   วันที่สอบปลายภาค '.$finalDate,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(12,12,'ลำดับที่',1,0,'C',1);
         $pdf->Cell(23,12,'รหัสนักศึกษา',1,0,'C',1);
         $pdf->Cell(68,12,'ชื่อ-สกุล',1,0,'C',1);
         $pdf->Cell(30,12,'สถานภาพนักศึกษา',1,0,'C',1);
         $pdf->Cell(128,6,'สัปดาห์ที่',1,0,'C',1);
         $pdf->Cell(15,12,'หมายเหตุ',1,0,'C',1);
         
         $y_axis = $y_axis_initial + $row_height;
         
         $pdf->SetY($y_axis);
         $pdf->SetX($x_axis_initial+133);
         $pdf->Cell(8,6,'1',1,0,'C',1);
         $pdf->Cell(8,6,'2',1,0,'C',1);
         $pdf->Cell(8,6,'3',1,0,'C',1);
         $pdf->Cell(8,6,'4',1,0,'C',1);
         $pdf->Cell(8,6,'5',1,0,'C',1);
         $pdf->Cell(8,6,'6',1,0,'C',1);
         $pdf->Cell(8,6,'7',1,0,'C',1);
         $pdf->Cell(8,6,'8',1,0,'C',1);
         $pdf->Cell(8,6,'9',1,0,'C',1);
         $pdf->Cell(8,6,'10',1,0,'C',1);
         $pdf->Cell(8,6,'11',1,0,'C',1);
         $pdf->Cell(8,6,'12',1,0,'C',1);
         $pdf->Cell(8,6,'13',1,0,'C',1);
         $pdf->Cell(8,6,'14',1,0,'C',1);
         $pdf->Cell(8,6,'15',1,0,'C',1);
         $pdf->Cell(8,6,'16',1,0,'C',1);
         
         $y_axis = $y_axis + $row_height;
     }
 
     $pdf->SetFont('AngsanaNew','',14);
     $pdf->SetY($y_axis);
     $pdf->SetX($x_axis_initial);
     $pdf->Cell(12,6,$r,1,0,'C');
     $pdf->Cell(23,6,iconv('UTF-8','TIS-620',$row_rd->stdCode),1,0,'C');
     $pdf->Cell(68,6,iconv('UTF-8','TIS-620',$row_rd->prefixName.$row_rd->stdName.' '.$row_rd->stdSurname),1,0,'L');
     $pdf->Cell(30,6,iconv('UTF-8','TIS-620',$row_rd->sstName),1,0,'L');
     $pdf->Cell(8,6,'',1,0,'C');
     $pdf->Cell(8,6,'',1,0,'C');
     $pdf->Cell(8,6,'',1,0,'C');
     $pdf->Cell(8,6,'',1,0,'C');
     $pdf->Cell(8,6,'',1,0,'C');
     $pdf->Cell(8,6,'',1,0,'C');
     $pdf->Cell(8,6,'',1,0,'C');
     $pdf->Cell(8,6,'',1,0,'C');
     $pdf->Cell(8,6,'',1,0,'C');
     $pdf->Cell(8,6,'',1,0,'C');
     $pdf->Cell(8,6,'',1,0,'C');
     $pdf->Cell(8,6,'',1,0,'C');
     $pdf->Cell(8,6,'',1,0,'C');
     $pdf->Cell(8,6,'',1,0,'C');
     $pdf->Cell(8,6,'',1,0,'C');
     $pdf->Cell(8,6,'',1,0,'C');
     $pdf->Cell(15,6,'',1,0,'C');
 
     //Go to next row
     $y_axis = $y_axis + $row_height;
     $i = $i + 1;
     $r = $r + 1;
   } //End foreach
 }
 
 //Create file
 $pdf->Output();
 $pdf->Output();
 ?>
  |