Location: PHPKode > projects > PHP Project Manager > viewproject.php
<?php
include "includes/header.php";
$project_id=$_GET['id'];
?>
<!--- VIEW PROJECT BREAKDOWN --->
<h2>View Individual Project Details</h2>
<div id="main_table">
		<table class="class1" cellspacing="0" cellpadding="2">
				<tr class="tablehead">
					<th class="tablehead" width="7%">Create Date</th>
					<th class="tablehead" style="text-align:left;" width="24%">Project Name</th>
					<th class="tablehead" width="12%">Status</th>
					<th class="tablehead" width="12%">Target Date</th>
					<th class="tablehead" width="7%">Time Spent</th>
					<th class="tablehead" width="7%">New Payment</th>
					<th class="tablehead" width="7%">Paid to Date</th>
					<th class="tablehead" width="8%">Amount Due</th>
					<th class="tablehead" width="3%">&nbsp;</th>
					<th class="tablehead" width="3%">&nbsp;</th>
				</tr>
<?php
include 'scripts/db.php';

   // connect to mysql
   $connection=mysql_connect($hostName,$username,$password)
   or die("Unable to connect to SQL Server");
   // connect to database
	mysql_select_db($databaseName,$connection)
	or die("Unable to select database");
		
	// query
	$query = "SELECT * from ".$d_ext."projects WHERE project_name='$project_id';";

	// run query
	$result=mysql_query($query, $connection)
	or die("Unable to run query on database");
	// fetch results
	$rowCheck=0;
	for ($rowCounter = 0;$row = @ mysql_fetch_array($result);$rowCounter++) 
	{
	echo "\n<tr>";	
	echo "\n<form method=\"post\" action=\"scripts/updateproject.php\">";
	$create_date=date_sort($row['Project_Create_Date']);
	echo "\n<td class=\"class1\">" . $create_date . "</td>";
	echo "\n<td class=\"class1\" style=\"text-align:left;\" title=\"" . stripslashes($row['Project_Description']) . "\">" . stripslashes($row['project_name']) . "</td>";
	echo "\n<td class=\"class1\"><select name=\"proj_status\" id=\"proj_status\">";
	echo "\n<option";
	load_statuses($row['Project_Status']);
	echo "\n</select></td>";
	$target=$row['Project_Target_Date'];
	$day=substr($target,8,2);
	$mth=substr($target,5,2);
	$year=substr($target,2,2);
	$target_date=$day."/".$mth."/".$year;
	$today = date("Y-m-d");
	echo "\n<td><input";
	if (($row['Project_Status']<>"Archive")&($row['Project_Status']<>"Suspended")&($row['Project_Status']<>"Completed"))
	{
	if ($target<$today) echo " class=\"past_target\"";
	if ($target==$today) echo " class=\"due_today\"";
	}
	else echo " class=\"no_target\"";	
	$target=date_sort($row['Project_Target_Date']);
	echo " name=\"proj_target\" id=\"proj_target\" type=\"text\" size=\"7\" maxlength=\"8\" value=\"" . $target . "\" /></td>";
	$hrs=floor($row['Project_Time']/60);
	$mins=$row['Project_Time']%60;
	echo "\n<td>" . $hrs . "h:" . $mins . "m</td>";
	echo "\n<td class=\"class1\"><input type=\"text\" name=\"proj_payt\" id=\"proj_payt\" size=\"4\" maxlength=\"8\" /></td>";
	echo "\n<td class=\"class1\">" . $row['Project_Paid_to_Date'] . "</td>";
	$Project_Due=calculate_total($row['project_name']);
	$Project_Due-=$row['Project_Paid_to_Date'];
	$Project_Due=number_format($Project_Due, 2, '.', '');
	echo "\n<td class=\"class1\">" . $Project_Due . "</td>";
	echo "<input type=\"hidden\" name=\"proj_paid\" id=\"proj_paid\" value=\"" . $row['Project_Paid_to_Date'] . "\">";
	echo "<input type=\"hidden\" name=\"proj_ref\" id=\"proj_ref\" value=\"" . $row['project_ref'] . "\">";
	echo "\n<td class=\"class1\"><input type=\"image\" src=\"images/button_update.gif\" style=\"margin-right:5px;border:0;\" alt=\"Update\"></td>";
	if($row['Project_Time']==0)
	echo "\n<td class=\"class1\"><img src=\"images/button_delete.gif\" alt=\"Delete\" onclick=\"delete_project(" . $row['project_ref'] . ");\" /></td>";
	else echo "\n<td class=\"class1\">&nbsp;</td>";		
	echo "</form></tr>";
	}
	// close database connection
	mysql_close($connection);
?>	
			</table>

