add test batches
This commit is contained in:
@@ -7,13 +7,12 @@ namespace App\Services\Certificates;
|
||||
class CertificatePdfService
|
||||
{
|
||||
private string $fontDir;
|
||||
|
||||
private string $imgDir;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->fontDir = public_path('assets/certificates/fonts').DIRECTORY_SEPARATOR;
|
||||
$this->imgDir = public_path('assets/certificates/images').DIRECTORY_SEPARATOR;
|
||||
$this->fontDir = public_path('assets/certificates/fonts') . DIRECTORY_SEPARATOR;
|
||||
$this->imgDir = public_path('assets/certificates/images') . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -21,9 +20,9 @@ class CertificatePdfService
|
||||
*/
|
||||
public function generate(array $students, string $certDate): string
|
||||
{
|
||||
$edwardianFont = \TCPDF_FONTS::addTTFfont($this->fontDir.'Edwardian Script ITC Regular.ttf', 'TrueTypeUnicode', '', 32);
|
||||
$garamondBold = \TCPDF_FONTS::addTTFfont($this->fontDir.'Garamond Bold.ttf', 'TrueTypeUnicode', '', 32);
|
||||
$ebGaramond = \TCPDF_FONTS::addTTFfont($this->fontDir.'EBGaramond-Regular.ttf', 'TrueTypeUnicode', '', 32);
|
||||
$edwardianFont = \TCPDF_FONTS::addTTFfont($this->fontDir . 'Edwardian Script ITC Regular.ttf', 'TrueTypeUnicode', '', 32);
|
||||
$garamondBold = \TCPDF_FONTS::addTTFfont($this->fontDir . 'Garamond Bold.ttf', 'TrueTypeUnicode', '', 32);
|
||||
$ebGaramond = \TCPDF_FONTS::addTTFfont($this->fontDir . 'EBGaramond-Regular.ttf', 'TrueTypeUnicode', '', 32);
|
||||
|
||||
$pdf = new \TCPDF('L', 'pt', 'A4', true, 'UTF-8', false);
|
||||
$pdf->SetCreator('Al Rahma Sunday School');
|
||||
@@ -40,7 +39,7 @@ class CertificatePdfService
|
||||
|
||||
foreach ($students as $student) {
|
||||
$pdf->AddPage();
|
||||
$name = $student['firstname'].' '.$student['lastname'];
|
||||
$name = $student['firstname'] . ' ' . $student['lastname'];
|
||||
$grade = $this->formatGrade((string) ($student['grade'] ?? ''));
|
||||
$certNumber = (string) ($student['cert_number'] ?? '');
|
||||
$verifyUrl = is_string($student['verify_url'] ?? null) ? $student['verify_url'] : null;
|
||||
@@ -65,8 +64,8 @@ class CertificatePdfService
|
||||
|
||||
private function drawCertificate(
|
||||
\TCPDF $pdf,
|
||||
float $W,
|
||||
float $H,
|
||||
float $W,
|
||||
float $H,
|
||||
string $name,
|
||||
string $grade,
|
||||
string $certDate,
|
||||
@@ -76,9 +75,9 @@ class CertificatePdfService
|
||||
string $garamondBold,
|
||||
string $ebGaramond
|
||||
): void {
|
||||
$pdf->Image($this->imgDir.'title.png', 126, 0, 600);
|
||||
$pdf->Image($this->imgDir.'background.png', 280, 176, 291, 340);
|
||||
$pdf->Image($this->imgDir.'signature.png', 140, 410, 90, 80);
|
||||
$pdf->Image($this->imgDir . 'title.png', 126, 0, 600);
|
||||
$pdf->Image($this->imgDir . 'background.png', 280, 176, 291, 340);
|
||||
$pdf->Image($this->imgDir . 'signature.png', 140, 410, 90, 80);
|
||||
|
||||
$pdf->SetFont('times', 'B', 24);
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
@@ -136,7 +135,7 @@ class CertificatePdfService
|
||||
$pdf->SetFont('helvetica', '', 8);
|
||||
$pdf->SetTextColor(150, 150, 150);
|
||||
$pdf->SetXY(70.86, $H - 39.68);
|
||||
$pdf->Cell(200, 12, 'Certificate No. '.$certNumber, 0, 0, 'L');
|
||||
$pdf->Cell(200, 12, 'Certificate No. ' . $certNumber, 0, 0, 'L');
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
}
|
||||
}
|
||||
@@ -162,7 +161,7 @@ class CertificatePdfService
|
||||
$lower = strtolower($clean);
|
||||
|
||||
if (preg_match('/^\d+$/', $clean) && (int) $clean >= 1 && (int) $clean <= 9) {
|
||||
return 'Grade '.$clean;
|
||||
return 'Grade ' . $clean;
|
||||
}
|
||||
if ($lower === 'youth') {
|
||||
return 'Youth';
|
||||
|
||||
Reference in New Issue
Block a user