<?php
include_once '../WebBuilder/fpdf.php';
include_once "../WebBuilder/main.class.php";

$db = new DBMain();
$res = $db->exec_query("certificates", ['*'], '', '', '', '', "record_id = {$_GET['record_id']}");
$data = $res->fetch_assoc();

// employee details 
$employee_res = $db->exec_query("client_employees", ['*'], '', '', '', '', "record_id = {$data['client_employees_id']}");
$employee_data = $employee_res->fetch_assoc();

// course details 
$course_res = $db->exec_query("courses", ['*'], '', '', '', '', "record_id = {$data['courses_id']}");
$course_data = $course_res->fetch_assoc();


$pdf = new FPDF();
$pdf->AliasNbPages();
$pdf->AddPage('P');


$pdf->Image('certificate_side_lines.png', 170, 10, 35);
$pdf->SetFont('Arial', 'B', 30);
$pdf->cell(15);
$pdf->Cell(115, 18, "", 0, 1, 'L');
$pdf->Cell(80, 15, "SAFETY TRAINING", 0, 1, 'L');
$pdf->Cell(80, 15, "PRACTITIONERS (Pty)Ltd", 0, 1, 'L');
$pdf->SetFont('Arial', '', 15);
$pdf->Cell(80, 15, "This is to certifiy that", 0, 1, 'L');
$pdf->SetFont('Arial', 'B', 25);
$pdf->MultiCell(80, 15, $employee_data['client_employees_name'] . ' ' . $employee_data['surname'], 0, 'L');
$pdf->Cell(80, 15, "ID: ".$employee_data['i_doc_passport'], 0, 1, 'L');
$pdf->SetFont('Arial', '', 15);
$pdf->MultiCell(80, 8, "", 0, 'L');
$pdf->MultiCell(80, 8, "has successfully completed the requirements for the course in", 0, 'L');
$pdf->SetFont('Arial', 'B', 25);

$pdf->MultiCell(100, 8, "", 0, 'L');
$pdf->MultiCell(100, 10, $course_data['courses_name'], 0, 'L');

$pdf->Output("I");
