first commit

This commit is contained in:
kicap
2023-07-11 17:28:33 +08:00
commit 8b945c8750
3343 changed files with 975054 additions and 0 deletions

208
application/controllers/Api.php Executable file
View File

@ -0,0 +1,208 @@
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, DELETE, PUT');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization');
header('Access-Control-Allow-Credentials: true');
header('Content-Type: application/json');
defined('BASEPATH') or exit('No direct script access allowed');
use chriskacerguis\RestServer\RestController;
class Api extends RestController
{
function __construct()
{
parent::__construct();
$this->load->model('model');;
// $this->db->query("SET sql_mode = '' ");
date_default_timezone_set("Asia/Kuala_Lumpur");
}
public function index_get()
{
$this->response(['message' => 'Halo Bosku', 'status' => true], 200);
// redirect(base_url());
}
// -----------------------------------------------------------------------------------------------------------
public function login_get()
{
$username = $this->get('username');
$password = $this->get('password');
if ($username != "admin" && $password != "admin") return
$this->response(['message' => 'Username atau Password Salah', 'status' => false], 400);
// set session
$this->session->set_userdata('level', 'admin');
$this->response(['message' => 'Login Berhasil', 'status' => true], 200);
}
public function login_tukang_parkir_get()
{
$username = $this->get('username');
$password = $this->get('password');
$cek_login = $this->model->tampil_data_where('tb_tukang_parkir', array('nik' => $username, 'password' => $password))->result();
if (count($cek_login) == 0) return
$this->response(['message' => 'Username atau Password Salah', 'status' => false], 400);
$cek_data = $this->model->tampil_data_where('tb_area_parkir', array('nik' => $cek_login[0]->nik))->result();
$this->session->set_userdata('nik', $cek_login[0]->nik);
$this->session->set_userdata('nama', $cek_login[0]->nama);
$this->session->set_userdata('id_parkir', $cek_data[0]->id_parkir);
// set session
$this->session->set_userdata('level', 'tukang_parkir');
$this->response(['message' => 'Login Berhasil', 'status' => true], 200);
}
public function kabupaten_maps_get()
{
$check_data = $this->model->tampil_data_where('tb_kabupaten', array('no' => '1'))->result();
$data = $check_data[0]->kordinat;
$this->response(['message' => 'Berhasil', 'status' => true, 'data' => json_decode($data,true)], 200);
}
public function all_kecamatan_get(){
$check_data = $this->model->tampil_data_keseluruhan('tb_kecamatan')->result();
$this->response(['message' => 'Berhasil', 'status' => true, 'data' => $check_data], 200);
}
public function all_kelurahan_get(){
$id_kecamatan = $this->get('id_kecamatan');
$check_data = $this->model->tampil_data_where('tb_kelurahan' , ['kecamatan' => $id_kecamatan])->result();
$check_maps = $this->model->tampil_data_where('tb_kecamatan' , ['no' => $id_kecamatan])->result();
if(count($check_data) == 0) return $this->response(['message' => 'Data Tidak Ditemukan', 'status' => false], 400);
$maps = $check_maps[0]->kordinat;
$this->response(['message' => 'Berhasil', 'status' => true, 'data' => $check_data , 'maps' => json_decode($maps,true)], 200);
}
public function kelurahan_maps_get(){
$id_kelurahan = $this->get('id_kelurahan');
$check_data = $this->model->tampil_data_where('tb_kelurahan' , ['no' => $id_kelurahan])->result();
if(count($check_data) == 0) return $this->response(['message' => 'Data Tidak Ditemukan', 'status' => false], 400);
$maps = $check_data[0]->kordinat;
$this->response(['message' => 'Berhasil', 'status' => true, 'data' => json_decode($maps,true)], 200);
}
public function tambah_parkir_post(){
$id_kecamatan = $this->post('kecamatan_id');
$id_kelurahan = $this->post('kelurahan_id');
$kordinat = $this->post('kordinat');
$center = $this->post('center');
$alamat = $this->post('alamat');
$luas = $this->post('luas');
$nik = $this->post('nik');
$nama = $this->post('nama');
$biaya_motor = $this->post('biaya_motor');
$biaya_mobil = $this->post('biaya_mobil');
if($id_kecamatan == null || $id_kelurahan == null || $kordinat == null || $center == null || $alamat == null || $luas == null) return $this->response(['message' => 'Data Tidak Boleh Kosong', 'status' => false], 400);
$array = [
// 'kecamatan' => $id_kecamatan,
'id_kelurahan' => $id_kelurahan,
'kordinat' => $kordinat,
'center' => $center,
'alamat' => $alamat,
'luas' => $luas,
];
$this->model->insert('tb_tukang_parkir', array('nik' => $nik, 'nama' => $nama, 'password' => 12345678));
$this->model->insert('tb_area_parkir', $array);
$this->response(['message' => 'Berhasil', 'status' => true, 'data' => $array], 200);
}
public function area_parkir_get(){
$check_data = $this->model->tampil_data_keseluruhan('tb_area_parkir')->result();
$this->response(['message' => 'Berhasil', 'status' => true, 'data' => $check_data], 200);
}
public function area_parkir_delete(){
$id = $this->delete('id');
if($id == null) return $this->response(['message' => 'Data Tidak Boleh Kosong', 'status' => false], 400);
$this->model->delete('tb_area_parkir', ['id_parkir' => $id]);
$this->response(['message' => 'Berhasil', 'status' => true,"id" => $id], 200);
}
public function data_tukang_parkir_get(){
$check_data = $this->model->custom_query("SELECT * FROM tb_tukang_parkir a join tb_area_parkir b on a.nik = b.nik where a.nik = '".$this->session->userdata('nik')."'")->result();
if (count($check_data) == 0) return $this->response(['message' => 'Data Tidak Ditemukan', 'status' => false], 400);
$check_kelurahan = $this->model->tampil_data_where('tb_kelurahan', ['no' => $check_data[0]->id_kelurahan])->result();
$check_kecamatan = $this->model->tampil_data_where('tb_kecamatan', ['no' => $check_kelurahan[0]->kecamatan])->result();
$kecamatan = $check_kecamatan[0]->kecamatan;
$kelurahan = $check_kelurahan[0]->kelurahan;
$this->response(['message' => 'Berhasil', 'status' => true, 'data' => $check_data[0], 'kecamatan' => $kecamatan, 'kelurahan' => $kelurahan], 200);
// $this->response(['message' => 'Berhasil', 'status' => true, 'data' => "ini dia"], 200);
}
public function ganti_password_post(){
$password_lama = $this->post('password_lama');
$password_baru = $this->post('password_baru');
$cek_data = $this->model->tampil_data_where('tb_tukang_parkir', ['nik' => $this->session->userdata('nik')])->result();
if(count($cek_data) == 0) return $this->response(['message' => 'Data Tidak Ditemukan', 'status' => false], 400);
if($cek_data[0]->password != $password_lama) return $this->response(['message' => 'Password Lama Salah', 'status' => false], 200);
$this->model->update('tb_tukang_parkir', ['nik' => $this->session->userdata('nik')], ['password' => $password_baru]);
$this->response(['message' => 'Berhasil', 'status' => true], 200);
}
public function kritik_post(){
$id_parkir = $this->post('id_parkir');
$nama = $this->post('nama');
$kritik = $this->post('kritik');
$cek_data = $this->model->tampil_data_where('tb_area_parkir', ['id_parkir' => $id_parkir])->result();
if(count($cek_data) == 0) return $this->response(['message' => 'Data Tidak Ditemukan', 'status' => false], 400);
$this->model->insert('tb_kritik', ['id_parkir' => $id_parkir, 'kritik' => $kritik, 'nama' => $nama]);
$this->response(['message' => 'Kritik Berhasil Dikirim', 'status' => true], 200);
}
public function kritik_get(){
$id_kritik = $this->get('id_kritik');
$cek_data = $this->model->tampil_data_where('tb_kritik', ['id_kritik' => $id_kritik])->result();
if(count($cek_data) == 0) return $this->response(['message' => 'Data Tidak Ditemukan', 'status' => false], 400);
$this->response(['message' => 'Berhasil', 'status' => true, 'data' => $cek_data[0]], 200);
}
}

