Advertisement
jamboljack

API List Fasilitator

Nov 28th, 2017
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 21.87 KB | None | 0 0
  1. // Data RTLH per Fasilitator
  2.     function listbyfasilitator_get() {
  3.         $username   = trim($this->get('username'));
  4.         $Data_rtlh  = array();
  5.        
  6.         if ($username == '') { // Jika Username Kosong
  7.             $Data_rtlh[] = array(  
  8.                                 'resp_error'    => TRUE,
  9.                                 'resp_msg'      => 'ID Fasilitator Masih Kosong.'
  10.                             );
  11.  
  12.             $this->response($Data_rtlh, 200);
  13.         } else { // Jika NPWRD Ada
  14.             $this->db->select('r.*, p.penduduk_no_kk, p.penduduk_nama, p.penduduk_jk, p.penduduk_alamat,
  15.                p.penduduk_rt, p.penduduk_rw, c.nama_kec, k.nama_kel, p.penduduk_tmpt_lhr, p.penduduk_tgl_lahir');
  16.             $this->db->from('rtlh_rtlh r');
  17.             $this->db->join('rtlh_penduduk_dukcapil p', 'r.penduduk_nik = p.penduduk_nik');
  18.             $this->db->join('rtlh_kec c', 'p.no_kec = c.no_kec');
  19.             $this->db->join('rtlh_kel k', 'p.no_kel = k.no_kel');
  20.             $this->db->where('k.no_kec = c.no_kec');
  21.             $this->db->where('r.rtlh_aktif', 1); // Aktif
  22.             $this->db->where('r.rtlh_step >=', 3); // Verifikasi ke Atas
  23.             $this->db->where('r.user_pengampu', $username);
  24.  
  25.             $listRTLH = $this->db->get()->result();
  26.  
  27.             if (count($listRTLH) > 0) {
  28.                 $response  = [
  29.                     'resp_error'    => FALSE,
  30.                     'resp_msg'      => "Success",
  31.                     'items'         => []
  32.                 ];
  33.  
  34.                 foreach ($listRTLH as $r) {
  35.                     $rtlh_id = $r->rtlh_id;
  36.  
  37.                     // 0 Persen
  38.                     $this->db->select('*');
  39.                     $this->db->from('rtlh_foto_rumah');
  40.                     $this->db->where('rtlh_id', $rtlh_id);
  41.                     $this->db->where('foto_tipe', '0');
  42.                     $this->db->order_by('foto_id', 'asc');
  43.                     $listFoto = $this->db->get()->result();
  44.                     if (count($listFoto) == 0) {
  45.                         $foto_rmh_0     = '';
  46.                         $foto_atap_0    = '';
  47.                         $foto_dinding_0 = '';
  48.                         $foto_lantai_0  = '';
  49.                         $is_valid_0     = false;
  50.                     } else {
  51.                         foreach($listFoto as $f) {
  52.                             $foto_nama = trim($f->foto_nama);
  53.                             switch ($foto_nama) {
  54.                                 case 'Rumah': // Rumah
  55.                                     $foto_rmh_0     = base_url('img/foto_rumah/'.$f->foto_file);
  56.                                     break;
  57.                                 case 'Atap': // Atap
  58.                                     $foto_atap_0    = base_url('img/foto_rumah/'.$f->foto_file);
  59.                                     break;
  60.                                 case 'Dinding': // Dinding
  61.                                     $foto_dinding_0 = base_url('img/foto_rumah/'.$f->foto_file);
  62.                                     break;
  63.                                 case 'Lantai': // Lantai
  64.                                     $foto_lantai_0 = base_url('img/foto_rumah/'.$f->foto_file);
  65.                                     break;
  66.                             }
  67.                         }
  68.                         $is_valid_0     = true;
  69.                     }
  70.  
  71.                     // 50 Persen
  72.                     $this->db->select('*');
  73.                     $this->db->from('rtlh_foto_rumah');
  74.                     $this->db->where('rtlh_id', $rtlh_id);
  75.                     $this->db->where('foto_tipe', '50');
  76.                     $this->db->order_by('foto_id', 'asc');
  77.                     $listFoto1 = $this->db->get()->result();
  78.                     if (count($listFoto1) == 0) {
  79.                         $foto_rmh_50     = '';
  80.                         $foto_atap_50    = '';
  81.                         $foto_dinding_50 = '';
  82.                         $foto_lantai_50  = '';
  83.                         $is_valid_50    = false;
  84.                     } else {
  85.                         foreach($listFoto1 as $f) {
  86.                             $foto_nama = trim($f->foto_nama);
  87.                             switch ($foto_nama) {
  88.                                 case 'Rumah': // Rumah
  89.                                     $foto_rmh_50     = base_url('img/foto_rumah/'.$f->foto_file);
  90.                                     break;
  91.                                 case 'Atap': // Atap
  92.                                     $foto_atap_50    = base_url('img/foto_rumah/'.$f->foto_file);
  93.                                     break;
  94.                                 case 'Dinding': // Dinding
  95.                                     $foto_dinding_50 = base_url('img/foto_rumah/'.$f->foto_file);
  96.                                     break;
  97.                                 case 'Lantai': // Lantai
  98.                                     $foto_lantai_50 = base_url('img/foto_rumah/'.$f->foto_file);
  99.                                     break;
  100.                             }
  101.                         }
  102.                         $is_valid_50    = true;
  103.                     }
  104.  
  105.                      // 100 Persen
  106.                     $this->db->select('*');
  107.                     $this->db->from('rtlh_foto_rumah');
  108.                     $this->db->where('rtlh_id', $rtlh_id);
  109.                     $this->db->where('foto_tipe', '100');
  110.                     $this->db->order_by('foto_id', 'asc');
  111.                     $listFoto2 = $this->db->get()->result();
  112.                     if (count($listFoto2) == 0) {
  113.                         $foto_rmh_100     = '';
  114.                         $foto_atap_100    = '';
  115.                         $foto_dinding_100 = '';
  116.                         $foto_lantai_100  = '';
  117.                         $is_valid_100     = false;
  118.                     } else {
  119.                         foreach($listFoto2 as $f) {
  120.                             $foto_nama = trim($f->foto_nama);
  121.                             switch ($foto_nama) {
  122.                                 case 'Rumah': // Rumah
  123.                                     $foto_rmh_100     = base_url('img/foto_rumah/'.$f->foto_file);
  124.                                     break;
  125.                                 case 'Atap': // Atap
  126.                                     $foto_atap_100    = base_url('img/foto_rumah/'.$f->foto_file);
  127.                                     break;
  128.                                 case 'Dinding': // Dinding
  129.                                     $foto_dinding_100 = base_url('img/foto_rumah/'.$f->foto_file);
  130.                                     break;
  131.                                 case 'Lantai': // Lantai
  132.                                     $foto_lantai_100 = base_url('img/foto_rumah/'.$f->foto_file);
  133.                                     break;
  134.                             }
  135.                         }
  136.                         $is_valid_100   = true;
  137.                     }
  138.  
  139.                     $response['items'][] = [
  140.                             'rtlh_id'   => $r->rtlh_id,
  141.                             'kd_wilayah'=> trim($r->rtlh_kode_wilayah),
  142.                             'nik'       => trim($r->penduduk_nik),
  143.                             'no_rtlh'   => trim($r->rtlh_no_urut),
  144.                             'nama'      => trim($r->penduduk_nama),
  145.                             'alamat'    => $r->penduduk_alamat.' RT. '.$r->penduduk_rt.' RW. '.$r->penduduk_rw.' DESA '.$r->nama_kel.' KEC. '.$r->nama_kec,
  146.                             'jk'        => trim($r->penduduk_jk),
  147.                             'tmpt_lahir'=> trim($r->penduduk_tmpt_lhr),
  148.                             'tgl_lahir' => $r->penduduk_tgl_lahir,
  149.                             'pbdt'      => trim($r->rtlh_pbdt),
  150.                             'status'    => trim($r->rtlh_prioritas),
  151.                             'data'      => [
  152.                                     'data_pendukung' => [
  153.                                         'is_form_valid'             => true,
  154.                                         'penghasilan_perbulan'      => $r->penghasilan_id,
  155.                                         'pengeluaran_perbulan'      => $r->pengeluaran_id,
  156.                                         'status_kepemilikan_tanah'  => $r->status_tanah_id,
  157.                                         'bukti_kepemilikan_tanah'   => $r->bukti_tanah_id,
  158.                                         'status_kepemilikan_rumah'  => $r->pemilik_rumah_id,
  159.                                         'aset_rumah_lain'           => $r->rtlh_rumah_lain,
  160.                                         'aset_tanah_lain'           => $r->rtlh_tanah_lain,
  161.                                         'imb'                       => $r->rtlh_imb,
  162.                                         'bantuan_perumahan'         => $r->bantuan_id
  163.                                     ],
  164.                                     'data_kondisi_fisik_rumah' => [
  165.                                         'is_form_valid'             => true,
  166.                                         'pondasi_bangunan'          => $r->bantuan_id,
  167.                                         'kondisi_balok_kolom'       => $r->rtlh_kondisi_balok,
  168.                                         'kondisi_konstruksi_atap'   => $r->rtlh_kondisi_atap,
  169.                                         'jendela_lubang_cahaya'     => $r->rtlh_jendela,
  170.                                         'ventilasi'                 => $r->ventilasi_id,
  171.                                         'sanitasi'                  => $r->rtlh_sanitasi,
  172.                                         'kondisi_sanitasi'          => $r->rtlh_kondisi_sanitasi,
  173.                                         'jenis_sanitasi'            => $r->sanitasi_id,
  174.                                         'septitank'                 => $r->rtlh_septitank,
  175.                                         'kondisi_septitank'         => $r->rtlh_kondisi_septitank,
  176.                                         'sumber_air_minum'          => $r->air_minum_id,
  177.                                         'sumber_listrik'            => $r->listrik_id
  178.                                     ],
  179.                                     'aspek_persyaratan' => [
  180.                                         'is_form_valid'             => true,
  181.                                         'luas_rumah'                => $r->rtlh_luas,
  182.                                         'jumlah_penghuni'           => $r->rtlh_jml_orang,
  183.                                         'no_kk_lain'                => $r->rtlh_no_kk_lain,
  184.                                         'jml_kk'                    => $r->rtlh_jml_kk,
  185.                                         'tinggi_bangunan'           => $r->tinggi_id,
  186.                                         'rg_keluarga'               => $r->rtlh_ruang_keluarga
  187.                                     ],
  188.                                     'aspek_komponen' => [
  189.                                         'is_form_valid'             => true,
  190.                                         'material_atap'             => $r->material_atap_id,
  191.                                         'kondisi_atap'              => $r->kondisi_atap_id,
  192.                                         'material_dinding_terluas'  => $r->material_dinding_id,
  193.                                         'kondisi_dinding'           => $r->kondisi_dinding_id,
  194.                                         'material_lantai'           => $r->material_lantai_id,
  195.                                         'luas_lantai'               => $r->luas_lantai_id
  196.                                     ],
  197.                                     'foto_pemilik' => [
  198.                                         "foto_pemilik" => [
  199.                                             'type'                  => 'online',
  200.                                             'source'                => base_url('img/foto/'.$r->rtlh_foto),
  201.                                             'latitude'              => '',
  202.                                             'longitude'             => '',
  203.                                             'height'                => 800,
  204.                                             'width'                 => 600
  205.                                         ],
  206.                                         'is_form_valid'             => true
  207.                                     ],
  208.                                     "foto_ktp_kk" => [
  209.                                         "ktp"       => [
  210.                                             'type'                  => 'online',
  211.                                             'source'                => base_url('img/foto_ktp_kk/'.$r->rtlh_foto_ktp),
  212.                                             'latitude'              => '',
  213.                                             'longitude'             => '',
  214.                                             'height'                => 0,
  215.                                             'width'                 => 300
  216.                                         ],
  217.                                         "ktp"       => [
  218.                                             'type'                  => 'online',
  219.                                             'source'                => base_url('img/foto_ktp_kk/'.$r->rtlh_foto_kk),
  220.                                             'latitude'              => '',
  221.                                             'longitude'             => '',
  222.                                             'height'                => 0,
  223.                                             'width'                 => 300
  224.                                         ],
  225.                                         'is_form_valid'             => true
  226.                                     ],
  227.                                     "lokasi_rumah" => [
  228.                                         'is_form_valid'             => true,
  229.                                         'latitude'                  => $r->rtlh_lat,
  230.                                         'longitude'                 => $r->rtlh_long,
  231.                                         'batas_utara'               => $r->rtlh_bts_utara,
  232.                                         'batas_timur'               => $r->rtlh_bts_timur,
  233.                                         'batas_selatan'             => $r->rtlh_bts_selatan,
  234.                                         'batas_barat'               => $r->rtlh_bts_barat
  235.                                     ],
  236.                                     "foto_bangunan_0" => [
  237.                                         "bangunan"  => [
  238.                                             'type'                  => 'online',
  239.                                             'source'                => $foto_rmh_0,
  240.                                             'latitude'              => '',
  241.                                             'longitude'             => '',
  242.                                             'height'                => 600,
  243.                                             'width'                 => 800
  244.                                         ],
  245.                                         "atap"  => [
  246.                                             'type'                  => 'online',
  247.                                             'source'                => $foto_atap_0,
  248.                                             'latitude'              => '',
  249.                                             'longitude'             => '',
  250.                                             'height'                => 600,
  251.                                             'width'                 => 800
  252.                                         ],
  253.                                         "dinding"  => [
  254.                                             'type'                  => 'online',
  255.                                             'source'                => $foto_dinding_0,
  256.                                             'latitude'              => '',
  257.                                             'longitude'             => '',
  258.                                             'height'                => 600,
  259.                                             'width'                 => 800
  260.                                         ],
  261.                                         "lantai"  => [
  262.                                             'type'                  => 'online',
  263.                                             'source'                => $foto_lantai_0,
  264.                                             'latitude'              => '',
  265.                                             'longitude'             => '',
  266.                                             'height'                => 600,
  267.                                             'width'                 => 800
  268.                                         ],
  269.                                         'is_form_valid'             => $is_valid_0
  270.                                     ],
  271.                                     "foto_bangunan_50" => [
  272.                                         "bangunan"  => [
  273.                                             'type'                  => 'online',
  274.                                             'source'                => $foto_rmh_50,
  275.                                             'latitude'              => '',
  276.                                             'longitude'             => '',
  277.                                             'height'                => 600,
  278.                                             'width'                 => 800
  279.                                         ],
  280.                                         "atap"  => [
  281.                                             'type'                  => 'online',
  282.                                             'source'                => $foto_atap_50,
  283.                                             'latitude'              => '',
  284.                                             'longitude'             => '',
  285.                                             'height'                => 600,
  286.                                             'width'                 => 800
  287.                                         ],
  288.                                         "dinding"  => [
  289.                                             'type'                  => 'online',
  290.                                             'source'                => $foto_dinding_50,
  291.                                             'latitude'              => '',
  292.                                             'longitude'             => '',
  293.                                             'height'                => 600,
  294.                                             'width'                 => 800
  295.                                         ],
  296.                                         "lantai"  => [
  297.                                             'type'                  => 'online',
  298.                                             'source'                => $foto_lantai_50,
  299.                                             'latitude'              => '',
  300.                                             'longitude'             => '',
  301.                                             'height'                => 600,
  302.                                             'width'                 => 800
  303.                                         ],
  304.                                         'is_form_valid'             => $is_valid_50
  305.                                     ],
  306.                                     "foto_bangunan_100" => [
  307.                                         "bangunan"  => [
  308.                                             'type'                  => 'online',
  309.                                             'source'                => $foto_rmh_100,
  310.                                             'latitude'              => '',
  311.                                             'longitude'             => '',
  312.                                             'height'                => 600,
  313.                                             'width'                 => 800
  314.                                         ],
  315.                                         "atap"  => [
  316.                                             'type'                  => 'online',
  317.                                             'source'                => $foto_atap_100,
  318.                                             'latitude'              => '',
  319.                                             'longitude'             => '',
  320.                                             'height'                => 600,
  321.                                             'width'                 => 800
  322.                                         ],
  323.                                         "dinding"  => [
  324.                                             'type'                  => 'online',
  325.                                             'source'                => $foto_dinding_100,
  326.                                             'latitude'              => '',
  327.                                             'longitude'             => '',
  328.                                             'height'                => 600,
  329.                                             'width'                 => 800
  330.                                         ],
  331.                                         "lantai"  => [
  332.                                             'type'                  => 'online',
  333.                                             'source'                => $foto_lantai_100,
  334.                                             'latitude'              => '',
  335.                                             'longitude'             => '',
  336.                                             'height'                => 600,
  337.                                             'width'                 => 800
  338.                                         ],
  339.                                         'is_form_valid'             => $is_valid_100
  340.                                     ]
  341.                             ]
  342.                     ];
  343.                 }
  344.             } else {
  345.                 $response  = [
  346.                     'resp_error'    => TRUE,
  347.                     'resp_msg'      => "Data Tidak Ada."
  348.                 ];
  349.             }
  350.  
  351.             $this->response($response, 200);
  352.         }
  353.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement