<?

include("include/startup.php");

$id = $_REQUEST['po_id'];
$pdf_name = $_REQUEST['pdf_name'];
$pdf_name = $pdf_name.'-'.$id.'.pdf';


$frontEndURL = $config->frontEndURL;

$url = $frontEndURL."/admin/in_out_reports/index?page=view&hide_top=1&hide_left=1&create_pdf=1";
			
			
if(isset($_REQUEST['print_url'])){
	
	echo "<a target='_blank' href='$url'>$url</a>";
	die;
}
unlink("".ROOT_DIR_PATH."'in_outs_reports_pdf/".$pdf_name);
$file_path = ROOT_DIR_PATH."/in_outs_reports_pdf/".$pdf_name;
exec("/usr/local/bin/wkhtmltopdf '$url' '$file_path'");
sleep(1);

if(file_exists(ROOT_DIR_PATH."/in_outs_reports_pdf/$pdf_name")){	
	ob_clean();
	header("Location: $frontEndURL"."in_outs_reports_pdf/$pdf_name");
	exit;
}

?>