230
application/controllers/Home.php Executable file
View File

@ -0,0 +1,230 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Home extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('model');
$this->load->model('m_tabel_ss');
if ($this->session->userdata('level') != "admin") {
// remove session
$this->session->unset_userdata('level');
redirect(base_url("login"));
}
}
function index()
{
$main['header'] = "Halaman Utama";
// $main['content'] = "admin/content/index";
$this->load->view('admin/index', $main);
}
function parkir()
{
if ($this->input->post('proses') == "table_area_parkir") {
$list = $this->m_tabel_ss->get_datatables(array('luas','alamat'), array(null, 'alamat',null, null, 'luas', null), array('id_parkir' => 'desc'), "tb_area_parkir", null,null, "*");
$data = array();
$no = $_POST['start'];
foreach ($list as $field) {
$kecamatan = '';
$kelurahan = '';
$cek_kelurahan = $this->model->tampil_data_where('tb_kelurahan', array('no' => $field->id_kelurahan))->result();
$kelurahan = $cek_kelurahan[0]->kelurahan;
$cek_kecamatan = $this->model->tampil_data_where('tb_kecamatan', array('no' => $cek_kelurahan[0]->kecamatan))->result();
$kecamatan = $cek_kecamatan[0]->kecamatan;
$no++;
$row = array();
$row[] = $no;
$row[] = $field->alamat;
$row[] = $kecamatan;
$row[] = $kelurahan;
$row[] = $field->luas . " m<sup>2</sup>";
$row[] = "Rp." . number_format($field->biaya_motor, 0, ',', '.');
$row[] = "Rp." . number_format($field->biaya_mobil, 0, ',', '.');
$row[] = "<center><button type='button' onclick='hapus_area_parkir(".$field->id_parkir.")' title='Hapus Area Parkir' class='btn btn-danger btn-circle btn-sm waves-effect waves-light'><i class='ico zmdi zmdi-delete'></i></button></center>";
$data[] = $row;
}
$output = array(
"draw" => $_POST['draw'],
"recordsTotal" => $this->m_tabel_ss->count_all("tb_area_parkir", null, null, "*"),
"recordsFiltered" => $this->m_tabel_ss->count_filtered(array('luas','alamat'), array(null, 'alamat',null, null, 'luas', null), array('id_parkir' => 'desc'), "tb_area_parkir", null,null, "*"),
"data" => $data,
);
//output dalam format JSON
echo json_encode($output);
} else {
$main['header'] = "Pengaturan Parkir";
// $main['content'] = "admin/content/pengaturan_parkir";
$this->load->view('admin/content/parkir', $main);
}
}
function tukang_parkir()
{
if ($this->input->post('proses') == "table_tukang_parkir") {
$list = $this->m_tabel_ss->get_datatables(array('nik','nama'), array(null, 'nik','nama', null, null), array('nik' => 'desc'), "tb_tukang_parkir", null,null, "*");
$data = array();
$no = $_POST['start'];
foreach ($list as $field) {
$cek_data = $this->model->tampil_data_where('tb_area_parkir', array('nik' => $field->nik))->result();
$kecamatan = '';
$kelurahan = '';
$cek_kelurahan = $this->model->tampil_data_where('tb_kelurahan', array('no' => $cek_data[0]->id_kelurahan))->result();
$kelurahan = $cek_kelurahan[0]->kelurahan;
$cek_kecamatan = $this->model->tampil_data_where('tb_kecamatan', array('no' => $cek_kelurahan[0]->kecamatan))->result();
$kecamatan = $cek_kecamatan[0]->kecamatan;
$no++;
$row = array();
$row[] = $no;
$row[] = $field->nik;
$row[] = $field->nama;
$row[] = $kecamatan;
$row[] = $kelurahan;
$row[] = $cek_data[0]->alamat;
// $row[] = $field->luas . " m<sup>2</sup>";
// $row[] = "Rp." . number_format($field->biaya_motor, 0, ',', '.');
// $row[] = "Rp." . number_format($field->biaya_mobil, 0, ',', '.');
// $row[] = "<center><button type='button' onclick='hapus_area_parkir(".$field->id_parkir.")' title='Hapus Area Parkir' class='btn btn-danger btn-circle btn-sm waves-effect waves-light'><i class='ico zmdi zmdi-delete'></i></button></center>";
$data[] = $row;
}
$output = array(
"draw" => $_POST['draw'],
"recordsTotal" => $this->m_tabel_ss->count_all("tb_area_parkir", null, null, "*"),
"recordsFiltered" => $this->m_tabel_ss->count_filtered(array('nik','nama'), array(null, 'nik','nama', null, null), array('nik' => 'desc'), "tb_tukang_parkir", null,null, "*"),
"data" => $data,
);
//output dalam format JSON
echo json_encode($output);
} else {
$main['header'] = "List Tukang Parkir";
// $main['content'] = "admin/content/pengaturan_parkir";
$this->load->view('admin/content/tukang_parkir', $main);
}
}
function parkir_index()
{
if ($this->input->post('proses') == "table_area_parkir") {
$list = $this->m_tabel_ss->get_datatables(array('luas','alamat'), array(null, 'alamat',null, null, 'luas', null), array('id_parkir' => 'desc'), "tb_area_parkir", null,null, "*");
$data = array();
$no = $_POST['start'];
foreach ($list as $field) {
$kecamatan = '';
$kelurahan = '';
$cek_kelurahan = $this->model->tampil_data_where('tb_kelurahan', array('no' => $field->id_kelurahan))->result();
$kelurahan = $cek_kelurahan[0]->kelurahan;
$cek_kecamatan = $this->model->tampil_data_where('tb_kecamatan', array('no' => $cek_kelurahan[0]->kecamatan))->result();
$kecamatan = $cek_kecamatan[0]->kecamatan;
$no++;
$row = array();
$row[] = $no;
$row[] = $field->alamat;
$row[] = $kecamatan;
$row[] = $kelurahan;
$row[] = $field->luas . " m<sup>2</sup>";
$row[] = "Rp." . number_format($field->biaya_motor, 0, ',', '.');
$row[] = "Rp." . number_format($field->biaya_mobil, 0, ',', '.');
$data[] = $row;
}
$output = array(
"draw" => $_POST['draw'],
"recordsTotal" => $this->m_tabel_ss->count_all("tb_area_parkir", null, null, "*"),
"recordsFiltered" => $this->m_tabel_ss->count_filtered(array('luas','alamat'), array(null, 'alamat',null, null, 'luas', null), array('id_parkir' => 'desc'), "tb_area_parkir", null,null, "*"),
"data" => $data,
);
//output dalam format JSON
echo json_encode($output);
} else {
$main['header'] = "Pengaturan Parkir";
// $main['content'] = "admin/content/pengaturan_parkir";
$this->load->view('admin/content/parkir', $main);
}
}
function logout(){
$this->session->sess_destroy();
redirect(base_url("login"));
}
function coba()
{
$check_data = $this->model->tampil_data_where('tb_kelurahan', array('no' => '21'))->result();
$data = $check_data[0]->kordinat;
$data = json_decode($data, true);
print_r($data[0]['kordinat']);
}
function coba1()
{
$string = '';
// replace lng and lat to "lng" and "lat" and remove space and last comma
$string = str_replace('lng:', '"lng":', $string);
$string = str_replace('lat:', '"lat":', $string);
$string = str_replace(' ', '', $string);
$string = substr($string, 0, -1);
// add square bracket
$string = '[' . $string . ']';
print_r($string);
}
function coba2()
{
$array = '';
$array = json_decode($array, true);
print_r($array);
// print_r(json_encode($array));
}
function coba_input()
{
$check_data = $this->model->tampil_data_keseluruhan('tb_area_parkir')->result();
foreach ($check_data as $key => $value) {
$data = $value->kordinat;
$ktp =737202300;
$random8 = rand(10000000, 99999999);
$nik = $ktp . $random8;
// create random indonesia name
$this->model->insert('tb_tukang_parkir', array(
'nik' => $nik,
'password' => 12345678,
));
$this->model->update('tb_area_parkir', array('id_parkir' => $value->id_parkir),array('nik' => $nik));
}
}
}

