|
30 | 30 | <link rel="stylesheet" href="https://cdn.datatables.net/1.13.7/css/jquery.dataTables.min.css">
|
31 | 31 | <link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.4.2/css/buttons.dataTables.min.css">
|
32 | 32 | <link rel="stylesheet" href="https://cdn.datatables.net/1.13.7/css/dataTables.bootstrap4.min.css">
|
| 33 | + <!-- Sweetalert2 --> |
| 34 | + <link rel="stylesheet" href="../assets/adminlte/plugins/sweetalert2-theme-bootstrap-4/bootstrap-4.min.css"> |
33 | 35 |
|
34 | 36 | <style>
|
35 | 37 | .lebar-kolom1 {
|
36 | 38 | width: 5%;
|
37 | 39 | }
|
38 | 40 |
|
39 | 41 | .lebar-kolom2 {
|
40 |
| - width: 45%; |
| 42 | + width: 40%; |
41 | 43 | }
|
42 | 44 |
|
43 | 45 | .lebar-kolom3 {
|
|
57 | 59 | }
|
58 | 60 |
|
59 | 61 | .lebar-kolom7 {
|
60 |
| - width: 10%; |
| 62 | + width: 15%; |
61 | 63 | }
|
62 | 64 |
|
63 | 65 | .card-padding {
|
|
116 | 118 | <!-- /.card-header -->
|
117 | 119 | <div class="card-body p-0">
|
118 | 120 | <div class="table-responsive card-padding">
|
119 |
| - <table id="tablePerusahaan" class="table table order-list table-striped table-bordered"> |
| 121 | + <table id="tableUser" class="table table order-list table-striped table-bordered"> |
120 | 122 | <thead>
|
121 | 123 | <tr>
|
122 | 124 | <th class="text-center lebar-kolom1">ID</th>
|
|
150 | 152 | ?>
|
151 | 153 | </td>
|
152 | 154 | <td class="text-center">
|
153 |
| - <div class="col"> |
154 |
| - <a href='edit.php?id=<?php echo $row["account_id"]; ?>' class="btn btn-info btn-block">Edit</a> |
| 155 | + <div style="display: inline-block;"> |
| 156 | + <a href='edit.php?id=<?php echo $row["account_id"]; ?>' class="btn btn-info"><i class="fas fa-pencil"></i></a> |
155 | 157 | </div>
|
| 158 | + <a href='#' class='btn btn-danger delete-btn' data-id='<?php echo $row["account_id"]; ?>'><i class="fas fa-trash"></i></a> |
156 | 159 | </td>
|
157 | 160 | </tr>
|
158 | 161 | <?php
|
|
204 | 207 | <script src="https://cdn.datatables.net/buttons/2.4.2/js/buttons.html5.min.js"></script>
|
205 | 208 | <script src="https://cdn.datatables.net/buttons/2.4.2/js/buttons.print.min.js"></script>
|
206 | 209 | <script src="https://cdn.datatables.net/buttons/2.4.2/js/buttons.bootstrap4.min.js"></script>
|
| 210 | + <!-- SweetAlert2 Toast --> |
| 211 | + <script src="../assets/adminlte/plugins/sweetalert2/sweetalert2.min.js"></script> |
207 | 212 |
|
208 | 213 | <!-- Page specific script -->
|
209 | 214 | <script>
|
210 | 215 | $(document).ready(function() {
|
211 |
| - var table = $('#tablePerusahaan').DataTable({ |
| 216 | + |
| 217 | + $('#tableUser').on('click', '.delete-btn', function(e) { |
| 218 | + e.preventDefault(); |
| 219 | + var userId = $(this).data('id'); |
| 220 | + |
| 221 | + // Tampilkan konfirmasi SweetAlert |
| 222 | + Swal.fire({ |
| 223 | + title: 'Apakah Anda yakin?', |
| 224 | + text: 'Data pengguna ini akan dihapus!', |
| 225 | + icon: 'warning', |
| 226 | + showCancelButton: true, |
| 227 | + confirmButtonColor: '#d33', |
| 228 | + cancelButtonColor: '#3085d6', |
| 229 | + confirmButtonText: 'Ya, hapus!', |
| 230 | + cancelButtonText: 'Batal' |
| 231 | + }).then((result) => { |
| 232 | + if (result.isConfirmed) { |
| 233 | + // Jika dikonfirmasi, lakukan penghapusan |
| 234 | + window.location.href = 'delete.php?id=' + userId; |
| 235 | + } |
| 236 | + }); |
| 237 | + }); |
| 238 | + |
| 239 | + var table = $('#tableUser').DataTable({ |
212 | 240 | responsive: true,
|
213 | 241 | language: {
|
214 | 242 | lengthMenu: 'Tampilkan _MENU_ data per halaman',
|
|
224 | 252 | 'pageLength',
|
225 | 253 | {
|
226 | 254 | extend: 'copy',
|
227 |
| - title: 'List Perusahaan', |
| 255 | + title: 'List User', |
228 | 256 | exportOptions: {
|
229 | 257 | columns: ':visible:not(.aksi-column)'
|
230 | 258 | }
|
|
236 | 264 | },
|
237 | 265 | {
|
238 | 266 | extend: 'csv',
|
239 |
| - title: 'List Perusahaan', |
| 267 | + title: 'List User', |
240 | 268 | exportOptions: {
|
241 | 269 | columns: ':visible:not(.aksi-column)'
|
242 | 270 | }
|
243 | 271 | },
|
244 | 272 | {
|
245 | 273 | extend: 'excel',
|
246 |
| - title: 'List Perusahaan', |
| 274 | + title: 'List User', |
247 | 275 | exportOptions: {
|
248 | 276 | columns: ':visible:not(.aksi-column)'
|
249 | 277 | }
|
250 | 278 | },
|
251 | 279 | {
|
252 | 280 | extend: 'pdf',
|
253 |
| - title: 'List Perusahaan', |
| 281 | + title: 'List User', |
254 | 282 | exportOptions: {
|
255 | 283 | columns: ':visible:not(.aksi-column)'
|
256 | 284 | }
|
257 | 285 | },
|
258 | 286 | {
|
259 | 287 | extend: 'print',
|
260 |
| - title: 'List Perusahaan', |
| 288 | + title: 'List User', |
261 | 289 | exportOptions: {
|
262 | 290 | columns: ':visible:not(.aksi-column)'
|
263 | 291 | }
|
|
0 commit comments