<?php
// Include the FPDF library
require('../fpdf186/fpdf.php');
require_once '../models/db_connection.php';
if(isset($_GET['id'])){
    $selstudent = mysqli_query($conn,"SELECT * FROM students WHERE student_id = '$_GET[id]'");
    
}
$myData = mysqli_fetch_array($selstudent);
class PDF extends FPDF {
    function Footer() {
        // Position at 1.5 cm from bottom
        $this->SetY(-15);
        // Arial italic 8
        $this->SetFont('Arial','I',8);
        // Page number
        $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
    }
}

// Create PDF object
$pdf = new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
    // Add certificate image as background
    $pdf->Image('fomu.jpg', 0, 0, $pdf->GetPageWidth(), $pdf->GetPageHeight());
    
    if (file_exists("../uploads/".$myData['filename'])) {
    $pdf->Image("../uploads/".$myData['filename'], 160, 35, 35, 35);
    }
    else{
        $pdf->Image("no_image.jpg", 170, 43, 35, 35);
    }

// Page Header
$pdf->SetFont('Arial','',40);
// Student details
$pdf->SetFont('Arial','',12);
//$pdf->Cell(0,10,'Registration Number: REG-TRD/A.21/MWZ/2024/14',0,1);
$pdf->SetFont('Arial','',14);
$pdf->SetXY(84, 45);
$pdf->Cell(0,10,$myData['en_id'],0,1);
$pdf->SetFont('Arial','',10);
$pdf->SetXY(100, 74);
$pdf->Cell(0,10,$myData['fullname'],0,1);
$pdf->SetXY(90, 82);
$pdf->Cell(0,10,$myData['address']."  ".$myData['street'],0,1);
$pdf->SetXY(84, 90);
$pdf->Cell(0,10,$myData['phone_number'],0,1);
$pdf->SetXY(60, 98);
$pdf->Cell(0,10,$myData['age'],0,1);
//$pdf->Cell(0,10,'Identification Number: 0002',0,1);
// $pdf->SetXY(150, 88);
// $pdf->Cell(0,10,$myData['street'],0,1);

// $pdf->SetXY(64, 102);
// $pdf->Cell(0,10,$myData['ident_number'],0,1);
// $pdf->SetXY(120, 94);
// $pdf->Cell(0,10,$myData['work'],0,1);
// $pdf->SetXY(160, 94);
// $pdf->Cell(0,10,$myData['education'],0,1);
// $pdf->SetXY(132, 102);
//$pdf->Cell(0,10,'O',0,1);

//$pdf->Cell(0,10,'Eye Problems: Yes',0,1);
//$pdf->Cell(0,10,'Ear Problems: Yes',0,1);
//$pdf->Cell(0,10,'Sensitive Case: No',0,1);
// Add image
// $pdf->Image('certificate_template.jpg',10,100,60);

// Output PDF
$pdf->Output();
?>
