<?php
require_once 'config/db.php';
require_once 'services/MessageService.php';

$msgService = new MessageService($conn);
$tplOptions = [
    'pos_x' => 50,
    'pos_y' => 90,
    'font_size' => 20,
    'font_color' => '#000000'
];

$outputPath = 'uploads/temp_pdfs/test_' . time() . '.pdf';
// I need a valid image_path. Let's see what is inside uploads/templates/
$bgImage = 'uploads/templates/test.jpg'; // just a placeholder, I'll check first what exists.

// Let's create a dummy image first to ensure it exists
$im = imagecreatetruecolor(800, 600);
imagefill($im, 0, 0, imagecolorallocate($im, 255, 255, 255));
imagejpeg($im, $bgImage);
imagedestroy($im);

$res = $msgService->generateBirthdayPdf($bgImage, 'Test Contact', $outputPath, $tplOptions);

var_dump($res);
if(file_exists($outputPath)){
    echo "PDF Created: " . $outputPath . "\n";
} else {
    echo "PDF Failed to create\n";
}
