Skip to content

Commit

Permalink
Book availibility is visiible, book check out functionality has been …
Browse files Browse the repository at this point in the history
…added.
  • Loading branch information
nidhitvaishnav committed Mar 7, 2018
1 parent cb87d31 commit 26932c5
Show file tree
Hide file tree
Showing 6 changed files with 212 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
text_temp.php
count_temp.php
3 changes: 1 addition & 2 deletions AddBorrower.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
//echo $location;
include('add_borrower.html');

if(empty($FirstName) || empty($LastName) || empty($email) || empty($ssn))
if(empty($FirstName) || empty($LastName) || empty($email) || empty($ssn) || empty($address) || empty($city) || empty($state) || empty($contact) )
{

echo "fields are empty".'<br>';
header("Location:add_borrower.html");
}
else{
$ssn_query = "select * from borrowers where SSN like "."'$ssn'"."";
Expand Down
68 changes: 68 additions & 0 deletions addCardID.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Library Management System</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="default.css" rel="stylesheet" type="text/css" /></head>
<body>
<div id="header">
<h1><a href="#">Library Management System</a></h1>

</div>
<div id="content">
<div id="colOne">
<h2>Add the card id of borrower </h2>
<br />
<!-- <p><small>Management System</small></p>-->
<form method="post" action="borrow_book.php">
<div>
<p>
<input type="text" id="card_id" name="card_id" value="" size="50" />
<input type="submit" id="submit1" name="submit1" value="submit" />
</p>
</div>
</form>
<?php
//require 'db_open.php';
if(isset($_GET["isbn"]))
{
$ISBN = $_GET["isbn"];
session_start();
$_SESSION['ISBN']=$ISBN;
}
?>




</div>
<div id="colTwo">
<ul>
<li><a href="index.html" target="_self">logout</a>
</li>
<li>
<h2>Pages</h2>
<ul>
<li><a href="home.html">Home</a></li>
<li><a href="add_borrower.html">Add Borrower</a></li>
<li><a href="view_borrower.html">View Borrower details</a></li>
<li><a href="fines.html">Fines</a></li>
<li><a href="#"></a></li>
</ul>
</li>
<li>
<h2><a href="http://validator.w3.org/check/referer" title="This page validates as XHTML 1.0 Transitional"><abbr title="eXtensible HyperText Markup Language"></abbr></a></h2>
</li>
<li></li>
</ul>
</div>
<div style="clear: both;">&nbsp;</div>
</div>
<div id="footer">
<p>Created by: Nidhi Vaishnav, (ntv170030), CS 6360.003, University of Texas at Dallas <a href="http://www.csstemplatesforfree.com/"><strong></strong></a></p>
</div>


</body>
</html>
2 changes: 1 addition & 1 deletion add_borrower.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ <h2>Adding a borrower</h2>
<p><label></label></p>

<label>
<input name="upload" type="submit" id="upload" value=" Upload "></td>
<input name="upload" type="submit" id="upload" value=" Add Borrower "></td>
</label>
</p>
</form>
Expand Down
126 changes: 126 additions & 0 deletions borrow_book.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Library Management System</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="default.css" rel="stylesheet" type="text/css" /></head>
<body>
<div id="header">
<h1><a href="#">Library Management System</a></h1>

</div>
<div id="content">
<div id="colOne">
<h2>Add the card id of borrower </h2>
<br />
<!-- <p><small>Management System</small></p>-->

<?php
//require 'db_open.php';
//echo ($_SERVER['REQUEST_METHOD']);
session_start();
$ISBN = $_SESSION['ISBN'];
if(isset($_POST['card_id']))
{
$Card_id=$_POST['card_id'];

if(empty($Card_id))
{
echo "Card_id field is empty";
}
else
{
$db_name = 'Library';
$con = mysqli_connect('localhost', 'root', 'root', "$db_name") or die(mysql_error());
// $db = mysql_select_db('Library', $con);
$query = "select bl.ISBN, b.Title, bl.Date_out, bl.Due_date from book_loans as bl join book as b where bl.isbn=b.isbn and card_id='".$Card_id."' and date_in is null";
//echo($ISBN);
//echo ($query);

$result = mysqli_query($con, $query);

$avail_query = "select count(*) as count from book_loans where ISBN='".$ISBN."' and Date_in is null";

$avail_result = mysqli_query($con, $avail_query);
$avail_row = mysqli_fetch_assoc($avail_result);

for ( $i = 0 ; $i < mysqli_num_rows($result) ; $i++ )
{
$row = mysqli_fetch_assoc($result);

echo "<table>";
echo "<tr style='font-weight: bold;'>";
echo "</tr>";
echo "<table border='1' style='border-collapse: collapse;border-color: silver;'>";

echo "<tr>";

echo "</table>";
echo "<table>";
echo "<tr style='font-weight: bold;'>";

echo "</tr>";
echo "<table border='1' style='border-collapse: collapse;border-color: silver;'>";
echo "<tr>"."<td align='center'>".'Title'."</td>"."<td>".$row['Title'] ."</td> "."</tr>";
echo "<tr>"."<td align='center'>".'ISBN'."</td>"."<td>".$row['ISBN'] ."</td> "."</tr>";
echo "<tr>"."<td align='center'>".'Checkout Date'."</td>"."<td>".$row['Date_out'] ."</td> "."</tr>";
echo "<tr>"."<td align='center'>".'Due_date'."</td>"."<td>".$row['Due_date'] ."</td> "."</tr>";
echo "</table>".'<br>';
}

if (mysqli_num_rows($result) == 3)
{
echo "Sorry, Request declined. You have already borrowed 3 books<br>";
}
elseif($avail_row['count']!=0)
{
echo "Sorry, Request declined. Book is no longer available.<br>";
}
else
{
$insert_query = "insert into book_loans(ISBN, Card_id, Date_out, Due_date, Date_in) values('".$ISBN."', '".$Card_id."', current_date(), date_add(current_date(), interval 14 day), NULL)";
$insert_result = mysqli_query($con, $insert_query) or die('Card id is not valid');
mysqli_close($con);
echo "Book with $ISBN is checked out successfully with card id $Card_id".'<br>';
}

}
}
session_unset();
session_destroy();
?>




</div>
<div id="colTwo">
<ul>
<li><a href="index.html" target="_self">logout</a>
</li>
<li>
<h2>Pages</h2>
<ul>
<li><a href="home.html">Home</a></li>
<li><a href="add_borrower.html">Add Borrower</a></li>
<li><a href="view_borrower.html">View Borrower details</a></li>
<li><a href="fines.html">Fines</a></li>
<li><a href="#"></a></li>
</ul>
</li>
<li>
<h2><a href="http://validator.w3.org/check/referer" title="This page validates as XHTML 1.0 Transitional"><abbr title="eXtensible HyperText Markup Language"></abbr></a></h2>
</li>
<li></li>
</ul>
</div>
<div style="clear: both;">&nbsp;</div>
</div>
<div id="footer">
<p>Created by: Nidhi Vaishnav, (ntv170030), CS 6360.003, University of Texas at Dallas <a href="http://www.csstemplatesforfree.com/"><strong></strong></a></p>
</div>


</body>
</html>
21 changes: 15 additions & 6 deletions search.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
$db_name = 'Library';
$con = mysqli_connect('localhost', 'root', 'root', "$db_name") or die(mysql_error());
// $db = mysql_select_db('Library', $con);
$search='%'.$search.'%';
echo($search);
$WildSearch='%'.$search.'%';
//echo($search);
$query = "select b.ISBN, b.title, group_concat(a.Author_name) as author_name, b.cover, b.pages from book as b, book_authors as ba, authors as a Where b.ISBN=ba.ISBN and ba.Author_id=a.Author_id and
(a.Author_name like "."'$search'"." or b.isbn="."'$search'"." or b.Title like "."'$search'".") GROUP BY b.ISBN";
(a.Author_name like "."'$WildSearch'"." or b.isbn="."'$search'"." or b.Title like "."'$WildSearch'".") GROUP BY b.ISBN";

// echo ($query);

Expand All @@ -60,7 +60,11 @@
for ( $i = 0 ; $i < mysqli_num_rows($result) ; $i++ )
{
$row = mysqli_fetch_assoc($result);
echo "<table>";
$avail_query = "select count(*) as count from book_loans where ISBN='".$row['ISBN']."' and Date_in is null";

$avail_result = mysqli_query($con, $avail_query);
$avail_row = mysqli_fetch_assoc($avail_result);
echo "<table>";
echo "<tr style='font-weight: bold;'>";
echo "</tr>";
echo "<table border='1' style='border-collapse: collapse;border-color: silver;'>";
Expand All @@ -82,8 +86,13 @@
echo "<tr>"."<td align='center'>".'Author name'."</td>"."<td>".$row['author_name'] ."</td> "."</tr>";
echo "<tr>"."<td align='center'>".'cover'."</td>"."<td>".$row['cover'] ."</td> "."</tr>";
echo "<tr>"."<td align='center'>".'pages'."</td>"."<td>".$row['pages']."</td> "."</tr>";
echo "<tr>"."<td align='center'>".'Borrow'."</td>"."<td><a href=borrow_book.html>Borrow book"."</a>"."</td> "."</tr>";

if ($avail_row['count']==0)
{
echo "<tr>"."<td align='center'>".'Availability'."</td>"."<td><a href=addCardID.php?isbn=".$row['ISBN'].">Check out"."</a>"."</td> "."</tr>";
}
else{
echo "<tr>"."<td align='center'>".'Availability'."</td>"."<td>unavailable"."</td> "."</tr>";
}
echo "</table>".'<br>';
}
}
Expand Down

0 comments on commit 26932c5

Please sign in to comment.