Jump to content

i cant figure out display


flemingmike

Recommended Posts

hello, newbie here.  i am struggling with the way my table is displayed.  as you can see if you goto http://durhamit.ca/citycore/2/tsreview.php and goto october 20th, Rui Zhang has 3 entries and im trying to make it display one at a time.

 

here is my code if anyone can point me in the right direction.

 

<?php

include 'config.php';
include 'javascript.php';

$d = date("d");
$m = date("m");
$y = date("Y");


?> 

<center>

<form method="POST">
Month: <select size="1" name="m">
<option selected="selected" value="<?php echo $m; ?>"><?php echo $m; ?></option>
<?php
$mlist = range( 1,12 );
foreach ($mlist as $v ) {
   echo "<option value=\"$v\">$v</option>\n";
}
?>
</select>

Day: <select size="1" name="d">
<option selected="selected" value="<?php echo $d; ?>"><?php echo $d; ?></option>
<?php
$dlist = range( 1,31 );
foreach( $dlist as $v ) {
   echo "<option value=\"$v\">$v</option>\n";
}
?>
</select>

Year: <select size="1" name="y">
<option selected="selected" value="<?php echo $y; ?>"><?php echo $y; ?></option>
<option value="2010">2010</option>
<option value="2011">2011</option>
<option value="2012">2012</option>
<option value="2013">2013</option>
<option value="2014">2014</option>
</select>



<input type="submit" value="View" name="view">
</form>


<?php

if(isset($_POST['view']))
{

$y3=$_POST['y'];
$m3=$_POST['m'];
$d3=$_POST['d'];


$pdate=$y3."-".$m3. "-".$d3;
$pdate1 = date( 'D M j', strtotime($pdate) );
} else {
$pdate =  date('Y-m-d', strtotime("-1 day") );
$pdate1 = date( 'D M j', strtotime($pdate) );
}

$pdate2 =  date('Y-m-d', strtotime("-1 day, $pdate") );
$y4 = date('Y', strtotime("$pdate2") );
$m4 = date('m', strtotime("$pdate2") );
$d4 = date('d', strtotime("$pdate2") );

$pdate3 =  date('Y-m-d', strtotime("+1 day, $pdate") );
$y5 = date('Y', strtotime("$pdate3") );
$m5 = date('m', strtotime("$pdate3") );
$d5 = date('d', strtotime("$pdate3") );

echo "<table border='1' style='border-collapse: collapse' bordercolorlight='#000000' bordercolordark='#000000' width='98%' align='center'>";
echo "<tr>";
echo "<td width='100%' colspan='9' align='center'>";
?>
<table border='0' cellpadding='0' width='100%'>
<tr>
	<td width='10%'  align="center">

<form name="back" method="POST">
<input type="submit" value="<<<" name="view">
<input type="hidden" name="y" value="<?php echo "$y4"; ?>">
<input type="hidden" name="m" value="<?php echo "$m4"; ?>">
<input type="hidden" name="d" value="<?php echo "$d4"; ?>">
</form>
	</td>
	<td align="center"><b>Timesheets For <?php echo "$pdate1"; ?></b></td>
	<td width='10%'  align="center">

<form name="forward" method="POST">
<input type="hidden" name="y" value="<?php echo "$y5"; ?>">
<input type="hidden" name="m" value="<?php echo "$m5"; ?>">
<input type="hidden" name="d" value="<?php echo "$d5"; ?>">
<input type="submit" value=">>>" name="view">
</form>
	</td>
</tr>
</table>
<?php
echo "</td>";
echo "</tr>";


