Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/php/
Upload File :
Current File : /var/www/cesa.co.za/php/calendarpdf.php

<?php
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);

session_start();
ob_start();

include_once('inc_db.php');
include_once($_SERVER['DOCUMENT_ROOT'] . '/cfg/pdf_css_config.php');  // Include the CSS configuration

$sThisURL = "/sce/school-of-consulting-engineers/cpd-training/training-calendar/";
$NumMonths = 6;
$pdf = 1;

if (isset($_REQUEST["NumMonths"]) && !empty($_REQUEST["NumMonths"])) {
	if ($_REQUEST["NumMonths"] == "yend") {
		$NumMonths = 13 - date("m");
	} else {
		$NumMonths = intval($_REQUEST["NumMonths"]);
	}
}
?>
<html>

<head>
	<style>
		<?php echo loadCSSForPDF(); ?>
		<?php 
		// Uncomment the line below if you need to debug CSS loading issues
		// echo debugCSSLoading(); 
		?>
	</style>
</head>

<body>
	<?php
	$_REQUEST["pdf"] = "1"; // Set PDF flag for calendar generation
	// include("inc_calendarnew.php");
	include("inc_scecalendarnew.php");
	?>
</body>

</html>
<?php
$content = ob_get_clean();

// Uncomment these lines for debugging
// echo $content;
// exit;

$content = str_replace("<img src='/images/spacer.gif' width=30'>", "&nbsp;", $content);
$error = null;

$inputhtmlfile = $_SERVER['DOCUMENT_ROOT'] . '/php/temp/calendar' . $_REQUEST["cat"] . $_REQUEST["NumMonths"] . '.html';
file_put_contents($inputhtmlfile, $content);
$filename = $_SERVER['DOCUMENT_ROOT'] . '/php/temp/calendar.pdf';
$process = 'wkhtmltopdf -B 10 -L 0 -R 0 -T 10 -O landscape --print-media-type ';
$process .= '--load-error-handling ignore -q "' . $inputhtmlfile . '" "' . $filename . '"';
exec($process, $error);

// echo $process . '<br />';
// var_dump($error);
// exit;

header("Location: https://www.cesa.co.za/php/temp/calendar.pdf?rand=" . rand());
?>