-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathview.php
More file actions
147 lines (140 loc) · 6.1 KB
/
Copy pathview.php
File metadata and controls
147 lines (140 loc) · 6.1 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
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
td
{
border: solid windowtext 1.0pt;
padding: 4pt 4pt 4pt 4pt;
}
table
{
font-size:8.5pt;
font-family: Tahoma;
}
</style>
<title></title>
</head>
<body>
<?php
if (isset($_POST['submit'])){
$isbn = $_POST['isbn'];
echo "<h1 align=\"center\">Please Login</h1>";
if ($_POST['submit'] == "Remove"){ //show the fields for removal
echo <<<_END
<form action="view.php" method="POST">
<input type="hidden" name=isbn value=$isbn>
<input type="hidden" name=type value="Remove">
<p align=center>Admin's name<input type="text" name="admin">
Password<input type="password" name="pass"></p>
<p align=center><input type="submit" name="rsubmit" value="Submit">
</form>
_END;
}else{ //show the fields for checking in/out
echo <<<_END
<form action="view.php" method="POST">
<input type="hidden" name=isbn value=$isbn>
<input type="hidden" name=type value="{$_POST['submit']}">
<p align=center>Admin's name<input type="text" name="admin">
Password<input type="password" name="pass"></p>
<p align=center>User's name<input type="text" name="user"></p>
<p align=center><input type="submit" name="csubmit" value="Submit">
</form>
_END;
}
}else if(isset($_POST['csubmit']) || isset($_POST['rsubmit'])){
require_once 'UserInterface.php';
$ui = new UserInterface();
if($ui->postData() == 0){
echo "<h2 align=center>An error occurred</h2>";
}else{
echo "<h2 align=center>Success</h2>";
}
}else{ //display the book
require_once 'UserInterface.php';
$ui = new UserInterface();
if (isset($_POST['esubmit'])){ //edit the book then display it
if($ui->postData() == 0){
echo "<h2 align=center>An error occurred</h2>";
exit();
}else{
$_GET['isbn'] = $_POST['isbn'];
}
}else{
//if (empty($_GET['isbn'])){
//echo "<p align=center>Nothing to display</p>";
//exit();
//}
}
$book = $ui->getData();
$isbn = $_GET['isbn'];
$name = $book->getName();
$authors = $book->getAuthor()->getAuthor();
$publishers = $book->getPublisher()->getPublisher();
$pdate = $book->getPublisher()->getPublishDate();
$pcount = $book->getPCount();
$description = $book->getDescription();
$quantity = $book->getQuantity();
$avail = $book->getNumAvailable();
$thumbnail = $book->getThumbnailLink();
echo "<h1 align=\"center\">View Book<img src=\"$thumbnail\" alt=\"\" align=\"middle\" /></h1>";
echo <<<_END
<table align=center cellspacing=0 cellpadding=0 border=1 style="border: solid windowtext 1.0pt">
<tr>
<td><b>ISBN</td><td><b>Quantity</td><td><b>Availabe</td>
</tr>
<td>$isbn</td>
<td>$quantity</td>
<td>$avail</td>
</tr>
<tr>
<td><b>Title</td><td><b>Pages</td><td></td>
</tr>
<tr>
<td>$name</td><td>$pcount</td><td></td>
</tr>
<tr>
<td><b>Authors</td><td></td><td></td></tr><tr>
_END;
for($i=0; $i<3; $i++){
if ($i < count($authors)){
echo "<td>{$authors[$i]}</td>";
}else{
echo "<td></td>";
}
}
echo "</tr><tr><td><b>Publishers</td><td></td><td></td></tr><tr>";
for($i=0; $i<3; $i++){
if ($i < count($publishers)){
echo "<td>{$publishers[$i]}</td>";
}else{
echo "<td></td>";
}
}
echo "</tr><tr><td><b>Publish Date</td><td></td><td></td></tr><tr><td>$pdate</td><td></td><td></td></tr>";
echo "<tr><td><b>Description</td><td></td><td></td></tr><tr><td colspan=3><textarea readonly=\"readonly\" style=\"resize: none;\" cols=50 rows=5>$description</textarea></td></tr>";
echo "</table>";
echo <<<_END
<form action="edit.php" method="GET">
<input type="hidden" name=isbn value=$isbn>
<p align=center><input type="submit" name="submit" value="Edit"></p>
</form>
<form action="view.php" method="POST">
<input type="hidden" name=isbn value=$isbn>
<p align=center>
<input type="submit" name="submit" value="Checkout">
<input type="submit" name="submit" value="Check In">
<input type="submit" name="submit" value="Remove">
</p>
</form>
_END;
}
?>
<br><p align="center"><a href="main.php">Return to Main Page</a>
</body>
</html>