<!---/ VIEW PROJECT BREAKDOWN --->
<!--- VIEW TASK BREAKDOWN --->
<h2>View Individual Task Details</h2>
<table cellspacing="0" cellpadding="2">
		<tr>
			<th class="tablehead" width="8%">Create Date</th>
			<th class="tablehead" style="text-align:left" width="20%">Task</th>
			<th class="tablehead" style="text-align:left" width="20%">Project</th>
			<th class="tablehead" width="14%">Status</th>
			<th class="tablehead" width="10%">Target Date</th>
			<th class="tablehead" width="10%">Time Taken (mins)</th>
			<th class="tablehead" width="12%">Total Time</th>
			<th class="tablehead" width="12%">Amount Due</th>
			<th class="tablehead" width="3%">&nbsp;</th>
			<th class="tablehead" width="3%">&nbsp;</th>
		</tr>
<?php
include 'scripts/db.php';

   // connect to mysql
   $connection=mysql_connect($hostName,$username,$password)
   or die("Unable to connect to SQL Server");
   // connect to database
	mysql_select_db($databaseName,$connection)
	or die("Unable to select database");
		
	// query
	$query = "SELECT * from ".$d_ext."tasks WHERE Task_Project_ID='$project_id' ORDER BY Task_Target_Date;";

	// run query
	$result=mysql_query($query, $connection)
	or die("Unable to run query on database");
	// fetch results
	$rowCheck=0;
	for ($rowCounter = 0;$row = @ mysql_fetch_array($result);$rowCounter++) 
	{
	echo "\n<form method=\"post\" action=\"scripts/updatetask.php\">";
	if(($rowCheck%2)==1)
	$color_class="class1";
	else
	$color_class="class2";
	echo "<tr>";
	$rowCheck++;	
	$create_date=date_sort($row['Task_Date_Created']);
	echo "\n<td class=\"".$color_class."\">" . $create_date . "</td>";
	echo "\n<td class=\"".$color_class."\" style=\"text-align:left;\" title=\"" . stripslashes($row['Task_Description']) . "\"><a href=\"viewtask.php?id=" . $row['Task_Ref']."\">" . stripslashes($row['Task_Name']) . "</a></td>";
	echo "\n<td class=\"".$color_class."\" style=\"text-align:left;\">" . $row["Task_Project_ID"] . "</td>";	
	echo "\n<td class=\"".$color_class."\"><select id=\"task_status\" name=\"task_status\">";
	load_statuses($row['Task_Status']);
	echo "\n</select></td>";
	$target=$row['Task_Target_Date'];
	$day=substr($target,8,2);
	$mth=substr($target,5,2);
	$year=substr($target,2,2);
	$target_date=$day."/".$mth."/".$year;
	$today = date("Y-m-d"); 
	echo "\n<td class=\"".$color_class."\"><input";
	if (($row['Task_Status']<>"Archive")&($row['Task_Status']<>"Suspended")&($row['Task_Status']<>"Completed"))
	{
	if ($target<$today) echo " class=\"past_target\"";
	if ($target==$today) echo " class=\"due_today\"";
	}
	else echo " class=\"no_target\"";
	$target_date=date_sort($row['Task_Target_Date']);
	echo " id=\"task_target\" name=\"task_target\" type=\"text\" size=\"7\" maxlength=\"8\" value=\"" . $target_date . "\" /></td>";
	echo "\n<td class=\"".$color_class."\"><input id=\"task_time\" name=\"task_time\" type=\"text\" size=\"4\" value=\"0\" maxlength=\"5\" /></td>";
	$hrs=floor($row['Task_Time_Spent']/60);
	$mins=$row['Task_Time_Spent']%60;
	echo "\n<td class=\"".$color_class."\">" . $hrs . "h:" . $mins . "m</td>";
	echo "<input type=\"hidden\" id=\"task_id\" name=\"task_id\" value=\"" . $row['Task_Ref'] . "\" >";
	echo "<input type=\"hidden\" id=\"task_total\" name=\"task_total\" value=\"" . $row['Task_Time_Spent'] . "\" >";
	echo "<input type=\"hidden\" id=\"task_project\" name=\"task_project\" value=\"" . $row['Task_Project_ID'] . "\" >";
	$Task_Due=($row['Flat_fee']+($row['Hourly_rate']*($row['Task_Time_Spent']/60)));
	$Task_Due=number_format($Task_Due, 2, '.', '');
	echo "\n<td class=\"".$color_class."\">" . $Task_Due;
	echo "</td>";
	echo "\n<td class=\"".$color_class."\"><input type=\"image\" src=\"images/button_update.gif\" style=\"margin-right:5px;border:0;\" alt=\"Update\"></td>";
	if($row['Task_Time_Spent']==0)
	echo "\n<td class=\"".$color_class."\"><img src=\"images/button_delete.gif\" alt=\"Delete\" onclick=\"delete_task(" . $row['Task_Ref'] . ");\" /></td>";
	else echo "\n<td class=\"".$color_class."\">&nbsp;</td>";
	echo "</tr></form>";
	}
	// close database connection
	mysql_close($connection);
?>	
	</table>
</div>
<!---/ VIEW TASK BREAKDOWN --->
</div>
<!---/ MAIN CONTENT AREA --->
<?php
include "includes/footer.php";
?>
Return current item: PHP Project Manager