Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- require APPPATH . '/libraries/REST_Controller.php';
- class Dataapi extends REST_Controller {
- function __construct($config = 'rest') {
- parent::__construct($config);
- }
- // Data Login
- function login_post() {
- $username = trim($this->post('username'));
- $password = trim($this->post('password'));
- $this->db->select('*');
- $this->db->from('rtlh_users');
- $this->db->where('user_username', $username);
- $hasiluser = $this->db->get()->row(); // Hasil Cek Username
- if (count($hasiluser) == 0) {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'Username Tidak Terdaftar'
- ];
- } else {
- $this->db->select('u.*, p.penduduk_nama');
- $this->db->from('rtlh_users u');
- $this->db->join('rtlh_penduduk_dukcapil p', 'u.user_username = p.penduduk_nik');
- $this->db->where('u.user_username', $username);
- $this->db->where('u.user_password', sha1($password));
- $this->db->where('u.user_status', 'Aktif');
- $hasilakun = $this->db->get()->row(); // Hasil Cek Username dan Password
- if (count($hasilakun) == 0) {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'Username atau Password Salah.'
- ];
- } else {
- $response[] = array(
- 'resp_error' => false,
- 'resp_msg' => 'Success',
- 'username' => trim($hasilakun->user_username),
- 'nama' => trim($hasilakun->penduduk_nama),
- 'avatar' => base_url('img/icon/'.$hasilakun->user_image),
- 'level' => $hasilakun->user_level
- );
- }
- }
- $this->response($response, 200);
- }
- // Data RTLH per Fasilitator
- function listbyfasilitator_get() {
- $username = trim($this->get('username'));
- if ($username == '') { // Jika Username Kosong
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'ID Fasilitator Masih Kosong.'
- ];
- $this->response($response, 200);
- } else {
- $this->db->select('r.*, p.penduduk_no_kk, p.penduduk_nama, p.penduduk_jk, p.penduduk_alamat,
- p.penduduk_rt, p.penduduk_rw, c.nama_kec, k.nama_kel, p.penduduk_tmpt_lhr, p.penduduk_tgl_lahir');
- $this->db->from('rtlh_rtlh r');
- $this->db->join('rtlh_penduduk_dukcapil p', 'r.penduduk_nik = p.penduduk_nik');
- $this->db->join('rtlh_kec c', 'p.no_kec = c.no_kec');
- $this->db->join('rtlh_kel k', 'p.no_kel = k.no_kel');
- $this->db->where('k.no_kec = c.no_kec');
- $this->db->where('r.rtlh_aktif', 1); // Aktif
- $this->db->where('r.rtlh_step >=', 3); // Verifikasi ke Atas
- $this->db->where('r.user_pengampu', $username);
- $listRTLH = $this->db->get()->result();
- if (count($listRTLH) > 0) {
- $response = [
- 'resp_error' => false,
- 'resp_msg' => "Success",
- 'items' => []
- ];
- foreach ($listRTLH as $r) {
- $rtlh_id = $r->rtlh_id;
- // 0 Persen
- $this->db->select('*');
- $this->db->from('rtlh_foto_rumah');
- $this->db->where('rtlh_id', $rtlh_id);
- $this->db->where('foto_tipe', '0');
- $this->db->order_by('foto_id', 'asc');
- $listFoto = $this->db->get()->result();
- if (count($listFoto) == 0) {
- $foto_rmh_0 = '';
- $foto_atap_0 = '';
- $foto_dinding_0 = '';
- $foto_lantai_0 = '';
- $is_valid_0 = false;
- } else {
- foreach($listFoto as $f) {
- $foto_nama = trim($f->foto_nama);
- switch ($foto_nama) {
- case 'Rumah': // Rumah
- $foto_1 = $f->foto_file;
- $foto_rmh_0 = base_url('img/foto_rumah/'.$f->foto_file);
- break;
- case 'Atap': // Atap
- $foto_2 = $f->foto_file;
- $foto_atap_0 = base_url('img/foto_rumah/'.$f->foto_file);
- break;
- case 'Dinding': // Dinding
- $foto_3 = $f->foto_file;
- $foto_dinding_0 = base_url('img/foto_rumah/'.$f->foto_file);
- break;
- case 'Lantai': // Lantai
- $foto_4 = $f->foto_file;
- $foto_lantai_0 = base_url('img/foto_rumah/'.$f->foto_file);
- break;
- }
- }
- // Kondisi Form Valid/Tidak
- if (!empty($foto_1) && !empty($foto_2) && !empty($foto_3) && !empty($foto_4)) {
- $is_valid_0 = true;
- } else {
- $is_valid_0 = false;
- }
- }
- // 50 Persen
- $this->db->select('*');
- $this->db->from('rtlh_foto_rumah');
- $this->db->where('rtlh_id', $rtlh_id);
- $this->db->where('foto_tipe', '50');
- $this->db->order_by('foto_id', 'asc');
- $listFoto1 = $this->db->get()->result();
- if (count($listFoto1) == 0) {
- $foto_rmh_50 = '';
- $foto_atap_50 = '';
- $foto_dinding_50 = '';
- $foto_lantai_50 = '';
- $is_valid_50 = false;
- } else {
- foreach($listFoto1 as $f) {
- $foto_nama = trim($f->foto_nama);
- switch ($foto_nama) {
- case 'Rumah': // Rumah
- $foto_5 = $f->foto_file;
- $foto_rmh_50 = base_url('img/foto_rumah/'.$f->foto_file);
- break;
- case 'Atap': // Atap
- $foto_6 = $f->foto_file;
- $foto_atap_50 = base_url('img/foto_rumah/'.$f->foto_file);
- break;
- case 'Dinding': // Dinding
- $foto_7 = $f->foto_file;
- $foto_dinding_50= base_url('img/foto_rumah/'.$f->foto_file);
- break;
- case 'Lantai': // Lantai
- $foto_8 = $f->foto_file;
- $foto_lantai_50 = base_url('img/foto_rumah/'.$f->foto_file);
- break;
- }
- }
- // Kondisi Form Valid/Tidak
- if (!empty($foto_5) && !empty($foto_6) && !empty($foto_7) && !empty($foto_8)) {
- $is_valid_50 = true;
- } else {
- $is_valid_50 = false;
- }
- }
- // 100 Persen
- $this->db->select('*');
- $this->db->from('rtlh_foto_rumah');
- $this->db->where('rtlh_id', $rtlh_id);
- $this->db->where('foto_tipe', '100');
- $this->db->order_by('foto_id', 'asc');
- $listFoto2 = $this->db->get()->result();
- if (count($listFoto2) == 0) {
- $foto_rmh_100 = '';
- $foto_atap_100 = '';
- $foto_dinding_100 = '';
- $foto_lantai_100 = '';
- $is_valid_100 = false;
- } else {
- foreach($listFoto2 as $f) {
- $foto_nama = trim($f->foto_nama);
- switch ($foto_nama) {
- case 'Rumah': // Rumah
- $foto_9 = $f->foto_file;
- $foto_rmh_100 = base_url('img/foto_rumah/'.$f->foto_file);
- break;
- case 'Atap': // Atap
- $foto_10 = $f->foto_file;
- $foto_atap_100 = base_url('img/foto_rumah/'.$f->foto_file);
- break;
- case 'Dinding': // Dinding
- $foto_11 = $f->foto_file;
- $foto_dinding_100 = base_url('img/foto_rumah/'.$f->foto_file);
- break;
- case 'Lantai': // Lantai
- $foto_12 = $f->foto_file;
- $foto_lantai_100 = base_url('img/foto_rumah/'.$f->foto_file);
- break;
- }
- }
- // Kondisi Form Valid/Tidak
- if (!empty($foto_9) && !empty($foto_10) && !empty($foto_11) && !empty($foto_12)) {
- $is_valid_100 = true;
- } else {
- $is_valid_100 = false;
- }
- }
- // Cek Foto Profil
- if (empty($r->rtlh_foto)) {
- $is_valid_foto = false;
- } else {
- $is_valid_foto = true;
- }
- // Cek Scan KTP
- if (empty($r->rtlh_foto_ktp) && empty($r->rtlh_foto_kk)) {
- $is_valid_ktp_kk = false;
- } else {
- $is_valid_ktp_kk = true;
- }
- $response['items'][] = [
- 'tanggal' => tgl_indo($r->rtlh_post),
- 'rtlh_id' => $r->rtlh_id,
- 'kd_wilayah'=> trim($r->rtlh_kode_wilayah),
- 'nik' => trim($r->penduduk_nik),
- 'no_rtlh' => trim($r->rtlh_no_urut),
- 'alias' => trim($r->penduduk_nama),
- 'alamat' => $r->penduduk_alamat.' RT. '.$r->penduduk_rt.' RW. '.$r->penduduk_rw.' DESA '.$r->nama_kel.' KEC. '.$r->nama_kec,
- 'jk' => trim($r->penduduk_jk),
- 'tmpt_lahir'=> trim($r->penduduk_tmpt_lhr),
- 'tgl_lahir' => $r->penduduk_tgl_lahir,
- 'pbdt' => trim($r->rtlh_pbdt),
- 'status' => trim($r->rtlh_prioritas),
- 'data' => [
- 'data_pendukung' => [
- 'is_form_valid' => true,
- 'penghasilan_perbulan' => $r->penghasilan_id,
- 'pengeluaran_perbulan' => $r->pengeluaran_id,
- 'status_kepemilikan_tanah' => $r->status_tanah_id,
- 'bukti_kepemilikan_tanah' => $r->bukti_tanah_id,
- 'status_kepemilikan_rumah' => $r->pemilik_rumah_id,
- 'aset_rumah_lain' => $r->rtlh_rumah_lain,
- 'aset_tanah_lain' => $r->rtlh_tanah_lain,
- 'imb' => $r->rtlh_imb,
- 'bantuan_perumahan' => $r->bantuan_id
- ],
- 'data_kondisi_fisik_rumah' => [
- 'is_form_valid' => true,
- 'pondasi_bangunan' => $r->bantuan_id,
- 'kondisi_balok_kolom' => $r->rtlh_kondisi_balok,
- 'kondisi_konstruksi_atap' => $r->rtlh_kondisi_atap,
- 'jendela_lubang_cahaya' => $r->rtlh_jendela,
- 'ventilasi' => $r->ventilasi_id,
- 'sanitasi' => $r->rtlh_sanitasi,
- 'kondisi_sanitasi' => $r->rtlh_kondisi_sanitasi,
- 'jenis_sanitasi' => $r->sanitasi_id,
- 'septitank' => $r->rtlh_septitank,
- 'kondisi_septitank' => $r->rtlh_kondisi_septitank,
- 'sumber_air_minum' => $r->air_minum_id,
- 'sumber_listrik' => $r->listrik_id
- ],
- 'aspek_persyaratan' => [
- 'is_form_valid' => true,
- 'luas_rumah' => $r->rtlh_luas,
- 'jumlah_penghuni' => $r->rtlh_jml_orang,
- 'no_kk_lain' => $r->rtlh_no_kk_lain,
- 'jml_kk' => $r->rtlh_jml_kk,
- 'tinggi_bangunan' => $r->tinggi_id,
- 'rg_keluarga' => $r->rtlh_ruang_keluarga
- ],
- 'aspek_komponen' => [
- 'is_form_valid' => true,
- 'material_atap' => $r->material_atap_id,
- 'kondisi_atap' => $r->kondisi_atap_id,
- 'material_dinding_terluas' => $r->material_dinding_id,
- 'kondisi_dinding' => $r->kondisi_dinding_id,
- 'material_lantai' => $r->material_lantai_id,
- 'luas_lantai' => $r->luas_lantai_id
- ],
- 'foto_pemilik' => [
- "foto_pemilik" => [
- 'type' => 'online',
- 'source' => base_url('img/foto/'.$r->rtlh_foto),
- 'latitude' => '',
- 'longitude' => '',
- 'height' => 800,
- 'width' => 600
- ],
- 'is_form_valid' => $is_valid_foto
- ],
- "foto_ktp_kk" => [
- "ktp" => [
- 'type' => 'online',
- 'source' => base_url('img/foto_ktp_kk/'.$r->rtlh_foto_ktp),
- 'latitude' => '',
- 'longitude' => '',
- 'height' => 0,
- 'width' => 300
- ],
- "kk" => [
- 'type' => 'online',
- 'source' => base_url('img/foto_ktp_kk/'.$r->rtlh_foto_kk),
- 'latitude' => '',
- 'longitude' => '',
- 'height' => 0,
- 'width' => 300
- ],
- 'is_form_valid' => $is_valid_ktp_kk
- ],
- "lokasi_rumah" => [
- 'is_form_valid' => true,
- 'latitude' => $r->rtlh_lat,
- 'longitude' => $r->rtlh_long,
- 'batas_utara' => $r->rtlh_bts_utara,
- 'batas_timur' => $r->rtlh_bts_timur,
- 'batas_selatan' => $r->rtlh_bts_selatan,
- 'batas_barat' => $r->rtlh_bts_barat
- ],
- "foto_bangunan_0" => [
- "bangunan" => [
- 'type' => 'online',
- 'source' => $foto_rmh_0,
- 'latitude' => '',
- 'longitude' => '',
- 'height' => 600,
- 'width' => 800
- ],
- "atap" => [
- 'type' => 'online',
- 'source' => $foto_atap_0,
- 'latitude' => '',
- 'longitude' => '',
- 'height' => 600,
- 'width' => 800
- ],
- "dinding" => [
- 'type' => 'online',
- 'source' => $foto_dinding_0,
- 'latitude' => '',
- 'longitude' => '',
- 'height' => 600,
- 'width' => 800
- ],
- "lantai" => [
- 'type' => 'online',
- 'source' => $foto_lantai_0,
- 'latitude' => '',
- 'longitude' => '',
- 'height' => 600,
- 'width' => 800
- ],
- 'is_form_valid' => $is_valid_0
- ],
- "foto_bangunan_50" => [
- "bangunan" => [
- 'type' => 'online',
- 'source' => $foto_rmh_50,
- 'latitude' => '',
- 'longitude' => '',
- 'height' => 600,
- 'width' => 800
- ],
- "atap" => [
- 'type' => 'online',
- 'source' => $foto_atap_50,
- 'latitude' => '',
- 'longitude' => '',
- 'height' => 600,
- 'width' => 800
- ],
- "dinding" => [
- 'type' => 'online',
- 'source' => $foto_dinding_50,
- 'latitude' => '',
- 'longitude' => '',
- 'height' => 600,
- 'width' => 800
- ],
- "lantai" => [
- 'type' => 'online',
- 'source' => $foto_lantai_50,
- 'latitude' => '',
- 'longitude' => '',
- 'height' => 600,
- 'width' => 800
- ],
- 'is_form_valid' => $is_valid_50
- ],
- "foto_bangunan_100" => [
- "bangunan" => [
- 'type' => 'online',
- 'source' => $foto_rmh_100,
- 'latitude' => '',
- 'longitude' => '',
- 'height' => 600,
- 'width' => 800
- ],
- "atap" => [
- 'type' => 'online',
- 'source' => $foto_atap_100,
- 'latitude' => '',
- 'longitude' => '',
- 'height' => 600,
- 'width' => 800
- ],
- "dinding" => [
- 'type' => 'online',
- 'source' => $foto_dinding_100,
- 'latitude' => '',
- 'longitude' => '',
- 'height' => 600,
- 'width' => 800
- ],
- "lantai" => [
- 'type' => 'online',
- 'source' => $foto_lantai_100,
- 'latitude' => '',
- 'longitude' => '',
- 'height' => 600,
- 'width' => 800
- ],
- 'is_form_valid' => $is_valid_100
- ]
- ]
- ];
- }
- } else {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => "Data Tidak Ada."
- ];
- }
- $this->response($response, 200);
- }
- }
- // Insert ke Table RTLH
- function insertrtlh_post() {
- // Upload File ZIP Android
- $config['upload_path'] = './temp_sync/dataoperator/';
- $config['max_size'] = '*';
- $this->load->library('upload');
- $this->upload->initialize($config);
- $upload = $this->upload->do_upload('zipfile');
- $upload_data = $this->upload->data();
- $file_name = $upload_data['full_path']; // File Full Path
- $nama_file = $upload_data['raw_name'];
- $json_file = $upload_data['raw_name'].'.json'; // JSON File
- $zip = new ZipArchive;
- if ($zip->open($file_name) === TRUE) {
- // Buat Folder jika belum Ada
- if (!file_exists('./temp_sync/dataoperator/data_ekstrak/'.$nama_file)) {
- mkdir('./temp_sync/dataoperator/data_ekstrak/'.$nama_file, 0755, true);
- } else {
- // Delete Folder Lama
- $src = './temp_sync/dataoperator/data_ekstrak/'.$nama_file;
- $dir = opendir($src);
- while(false !== ( $file = readdir($dir)) ) {
- if (( $file != '.' ) && ( $file != '..' )) {
- if ( is_dir($src . '/' . $file) ) {
- delete_dir($src . '/' . $file);
- }
- else {
- unlink($src . '/' . $file);
- }
- }
- }
- closedir($dir);
- rmdir($src);
- // Buat Folder baru lagi
- mkdir('./temp_sync/dataoperator/data_ekstrak/'.$nama_file, 0755, true);
- }
- $zip->extractTo('./temp_sync/dataoperator/data_ekstrak/'.$nama_file);
- $zip->close();
- } else {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => "Ekstrak ZIP Gagal."
- ];
- }
- unlink($file_name); // Delete Zip
- // $this->response($response, 200);
- // Baca File JSON
- if(file_exists('./temp_sync/dataoperator/data_ekstrak/'.$nama_file.'/'.$json_file)) {
- $document = file_get_contents(FCPATH.'temp_sync/dataoperator/data_ekstrak/'.$nama_file.'/'.$json_file);
- $data = json_decode($document);
- // Cek Data API Dukcapil
- $this->load->library('curl');
- $nik = trim($data->nik); // NIK
- $this->curl->http_header('Content-Type: application/json');
- $this->curl->create('http://222.124.25.110:8000/dukcapil/get_json/DISPERKIM/NIK');
- $this->curl->post(json_encode(["user_id"=>"DISPERKIM","password"=>"rumah","nik"=> $nik]));
- $response = $this->curl->execute();
- $curl_jason = json_decode($response, true, 512, JSON_BIGINT_AS_STRING);
- if(count($curl_jason) > 0) {
- $kd_wilayah = substr($curl_jason['content'][0]['NIK'], 0, 6);
- $nik = $curl_jason['content'][0]['NIK'];
- $nama = $curl_jason['content'][0]['NAMA_LGKP'];
- $jk = $curl_jason['content'][0]['JENIS_KLMIN'];
- $tempatlahir = $curl_jason['content'][0]['TMPT_LHR'];
- $tgllahir = $curl_jason['content'][0]['TGL_LHR'];
- $no_kk = $curl_jason['content'][0]['NO_KK'];
- $alamat = $curl_jason['content'][0]['ALAMAT'];
- $no_kec = $curl_jason['content'][0]['NO_KEC'];
- $no_kel = $curl_jason['content'][0]['NO_KEL'];
- $rt = $curl_jason['content'][0]['NO_RT'];
- $rw = $curl_jason['content'][0]['NO_RW'];
- $pekerjaan = $curl_jason['content'][0]['JENIS_PKRJN'];
- } else {
- $this->curl->http_header('Content-Type: application/json');
- $this->curl->create('http://180.246.204.97:8000/dukcapil/get_json/DISPERKIM/NIK');
- $this->curl->post(json_encode(["user_id"=>"DISPERKIM","password"=>"rumah","nik"=>$nik]));
- $response = $this->curl->execute();
- $curl_jason = json_decode($response, true, 512, JSON_BIGINT_AS_STRING);
- if(count($curl_jason) > 0) {
- $kd_wilayah = substr($curl_jason['content'][0]['NIK'], 0, 6);
- $nik = $curl_jason['content'][0]['NIK'];
- $nama = $curl_jason['content'][0]['NAMA_LGKP'];
- $jk = $curl_jason['content'][0]['JENIS_KLMIN'];
- $tempatlahir = $curl_jason['content'][0]['TMPT_LHR'];
- $tgllahir = $curl_jason['content'][0]['TGL_LHR'];
- $no_kk = $curl_jason['content'][0]['NO_KK'];
- $alamat = $curl_jason['content'][0]['ALAMAT'];
- $no_kec = $curl_jason['content'][0]['NO_KEC'];
- $no_kel = $curl_jason['content'][0]['NO_KEL'];
- $rt = $curl_jason['content'][0]['NO_RT'];
- $rw = $curl_jason['content'][0]['NO_RW'];
- $pekerjaan = $curl_jason['content'][0]['JENIS_PKRJN'];
- } else {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => "NIK Tidak Di Temukan."
- ];
- $this->response($response, 200);
- }
- }
- // Cek Data PBDT atau NON PBDT
- $this->db->select('*');
- $this->db->from('rtlh_data_pbdt');
- $this->db->where('pbdt_nik', $nik);
- $dtnik = $this->db->get()->row();
- if(count($dtnik) > 0) {
- $status_pbdt = 'PBDT';
- } else {
- $status_pbdt = 'NON PBDT';
- }
- // No. Urut RTLH
- $this->db->select('RIGHT(r.rtlh_no_urut, 4) as kode', FALSE);
- $this->db->from('rtlh_rtlh r');
- $this->db->join('rtlh_penduduk_dukcapil p', 'r.penduduk_nik = p.penduduk_nik');
- $this->db->where('p.no_kec', $no_kec); // per Kecamatan
- $this->db->where('p.no_kel', $no_kel); // per Kelurahan
- $this->db->where('p.penduduk_rt', $rt); // per RT
- $this->db->where('p.penduduk_rw', $rw); // per RW
- $this->db->order_by('r.rtlh_id', 'desc');
- $this->db->limit(1);
- $query = $this->db->get();
- if ($query->num_rows() <> 0) {
- $data = $query->row();
- $kode = intval($data->kode) + 1;
- } else {
- $kode = 1;
- }
- $nourut = str_pad($kode, 4, "0", STR_PAD_LEFT);
- $kel = substr($no_kel, 2, 2);
- $no_RTLH = '3320'.$kec.$kel.$rt.$rw.$nourut;
- // Insert Variabel
- // Variabel Prioritas Darurat
- $lstPondasi = $data->data->data_kondisi_fisik_rumah->pondasi_bangunan; // Pondasi Bangunan
- $lstKondisiBalok = $data->data->data_kondisi_fisik_rumah->kondisi_balok_kolom; // Kondisi Balok dan Kolom
- $lstKondisiKonstruksiAtap = $data->data->data_kondisi_fisik_rumah->kondisi_konstruksi_atap; // Kondisi Konstruksi Atap
- // Variabel Status Prioritas
- $lstSanitasi = $data->data->data_kondisi_fisik_rumah->sanitasi; // Kmr. Mandi & Jamban (ADA/TIDAK ADA)
- $lstKondisiAtap = $data->data->aspek_komponen->kondisi_atap; // Kondisi Atap (BOCOR SEDANG, BOCOR BERAT (2,3))
- $lstKondisiDinding = $data->data->aspek_komponen->kondisi_dinding; // Kondisi Dinding (RUSAK SEDANG, RUSAK BERAT (2,3))
- $lstMaterialLantai = $data->data->aspek_komponen->material_lantai; // Material Lantai (TANAH (6))
- // jika TIDAK ADA, nilai = 1
- if ($lstSanitasi == 2) {
- $nilaiSanitasi = 1;
- } else {
- $nilaiSanitasi = 0;
- }
- // jika BOCOR, nilai = 1
- if ($lstKondisiAtap == 2 || $lstKondisiAtap == 3) {
- $nilaiKondisiAtap = 1;
- } else {
- $nilaiKondisiAtap = 0;
- }
- // jika RUSAK, nilai = 1
- if ($lstKondisiDinding == 2 || $lstKondisiDinding == 3) {
- $nilaiKondisiDinding = 1;
- } else {
- $nilaiKondisiDinding = 1;
- }
- // jika TANAH, nilai = 1
- if ($lstMaterialLantai == 6) {
- $nilaiLantai = 1;
- } else {
- $nilaiLantai = 1;
- }
- $BatasDarurat = ($lstPondasi+$lstKondisiBalok+$lstKondisiKonstruksiAtap);
- $JumlahPrioritas = ($nilaiSanitasi+$nilaiKondisiAtap+$nilaiKondisiDinding+$nilaiLantai);
- if ($BatasDarurat == 6) { // Jika TIDAK LAYAK Semua = 6
- $StatusPrioritas = 'DARURAT';
- } else {
- switch ($JumlahPrioritas) {
- case ($JumlahPrioritas == 4): // Jika 4 Komponen
- $StatusPrioritas = 'PRIORITAS 1';
- break;
- case ($JumlahPrioritas == 3): // Jika 3 Komponen
- $StatusPrioritas = 'PRIORITAS 2';
- break;
- case ($JumlahPrioritas == 2): // Jika 2 Komponen
- $StatusPrioritas = 'PRIORITAS 3';
- break;
- case ($JumlahPrioritas == 1): // Jika 1 Komponen
- $StatusPrioritas = 'PRIORITAS 4';
- break;
- case ($JumlahPrioritas == 0): // Jika 0 Komponen
- $StatusPrioritas = 'PRIORITAS 5';
- break;
- default:
- $StatusPrioritas = 'TIDAK MASUK PRIORITAS';
- }
- }
- // Input Data Penduduk, Cek jika Ada Data atau Belum
- $checkNIK = "SELECT penduduk_nik FROM rtlh_penduduk_dukcapil WHERE penduduk_nik='$nik'";
- $hasil = $this->db->query($checkNIK)->row();
- if (count($hasil) == 0) {
- $data = array(
- 'penduduk_nik' => $nik,
- 'penduduk_no_kk' => $no_kk,
- 'penduduk_nama' => $nama,
- 'penduduk_tmpt_lhr' => $tempatlahir,
- 'penduduk_tgl_lahir'=> $tgllahir,
- 'penduduk_jk' => $jk,
- 'no_kec' => $no_kec,
- 'no_kel' => $no_kel,
- 'penduduk_alamat' => $alamat,
- 'penduduk_rt' => $rt,
- 'penduduk_rw' => $rw,
- 'penduduk_kerja' => $pekerjaan,
- 'penduduk_update' => date('Y-m-d H:i:s')
- );
- $this->db->insert('rtlh_penduduk_dukcapil', $data);
- } else {
- $data = array(
- 'penduduk_no_kk' => $no_kk,
- 'penduduk_nama' => $nama,
- 'penduduk_tmpt_lhr' => $tempatlahir,
- 'penduduk_tgl_lahir'=> $tgllahir,
- 'penduduk_jk' => $jk,
- 'no_kec' => $no_kec,
- 'no_kel' => $no_kel,
- 'penduduk_alamat' => $alamat,
- 'penduduk_rt' => $rt,
- 'penduduk_rw' => $rw,
- 'penduduk_kerja' => $pekerjaan,
- 'penduduk_update' => date('Y-m-d H:i:s')
- );
- $this->db->where('penduduk_nik', $nik);
- $this->db->update('rtlh_penduduk_dukcapil', $data);
- }
- // Input ke RTLH
- $data = array(
- 'rtlh_kode_wilayah' => $kd_wilayah,
- 'rtlh_no_urut' => trim($no_RTLH),
- 'penduduk_nik' => $nik,
- 'rtlh_pbdt' => $status_pbdt,
- 'no_kec' => $no_kec,
- 'no_kel' => $no_kel,
- 'penghasilan_id' => $data->data->data_pendukung->penghasilan_perbulan,
- 'pengeluaran_id' => $data->data->data_pendukung->pengeluaran_perbulan,
- 'status_tanah_id' => $data->data->data_pendukung->status_kepemilikan_tanah,
- 'bukti_tanah_id' => $data->data->data_pendukung->bukti_kepemilikan_tanah,
- 'pemilik_rumah_id' => $data->data->data_pendukung->status_kepemilikan_rumah,
- 'rtlh_rumah_lain' => $data->data->data_pendukung->aset_rumah_lain,
- 'rtlh_tanah_lain' => $data->data->data_pendukung->aset_tanah_lain,
- 'rtlh_imb' => $data->data->data_pendukung->imb,
- 'bantuan_id' => $data->data->data_pendukung->bantuan_perumahan,
- 'rtlh_pondasi' => $data->data->data_kondisi_fisik_rumah->pondasi_bangunan,
- 'rtlh_kondisi_balok' => $data->data->data_kondisi_fisik_rumah->kondisi_balok_kolom,
- 'rtlh_kondisi_atap' => $data->data->data_kondisi_fisik_rumah->kondisi_konstruksi_atap,
- 'rtlh_jendela' => $data->data->data_kondisi_fisik_rumah->jendela_lubang_cahaya,
- 'ventilasi_id' => $data->data->data_kondisi_fisik_rumah->ventilasi,
- 'rtlh_sanitasi' => $data->data->data_kondisi_fisik_rumah->sanitasi,
- 'rtlh_kondisi_sanitasi' => $data->data->data_kondisi_fisik_rumah->kondisi_sanitasi,
- 'sanitasi_id' => $data->data->data_kondisi_fisik_rumah->jenis_sanitasi,
- 'rtlh_septitank' => $data->data->data_kondisi_fisik_rumah->septitank,
- 'rtlh_kondisi_septitank'=> $data->data->data_kondisi_fisik_rumah->kondisi_septitank,
- 'air_minum_id' => $data->data->data_kondisi_fisik_rumah->sumber_air_minum,
- 'listrik_id' => $data->data->data_kondisi_fisik_rumah->sumber_listrik,
- 'rtlh_luas' => $data->data->aspek_persyaratan->luas_rumah,
- 'rtlh_jml_orang' => $data->data->aspek_persyaratan->jumlah_penghuni,
- 'rtlh_no_kk_lain' => $data->data->aspek_persyaratan->no_kk_lain,
- 'rtlh_jml_kk' => $data->data->aspek_persyaratan->jml_kk,
- 'tinggi_id' => $data->data->aspek_persyaratan->tinggi_bangunan,
- 'rtlh_ruang_keluarga' => $data->data->aspek_persyaratan->rg_keluarga,
- 'material_atap_id' => $data->data->aspek_komponen->material_atap,
- 'kondisi_atap_id' => $data->data->aspek_komponen->kondisi_atap,
- 'material_dinding_id' => $data->data->aspek_komponen->material_dinding_terluas,
- 'kondisi_dinding_id' => $data->data->aspek_komponen->kondisi_dinding,
- 'material_lantai_id' => $data->data->aspek_komponen->material_lantai,
- 'luas_lantai_id' => $data->data->aspek_komponen->luas_lantai,
- 'rtlh_lat' => $data->data->lokasi_rumah->latitude,
- 'rtlh_long' => $data->data->lokasi_rumah->longitude,
- 'rtlh_bts_timur' => $data->data->lokasi_rumah->batas_timur,
- 'rtlh_bts_barat' => $data->data->lokasi_rumah->batas_barat,
- 'rtlh_bts_utara' => $data->data->lokasi_rumah->batas_utara,
- 'rtlh_bts_selatan' => $data->data->lokasi_rumah->batas_selatan,
- 'rtlh_status' => 'Baru',
- 'rtlh_prioritas' => $StatusPrioritas,
- 'rtlh_foto' => $data->data->foto_pemilik->foto_pemilik->source,
- 'user_username' => '3319042107870002',
- 'rtlh_post' => date('Y-m-d H:i:s'),
- 'rtlh_update' => date('Y-m-d H:i:s')
- );
- $this->db->insert('rtlh_rtlh', $data);
- } else {
- echo 'File Tidak Ada.';
- }
- }
- }
- /* Location: ./application/controllers/api/Dataapi.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement