-
Notifications
You must be signed in to change notification settings - Fork 0
/
bible_stock.php
183 lines (124 loc) · 4.46 KB
/
bible_stock.php
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?php
include('dbcon.php');
include('layout.php');
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Bible stock </title>
</head>
<body>
<div class="container_content" id= "table-id" align="center">
<div >
<br>
</div>
<br>
<br>
<br>
<label for="Search"><strong>Search</strong></label>
<input type="text" name="search" id="search" placeholder="search..." size="115px" class="table-filter" data-table="order-table" align="center" />
<table class="order-table" align="center" >
<tr><th>Number</th><th>Name</th><th>Category</th><th>Testament</th><th>Description</th><th>Balance</th><th>Action</th></tr>
<?php
class TableRows extends RecursiveIteratorIterator {
function __construct($it) {
parent::__construct($it, self::LEAVES_ONLY);
}
function current() {
return "<td style='width: 150px; border: 1px solid black;'>" . parent::current(). "</td>";
}
function beginChildren() {
echo "<tr>";
}
function endChildren() {
echo "</tr>" . "\n";
}
}
try { $sql = "SELECT A.item_id, A.name, A.category,A.testament, A.description,B.CurrentBalance, B.transTime
FROM biblestock A
INNER JOIN items_transaction B
ON A.item_id= B.ItemId WHERE (item_id, transTime )IN
(SELECT item_id, MAX(C.transTime) AS lastdate
FROM items_transaction C
GROUP BY C.ItemId) ORDER BY item_id ASC" ;
// try { $sql = "SELECT * from biblestock ORDER BY record_id" ;
$result = mysqli_query($conn, $sql)or die (mysqli_error($conn));
while ($row = mysqli_fetch_assoc( $result )) {
$item_id=$row['item_id'];
$name=$row['name'];
$category=$row['category'];
$testament=$row['testament'];
$description=$row['description'];
$bal=$row['CurrentBalance'];
If ($bal<=0){$issue="Hidden";}
else{$issue="";}
echo '<td>'. $row['item_id'].'</td>';
echo '<td>'. $row['name'].'</td>';
echo '<td>'. $row['category'].'</td>';
echo '<td>'. $row['testament'].'</td>';
echo '<td>'. $row['description'].'</td>';
echo '<td>'. $row['CurrentBalance'].'</td>';
echo '<td></td>';
echo '<td>
<div class="dropdown">
<button class="dropbtn">...</button>
<div class="dropdown-content">
<li><a href="inStock.php?name='.$name.' &catid='.$item_id.'">Received copies</a></li>
<li><a href="stock_assigning.php?name='.$name.' &catid='.$item_id.'">Issue copies</a></li>
</div>
</div>
</td>';
echo'</tr>';
}
}
catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
echo'</table>';
?>
</div>
<script>
(function() {
'use strict';
var TableFilter = (function() {
var Arr = Array.prototype;
var input;
function onInputEvent(e) {
input = e.target;
var table1 = document.getElementsByClassName(input.getAttribute('data-table'));
Arr.forEach.call(table1, function(table) {
Arr.forEach.call(table.tBodies, function(tbody) {
Arr.forEach.call(tbody.rows, filter);
});
});
}
function filter(row) {
var text = row.textContent.toLowerCase();
//console.log(text);
var val = input.value.toLowerCase();
//console.log(val);
row.style.display = text.indexOf(val) === -1 ? 'none' : 'table-row';
}
return {
init: function() {
var inputs = document.getElementsByClassName('table-filter');
Arr.forEach.call(inputs, function(input) {
input.oninput = onInputEvent;
});
}
};
})();
/*console.log(document.readyState);
document.addEventListener('readystatechange', function() {
if (document.readyState === 'complete') {
console.log(document.readyState);
TableFilter.init();
}
}); */
TableFilter.init();
})();
</script>
</table>
</body>
</html>