Path : /var/www/html/main/ap/register/
File Upload :
Current File : /var/www/html/main/ap/register/certificate.php

<?php
/*!
 * Copyright Anucha Puangpaka
 * Contacts anucha.ppk@icloud.com 062-479-9836
 */

session_start();
error_reporting(E_ALL);
ini_set("display_errors", 0);
ini_set('memory_limit','512M');

include('../../config.php');

if(empty($_SESSION['xcode']) && empty($_GET['id'])){
  echo "<p>Anucha Puangpaka 062-4799-836 มหาวิทยาลัยราชภัฏกำแพงเพชร</p>";
}else{
  if($_GET['nu']==""){
    $head = "";

    $foot = "";

    $sql = "select * from ap_products where code='$_GET[xcode]'";
    $query = mysqli_query($conn,$sql);
    $rows = mysqli_fetch_array($query);

    $sql2 = "select * from ap_register where code='$_GET[xcode]' and id='$_GET[id]'";
    $query2 = mysqli_query($conn,$sql2);
    $num_rows2 = mysqli_num_rows($query2);
    $rows2 = mysqli_fetch_array($query2);
    
    $html = "<table width='100%' bgcolor='#ffffff'>
    <tr>
      <td colspan='2' align='center' height='25'></td>
    </tr>
    <tr>
      <td class='font-certificate3'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$rows[certificateCode]</td>
      <td class='font-certificate3' align='right'>KPRU ARIT ".(date(Y)+543)."/$_GET[id]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
    </tr>
    <tr>
      <td colspan='2' height='200'></td>
    </tr>
    <tr>
      <td colspan='2' align='center' class='font-certificate'>$rows2[f1002]</td>
    </tr>
    </table>";

    require_once('../../mpdf/mpdf.php');
    $pdf = new mPDF('th', 'A5-L', '0', '', 0, 0, 0, 0);
    $pdf->mirrorMargins = 1;
    $pdf->SetDisplayMode('fullwidth');
    $stylesheet = file_get_contents('style.css');
    $pdf->WriteHTML($stylesheet,1);
    $pdf->SetHTMLHeader($head);
    $pdf->SetHTMLHeader($head,'E');
    $pdf->SetHTMLFooter($foot);
    $pdf->SetHTMLFooter($foot,'E');

    $pdf->SetWatermarkImage('images/certificate3.png');
    $pdf->showWatermarkImage = true;
    $pdf->watermarkImageAlpha = 1.0;

    $pdf->SetTitle("Certificate");
    $pdf->SetAuthor("KPRU ARIT");
    $pdf->SetCreator("Anucha Puangpaka");
    $pdf->SetSubject("$rows[name]");
    $pdf->SetKeywords("$rows[name]");
    $pdf->WriteHTML($html, 2);
    $pdf->Output("certificate/$_GET[xcode]-".date('YmdHis').".pdf");
    $pdf->Output();
    exit;
  }
}

include('logs.php');

mysqli_close($conn);
?>