first commit

This commit is contained in:
kicap
2023-07-14 11:32:46 +08:00
commit 5c7d9cdfbc
1901 changed files with 341376 additions and 0 deletions

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

@ -0,0 +1,136 @@
<?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 index_post()
{
$this->response(['message' => 'Halo Bosku post', 'status' => true], 400);
// redirect(base_url());
}
// -----------------------------------------------------------------------------------------------------------
public function siswa_post()
{
$nama = $this->post('nama');
$jenis_kelamin = $this->post('jenis_kelamin');
$tanggal_lahir = $this->post('tanggal_lahir');
$tempat_lahir = $this->post('tempat_lahir');
$alamat = $this->post('alamat');
$no_telpon = $this->post('no_telpon');
$agama = $this->post('agama');
$kewarganegaraan = $this->post('kewarganegaraan');
$pendidikan_sd = $this->post('pendidikan_sd');
$pendidikan_smp = $this->post('pendidikan_smp');
$pendidikan_sma = $this->post('pendidikan_sma');
$kemampuan = $this->post('kemampuan');
$hobi = $this->post('hobi');
$foto = $_FILES['foto'];
$cek_last_ai = $this->model->cek_last_ai('tb_siswa');
$upload_dir = 'assets/siswa/'.$cek_last_ai.'/';
if (!is_dir($upload_dir)) {
mkdir($upload_dir);
}
$path = $upload_dir . $foto['name'];
move_uploaded_file($foto['tmp_name'], $path);
$array = [
'nama' => $nama,
'jenis_kelamin' => $jenis_kelamin,
'tanggal_lahir' => $tanggal_lahir,
'tempat_lahir' => $tempat_lahir,
'alamat' => $alamat,
'no_telpon' => $no_telpon,
'agama' => $agama,
'kewarganegaraan' => $kewarganegaraan,
'pendidikan_sd' => $pendidikan_sd,
'pendidikan_smp' => $pendidikan_smp,
'pendidikan_sma' => $pendidikan_sma,
'kemampuan' => $kemampuan,
'hobi' => $hobi,
'img_url' => $path
];
$this->model->insert('tb_siswa', $array);
$this->response(['message' => 'ini untuk siswa post', 'status' => $array], 200);
}
public function siswa_get()
{
$data = $this->model->tampil_data_keseluruhan('tb_siswa')->result();
$this->response(['message' => 'ini untuk siswa get', 'status' => true , 'data' => $data], 200);
}
public function siswa_detail_get()
{
$id = $this->get('id');
$data = $this->model->tampil_data_where('tb_siswa', ['id_siswa' => $id])->result();
if (count($data) == 0) return $this->response(['message' => 'data tidak ditemukan', 'status' => false], 200);
$this->response(['message' => 'ini untuk siswa get', 'status' => true , 'data' => $data[0]], 200);
}
public function dana_sosial_post()
{
$nama = $this->post('nama');
$jumlah = $this->post('jumlah');
$tanggal = $this->post('tanggal');
$array = [
'nama' => $nama,
'jumlah' => $jumlah,
'tanggal' => $tanggal,
];
$this->model->insert('tb_dana_sosial', $array);
$this->response(['message' => 'ini untuk dana sosial', 'status' => true], 200);
}
public function dana_sosial_get()
{
$data = $this->model->tampil_data_keseluruhan('tb_dana_sosial')->result();
$this->response(['message' => 'ini untuk dana sosial get', 'status' => true , 'data' => $data], 200);
}
}

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

@ -0,0 +1,111 @@
<?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[] = "<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 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));
}
}

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,25 @@
<?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);
}
}

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>