<!--
Pat and Inventory Management System
Version 2.0
Created by Tom Dyer
Last edited by Tom Dyer 16/1/10
Main (a) Page
-->
<?php
session_start(); // This connects an existing session
include_once '../../config.php';
$_SESSION['docroot'] = $directory;
$_SESSION['servroot'] = $servroot;
$barcode = $_SESSION['barcode'];
$name = $_SESSION['description'];
?>
<html>
<title>PIMS | Home Screen</title>
<body onLoad="document.input.barcode.focus()" LINK="0033CC" VLINK="0033CC">
<Head><link rel="shortcut icon" href="<?php echo "$servroot"; ?>/favicon.ico" type="image/x-icon"></Head>
<?php
mysql_connect($sqlhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM names ORDER BY name ASC";
$result=mysql_query($query);
$num=mysql_numrows($result);
?>
<h3>This item does not have a standard description</h3>
<h4>Please select a name from the list</h4>
<table border="0">
<form action="" method="post" name="input">
<input type="hidden" name="cmd" value="done"</input>
<tr><td>Barcode:</td><td><? echo "$barcode"; ?></td></tr>
<tr><td>Description:</td><td><? echo "$name"; ?></td></tr>
<tr>
<td>Pick Description: </td><td><SELECT id="name" name="name"><option value=pick>Don't Change Description</option><?php
$i=0;
while ($i < $num) {
$names=mysql_result($result,$i,"name");
echo '<option value="'.$names.'">'.$names.'</option>';
$i++;
}
?></select></td>
</tr><tr>
</table>
<input type="submit" value="Submit">
<br />
</form>
<?php
if ($_POST['cmd'] == 'done')
{
$newname = $_POST['name'];
if($newname == 'pick')
{
mysql_query("INSERT INTO `namechanged` VALUES ('', '$barcode')");
echo "No Change Made";
}
else
{
mysql_query("UPDATE equipment SET name = '$newname' WHERE barcode = '$barcode'");
echo "Changed Name";
}
ob_end_flush();
header('Location: index.php');
echo '<script language="javascript">window.location="index.php";</script>';
}
?>
</body>
</html>