📂 FileMgr
📍
/home/rsukartini.com/rs/app/Views/backend/download
✏️ Edit File: /home/rsukartini.com/rs/app/Views/backend/download/index.php
⬅ Kembali
<?= $this->include('backend/headeradmin') ?> <div class="main-content"> <?= $this->include('backend/menuatasadmin') ?> <div class="header bg-gradient-primary pb-8 pt-5 pt-md-8"> <div class="container-fluid"> <div class="header-body"></div> </div> </div> <div class="container-fluid mt--7"> <div class="row"> <div class="col-xl-12"> <div class="card shadow"> <div class="card-header border-0 d-flex justify-content-between align-items-center"> <h3 class="mb-0">Daftar File Download</h3> <?php if (session('role') === 'admin'): ?> <a href="<?= base_url('download/create') ?>" class="btn btn-primary"><i class="fas fa-plus"></i> Tambah File</a> <?php endif; ?> </div> <div class="card-body"> <?php if (session()->getFlashdata('success')): ?> <div class="alert alert-success"> <?= session()->getFlashdata('success') ?> </div> <?php endif; ?> <?php if (session()->getFlashdata('error')): ?> <div class="alert alert-danger"> <?= session()->getFlashdata('error') ?> </div> <?php endif; ?> <div class="table-responsive"> <table class="table table-bordered align-items-center table-flush" id="tabel-download"> <thead class="thead-light"> <tr> <th>No</th> <th>Judul</th> <th>Kategori</th> <th>Sub Kategori</th> <th>File</th> <th>Ukuran</th> <th>Download</th> <th>Tanggal</th> <th>Aksi</th> </tr> </thead> <tbody> <?php if (!empty($downloads)): ?> <?php $no=1; foreach ($downloads as $download): ?> <tr> <td><?= $no++ ?></td> <td><?= esc($download['judul']) ?></td> <td> <span class="badge badge-info"><?= esc($download['nama_kategori_download']) ?></span> </td> <td> <span class="badge badge-warning"><?= esc($download['nama_sub_kategori_download']) ?></span> </td> <td> <i class="fas fa-file-<?= getFileIcon($download['tipe_file']) ?> text-primary"></i> <?= esc($download['nama_file']) ?> </td> <td><?= formatFileSize($download['ukuran_file']) ?></td> <td> <span class="badge badge-success"><?= $download['hits'] ?> kali</span> </td> <td><?= date('d/m/Y', strtotime($download['created_at'])) ?></td> <td> <a href="<?= base_url('download/download/'.$download['id_download']) ?>" class="btn btn-sm btn-info" title="Download"> <i class="fas fa-download"></i> </a> <?php if (session('role') === 'admin'): ?> <a href="<?= base_url('download/edit/'.$download['id_download']) ?>" class="btn btn-sm btn-warning" title="Edit"> <i class="fas fa-pencil-alt"></i> </a> <a href="<?= base_url('download/delete/'.$download['id_download']) ?>" class="btn btn-sm btn-danger btn-hapus-download" title="Hapus"> <i class="fas fa-trash"></i> </a> <?php endif; ?> </td> </tr> <?php endforeach; ?> <?php else: ?> <tr><td colspan="9" class="text-center">Tidak ada data file download.</td></tr> <?php endif; ?> </tbody> </table> </div> </div> </div> </div> </div> <?= $this->include('backend/footeradmin') ?> </div> </div> <?= $this->include('backend/jsadmin') ?> <!-- SweetAlert2 CDN --> <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script> <!-- DataTables CSS --> <link rel="stylesheet" href="<?= base_url('argon/assets/js/plugins/datatables/dataTables.bootstrap4.min.css') ?>"> <!-- DataTables JS --> <script src="<?= base_url('argon/assets/js/plugins/datatables/jquery.dataTables.min.js') ?>"></script> <script src="<?= base_url('argon/assets/js/plugins/datatables/dataTables.bootstrap4.min.js') ?>"></script> <script> // Notifikasi SweetAlert2 dari flashdata <?php if (session()->getFlashdata('success')): ?> Swal.fire({ icon: 'success', title: 'Sukses', text: '<?= session('success') ?>', timer: 2000, showConfirmButton: false }); <?php endif; ?> <?php if (session()->getFlashdata('error')): ?> Swal.fire({ icon: 'error', title: 'Gagal', text: '<?= session('error') ?>', timer: 2000, showConfirmButton: false }); <?php endif; ?> $(document).ready(function() { $('#tabel-download').DataTable({ language: { url: '//cdn.datatables.net/plug-ins/1.10.21/i18n/Indonesian.json' }, pageLength: 10, lengthMenu: [5, 10, 25, 50, 100], ordering: true, searching: true, stateSave: true, responsive: true, autoWidth: false, scrollX: true, scrollY: 300, scrollCollapse: true, paging: true, info: true, language: { paginate: { previous: "<i class='fas fa-angle-left'></i>", next: "<i class='fas fa-angle-right'></i>" } } }); }); // SweetAlert2 konfirmasi hapus download $(document).on('click', '.btn-hapus-download', function(e) { e.preventDefault(); var url = $(this).attr('href'); Swal.fire({ title: 'Yakin hapus file ini?', text: 'Data yang dihapus tidak bisa dikembalikan!', icon: 'warning', showCancelButton: true, confirmButtonColor: '#d33', cancelButtonColor: '#3085d6', confirmButtonText: 'Ya, hapus!', cancelButtonText: 'Batal' }).then((result) => { if (result.isConfirmed) { window.location.href = url; } }); }); </script> <?php // Helper function untuk icon file function getFileIcon($extension) { $icons = [ 'pdf' => 'pdf', 'doc' => 'word', 'docx' => 'word', 'xls' => 'excel', 'xlsx' => 'excel', 'ppt' => 'powerpoint', 'pptx' => 'powerpoint', 'txt' => 'alt', 'zip' => 'archive', 'rar' => 'archive' ]; return isset($icons[strtolower($extension)]) ? $icons[strtolower($extension)] : 'alt'; } // Helper function untuk format ukuran file function formatFileSize($bytes) { if ($bytes >= 1073741824) { return number_format($bytes / 1073741824, 2) . ' GB'; } elseif ($bytes >= 1048576) { return number_format($bytes / 1048576, 2) . ' MB'; } elseif ($bytes >= 1024) { return number_format($bytes / 1024, 2) . ' KB'; } else { return $bytes . ' bytes'; } } ?>
💾 Simpan File
Batal
⬅ Naik ke backend
3 item
Nama
Tipe
Ukuran
Diubah
Aksi
🐘
create.php
php
15.6 KB
2025-08-01 11:37
✏️ Edit
👁️ View
🗑 Hapus
🐘
edit.php
php
19.5 KB
2025-08-01 11:48
✏️ Edit
👁️ View
🗑 Hapus
🐘
index.php
php
7.3 KB
2025-08-01 11:28
✏️ Edit
👁️ View
🗑 Hapus