require_once 'config.php';
require_once './backend/lib.class.php';
require_once './pdf/autoload.inc.php';
use Dompdf\Dompdf;
ob_start();
/* ---------- GET PAPER ID ---------- */
if (isset($_GET['member']) && $_GET['member'] != '') {
$paperId = intval($_GET['member']);
} else {
// fallback to slug from URL
$slug = basename(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
$sqlSlug = "
SELECT ID
FROM paper_form
WHERE STATUS IN (
'Paper Published and It is accessible online on our website.',
'Publication Fee Received'
)
AND PAPER_SLUG = '".$conn->real_escape_string($slug)."'
LIMIT 1
";
$resSlug = $conn->query($sqlSlug);
if ($resSlug && $resSlug->num_rows > 0) {
$rowSlug = $resSlug->fetch_assoc();
$paperId = $rowSlug['ID'];
} else {
die('Invalid request');
}
}
$paperId = intval($_GET["member"]);
/* ---------------- FETCH PAPER ---------------- */
$sql1 = "SELECT * FROM paper_form WHERE ID='$paperId'";
$result1 = $conn->query($sql1);
if (!$result1 || $result1->num_rows == 0) {
die("Paper not found");
}
$rows1 = $result1->fetch_assoc();
/* ---------------- FETCH VOLUME ---------------- */
$sql2 = "SELECT * FROM call_paper WHERE ENABLED='Y' AND ID='".$rows1["VOLUME"]."'";
$result2 = $conn->query($sql2);
if (!$result2 || $result2->num_rows == 0) {
die("Volume not found");
}
$rows2 = $result2->fetch_assoc();
/* ---------------- IMAGE PATH ---------------- */
$bgImage = realpath(__DIR__ . '/images/certificate1.jpg');
/* ---------------- HTML ---------------- */
$html = "
";
/* ---------------- GENERATE CERTIFICATES ---------------- */
for ($i = 1; $i <= 8; $i++) {
$fname = $rows1["A{$i}FNAME"] ?? '';
$lname = $rows1["A{$i}LNAME"] ?? '';
if ($fname == '' || $fname == 'First Name') continue;
$title = htmlspecialchars($rows1["PNAME"]);
if (strlen($title) > 200) {
$titleClass = 'small';
} elseif (strlen($title) > 150) {
$titleClass = 'medium';
} else {
$titleClass = '';
}
$html .= "
It is hereby certified that the paper ID : IJRASET{$rows1['ID']}, entitled
{$title}
by
{$fname} {$lname}
after review is found suitable and has been published in
{$rows2['VNAME']}, {$rows2['ISSUE']}, {$rows2['MONTH']}
International Journal for Research in Applied Science &
Engineering Technology
(International Peer Reviewed and Refereed Journal)
Good luck for your future endeavors
";
}
$html .= "";
/* ---------------- RENDER PDF ---------------- */
ob_end_clean();
$dompdf = new Dompdf();
$dompdf->loadHtml($html);
$dompdf->setPaper([0, 0, 1100, 790], 'landscape');
$dompdf->render();
$dompdf->stream("IJRASET{$rows1['ID']}.pdf", ["Attachment" => false]);
exit;