<?php require_once('../Connections/viet.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $SERVER['PHP_SELF'];
if (isset($SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($POST["MM_insert"])) && ($POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO main_data (Date_of_work, Busines_name, Start_of_work, End_of_work, Total_time_worked, Who_did_the_work, Who_oked_the_work, What_was_done) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($POST['DWork'], "date"),
GetSQLValueString($POST['BName'], "text"),
GetSQLValueString($POST['SWork'], "date"),
GetSQLValueString($POST['EWork'], "date"),
GetSQLValueString($POST['TTWorked'], "text"),
GetSQLValueString($POST['EmployeeList'], "text"),
GetSQLValueString($POST['Approval'], "text"),
GetSQLValueString($POST['textfield'], "text"));
mysql_select_db($database_viet, $viet);
$Result1 = mysql_query($insertSQL, $viet) or die(mysql_error());
$insertGoTo = "ncs_completed.php";
if (isset($SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_viet, $viet);
$query_vinsert = "SELECT * FROM main_data";
$vinsert = mysql_query($query_vinsert, $viet) or die(mysql_error());
$row_vinsert = mysql_fetch_assoc($vinsert);
$totalRows_vinsert = mysql_num_rows($vinsert);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<div align="center">
<p>Please inset the data upon completing the work.
</p>
<p> </p>
<p> </p>
<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<p> </p>
<table width="100%" border="1">
<tr>
<th bgcolor="#CCCCCC" scope="col">Business Name</th>
<th bgcolor="#999999" scope="col">Business Phone number</th>
<th bgcolor="#999999" scope="col">Date of Work</th>
<th bgcolor="#999999" scope="col">Start of work</th>
<th bgcolor="#999999" scope="col">End of work</th>
<th bgcolor="#999999" scope="col">Total time worked</th>
</tr>
<tr>
<td><input name="BName" type="text" id="BName" value="<?php echo $row_vinsert['Busines_name']; ?>" /></td>
<td><input name="BNumber" type="text" id="BNumber" value="<?php echo $row_vinsert['Business_phone_number']; ?>" /></td>
<td><input name="DWork" type="text" id="DWork" value="<?php echo $row_vinsert['Date_of_work']; ?>" /></td>
<td><input name="SWork" type="text" id="SWork" value="<?php echo $row_vinsert['Start_of_work']; ?>" /></td>
<td><input name="EWork" type="text" id="EWork" value="<?php echo $row_vinsert['End_of_work']; ?>" /></td>
<td><input name="TTWorked" type="text" id="TTWorked" value="<?php echo $row_vinsert['Total_time_worked']; ?>" /></td>
</tr>
</table>
<table width="100%" border="1">
<tr>
<th width="16%" bgcolor="#999999" scope="col">Who did the work</th>
<th width="13%" bgcolor="#999999" scope="col">Who approved the job</th>
<th width="71%" bgcolor="#999999" scope="col">What was done</th>
</tr>
<tr>
<td><label for="EmployeeList">EmployeeList</label>
<select name="EmployeeList" id="EmployeeList">
<option value="Viet">Viet</option>
<option value="Daniel">Daniel</option>
<option value="Marek">Marek</option>
<option value="Chad">Chad</option>
<option value="Jose">Jose</option>
<option value="Other">Other</option>
<?php
do {
?>
<option value="<?php echo $row_vinsert['Who_did_the_work']?>"><?php echo $row_vinsert['Who_did_the_work']?></option>
<?php
} while ($row_vinsert = mysql_fetch_assoc($vinsert));
$rows = mysql_num_rows($vinsert);
if($rows > 0) {
mysql_data_seek($vinsert, 0);
$row_vinsert = mysql_fetch_assoc($vinsert);
}
?>
</select></td>
<td><input name="Approval" type="text" id="Approval" value="<?php echo $row_vinsert['Who_oked_the_work']; ?>" /></td>
<td><label for="textfield"></label>
<input name="textfield" type="text" id="textfield" value="<?php echo $row_vinsert['What_was_done']; ?>" size="100" /></td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<table width="50%" border="1">
<tr>
<th scope="col"><input type="reset" name="Clear" id="Clear" value="Clear" /></th>
<th scope="col"><input type="submit" name="Submit" id="Submit" value="Submit" /></th>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p> </p>
</div>
</body>
</html>
<?php
mysql_free_result($vinsert);
?>