Viewing file:      v_printSendGradePDF.php (9.79 KB)      -rw-r--r-- Select action/file-type:    (+) |   (+) |   (+) | Code (+) | Session (+) |   (+) | SDB (+) |   (+) |   (+) |   (+) |   (+) |   (+) |
 
<?php define('FPDF_FONTPATH',$this->config->item('path_application').'/font/');
  class PDF extends FPDF {     var $cfgClgLogo;     var $cfgClgName;     var $cfgSiteName;
      //Page header     function Header() {         //Logo         $this->Image($this->cfgClgLogo,10,3,18,15);         //Title         $this->SetFont('AngsanaNew','B',15);         $this->SetY(7);         $this->SetX(30);         $this->Cell(0,0,$this->cfgClgName,0,0,'L');         $this->Ln(7);         $this->SetFontSize(15);         $this->SetX(30);         $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()     {         //Position at 3.0 cm from bottom         $this->SetLineWidth(0.4);         $this->Line(10,286,200,286);         $this->SetY(-7);         $this->SetX(10);         $this->SetFont('AngsanaNew','',14);         $this->Cell(0,0,iconv('UTF-8', 'TIS-620', 'วันที่พิมพ์ : '.date("d/m/y H:i")),0,0,'L');         //Page number         $this->Cell(0,0,iconv('UTF-8', 'TIS-620', 'หน้า '.$this->PageNo().'/{nb}'),0,0,'R');     } }
  $row_co = isset($qu_co) ? $qu_co->row() : NULL;
  //Create new pdf file $pdf=new PDF(); $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);
  //Add first page $pdf->AddPage();
  //Set initial y axis position per page $y_axis_initial = 55;
  //Set initial x position of table $x_axis_initial = 20;
  //Set Row Height $row_height = 6;
  $pdf->SetFont('AngsanaNew','B',18); $pdf->SetX(105); $pdf->SetY(25); $pdf->Cell(0,0,iconv('UTF-8', 'TIS-620', 'ผลการเรียนรายวิชา'),0,0,'C'); $pdf->Ln(7); $pdf->SetFontSize(16); $pdf->Cell(25,0,iconv('UTF-8', 'TIS-620', 'รหัสวิชา '),0,0,'L'); $pdf->Cell(100,0,iconv('UTF-8', 'TIS-620', $row_co->crsCode.' '.$row_co->crsName),0,0,'L'); $pdf->Cell(27,0,iconv('UTF-8', 'TIS-620', 'กลุ่ม '),0,0,'L'); $pdf->Cell(0,0,(($view == 's') ? '-' : $row_co->coSection),0,0,'L'); $pdf->Ln(7); $pdf->Cell(25,0,iconv('UTF-8', 'TIS-620', 'หน่วยกิต '),0,0,'L'); $pdf->Cell(100,0,$row_co->crsUnit,0,0,'L'); $pdf->Cell(27,0,iconv('UTF-8', 'TIS-620', 'ภาค/ปีการศึกษา '),0,0,'L'); $pdf->Cell(0,0,$row_co->coTmId.'/'.$row_co->coAcY,0,0,'L'); $pdf->Ln(7); $pdf->Cell(25,0,iconv('UTF-8', 'TIS-620', 'อาจารย์ผู้สอน '),0,0,'L'); //$pdf->Cell(0,0,iconv('UTF-8', 'TIS-620', $prsNames),0,0,'L'); $pdf->SetFontSize(11); $strPrsNames = ''; $nPrs = count($prsNames); if(is_array($prsNames)){         for($cPrs=0; $cPrs<$nPrs && $cPrs<=5; $cPrs++){         $strPrsNames .= $prsNames[$cPrs];     } } $pdf->Cell(0,0,iconv('UTF-8', 'TIS-620', $strPrsNames),0,0,'L'); if($nPrs > 6){     $pdf->Ln(7);$strPrsNames = '';     for($cPrs=6; $cPrs<$nPrs ; $cPrs++){         $strPrsNames .= $prsNames[$cPrs];     }     $pdf->Cell(0,-2,iconv('UTF-8', 'TIS-620', $strPrsNames),0,0,'L');     } //print column titles for the actual page
  $pdf->SetFillColor(232,232,232); $pdf->SetFontSize(14); $pdf->SetY($y_axis_initial); $pdf->Cell(15,6,iconv('UTF-8', 'TIS-620', 'ลำดับที่'),1,0,'C',1); $pdf->Cell(25,6,iconv('UTF-8', 'TIS-620', 'รหัสนักศึกษา'),1,0,'C',1); $pdf->Cell(105,6,iconv('UTF-8', 'TIS-620', 'ชื่อ-นามสกุลนักศึกษา'),1,0,'C',1); $pdf->Cell(25,6,iconv('UTF-8', 'TIS-620', 'เกรด'),1,0,'C',1);
  $y_axis = $y_axis_initial + $row_height;
  //initialize counter $i = 0; $r = 1;
  //Set maximum rows per page $max = 35;
  foreach ($rs1 as $key => $val) {     if ($i == $max) {         $i = 0;         $pdf->AddPage();
          $pdf->SetFont('AngsanaNew','B',18);         $pdf->SetX(105);         $pdf->SetY(25);         $pdf->Cell(0,0,iconv('UTF-8', 'TIS-620', 'ผลการเรียนรายวิชา'),0,0,'C');         $pdf->Ln(7);         $pdf->SetFontSize(16);         $pdf->Cell(25,0,iconv('UTF-8', 'TIS-620', 'รหัสวิชา '),0,0,'L');         $pdf->Cell(100,0,iconv('UTF-8', 'TIS-620', $row_co->crsCode.' '.$row_co->crsName),0,0,'L');         $pdf->Cell(27,0,iconv('UTF-8', 'TIS-620', 'กลุ่ม '),0,0,'L');         $pdf->Cell(0,0,(($view == 's') ? '-' : $row_co->coSection),0,0,'L');         $pdf->Ln(7);         $pdf->Cell(25,0,iconv('UTF-8', 'TIS-620', 'หน่วยกิต '),0,0,'L');         $pdf->Cell(100,0,$row_co->crsUnit,0,0,'L');         $pdf->Cell(27,0,iconv('UTF-8', 'TIS-620', 'ภาค/ปีการศึกษา '),0,0,'L');         $pdf->Cell(0,0,$row_co->coTmId.'/'.$row_co->coAcY,0,0,'L');         $pdf->Ln(7);         $pdf->Cell(25,0,iconv('UTF-8', 'TIS-620', 'อาจารย์ผู้สอน '),0,0,'L');             //$pdf->Cell(0,0,iconv('UTF-8', 'TIS-620', $prsNames),0,0,'L');                 $pdf->SetFontSize(12);         $nPrs = count($prsNames);         $strPrsNames = '';         for($cPrs=0; $cPrs<$nPrs && $cPrs<=5; $cPrs++){             $strPrsNames .= $prsNames[$cPrs];         }         $pdf->Cell(0,0,iconv('UTF-8', 'TIS-620', $strPrsNames),0,0,'L');         if($nPrs > 6){             $pdf->Ln(7);$strPrsNames = '';             for($cPrs=6; $cPrs<$nPrs ; $cPrs++){                 $strPrsNames .= $prsNames[$cPrs];             }             $pdf->Cell(0,-2,iconv('UTF-8', 'TIS-620', $strPrsNames),0,0,'L');             }                  //print column titles for the current page         $pdf->SetFillColor(232,232,232);         $pdf->SetFontSize(14);         $pdf->SetY($y_axis_initial);         $pdf->Cell(15,6,iconv('UTF-8', 'TIS-620', 'ลำดับที่'),1,0,'C',1);         $pdf->Cell(25,6,iconv('UTF-8', 'TIS-620', 'รหัสนักศึกษา'),1,0,'C',1);         $pdf->Cell(105,6,iconv('UTF-8', 'TIS-620', 'ชื่อ-นามสกุลนักศึกษา'),1,0,'C',1);         $pdf->Cell(25,6,iconv('UTF-8', 'TIS-620', 'เกรด'),1,0,'C',1);
          //Go to next row         $y_axis = $y_axis_initial + $row_height;     }
      $row_std = $rs1[$key]['qu_std']->row();
      $pdf->SetFont('AngsanaNew','',14);     $pdf->SetY($y_axis);     $pdf->Cell(15,6,$r,1,0,'C');     $pdf->Cell(25,6,$row_std->stdCode,1,0,'C');     $pdf->Cell(105,6,iconv('UTF-8', 'TIS-620', $row_std->prefixName.$row_std->stdName.' '.$row_std->stdSurname),1,0,'L');     $pdf->Cell(25,6,iconv('UTF-8', 'TIS-620', $rs1[$key]['rdGrade']),1,0,'C');
      //Go to next row     $y_axis = $y_axis + $row_height;     $i = $i + 1;     $r = $r + 1; }
  if ($i > 25) {     $i = 0;     $pdf->AddPage();
      $pdf->SetFont('AngsanaNew','B',18);     $pdf->SetX(105);     $pdf->SetY(25);     $pdf->Cell(0,0,iconv('UTF-8', 'TIS-620', 'ผลการเรียนรายวิชา'),0,0,'C');     $pdf->Ln(7);     $pdf->SetFontSize(16);     $pdf->Cell(25,0,iconv('UTF-8', 'TIS-620', 'รหัสวิชา '),0,0,'L');     $pdf->Cell(100,0,iconv('UTF-8', 'TIS-620', $row_co->crsCode.' '.$row_co->crsName),0,0,'L');     $pdf->Cell(27,0,iconv('UTF-8', 'TIS-620', 'กลุ่ม '),0,0,'L');     $pdf->Cell(0,0,(($view == 's') ? '-' : $row_co->coSection),0,0,'L');     $pdf->Ln(7);     $pdf->Cell(25,0,iconv('UTF-8', 'TIS-620', 'หน่วยกิต '),0,0,'L');     $pdf->Cell(100,0,$row_co->crsUnit,0,0,'L');     $pdf->Cell(27,0,iconv('UTF-8', 'TIS-620', 'ภาค/ปีการศึกษา '),0,0,'L');     $pdf->Cell(0,0,$row_co->coTmId.'/'.$row_co->coAcY,0,0,'L');     $pdf->Ln(7);     $pdf->Cell(25,0,iconv('UTF-8', 'TIS-620', 'อาจารย์ผู้สอน '),0,0,'L'); //    $pdf->Cell(0,0,iconv('UTF-8', 'TIS-620', $prsNames),0,0,'L');     $pdf->SetFontSize(12);     $nPrs = count($prsNames);     $strPrsNames = '';     for($cPrs=0; $cPrs<$nPrs && $cPrs<=5; $cPrs++){         $strPrsNames .= $prsNames[$cPrs];     }     $pdf->Cell(0,0,iconv('UTF-8', 'TIS-620', $strPrsNames),0,0,'L');     if($nPrs > 6){         $pdf->Ln(7);$strPrsNames = '';         for($cPrs=6; $cPrs<$nPrs ; $cPrs++){             $strPrsNames .= $prsNames[$cPrs];         }         $pdf->Cell(0,-2,iconv('UTF-8', 'TIS-620', $strPrsNames),0,0,'L');     }              //print column titles for the current page     $pdf->SetFillColor(232,232,232);     $pdf->SetFontSize(14);     $pdf->SetY($y_axis_initial);     $pdf->Cell(15,6,iconv('UTF-8', 'TIS-620', 'ลำดับที่'),1,0,'C',1);     $pdf->Cell(25,6,iconv('UTF-8', 'TIS-620', 'รหัสนักศึกษา'),1,0,'C',1);     $pdf->Cell(105,6,iconv('UTF-8', 'TIS-620', 'ชื่อ-นามสกุลนักศึกษา'),1,0,'C',1);     $pdf->Cell(25,6,iconv('UTF-8', 'TIS-620', 'เกรด'),1,0,'C',1);              //Go to next row     $y_axis = $y_axis_initial + $row_height; }
  $y_axis = $y_axis + $row_height;
  $pdf->SetFont('AngsanaNew','B',14); $pdf->SetY($y_axis); $pdf->Cell(0,6,iconv('UTF-8', 'TIS-620', 'สรุปผลเกรด :'),0,0,'L');
  $y_axis = $y_axis + $row_height; $x_axis = $x_axis_initial;
  foreach ($rs2 as $key => $val) {     $pdf->SetFont('AngsanaNew','',14);     $pdf->SetY($y_axis);     $pdf->SetX($x_axis);     $pdf->Cell(5,6,$rs2[$key]['grdGrade'],0,0,'L');     $pdf->Cell(30,6,iconv('UTF-8', 'TIS-620', ': '.$rs2[$key]['cntStd'].' คน'),0,0,'L');          if ($x_axis > 140) {         $y_axis = $y_axis + $row_height;         $x_axis = $x_axis_initial;     } else {         $x_axis = $x_axis + 35;     } }
  $y_axis = $y_axis + (2 * $row_height);
  $pdf->SetY($y_axis); $pdf->Cell(60,6,iconv('UTF-8', 'TIS-620', 'ลงชื่อ............................................'),0,0,'C'); $pdf->Cell(50,6,iconv('UTF-8', 'TIS-620', 'ลงชื่อ............................................'),0,0,'C'); $pdf->Cell(0,6,iconv('UTF-8', 'TIS-620', 'ลงชื่อ............................................'),0,0,'C'); $pdf->Ln(7); $pdf->Cell(60,6,iconv('UTF-8', 'TIS-620', '('.$prsName.')'),0,0,'C'); $pdf->Cell(50,6,'(...........................................................)',0,0,'C'); $pdf->Cell(0,6,'(...........................................................)',0,0,'C'); $pdf->Ln(7); $pdf->Cell(60,6,iconv('UTF-8', 'TIS-620', 'อาจารย์ผู้รับผิดชอบส่งเกรด'),0,0,'C'); $pdf->Cell(50,6,'...........................................................',0,0,'C'); $pdf->Cell(0,6,'...........................................................',0,0,'C');
  //Create file $pdf->Output(); ?>
  |