Location: PHPKode > projects > Online Resource Management system > storms/user/welcome.php
<?php

/************************************************
 *   User main screen
 *   maintained by: Raymond Lai
 *   created: 1 Feb 2001
 *   last update: 11 Feb 2001
 *   Input: Nil
 *   Output: Nil
 *   Purpose: Main page of the system for users
 ************************************************/

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");

include("$lang.inc");

mysql_connect($dbhost, $dbuser, $dbpasswd);


$bookloan_query = "SELECT books.bookID, book_transaction.book_transaction_duedate, books.book_name, "
		 ."to_days(now()) > to_days(book_transaction.book_transaction_duedate) as overdue "
		 ."FROM book_transaction, book_transactionitems, books, users "
		 ."WHERE ((users.user_acct ='$username') "
		 ."AND(book_transaction.book_transactionID = book_transactionitems.book_transactionID) "
		 ."AND(book_transaction.userID =users.userID) "
		 ."AND(book_transactionitems.bookID =books.bookID) "
		 ."AND(book_transactionitems.book_returned = 'N')) "
		 ."ORDER BY book_transaction.book_transaction_duedate ASC";
$bookloan_result = mysql_db_query($dbname, $bookloan_query);
$bookloan_numrows = mysql_num_rows($bookloan_result);

$bookhold_query = "SELECT book_temp_borrow.bookID, books.book_name "
		 ."FROM book_temp_borrow, books, users "
		 ."WHERE ((book_temp_borrow.bookID = books.bookID) "
		 ."AND (book_temp_borrow.userID = users.userID) "
		 ."AND (users.user_acct ='$username')) "
		 ."ORDER BY books.bookID ASC";
$bookhold_result = mysql_db_query($dbname, $bookhold_query);
$bookhold_numrows = mysql_num_rows($bookhold_result);

$swloan_query = "SELECT software.softwareID, software.software_name "
	       ."FROM software, software_transaction, software_transactionitems, users "
	       ."WHERE ((software_transaction.software_transactionID = software_transactionitems.software_transactionID) "
	       ."AND(software_transactionitems.softwareID =software.softwareID) "
	       ."AND(software_transaction.userID =users.userID) "
	       ."AND(users.user_acct ='$username') "
	       ."AND(software_transactionitems.software_returned = 'N') "
	       ."AND(software.software_status = 'borrowed'))";

$swloan_result = mysql_db_query($dbname, $swloan_query);
$swloan_numrows = mysql_num_rows($swloan_result);

$hwloan_query = "SELECT hardware.hardwareID, hardware.hardware_name "
	       ."FROM hardware, hardware_transaction, hardware_transactionitems, users "
	       ."WHERE ((hardware_transaction.hardware_transactionID = hardware_transactionitems.hardware_transactionID) "
	       ."AND(hardware_transactionitems.hardwareID =hardware.hardwareID) "
	       ."AND(hardware_transaction.userID =users.userID) "
	       ."AND(users.user_acct ='$username') "
	       ."AND(hardware_transactionitems.hardware_returned = 'N') "
	       ."AND(hardware.hardware_status = 'borrowed'))";

$hwloan_result = mysql_db_query($dbname, $hwloan_query);
$hwloan_numrows = mysql_num_rows($hwloan_result);

$rmbooking_query = "select dayname(room_booking_start_time) as weekday, "
		  ."date_format(room_booking_start_time, '%D %M %Y (%W)') as date, "
		  ."date_format(room_booking_start_time, '%k:%i') as start_time, "
		  ."date_format(room_booking_end_time, '%k:%i') as end_time, "
		  ."rooms.room_code, "
		  ."bookings.room_bookingID, "
		  ."bookings.room_booking_type "
		  ."from bookings, rooms, users "
		  ."where bookings.room_booking_start_time >= current_date "
		  ."and bookings.room_booking_start_time <= date_add(current_date, interval 7 day) "
		  ."and users.userID = bookings.userID "
		  ."and rooms.roomID = bookings.roomID "
		  ."and users.user_acct = '$username'";

$rmbooking_result = mysql_db_query($dbname, $rmbooking_query);
$rmbooking_numrows = mysql_num_rows($rmbooking_result);

?>
<html>
<head>
<title>STCP resource control system</title>
<?php print $doc_encoding; ?>
<link rel="stylesheet" href="../style_<?php print $lang; ?>.css" type="text/css">
</head>
<script language="javaScript" type="text/javascript" SRC="../js/details_window.js"></SCRIPT>
<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"> 
	<!--- ©O«×«Y menu¬J¦ì¸m. ­ø¦nÕi©O«×! --->
<?php include("menu.inc"); ?>
	<!--- ¤W­±«YÂ\ menu¬J¦a¤è! --->
	</td>
	<td valign="top" align="center"> 
	<!--- ©O«×¥ý«Y¦U¦ìÂ\ content¬J¦a¤è --->		
        <table width="95%" border="0" cellpadding="3">
	<tr valign="top">
		<td height="50" class="heading"><?php printf ($msg_welcome, $name); ?></td>
	</tr>
	<tr>
	<th valign="bottom" align="left" height="30" colspan="2" class="subheading">Books</th>
        </tr>
	<tr>
		<td colspan="2">
                                <table border="0" cellpadding="0" cellspacing="0" width="100%">
					<tr>
							<td width="36" height="30"><img src="../image/titleHeader_r1_c1.png" width="36" height="30" border="0"></td>
							<td height="30" background="../image/titleHeader_r1_c2.png" valign="bottom" width="100%" colspan="2"><span class="text12pxwhitebold"><?php printf ($msg_welcome_books_borrowed, $bookloan_numrows); ?></span></td>
							<td width="117" height="30"><img src="../image/titleHeader_r1_c3.png" width="117" height="30" border="0"></td>
					</tr>
<?php
if($bookloan_numrows)
{
?>
					<tr>
							<td width="36" height="40">&nbsp;</td>
							<td height="40" width="50%">Book name</td>
							<td height="40" width="50%">Due date</td>
							<td width="117" height="40">&nbsp;</td>
					</tr>
<?
	while($bookloan_rows = mysql_fetch_array($bookloan_result))
	{
		$textclass = ($bookloan_rows["overdue"]) ? "textoverdue" : "text12px";
		$linkclass = ($bookloan_rows["overdue"]) ? "textoverdue" : "textlink";
                print "\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td width=\"36\" height=\"20\">&nbsp;</td>\n";
		print "\t\t\t\t\t\t\t<td width=\"50%\" height=\"20\"><a class=\"$linkclass\" href=\"#\" onClick=\"showDetails('book', '" . $bookloan_rows["bookID"] . "', 601, 550); return false\">" . $bookloan_rows["book_name"] . "</a></td>\n";
		print "\t\t\t\t\t\t\t<td width=\"50%\" height=\"20\" class=\"$textclass\">" . $bookloan_rows["book_transaction_duedate"] . "</td>\n";
		print "\t\t\t\t\t\t\t<td width=\"117\">&nbsp;</td>\n";
		print "\t\t\t\t\t</tr>\n";
	}
}
?>
					</table>
		</td>
	</tr>
	<tr>
		<td colspan="2">
					<table border="0" cellpadding="0" cellspacing="0" width="100%">
						<tr>
							<td width="36" height="30"><img src="../image/titleHeader_r1_c1.png" width="36" height="30" border="0"></td>
							<td height="30" background="../image/titleHeader_r1_c2.png" valign="bottom" width="100%" colspan="2"><font color="#FFFFFF" size="3"><span class=text12pxwhitebold><?php printf($msg_welcome_books_held, $bookhold_numrows); ?></span></font></td>
							<td width="117" height="30"><img src="../image/titleHeader_r1_c3.png" width="117" height="30" border="0"></td>
						</tr>
<?php
if($bookhold_numrows)
{
?>
						<tr>
							<td width="36" height="40">&nbsp;</td>
							<td height="40" width="100%">Book name</td>
							<td width="117" height="40">&nbsp;</td>
						</tr>
<?php
	while($bookhold_rows = mysql_fetch_array($bookhold_result))
	{
                print "\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td width=\"36\" height=\"20\">&nbsp;</td>\n";
		print "\t\t\t\t\t\t\t<td width=\"100%\" height=\"20\"><a href=\"#\" onClick=\"showDetails('book', '" . $bookhold_rows["bookID"] . "', 601, 550); return false\" class=\"textlink\">" . $bookhold_rows["book_name"] . "</a></td>\n";
		print "\t\t\t\t\t\t\t<td width=\"117\" height=\"20\">&nbsp;</td>\n";
		print "\t\t\t\t\t</tr>\n";
	}
}
?>
						<tr>
							<td width="36" height="40">&nbsp;</td>
							<td width="100%" height="40"><a href="user_browse_books.php" class="textlink"><?php print $msg_welcome_browse_books; ?></a></td>
							<td width="117" height="40">&nbsp;</td>
						</tr>
					</table>
		</td>
	</tr>
	<tr>
	<th align="left" height="50" colspan="2" class="subheading">Software and hardware</th>
        </tr>
	<tr>
		<td colspan="2">
                                <table border="0" cellpadding="0" cellspacing="0" width="100%">
	                                <tr>
							<td width="36" height="30"><img src="../image/titleHeader_r1_c1.png" width="36" height="30" border="0"></td>
							<td height="30" background="../image/titleHeader_r1_c2.png" valign="bottom" width="100%" colspan="2"><font color="#FFFFFF" size="3"><span class=text12pxwhitebold><?php printf($msg_welcome_software_borrowed, $swloan_numrows); ?></span></font></td>
							<td width="117" height="30"><img src="../image/titleHeader_r1_c3.png" width="117" height="30" border="0"></td>
					</tr>
<?php
if($swloan_numrows)
{
?>
					<tr>
							<td width="36" height="40">&nbsp;</td>
							<td height="40" width="100%" colspan="2">Software name</td>
							<td width="117" height="40">&nbsp;</td>
					</tr>
<?php
	while($swloan_rows = mysql_fetch_array($swloan_result))
	{
	print "\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td width=\"36\" height=\"20\">&nbsp;</td>\n";
	print "\t\t\t\t\t\t\t<td width=\"100%\" colspan=\"2\"><a href=\"#\" onClick=\"showDetails('software', '" . $swloan_rows["softwareID"] . "', 601, 550); return false\" class=\"textlink\">" . $swloan_rows["software_name"] . "</a></td>\n";
	print "\t\t\t\t\t\t\t<td width=\"117\" height=\"20\">&nbsp;</td>\n";
	print "\t\t\t\t\t</tr>\n";
	}
}
?>
					</table>
		</td>
	</tr>
	<tr>
		<td colspan="2">
                                <table border="0" cellpadding="0" cellspacing="0" width="100%">
	                                <tr>
						<td width="36" height="30"><img src="../image/titleHeader_r1_c1.png" width="36" height="30" border="0"></td>
						<td height="30" background="../image/titleHeader_r1_c2.png" valign="bottom" width="100%" colspan="2"><font color="#FFFFFF" size="3"><span class=text12pxwhitebold><?php printf($msg_welcome_hardware_borrowed, $hwloan_numrows); ?></span></font></td>
						<td width="117" height="30"><img src="../image/titleHeader_r1_c3.png" width="117" height="30" border="0"></td>
					</tr>
<?php
if($hwloan_numrows)
{
?>
					<tr>
							<td width="36" height="40">&nbsp;</td>
							<td height="40" width="100%" colspan="2">Hardware name</td>
							<td width="117" height="40">&nbsp;</td>
					</tr>
<?php
	while($hwloan_rows = mysql_fetch_array($hwloan_result))
	{
		print "\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td width=\"36\" height=\"25\">&nbsp;</td>\n";
		print "\t\t\t\t\t\t\t<td width=\"100%\" colspan=\"2\" height=\"25\"><a href=\"#\" onClick=\"showDetails('hardware', '" . $hwloan_rows["hardwareID"] . "', 601, 550); return false\" class=\"textlink\">" . $hwloan_rows["hardware_name"] . "</a></td>\n";
		print "\t\t\t\t\t\t\t<td width=\"117\" height=\"25\">&nbsp;</td>\n";
		print "\t\t\t\t\t</tr>\n";
	}
}
?>
					<tr>
						<td width="36" height="40">&nbsp;</td>
						<td width="50%" height="40"><a href="user_browse_software.php" class="textlink"><?php print $msg_welcome_browse_software; ?></a></td>
						<td width="50%" height="40"><a href="user_browse_hardware.php" class="textlink"><?php print $msg_welcome_browse_hardware; ?></a></td>
						<td width="117" height="40">&nbsp;</td>
					</tr>
				</table>
		</td>
	</tr>
	<tr>
	<th align="left" height="50" colspan="2" class="subheading">Room booking system</th>
        </tr>
	<tr>
		<td colspan="2">
			<table border="0" cellpadding="0" cellspacing="0" width="100%">
				<tr>
					<td width="36" height="30"><img src="../image/titleHeader_r1_c1.png" width="36" height="30" border="0"></td>
					<td height="30" background="../image/titleHeader_r1_c2.png" valign="bottom" width="100%" colspan="6"><font color="#FFFFFF" size="3"><span class=text12pxwhitebold>You have booked these classrooms in the coming 7 days.</span></font></td>
					<td width="117" height="30" colspan="2"><img src="../image/titleHeader_r1_c3.png" width="117" height="30" border="0"></td>
				</tr>
<?php
if($rmbooking_numrows)
{
?>
				<tr>
					<td width="36" height="40">&nbsp;</td>
					<td height="40" width="20%">Date</td>
					<td height="40" width="20%">Room</td>
					<td height="40" width="20%">Start time</td>
					<td height="40" width="20%">End time</td>
					<td height="40" width="20%">Purpose</td>
					<td width="117" height="40">&nbsp;</td>
				</tr>
<?php
	while($rmbooking_rows = mysql_fetch_array($rmbooking_result))
	{
		print "\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td width=\"36\" height=\"20\">&nbsp;</td>\n";
		print "\t\t\t\t\t\t\t<td height=\"20\" width=\"20%\" class=\"text12px\">" . $rmbooking_rows["date"] . "</td>\n";
		print "\t\t\t\t\t\t\t<td height=\"20\" width=\"20%\" class=\"text12px\">" . $rmbooking_rows["room_code"] . "</td>\n";
		print "\t\t\t\t\t\t\t<td height=\"20\" width=\"20%\" class=\"text12px\">" . $rmbooking_rows["start_time"] . "</td>\n";
		print "\t\t\t\t\t\t\t<td height=\"20\" width=\"20%\" class=\"text12px\">" . $rmbooking_rows["end_time"] . "</td>\n";
		print "\t\t\t\t\t\t\t<td height=\"20\" width=\"20%\" class=\"text12px\">" . $rmbooking_rows["room_booking_type"] . "</td>\n";
		print "\t\t\t\t\t\t\t<td height=\"20\" width=\"50\"><a href=\"user_edit_room_booking.php?in_bookingID=" . $rmbooking_rows["room_bookingID"] ."\" class=\"textlink\">Edit</a></td>\n";
		print "\t\t\t\t\t\t\t<td height=\"20\" width=\"17\">&nbsp;</td>\n";
		print "\t\t\t\t\t\t\t<td height=\"20\" width=\"50\"><a href=\"user_delete_room_booking.php?in_bookingID=" . $rmbooking_rows["room_bookingID"] ."\" class=\"textlink\">Cancel<a/></td>\n";
		print "\t\t\t\t\t</tr>\n";
	}
}
?>
				<tr>
					<td width="36" height="40">&nbsp;</td>
					<td width="100%" height="40"><a href="user_room_booking_main.php" class="textlink">Room booking system</a></td>
					<td width="117" height="40">&nbsp;</td>
				</tr>
				</table>
		</td>
	</tr>
	</table>
	</td>
</tr>
</table>
</body>
</html>
Return current item: Online Resource Management system