-
Notifications
You must be signed in to change notification settings - Fork 0
/
quanlynhacungcap.php
241 lines (228 loc) · 11 KB
/
quanlynhacungcap.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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<?php
include 'admin/db.php';
session_start();
if (isset($_SESSION['type'])) {
if($_SESSION['type'] != 2){
header("Location: index.php");
}
}else{
header("Location: index.php");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Quản lý nhà cung cấp</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<script src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.20/js/dataTables.bootstrap4.min.js"></script>
<script src="https://cdn.datatables.net/1.10.20/css/dataTables.bootstrap4.min.css"></script>
<script src="ajax/nhacungcap.js"></script>
<script>
$(document).ready(function() {
// Cấu hình các nhãn phân trang
$('#example').dataTable({
"language": {
"sProcessing": "Đang xử lý...",
"sLengthMenu": "Xem _MENU_",
"sZeroRecords": "Không tìm thấy dòng nào phù hợp",
"sInfo": "Đang xem _START_ đến _END_ trong tổng số _TOTAL_ mục",
"sInfoEmpty": "Đang xem 0 đến 0 trong tổng số 0 mục",
"sInfoFiltered": "(được lọc từ _MAX_ mục)",
"sInfoPostFix": "",
"sSearch": "Tìm:",
"sUrl": "",
"oPaginate": {
"sFirst": "Đầu",
"sPrevious": "Trước",
"sNext": "Tiếp",
"sLast": "Cuối"
}
},
"processing": true, // tiền xử lý trước
"aLengthMenu": [
[3, 10, 20, 50],
[3, 10, 20, 50]
], // danh sách số trang trên 1 lần hiển thị bảng
});
});
</script>
</head>
<body>
<div class="container">
<p id="success"></p>
<div class="table-wrapper">
<div class="table-title">
<div class="row">
<div class="col-sm-6 float-right">
<h2><b>Danh sách nhà cung cấp</b></h2>
</div>
<div class="col-sm-6">
<a href="#addPro" class="btn btn-success" data-toggle="modal"><i class="material-icons"></i>
<span>Thêm nhà cung cấp</span></a>
<a href="index.php" class="btn btn-success">
<span>Quay về</span></a>
</div>
</div>
</div>
<table id="example" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Phone</th>
<th>Address</th>
<th>Email</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$result = mysqli_query($conn,"SELECT * FROM nhacungcap");
while($row = mysqli_fetch_array($result)) {
?>
<tr id="<?php echo $row["id"]; ?>">
<td><?php echo $row["id"]; ?></td>
<td><?php echo $row["name"]; ?></td>
<td><?php echo $row["phone"]; ?></td>
<td><?php echo $row["address"]; ?></td>
<td><?php echo $row["email"]; ?></td>
<td>
<button type="button" class="btn btn-danger" id="edit"><a href="#editStaff" class="edit"
data-toggle="modal">
<b class="update" data-toggle="tooltip" data-id="<?php echo $row["id"]; ?>"
data-name="<?php echo $row["name"]; ?>"
data-phone="<?php echo $row["phone"]; ?>"
data-address="<?php echo $row["address"]; ?>"
data-email="<?php echo $row["email"]; ?>" title=" Edit">Sửa</b>
</a></button>
<button type="button" class="btn btn-warning" id="del"><a href="#deleteStaff" class="delete"
data-id="<?php echo $row["id"]; ?>" data-toggle="modal"><b data-toggle="tooltip"
title="Delete">Xóa</b></a></button>
</td>
</tr>
<?php
}
?>
</tbody>
<tfoot>
<tr>
<th>ID</th>
<th>Name</th>
<th>Phone</th>
<th>Address</th>
<th>Email</th>
<th>Action</th>
</tr>
</tfoot>
</table>
</div>
<!-- Add Modal HTML -->
<div id="addPro" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<form id="formPro">
<div class="modal-header">
<h4 class="modal-title">Thêm nhà cung cấp</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<div class="form-group">
<label>ID</label>
<input type="text" id="id" name="id" class="form-control" required>
</div>
<div class="form-group">
<label>Name</label>
<input type="text" id="name" name="name" class="form-control" required>
</div>
<div class="form-group">
<label>PHONE</label>
<input type="phone" id="phone" name="phone" class="form-control" required>
</div>
<div class="form-group">
<label>ADDRESS</label>
<input type="address" id="address" name="address" class="form-control" required>
</div>
<div class="form-group">
<label>EMAIL</label>
<input type="email" id="email" name="email" class="form-control" required>
</div>
</div>
<div class="modal-footer">
<input type="hidden" value="1" name="type">
<input type="button" class="btn btn-default" data-dismiss="modal" value="Cancel">
<button type="button" class="btn btn-success" id="btn-add">Thêm</button>
</div>
</form>
</div>
</div>
</div>
<!-- Edit Modal HTML -->
<div id="editStaff" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<form id="editForm">
<div class="modal-header">
<h4 class="modal-title">Sửa thông tin nhà cung cấp</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<div class="form-group">
<label>ID</label>
<input type="text" id="id_u" name="id" class="form-control" required>
</div>
<div class="form-group">
<label>Name</label>
<input type="text" id="name_u" name="name" class="form-control" required>
</div>
<div class="form-group">
<label>PHONE</label>
<input type="phone" id="phone_u" name="phone" class="form-control" required>
</div>
<div class="form-group">
<label>ADDRESS</label>
<input type="address" id="address_u" name="address" class="form-control" required>
</div>
<div class="form-group">
<label>Email</label>
<input type="email" id="email_u" name="email" class="form-control" required>
</div>
</div>
<div class="modal-footer">
<input type="hidden" value="2" name="type">
<input type="button" class="btn btn-default" data-dismiss="modal" value="Cancel">
<button type="button" class="btn btn-info" id="update">Sửa</button>
</div>
</form>
</div>
</div>
</div>
<!-- Delete Modal HTML -->
<div id="deleteStaff" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<form>
<div class="modal-header">
<h4 class="modal-title">Xóa nhà cung cấp</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<input type="hidden" id="id_d" name="id" class="form-control">
<p>Bạn có muốn xóa thông tin này không?</p>
<p class="text-warning"><small>Đây là hành động.</small></p>
</div>
<div class="modal-footer">
<input type="button" class="btn btn-default" data-dismiss="modal" value="Cancel">
<button type="button" class="btn btn-danger" id="delete">Xóa</button>
</div>
</form>
</div>
</div>
</div>
</body>
</html>