File "pdf.php"
Full path: /home/andyrdhboardrevi/public_html/.cp__/pdf.php
File size: 5.26 KiB (5385 bytes)
MIME-type: text/x-php
Charset: utf-8
Download Open Edit Advanced Edit Back
<?php
set_time_limit(0);
if($_REQUEST['cecource'] == 2)
{$usrTable = "dha_registered_user_ce";}
else
{$usrTable = "dha_registered_user";}
include ('php/database.php');
$db = new db;
function get_User_Meta_Cust($metaKey, $userID = 0){
global $db;
$data = $db->query("SELECT * FROM dha_user_metadata where user_id='".$userID."' and meta_key='".$metaKey."'");
$row = mysqli_fetch_assoc($data[0]);
return $row['meta_value'];
}
ob_start();
// get fields and order
$fields1 = trim($_POST['order'],',');
$order = explode(',',$fields1);
// build sql statement
$sql_search = '';
$sql_sort = '';
foreach($order as $f) {
if($f=="gradMonth" || $f == "gradYear" || $f == "boardMonth"){
break;
}
if($f == "DhaPinNumber")
$f = "DhsPinNumber";
$fields .= $f." ,";
// search
if($_POST[$f] != '')
$sql_search .= " $f like '%".$_POST[$f]."%' ,";
// sort
if($_POST['_'.$f] != 'none')
$sql_sort = $f." ,";
}
$fields = trim($fields,',');
$dateFYear = $_POST['dispyear'] ;
$dateNYear = $dateFYear + 1;
$date1 = $dateFYear.'-04-01' ;
$date2 = $dateNYear.'-04-01' ;
// limit
if ($_POST['numbers'] == 'limit')
$limit = " LIMIT ".$_POST['num'];
else
$limit = '';
// check for sort and search
if ($sql_search != '')
{
$sql_search = ' WHERE '.trim($sql_search,',');
$sql_search .= " and date between '$date1' and '$date2'";
}
else
{
$sql_search = " WHERE date between '$date1' and '$date2'";
}
if ($sql_sort != '')
$sql_sort = ' ORDER BY '.trim($sql_sort,',');
// execute
$data = $db->query("SELECT $fields FROM ".$usrTable." $sql_search $sql_sort");
$dataTwilio = $db->query("SELECT * FROM dha_twilio_numbers order by numID");
while ($row = mysqli_fetch_assoc($dataTwilio[0])) {
$twilioARR[$row['numID']] = $row['twilioNum'];
}
?>
<?php
// cost related values
$total = 0;
$iscost = false;
$width = 0;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $_POST['title']; ?></title>
</head>
<body>
<H2 ><?php echo $_POST['title']; ?></H2>
<table border="1" cellspacing="0" cellpadding="0" >
<tr>
<?php foreach ($order as $f){ ?>
<TD bgcolor="#D5D8DC" c align="center" width="<?php echo $_POST[$f."_size"]; ?>"><b> <?php echo ucfirst($f); ?></b></TD>
<?php
$width += $_POST[$f."_size"] +1;
}
?>
</tr>
<?php while ($row = mysqli_fetch_assoc($data[0])) { ?>
<tr>
<?php foreach ($order as $f){ ?>
<td class="data"><?php
if($f == "DhaPinNumber")
$f = "DhsPinNumber";
if ($f == 'cost') {
echo '$'.number_format($row[$f],2);
$iscost = true;
$total += $row[$f];
}
else if ($f == 'status'){
if ($row[$f] == 1)
echo 'Registered';
else
echo 'Unregistered';
}
else if ($f == 'texttimezone') {
if($row[$f] == 'America/Chicago')
echo "Central";
else if($row[$f] == 'America/Denver')
echo "Mountain";
else if($row[$f] == 'America/Los_Angeles')
echo "Pacific";
else if($row[$f] == 'America/Anchorage')
echo "Alaska";
else if($row[$f] == 'America/Adak')
echo "Hawaii";
else if($row[$f] == 'America/New_York')
echo "Eastern";
else
echo "";
}
else if ($f == 'textPhone'){
echo $twilioARR[$row[$f]];
}
else if ($f == 'date'){
echo date("n/j/Y", strtotime($row[$f]));
}
else if ($f == 'gradMonth'){
echo get_User_Meta_Cust("USER_GRAD_MONTH",$row['name_id'] );
}
else if ($f == 'gradYear'){
echo get_User_Meta_Cust("USER_GRAD_YEAR",$row['name_id'] );
}
else if ($f == 'boardMonth'){
echo get_User_Meta_Cust("USER_BOARD_MONTH",$row['name_id'] );
}
else
echo ucfirst($row[$f])." ";
?></td>
<?php } ?>
</tr>
<?php } ?>
</table>
<br />
<div style="padding-left:20px; background-color:#E5E7E9">
<?php if ($iscost) echo "Total Cost : $".number_format($total,2); ?>
</div>
<br /><br /><br />
<?php echo ucfirst($_POST['title']).' @ '.$_POST['time']; ?>
<span>
</span>
<style>
.box {width:<?php echo $width; ?>px;}
</style>
</body>
</html>
<?php
// generate pdf file if requested
$output = ob_get_contents();
ob_end_clean();
require_once("dompdf/dompdf_config.inc.php");
$dompdf = new Dompdf();
$dompdf->load_html($output);
// (Optional) Setup the paper size and orientation
$dompdf->set_paper($_POST['format'],$_POST['orientation']);
// Render the HTML as PDF
$dompdf->render();
// Output the generated PDF to Browser
//$output = $dompdf->output();
$dompdf->stream();
// echo $output;
header('Pragma: public'); // required
header('Expires: 0'); // no cache
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header("Content-Type: application/pdf");
header('Content-Transfer-Encoding: binary');
// It will be called downloaded.pdf
header("Content-Disposition:inline;filename=".str_replace(" ","_",$_POST['title'])."");
ob_flush();
// file_put_contents($filename, $output);
exit;
//$pdf = new HTML2FPDF();
/*
$pdf = new HTML2FPDF('l','mm',$_POST['format']);
$pdf->AddPage($_POST['orientation']);
$pdf->pgwidth = 1000;
$pdf->WriteHTML($output);
header('Content-type: application/pdf');
header("Content-Disposition: $attachment; filename=\"".str_replace(" ","_",$_POST['title'])."\"");
$pdf->Output('doc.pdf','I');
*/
?>