File: /home/kochikidswysewor/www/wp-content/themes/children-charity-child/print-invoice.php
<?php $path = preg_replace('/wp-content(?!.*wp-content).*/','',__DIR__);
include($path.'wp-load.php');
$child_id = $_GET['n'];
if( have_rows('sponsor_user_details',$child_id) ):
$user = wp_get_current_user();
$user_id = $user->ID;
$user_email = $user->user_email;
$i=1; while ( have_rows('sponsor_user_details',$child_id) ) : the_row();
$sponsors = get_sub_field('sponsors_');
$sponser_amount = get_sub_field('sponser_amount',$child_id);
$sponsor_date = get_sub_field('sponsor_date',$child_id);
$transaction_id = get_sub_field('transaction_id',$child_id);
$sponsored_child_name = get_the_title($child_id);
if($sponsors==$user_id){
$user_info = get_userdata($sponsors);
$sponsor_html ="";
$sponsor_html.='
<div style="width:670px; border:1px solid rgb(216, 216, 216); padding:15px;">
<div style="width:640px; height:auto; background-color:#cd366b; display:block; padding:15px;">
<div style="float:left"><img src="'.$_SERVER["DOCUMENT_ROOT"].'/wp-content/uploads/2019/12/Kochi-Kids.jpg" alt="Kochi Kids" style="width:100px; margin:0 0 10px;"></div>
<div style="color:#fff; font-family:Arial, Helvetica, sans-serif; font-size: 15px; font-weight:bold; text-align: center;padding: 5px;float: left; line-height: 1; width:540px; font-size: 20px; text-align:right;padding-top:50px">12345 67890</div>
<div style="clear:both"></div>
</div>
<h1 style="color:#333; font-family:Arial, Helvetica, sans-serif; font-size: 20px; font-weight:bold;" >Hi '. $user_info->display_name.',</h1>
<p style="color:#333; font-family:Arial, Helvetica, sans-serif; font-size: 16px;">Thank you for sponsoring a child.</p>
<h6 style="color:#cd366b; font-family:Arial, Helvetica, sans-serif; font-size: 16px; font-weight:bold; padding: 10px; padding-left: 0; margin-top: 0; margin-bottom: 0;">Transaction ID: '.$transaction_id.'</h6>
<table style="width:670px; border: 1px solid rgb(216, 216, 216); padding: 0;border-collapse: separate;
border-spacing:0px;">
<tbody>
<tr>
<td style="border-right:1px solid rgb(216, 216, 216); border-bottom: 1px solid rgb(216, 216, 216); color:#333; font-family:Arial, Helvetica, sans-serif; font-size: 14px; font-weight:bold; padding: 10px;" colspan="0">Name </td>
<td style="color:#333; font-family:Arial, Helvetica, sans-serif; font-size: 14px; font-weight:normal; border-bottom: 1px solid rgb(216, 216, 216); padding: 10px;">'.$sponsored_child_name.'</td>
</tr>
<tr>
<td style="border-right:1px solid rgb(216, 216, 216);color:#333; font-family:Arial, Helvetica, sans-serif; font-size: 14px; font-weight:bold; padding: 10px;">Sponsored Amount </td>
<td style="color:#333; font-family:Arial, Helvetica, sans-serif; font-size: 14px; font-weight:normal; padding: 10px;">'. $sponser_amount.'</td>
</tr>
</tbody>
</table>
</div>';
//echo $sponsor_html;
} $i++; endwhile; endif;
//----HTML TO PDF CONVERTER------//
ob_start();// Include autoloader
require_once 'dompdf/autoload.inc.php';
// Reference the Dompdf namespace
use Dompdf\Dompdf;
// Instantiate and use the dompdf class
$dompdf = new Dompdf();
// Load HTML content
$dompdf->loadHtml($sponsor_html);
// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'portrait');
// Render the HTML as PDF
$dompdf->render();
$rrr = $dompdf->stream("invoice.pdf", array("Attachment" => 1));
//----HTML TO PDF CONVERTER------//?>