| Server IP : 127.0.0.1 / Your IP : 192.168.99.1 Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9 System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64 User : Administrator ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : D:/wamp/www/SIPBOS_2020/application/libraries/ |
Upload File : |
<?php
/*
* Class penomoran otomatis
*/
class autho
{
var $CI = null;
function __construct()
{
$this->CI = & get_instance();
}
function check_nomor_aktivitas($param)
{
$id_skpd = isset($param['id_skpd']) ? $param['id_skpd'] : 0;
$form = isset($param['tipe']) ? $param['tipe'] : '';
$beban = isset($param['beban']) ? $param['beban'] : '';
$keperluan = isset($param['keperluan']) ? $param['keperluan'] : '';
$tipe = '';
switch ($form)
{
case 'SPD' :
case 'SKPD' :
case 'TBP' :
case 'STS' :
case 'SPP' :
case 'SPM' :
case 'SP2D' :
case 'SPJP' :
case 'SPJPB' :
case 'DP' :
case 'CP' :
case 'SSU' :
case 'SSP' :
case 'SPJK' :
case 'SPFK' :
case 'MP' :
case 'BLJ' :
case 'SPJ' :
case 'SPJKD' :
case 'PB' :
case 'PB_TARIK' :
case 'PB_SETOR' :
case 'BKU' :
case 'BKUS' :
case 'PANJAR' :
case 'SISA_PJR' :
case 'SP2B' :
case 'SP3B' :
case 'SPJ_PANJAR' : $tipe = $form; break;
case 'BKUSP' : $tipe = $form; break;
case 'VER_SPP' : $tipe = 'SPP'; break;
case 'VER_SPM' : $tipe = 'SPM'; break;
case 'VER_SPJ' : $tipe = 'SPJ'; break;
}
/* ambil template sesuai tipe aktivitas */
$db = $this->CI->db;
$db->select('template')->from('penomoran')->where('tipe', $form);
$result = $db->get()->row_array();
if ( count($result) == 0 ){
return false;
}
$only_nomor = FALSE;
$template = $result['TEMPLATE'];
$sql_cek = $template;
/* Proses {nomor}
******************************************************************************************
*/
$pattern = "{nomor:\d+(:AN)?}";
preg_match_all($pattern, $template, $tmp);
$tmp_nomor = $tmp[0];
$digit_ = '';
$digit = 1;
// $first_digit = strpos ($template, "{nomor") + 1;
if (count($tmp_nomor) > 0)
{
$nomor = $tmp_nomor[0];
$tmp = explode(':', $nomor);
$digit = $tmp[1];
$digit_ = str_repeat('_', $digit);
if (isset($tmp[2]) && $tmp[2] === 'AN')
{
$only_nomor = TRUE;
$tmp_nomor = str_replace(':AN', '', $nomor);
}
$sql_cek = str_replace("{".$nomor."}", $digit_, $sql_cek);
}
/* Proses {skpd}
******************************************************************************************
*/
if ($id_skpd)
{
$pattern = "{skpd:\d+}";
preg_match_all($pattern, $template, $tmp);
$tmp_skpd = $tmp[0];
if (count($tmp_skpd) > 0)
{
$tmp = explode(':', $tmp_skpd[0]);
$digit_skpd = $tmp[1];
$db->select('kode_skpd, kode_skpd_lkp')->from('v_skpd')->where('id_skpd', $param['id_skpd']);
$skpd = $db->get()->row_array();
switch ($digit_skpd)
{
case 1 : $kode_skpd = $skpd['KODE_SKPD'];
case 2 : $kode_skpd = $skpd['KODE_SKPD_LKP'];
}
$sql_cek = str_replace("{".$tmp_skpd[0]."}", $kode_skpd, $sql_cek);
}
/* Proses {adm}
******************************************************************************************
*/
$pattern = "{adm}";
preg_match_all($pattern, $template, $tmp);
$tmp_adm = $tmp[0];
if (count($tmp_adm) > 0)
{
$db->select('kode_administrasi')->from('skpd')->where('id_skpd', $param['id_skpd']);
$skpd = $db->get()->row_array();
$sql_cek = str_replace($pattern, $skpd['KODE_ADMINISTRASI'], $sql_cek);
}
}
/* Proses {spp}
******************************************************************************************
*/
if (in_array($form, array('SPP', 'VER_SPP', 'SPM', 'VER_SPM', 'SP2D')) )
{
$pattern = "{spp}";
preg_match_all($pattern, $template, $tmp);
$tmp_tipe = $tmp[0];
if (count($tmp_tipe) > 0)
{
$spp = $keperluan;
if ($beban === 'GJ') $spp = 'GJ';
$sql_cek = str_replace($pattern, $spp, $sql_cek);
}
}
/* Proses {tipe}
******************************************************************************************
*/
$pattern = "{tipe}";
preg_match_all($pattern, $template, $tmp);
$tmp_tipe = $tmp[0];
if (count($tmp_tipe) > 0)
{
$sql_cek = str_replace($pattern, $param['tipe'], $sql_cek);
}
/* Proses {triwulan}
******************************************************************************************
*/
$pattern = "{triwulan}";
preg_match_all($pattern, $template, $tmp);
$tmp_tw = $tmp[0];
if (count($tmp_tw) > 0)
{
$triwulan = $this->triwulan(date("m"));
$sql_cek = str_replace($pattern, $triwulan, $sql_cek);
}
/* Proses {bulan}
******************************************************************************************
*/
$pattern = "{bulan}";
preg_match_all($pattern, $template, $tmp);
$tmp_bulan = $tmp[0];
if (count($tmp_bulan) > 0)
{
$bulan = $this->bulan(date("m"));
$sql_cek = str_replace($pattern, $bulan, $sql_cek);
}
/* Proses {tahun}
******************************************************************************************
*/
$pattern = "{tahun}";
preg_match_all($pattern, $template, $tmp);
$tmp_tahun = $tmp[0];
if (count($tmp_tahun) > 0)
{
$tahun = date("Y");
$sql_cek = str_replace($pattern, $tahun, $sql_cek);
}
/* Proses {keperluan}
******************************************************************************************
*/
if ($keperluan)
{
$pattern = "{keperluan}";
preg_match_all($pattern, $template, $tmp);
$tmp_kpl = $tmp[0];
if (count($tmp_kpl) > 0)
{
$sql_cek = str_replace($pattern, $keperluan, $sql_cek);
}
}
/* Proses {beban}
******************************************************************************************
*/
if ($beban)
{
$pattern = "{beban}";
preg_match_all($pattern, $template, $tmp);
$tmp_bbn = $tmp[0];
if (count($tmp_bbn) > 0)
{
$sql_cek = str_replace($pattern, $beban, $sql_cek);
}
}
if ($digit_ != '')
{
$first_digit = strpos ($sql_cek, $digit_) + 1;
$tabel;
/* cek nomor terakhir */
switch ($tipe)
{
case 'SPD' : $tabel = 'SPD'; break;
case 'SKPD' : $tabel = 'SKRD'; break;
case 'TBP' : $tabel = 'TBP'; break;
case 'STS' : $tabel = 'STS'; break;
case 'SPP' : $tabel = 'V_SPP'; break;
case 'SPM' : $tabel = 'V_SPM'; break;
case 'SP2D' : $tabel = 'V_SP2D'; break;
case 'SPJP' : $tabel = 'SPJP'; break;
case 'SPJPB' : $tabel = 'SPJP'; break;
case 'DP' : $tabel = 'DAFTAR_PENGUJI'; break;
case 'CP' : $tabel = 'KONTRA_POS'; break;
case 'SSU' : $tabel = 'SETORAN_SISA'; break;
case 'SSP' : $tabel = 'SETORAN_PAJAK'; break;
case 'SPJK' : $tabel = 'SETORAN_PAJAK_SP2D'; break;
case 'SPFK' : $tabel = 'SETORAN_PFK_SP2D'; break;
case 'MP' : $tabel = 'MEMO_PENYESUAIAN'; break;
case 'BLJ' : $tabel = 'BELANJA'; break;
case 'SP2B' : $tabel = 'SP2B_SP3B'; break;
case 'SP3B' : $tabel = 'SP2B_SP3B'; break;
case 'SPJ' : $tabel = 'SPJ'; break;
case 'SPJKD' : $tabel = 'SPJKD'; break;
case 'PB' :
case 'PB_TARIK' : $tabel = 'PEMINDAHBUKUAN'; break;
case 'PB_SETOR' : $tabel = ''; break;
case 'PANJAR' :
case 'SISA_PJR' :
case 'SPJ_PANJAR' : $tabel = 'PANJAR'; break;
case 'BKU' : $tabel = 'BKU'; break;
case 'BKUS' :
case 'BKUSP' : $tabel = 'BKU_SKPD'; break;
}
if (in_array($form, array('VER_SPP', 'VER_SPM', 'VER_SPJ')) )
{
/* untuk form verifikasi yang dicek dari NOMOR_VERIFIKASI */
$kolom_nomor = 'b.nomor_verifikasi';
}
else {
/* selain form verifikasi diambil dari NOMOR di tabel AKTIVITAS */
$kolom_nomor = 'a.nomor';
}
$db->select('coalesce(max(substring('.$kolom_nomor.' from '.$first_digit.' for '.$digit.')), 0) maxno');
$db->from('aktivitas a');
if ($tabel !== '')
$db->join($tabel." b", 'b.id_aktivitas = a.id_aktivitas');
$db->where('a.tipe', $tipe);
$db->where('a.tahun', $this->CI->session->userdata('tahun'));
if($tipe=='spjp') $db->where('b.nominal_pendapatan > 0');
if($tipe=='spjpb') $db->where('b.nominal_belanja > 0');
if (!$only_nomor)
{
$db->where($kolom_nomor." like '".$sql_cek."'");
if (isset($digit_skpd) && $id_skpd > 0) $db->where('a.id_skpd', $id_skpd);
if ($keperluan && count($tmp_kpl) > 0) $db->where('b.keperluan', $keperluan);
if ($beban && count($tmp_bbn) > 0)
{
if (in_array($form, array('SPP', 'SPM', 'SP2D', 'VER_SPP', 'VER_SPM')))
$db->where('b.jenis_beban', $beban);
else
$db->where('b.beban', $beban);
}
}
$result = $db->get()->row_array();
if (count($result) > 0)
$maxno = (int) $result['MAXNO'] == 0 ? 1 : (int) $result['MAXNO'] + 1;
else
$maxno = 1;
$nomor = $this->FormatNoTrans($maxno, $digit);
return substr_replace($sql_cek, $nomor, $first_digit - 1, $digit);
}
else
return $sql_cek;
}
function FormatNoTrans($num,$panjang) {
$pjg_kar = strlen($num);
$rpt = $panjang - $pjg_kar;
$prev = '';
if($rpt > 0){
for($u=0;$u<$rpt;$u++){
$prev.="0";
}
$NoTrans = $prev.$num;
}
else{
$NoTrans = $num;
}
return $NoTrans;
}
function bulan($bulan)
{
switch ($bulan)
{
case 1 : $bulan = "JAN"; break;
case 2 : $bulan = "FEB"; break;
case 3 : $bulan = "MAR"; break;
case 4 : $bulan = "APR"; break;
case 5 : $bulan = "MEI"; break;
case 6 : $bulan = "JUN"; break;
case 7 : $bulan = "JUL"; break;
case 8 : $bulan = "AGS"; break;
case 9 : $bulan = "SEP"; break;
case 10 : $bulan = "OKT"; break;
case 11 : $bulan = "NOV"; break;
case 12 : $bulan = "DES"; break;
}
return $bulan;
}
function triwulan($bulan)
{
switch ($bulan)
{
case 1 :
case 2 :
case 3 : $triwulan = 'I'; break;
case 4 :
case 5 :
case 6 : $triwulan = 'II'; break;
case 7 :
case 8 :
case 9 : $triwulan = 'III'; break;
case 10 :
case 11 :
case 12 : $triwulan = 'IV'; break;
}
return $triwulan;
}
}