168 lines
5.0 KiB
PHP
168 lines
5.0 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
class FAQ extends CI_Controller
|
|
{
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model("ModelPertanyaan");
|
|
$this->load->model("ModelJawaban");
|
|
}
|
|
|
|
function index()
|
|
{
|
|
$pertanyaan = $this->ModelPertanyaan->get_data();
|
|
// $jawaban = $this->ModelJawaban->get_data();
|
|
$data = array(
|
|
'body' => 'FAQ/list',
|
|
'pertanyaan' => $pertanyaan,
|
|
// 'jawaban' => $jawaban,
|
|
);
|
|
$this->load->view('index', $data);
|
|
}
|
|
public function input_pertanyaan()
|
|
{
|
|
$pertanyaan = $this->ModelPertanyaan->get_data();
|
|
$data = array(
|
|
'body' => 'FAQ/input',
|
|
'form' => 'FAQ/form',
|
|
'pertanyaan' => $pertanyaan,
|
|
);
|
|
$this->load->view('index', $data);
|
|
}
|
|
public function insert_pertanyaan()
|
|
{
|
|
$data = array(
|
|
'pertanyaan' => $this->input->post('pertanyaan'),
|
|
);
|
|
if ($this->db->insert("pertanyaan", $data)) {
|
|
// $this->session->set_flashdata("notif", $this->Notif->berhasil("Berhasil Input Data"));
|
|
redirect(base_url() . "FAQ");
|
|
} else {
|
|
$this->session->set_flashdata("notif", $this->Notif->gagal("gagal Input Data"));
|
|
redirect(base_url() . "FAQ");
|
|
}
|
|
// echo json_encode($data);
|
|
}
|
|
|
|
function edit_pertanyaan(){
|
|
$id = $this->uri->segment(3);
|
|
$pertanyaan = $this->ModelPertanyaan->get_data_edit($id);
|
|
$data = array(
|
|
'body' => 'FAQ/edit',
|
|
'form' => 'FAQ/form',
|
|
'pertanyaan' => $pertanyaan,
|
|
);
|
|
$this->load->view('index', $data);
|
|
}
|
|
function update_pertanyaan()
|
|
{
|
|
$id = $this->uri->segment(3);
|
|
$data = array(
|
|
'pertanyaan' => $this->input->post('pertanyaan'),
|
|
);
|
|
$this->db->where("id_pertanyaan", $id);
|
|
if ($this->db->update("pertanyaan", $data)) {
|
|
// code...
|
|
// $this->session->set_flashdata("notif", $this->Notif->berhasil("Berhasil Input Data"));
|
|
redirect(base_url() . "FAQ");
|
|
} else {
|
|
$this->session->set_flashdata("notif", $this->Notif->gagal("gagal Input Data"));
|
|
redirect(base_url() . "FAQ");
|
|
}
|
|
}
|
|
|
|
function delete_pertanyaan()
|
|
{
|
|
$id = $this->input->post("id_pertanyaan");
|
|
$this->db->where_in("id_pertanyaan", $id);
|
|
if ($this->db->delete("pertanyaan")) {
|
|
// $this->session->set_flashdata("notif", $this->Notif->berhasil("Berhasil Input Data"));
|
|
redirect(base_url() . "FAQ");
|
|
// code...
|
|
} else {
|
|
$this->session->set_flashdata("notif", $this->Notif->gagal("gagal Input Data"));
|
|
redirect(base_url() . "FAQ");
|
|
}
|
|
}
|
|
|
|
function jawaban()
|
|
{
|
|
$jawaban = $this->ModelJawaban->get_jawaban_edit();
|
|
$data = array(
|
|
'body' => 'Jawaban/list',
|
|
'jawaban' => $jawaban,
|
|
);
|
|
$this->load->view('index', $data);
|
|
}
|
|
public function input_jawaban()
|
|
{
|
|
$pertanyaan = $this->ModelPertanyaan->get_data();
|
|
$data = array(
|
|
'body' => 'Jawaban/input',
|
|
'form' => 'Jawaban/form',
|
|
'pertanyaan' => $pertanyaan,
|
|
);
|
|
$this->load->view('index', $data);
|
|
}
|
|
public function insert_jawaban()
|
|
{
|
|
$data = array(
|
|
'id_pertanyaan' => $this->input->post('id_pertanyaan'),
|
|
'jawaban' => $this->input->post('jawaban'),
|
|
);
|
|
if ($this->db->insert("jawaban", $data)) {
|
|
// $this->session->set_flashdata("notif", $this->Notif->berhasil("Berhasil Input Data"));
|
|
redirect(base_url() . "FAQ/Jawaban");
|
|
} else {
|
|
$this->session->set_flashdata("notif", $this->Notif->gagal("gagal Input Data"));
|
|
redirect(base_url() . "FAQ/Jawaban");
|
|
}
|
|
// echo json_encode($data);
|
|
}
|
|
|
|
function edit_jawaban(){
|
|
$id = $this->uri->segment(3);
|
|
$jawaban = $this->ModelJawaban->get_data_edit($id);
|
|
$pertanyaan = $this->ModelPertanyaan->get_data();
|
|
$data = array(
|
|
'body' => 'Jawaban/edit',
|
|
'form' => 'Jawaban/form',
|
|
'jawaban' => $jawaban,
|
|
'pertanyaan' => $pertanyaan,
|
|
);
|
|
$this->load->view('index', $data);
|
|
}
|
|
function update_jawaban()
|
|
{
|
|
$id = $this->uri->segment(3);
|
|
$data = array(
|
|
'jawaban' => $this->input->post('jawaban'),
|
|
);
|
|
$this->db->where("id_jawaban", $id);
|
|
if ($this->db->update("jawaban", $data)) {
|
|
// code...
|
|
// $this->session->set_flashdata("notif", $this->Notif->berhasil("Berhasil Input Data"));
|
|
redirect(base_url() . "FAQ/Jawaban");
|
|
} else {
|
|
$this->session->set_flashdata("notif", $this->Notif->gagal("gagal Input Data"));
|
|
redirect(base_url() . "FAQ/Jawaban");
|
|
}
|
|
}
|
|
|
|
function delete_jawaban()
|
|
{
|
|
$id = $this->input->post("id_jawaban");
|
|
$this->db->where_in("id_jawaban", $id);
|
|
if ($this->db->delete("jawaban")) {
|
|
// $this->session->set_flashdata("notif", $this->Notif->berhasil("Berhasil Input Data"));
|
|
redirect(base_url() . "FAQ/Jawaban");
|
|
// code...
|
|
} else {
|
|
$this->session->set_flashdata("notif", $this->Notif->gagal("gagal Input Data"));
|
|
redirect(base_url() . "FAQ/Jawaban");
|
|
}
|
|
}
|
|
} |