-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreturn.php
More file actions
164 lines (143 loc) · 5.37 KB
/
Copy pathreturn.php
File metadata and controls
164 lines (143 loc) · 5.37 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
158
159
160
161
162
163
164
<?php
include_once('header.php');
if($role == 'kiosk'){
header("Location: index.php");
exit;
}
?>
<body class="landing-body">
<?php include_once('sidebar.php'); ?>
<div class="content">
<!-- CONTENT - RETURN -->
<section id="return">
<div class="return-search-container">
<div class="bar">
<h3>Return Book</h3>
</div>
<div class="body">
<div>
<p>Issue ID</p>
<input type="text" id="issueIDSearch" placeholder="BHI-----" required>
</div>
<div>
<p>Member ID</p>
<input type="text" id="memberIDSearch" placeholder="BHM-----" required>
</div>
<div>
<p>Book ID</p>
<input type="text" id="bookIDSearch" placeholder="BHB-----" required>
</div>
<button id="returnSearch">Search</button>
</div>
</div>
<div class="return-summary-container">
<div class="bar">
<h3>Return Summary</h3>
</div>
<div class="body">
<div>
<h3>Book Name</h3>
<p id="returnBookName"></p>
</div>
<div>
<h3>Author</h3>
<p id="returnBookAuthor"></p>
</div>
<div>
<h3>Member Name</h3>
<p id="returnMemberName"></p>
</div>
<div>
<h3>Issue Date</h3>
<p id="returnIssueDate"></p>
</div>
<div>
<h3>Issued By</h3>
<p id="returnIssuedBy"></p>
</div>
<div>
<button id="returnBookDetails">Details</button>
<button id="returnBookBtn">Return</button>
</div>
</div>
</div>
</section> <!-- RETURN ENDS -->
</div>
</body>
<?php include_once('footer.php'); ?>
<script>
// RETURN SEARCH
var issueID = "";
var bookID = "";
$("#returnSearch").click(function(){
let searchIssue = $("#issueIDSearch").val();
let searchMember = $("#memberIDSearch").val();
let searchBook = $("#bookIDSearch").val();
searchIssue = searchIssue.replace(/^BHI/, '');
searchMember = searchMember.replace(/^BHM/, '');
searchBook = searchBook.replace(/^BHB/, '');
if(searchIssue == "" || searchMember == "" || searchBook == "") return alert("Please fill all details");
console.log(searchIssue, searchMember, searchBook);
$.ajax({
url : "ajax/return.php",
method : "POST",
dataType : "json",
contentType : 'application/json',
data : JSON.stringify({"get" : "searchReturn", "issue" : searchIssue, "member" : searchMember, "book" : searchBook}),
success : function(data){
console.log(data);
if(data.length == 0) return alert("No Record Found");
issueID = data[0].issue_id;
bookID = data[0].book_id;
$(".return-summary-container").slideDown(200);
$("#returnBookName").text(data[0].book_name+"("+data[0].book_id+")");
$("#returnBookAuthor").text(data[0].author);
$("#returnMemberName").text(data[0].full_name +"("+data[0].member_id+")");
$("#returnIssueDate").text(data[0].issue_date);
$("#returnIssuedBy").text(data[0].issued_by);
},
error : function(err){
console.log(err);
}
})
})
$("#returnBookDetails").click(function(){
window.location.href = "issueDetails.php?id="+issueID;
})
// RETURN SET
$("#returnBookBtn").click(function(){
let sure = confirm("Return Book : "+$("#returnBookName").text());
if(!sure) return;
let returnedBy = "<?php echo $_SESSION['user_name']; ?>";
$.ajax({
url : "ajax/return.php",
method : "POST",
dataType : "json",
contentType : 'application/json',
data : JSON.stringify({"get" : "returnBook", "issueID" : issueID, "returnedBy" : returnedBy, "bookID" : bookID}),
success : function(data){
console.log(data);
window.location.href = "return.php?status=1";
},
error : function(err){
console.log(err);
}
})
})
const param = new URLSearchParams(window.location.search);
// RETURN VALUE FROM URL
if(param.get('bookID')){
$("#bookIDSearch").val(param.get('bookID'));
}
// TOASTIFY
if(param.get('status') == 1){
Toastify({
text: "Book returned successfully!",
duration: 3000,
gravity: "top",
position: "center",
stopOnFocus: true
}).showToast();
history.replaceState(null, "", window.location.pathname);
}
</script>