$result5 = mysql_query("SELECT * FROM staff ORDER BY name");
while($row = mysql_fetch_array($result5))
{
$eid=$row['eid'];
$mname=$row['name'];



$result3 = mysql_query("SELECT * FROM timesheet WHERE date = '$pdate' AND eid = '$eid'");
$talltime = 0;
while($row3 = mysql_fetch_array($result3))
{

  $tid=$row3['id'];
  $tdate=$row3['date'];
  $tjobnumber=$row3['jobnumber'];
  $teid=$row3['eid'];
  $tdescription=$row3['description'];
  $tsignin=$row3['start'];
  $tfinish=$row3['finish'];
  $tlunch=$row3['lunch'];
  $tkms=$row3['kms'];
  $tschednum=$row3['schednum'];
  $tapproval=$row3['approval'];
  
  
if("$tapproval" == "1") {
$tapproval1="<font color='#00FF00'>In Progress</font>";
 }  

if("$tapproval" == "2") {
$tapproval1="<a target='_blank' href='approve.php?id=$tid'><font color='#FF0000'>Approve</font></a><br />
<a href='edittimesheet.php?id=" . $tschednum . "'>Edit</a>";

 }  

if("$tapproval" == "3") {
$tapproval1="Approved";
 } 


  
  $tdate1 = date( 'M j, Y', strtotime($tdate) );
  
    $tsignin1 = date( 'g:i a', strtotime($tsignin) );
$tfinish1 = date( 'g:i a', strtotime($tfinish) );

if( empty($tfinish) ) {
 $tfinish2="<i>In Progress";
} else {
 $tfinish2="$tfinish1";
}

$shortid=substr($tjobnumber, 5, -1); //remove the first 5 characters and minus the last character

$result = mysql_query("SELECT * FROM jobs WHERE id = '$shortid'");
while($row = mysql_fetch_array($result))
{
$jstatus=$row['status'];

}


$result4 = mysql_query("SELECT * FROM schedule WHERE id = '$tschednum'");
while($row4 = mysql_fetch_array($result4))
{

  $sid=$row4['id'];
  $sdate=$row4['date'];
  $seid=$row4['eid'];
  $sjobnumber=$row4['jobnumber'];
  $sstarttime=$row4['starttime'];
  $sstatus=$row4['status'];
  $setime=$row4['etime'];
  
}

$log_in_time_string = strtotime($tsignin);
$log_out_time_string = strtotime($tfinish);
$difference_in_seconds = ($log_out_time_string - $log_in_time_string);
$tbilled = ($difference_in_seconds / 3600);
  
  
  if($tbilled < 0)
{
    $tbilled1 = $tbilled + 24;
} else {
    $tbilled1=$tbilled;
}
  
  $tbilled2 = number_format(round($tbilled1*4)/4,2);
  $tbilled3 = $tbilled2 - $tlunch ;
  $talltime += $tbilled3;
  
  
  if ($talltime == '0' ) {
 echo "nothing";
 } else {

   echo "<tr>";
  echo "<td align='left' colspan='10'><b>&nbsp" . $mname . "</b></td>";
  echo "</tr>";

echo "<tr>
		<th align='center'>Date</th>
		<th align='center'>Job Number</th>
		<th align='center' width='30%'>Service Report</th>
		<th align='center'>Sign In Time</th>
		<th align='center'>Sign Out Time</th>
		<th align='center'>Lunch</th>
		<th align='center'>Time Billed</th>
		<th align='center'>Estimated</th>
		<th align='center'>Status</th>		
</tr>";
  
  echo "<tr>";
  echo "<td align='center'>" . $tdate1 . "</td>";
  echo "<td align='center'>" . $tjobnumber . "</td>";
  echo "<td align='center'>" . $tdescription . "</td>";
  echo "<td align='center'>" . $tsignin1 . "</td>";  
echo "<td align='center'>" . $tfinish2 . "</td>";
echo "<td align='center'>" . $tlunch . " hour</td>";
echo "<td align='center'>";
     if ($tbilled3 > $setime ) {
 echo "<font color='red'><b>*** " . $tbilled3 . " hours ***</b></font>";
 } else {
 echo "" . $tbilled3 . " hours";
 }
echo "</td>";
echo "<td align='center'>" . $setime . " hours</td>";
echo "<td align='center' nowrap>" . $tapproval1 . "</td>";


  echo "</tr>";

} 
   echo "<tr>";

  echo "<td colspan='6' align='right'><b>Totals :</td>";
  echo "<td align='center' colspan='3'>";
     if ($talltime > "8" ) {
 echo "<font color='red'><b>*** " . $talltime . " hours ***</b></font>";
 } elseif ($talltime < "0" ) {
 echo "<font color='red'><b>Still signed into a job</b></font>";
 } else {
 echo "" . $talltime . " hours";
 }
echo "</td>";

  echo "</tr>";

   echo "<tr>";
echo "<td align='center' colspan='10' bgcolor='#D9FFD9'>&nbsp</td>";
  echo "</tr>";

}
}
    
echo "</table>";







include 'close.php';

?>

Link to comment
https://forums.phpfreaks.com/topic/217008-i-cant-figure-out-display/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.