Advertisement
tanmyid

Lapor.php

Feb 21st, 2024
764
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.27 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') or exit('No direct script access allowed');
  3.  
  4. class Lapor extends CI_Controller
  5. {
  6.     public function __construct()
  7.     {
  8.         parent::__construct();
  9.         $this->load->model('panitia/Lapor_model');
  10.         $this->load->library('form_validation');
  11.         $this->load->helper(array('url', 'form'));
  12.     }
  13.  
  14.     public function index()
  15.     {
  16.         $data = [
  17.             'title' => 'Data Lapor Lelang',
  18.             'breadcrumb' => 'Data Lapor Lelang'
  19.         ];
  20.         $lelang_id = '1';
  21.         $data['queryLapor'] = $this->Lapor_model->getDataLapor();
  22.         $data['user'] = isset($_SESSION['nama']) ? $this->db->query('select * from panitia where nama = "' . $_SESSION['nama'] . '"')->row() : NULL;
  23.  
  24.         $this->load->view('panitia/partials/header', $data);
  25.         $this->load->view('panitia/partials/start', $data);
  26.         $this->load->view('panitia/lapor/index', $data);
  27.         $this->load->view('panitia/partials/end');
  28.         $this->load->view('panitia/partials/footer');
  29.     }
  30.  
  31.     // Menampilkan halaman tambah data lapor
  32.     public function tambah()
  33.     {
  34.         $this->form_validation->set_rules('tgl_lpr', 'Tanggal Lapor', 'required');
  35.         $this->form_validation->set_rules('lelang_id', 'ID Lelang', 'required');
  36.         $this->form_validation->set_rules('deskripsi', 'Deskripsi', 'required');
  37.         $this->form_validation->set_rules('nama_pelapor', 'Nama Pelapor', 'required');
  38.         $this->form_validation->set_rules('no_hp', 'Nomor HP', 'required');
  39.         $this->form_validation->set_rules('nama_pelanggar', 'Nama Pelanggar', 'required');
  40.  
  41.         if ($this->form_validation->run() == FALSE) {
  42.             $data['title'] = 'Tambah Data Lapor';
  43.             $data['lelang_options'] = $this->Lapor_model->getLelangOptions();
  44.             $data['user'] = $this->db->query('select * from panitia where nama = "' . $_SESSION['nama'] . '"')->row();
  45.             $this->load->view('panitia/partials/header', $data);
  46.             $this->load->view('panitia/partials/start', $data);
  47.             $this->load->view('panitia/lapor/index', $data);
  48.             $this->load->view('panitia/partials/end');
  49.             $this->load->view('panitia/partials/footer');
  50.         } else {
  51.             $data = array(
  52.                 'tgl_lpr' => $this->input->post('tgl_lpr'),
  53.                 'lelang_id' => $this->input->post('lelang_id'),
  54.                 'deskripsi' => $this->input->post("deskripsi"),
  55.                 'nama_pelapor' => $this->input->post("nama_pelapor"),
  56.                 'no_hp' => $this->input->post('no_hp'),
  57.                 'nama_pelanggar' => $this->input->post('nama_pelanggar'),
  58.                 'status' => 0
  59.             );
  60.  
  61.             $this->Lapor_model->tambah($data); // Perbaikan: menggunakan Lapor_model
  62.             redirect('pelelang/lapor/index');
  63.         }
  64.     }
  65.     // Menampilkan halaman edit
  66.     public function edit($id)
  67.     {
  68.         $this->form_validation->set_rules('tgl_lpr', 'Tanggal Lapor', 'required');
  69.         $this->form_validation->set_rules('lelang_id', 'ID Lelang', 'required');
  70.         $this->form_validation->set_rules('deskripsi', 'Deskripsi', 'required');
  71.         $this->form_validation->set_rules('nama_pelapor', 'Nama Pelapor', 'required');
  72.         $this->form_validation->set_rules('no_hp', 'Nomor HP', 'required');
  73.         $this->form_validation->set_rules('nama_pelanggar', 'Nama Pelanggar', 'required');
  74.  
  75.         if ($this->form_validation->run() == FALSE) {
  76.             $data['title'] = 'Edit Data Lapor';
  77.             $data['data'] = $this->Lapor_model->getDataDetail($id);
  78.             $data['user'] = $this->db->query('select * from panitia where nama = "' . $_SESSION['nama'] . '"')->row();
  79.             $data['lelang_options'] = $this->Lapor_model->getLelangOptions();
  80.             $this->load->view('panitia/partials/header', $data);
  81.             $this->load->view('panitia/partials/start', $data);
  82.             $this->load->view('panitia/lapor/index', $data);
  83.             $this->load->view('panitia/partials/end');
  84.             $this->load->view('panitia/partials/footer');
  85.         } else {
  86.             $data = array(
  87.                 'tgl_lpr' => $this->input->post('tgl_lpr'),
  88.                 'lelang_id' => $this->input->post('lelang_id'),
  89.                 'deskripsi' => $this->input->post('deskripsi'),
  90.                 'nama_pelapor' => $this->input->post('nama_pelapor'),
  91.                 'no_hp' => $this->input->post('no_hp'),
  92.                 'nama_pelanggar' => $this->input->post('nama_pelanggar'),
  93.                 'status' => 0
  94.             );
  95.  
  96.             $this->Lapor_model->updateDataLapor($id, $data); // Perbaikan: menggunakan Lapor_model
  97.             redirect('panitia/lapor/index');
  98.         }
  99.     }
  100.     // Mengonfirmasi status lapor
  101.     public function konfirmasiSudahVerifikasi($id_lapor, $pesan)
  102.     {
  103.         $this->Lapor_model->konfirmasiLapor($id_lapor, $pesan); // Perbaikan: menggunakan Lapor_model
  104.         if ($pesan == 1) {
  105.             redirect('panitia/lapor/index');
  106.         } else {
  107.             redirect('panitia/dashboard');
  108.         }
  109.     }
  110.  
  111.     // Menghapus data lapor
  112.     public function deleteLapor($id)
  113.     {
  114.         $this->Lapor_model->deleteDataLapor($id); // Perbaikan: menggunakan Lapor_model
  115.         redirect(base_url('panitia/lapor/index'));
  116.     }
  117. }
  118.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement