-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckIn.php
More file actions
157 lines (134 loc) · 5.99 KB
/
CheckIn.php
File metadata and controls
157 lines (134 loc) · 5.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<html>
<head> <center> <h1>Library Management System</h1> </center>
<link rel="stylesheet" type="text/css" href="style.css">
<title> Library Management System </title>
<body>
<h2><left><a href="Page1.html">Homepage</a></left></h2>
<h2><a href="fines.php">Fines</a></h2>
<form name="check" method="post">
<h1> <center> Check_In </center> </h1>
<center><table cellspacing="5">
<tr>
<td>Book Id: </td>
<td><input type="text" name="book_id" id="book_id"/> </td>
</tr>
<tr>
<td>Card No.: </td>
<td> <input type="text" name="cardno" id="cardno"/> </td>
</tr>
<tr>
<td colspan="2"><center> Borrower Name</center> </td>
</tr>
<tr>
<td>First Name: </td>
<td> <input type="text" name="fname" id="fname"/> </td>
</tr>
<tr>
<td>Last Name: </td>
<td> <input type="text" name="lname" id="lname"/> </td>
</tr>
<tr>
<td></td>
<td> <input type="submit" name="checkin" value="CheckIn"/></td>
</tr>
</table></center>
<br><br><br><br>
<?php
$con = mysql_connect("localhost", "root", "");
if ($con) {
mysql_select_db("library");
} else {
echo 'could not connect' . "<br/>";
}
if ($_POST) {
if (isset($_POST['checkin'])) {
checkIn();
}
}
function checkIn() {
$bookid = $_POST['book_id'];
$card = $_POST['cardno'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$query = "select a.book_id2, a.card_no,a.branch_id1,date_in, due_date, fname, lname from book_loans a inner join borrower c
on a.card_no = c.card_no and
(book_id2 LIKE '%$bookid%' or a.card_no = '%$card%' or fname LIKE '%$fname%' or
lname LIKE '%$lname%');";
if ($query === FALSE) {
echo "<script type='text/javascript'>alert('NO such book present');</script>";
mysql_error();
} else {
$query_test = mysql_query($query);
echo "<center><table cellspacing='10'>";
echo "<tr>";
echo "<th></th>";
echo "<th>Card No</th>";
//echo "<th> DateIn</th>";
echo "<th> Due Date</th>";
echo "<th>First Name </th>";
echo "<th>Last Name</th>";
echo "</tr>";
while ($rows = mysql_fetch_assoc($query_test)) {
echo "<tr>";
echo "<td><input type='radio' name='test' value='" . $rows['book_id2'] . " " . $rows['card_no'] . " " . $rows['branch_id1'] . " " . $rows['date_in'] . " " . $rows['due_date'] . " " . $rows['fname'] . " " . $rows['lname'] . "'></td>";
echo "<td>" . $rows['card_no'] . "</td>";
//echo "<td>" . $rows['date_in'] . "</td>";
echo "<td>" . $rows['due_date'] . "</td>";
echo "<td> <center>" . $rows['fname'] . " </center></td>";
echo "<td> <center>" . $rows['lname'] . " </center></td>";
echo "</tr>";
}
echo "<tr>";
echo "<td></td>";
echo "<td></td>";
echo "<td><input type='submit' name='test_val' value='submit'/></td>";
echo "</tr>";
echo "</table></center>";
}
}
?>
<?php
if ($_POST) {
if (isset($_POST['test_val'])) {
if(isset($_POST['test']))
{
checkin_display();
}
}
}
function checkin_display() {
$test = explode(" ", $_POST['test']);
$bookid = $test[0];
$card = $test[1];
$branchid = $test[2];
/* $datein = $test[2];
$duedate = $test[3];
$fname = $test[4];
$lname = $test[5];
*/
$queryin = "update book_loans
set date_in = current_date()
where book_id2 = '$bookid' and
card_no= '$card' and branch_id1 = '$branchid'";
mysql_query($queryin);
if ($queryin === FALSE) {
echo mysql_error();
} else {
$queryadd = "update book_copies
set no_of_copies = no_of_copies+1
where book_id = '$bookid' and branch_id= '$branchid'";
mysql_query($queryadd);
$query_check = "select date_in, due_date from book_loans where book_id2='$bookid' and
card_no='$card'";
$result = mysql_query($query_check);
while ($row = mysql_fetch_assoc($result)) {
if ($row['date_in'] > $row['due_date']) {
echo "<script type='text/javascript'> alert('You have exceeded the due date lookup fines table for late fee')</script>";
}
}
}
}
?>
</form>
</body>
</html>