-
Notifications
You must be signed in to change notification settings - Fork 0
/
customers.php
executable file
·196 lines (183 loc) · 7.29 KB
/
customers.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
<?php
session_start();
if (!isset($_SESSION['id']) || !isset($_SESSION['role'])) {
header('Location: login.php');
exit;
}
include 'connection.php';
include_once('includes/header.php');
?>
<style>
#yourTableID {
width: 100%;
margin-top: 20px;
}
#yourTableID th,
#yourTableID td {
text-align: center;
}
#yourTableID th {
background-color: #f8f9fa;
color: #343a40;
}
#yourTableID tbody tr:hover {
background-color: #f8f9fa;
color: #343a40;
}
/* Style for the modal */
.modal-content {
background-color: #f8f9fa;
}
.modal-footer {
background-color: #343a40;
color: #ffffff;
}
</style>
<div id="page-wrapper">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header text-center">Customer</h1>
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
<div class="row">
<table id="yourTableID" class="table table-striped table-bordered">
<thead>
<th>ID</th>
<th>Name</th>
<th>Phone</th>
<th>Action</th>
</thead>
<tbody>
<?php
$query = "SELECT * FROM customers";
$sql = mysqli_query($conn, $query);
while ($row = mysqli_fetch_array($sql)) { ?>
<tr>
<td><?php echo $row['id'] ?></td>
<td><?php echo $row['name'] ?></td>
<td><?php echo $row['phone'] ?></td>
<td>
<a class="btn btn-primary" href="editCustomer.php?id=<?php echo $row['id'] ?>">Edit</a>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
<!-- Include jQuery -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.13.7/css/jquery.dataTables.min.css">
<!-- <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/2.4.2/css/buttons.dataTables.min.css"> -->
<!-- <script type="text/javascript" src="https://code.jquery.com/jquery-3.6.0.min.js"></script> -->
<script type="text/javascript" src="https://cdn.datatables.net/1.10.24/js/jquery.dataTables.js"></script>
<!-- <script type="text/javascript" src="https://cdn.datatables.net/buttons/2.4.2/js/dataTables.buttons.min.js"></script> -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
<!-- <script type="text/javascript" src="https://cdn.datatables.net/buttons/2.4.2/js/buttons.html5.min.js"></script> -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
<!-- Include DataTables Buttons CSS and JS -->
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/2.4.2/css/buttons.dataTables.min.css">
<script type="text/javascript" src="https://cdn.datatables.net/buttons/2.4.2/js/dataTables.buttons.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/2.4.2/js/buttons.html5.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
<script>
$(document).ready(function() {
$('#yourTableID').DataTable({
"dom": '<"row mb-3"<"col-sm-12 col-md-6"l><"col-sm-12 col-md-6"f>>' +
'<"row"<"col-sm-12"B>>' +
'<"row"<"col-sm-12"tr>>' +
'<"row"<"col-sm-12 col-md-5"i><"col-sm-12 col-md-7"p>>',
responsive: true,
"buttons": [{
extend: 'copyHtml5',
className: 'btn btn-success',
text: 'Copy to Clipboard',
exportOptions: {
title: function() {
return 'Custom File Name - Copy';
}
}
},
{
extend: 'csvHtml5',
className: 'btn btn-warning',
text: 'Export to CSV',
exportOptions: {
title: function() {
return 'Custom File Name - CSV';
}
}
},
{
extend: 'excelHtml5',
className: 'btn btn-primary',
text: 'Export to Excel',
exportOptions: {
title: function() {
return 'Custom File Name - Excel';
}
}
},
{
extend: 'pdfHtml5',
className: 'btn btn-danger',
text: 'Export to PDF',
exportOptions: {
title: function() {
return 'Custom File Name - PDF';
}
}
},
'print'
],
"lengthMenu": [
[15, 25, 50, -1],
[15, 25, 50, "All"]
],
"pageLength": 15,
"language": {
"lengthMenu": "Show _MENU_ entries per page",
"zeroRecords": "No matching records found",
"info": "Showing _START_ to _END_ of _TOTAL_ entries",
"infoEmpty": "Showing 0 to 0 of 0 entries",
"infoFiltered": "(filtered from _MAX_ total entries)",
"paginate": {
"first": "First",
"previous": "Previous",
"next": "Next",
"last": "Last"
}
},
"initComplete": function(settings, json) {
// Apply custom styling to the buttons
var buttons = $('.dt-buttons button');
buttons.css({
'background-color': '#337ab7',
'border-radius': '5px',
'color': '#fff',
'transition': 'background-color 0.3s ease, border-radius 0.3s ease'
});
// Add hover effect
buttons.hover(
function() {
$(this).css('background-color', '#2d70aa');
},
function() {
$(this).css('background-color', '#337ab7');
}
);
var searchInput = $('.dataTables_filter input');
// searchInput.addClass('form-control rounded-pill'); // Bootstrap class for input styling and border-radius
searchInput.attr('placeholder', 'Search...');
}
});
});
</script>
<?php include_once('includes/footer.php'); ?>