View File

@ -0,0 +1,19 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Login extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('model');
$this->load->model('m_tabel_ss');
}
public function index()
{
$this->load->view('login/index');
}
}
?>

View File

@ -0,0 +1,98 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Tukang_parkir extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('model');
$this->load->model('m_tabel_ss');
// if ($this->session->userdata('level') != "tukang_parkir") {
// // remove session
// $this->session->unset_userdata('level');
// redirect(base_url("tukang_parkir/login"));
// }
}
function index()
{
if ($this->session->userdata('level') != "tukang_parkir") {
// remove session
$this->session->unset_userdata(array('level', 'nik', 'nama'));
redirect(base_url("tukang_parkir/login"));
}
$main['header'] = "Area Parkir Parepare";
// $main['content'] = "admin/content/index";
$this->load->view('tukang_parkir/index', $main);
}
function kritik()
{
if ($this->session->userdata('level') != "tukang_parkir") {
// remove session
$this->session->unset_userdata(array('level', 'nik', 'nama'));
redirect(base_url("tukang_parkir/login"));
}
if ($this->input->post('proses') == "table_area_parkir") {
$list = $this->m_tabel_ss->get_datatables(array('created_at','nama'), array('created_at','nama',null), array('id_kritik' => 'desc'), "tb_kritik", null,['id_parkir' =>$this->session->userdata('id_parkir')], "*");
$data = array();
$no = $_POST['start'];
foreach ($list as $field) {
$no++;
$row = array();
$row[] = $field->created_at;
$row[] = $field->nama;
$row[] = "<center><button type='button' onclick='lihat_kritik(".$field->id_kritik.")' title='Hapus Area Parkir' class='btn btn-info btn-circle btn-sm waves-effect waves-light'><i class='ico zmdi zmdi-info'></i></button></center>";
$data[] = $row;
}
$output = array(
"draw" => $_POST['draw'],
"recordsTotal" => $this->m_tabel_ss->count_all("tb_kritik", null, null, "*"),
"recordsFiltered" => $this->m_tabel_ss->count_filtered(array('created_at','nama'), array('created_at','nama',null), array('id_kritik' => 'desc'), "tb_area_parkir", null,['id_parkir' =>$this->session->userdata('id_parkir')], "*"),
"data" => $data,
);
//output dalam format JSON
echo json_encode($output);
} else {
$main['header'] = "Kritik Dan Komen";
// $main['content'] = "admin/content/index";
$this->load->view('tukang_parkir/content/kritik', $main);
}
}
function password()
{
if ($this->session->userdata('level') != "tukang_parkir") {
// remove session
$this->session->unset_userdata(array('level', 'nik', 'nama'));
redirect(base_url("tukang_parkir/login"));
}
$main['header'] = "Ganti Password";
// $main['content'] = "admin/content/index";
$this->load->view('tukang_parkir/content/password', $main);
}
function login()
{
$this->load->view('tukang_parkir/login');
}
function logout()
{
// remove session
$this->session->unset_userdata(array('level', 'nik', 'nama'));
redirect(base_url("tukang_parkir/login"));
}
}

