@ -1,62 +1,135 @@
<?php
<?php
namespace App\Controllers\Kewilayahan;
namespace App\Controllers\Kewilayahan;
use App\Libraries\AldLibrary;
use CodeIgniter\API\ResponseTrait;
use CodeIgniter\Controller;
use CodeIgniter\Controller;
class Ref extends Controller
class Ref extends Controller
{
{
use ResponseTrait;
public function propinsi()
public function propinsi()
{
{
$username = session('nip');
if (!$username) {
return $this->respond(null, 401);
}
$db = \Config\Database::connect();
$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();
$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) {
foreach ($data as $key => $val) {
$val->value = $val->value;
$val->value = $Ald->encryptMe($ val->value, $username) ;
}
}
return json_encode($data );
return $this->respond($data, 200 );
}
}
public function kota()
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();
$db = \Config\Database::connect();
$data = $db->table('KPDL_V_BATAS_DESA')
$data = $db->table('KPDL_V_BATAS_DESA')
->select('ADM2_PCODE as value, ADM2_EN as label')
->select('ADM2_PCODE as value, ADM2_EN as label')
->distinct()
->distinct()
->where('ADM2_PCODE IS NOT NULL')
->where('ADM2_PCODE IS NOT NULL')
->where('ADM1_PCODE', $this->request->getGet('prop'))
->where('ADM1_PCODE', $prop)
->orderBy('ADM2_EN')->get()->getResult();
->orderBy('ADM2_EN')->get()->getResult();
return json_encode($data);
foreach ($data as $key => $val) {
$val->value = $Ald->encryptMe($val->value, $username);
}
return $this->respond($data, 200);
}
}
public function kecamatan()
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();
$db = \Config\Database::connect();
$data = $db->table('KPDL_V_BATAS_DESA')
$data = $db->table('KPDL_V_BATAS_DESA')
->select('ADM3_PCODE as value, ADM3_EN as label')
->select('ADM3_PCODE as value, ADM3_EN as label')
->distinct()
->distinct()
->where('ADM3_PCODE IS NOT NULL')
->where('ADM3_PCODE IS NOT NULL')
->where('ADM2_PCODE', $this->request->getGet('kota'))
->where('ADM2_PCODE', $kota)
->orderBy('ADM3_EN')->get()->getResult();
->orderBy('ADM3_EN')->get()->getResult();
return json_encode($data);
foreach ($data as $key => $val) {
$val->value = $Ald->encryptMe($val->value, $username);
}
return $this->respond($data, 200);
}
}
public function kelurahan()
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();
$db = \Config\Database::connect();
$data = $db->table('KPDL_V_BATAS_DESA')
$data = $db->table('KPDL_V_BATAS_DESA')
->select('ADM4_PCODE as value, ADM4_EN as label')
->select('ADM4_PCODE as value, ADM4_EN as label')
->distinct()
->distinct()
->where('ADM4_PCODE IS NOT NULL')
->where('ADM4_PCODE IS NOT NULL')
->whereIn('ADM3_PCODE', $this->request->getGet('kec'))
->whereIn('ADM3_PCODE', $kec)
->orderBy('ADM4_EN')->get()->getResult();
->orderBy('ADM4_EN')->get()->getResult();
return json_encode($data);
foreach ($data as $key => $val) {
$val->value = $Ald->encryptKpdl($val->value, $username);
}
return $this->respond($data, 200);
}
}
public function zpkanwil()
public function zpkanwil()
{
{
$Ald = new AldLibrary;
$username = session('nip');
$db = \Config\Database::connect();
$db = \Config\Database::connect();
$data = $db->table('KPDL_ZP_NAS_DIFF')
$data = $db->table('KPDL_ZP_NAS_DIFF')
@ -65,7 +138,7 @@ class Ref extends Controller
->orderBy('NM_KANWIL')->get()->getResult();
->orderBy('NM_KANWIL')->get()->getResult();
foreach ($data as $key => $val) {
foreach ($data as $key => $val) {
$val->value = $val->value;
$val->value = $Ald->encryptMe($ val->value, $username) ;
}
}
return json_encode($data);
return json_encode($data);
@ -73,46 +146,89 @@ class Ref extends Controller
public function zpkpp()
public function zpkpp()
{
{
$Ald = new AldLibrary;
$username = session('nip');
$kanwil = $Ald->decryptMe($this->request->getPost('kanwil'), $username);
$db = \Config\Database::connect();
$db = \Config\Database::connect();
$data = $db->table('KPDL_ZP_NAS_DIFF')
$data = $db->table('KPDL_ZP_NAS_DIFF')
->select('KD_KPP as value, NM_KPP as label')
->select('KD_KPP as value, NM_KPP as label')
->distinct()
->distinct()
->where('KD_KANWIL', $this->request->getGet('kanwil'))
->where('KD_KANWIL', $kanwil)
->orderBy('NM_KPP')->get()->getResult();
->orderBy('NM_KPP')->get()->getResult();
foreach ($data as $key => $val) {
$val->value = $Ald->encryptMe($val->value, $username);
}
return json_encode($data);
return json_encode($data);
}
}
public function zpseksi()
public function zpseksi()
{
{
$Ald = new AldLibrary;
$username = session('nip');
$kpp = $Ald->decryptMe($this->request->getPost('kpp'), $username);
$db = \Config\Database::connect();
$db = \Config\Database::connect();
$data = $db->table('KPDL_ZP_NAS_DIFF')
$data = $db->table('KPDL_ZP_NAS_DIFF')
->select('KD_UNIT_OR as value, SEKSI as label')
->select('KD_UNIT_OR as value, SEKSI as label')
->distinct()
->distinct()
->whereIn('KD_KPP', $this->request->getGet('kpp'))
->where('KD_KPP', $kpp)
->orderBy('SEKSI')->get()->getResult();
->orderBy('SEKSI')->get()->getResult();
foreach ($data as $key => $val) {
$val->value = $Ald->encryptKpdl($val->value, $username);
}
return json_encode($data);
return json_encode($data);
}
}
public function zpar()
public function zpar()
{
{
$db = \Config\Database::connect();
$Ald = new AldLibrary;
$kpp = $this->request->getGet('kpp');
$username = session('nip');
$seksi = $this->request->getGet('seksi');
$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')
$data = $db->table('KPDL_ZP_NAS_DIFF')
->select('NIP_AR as value, NM_AR as label')
->select('NIP_AR as value, NM_AR as label')
->distinct()
->distinct()
->whereIn('KD_KPP', $kpp)
->where('KD_KPP', $kpp)
->whereIn('KD_UNIT_OR', $seksi)
->whereIn('KD_UNIT_OR', $seksi)
->orderBy('NM_AR')->get()->getResult();
->orderBy('NM_AR');
$data = $data->get()->getResult();
foreach ($data as $key => $val) {
$val->value = $Ald->encryptMe($val->value, $username);
}
return json_encode($data);
return json_encode($data);
}
}
public function zpzp()
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();
$db = \Config\Database::connect();
$kpp = $this->request->getPost('kpp');
$seksi = $this->request->getPost('seksi');
$ar = $this->request->getPost('ar');
$data = $db->table('KPDL_ZP_NAS_DIFF')
$data = $db->table('KPDL_ZP_NAS_DIFF')
->select("OGC_FID as value, NO_URUT || '-' || ATTRIBUTE1 as label")
->select("OGC_FID as value, NO_URUT || '-' || ATTRIBUTE1 as label")
->distinct()
->distinct()
@ -120,7 +236,9 @@ class Ref extends Controller
->whereIn('KD_UNIT_OR', $seksi)
->whereIn('KD_UNIT_OR', $seksi)
->whereIn('NIP_AR', $ar)
->whereIn('NIP_AR', $ar)
->orderBy('LABEL')->get()->getResult();
->orderBy('LABEL')->get()->getResult();
foreach ($data as $key => $value) {
foreach ($data as $key => $value) {
$value->value = $Ald->encryptMe($value->value, $username);
$value->label = $value->LABEL;
$value->label = $value->LABEL;
unset($value->LABEL);
unset($value->LABEL);
@ -130,7 +248,8 @@ class Ref extends Controller
public function kanwilPratama()
public function kanwilPratama()
{
{
$Ald = new AldLibrary;
$username = session('nip');
$db = \Config\Database::connect();
$db = \Config\Database::connect();
$data = $db->table('DIM_KANTOR')
$data = $db->table('DIM_KANTOR')
->select('KD_KANWIL as value, NM_KANTOR as label')
->select('KD_KANWIL as value, NM_KANTOR as label')
@ -138,7 +257,7 @@ class Ref extends Controller
->orderBy('NM_KANTOR')->get()->getResult();
->orderBy('NM_KANTOR')->get()->getResult();
foreach ($data as $key => $val) {
foreach ($data as $key => $val) {
$val->value = $val->value;
$val->value = $Ald->encryptMe($ val->value, $username) ;
}
}
return json_encode($data);
return json_encode($data);
@ -146,7 +265,11 @@ class Ref extends Controller
public function kppPratama()
public function kppPratama()
{
{
$kanwil = $this->request->getGet('kanwil');
$Ald = new AldLibrary;
$username = session('nip');
$kanwil = $Ald->decryptMe($this->request->getGet('kanwil'), $username);
$db = \Config\Database::connect();
$db = \Config\Database::connect();
$data = $db->table('DIM_KANTOR')
$data = $db->table('DIM_KANTOR')
->select('KD_KPP as value, NM_KANTOR as label')
->select('KD_KPP as value, NM_KANTOR as label')
@ -155,7 +278,7 @@ class Ref extends Controller
->orderBy('NM_KANTOR')->get()->getResult();
->orderBy('NM_KANTOR')->get()->getResult();
foreach ($data as $key => $val) {
foreach ($data as $key => $val) {
$val->value = $val->value;
$val->value = $Ald->encryptMe($ val->value, $username) ;
}
}
return json_encode($data);
return json_encode($data);
@ -163,6 +286,8 @@ class Ref extends Controller
public function kanwil()
public function kanwil()
{
{
$Ald = new AldLibrary;
$username = session('nip');
$db = \Config\Database::connect();
$db = \Config\Database::connect();
$data = $db->table('DIM_KANTOR')
$data = $db->table('DIM_KANTOR')
@ -171,7 +296,7 @@ class Ref extends Controller
->orderBy('NM_KANTOR')->get()->getResult();
->orderBy('NM_KANTOR')->get()->getResult();
foreach ($data as $key => $val) {
foreach ($data as $key => $val) {
$val->value = $val->value;
$val->value = $Ald->encryptMe($ val->value, $username) ;
}
}
return json_encode($data);
return json_encode($data);
@ -179,7 +304,11 @@ class Ref extends Controller
public function kpp()
public function kpp()
{
{
$kanwil = $this->request->getGet('kanwil');
$Ald = new AldLibrary;
$username = session('nip');
$kanwil = $Ald->decryptMe($this->request->getGet('kanwil'), $username);
$db = \Config\Database::connect();
$db = \Config\Database::connect();
$data = $db->table('DIM_KANTOR')
$data = $db->table('DIM_KANTOR')
->select('KD_KPP as value, NM_KANTOR as label')
->select('KD_KPP as value, NM_KANTOR as label')
@ -188,7 +317,7 @@ class Ref extends Controller
->orderBy('NM_KANTOR')->get()->getResult();
->orderBy('NM_KANTOR')->get()->getResult();
foreach ($data as $key => $val) {
foreach ($data as $key => $val) {
$val->value = $val->value;
$val->value = $Ald->encryptMe($ val->value, $username) ;
}
}
return json_encode($data);
return json_encode($data);
@ -196,7 +325,10 @@ class Ref extends Controller
public function seksi()
public function seksi()
{
{
$kpp = $this->request->getGet('kpp');
$Ald = new AldLibrary;
$username = session('nip');
$kpp = $Ald->decryptMe($this->request->getGet('kpp'), $username);
$db = \Config\Database::connect();
$db = \Config\Database::connect();
$data = $db->table('PEGAWAI')->distinct()
$data = $db->table('PEGAWAI')->distinct()
->select('KD_UNIT_ORGANISASI as value, NAMA_UNIT_ES4 as label')
->select('KD_UNIT_ORGANISASI as value, NAMA_UNIT_ES4 as label')
@ -205,7 +337,7 @@ class Ref extends Controller
->orderBy('NAMA_UNIT_ES4')->get()->getResult();
->orderBy('NAMA_UNIT_ES4')->get()->getResult();
foreach ($data as $key => $val) {
foreach ($data as $key => $val) {
$val->value = $val->value;
$val->value = $Ald->encryptKpdl($ val->value, $username) ;
}
}
return json_encode($data);
return json_encode($data);
@ -213,8 +345,17 @@ class Ref extends Controller
public function ar()
public function ar()
{
{
$kpp = $this->request->getPost('kpp');
$Ald = new AldLibrary;
$kd_unit_organisasi = $this->request->getPost('seksi');
$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();
$db = \Config\Database::connect();
$data = $db->table('PEGAWAI')->distinct()
$data = $db->table('PEGAWAI')->distinct()
@ -225,12 +366,25 @@ class Ref extends Controller
->orderBy('NAMA')->get()->getResult();
->orderBy('NAMA')->get()->getResult();
foreach ($data as $key => $val) {
foreach ($data as $key => $val) {
$val->value = $val->value;
$val->value = $Ald->encryptMe($ val->value, $username) ;
}
}
return json_encode($data);
return json_encode($data);
}
}
public function change_case($arr)
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);
return array_change_key_case($arr, CASE_LOWER);
}
}