I have a question :
When i combine php and javascript as in the code below, my current php page does not navigate to timesheet.php until i write document.write() in my javascript code? Why is it so? It slows down reloading the form and a white screen also flashes before timesheet.php is loaded? How can i fix this thing?

function nextdate(userid,weeknum)
{
	weeknum ++;
        var date=document.userform.weekof.value;
	document.write();
self.location='timesheet.php?userid='+userid+'&ndate='+date+'&wno='+weeknum;
}

Try This::

function nextdate(userid,weeknum)
{
	weeknum++;
        var date = document.userform.weekof.value;
        window.location=
'timesheet.php?userid='+userid+'&ndate='+date+'&wno='+weeknum;
}

Try This::

function nextdate(userid,weeknum)
{
	weeknum++;
        var date = document.userform.weekof.value;
        window.location=
'timesheet.php?userid='+userid+'&ndate='+date+'&wno='+weeknum;
}

window.location() does not work. Any other solution?

the code provide by her has to work, if not just check if you get the values of the variables inside he function.
alert(userid+">>"+weeknum);
and also post what error you face check the error console.

Whoops, I forgot, the api is document.location not window.location .
Swap those out and it SHOULD work.

Document.location() also does not work. It works only if i have the code like this :

function nextdate(userid,weeknum)
{
    weeknum ++;
    var date=document.userform.weekof.value;
    document.write();
      document.location='timesheet.php?userid='+userid+'&ndate='+date+'&wno='+weeknum;
}

Why do i need to have document.write() before document.location()? And i tried to print the value of variables. They are holding the correct value. I don't know about the error console. Is there any other method to debug it?

Thanks !

It looks like your document object is being grabbed by other code on the same page. See if any variables such as document are being initiated or ovverridden. I think document.write() forces the browser to reinitialize the document variable, so you can reset its location.

@ codejustout:

It makes sense but i did not get the solution completely. Could you elaborate a little bit on how to do it?

Thanks

To add on...I just saw the code and all i can figure out is that:

I need document.write() before self.location() or window.location() only if i am navigating to some other php page.

If i am staying on the same php page and just changing the URL with some other variables, i do not need document.write() before self.location() and everything works fine.

It appears strange to me. Could anyone explain why is it so?

Is the page online?
It's probably something else conflicting.

I have attached the entire file here :

<?php
session_start();
if(isset($_GET['wno']))
$_SESSION['weekNum']=$_GET['wno'];
require("afterlogout.php");
require("globals.php");
$tot_monday = 0;
$tot_tuesday = 0;
$tot_wednesday = 0;
$tot_thursday = 0;
$tot_friday = 0;
$tot_saturday = 0;
$tot_sunday = 0;
$final_hortotal_billable = 0;
$final_hortotal_nonbillable = 0;
$hrscharged = 0;
$setstatus=1;
?>

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">

<head>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
	<meta name="description" content=""/>
	<meta name="keywords" content="" />
	<meta name="author" content="" />
	<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
    <style type="text/css">
<!--
.style1 {font-size: 120%}
.style5 {
	font-size: medium;
	font-weight: bold;
}
-->
    </style>
    <style type="text/css">
