Skip to content

Commit

Permalink
Update v1.1-rev3: Add settings menu
Browse files Browse the repository at this point in the history
  • Loading branch information
billalxcode committed Jul 8, 2022
1 parent 3cf13f9 commit 6ca3e1a
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 34 deletions.
1 change: 1 addition & 0 deletions app/Config/Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@

$routes->group("settings", ['filter' => 'authadmin'], function ($routes) {
$routes->get("", "Settings::index");
$routes->post("save", "Settings::save");
});
});

Expand Down
36 changes: 35 additions & 1 deletion app/Controllers/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,42 @@ class Settings extends BaseController
{
public function index()
{
helper("form");
$this->context['title'] = "Kelola Pengaturan";

$this->context['values'] = $this->settingsModel->first();

return $this->renderView("admin/settings/general");
}

public function save() {
$type = $this->request->getPost('type');
if ($type == 'general') {
$penyelenggara = $this->request->getPost("penyelenggara");
$provinsi = $this->request->getPost("provinsi");
$kota = $this->request->getPost("kota");
$kecamatan = $this->request->getPost("kecamatan");

$penyelenggara = isset($penyelenggara) ? $penyelenggara : "";
$provinsi = isset($provinsi) ? $provinsi : "";
$kota = isset($kota) ? $kota : "";
$kecamatan = isset($kecamatan) ? $kecamatan : "";

$data_post = [
'penyelenggara' => $penyelenggara,
'provinsi' => $provinsi,
'kota' => $kota,
'kecamatan' => $kecamatan,
'alamat' => ''
];
$settingsData = $this->settingsModel->first();
if ($settingsData) {
$this->settingsModel->update($settingsData['id'], $data_post);
} else {
$this->settingsModel->save($data_post);
}

$this->session->setFlashdata('success', 'Berhasil menyimpan data');
return redirect()->back();
}
}
}
106 changes: 73 additions & 33 deletions app/Views/admin/settings/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@

<?= $this->section("content"); ?>
<div class="container-xxl flex-grow-1 container-p-y">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-1">
<?php if (session()->getFlashdata('success')) : ?>
<div class="alert alert-success">
<?= session()->getFlashdata('success') ?>
</div>
<?php endif ?>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">

<div class="nav-align-top mb-4">
<ul class="nav nav-pills mb-3 nav-fill" role="tablist">
<li class="nav-item">
Expand All @@ -19,47 +27,79 @@
</ul>
<div class="tab-content">
<div class="tab-pane fade show active" id="nav-home-panel" role="tabpanel">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<form action="<?= base_url('admin/settings/save') ?>" method="post">
<form action="<?= base_url('admin/settings/save') ?>" method="post">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<?= csrf_field() ?>
<input type="hidden" name="type" value="general">
<div class="row mb-3">
<label class="col-sm-2 col-form-label" for="penyelenggara">Nama Lengkap</label>
<label class="col-sm-2 col-form-label" for="penyelenggara">Penyelenggara</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="penyelenggara" name="penyelenggara" placeholder="Masukan Penyelenggara" aria-label="Penyelenggara" value="<?= $values['penyelenggara'] ?>" />
</div>
<?php if (isset(session()->getFlashdata('errors')['penyelenggara'])) : ?>
<small class="form-text text-danger"><?= session()->getFlashdata('errors')['penyelenggara'] ?></small>
<?php endif ?>
</div>
<div class="row mb-3">
<label class="col-sm-2 col-form-label" for="provinsi">Provinsi</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="provinsi" name="provinsi" placeholder="Masukan provinsi" aria-label="provinsi" value="<?= $values['provinsi'] ?>" />
</div>
<?php if (isset(session()->getFlashdata('errors')['provinsi'])) : ?>
<small class="form-text text-danger"><?= session()->getFlashdata('errors')['provinsi'] ?></small>
<?php endif ?>
</div>

<div class="row mb-3">
<label class="col-sm-2 col-form-label" for="kota">Kota</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="penyelenggara" name="penyelenggara" placeholder="Masukan Penyelenggara" aria-label="Penyelenggara" />
<input type="text" class="form-control" id="kota" name="kota" placeholder="Masukan kota" aria-label="kota" value="<?= $values['kota'] ?>" />
</div>
<?php if (isset(session()->getFlashdata('errors')['nama'])) : ?>
<small class="form-text text-danger"><?= session()->getFlashdata('errors')['nama'] ?></small>
<?php if (isset(session()->getFlashdata('errors')['kota'])) : ?>
<small class="form-text text-danger"><?= session()->getFlashdata('errors')['kota'] ?></small>
<?php endif ?>
</div>
</form>
<div class="row mb-3">
<label class="col-sm-2 col-form-label" for="kecamatan">kecamatan</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="kecamatan" name="kecamatan" placeholder="Masukan kecamatan" aria-label="kecamatan" value="<?= $values['kecamatan'] ?>" />
</div>
<?php if (isset(session()->getFlashdata('errors')['kecamatan'])) : ?>
<small class="form-text text-danger"><?= session()->getFlashdata('errors')['kecamatan'] ?></small>
<?php endif ?>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
<button class="btn btn-primary"><i class="fa fa-save"></i> Simpan</button>

</div>
</div>
</div>
</form>
</div>
<div class="tab-pane fade" id="nav-profile-panel" role="tabpanel">
<p>
Donut dragée jelly pie halvah. Danish gingerbread bonbon cookie wafer candy oat cake ice cream. Gummies
halvah
tootsie roll muffin biscuit icing dessert gingerbread. Pastry ice cream cheesecake fruitcake.
</p>
<p class="mb-0">
Jelly-o jelly beans icing pastry cake cake lemon drops. Muffin muffin pie tiramisu halvah cotton candy
liquorice caramels.
</p>
</div>
<div class="tab-pane fade" id="nav-calendar-panel" role="tabpanel">
<p>
Oat cake chupa chups dragée donut toffee. Sweet cotton candy jelly beans macaroon gummies cupcake gummi
bears
cake chocolate.
</p>
<p class="mb-0">
Cake chocolate bar cotton candy apple pie tootsie roll ice cream apple pie brownie cake. Sweet roll icing
sesame snaps caramels danish toffee. Brownie biscuit dessert dessert. Pudding jelly jelly-o tart brownie
jelly.
</p>
</div>
</div>
<div class="tab-pane fade" id="nav-profile-panel" role="tabpanel">
<p>
Donut dragée jelly pie halvah. Danish gingerbread bonbon cookie wafer candy oat cake ice cream. Gummies
halvah
tootsie roll muffin biscuit icing dessert gingerbread. Pastry ice cream cheesecake fruitcake.
</p>
<p class="mb-0">
Jelly-o jelly beans icing pastry cake cake lemon drops. Muffin muffin pie tiramisu halvah cotton candy
liquorice caramels.
</p>
</div>
<div class="tab-pane fade" id="nav-calendar-panel" role="tabpanel">
<p>
Oat cake chupa chups dragée donut toffee. Sweet cotton candy jelly beans macaroon gummies cupcake gummi
bears
cake chocolate.
</p>
<p class="mb-0">
Cake chocolate bar cotton candy apple pie tootsie roll ice cream apple pie brownie cake. Sweet roll icing
sesame snaps caramels danish toffee. Brownie biscuit dessert dessert. Pudding jelly jelly-o tart brownie
jelly.
</p>
</div>
</div>
</div>
Expand Down

0 comments on commit 6ca3e1a

Please sign in to comment.