<?php
/************************************************
* Book browse page
* maintained by: Raymond Lai
* last update: 29 Jan 2001
* Input: Nil
* Output: Nil
* Purpose: To list all available books
* in the databas
************************************************/
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("book_request_items");
include("$lang.inc");
mysql_connect ($dbhost, $dbuser, $dbpasswd);
$count_query = "select count(*) from books";
$result = mysql_db_query($dbname, $count_query);
if($row = mysql_fetch_array($result))
{
$num_rows = $row[0];
}
else
{
print "No records found.";
mysql_free_result($result);
}
// next determine if page has been passed to script, if not use 1
if (empty($page))
{
$page = 1;
}
$offset = $records_per_page * ($page - 1);
// calculate number of pages needing links
$numpages = intval($num_rows / $records_per_page);
$query = "select bookID, book_name, book_author, book_isbn, book_yrOfPub, book_publisher, book_status from books, _all_items where item_deprecated='N'";
if($sortby)
{
$query .= " order by $sortby";
}
if($sortorder)
{
$query .= " $sortorder";
}
// get results
$result = mysql_db_query($dbname, "$query limit $offset,$records_per_page");
// $numpages now contains int of pages needed unless there is a remainder from division
if ($num_rows % $records_per_page)
{
// has remainder so add one page
$numpages++;
}
?>
<html>
<head>
<title><?php print $msg_browse_book_title; ?></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 align="center" valign="top">
<!--- ©O«×¥ý«Y¦U¦ìÂ\ content¬J¦a¤è --->
<table width="90%" border="0" cellspacing="0" cellpadding="5">
<tr valign="top">
<td colspan="6"><h3 class="heading"><?php print $msg_browse_book_title; ?></h3></td>
</tr>
<tr>
<td colspan="3" height="30"><span class="text12px"><?php print $msg_user;?></span><span class="text12pxbold"><?php print $name; ?></span></td>
<?php
if(!empty($book_request_items))
{
?>
<td colspan="3"><a class="textlink" href="user_view_book_requesttray.php"><?php print $msg_browse_book_view_list; ?></a></td>
<?php
}
else
{
?>
<td colspan="3"> </td>
<?php
}
?>
</tr>
<tr>
<td height="30" width="25%"><?php print $msg_browse_book_search; ?></td>
<form action="user_search_books.php">
<td width="25%" align="center" colspan="2">
<input type="text" name="qs">
</td>
<td width="25%" align="center">
<select name="qstype">
<option value="book_name"><?php print $msg_browse_book_search_bookname; ?></option>
<option value="book_keyword"><?php print $msg_browse_book_search_keyword; ?></option>
</select>
</td>
<td width="25%" colspan="2">
<input type="submit" name="Submit" value="Search">
</td>
</form>
</tr>
<tr>
<td colspan="6"><?php printf($msg_browse_book_total, $num_rows, $page, $numpages); ?></td>
</tr>
<tr>
<td colspan="4">
<a class="textlink" href="<?php print "$PHP_SELF?page=$page&sortby=book_name"; ?>"><?php print $msg_browse_book_name_header; ?></a>
<a class="textlink" href="<?php print "$PHP_SELF?page=$page&sortby=book_name&sortorder=asc"; ?>"><img src="../image/plus.gif" alt="<?php print $msg_plus; ?>" border="0"></a>
<a class="textlink" href="<?php print "$PHP_SELF?page=$page&sortby=book_name&sortorder=desc"; ?>"><img src="../image/minus.gif" alt="<?php print $msg_minus; ?>" border="0"></a>
</td>
<td colspan="2">
<a class="textlink" href="<?php print "$PHP_SELF?page=$page&sortby=book_status"; ?>"><?php print $msg_browse_book_status_header; ?></a>
<a href="<?php print "$PHP_SELF?page=$page&sortby=book_status&sortorder=asc"; ?>"><img src="../image/plus.gif" alt="<?php print $msg_plus; ?>" border="0"></a>
<a href="<?php print "$PHP_SELF?page=$page&sortby=book_status&sortorder=desc"; ?>"><img src="../image/minus.gif" alt="<?php print $msg_minus; ?>" border="0"></a>
</td>
</tr>
<?php
// now you can display the results returned
$rowcolor = $major_color;
while($row = mysql_fetch_array($result))
{
if($rowcolor == $minor_color)
$rowcolor = $major_color;
else
$rowcolor = $minor_color;
print "\t\t\t\t<tr bgcolor=\"$rowcolor\">\n";
print "\t\t\t\t\t<td colspan=\"4\" width=\"70%\"><a class=\"textlink\" href=\"#\" onClick=\"showDetails('book', '" . $row["bookID"] . "', 601, 550)\">". $row["book_name"] . "</a><br>\n";
print "\t\t\t\t\t\t$msg_book_author". $row["book_author"] ."<br>\n";
print "\t\t\t\t\t\t$msg_book_publisher". $row["book_publisher"] ."<br>\n";
print "\t\t\t\t\t\t$msg_book_yop" .$row["book_yrOfPub"] ."<br>\n";
print "\t\t\t\t\t\t$msg_book_isbn". $row["book_isbn"] ."<br>\n";
print "\t\t\t\t\t</td>\n";
if($row["book_status"] == "on shelf")
print "\t\t\t\t\t<td width=\"30%\" colspan=\"2\" nowrap><a class=\"textlink\" href=\"user_book_add2req.php?bookid=". $row["bookID"] . "\">$msg_browse_book_add_to_list</a></td>\n";
else
print "\t\t\t\t\t<td width=\"30%\" colspan=\"2\" nowrap>". $row["book_status"] . "</td>\n";
print "\t\t\t\t</tr>\n";
}
?>
<tr height="20">
<td colspan="3" align="right">
<?php
if ($page > 1)
{
// bypass PREV link if offset is 0
$refpage = $page - 1;
print "\t\t\t<a href=\"$PHP_SELF?page=$regpage\" class=\"textlink\"><img src=\"../image/previous.png\" border=\"0\" alt=\"$msg_previous_page\"></a>\n";
}
else
{
print "\t\t\t \n";
}
// check to see if last page
?>
</td>
<td colspan="3" align="left">
<?php
if ($page < $numpages)
{
// not last page so give NEXT link
$refpage = $page + 1;
print "\t\t\t<a href=\"$PHP_SELF?page=$refpage\" class=\"textlink\"><img src=\"../image/next.png\" border=\"0\" alt=\"$msg_next_page\"></a>\n";
}
else
{
print "\t\t\t \n";
}
?>
</td>
</tr>
</table>
<!--- °O¦í, ¥u«Y©O«×!!!! --->
</td>
</tr>
</table>
</body>
</html>