|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
namespace App\Controllers\Kewilayahan\Sebaran; |
|
|
|
|
|
|
|
|
|
use App\Libraries\KpdlLibrary; |
|
|
|
|
use CodeIgniter\Database\RawSql; |
|
|
|
|
|
|
|
|
|
class IdentifikasiLapangan extends \App\Controllers\Kewilayahan\Kytp |
|
|
|
|
|
|
|
|
@ -12,7 +13,8 @@ class IdentifikasiLapangan extends \App\Controllers\Kewilayahan\Kytp
|
|
|
|
|
$adm4_pcode = $request->getPost('adm4_pcode') ?? []; |
|
|
|
|
$id_poly_zona = $request->getPost('id_poly_zona') ?? []; |
|
|
|
|
|
|
|
|
|
$db = \Config\Database::connect(); |
|
|
|
|
$db = \Config\Database::connect(); |
|
|
|
|
$KpdlLibrary = new KpdlLibrary; |
|
|
|
|
if ($bulan == 'semua') { |
|
|
|
|
|
|
|
|
|
$npwp = $db->table('KPDL_MV_JML_KPDL_AGG A') |
|
|
|
@ -36,10 +38,36 @@ class IdentifikasiLapangan extends \App\Controllers\Kewilayahan\Kytp
|
|
|
|
|
->join("(" . $npwp . ") C", 'A.KODE = C.BULAN', 'left') |
|
|
|
|
->orderBy('BULAN'); |
|
|
|
|
|
|
|
|
|
$KpdlLibrary = new KpdlLibrary; |
|
|
|
|
|
|
|
|
|
return $KpdlLibrary->single_array($data->get()->getResult(), 'JML'); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
$tgl_format = date('Y') . '-' . $bulan . '-' . '01'; |
|
|
|
|
$generateTgl = $db->newQuery(new RawSql("SELECT trunc(LAST_DAY(to_date('" . $tgl_format . "','YYYY-MM-DD')) - level + 1) AS TGL |
|
|
|
|
FROM |
|
|
|
|
dual |
|
|
|
|
CONNECT BY LEVEL <= (trunc(LAST_DAY(to_date('" . $tgl_format . "','YYYY-MM-DD'))) - to_date('" . $tgl_format . "','YYYY-MM-DD') + 1)")); |
|
|
|
|
|
|
|
|
|
$data = $db->table('KPDL_MV_LOKASI_SUBJEK B') |
|
|
|
|
->select("TO_CHAR(CREATION_DATE,'DD') as TGL, COUNT(1) JML") |
|
|
|
|
->where("to_char(CREATION_DATE,'YYYY') = ", date('Y')) |
|
|
|
|
->where("to_char(CREATION_DATE,'MM') = ", $bulan) |
|
|
|
|
->groupBy("TO_CHAR(CREATION_DATE,'DD')"); |
|
|
|
|
|
|
|
|
|
if ($opsiWilZona == 'wilayah') { |
|
|
|
|
$data = $data->whereIn('ADM4_PCODE', $adm4_pcode); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($opsiWilZona == 'zona') { |
|
|
|
|
$data = $data->whereIn('ID_POLY_ZONA', $id_poly_zona); |
|
|
|
|
} |
|
|
|
|
$data = $data->getCompiledSelect(); |
|
|
|
|
|
|
|
|
|
$dataRet = $db->newQuery() |
|
|
|
|
->select("A.TGL, B.JML") |
|
|
|
|
->from($generateTgl, "A") |
|
|
|
|
->join("(" . $data . ") B", "A.TGL = B.TGL", 'left') |
|
|
|
|
->orderBy("TGL"); |
|
|
|
|
return $KpdlLibrary->single_array($dataRet->get()->getResult(), 'JML'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -49,7 +77,8 @@ class IdentifikasiLapangan extends \App\Controllers\Kewilayahan\Kytp
|
|
|
|
|
$adm4_pcode = $request->getPost('adm4_pcode') ?? []; |
|
|
|
|
$id_poly_zona = $request->getPost('id_poly_zona') ?? []; |
|
|
|
|
|
|
|
|
|
$db = \Config\Database::connect(); |
|
|
|
|
$db = \Config\Database::connect(); |
|
|
|
|
$KpdlLibrary = new KpdlLibrary; |
|
|
|
|
if ($bulan == 'semua') { |
|
|
|
|
|
|
|
|
|
$npwp = $db->table('KPDL_MV_JML_KPDL A') |
|
|
|
@ -73,10 +102,55 @@ class IdentifikasiLapangan extends \App\Controllers\Kewilayahan\Kytp
|
|
|
|
|
->join("(" . $npwp . ") C", 'A.KODE = C.BULAN', 'left') |
|
|
|
|
->orderBy('BULAN'); |
|
|
|
|
|
|
|
|
|
$KpdlLibrary = new KpdlLibrary; |
|
|
|
|
|
|
|
|
|
return $KpdlLibrary->single_array($data->get()->getResult(), 'JML'); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
$tgl_format = date('Y') . '-' . $bulan . '-' . '01'; |
|
|
|
|
$generateTgl = "SELECT TO_CHAR(LAST_DAY(to_date('" . $tgl_format . "','YYYY-MM-DD')) - level + 1,'DD') AS TGL |
|
|
|
|
FROM |
|
|
|
|
dual |
|
|
|
|
CONNECT BY LEVEL <= (trunc(LAST_DAY(to_date('" . $tgl_format . "','YYYY-MM-DD'))) - to_date('" . $tgl_format . "','YYYY-MM-DD') + 1)"; |
|
|
|
|
|
|
|
|
|
$data = $db->table('KPDL_MV_LOKASI_SUBJEK B') |
|
|
|
|
->select("TO_CHAR(CREATION_DATE,'DD') as TGL, COUNT(1) JML") |
|
|
|
|
->where("to_char(CREATION_DATE,'YYYY') = ", date('Y')) |
|
|
|
|
->where("to_char(CREATION_DATE,'MM') = " . $bulan) |
|
|
|
|
->groupBy("TO_CHAR(CREATION_DATE,'DD')"); |
|
|
|
|
|
|
|
|
|
if ($opsiWilZona == 'wilayah') { |
|
|
|
|
$data = $data->whereIn('ADM4_PCODE', $adm4_pcode); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($opsiWilZona == 'zona') { |
|
|
|
|
$data = $data->whereIn('ID_POLY_ZONA', $id_poly_zona); |
|
|
|
|
} |
|
|
|
|
$data = $data->getCompiledSelect(); |
|
|
|
|
|
|
|
|
|
$dataRet = $db->newQuery() |
|
|
|
|
->select("A.TGL, B.JML") |
|
|
|
|
->from("(" . $generateTgl . ") A") |
|
|
|
|
->join("(" . $data . ") B", "A.TGL = B.TGL", 'left') |
|
|
|
|
->orderBy("TGL"); |
|
|
|
|
|
|
|
|
|
return $KpdlLibrary->single_array($dataRet->get()->getResult(), 'JML'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected function generateSeries($bulan) |
|
|
|
|
{ |
|
|
|
|
$db = \Config\Database::connect(); |
|
|
|
|
$tgl_format = date('Y') . '-' . $bulan . '-' . '01'; |
|
|
|
|
$generateTgl = $db->query("SELECT TO_CHAR(LAST_DAY(to_date('" . $tgl_format . "','YYYY-MM-DD')) - level + 1,'DD') AS TGL |
|
|
|
|
FROM |
|
|
|
|
dual |
|
|
|
|
CONNECT BY LEVEL <= (trunc(LAST_DAY(to_date('" . $tgl_format . "','YYYY-MM-DD'))) - to_date('" . $tgl_format . "','YYYY-MM-DD') + 1) ORDER BY TGL"); |
|
|
|
|
|
|
|
|
|
$data = $generateTgl->getResult(); |
|
|
|
|
$data_arr = []; |
|
|
|
|
foreach ($data as $row) { |
|
|
|
|
array_push($data_arr, $row->TGL); |
|
|
|
|
} |
|
|
|
|
return $data_arr; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|