2025-04-27 07:06:24 +07:00

107 lines
7.0 KiB
PHP
Executable File

<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<section class="content-header">
<h1>
PROFIL
<small>Manajemen Profil</small>
</h1>
</section>
<section class="content">
<div class="row">
<div class="col-md-12">
<a href="<?php echo site_url('dashboard/tambah_profil'); ?>" aria-label="Buat Profil Baru" class="btn btn-sm btn-primary">
<i class="fa fa-plus"></i> Buat Profil Baru
</a>
<br/><br/>
<!-- Menampilkan pesan flashdata -->
<?php if ($this->session->flashdata('success')): ?>
<div class="alert alert-success">
<?php echo $this->session->flashdata('success'); ?>
</div>
<?php endif; ?>
<?php if ($this->session->flashdata('error')): ?>
<div class="alert alert-danger">
<?php echo $this->session->flashdata('error'); ?>
</div>
<?php endif; ?>
<div class="box box-primary">
<div class="box-header">
<h3 class="box-title">Profil</h3>
</div>
<div class="box-body">
<table id="table45" class="table table-striped table-bordered nowrap" style="width:100%">
<thead>
<tr>
<th width="1%">NO</th>
<th>TANGGAL</th>
<th>PROFIL</th>
<th>AUTHOR</th>
<th>KATEGORI</th>
<th width="10%">GAMBAR</th>
<th>STATUS</th>
<th width="10%">OPTION</th>
</tr>
</thead>
<tbody>
<?php
$no = 1;
foreach($profil as $k){
?>
<tr>
<td><?php echo $no++; ?></td>
<td><?php echo date('d/m/Y H:i', strtotime($k->profil_tanggal)); ?></td>
<td>
<?php echo $k->profil_judul; ?>
<br/>
<small class="text-muted">
<?php echo base_url()."".$k->profil_slug; ?>
</small>
</td>
<td><?php echo $k->pengguna_nama; ?></td>
<td><?php echo $k->kategori_profil_nama; ?></td>
<td><img width="100%" class="img-responsive" src="<?php echo base_url().'/gambar/profil/'.$k->profil_sampul; ?>"></td>
<td>
<?php
if($k->profil_status=="publish"){
echo "<span class='label label-success'>Di Publish</span>";
}else{
echo "<span class='label label-danger'>Tidak di Publish</span>";
}
?>
</td>
<td>
<a target="_blank" href="<?php echo base_url().$k->profil_slug; ?>" class="btn btn-success btn-sm"> <i class="fa fa-eye"></i> </a> &nbsp;
<?php
// cek apakah pengguna yang login adalah penulis
if($this->session->userdata('level') == "penulis"){
// jika penulis, maka cek apakah penulis profil ini adalah si pengguna atau bukan
if($this->session->userdata('id') == $k->profil_author){
?>
<a href="<?php echo base_url().'dashboard/edit_profil/'.$k->profil_id; ?>" class="btn btn-warning btn-sm"> <i class="fa fa-pencil"></i> </a> &nbsp;
<a href="<?php echo base_url().'dashboard/profil_hapus/'.$k->profil_id; ?>" class="btn btn-danger btn-sm" onclick="return confirm('Apakah Anda yakin ingin menghapus profil ini?');"> <i class="fa fa-trash"></i> </a> &nbsp;
<?php
}
}else{
// jika yang login adalah admin
?>
<a href="<?php echo base_url().'dashboard/edit_profil/'.$k->profil_id; ?>" class="btn btn-warning btn-sm"> <i class="fa fa-pencil"></i> </a> &nbsp;
<a href="<?php echo base_url().'dashboard/profil_hapus/'.$k->profil_id; ?>" class="btn btn-danger btn-sm" onclick="return confirm('Apakah Anda yakin ingin menghapus profil ini?');"> <i class="fa fa-trash"></i> </a> &nbsp;
<?php
}
?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</section>
</div>