<?php
/***************************************************
* File name: user_hardware_checkout.php
* Function: Check out user hardware requests
* Maintained by: Raymond Lai
* Last update: 3 May 2001
* Input : hardwareID stored at user session
* Output: online booking entries
* Purpose: To store user requested hardware to
* database, and update hardware_status to
* "reserved"
***************************************************/
include("../includes/session_mysql.inc");
include("../includes/global-vars.inc");
session_start();
session_register("user_class");
session_register("username");
session_register("name");
session_register("lang");
session_register("hardware_request_items");
include("$lang.inc");
mysql_connect($dbhost, $dbuser, $dbpasswd);
reset($hardware_request_items);
//get userID and user book loan quota
$user_query = "select userID from users where user_acct='$username'";
$userid_result = mysql_db_query($dbname, $user_query);
$userid = mysql_result($userid_result, 0, 0);
$z = 0;
while($array_prop = each($hardware_request_items))
{
$hardware_status_query = "select hardware_name, hardware_status from hardware where hardwareID = '". $array_prop["value"] . "'";
$hardware_status = mysql_db_query($dbname, $hardware_status_query);
if($hardware_status)
{
$row = mysql_fetch_array($hardware_status);
$hardware_reserve_result[$z]["hardware_name"] = $row["hardware_name"];
if($row["hardware_status"] == "reserved")
{
print "Cannot borrow";
break;
$hardware_reserve_result[$z]["result"] = "fail";
}
else
{
$hardwarereq_item_query = "insert into hardware_temp_borrow(hardwareID, userID) values (" . $array_prop["value"] . ", $userid)";
$hardwarestat_query = "update hardware set hardware_status = \"reserved\" where hardwareID = '". $array_prop["value"] . "'";
mysql_db_query($dbname, $hardwarereq_item_query);
mysql_db_query($dbname, $hardwarestat_query);
$hardware_reserve_result[$z]["result"] = "success";
}
}
$z++;
}
unset($hardware_request_items);
?>
<html>
<head>
<title><?php print $msg_tray_hardware_checkout; ?></title>
<?php print $doc_encoding; ?>
<link rel="stylesheet" href="../style.css" type="text/css">
</head>
<body bgcolor="#FFFFFF" text="#000000" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0" bottommargin="0" rightmargin="0">
<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="160" bgcolor="#FFFFFF" valign="top">
<?php include("menu.inc"); ?>
</td>
<td valign="top">
<table width="90%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td colspan="4">
<h3 class="heading"><?php print $msg_tray_hardware_checkout; ?></h3>
<span class="text10point"><?php print $msg_user; ?></span>
<span class="text10pointbold"><?php print $name; ?></span>
</td>
</tr>
<tr>
<td colspan="4"><?php print $msg_tray_hardware_checkout_result; ?></td>
</tr>
<?php
for($i=0; $i<count($hardware_reserve_result); $i++)
{
?>
<tr>
<td colspan="2"><?php print $hardware_reserve_result[$i]["hardware_name"]; ?></td>
<td colspan="2"><?php print $hardware_reserve_result[$i]["result"]; ?></td>
</tr>
<?php
}
?>
<tr>
<td colspan="4"><a href="welcome.php" class="textlink"><?php print $msg_option_home; ?></a></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>