Ok I tried the cache but it didn't work so I am guessing that I am not putting it in the right place. so here is the code for one report. Where would I put it?
Code: Select all
<?php
//connect to existing session
//if no existing session, send user to login page
include "verify.inc";
?>
<HTML>
<HEAD>
<TITLE>Recent Batches</TITLE>
<link rel="stylesheet" type="text/css" href="topstyle.css" />
<link rel="stylesheet" type="text/css" media="print" href="printstyle.css" />
</HEAD>
<BODY>
<div class="content">
<?php
//Generate billet type list for subtitle
if (count($_REQUESTї'billet_type_cboxes']) > 0) {
$billet_type_list = "Billet Type";
$billet_type_list .= (count($_REQUESTї'billet_type_cboxes']) > 1) ? "s: " : ": ";
foreach ($_REQUESTї'billet_type_cboxes'] as $billet_type) {
$billet_type_list .= $billet_type.", ";
}
$billet_type_list = substr($billet_type_list, 0, strlen($billet_type_list)-2);
}
else {
$billet_type_list = "All Billet Types";
}
//Generate bead type list for subtitle
if (count($_REQUESTї'bead_type_cboxes']) > 0) {
$bead_type_list = "Bead Type";
$bead_type_list .= (count($_REQUESTї'bead_type_cboxes']) > 1) ? "s: " : ": ";
foreach($_REQUESTї'bead_type_cboxes'] as $bead_type) {
$bead_type_list .= $bead_type.", ";
}
$bead_type_list = substr($bead_type_list, 0, strlen($bead_type_list)-2);
}
else {
$bead_type_list = "All Bead Types";
}
//Set report title and subtitle
$title = "Recent Batches";
$startdate = strtotime($_REQUESTї'StartDateMonth']." ".$_REQUESTї'StartDateDay'].", ".$_REQUESTї'StartDateYear']);
$enddate = strtotime($_REQUESTї'EndDateMonth']." ".$_REQUESTї'EndDateDay'].", ".$_REQUESTї'EndDateYear']);
$subtitle = date("F j, Y", $startdate) . " - " . date("F j, Y", $enddate);
$subtitle .= "<br>".$billet_type_list;
$subtitle .= "<br>".$bead_type_list;
//Add one day to end date
$enddate = mktime (date('H',$enddate),date('i',$enddate),date('s',$enddate),date('n',$enddate),date('j',$enddate)+1,date('Y',$enddate));
//Show header graphic and report title
include "header.inc";
//Connect to server specified in include file and database specified by session variable
include "connect.inc";
//Build billet type criteria
if (count($_REQUESTї'billet_type_cboxes']) > 0) {
foreach ($_REQUESTї'billet_type_cboxes'] as $billet_type) {
$billet_type_crit .= "fldMoldBilletType = '".$billet_type."' OR ";
}
$billet_type_crit = "(".substr($billet_type_crit, 0, strlen($billet_type_crit)-4).")";
}
else {
$billet_type_crit = "(1=1)";
}
//Build bead type criteria
if (count($_REQUESTї'bead_type_cboxes']) > 0) {
foreach ($_REQUESTї'bead_type_cboxes'] as $bead_type) {
$bead_type_crit .= "tblExpansionMolding.fldBeadType = '".$bead_type."' OR ";
}
$bead_type_crit = "(".substr($bead_type_crit, 0, strlen($bead_type_crit)-4).")";
}
else {
$bead_type_crit= "(1=1)";
}
//Build date criteria (already added 1 day to end date)
$date_crit = "(fldMoldStartTimeDate >= '";
$date_crit .= date("m-d-Y", $startdate)." 00:00:00' AND fldMoldStartTimeDate <= '";
$date_crit .= date("m-d-Y", $enddate)." 00:00:00')";
//Build SQL statement
$sql = "SELECT fldSheetNumber, fldMoldBilletType, tblExpansionMolding.fldBeadType, fldMoldStartTimeDate, ";
$sql .= "fldPoundsExpanded, ";
$sql .= "DATEDIFF(hh, fldExpandEndTimeDate, COALESCE(fldMoldStartTimeDate, GETDATE())) AS fldBeadAge, ";
$sql .= "ROUND(fldMinAge * ISNULL(fldAgeMultiplier, 1), 0) AS fldMinAge, ";
$sql .= "ROUND(fldTargetAge * ISNULL(fldAgeMultiplier, 1), 0) AS fldTargetAge, ";
$sql .= "ROUND(fldMaxAge * ISNULL(fldAgeMultiplier, 1), 0) AS fldMaxAge, ";
$sql .= "DATEDIFF(hh, fldExpandEndTimeDate, COALESCE(fldMoldStartTimeDate, GETDATE())) - ROUND(fldMinAge * ISNULL(fldAgeMultiplier, 1), 0) AS fldHrsOverMin, ";
$sql .= "(SELECT COUNT(fldBilletNumber) FROM tblBillets WHERE tblBillets.fldSheetNumber = tblExpansionMolding.fldSheetNumber) AS fldNumBillets, ";
$sql .= "(SELECT AVG(fldBilletWeight / (fldBilletLength * fldBilletWidth * fldBilletDepth / 144)) FROM tblBillets WHERE tblBillets.fldSheetNumber = tblExpansionMolding.fldsheetNumber) AS fldAvgDensity, ";
$sql .= "1 - (CAST((fldPoundsExpanded + ISNULL(fldPoundsAdded, 0) - ISNULL(fldPoundsRemaining, 0)) AS DECIMAL) / (SELECT SUM(fldBilletWeight) FROM tblBillets WHERE tblBillets.fldSheetNumber = tblExpansionMolding.fldSheetNumber)) AS fldRegrindPercent ";
$sql .= "FROM tblExpansionMolding LEFT OUTER JOIN tblBilletTypes ON fldMoldBilletType = fldBilletType ";
$sql .= "LEFT OUTER JOIN tblBeadTypes ON tblExpansionMolding.fldBeadType = tblBeadTypes.fldBeadType ";
$sql .= "WHERE fldMolded = 1 AND ".$billet_type_crit." AND ".$bead_type_crit." AND ".$date_crit." ";
$sql .= "ORDER BY fldMoldStartTimeDate DESC";
//Execute query
$result = mssql_query($sql, $db);
//Get data row
if ($datarow = mssql_fetch_array($result)) {
?>
<table class="detail">
<tr class="headrow"><!-- Header row -->
<td class="headlabel">Sheet</td>
<td class="headlabel">Type</td>
<td class="headlabel">Bead</td>
<td class="headlabel">Date/Time</td>
<td class="headlabel">Lbs.</td>
<td class="headlabel">Age (Min/Tgt/Max)</td>
<td class="headlabel" style="{padding-right:0px}">Hrs. Over Min.</td>
<td class="headlabel" style="{padding-right:10px}">Num. Billets</td>
<td class="headlabel">Avg. Dens.</td>
<td class="headlabel" style="{padding-right:10px}">Regrind %</td>
</tr>
<?php
while ($datarow) {
?>
<tr class="detailrow"><!-- Data row -->
<td class="detail"><a href="batch.php?BatchNum=<?= $datarowї'fldSheetNumber'] ?>"><?= $datarowї'fldSheetNumber'] ?></a></td>
<td class="detail"><?= $datarowї'fldMoldBilletType'] ?></td>
<td class="detail"><?= $datarowї'fldBeadType'] ?></td>
<td class="detail"><?= str_replace(" ", " ", date("m/d/y H:i", strtotime($datarowї'fldMoldStartTimeDate']))) ?></td>
<td class="detail"><?= number_format($datarowї'fldPoundsExpanded']) ?></td>
<td class="detail"><?= number_format($datarowї'fldBeadAge'])." (".number_format($datarowї'fldMinAge'])."/".number_format($datarowї'fldTargetAge'])."/".number_format($datarowї'fldMaxAge']).")" ?></td>
<td class="detail"><?= number_format($datarowї'fldHrsOverMin']) ?></td>
<td class="detail"><?= number_format($datarowї'fldNumBillets']) ?></td>
<td class="detail"><?= number_format($datarowї'fldAvgDensity'], 2) ?></td>
<td class="detail"><?= number_format(100 * $datarowї'fldRegrindPercent'], 0)."%" ?></td>
</tr>
<?php
//fetch next row
$datarow = mssql_fetch_array($result);
}
echo "</table>";
}
//if no row
else {
echo "No batches found.";
}
?>
</div>
</BODY>
</HTML>