Commit f36e6cdb by KyrieCettyara

Menambah menu admin

parent 4766dd33
......@@ -48,7 +48,7 @@ $routes->group("user", ["filter" => "auth"], function ($routes) {
$routes->get('logout', ' UserController::logout');
$routes->get('list-kuliner', "ArtikelController::listKuliner");
$routes->get("kuliner/(:num)", "ArtikelController::kulinerById/$1");
$routes->get("artikel/(:num)", "ArtikelController::artikelById/$1");
$routes->match(["get", "post"], "add-artikel", "ArtikelController::addArtikel");
$routes->match(["get", "post"], "edit-artikel/(:num)", "ArtikelController::editArtikel/$1");
$routes->get("delete-artikel/(:num)", "ArtikelController::deleteArtikel/$1");
......
......@@ -4,21 +4,30 @@ namespace App\Controllers;
use App\Controllers\BaseController;
use App\Models\UserModel;
use App\Models\ArtikelModel;
class AdminController extends BaseController
{
public function __construct()
{
if (session()->get('role_id') != 1) {
echo 'Access denied';
exit;
}
helper('text');
}
public function index()
{
$model = new ArtikelModel();
$data['title'] = 'Admin';
return view("admin/dashboard");
$data = $model->findAll();
return view('admin/list', [
"data" => $data,
]);
}
......
......@@ -25,11 +25,11 @@ class ArtikelController extends BaseController
]);
}
public function kulinerById($key = null)
public function artikelById($key = null)
{
$kulinerModel = new ArtikelModel();
$artikelModel = new ArtikelModel();
$value = $kulinerModel->where('id_artikel', $key)->first();
$value = $artikelModel->where('id_artikel', $key)->first();
$this->setArtikelSession($value);
if (session()->get('role_id') == 1) {
......@@ -83,9 +83,15 @@ class ArtikelController extends BaseController
$model = new ArtikelModel();
$file = $this->request->getFile('gambar');
if ($file->isValid() && !$file->hasMoved()) {
$imageName = $file->getRandomName();
$file->move('upload/', $imageName);
}
$newData = [
'id_jenis_artikel' => $this->request->getVar('id_jenis_artikel'),
'gambar' => $this->request->getVar('gambar'),
'gambar' => $imageName,
'judul_artikel' => $this->request->getVar('judul_artikel'),
'isi_artikel' => $this->request->getVar('isi_artikel'),
......
<div class="panel-body">
<hr>
<form class="" action="<?= base_url('ArtikelController/addArtikel'); ?>" method="post">
<div class="form-group">
<label for="name">Jenis Artikel</label>
<select name="id_jenis_artikel" id="id_jenis_artikel">
<!DOCTYPE html>
<html lang="en">
<?php foreach ($data as $value) : ?>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<option value="<?= $value['id_jenis_artikel']; ?>">
<?= $value['nama_jenis_artikel']; ?>
</option>
<?php endforeach; ?>
</select>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col">
<div class="panel-body">
<hr>
<form class="" enctype="multipart/form-data" action="<?= base_url('ArtikelController/addArtikel'); ?>" method="post">
<div class="form-group">
<label for="name">Jenis Artikel</label>
<select class="form-control" name="id_jenis_artikel" id="id_jenis_artikel">
<?php foreach ($data as $value) : ?>
<option value="<?= $value['id_jenis_artikel']; ?>">
<?= $value['nama_jenis_artikel']; ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="custom-file">
<input type="file" class="custom-file-input" id="gambar">
<label class="custom-file-label" for="gambar">Choose file...</label>
<input type="file" class="custom-file-input" name="gambar" id="gambar">
</div>
<div class="form-group">
<label for="judul_artikel">Judul Artikel</label>
<input class="form-control" type="text" class="form-control" name="judul_artikel" id="judul_artikel">
</div>
<div class="form-group">
<label for="isi_artikel">Isi</label>
<textarea class="form-control" type="text" class="form-control" name="isi_artikel" id="isi_artikel"></textarea>
</div>
<button type="submit" class="btn btn-success">Submit</button>
</form>
</div>
</div>
</div>
<div class="form-group">
<label for="gambar">Gambar</label>
<input type="file" class="form-control" name="gambar" id="gambar">
</div>
<div class="form-group">
<label for="judul_artikel">Judul Artikel</label>
<input type="text" class="form-control" name="judul_artikel" id="judul_artikel">
</div>
<div class="form-group">
<label for="isi_artikel">Isi</label>
<input type="text" class="form-control" name="isi_artikel" id="isi_artikel">
</div>
<button type="submit" class="btn btn-success">Submit</button>
</form>
</div>
\ No newline at end of file
</div>
</body>
</html>
\ No newline at end of file
<div class="container" style="margin-top:20px;">
<div class="row">
<div class="col-sm-6">
<div class="panel panel-primary">
<div class="panel-heading">Admin Dashboard</div>
<div class="panel-body">
<h1>Hello, <?= session()->get('name') ?></h1>
<h3><a href="<?= site_url('AuthController/logout') ?>">Logout</a></h3>
</div>
</div>
</div>
</div>
</div>
<a href="<?= base_url('ArtikelController/addArtikel') ?>" class="get-started-btn">Logout</a>
\ No newline at end of file
<h2 id="judul_artikel" name="judul_artikel"><?= $value['judul_artikel']; ?></h1>
<?= $this->extend('admin/side_menu'); ?>
<button> <a href=" <?= base_url('edit-artikel/' . $value['id_artikel']); ?>">Edit</a></button>
<?= $this->section('content'); ?>
<a href=" <?= base_url('edit-artikel/' . $value['id_artikel']); ?>" class="btn btn-primary">Edit</a>
<a href="<?= base_url('delete-artikel/' . $value['id_artikel']); ?>" class="btn btn-primary">Delete</a>
<button> <a href="<?= base_url('delete-artikel/' . $value['id_artikel']); ?>">Delete</a></button>
\ No newline at end of file
<div class="container">
<div class="row">
<div class="col">
<div class="card">
<?php $image = $value['gambar']; ?>
<img id="gambar" src="<?php echo base_url("upload/$image"); ?> " alt="image" />
<div class=" card-body">
<h5 class="card-title"><?= $value['judul_artikel']; ?></h5>
<p class="card-text"><?= $value['isi_artikel']; ?></p>
</div>
</div>
</div>
</div>
</div>
<?= $this->endSection(); ?>
\ No newline at end of file
<?= $this->extend('admin/side_menu'); ?>
<?= $this->section('content'); ?>
<?php foreach ($data as $value) : ?>
<?php
$isi_artikel = $value['isi_artikel'];
$isi_artikel = character_limiter($isi_artikel, 100);
?>
<div class="container">
<div class="row">
<div class="col">
<div class="card">
<img id="gambar" class="card-img-top" src="<?= "upload/" . $value['gambar']; ?>" alt="image" />
<div class=" card-body">
<h5 class="card-title"><?= $value['judul_artikel']; ?></h5>
<p class="card-text"><?= $isi_artikel; ?></p>
<a href="<?= base_url('artikel/' . $value['id_artikel']); ?>" class="btn btn-primary">Go somewhere</a>
</div>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
<?= $this->endSection(); ?>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Nunito:400,600,700,800,900" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<link href="<?php echo base_url('css/admin.css'); ?> " rel="stylesheet">
</head>
<body>
<div class="wrapper">
<div class="side-menu">
<div class="logo">
Hi, Admin!
</div>
<div class="menu">
<ul>
<li><a href="<?= base_url('admin') ?>"><i class="fa fa-server" aria-hidden="true"></i><span class="text"> Kelola Artikel </span></a></li>
<li><a href="#"><i class="fa fa-user-plus" aria-hidden="true"></i><span class="text"> Kelola Akun Admin </span></a></li>
<li><a href="<?= base_url('AuthController/logout') ?>"><i class="fa fa-sign-out" aria-hidden="true"></i><span class="text"> Keluar</span></a></li>
</ul>
</div>
</div>
<div class="main-content">
<div class="topmenu">
<div class="search"><i class="fa fa-search" aria-hidden="true"></i> <input type='text' class='src' placeholder='Search for cards...' /></div>
</div>
<div class="main-section">
<?= $this->renderSection('content'); ?>
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
<div class="side-menu">
<div class="logo">
Hi, Admin!
</div>
<div class="menu">
<ul>
<li><a href="#"><i class="fa fa-server" aria-hidden="true"></i><span class="text"> Kelola Artikel </span></a></li>
<li><a href="#"><i class="fa fa-user-plus" aria-hidden="true"></i><span class="text"> Tambah Akun Admin </span></a></li>
</ul>
</div>
</div>
\ No newline at end of file
......@@ -36,18 +36,9 @@
<script src="<?php echo base_url('vendor/aos/aos.js'); ?> "></script>
<!-- Template Main JS File -->
<script src="<?php echo base_url('js/main.js'); ?> "></script>
<script>
$(document).ready(function() {
$("button").click(function() {
$.get("date-time.php", function(data) {
// Display the returned data in browser
$("#result").html(data);
});
});
});
</script>
<script type="text/javascript" src="<?php echo base_url('js/main.js'); ?> "></script>
</head>
<body>
......
<?php foreach ($allValue as $value) : ?>
<h1><?= $value['judul_artikel']; ?></h1>
<?php
$isi_artikel = $value['isi_artikel'];
$isi_artikel = character_limiter($isi_artikel, 100);
?>
<p><?= $isi_artikel; ?></p>
<a href="#">baca selanjutnya</a>
<?php endforeach; ?>
\ No newline at end of file
html {
font-family: "Nunito", sans-serif;
height: 100%;
}
body {
margin: 0px;
height: 100%;
}
.wrapper {
height: auto;
min-height: 100%;
overflow: hidden;
}
.side-menu {
/* min-width: 250px; */
width: 250px;
float: left;
background: #32325d;
height: auto;
min-height: 100%;
margin-bottom: -5000px; /* any large number will do */
padding-bottom: 5000px;
}
.topmenu {
height: 60px;
padding: 10px 0px 10px 0px;
background: #6772e5;
color: #e1e2fa;
}
.logo {
background: #3a3a63;
color: #ffffff;
font-size: 24px;
font-weight: bold;
padding: 10px 0px 0px 10px;
height: 45px;
}
.main-section {
height: 100%;
}
a {
text-decoration: none;
color: #e1e2fa;
}
.menu ul {
list-style-type: none;
margin-left: 0px;
padding-left: 10px;
}
.menu ul li a {
font-size: 12px;
font-weight: 800;
display: inline-block;
padding-top: 10px;
padding-bottom: 10px;
width: 100%;
margin-left: -5px;
padding-left: 10px;
}
.menu ul li a:hover {
background: #262646;
border-left: solid 5px #6a75eb;
margin-left: -10px;
width: 98%;
}
.menu ul li ul {
padding-left: 0px;
}
.main-section {
background: #f6f9fc;
height: 100%;
margin-bottom: -5000px; /* any large number will do */
padding-bottom: 5000px;
margin-left: 250px;
}
.search {
width: 340px;
float: left;
margin-top: 3px;
margin-left: 25px;
padding-left: 10px;
background: #5c66cd;
padding-top: 3px;
padding-bottom: 3px;
border-radius: 15px;
color: #8089e8;
}
input.src {
background: none;
border: none;
width: 300px;
font-family: "Nunito", sans-serif;
color: #8089e8;
font-size: 13px;
font-weight: 600;
}
*:focus {
outline: none;
}
::-webkit-input-placeholder {
/* Chrome/Opera/Safari */
font-family: "Nunito", sans-serif;
color: #8089e8;
font-size: 13px;
font-weight: 600;
}
::-moz-placeholder {
/* Firefox 19+ */
font-family: "Nunito", sans-serif;
color: #8089e8;
font-size: 13px;
font-weight: 600;
}
:-ms-input-placeholder {
/* IE 10+ */
font-family: "Nunito", sans-serif;
color: #8089e8;
font-size: 13px;
font-weight: 600;
}
:-moz-placeholder {
/* Firefox 18- */
font-family: "Nunito", sans-serif;
color: #8089e8;
font-size: 13px;
font-weight: 600;
}
.container {
margin: 15px 0px 15px 0px;
}
#gambar {
width: 400px;
display: block;
margin-left: auto;
margin-right: auto;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment