respond(null, 401); } $db = \Config\Database::connect(); $data = $db->table('KPDL_V_BATAS_DESA')->where('ADM1_PCODE IS NOT NULL') ->select('ADM1_PCODE as value, ADM1_EN as label') ->distinct()->orderBy('ADM1_EN')->get()->getResult(); $Ald = new AldLibrary; $username = session('nip'); foreach ($data as $key => $val) { $val->value = $Ald->encryptMe($val->value, $username); } return $this->respond($data, 200); } public function kota() { $Ald = new AldLibrary; $username = session('nip'); if (!$username) { return $this->respond(null, 401); } if (!$this->validate([ 'prop' => 'required|max_length[10]', ])) { return $this->respond($this->validator->getErrors(), 422); } $prop = $Ald->decryptMe($this->request->getGet('prop'), $username); if (!ctype_alnum($prop)) { return $this->respond(null, 400); } $db = \Config\Database::connect(); $data = $db->table('KPDL_V_BATAS_DESA') ->select('ADM2_PCODE as value, ADM2_EN as label') ->distinct() ->where('ADM2_PCODE IS NOT NULL') ->where('ADM1_PCODE', $prop) ->orderBy('ADM2_EN')->get()->getResult(); foreach ($data as $key => $val) { $val->value = $Ald->encryptMe($val->value, $username); } return $this->respond($data, 200); } public function kecamatan() { $Ald = new AldLibrary; $username = session('nip'); if (!$username) { return $this->respond(null, 401); } if (!$this->validate([ 'kota' => 'required|max_length[10]', ])) { return $this->respond($this->validator->getErrors(), 422); } $kota = $Ald->decryptMe($this->request->getGet('kota'), $username); $db = \Config\Database::connect(); $data = $db->table('KPDL_V_BATAS_DESA') ->select('ADM3_PCODE as value, ADM3_EN as label') ->distinct() ->where('ADM3_PCODE IS NOT NULL') ->where('ADM2_PCODE', $kota) ->orderBy('ADM3_EN')->get()->getResult(); foreach ($data as $key => $val) { $val->value = $Ald->encryptMe($val->value, $username); } return $this->respond($data, 200); } public function kelurahan() { $Ald = new AldLibrary; $username = session('nip'); if (!$username) { return $this->respond(null, 401); } if (!$this->validate([ 'kec' => 'required', ])) { return $this->respond($this->validator->getErrors(), 422); } $kec = []; foreach ($this->request->getPost('kec') as $key => $value) { $kec[] = $Ald->decryptMe($value, $username); } $db = \Config\Database::connect(); $data = $db->table('KPDL_V_BATAS_DESA') ->select('ADM4_PCODE as value, ADM4_EN as label') ->distinct() ->where('ADM4_PCODE IS NOT NULL') ->whereIn('ADM3_PCODE', $kec) ->orderBy('ADM4_EN')->get()->getResult(); foreach ($data as $key => $val) { $val->value = $Ald->encryptKpdl($val->value, $username); } return $this->respond($data, 200); } public function zpkanwil() { $Ald = new AldLibrary; $username = session('nip'); $db = \Config\Database::connect(); $data = $db->table('KPDL_ZP_NAS_DIFF') ->select('KD_KANWIL as value, NM_KANWIL as label') ->distinct() ->orderBy('NM_KANWIL')->get()->getResult(); foreach ($data as $key => $val) { $val->value = $Ald->encryptMe($val->value, $username); } return json_encode($data); } public function zpkpp() { $Ald = new AldLibrary; $username = session('nip'); $kanwil = $Ald->decryptMe($this->request->getPost('kanwil'), $username); $db = \Config\Database::connect(); $data = $db->table('KPDL_ZP_NAS_DIFF') ->select('KD_KPP as value, NM_KPP as label') ->distinct() ->where('KD_KANWIL', $kanwil) ->orderBy('NM_KPP')->get()->getResult(); foreach ($data as $key => $val) { $val->value = $Ald->encryptMe($val->value, $username); } return json_encode($data); } public function zpseksi() { $Ald = new AldLibrary; $username = session('nip'); $kpp = $Ald->decryptMe($this->request->getPost('kpp'), $username); $db = \Config\Database::connect(); $data = $db->table('KPDL_ZP_NAS_DIFF') ->select('KD_UNIT_OR as value, SEKSI as label') ->distinct() ->where('KD_KPP', $kpp) ->orderBy('SEKSI')->get()->getResult(); foreach ($data as $key => $val) { $val->value = $Ald->encryptKpdl($val->value, $username); } return json_encode($data); } public function zpar() { $Ald = new AldLibrary; $username = session('nip'); $kpp = $Ald->decryptMe($this->request->getPost('kpp'), $username); $seksi = []; foreach ($this->request->getPost('seksi') ?? [] as $key => $value) { $seksi[] = $Ald->decryptKpdl($value, $username); } $db = \Config\Database::connect(); $data = $db->table('KPDL_ZP_NAS_DIFF') ->select('NIP_AR as value, NM_AR as label') ->distinct() ->where('KD_KPP', $kpp) ->whereIn('KD_UNIT_OR', $seksi) ->orderBy('NM_AR'); $data = $data->get()->getResult(); foreach ($data as $key => $val) { $val->value = $Ald->encryptMe($val->value, $username); } return json_encode($data); } public function zpzp() { $Ald = new AldLibrary; $username = session('nip'); $kpp = $Ald->decryptMe($this->request->getPost('kpp'), $username); $seksi = []; foreach ($this->request->getPost('seksi') as $key => $value) { $seksi[] = $Ald->decryptKpdl($value, $username); } $ar = []; foreach ($this->request->getPost('ar') as $key => $value) { $ar[] = $Ald->decryptMe($value, $username); } $db = \Config\Database::connect(); $data = $db->table('KPDL_ZP_NAS_DIFF') ->select("OGC_FID as value, NO_URUT || '-' || ATTRIBUTE1 as label") ->distinct() ->where('KD_KPP', $kpp) ->whereIn('KD_UNIT_OR', $seksi) ->whereIn('NIP_AR', $ar) ->orderBy('LABEL')->get()->getResult(); foreach ($data as $key => $value) { $value->value = $Ald->encryptMe($value->value, $username); $value->label = $value->LABEL; unset($value->LABEL); } return json_encode(($data)); } public function kanwilPratama() { $Ald = new AldLibrary; $username = session('nip'); $db = \Config\Database::connect(); $data = $db->table('DIM_KANTOR') ->select('KD_KANWIL as value, NM_KANTOR as label') ->where('ID_JNS_KANTOR', 23) ->orderBy('NM_KANTOR')->get()->getResult(); foreach ($data as $key => $val) { $val->value = $Ald->encryptMe($val->value, $username); } return json_encode($data); } public function kppPratama() { $Ald = new AldLibrary; $username = session('nip'); $kanwil = $Ald->decryptMe($this->request->getGet('kanwil'), $username); $db = \Config\Database::connect(); $data = $db->table('DIM_KANTOR') ->select('KD_KPP as value, NM_KANTOR as label') ->where('KD_KANWIL', $kanwil) ->where('ID_JNS_KANTOR', 24) ->orderBy('NM_KANTOR')->get()->getResult(); foreach ($data as $key => $val) { $val->value = $Ald->encryptMe($val->value, $username); } return json_encode($data); } public function kanwil() { $Ald = new AldLibrary; $username = session('nip'); $db = \Config\Database::connect(); $data = $db->table('DIM_KANTOR') ->select('KD_KANWIL as value, NM_KANTOR as label') ->whereIn('ID_JNS_KANTOR', [21, 23]) ->orderBy('NM_KANTOR')->get()->getResult(); foreach ($data as $key => $val) { $val->value = $Ald->encryptMe($val->value, $username); } return json_encode($data); } public function kpp() { $Ald = new AldLibrary; $username = session('nip'); $kanwil = $Ald->decryptMe($this->request->getGet('kanwil'), $username); $db = \Config\Database::connect(); $data = $db->table('DIM_KANTOR') ->select('KD_KPP as value, NM_KANTOR as label') ->where('KD_KANWIL', $kanwil) ->whereIn('ID_JNS_KANTOR', [22, 24]) ->orderBy('NM_KANTOR')->get()->getResult(); foreach ($data as $key => $val) { $val->value = $Ald->encryptMe($val->value, $username); } return json_encode($data); } public function seksi() { $Ald = new AldLibrary; $username = session('nip'); $kpp = $Ald->decryptMe($this->request->getGet('kpp'), $username); $db = \Config\Database::connect(); $data = $db->table('PEGAWAI')->distinct() ->select('KD_UNIT_ORGANISASI as value, NAMA_UNIT_ES4 as label') ->where('KPPADM', $kpp) ->where('NAMA_JABATAN', "Account Representative") ->orderBy('NAMA_UNIT_ES4')->get()->getResult(); foreach ($data as $key => $val) { $val->value = $Ald->encryptKpdl($val->value, $username); } return json_encode($data); } public function ar() { $Ald = new AldLibrary; $username = session('nip'); $kpp = $Ald->decryptMe($this->request->getPost('kpp'), $username); $kd_unit_organisasi = []; foreach ($this->request->getPost('seksi') as $key => $value) { $kd_unit_organisasi[] = $Ald->decryptKpdl($value, $username); } // print_r($kpp); // exit; $db = \Config\Database::connect(); $data = $db->table('PEGAWAI')->distinct() ->select('NIP9 as value, NAMA as label') ->where('KPPADM', $kpp) ->whereIn('KD_UNIT_ORGANISASI', $kd_unit_organisasi) ->where('NAMA_JABATAN', "Account Representative") ->orderBy('NAMA')->get()->getResult(); foreach ($data as $key => $val) { $val->value = $Ald->encryptMe($val->value, $username); } return json_encode($data); } public function opsi() { $Ald = new AldLibrary(); $data = [ 'wilayah' => ['key' => $Ald->encryptMe('wilayah', session('nip'))], 'zona' => ['key' => $Ald->encryptMe('zona', session('nip'))], 'perekam' => ['key' => $Ald->encryptMe('perekam', session('nip'))], 'pengampu' => ['key' => $Ald->encryptMe('pengampu', session('nip'))], ]; return $this->respond($data, 200); } protected function change_case($arr) { return array_change_key_case($arr, CASE_LOWER); } }