mirror of
https://github.com/Alvin-Zilverstand/Spik-en-span.git
synced 2026-03-06 11:17:09 +01:00
Add font generation utility and TrueType font parser
- Introduced `makefont.php` for generating font definition files from TrueType and Type1 fonts. - Implemented `ttfparser.php` to parse and subset TrueType fonts, handling various font tables and properties. - Added functions for loading font maps, extracting font information, and creating font descriptor arrays. - Included error handling and messaging for better user feedback during font processing. - Enabled command-line usage for font file generation with options for encoding, embedding, and subsetting.
This commit is contained in:
@@ -32,9 +32,9 @@ $categoryType = strtolower($categoryType) === 'volwassenen' ? 'volwassen' : 'kin
|
||||
require __DIR__ . '/../phpmailer/src/PHPMailer.php';
|
||||
require __DIR__ . '/../phpmailer/src/SMTP.php';
|
||||
require __DIR__ . '/../phpmailer/src/Exception.php';
|
||||
require_once __DIR__ . '/../fpdf/fpdf.php'; // Ensure FPDF is included only once
|
||||
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
|
||||
// Prepare SQL statement
|
||||
$sql = "INSERT INTO tickets (ticket_id, name, email, category, day, quantity, qr_code_link) VALUES (?, ?, ?, ?, ?, ?, ?)";
|
||||
@@ -44,7 +44,7 @@ if (!$stmt) {
|
||||
die("Error preparing statement: " . $conn->error);
|
||||
}
|
||||
|
||||
$qrCodes = []; // Array to store QR code URLs for email attachment
|
||||
$qrCodes = []; // Array to store QR code URLs for PDF attachment
|
||||
|
||||
// Insert one ticket per row and generate QR codes
|
||||
for ($i = 0; $i < $quantity; $i++) {
|
||||
@@ -59,13 +59,66 @@ for ($i = 0; $i < $quantity; $i++) {
|
||||
exit();
|
||||
}
|
||||
|
||||
$qrCodes[] = $qrCodeUrl; // Store QR code URL for email
|
||||
$qrCodes[] = ['ticket_id' => $ticket_id, 'qr_code_url' => $qrCodeUrl]; // Store QR code details for PDF
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
|
||||
// Send confirmation email with QR codes
|
||||
// Generate individual PDFs for each QR code
|
||||
$pdfPaths = []; // Array to store paths of generated PDFs
|
||||
foreach ($qrCodes as $index => $qrCode) {
|
||||
$pdf = new FPDF();
|
||||
$pdf->AddPage();
|
||||
|
||||
// Add a header with background color
|
||||
$pdf->SetFillColor(40, 167, 69); // Green background
|
||||
$pdf->SetTextColor(255, 255, 255); // White text
|
||||
$pdf->SetFont('Arial', 'B', 20);
|
||||
$pdf->Cell(0, 15, 'Spik & Span - Ticket Bevestiging', 0, 1, 'C', true);
|
||||
$pdf->Ln(10);
|
||||
|
||||
// Add customer details section with a light gray background
|
||||
$pdf->SetFillColor(240, 240, 240); // Light gray background
|
||||
$pdf->SetTextColor(0, 0, 0); // Black text
|
||||
$pdf->SetFont('Arial', '', 12);
|
||||
$pdf->Cell(0, 10, 'Naam: ' . $name, 0, 1, 'L', true);
|
||||
$pdf->Cell(0, 10, 'E-mail: ' . $email, 0, 1, 'L', true);
|
||||
$pdf->Ln(10);
|
||||
|
||||
// Add ticket details
|
||||
$pdf->SetFont('Arial', '', 12);
|
||||
$pdf->SetTextColor(0, 0, 0); // Black text
|
||||
$pdf->Cell(0, 10, 'Ticket ' . ($index + 1) . ':', 0, 1, 'L');
|
||||
$pdf->Cell(0, 10, 'Ticket ID: ' . $qrCode['ticket_id'], 0, 1, 'L');
|
||||
$pdf->Ln(5);
|
||||
|
||||
// Add QR code image centered
|
||||
$qrCodeImage = file_get_contents($qrCode['qr_code_url']);
|
||||
$qrCodePath = __DIR__ . "/temp_qr_$index.png";
|
||||
file_put_contents($qrCodePath, $qrCodeImage);
|
||||
$pdf->Cell(0, 0, '', 0, 1, 'C'); // Move to the center
|
||||
$pdf->Image($qrCodePath, ($pdf->GetPageWidth() - 50) / 2, $pdf->GetY(), 50, 50); // Center the QR code
|
||||
$pdf->Ln(60);
|
||||
|
||||
// Clean up temporary QR code image
|
||||
unlink($qrCodePath);
|
||||
|
||||
// Add a footer with a green background
|
||||
$pdf->SetY(-30);
|
||||
$pdf->SetFillColor(40, 167, 69); // Green background
|
||||
$pdf->SetTextColor(255, 255, 255); // White text
|
||||
$pdf->SetFont('Arial', 'I', 10);
|
||||
$pdf->Cell(0, 10, 'Bedankt voor uw bestelling bij Spik & Span!', 0, 1, 'C', true);
|
||||
$pdf->Cell(0, 10, 'Voor vragen kunt u contact opnemen via onze website.', 0, 1, 'C', true);
|
||||
|
||||
// Save PDF to a temporary file
|
||||
$pdfPath = __DIR__ . "/ticket_$index.pdf";
|
||||
$pdf->Output('F', $pdfPath);
|
||||
$pdfPaths[] = $pdfPath; // Store the path of the generated PDF
|
||||
}
|
||||
|
||||
// Send confirmation email with all PDF attachments
|
||||
$mail = new PHPMailer(true);
|
||||
|
||||
try {
|
||||
@@ -82,51 +135,26 @@ try {
|
||||
|
||||
$mail->isHTML(true);
|
||||
$mail->Subject = 'Bevestiging van je bestelling';
|
||||
|
||||
// Build the email body with inline styles
|
||||
$mail->Body = '
|
||||
<div style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto; padding: 20px; border: 1px solid #ddd; border-radius: 10px; background-color: #f9f9f9;">
|
||||
<h1 style="color: #28a745; text-align: center;">Bedankt voor je bestelling!</h1>
|
||||
<p style="font-size: 16px; color: #333;">Beste ' . htmlspecialchars($name) . ',</p>
|
||||
<p style="font-size: 16px; color: #333;">We hebben je bestelling succesvol ontvangen. Hieronder vind je de details van je bestelling:</p>
|
||||
<table style="width: 100%; border-collapse: collapse; margin: 20px 0;">
|
||||
<tr>
|
||||
<td style="padding: 10px; border: 1px solid #ddd;"><strong>Naam:</strong></td>
|
||||
<td style="padding: 10px; border: 1px solid #ddd;">' . htmlspecialchars($name) . '</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding: 10px; border: 1px solid #ddd;"><strong>E-mail:</strong></td>
|
||||
<td style="padding: 10px; border: 1px solid #ddd;">' . htmlspecialchars($email) . '</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding: 10px; border: 1px solid #ddd;"><strong>Categorie:</strong></td>
|
||||
<td style="padding: 10px; border: 1px solid #ddd;">' . htmlspecialchars($category) . '</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding: 10px; border: 1px solid #ddd;"><strong>Aantal Tickets:</strong></td>
|
||||
<td style="padding: 10px; border: 1px solid #ddd;">' . $quantity . '</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p style="font-size: 16px; color: #333;">Hieronder vind je de QR-codes voor je tickets:</p>
|
||||
<div style="text-align: center;">';
|
||||
|
||||
// Add QR codes to the email body
|
||||
foreach ($qrCodes as $index => $qrCodeUrl) {
|
||||
$mail->Body .= '
|
||||
<div style="margin-bottom: 20px;">
|
||||
<p style="font-size: 16px; color: #333;"><strong>Ticket ' . ($index + 1) . ':</strong></p>
|
||||
<img src="' . $qrCodeUrl . '" alt="QR Code" style="width: 150px; height: 150px; border: 1px solid #ddd; border-radius: 10px;">
|
||||
</div>';
|
||||
}
|
||||
|
||||
$mail->Body .= '
|
||||
</div>
|
||||
<p style="font-size: 16px; color: #333;">We wensen je veel plezier tijdens het evenement!</p>
|
||||
<p style="font-size: 16px; color: #333;">We hebben je bestelling succesvol ontvangen. Je tickets zijn bijgevoegd in de PDF-bestanden.</p>
|
||||
<p style="font-size: 16px; color: #333;">Met vriendelijke groet,<br><strong>Spik & Span</strong></p>
|
||||
</div>';
|
||||
|
||||
// Attach each PDF to the email
|
||||
foreach ($pdfPaths as $pdfPath) {
|
||||
$mail->addAttachment($pdfPath);
|
||||
}
|
||||
|
||||
$mail->send();
|
||||
|
||||
// Clean up temporary PDF files
|
||||
foreach ($pdfPaths as $pdfPath) {
|
||||
unlink($pdfPath);
|
||||
}
|
||||
|
||||
// Redirect to the order completion page
|
||||
header("Location: ../order-complete.html");
|
||||
exit();
|
||||
|
||||
Reference in New Issue
Block a user