-
Notifications
You must be signed in to change notification settings - Fork 0
/
tabel_history.php
224 lines (212 loc) · 7.14 KB
/
tabel_history.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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<?php
session_start();
if (isset($_POST['logout'])) {
session_destroy();
header("location:login.php?status=logout");
}
if (!isset($_SESSION['user_login'])) {
header("location:login.php");
}
include('connect.php');
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>HISTORI</title>
<link rel="shortcut icon" href="resource/icon.png" />
<link rel="stylesheet" href="resource/icon.css">
<link rel='stylesheet' href='resource/bootstrap.min.css'>
</head>
<STYLE>
body{
font-family: 'Trebuchet MS', serif;
}
.tableFixHead { overflow-y: auto; height: 500px; }
/* Just common table stuff. */
table { border-collapse: collapse; width: 100%; }
th, td { padding: 8px 16px; }
th { background:#eee; }
</STYLE>
<body>
<?php
include('resource/navbar.php');
?>
<div class="container-fluid">
<div class="row">
<div class="col-12 text-center" style="margin-top:30px;margin-bottom:20px;">
<h2 class='display-4'>HISTORI</h2>
</div>
</div>
<div class="row">
<div class="col-12" >
<div class="tableFixHead">
<table class='table table-hover' id="myTable" >
<thead>
<tr>
<th onclick="sortTable(0)">Nama Barang<i class="material-icons align-text-top">sort</i></th>
<th>Jumlah</th>
<th onclick="sortTable(2)">Tanggal Peminjaman<i class="material-icons align-text-top">sort</i></th>
<th onclick="sortTable(3)">Tanggal Kembali<i class="material-icons align-text-top">sort</i></th>
<th onclick="sortTable(4)">Nama Peminjam<i class="material-icons align-text-top">sort</i></th>
<th>Kontak Peminjam</th>
<th>Kontak Cadangan</th>
<th>Status</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
include 'connect.php';
$no = 1;
$data = mysqli_query($conn,"select * from history order by id_peminjaman desc");
$data1 = mysqli_query($conn,"select nama_barang from barang where id = id_barang");
while($d = mysqli_fetch_array($data)){
?>
<tr >
<?php
$id_brng = $d['id_barang'];
$data1 = mysqli_query($conn,"select nama_barang from barang where id = $id_brng");
$d1 = mysqli_fetch_array($data1);
?>
<td class='align-middle text-capitalize'><?php echo $d1['nama_barang']; ?></td>
<td class='align-middle'><?php echo $d['jumlah']; ?></td>
<?php
$newDate_pinjam = date("Y-m-d", strtotime($d['tanggal_peminjaman']));
?>
<td class='align-middle'><?php echo $newDate_pinjam; ?></td>
<?php
$newDate_kembali = date("Y-m-d", strtotime($d['tanggal_kembali']));
?>
<td class='align-middle'><?php echo $newDate_kembali; ?></td>
<td class='align-middle text-capitalize'><?php echo $d['nama_peminjam']; ?></td>
<td class='align-middle'><?php echo $d['kontak_peminjam']; ?></td>
<td class='align-middle'><?php echo $d['kontak_cadangan']; ?></td>
<td class='align-middle'>
<?php
//echo $d['kontak_cadangan'];
if ($d['status']==1) {
# code...
echo "<i class='material-icons align-text-top' style='color:green'>check</i>";
} else {
# code...
echo "<i class='material-icons align-text-top' style='color:red'>clear</i>";
}
?>
</td>
<td>
<button type="button" class="btn btn-danger" data-toggle="popover" data-trigger="focus" title="Jumlah barang rusak saat kembali" data-content="<?php echo $d['kondisi']; ?>">Info</button>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<script src="resource/jquery-3.3.1.slim.min.js" ></script>
<script src="resource/popper.min.js" ></script>
<script src="resource/bootstrap.min.js" ></script>
<script src="resource/bootstrap.bundle.min.js"></script>
<script type='text/javascript' src="resource/bootstrap-datepicker.min.js"></script>
<link rel="stylesheet" href="resource/bootstrap-datepicker3.css">
<script type='text/javascript'>
$('.popover-dismiss').popover({
trigger: 'focus'
});
$(function () {
$('[data-toggle="popover"]').popover()
});
$('.date').datepicker({
format: "yyyy",
startView : 2,
minViewMode: 2,
autoclose: true
});
</script>
<script>
// function myFunction() {
// var input, filter, table, tr, td, i, txtValue;
// input = document.getElementById("myInput");
// filter = input.value.toUpperCase();
// table = document.getElementById("myTable");
// tr = table.getElementsByTagName("tr");
// for (i = 0; i < tr.length; i++) {
// td = tr[i].getElementsByTagName("td")[4];
// if (td) {
// txtValue = td.textContent || td.innerText;
// if (txtValue.toUpperCase().indexOf(filter) > -1) {
// tr[i].style.display = "";
// } else {
// tr[i].style.display = "none";
// }
// }
// }
// }
function sortTable(n) {
var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0;
table = document.getElementById("myTable");
switching = true;
//Set the sorting direction to ascending:
dir = "asc";
/*Make a loop that will continue until
no switching has been done:*/
while (switching) {
//start by saying: no switching is done:
switching = false;
rows = table.rows;
/*Loop through all table rows (except the
first, which contains table headers):*/
for (i = 1; i < (rows.length - 1); i++) {
//start by saying there should be no switching:
shouldSwitch = false;
/*Get the two elements you want to compare,
one from current row and one from the next:*/
x = rows[i].getElementsByTagName("TD")[n];
y = rows[i + 1].getElementsByTagName("TD")[n];
/*check if the two rows should switch place,
based on the direction, asc or desc:*/
if (dir == "asc") {
if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) {
//if so, mark as a switch and break the loop:
shouldSwitch= true;
break;
}
} else if (dir == "desc") {
if (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase()) {
//if so, mark as a switch and break the loop:
shouldSwitch = true;
break;
}
}
}
if (shouldSwitch) {
/*If a switch has been marked, make the switch
and mark that a switch has been done:*/
rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
switching = true;
//Each time a switch is done, increase this count by 1:
switchcount ++;
} else {
/*If no switching has been done AND the direction is "asc",
set the direction to "desc" and run the while loop again.*/
if (switchcount == 0 && dir == "asc") {
dir = "desc";
switching = true;
}
}
}
}
</script>
<script>var $th = $('.tableFixHead').find('thead th')
$('.tableFixHead').on('scroll', function() {
$th.css('transform', 'translateY('+ this.scrollTop +'px)');
});
</script>
</body>
</html>