<!--
.style6 {color: #000000}
.style11 {font-size: 14px}
.style12 {color: #000000; font-weight: bold; }
.style13 {font-size: 14}
-->
    </style>
   
    <script language="JavaScript" type="text/javascript">
	
			function refreshpage(userid,val1)
			{
			self.location='timesheet.php?userid='+userid+'&wno=0&pdate='+val1+'&temp=1';
			}
			
			function prevdate(userid,weeknum)
			{
			weeknum --;
			var date=document.userform.weekof.value;
		//	document.write();
			//self.location='timesheet.php?userid='+userid+'&pdate='+date+'&wno='+weeknum;
			document.location='timesheet.php?userid='+userid+'&pdate='+date+'&wno='+weeknum;
			}
			
			function nextdate(userid,weeknum)
			{
			weeknum ++;
			var date=document.userform.weekof.value;
	//		document.write();
		//self.location='timesheet.php?userid='+userid+'&ndate='+date+'&wno='+weeknum;
		document.location='timesheet.php?userid='+userid+'&ndate='+date+'&wno='+weeknum;
			}
			
			function addcodepdate(userid,wno)
			{
			var date=document.userform.weekof.value;
			document.write();
			self.location='addtimerecord.php?userid='+userid+'&wno='+wno+'&pdate='+date;
			}

			function addcodendate(userid,wno)
			{
			var date=document.userform.weekof.value;
			document.write();
			self.location='addtimerecord.php?userid='+userid+'&wno='+wno+'&ndate='+date;
			}
			
			function reloaduseridpdate(pdate,wno)
			{
			var val=userform.employeeid.options[userform.employeeid.options.selectedIndex].value;	
			self.location='timesheet.php?userid='+val+'&pdate='+pdate+'&wno='+wno;
			}
			
			function reloaduseridndate(ndate,wno)
			{
			var val=userform.employeeid.options[userform.employeeid.options.selectedIndex].value;	
			self.location='timesheet.php?userid='+val+'&ndate='+ndate+'&wno='+wno;
			}
			
			function switchtimepdate(userid,pdate,wno)
			{
		//				document.write("I am here");
		//	var val=userform.employeeid.options[userform.employeeid.options.selectedIndex].value;	
		//	self.location='expensesheet.php?userid='+val+'&pdate='+pdate+'&wno='+wno;
		var url = "expensesheet.php?userid="+userid+"&pdate="+pdate+"&wno="+wno;
//		document.write(url);
		self.location.href =url;
//		window.location.href="expensesheet.php?userid="+userid+"&pdate="+pdate+"&wno="+wno;
//			document.location.href='viewusers.php';
			}
			
			function switchtimendate(ndate,wno)
			{
			//		document.write("I am here");
			var val=userform.employeeid.options[userform.employeeid.options.selectedIndex].value;	
			self.location='timesheet.php?userid='+val+'&ndate='+ndate+'&wno='+wno;
			}
			
			function switchexpndate(ndate,wno)
			{
			//		document.write("I am here");
			var val=userform.employeeid.options[userform.employeeid.options.selectedIndex].value;	
			self.location='expensesheet.php?userid='+val+'&ndate='+ndate+'&wno='+wno;
			}
			
			function switchexppdate(pdate,wno)
			{
			document.write("I am here");
			var val=userform.employeeid.options[userform.employeeid.options.selectedIndex].value;	
			self.location='expensesheet.php?userid='+val+'&pdate='+pdate+'&wno='+wno;
			}
			</script>	
    
</head>
<title>Complete Systems Automation</title> 
<body>

<div id="header">
	<div class="center_wrapper">
		
		<div id="toplinks"><?php include("displayusername.php");?></div>
	  <div class="clearer">&nbsp;</div>

		<div id="site_title">
	  </div>

  </div>
</div>

<div id="navigation">
	<div class="center_wrapper">
	
		<ul>
		  <?php include("timeexpenselinks.html");?>
	  </ul>
	  <div class="clearer">&nbsp;</div>

	</div>
</div>

<div id="main_wrapper_outer">
	<div id="main_wrapper_inner">
		<div class="center_wrapper">

			<div class="left" id="main">
			  <p align="center" class="style5 style6">Time Sheet</p>
			  <p align="center" class="style5 style6">&nbsp;</p>
			  <p align="left" class="style5 style6">&nbsp;</p>
              
                
              <form name="userform" method="post">
              
              <?php
			  if(isset($_POST['Ok']))
			  {
			  $userid= $_POST['userid'];
			  $wno= $_POST['wno'];		
			  $status=$_POST['status'];
			  	  
			  if(isset($_POST['pdate']))
			  $currdate=$_POST['pdate'];

			  else if(isset($_POST['ndate']))
			  $currdate=$_POST['ndate'];
			  
				   	    $_SESSION['weekNum'] = $wno;
						 
						$nextdate = $_SESSION['weekNum']+1;
						$nextmonday = date("m-d-Y", strtotime('monday +'.$nextdate.'week')); 
						$date = explode('-',str_replace('-','-',$nextmonday));
						$nextdate = $date[2].'-'.$date[0].'-'.$date[1];
			  		
			  	$query = "SELECT * from tbltimerecords,tblprojectsubgrouplist WHERE UserID='$userid' AND Date>='$currdate' AND Date <'$nextdate' AND tbltimerecords.ProjectID = tblprojectsubgrouplist.ProjectID AND tbltimerecords.ProjectSubGroupID = tblprojectsubgrouplist.ProjectSubGroupID AND (tblprojectsubgrouplist.BillingStatus = 'Billable' OR tblprojectsubgrouplist.BillingStatus = 'Non-Billable');";
					$result = mysql_query($query);
						
							for ($i=0 ;$i<mysql_num_rows($result); $i++)
							{
							$row_array= mysql_fetch_row($result);		
							$id = $row_array[0];
							$query = "UPDATE tbltimerecords SET StatusID = '$status' WHERE ID='$id';";
							$result_sub = mysql_query($query);
							}
												
		//		 if(isset($_POST['pdate']))			
		//		 header( 'Location: timesheet.php?userid='.$userid.'&pdate='.$currdate.'&wno='.$wno);		

			//	 else if(isset($_POST['ndate']))			
			//	 header( 'Location: timesheet.php?userid='.$userid.'&ndate='.$currdate.'&wno='.$wno);		
			  }
              ?>
              <strong> </strong><span class="style1"><strong><span class="style6">Employee ID : </span>&nbsp;</strong></span>&nbsp;&nbsp;
              <?php
		if(isset($_GET['pdate']))
		$prevdate =$_GET['pdate'];
		if(isset($_GET['ndate']))
		$nextdate =$_GET['ndate'];
		if(isset($_GET['wno']))
		$wn =$_GET['wno'];
		
		if(isset($_GET['pdate']))
		{
		?>
              <select name="employeeid" id="employeeid" onChange="javascript:reloaduseridpdate('<?php echo($prevdate);?>','<?php echo($wn);?>');">
                <?php
		}
		else if(isset($_GET['ndate']))
		{
		?>
                <select name="employeeid" id="employeeid" onChange="javascript:reloaduseridndate('<?php echo($nextdate);?>','<?php echo($wn);?>');">
                <?php
		}
		
					if(!isset($_GET['userid']))
					{
					$userid = $_SESSION['username'];		
					$monday = date("m-d-Y", strtotime('monday +'.'-1'.'week')); 				
					echo ("<SCRIPT LANGUAGE='javascript'>refreshpage('$userid','$monday');</SCRIPT>");
					}
					
			  	$query ="Select UserID from tbluserlist;";
			  	$result= mysql_query($query);
				
				for ($i=0 ;$i<mysql_num_rows($result); $i++)
						{
						$row_array = mysql_fetch_row($result);
						
						$query = "SELECT FirstName, LastName from tbluserlist WHERE UserID='$row_array[0]';";
						$resultname = mysql_query($query);
						$row_array_name = mysql_fetch_row($resultname);
						
						if($row_array[0] == $_GET['userid'])
						{
						?>
                <option selected="selected" value="<?php echo($row_array[0]);?>"><?php echo($row_array[0]."&nbsp;&nbsp;".$row_array_name[0]." ".$row_array_name[1]);?> </option>
                <?php
						}
						else
						{
						?>
                <option value="<?php echo($row_array[0]);?>"><?php echo($row_array[0]."&nbsp;&nbsp;".$row_array_name[0]." ".$row_array_name[1]);?> </option>
                <?php
					  }
					}	
				
			  ?>
                          </select>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <?php
  if(isset($_GET['pdate']))
		{
		$pd = $_GET['pdate'];
		$q = $_GET['wno']; 
		$uid =$_GET['userid']; 
		?>
            <input type="submit" name="Enter Time"  value="Enter Time" tabindex="2" id="EnterTime" onClick="javascript:switchexppdate('<?php echo($uid);?>','<?php echo($pd);?>','<?php echo($q);?>');"/>
                <?php
		}
		else if(isset($_GET['ndate']))
		{
		$nd = $_GET['ndate'];
		$q = $_GET['wno'];
		?>
           <input type="submit" name="Enter Time"  value="Enter Time" tabindex="2" id="EnterTime" onClick="javascript:switchexpndate('<?php echo($nd);?>','<?php echo($q);?>');"/>
                <?php
		}
		?>
  
&nbsp;&nbsp;&nbsp;&nbsp;

 <?php
  if(isset($_GET['pdate']))
		{
		$pd = $_GET['pdate'];
		$q = $_GET['wno'];
		$uid =$_GET['userid']; 
		?>
          <input type="submit" name="Enter Expenses"  value="Enter Expenses" tabindex="3" id="EnterExpenses" onClick="javascript:switchtimepdate('<?php echo($uid);?>','<?php echo($pd);?>','<?php echo($q);?>');"/>

                <?php
		}
		else if(isset($_GET['ndate']))
		{
		$nd = $_GET['ndate'];
		$q = $_GET['wno'];		
		?>
           <input type="submit" name="Enter Expenses"  value="Enter Expenses" tabindex="3" id="EnterExpenses" onClick="javascript:switchtimendate('<?php echo($nd);?>','<?php echo($q);?>');"/>
      <?php
		}
		?>
					<p>&nbsp;</p>
                     <p>&nbsp;</p>
                     <p><span class="style1"><strong><span class="style6">Week Of : </span>&nbsp;</strong></span>&nbsp;&nbsp;
                       <label>
                       <?php
					  
					     if(isset($_GET['pdate']))
 						  {
	   					   if(isset($_GET['temp']))
							$_SESSION['weekNum'] = $_GET['wno']-1;
						   else
						   $_SESSION['weekNum'] = $_GET['wno'];
						   
						$next_week = date("m-d-Y", strtotime('monday +'.$_SESSION['weekNum'].'week')); 
						$monday = $next_week;
						}
				
						else if(isset($_GET['ndate']))
						{
						$_SESSION['weekNum'] = $_GET['wno'];
					    $next_week = date("m-d-Y", strtotime('monday +'.$_SESSION['weekNum'].'week')); 
						$monday = $next_week;
						}
						
                     ?>
                       <input name="weekof" type="text" id="weekof" size="10" maxlength="10" disabled value="<?php echo($monday);?>">
                       </label> 
					&nbsp;&nbsp;
                       <input type="submit" name="Prev" id="prev" value="Prev" onClick="javascript:prevdate('<?php echo($_GET['userid']);?>','<?php echo($_SESSION['weekNum'])?>');">
                       
                       &nbsp;&nbsp;
                       
                       <input type="submit" name="Next" id="next" value="Next" onClick="javascript:nextdate('<?php echo($_GET['userid']);?>','<?php echo($_SESSION['weekNum'])?>');">
                </p>
                     <p>&nbsp;</p> <p>&nbsp; </p>
          
              <br>
              <p class="style5 style6">Billable Time:</p><br>
            
            <table border="1" bordercolor="#000000" bgcolor="#F2F2EB" id="dashboard6">
       		  <thead align="center">
                  			<tr>
                            <?php
						
							echo("<TH><h6> Project</h6></TH>");									
							echo("<TH><h6> Sub Group</h6></TH>");		
							echo("<TH><h6> Sub Group Title</h6></TH>");									
							echo("<TH><h6> Task</h6></TH>");		
							echo("<TH><h6> Mon </h6></TH>");
							echo("<TH><h6> Tue </h6></TH>");							
							echo("<TH><h6> Wed </h6></TH>");					
							echo("<TH><h6> Thu </h6></TH>");							
							echo("<TH><h6> Fri </h6></TH>");
							echo("<TH><h6> Sat </h6></TH>");	
							echo("<TH><h6> Sun </h6></TH>");
							echo("<TH><h6> Total </h6></TH>");	
							echo("<TH><h6> OT </h6></TH>");																			
							echo("<TH><h6> Bdgt Remain</h6></TH>");
							echo("<TH><h6> Status </h6></TH>");
						 echo("<TH><h6> Action &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</h6></TH>");
							?>
                        </tr>
                  </thead>
                  <tbody>
							
                            <?php 
							echo("<tr>");
										
						if(isset($_GET['pdate']) && isset($_GET['temp']))
						{
						$currdate = $_GET['pdate'];
						$date = explode('-',str_replace('-','-',$currdate));
						$currdate = $date[2].'-'.$date[0].'-'.$date[1];
				
						$nextdate = $_SESSION['weekNum']+1;
						$nextmonday = date("m-d-Y", strtotime('monday +'.$nextdate.'week')); 
						$date = explode('-',str_replace('-','-',$nextmonday));
						$nextdate = $date[2].'-'.$date[0].'-'.$date[1];							
						}
						
						else if(isset($_GET['pdate']))
						{
						$monday = date("m-d-Y", strtotime('monday +'.$_SESSION['weekNum'].'week')); 
						$date = explode('-',str_replace('-','-',$monday));
						$currdate = $date[2].'-'.$date[0].'-'.$date[1];		
					
						$nextdate = $_SESSION['weekNum']+1;
						$nextmonday = date("m-d-Y", strtotime('monday +'.$nextdate.'week')); 
						$date = explode('-',str_replace('-','-',$nextmonday));
						$nextdate = $date[2].'-'.$date[0].'-'.$date[1];											
						}
						
						else if(isset($_GET['ndate']))
						{
						$monday = date("m-d-Y", strtotime('monday +'.$_SESSION['weekNum'].'week')); 
						$date = explode('-',str_replace('-','-',$monday));
						$currdate = $date[2].'-'.$date[0].'-'.$date[1];	
				
						$nextdate = $_SESSION['weekNum']+1;
						$nextmonday = date("m-d-Y", strtotime('monday +'.$nextdate.'week')); 
						$date = explode('-',str_replace('-','-',$nextmonday));
						$nextdate = $date[2].'-'.$date[0].'-'.$date[1];					
						}
						
						$hortotal = 0;
						$ver_monday=0;
						$ver_tuesday=0;
						$ver_wednesday=0;
						$ver_thursday=0;
						$ver_friday=0;
						$ver_saturday=0;
						$ver_sunday=0;																																				
						$userid = $_GET['userid'];
						
						$query = "SELECT * from tbltimerecords,tblprojectsubgrouplist WHERE UserID='$userid' AND Date>='$currdate' AND Date <'$nextdate' AND tbltimerecords.ProjectID = tblprojectsubgrouplist.ProjectID AND tbltimerecords.ProjectSubGroupID = tblprojectsubgrouplist.ProjectSubGroupID AND tblprojectsubgrouplist.BillingStatus='Billable';";
				
						$resultsubgroup = mysql_query($query);
						
							for ($i=0 ;$i<mysql_num_rows($resultsubgroup); $i++)
							{
							$hortotal = 0;
							echo("<tr>");
							$row_array_subgroup = mysql_fetch_row($resultsubgroup);
						
						   $id = $row_array_subgroup[0];
						   $projectid = $row_array_subgroup[3];
						   $projectsubgroupid =$row_array_subgroup[4];
						   $taskid= $row_array_subgroup[5];  						   							
   						   $billingcodedescription =$row_array_subgroup[6];
						   $monday = $row_array_subgroup[7];  
						   $tuesday = $row_array_subgroup[8];  
						   $wednesday = $row_array_subgroup[9];  						   
						   $thursday = $row_array_subgroup[10];  
						   $friday = $row_array_subgroup[11];  
						   $saturday = $row_array_subgroup[12];  
						   $sunday = $row_array_subgroup[13];  						   
						   $comment = $row_array_subgroup[14];  						   
						   $payrate = $row_array_subgroup[15];  						   						   						   
						   $billoutrate = $row_array_subgroup[16];  						   						   
						   $statusid = $row_array_subgroup[17];  						   						   						   
						   $otrecord = $row_array_subgroup[18];  
						   
						   $setstatus = $statusid;			
						   		   						   
							$hortotal = $monday + $tuesday+$wednesday+$thursday+$friday+$saturday+$sunday;	
							$ver_monday +=$monday;
							$ver_tuesday +=$tuesday;
							$ver_wednesday +=$wednesday;
							$ver_thursday +=$thursday;
							$ver_friday +=$friday;
							$ver_saturday +=$saturday;
							$ver_sunday +=$sunday;		

							$final_hortotal_billable +=$hortotal; 		   
						   
						$query = "Select Description from tblprojectsubgrouplist where ProjectID = '$projectid' AND ProjectSubGroupID = '$projectsubgroupid';";
						$resultdesc = mysql_query($query);
						$row_array_desc = mysql_fetch_row($resultdesc);
						$projectdesc = $row_array_desc[0];

						$query = "Select tblprojecttasklist.BillingCodeID,tblprojecttasklist.BillingCodeGroupID from tblprojecttasklist,tbltimerecords where tbltimerecords.TaskID = tblprojecttasklist.TaskID AND tbltimerecords.TaskID = '$taskid' AND tblprojecttasklist.ProjectID = '$projectid' AND tblprojecttasklist.ProjectSubGroupID = '$projectsubgroupid' ;";
						$resultbillingcode = mysql_query($query);
						$row_array_bc = mysql_fetch_row($resultbillingcode);
						$billingcodeid = $row_array_bc[0];
						$billingcodegroupid = $row_array_bc[1];	
						
						$query = "Select Hours from tblprojecttasklist where ProjectID= '$projectid' AND ProjectSubGroupID= '$projectsubgroupid' AND UserID='$userid' AND TaskID='$taskid';";	
						$resulthours = mysql_query($query);	
						$row_array_hours = mysql_fetch_row($resulthours);
						$hours = $row_array_hours[0];
					
						$query = "Select Description from tblbillingcodes where BillingCodeID= '$billingcodeid' AND BillingCodeGroupID= '$billingcodegroupid';";	
						$resultbillingdesc = mysql_query($query);
						$row_array_bc = mysql_fetch_row($resultbillingdesc);
						$billingcodedesc = $row_array_bc[0];

						$query = "Select GroupName from tblbillingcodegroups where GroupID= '$billingcodegroupid';";	
						$resultbillinggpdesc = mysql_query($query);
						$row_array_bc = mysql_fetch_row($resultbillinggpdesc);
						$billingcodegroupdesc = $row_array_bc[0];
						
						$query = "Select Description from tbltimeexpensestatus where StatusID = '$statusid';";
						$resultstatus = mysql_query($query);
						$row_array_status = mysql_fetch_row($resultstatus);
						$statusdesc = $row_array_status;
						
						
			$query = "Select Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday from tbltimerecords where ProjectID= '$projectid' AND ProjectSubGroupID= '$projectsubgroupid' AND UserID='$userid' AND TaskID='$taskid';";	
						$resultremain = mysql_query($query);

						$hrscharged = 0;
						
				//		$totrows = mysql_num_rows($resultremain);
						for ($l=0 ;$l<mysql_num_rows($resultremain); $l++)
						{
						$remain = mysql_fetch_row($resultremain);
						$hrscharged +=$remain[0];
						$hrscharged +=$remain[1];
						$hrscharged +=$remain[2];
						$hrscharged +=$remain[3];
						$hrscharged +=$remain[4];
						$hrscharged +=$remain[5];
						$hrscharged +=$remain[6];																																				 						}
						
						$budgetremaining = $hours - $hrscharged;
						
								echo("<td> <center>".$projectid . "</center></td>");	
								echo("<td> <center>".$projectsubgroupid . "</center></td>");		
								echo("<td>".$projectdesc . "</td>");		
								echo("<td>".$billingcodegroupdesc.";".$billingcodedesc."</td>");										
						//		echo("<td>".$billingcodegroupdesc.";".$billingcodedesc.$hours." ".$totrows." ".$hrscharged."</td>");		
//								echo()																				
								echo("<td> <center> ".$monday . " </center></td>");	
								echo("<td> <center>".$tuesday. "</center></td>");																
								echo("<td> <center>".$wednesday. "</center></td>");
								echo("<td> <center>".$thursday. "</center></td>");
								echo("<td> <center>".$friday."</center></td>");
								echo("<td> <center>".$saturday. "</center></td>");
								echo("<td> <center>".$sunday. "</center></td>");																								
								echo("<td> <center>".$hortotal."</center></td>");
								echo("<td> <center>".$otrecord."</center></td>");
								echo("<td> <center>".$budgetremaining."</center></td>");
								echo("<td> <center>".$statusdesc[0]."</center></td>");																
								
						$val=$row_array_subgroup[0];
						
						$wnotemp = $_GET['wno'];
						if($setstatus == 1)
						{
						if(isset($_GET['pdate']))
						{
						?>
		      <td><center><a href="updatetimerecord.php?id=<?php echo($id);?>&pdate=<?php echo($currdate);?>&wno=<?php echo($wnotemp);?>">Edit</a>&nbsp;
              <a href="deletetimerecord.php?id=<?php echo($id);?>&pdate=<?php echo($currdate);?>&wno=<?php echo($wnotemp);?>">Delete</a>&nbsp;
		              <?php
						}
					  else
					  {
					  ?>
              <td><center><a href="updatetimerecord.php?id=<?php echo($id);?>&ndate=<?php echo($currdate);?>&wno=<?php echo($wnotemp);?>">Edit</a>&nbsp;
              <a href="deletetimerecord.php?id=<?php echo($id);?>&pdate=<?php echo($currdate);?>&wno=<?php echo($wnotemp);?>">Delete</a>&nbsp;
		              <?php
        		      }
					  }
					  
					  else
					  {
					  ?>
					   <td><center>Edit&nbsp;&nbsp;Delete
                       <?php
					   }
		              ?>
        						
<?php 
		  					echo("</tr>");
									}
							
							 echo("<tr>");
							  echo("<td></td>");	  
							  echo("<td></td>");	   
							  echo("<td></td>");	
							  echo("<td> <h6><center>Billable Totals:</h6></center></td>");  
							  echo("<td><center>".$ver_monday."</center></td>");	 
							  echo("<td><center>".$ver_tuesday."</center></td>");	
							  echo("<td><center>".$ver_wednesday."</center></td>");	  
							  echo("<td><center>".$ver_thursday."</center></td>");	   
							  echo("<td><center>".$ver_friday."</center></td>");	  
							  echo("<td><center>".$ver_saturday."</center></td>");	 
							  echo("<td><center>".$ver_sunday."</center></td>");	
							  echo("<td><center>".$final_hortotal_billable."</center></td>");	  
							  echo("<td></td>");	   
							  echo("<td></td>");	  
							  echo("<td></td>");	 
							  echo("<td></td>");	
							  echo("</tr>");
							  $tot_monday += $ver_monday;
							  $tot_tuesday += $ver_tuesday;
							  $tot_wednesday += $ver_wednesday;
							  $tot_thursday += $ver_thursday;
							  $tot_friday += $ver_friday;
							  $tot_saturday += $ver_saturday;
							  $tot_sunday += $ver_sunday;							  							  							  							  							  							 
		    ?>
                	    </tbody>
                	      <div align="center"></div>
			  </table>
       		 
			  
			  <p>&nbsp;</p>
			  <p>&nbsp;</p>
              
              
              <br>              <br>
	           
           <p class="style5 style6">Non-Billable Time:</p><br>
            
            <table border="1" bordercolor="#000000" bgcolor="#F2F2EB" id="dashboard6">
       		  <thead align="center">
                  			<tr>
                            <?php
						
							echo("<TH><h6> Project</h6></TH>");									
							echo("<TH><h6> Sub Group</h6></TH>");		
							echo("<TH><h6> Sub Group Title</h6></TH>");									
							echo("<TH><h6> Task</h6></TH>");		
							echo("<TH><h6> Mon </h6></TH>");
							echo("<TH><h6> Tue </h6></TH>");							
							echo("<TH><h6> Wed </h6></TH>");					
							echo("<TH><h6> Thu </h6></TH>");							
							echo("<TH><h6> Fri </h6></TH>");
							echo("<TH><h6> Sat </h6></TH>");	
							echo("<TH><h6> Sun </h6></TH>");
							echo("<TH><h6> Total </h6></TH>");	
							echo("<TH><h6> OT </h6></TH>");																			
							echo("<TH><h6> Bdgt Remain</h6></TH>");
							echo("<TH><h6> Status </h6></TH>");
						 echo("<TH><h6> Action &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</h6></TH>");
							?>
               	    </tr>
       	 	  </thead>
             		   <tbody>
							
                            <?php 
							echo("<tr>");
										
						if(isset($_GET['pdate']) && isset($_GET['temp']))
						{
						$currdate = $_GET['pdate'];
						$date = explode('-',str_replace('-','-',$currdate));
						$currdate = $date[2].'-'.$date[0].'-'.$date[1];
				
						$nextdate = $_SESSION['weekNum']+1;
						$nextmonday = date("m-d-Y", strtotime('monday +'.$nextdate.'week')); 
						$date = explode('-',str_replace('-','-',$nextmonday));
						$nextdate = $date[2].'-'.$date[0].'-'.$date[1];							
						}
						
						else if(isset($_GET['pdate']))
						{
						$monday = date("m-d-Y", strtotime('monday +'.$_SESSION['weekNum'].'week')); 
						$date = explode('-',str_replace('-','-',$monday));
						$currdate = $date[2].'-'.$date[0].'-'.$date[1];		
					
						$nextdate = $_SESSION['weekNum']+1;
						$nextmonday = date("m-d-Y", strtotime('monday +'.$nextdate.'week')); 
						$date = explode('-',str_replace('-','-',$nextmonday));
						$nextdate = $date[2].'-'.$date[0].'-'.$date[1];											
						}
						
						else if(isset($_GET['ndate']))
						{
						$monday = date("m-d-Y", strtotime('monday +'.$_SESSION['weekNum'].'week')); 
						$date = explode('-',str_replace('-','-',$monday));
						$currdate = $date[2].'-'.$date[0].'-'.$date[1];	
				
						$nextdate = $_SESSION['weekNum']+1;
						$nextmonday = date("m-d-Y", strtotime('monday +'.$nextdate.'week')); 
						$date = explode('-',str_replace('-','-',$nextmonday));
						$nextdate = $date[2].'-'.$date[0].'-'.$date[1];					
						}
						
						$hortotal = 0;
						$ver_monday=0;
						$ver_tuesday=0;
						$ver_wednesday=0;
						$ver_thursday=0;
						$ver_friday=0;
						$ver_saturday=0;
						$ver_sunday=0;																																				
						
						$query = "SELECT * from tbltimerecords,tblprojectsubgrouplist WHERE UserID='$userid' AND Date>='$currdate' AND Date <'$nextdate' AND tbltimerecords.ProjectID = tblprojectsubgrouplist.ProjectID AND tbltimerecords.ProjectSubGroupID = tblprojectsubgrouplist.ProjectSubGroupID AND tblprojectsubgrouplist.BillingStatus='Non-Billable';";
				
						$resultsubgroup = mysql_query($query);
						
							for ($i=0 ;$i<mysql_num_rows($resultsubgroup); $i++)
							{
							$hortotal = 0;
							echo("<tr>");
							$row_array_subgroup = mysql_fetch_row($resultsubgroup);
						
						   $id = $row_array_subgroup[0];
						   $projectid = $row_array_subgroup[3];
						   $projectsubgroupid =$row_array_subgroup[4];
						   $taskid= $row_array_subgroup[5];  						   							
   						   $billingcodedescription =$row_array_subgroup[6];
						   $monday = $row_array_subgroup[7];  
						   $tuesday = $row_array_subgroup[8];  
						   $wednesday = $row_array_subgroup[9];  						   
						   $thursday = $row_array_subgroup[10];  
						   $friday = $row_array_subgroup[11];  
						   $saturday = $row_array_subgroup[12];  
						   $sunday = $row_array_subgroup[13];  						   
						   $comment = $row_array_subgroup[14];  						   
						   $payrate = $row_array_subgroup[15];  						   						   						   
						   $billoutrate = $row_array_subgroup[16];  						   						   
						   $statusid = $row_array_subgroup[17];  						   						   						   
						   $otrecord = $row_array_subgroup[18];  						   						   
						   			
							$hortotal = $monday + $tuesday+$wednesday+$thursday+$friday+$saturday+$sunday;	
							$ver_monday +=$monday;
							$ver_tuesday +=$tuesday;
							$ver_wednesday +=$wednesday;
							$ver_thursday +=$thursday;
							$ver_friday +=$friday;
							$ver_saturday +=$saturday;
							$ver_sunday +=$sunday;		

							$final_hortotal_nonbillable +=$hortotal; 		   
						   
						$query = "Select Description from tblprojectsubgrouplist where ProjectID = '$projectid' AND ProjectSubGroupID = '$projectsubgroupid';";
						$resultdesc = mysql_query($query);
						$row_array_desc = mysql_fetch_row($resultdesc);
						$projectdesc = $row_array_desc[0];

						$query = "Select tblprojecttasklist.BillingCodeID,tblprojecttasklist.BillingCodeGroupID from tblprojecttasklist,tbltimerecords where tbltimerecords.TaskID = tblprojecttasklist.TaskID AND tbltimerecords.TaskID = '$taskid' AND tblprojecttasklist.ProjectID = '$projectid' AND tblprojecttasklist.ProjectSubGroupID = '$projectsubgroupid' ;";
						$resultbillingcode = mysql_query($query);
						$row_array_bc = mysql_fetch_row($resultbillingcode);
						$billingcodeid = $row_array_bc[0];
						$billingcodegroupid = $row_array_bc[1];	
						
						$query = "Select Hours from tblprojecttasklist where ProjectID= '$projectid' AND ProjectSubGroupID= '$projectsubgroupid' AND UserID='$userid' AND TaskID='$taskid';";	
						$resulthours = mysql_query($query);
						$row_array_hours = mysql_fetch_row($resulthours);
						$hours = $row_array_hours[0];
					
						$query = "Select Description from tblbillingcodes where BillingCodeID= '$billingcodeid' AND BillingCodeGroupID= '$billingcodegroupid';";	
						$resultbillingdesc = mysql_query($query);
						$row_array_bc = mysql_fetch_row($resultbillingdesc);
						$billingcodedesc = $row_array_bc[0];

						$query = "Select GroupName from tblbillingcodegroups where GroupID= '$billingcodegroupid';";	
						$resultbillinggpdesc = mysql_query($query);
						$row_array_bc = mysql_fetch_row($resultbillinggpdesc);
						$billingcodegroupdesc = $row_array_bc[0];
						
						$query = "Select Description from tbltimeexpensestatus where StatusID = '$statusid';";
						$resultstatus = mysql_query($query);
						$row_array_status = mysql_fetch_row($resultstatus);
						$statusdesc = $row_array_status;
						
						$query = "Select Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday from tbltimerecords where ProjectID= '$projectid' AND ProjectSubGroupID= '$projectsubgroupid' AND UserID='$userid' AND TaskID='$taskid';";	
						$resultremain = mysql_query($query);
						$hrscharged =0;
						
						for ($z=0 ;$z<mysql_num_rows($resultremain); $z++)
						{
						$remain = mysql_fetch_row($resultremain);
						$hrscharged +=$remain[0];
						$hrscharged +=$remain[1];
						$hrscharged +=$remain[2];
						$hrscharged +=$remain[3];
						$hrscharged +=$remain[4];
						$hrscharged +=$remain[5];
						$hrscharged +=$remain[6];																																				 						}
						
							$budgetremaining = $hours - $hrscharged;

								echo("<td> <center>".$projectid . "</center></td>");	
								echo("<td> <center>".$projectsubgroupid . "</center></td>");		
								echo("<td>".$projectdesc . "</td>");		
								echo("<td>".$billingcodegroupdesc.";".$billingcodedesc."</td>");																						
								echo("<td> <center> ".$monday . " </center></td>");	
								echo("<td> <center>".$tuesday. "</center></td>");																
								echo("<td> <center>".$wednesday. "</center></td>");
								echo("<td> <center>".$thursday. "</center></td>");
								echo("<td> <center>".$friday."</center></td>");
								echo("<td> <center>".$saturday. "</center></td>");
								echo("<td> <center>".$sunday. "</center></td>");																								
								echo("<td> <center>".$hortotal."</center></td>");
								echo("<td> <center>".$otrecord."</center></td>");
								echo("<td> <center>".$budgetremaining."</center></td>");
								echo("<td> <center>".$statusdesc[0]."</center></td>");																
								
						$val=$row_array_subgroup[0];
						
						$wnotemp = $_GET['wno'];
						if($setstatus == 1)
						{
						if(isset($_GET['pdate']))
						{
						?>
		      <td><center><a href="updatetimerecord.php?id=<?php echo($id);?>&pdate=<?php echo($currdate);?>&wno=<?php echo($wnotemp);?>">Edit</a>&nbsp;
              <a href="deletetimerecord.php?id=<?php echo($id);?>&pdate=<?php echo($currdate);?>&wno=<?php echo($wnotemp);?>">Delete</a>&nbsp;
		              <?php
						}
					  else
					  {
					  ?>
              <td><center><a href="updatetimerecord.php?id=<?php echo($id);?>&ndate=<?php echo($currdate);?>&wno=<?php echo($wnotemp);?>">Edit</a>&nbsp;
              <a href="deletetimerecord.php?id=<?php echo($id);?>&pdate=<?php echo($currdate);?>&wno=<?php echo($wnotemp);?>">Delete</a>&nbsp;
		              <?php
        		      }
					  }
					  
					  else
					  {
					  ?>
					   <td><center>Edit&nbsp;&nbsp;Delete
                       <?php
					   }
			   ?>
        <?php 
		  					echo("</tr>");
									}
							
							 echo("<tr>");
							  echo("<td></td>");	  
							  echo("<td></td>");	   
							  echo("<td></td>");	
							  echo("<td> <h6><center>Non-Billable Totals:</h6></center></td>");  
							  echo("<td><center>".$ver_monday."</center></td>");	 
							  echo("<td><center>".$ver_tuesday."</center></td>");	
							  echo("<td><center>".$ver_wednesday."</center></td>");	  
							  echo("<td><center>".$ver_thursday."</center></td>");	   
							  echo("<td><center>".$ver_friday."</center></td>");	  
							  echo("<td><center>".$ver_saturday."</center></td>");	 
							  echo("<td><center>".$ver_sunday."</center></td>");	
							  echo("<td><center>".$final_hortotal_nonbillable."</center></td>");	  
							  echo("<td></td>");	   
							  echo("<td></td>");	  
							  echo("<td></td>");	 
							  echo("<td></td>");	
							  echo("</tr>");
							  $tot_monday += $ver_monday;
							  $tot_tuesday += $ver_tuesday;
							  $tot_wednesday += $ver_wednesday;
							  $tot_thursday += $ver_thursday;
							  $tot_friday += $ver_friday;
							  $tot_saturday += $ver_saturday;
							  $tot_sunday += $ver_sunday;	
							  
							  $final = $final_hortotal_nonbillable + $final_hortotal_billable;	
							  echo("<tr>");
							  echo("<td></td>");	  
							  echo("<td></td>");	   
							  echo("<td></td>");	
							  echo("<td> <h6><center>Totals:</h6></center></td>");  
							  echo("<td><center>".$tot_monday."</center></td>");	 
							  echo("<td><center>".$tot_tuesday."</center></td>");	
							  echo("<td><center>".$tot_wednesday."</center></td>");	  
							  echo("<td><center>".$tot_thursday."</center></td>");	   
							  echo("<td><center>".$tot_friday."</center></td>");	  
							  echo("<td><center>".$tot_saturday."</center></td>");	 
							  echo("<td><center>".$tot_sunday."</center></td>");	
							  echo("<td><center>".$final."</center></td>");	  
							  echo("<td></td>");	   
							  echo("<td></td>");	  
							  echo("<td></td>");	 
							  echo("<td></td>");	
							 echo("</tr>");
						  							  							  							  							  							 
		    ?>
                	    </tbody>
                	      <div align="center"></div>
			  </table>
       		  <p>&nbsp;</p>
			  <p>&nbsp;</p>
			  <p>&nbsp;</p>
              
              
              
                <?php
                $uid = $_GET['userid'];
				$wno= $_GET['wno'];
				
				if(isset($_GET['pdate']))
				{
					if($setstatus ==1)
					{
					?>
					   <input type="submit" name="Add" value="Add Record" tabindex="1" id="Add" onClick="javascript:addcodepdate('<?php echo($uid);?>','<?php echo($wno);?>');"/>
				<?php
					}
					else
					{
					?>
					   <input type="submit" name="Add" disabled value="Add Record" tabindex="1" id="Add" onClick="javascript:addcodepdate('<?php echo($uid);?>','<?php echo($wno);?>');"/>
				<?php
					}
				}
					  
				else if(isset($_GET['ndate']))
				{
					if($setstatus ==1)
					{
					?>
				 <input type="submit" name="Add" value="Add Record" tabindex="1" id="Add" onClick="javascript:addcodendate('<?php echo($uid);?>','<?php echo($wno);?>');"/>
				<?php
					}
					else
					{
					?>
					    <input type="submit" name="Add" disabled value="Add Record" tabindex="1" id="Add" onClick="javascript:addcodendate('<?php echo($uid);?>','<?php echo($wno);?>');"/>
				<?php
					}
				}	
			?>

			  <p>&nbsp;</p>
			  <p>&nbsp;</p>
			  <p>
			    <label><span class="style5 style6">Status</span></label>
			    <label>
			    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<select name="status" id="status">
                
                <?php
				if($setstatus == 1)
				{
				?>
                <option value="1" selected="selected">New</option>
                <option value="2">Submitted</option>
                <option value="3" disabled>Approved</option>
                <option value="4" disabled>Invoiced</option>
                <?php
				}
				
                else if($setstatus == 2)
				{
				?>
                <option value="2" selected="selected">Submitted</option>
                <option value="1">New</option>
                <option value="3">Approved</option>
                <option value="4" disabled>Invoiced</option>
                <?php
				}

				else if($setstatus == 3)
				{
				?>
                <option value="3" selected="selected">Approved</option>
                <option value="1">New</option>
                <option value="4">Invoiced</option>
                <option value="2" disabled>Submitted</option>

                <?php
				}

				else if($setstatus == 4)
				{
				?>
                <option value="4" selected="selected">Invoiced</option>
                <option value="2" disabled>Submitted</option>
                <option value="3" disabled>Approved</option>
                <option value="1" disabled>New</option>
                <?php
				}
				?>
                </select>
			    </label>
                
                <?php
                $uid = $_GET['userid'];
				$wno= $_GET['wno'];
				?>
				<input type="hidden" name="userid" id="userid" value="<?php echo($uid);?>">
				<input type="hidden" name="wno" id="wno" value="<?php echo($wno);?>">                
                
				<?php
				if(isset($_GET['pdate']))
				{
				?>
                <input type="hidden" name="pdate" id="pdate" value="<?php echo($currdate);?>">   
			    <?php
				} 
				else if(isset($_GET['ndate']))
				{
				?>
			     <input type="hidden" name="ndate" id="ndate" value="<?php echo($currdate);?>">                  
                <?php
				}
                ?>
               &nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" name="Ok" id="Ok" value="Ok">
            
                
			  </p>
			  <p>&nbsp;</p>
			  <p>&nbsp;</p>
			  <p>
			    <label></label>
			    </p>
			  <p class="style11">
			    <label></label>
			  </p>
			  <p>&nbsp;&nbsp;&nbsp;&nbsp;  </p>
			  <div align="center">
            
                   
                   
                   </p>
                </div>
                 <p>&nbsp;</p>
          
          </form>
              
			  <p align="center">&nbsp;</p>
			  <p align="center">&nbsp;</p>
			  <p align="center">&nbsp;</p>
		  </div>

		  <div class="clearer">&nbsp;</div>

		</div>
	</div>
</div>


<div id="footer">
	<div class="center_wrapper"><span class="left">&copy; 2009 Complete  Systems Automation, Inc. </span>
	  <div class="right"></div>
		
	  <div class="clearer">&nbsp;</div>

  </div>
</div>

</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.