View File

@ -0,0 +1,70 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class User extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('model');
$this->load->model('m_tabel_ss');
}
function index()
{
$main['header'] = "Area Parkir Parepare";
// $main['content'] = "admin/content/index";
$this->load->view('user/index', $main);
}
function parkir_index()
{
if ($this->input->post('proses') == "table_area_parkir") {
$list = $this->m_tabel_ss->get_datatables(array('luas','alamat'), array(null, 'alamat',null, null, 'luas', null), array('id_parkir' => 'desc'), "tb_area_parkir", null,null, "*");
$data = array();
$no = $_POST['start'];
foreach ($list as $field) {
$kecamatan = '';
$kelurahan = '';
$cek_kelurahan = $this->model->tampil_data_where('tb_kelurahan', array('no' => $field->id_kelurahan))->result();
$kelurahan = $cek_kelurahan[0]->kelurahan;
$cek_kecamatan = $this->model->tampil_data_where('tb_kecamatan', array('no' => $cek_kelurahan[0]->kecamatan))->result();
$kecamatan = $cek_kecamatan[0]->kecamatan;
$no++;
$row = array();
$row[] = $no;
$row[] = $field->alamat;
$row[] = $kecamatan;
$row[] = $kelurahan;
$row[] = $field->luas . " m<sup>2</sup>";
$row[] = "Rp." . number_format($field->biaya_motor, 0, ',', '.');
$row[] = "Rp." . number_format($field->biaya_mobil, 0, ',', '.');
$data[] = $row;
}
$output = array(
"draw" => $_POST['draw'],
"recordsTotal" => $this->m_tabel_ss->count_all("tb_area_parkir", null, null, "*"),
"recordsFiltered" => $this->m_tabel_ss->count_filtered(array('luas','alamat'), array(null, 'alamat',null, null, 'luas', null), array('id_parkir' => 'desc'), "tb_area_parkir", null,null, "*"),
"data" => $data,
);
//output dalam format JSON
echo json_encode($output);
} else {
$main['header'] = "Pengaturan Parkir";
// $main['content'] = "admin/content/pengaturan_parkir";
$this->load->view('admin/content/parkir', $main);
}
}
}

View File

@ -0,0 +1,25 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {
/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* @see https://codeigniter.com/user_guide/general/urls.html
*/
public function index()
{
$this->load->view('welcome_message');
}
}

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>