Location: PHPKode > projects > Time Recording System > manageInvoice.php
<?
/*
	################################################################
	# >>> Time Recording System											#
	################################################################
	# > Authors:  Lucian Pricop and David Sturtevant					#
	# > E-mail:  hide@address.com						#
	# > Date: 	 17 April 2007											#
	#																			#
	# This web application allows your staff to submit their time	#
	# sheets on line 														#
	################################################################
	#	Copyright (C) 2007  Oxford Archaeology							#
	#																			#
	# This program is free software; you can redistribute 			#
	# it and/or modify it under the terms of the GNU General 		#
	# Public License as published by the Free Software 				#
	# Foundation; either version 2 of the License, or (at your	 	#
	# option) any later version.											#
	#																			#
	# This program is distributed in the hope that it will be 		#
	# useful, but WITHOUT ANY WARRANTY; without even the 				#
	# implied warranty of MERCHANTABILITY or FITNESS FOR A 			#
	# PARTICULAR PURPOSE.  See the GNU General Public License 		#
	# for more details.														#
	#																			#
	# You should have received a copy of the GNU General 				#
	# Public License along with this program; if not, write to 		#
	# the Free Software Foundation, Inc., 59 Temple Place - 			#
	# Suite 330, Boston, MA  02111-1307, USA.							#
	################################################################
*/
	require("header.php");
	function __autoload($class_name) {
		require_once $class_name . '.php';
	}
	if(!isset($_GET["invoicecode"]))
	{
		header("Location: index2.php?status=noinvoicespec");
		die();
	}
	$invoiceCode = rawurldecode(trim($_GET["invoicecode"]));
	
	$dbconn = new dbcontrol();
	$connectionStatus = $dbconn->connectdb();
	$queryString = "SELECT * FROM tbl_invoice_code_lookup WHERE invoicecode = '".pg_escape_string($invoiceCode)."'";
	$queryResult = $dbconn->sendquery2($queryString);
	$rowNr = $dbconn->numberofrows();
		
	if($rowNr == 0)
	{
		header("Location: index2.php?status=noinvoicefound");
		die();
	}
	$rowarray = pg_fetch_array($queryResult, null,PGSQL_ASSOC);
	if($_SESSION["refid".$privateKey] != intval($rowarray["projectmanager"]))
	{
		header("Location: index2.php?status=shnitzelmyster");
		die();
	}
	$projectName = $rowarray["projectname"];
	$department = $rowarray["department"];
	$completed = ( strcmp($rowarray["completed"],"t")==0 );
	$reqAuth = ( strcmp($rowarray["requiresauthorization"],"t")==0 );
	$taskNeeded = ( strcmp($rowarray["taskneeded"],"t")==0 );
		
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
        <title>Time Recording System</title>	
		<link href="favicon.ico" type="image/x-icon" rel="shortcut icon"/>
		<link rel='stylesheet' type='text/css' href='timesheets.css' />
		<script type="text/javascript" src="yui/build/yahoo/yahoo.js"></script>
		<script type="text/javascript" src="yui/build/dom/dom.js"></script>
		<script type="text/javascript" src="yui/build/event/event.js"></script>
		<script type="text/javascript" src="yui/build/connection/connection.js"></script>
		<script type="text/javascript" src="yui/build/animation/animation.js"></script>
		<script type="text/javascript" src="yui/build/autocomplete/autocomplete.js"></script>
		<script type="text/javascript" src="js/ajaxRequestModule.js"></script>
		<script type="text/javascript" src="js/manageInvoiceScript.js"></script>
		<script type="text/javascript" src="dojo/dojo.js"></script>
		<script>
			dojo.require("dojo.widget.Checkbox");
			dojo.hostenv.writeIncludes();
		</script>
	</head>
	<body>
		<div id="doc" class="yui-t1">
			<div id="hd">
				<h1>Time Recording System</h1>
			</div>
			<?require("mainMenu.php");?>
			<div id="bd">
				<div id="yui-main">
					<div class="navset" id="nav">
						<div class="hd" id="menuTop">
						</div>	
						<div class="bd" id="menuMiddle">
						</div>
						<div class="bd" id="menuBottom">
						</div>
					</div>	
					<div id='content'>
						<div id="mainFormContainer">
							<table class="FormTable">
								<tr>
									<td class="mainFormText" colspan="4"><h4>Edit invoice code details</h4></td>
								</tr>
								<tr>
									<td class="mainFormTextLabel" colspan="2">Invoice code</td>
									<td class="mainFormTextLabel" colspan="2"><input type="text" name="invoicecode" id="invoicecode" value="<?echo $invoiceCode?>" readonly="readonly"/></td>
								</tr>
								<tr>
									<td class="mainFormTextLabel" colspan="2">Project name</td>
									<td class="mainFormTextLabel" colspan="2"><input type="text" name="projectname" id="projectname" value="<?echo $projectName?>"/></td>
								</tr>
								<tr>
									<td class="mainFormTextLabel" colspan="2">Department</td>
									<td class="mainFormTextLabel" colspan="2">
										<select name="department" id="department"/>
										<?
											$queryString = "SELECT DISTINCT department FROM tbl_invoice_code_lookup ORDER BY department ASC";
											$queryResult = $dbconn->sendquery2($queryString);
											$rowNr = $dbconn->numberofrows();
											if($rowNr == 0)
												echo "<option value=\"-1\">none</option>\n";
											else
												for($i=0; $i<$rowNr ;++$i)
												{
													$rowarray = pg_fetch_array($queryResult, null,PGSQL_ASSOC);
													if(strcmp($rowarray["department"],"")==0)
														continue;
													if(strcmp($rowarray["department"],$department)==0)
														echo "\t\t\t<option selected=\"selected\" value=\"".$rowarray["department"]."\">".$rowarray["department"]."</option>\n";	
													else
														echo "\t\t\t<option value=\"".$rowarray["department"]."\">".$rowarray["department"]."</option>\n";
												}
										?>
										</select>
									</td>
								</tr>
								<tr>
									<td class="mainFormTextLabel" colspan="2">Completed</td>
									<td class="mainFormTextLabel" colspan="2"><input type="checkbox" name="completed" id="completed" <?if($completed) echo "checked=\"checked\"" ?>/></td>
								</tr>
								<tr>
									<td class="mainFormTextLabel" colspan="2">Task needed</td>
									<td class="mainFormTextLabel" colspan="2"><input type="checkbox" name="taskneeded" id="taskneeded" <?if($taskNeeded) echo "checked=\"checked\"" ?>/></td>
								</tr>
								<tr>
									<td class="mainFormTextLabel" colspan="2">Requires authorization</td>
									<td class="mainFormTextLabel" colspan="2"><input type="checkbox" name="reqauth" id="reqauth" <?if($reqAuth) echo "checked=\"checked\"" ?>/></td>
								</tr>
								<tr>
									<td class="mainFormTextLink" colspan="4" onclick="saveDetails(event)">Save details <span class="sidenote">(some changes may affect the task code list, you need to save so it can be updated) </span></td>
								</tr>
								<tr>
									<td class="mainFormText" id="statusDisplay" colspan="4">&nbsp;</td>
								</tr>
		
								<!-- task list section -->
								
								<?
								$queryString="SELECT tsk.taskcode,tsk.taskname FROM tbl_invoice_code_lookup i LEFT JOIN tbl_invoice_group_matrix g ON i.invoicecode = g.invoicecoderefid LEFT JOIN tbl_invoice_task_group it ON g.groupnamerefid = it.groupname LEFT JOIN tbl_task_group_matrix t ON it.groupname = t.groupnamerefid LEFT JOIN tbl_task_code_lookup tsk ON t.taskcoderefid = tsk.taskcode WHERE (i.invoicecode LIKE '".pg_escape_string($invoiceCode)."' OR i.invoicecode LIKE '".strtoupper(pg_escape_string($invoiceCode))."') ORDER BY t.taskcoderefid ASC";
								$queryResult = $dbconn->sendquery2($queryString);
								$rowNr = $dbconn->numberofrows();
								if($rowNr != 0)
								{
								?>
								<tr>
									<td class="mainFormTextLabel" colspan="2">
										Task code:
									</td>
									<td class="mainFormTextLabel">
										<input type="text" name="taskcode" id="taskcode" disabled="disabled"/><br/>
									</td>
									<td class="mainFormTextLink" style="width: 50px" onclick="addTask(event)" rowspan="2">add new</td>
								</tr>
								<tr>
									<td class="mainFormTextLabel" colspan="2">
										Task name:
									</td>
									<td class="mainFormTextLabel">
										<input type="text" name="taskname" id="taskname" disabled="disabled"/>
									</td>
								</tr>
								<tr>
									<td class="mainFormTextMenu" colspan="4">Related task code list</td>
								</tr>
								<tr>
									<td class="mainFormTextLabel" colspan="2">
										Task code:
									</td>
									<td class="mainFormTextLabel" >
										<input type="text" name="taskcodeEdit" id="taskcodeEdit" /><br/>
										<span class="sidenote">start typing a task code to see a list</span>
									</td>
									<td class="mainFormTextLink" id="editTaskDetails" onclick="editTask(event)" rowspan="2">edit</td>
								</tr>
								<tr>
									<td class="mainFormTextLabel" colspan="2">
										Task name:
									</td>
									<td class="mainFormTextLabel" >
										<input type="text" name="tasknameEdit" id="tasknameEdit" disabled="disabled"/>
									</td>
								</tr>
								<tr>
									<td colspan="4">
								    <div id="taskCodeEditDojoDiv" class="AutoCompleteResultContainer">
										<!--<table style="width: 100%; padding: 0px; margin: 0px">
								<?
									/*for($i = 0;$i< $rowNr ;++$i)
									{
										$rowarray = pg_fetch_array($queryResult, null,PGSQL_ASSOC);
										$taskCode = $rowarray["taskcode"];
										$taskName = $rowarray["taskname"];
										echo "\t\t\t\t\t\t\t\t<tr>\n";
										echo "\t\t\t\t\t\t\t\t\t<td class=\"mainFormTextLabel\">".$taskCode."</td>";
										echo "\t\t\t\t\t\t\t\t\t<td class=\"mainFormTextLabel\">".$taskName."</td>";
										echo "<td class=\"mainFormTextLink\" taskcode=\"".$taskCode."\" onclick=\"editTask(event)\">edit</td>\n";
										echo "<td class=\"mainFormTextLink\" taskcode=\"".$taskCode."\" onclick=\"deleteTask(event)\">delete</td>\n";
										echo "\t\t\t\t\t\t\t\t</tr>\n";
									} */
								}
								?> 		</table>-->
									</div>
									</td>
								</tr>
								<tr>
									<td class="mainFormText" colspan="4">&nbsp;</td>
								</tr>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>
		<?require("footer.php");?>
	</body>
</html>
Return current item: Time Recording System