| Server IP : 172.67.187.206 / Your IP : 172.71.28.155 Web Server : Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30 System : Windows NT WIN-ECQAAA40806 6.2 build 9200 (Windows Server 2012 Standard Edition) i586 User : SYSTEM ( 0) PHP Version : 5.6.30 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : E:/Inetpub/www/news/datacenter/admin/report/ |
Upload File : |
<?php
require_once("setPDF.php"); // ไฟล์สำหรับกำหนดรายละเอียด pdf
require_once('../config.php');
// เพิ่มหน้าใน PDF
/*
$code = $mysqli->escape_string($_GET['stucode']);
$SQLy = $mysqli->query("SELECT * FROM history WHERE stucode ='$code'");
$Rowy = mysqli_fetch_array($SQLy);
$stu=$Rowy['stucode'];
*/
$pdf->SetTitle('รายงาน PDF'); //Titlo del pdf
$pdf->setPrintHeader(false); //หัวกระดาษ
$pdf->setPrintFooter(true); //No se imprime pie de pagina
$pdf->SetMargins(18, 16, 15, false); //ตั้งค่าระยะห่างจากหัวกระดาษ
$pdf->SetAutoPageBreak(true, 20); //Se define un salto de pagina con un limite de pie de pagina
$pdf->AddPage();
// กำหนด HTML code หรือรับค่าจากตัวแปรที่ส่งมา
// กรณีกำหนดโดยตรง
// ตัวอย่าง กรณีรับจากตัวแปร
// $htmlcontent =$_POST['HTMLcode'];
//$htmlcontent='<p>ทดสอบการแปลงไฟล์</p>';
$htmlcontent=stripslashes($htmlcontent);
$htmlcontent=AdjustHTML($htmlcontent);
$idcard=$_GET['idcard'];
$SQL = $mysqli->query("SELECT * FROM users WHERE `username`='$idcard'");
$Row = mysqli_fetch_array($SQL);
$uid = $Row['username'];
$sesao = $Row['name'];
// สร้างเนื้อหาจาก HTML code
$tbl1 = <<<EOD
รายชื่อโรงเรียน
EOD;
$tbl2 = <<<EOD
สังกัด$sesao
EOD;
$html = '<table width="600" style="border:1px solid;">
<thead>
<tr>
<th style=" width:35px;" align="center"><b>ที่</b></th>
<th style=" width:80px;" align="center"><b>รหัส</b></th>
<th style=" width:300px;" align="center"><b>ชื่อโรงเรียน</b></th>
<th style=" width:80px;" align="center"><b></b></th>
</tr></thead><tbody>';
$sql2 = "SELECT * FROM users where `gset`='$idcard'";
$dbquery2 = $mysqli->query($sql2);
$i = 0;
while($row2=mysqli_fetch_array($dbquery2)) {
$username=$row2['username'];
$name=$row2['name'];
$u="";
$i++;
$html .= '<tr>';
$html .= '<td style="width:35px;" align="center">'.$i.'</td>';
$html .= '<td style="width:80px;" align="center">'.$username.'</td>';
$html .= '<td style="width:300px;" align="left"> '.$name.'</td>';
$html .= '<td style="width:80px;" align="center">'.$u.'</td>';
$html .= '</tr>';
}
$html .= '</tbody></table>';
// เลื่อน pointer ไปหน้าสุดท้าย
$pdf->Ln(-3);
$pdf->SetFont('th-sarabun','b',20);
$pdf->Cell(0, 0, $tbl1, 0, 0, 'C');
$pdf->Ln(10);
$pdf->SetFont('th-sarabun','b',18);
$pdf->Cell(0, 0, $tbl2, 0, 0, 'C');
$pdf->Ln(15);
$pdf->SetFont('','',15,'','','L');
$pdf->writeHTML($html, true, 0, true, 0);
$pdf->lastPage();
// ปิดและสร้างเอกสาร PDF
ob_end_clean();
$today = date("dmY");
$pdf->Output('sesao-Report'.$today.'.pdf', 'I');
?>