if ($total_time > "05:00:00" || $total_time <= "00:00:00")
{
echo "";
}
else
{
echo "<center><table border = '0' cellspaceing = '0' cellpadding = '-1' width = '10%' bgcolor = '#999999'>";
echo "<tr><td align = 'center' width = '100%'>$total_time</td>";
echo "</tr></table></center>";
$complete_total_time1 += $total_seconds;
}
}
else
{
$sec = ($end_action - $resume_time) + ($pause_time - $start_action);
$total_seconds = $sec;
$hr = floor($sec/60/60);
$sec = $sec - $hr * 60 * 60;
$min = floor($sec/60);
$sec = $sec - $min * 60;
$total_time = sprintf("%02d:%02d:%02d", $hr, $min, $sec);
$start_count = "0";
$end_count = "0";
$pause_count = "0";
$resume_count = "0";
$pause_time = "0";
$resume_time = "0";
if ($total_time > "05:00:00" || $total_time <= "00:00:00")
{
echo "";
}
else
{
echo "<center><table border = '0' cellspaceing = '0' cellpadding = '-1' width = '10%' bgcolor = '#999999'>";
echo "<tr><td align = 'center' width = '100%'>$total_time</td>";
echo "</tr></table></center>";
$complete_total_time1 += $total_seconds;
}
}
}
else
{
echo "";
}
/*end math for last loop-------------------*/
/*start math for total time----------------*/
$sec = $complete_total_time1;
$hr = floor($sec/60/60);
$sec = $sec - $hr * 60 * 60;
$min = floor($sec/60);
$sec = $sec - $min * 60;
$complete_total_time2 = sprintf("%02d:%02d:%02d", $hr, $min, $sec);
echo "<table border = '0' cellspaceing = '0' cellpadding = '-1' width = '30%' bgcolor = '#ffffff'>";
echo "<tr><td align = 'center' width = '10%'><br>Table Time</td></tr>";
echo "<tr><td align = 'center' bgcolor = '#999999'>$complete_total_time2</td>";
echo "</tr></table></center>";
/*end math for total time------------------*/
$query="SELECT ad_order.company company, job_log.employee_id employee_id, job_log.time time, job_log.table_id table_id, job_log.ad_id ad_id, job_log.action action FROM ad_order LEFT JOIN (job_log) ON (job_log.ad_id=ad_order.id) WHERE ad_order.cust_id=$table_id ORDER BY company,time";
$complete_total_time3 = 0;
$last_value = "";
$result=mysql_query($query);
while($row = mysql_fetch_assoc($result)) {
if (preg_match('/Start Creation|Start Table PTG|Cutting - Begin|Begin 1st Proof|Begin 2nd Proof|Proof Print - Begin|Start In-House Fix|Final Print - Begin|Start Outside Change|Start Outside Fix/',$action3)){
$start_action = $time;
$start_count++;}
if ($action3=="Pause"){
$pause_time = $time;
$pause_count++;
$start_action2 = $pause_time - $start_action;}
if ($action3=="Resume"){
$resume_time = $time;
$resume_count++;}
if (preg_match('/End Creation|Finish Table PTG|Cutting - End|End 1st Proof -OK|End 1st Proof - FIX|End 2nd Proof - OK|End 2nd Proof - FIX|End In-House Fix|Final Print - End|End Outside Change|End Outside Fix/',$action3)){
$end_action = $time;
$end_count++;
if ($end_count > $start_count){
$start_action = "0";
$start_count--;}
if ($pause_count != $resume_count){
$sec = ($end_action - $start_action) + $start_action2;
$total_seconds = $sec;
$hr = floor($sec/60/60);
$sec = $sec - $hr * 60 * 60;
$min = floor($sec/60);
$sec = $sec - $min * 60;
$total_time = sprintf("%02d:%02d:%02d", $hr, $min, $sec);
$start_count = "0";
$end_count = "0";
$pause_count = "0";
$resume_count = "0";
$pause_time = "0";
$resume_time = "0";
if ($total_time > "05:00:00" || $total_time <= "00:00:00"){echo "";}
else {echo "<center><table border = '0' cellspaceing = '0' cellpadding = '-1' width = '10%' bgcolor = '#999999'>";
echo "<tr><td align = 'center' width = '100%'>$total_time</td>";
echo "</tr></table></center>";
$complete_total_time3 += $total_seconds;
}}
else{$sec = ($end_action - $resume_time) + ($pause_time - $start_action);
$total_seconds = $sec;
$hr = floor($sec/60/60);
$sec = $sec - $hr * 60 * 60;
$min = floor($sec/60);
$sec = $sec - $min * 60;
$total_time = sprintf("%02d:%02d:%02d", $hr, $min, $sec);
$start_count = "0";
$end_count = "0";
$pause_count = "0";
$resume_count = "0";
$pause_time = "0";
$resume_time = "0";
if ($total_time > "05:00:00" || $total_time <= "00:00:00"){$total_time = "No Entry";}
else {echo "<center><table border = '0' cellspaceing = '0' cellpadding = '-1' width = '10%' bgcolor = '#999999'>";
echo "<tr><td align = 'center' width = '100%'>$total_time</td>";
echo "</tr></table></center>";
$complete_total_time3 += $total_seconds;
}}}
else{
echo "";}
{
$company = $row['company'];
$time = $row['time'];
$employee_name2 = $row['employee_id'];
$action3 = $row['action'];
$showtime = date('m/d/y-h:i:s',$time);
if ($showtime=="12/31/69-06:00:00")
$showtime = "No Entry";
else
$showtime = date('m/d/y-h:i:s',$time);
$query2 = "SELECT * FROM employees WHERE employee_id = '$employee_name2'";
$result2 = mysql_query($query2);
while($row2 = mysql_fetch_assoc($result2))
{
$employee_name2 = $row2['fname']." ".$row2['lname'];
if ($employee_name2=="")
$employee_name2 = "No Entry";
else
$employee_name2 = $row2['fname']." ".$row2['lname'];
}
$query3 = "SELECT * FROM job_actions WHERE action_id = '$action3'";
$result3 = mysql_query($query3);
while($row3 = mysql_fetch_assoc($result3))
{
$action3 = $row3['action_name'];
if ($action3=="")
$action3 = "No Entry";
else
$action3 = $row3['action_name'];
}
if($row['company'] != $last_value){
echo "<br><br>";
echo "<center><table border = '1' cellspaceing = '2' cellpadding = '4' width = '100%' bgcolor = '#999999'>";
echo "<tr><td align = 'center' width = '40%'><font color='#ffffff'>Company Name</font></td><td align = 'center' width = '20%'><font color='#ffffff'>Employee Name</font></td><td align = 'center' width = '20%'><font color='#ffffff'>Time</font></td><td align = 'center' width = '25%'><font color='#ffffff'>Action</font></td></tr>";
echo "</table><br></center>";
$last_value = $row['company'];}
}
echo "<center><table border = '0' cellspaceing = '0' cellpadding = '1' width = '100%' bgcolor = '#ffffff'>";
echo "<tr><td align = 'center' abbr = abbr_text width = '40%'>$company</td><td align = 'center' width = '20%'>$employee_name2</td><td align = 'center' width = '20%'>$showtime</td><td align = center width = '25%'>$action3</td></tr><td align = 'center' abbr = abbr_text width = '40%'>$table_time4</td>";
echo "</table></center>";
}
$sec = $complete_total_time3;
$hr = floor($sec/60/60);
$sec = $sec - $hr * 60 * 60;
$min = floor($sec/60);
$sec = $sec - $min * 60;
$complete_total_time4 = sprintf("%02d:%02d:%02d", $hr, $min, $sec);
echo "<center><table border = '0' cellspaceing = '0' cellpadding = '-1' width = '20%' bgcolor = '#ffffff'>";
echo "<tr><td><br></td></tr>";
echo "<tr><td width = '100%' td align = 'center'>Total Ad Time</td></tr>";
echo "<tr><td align = 'center' width = '100%' bgcolor = '#999999'>$complete_total_time4</td></tr></table>";
$full_table_time = $complete_total_time1 + $complete_total_time3;
$sec = $full_table_time;
$hr = floor($sec/60/60);
$sec = $sec - $hr * 60 * 60;
$min = floor($sec/60);
$sec = $sec - $min * 60;
$full_table_time1 = sprintf("%02d:%02d:%02d", $hr, $min, $sec);
echo "<table border = '0' cellspaceing = '0' cellpadding = '-1' width = '20%' bgcolor = '#ffffff'>";
echo "<tr><td><br></td></tr>";
echo "<tr><td><br></td></tr>";
echo "<tr><td width = '100%' td align = 'center'>Total Time</td></tr>";
echo "<tr><td align = 'center' width = '100%' bgcolor = '#999999'>$full_table_time1</td>";
echo "</tr></table></center>";
echo "<br><br>";
mysql_close();
?>
</TD>
</TR>
<TR>
<TD COLSPAN=3><IMG SRC="images/inside_08.gif" WIDTH=758 HEIGHT=3></TD>
</TR>
</TABLE>
</body>
</html>
If you require any more info just let me know. Thanks for any help you can provide.