Untitled

mail@pastecode.io avatar
unknown
plain_text
5 months ago
6.3 kB
1
Indexable
   function generate($kd_satker,$tahun,$bulan,$jenis) {
        $index = 0;
        $data = array();
        $data2 = array();
        $no = 0;
        
        if($jenis == 'PPNPN'){
            $this->generate_ppnpn($kd_satker,$tahun,$bulan);
        }else{
            $results = $this->_ci->M_pegawai->select_all($kd_satker);
            if(isset($results)){
              foreach ($results as $pegawai) {
                $nip = $pegawai->nip;
                $nik = $pegawai->nik;
                if($jenis == 'Gaji'){
                    $this->_ci->load->model('M_gaji');
                    $result = $this->_ci->M_gaji->select_all_sum_by_pegawai($kd_satker,$tahun,$bulan,$nip);
                }elseif($jenis == 'Gaji Rapel'){
                    $this->_ci->load->model('M_gaji_rapel');
                    $result = $this->_ci->M_gaji_rapel->select_by_bulan_tahun_by_pegawai($bulan,$tahun,$kd_satker,$nip);
                }elseif($jenis == 'Tukin'){
                    $this->_ci->load->model('M_tukin');
                    $result = $this->_ci->M_tukin->select_all_sum_by_pegawai($kd_satker,$tahun,$bulan,$nip);
                }
                $no_daftar = $result->no_daftar;
    
                $reg_penghasilan = $this->_ci->M_tb_register_penghasilan->get_by_no_daftar($kd_satker,$tahun,$no_daftar);
                if($reg_penghasilan != NULL){
                    $tgl_potong = $reg_penghasilan->tgl_potong;
                }else{
                  $tgl_potong = '';
                }
                if($pegawai != NULL){
                  $nama = $pegawai->nama;
                  $nik = $pegawai->nik;
                  $npwp = $pegawai->npwp;
                }else{
                  $nama = '';
                  $nik = '';
                  $npwp = '';
                }
                if($jenis == 'Gaji'){
                    $kdpajak = "21-100-01";
                    $ph_bruto = ($result->gaji_pokok + $result->tj_istri + $result->tj_anak + $result->tj_upns + $result->tj_struk + $result->tj_fungs + $result->tj_daerah + $result->tj_pencil + $result->tj_lain + $result->tj_kompen + $result->pembul + $result->tj_beras);
                    $pph = $result->pph;
                    $tarif_pph = '5';
                    $tgl_lahir = '';
                    $alamat = '';
                    $no_passport = '';
                    $no_kitas = '';
                    $kd_negara = '';
                }elseif($jenis == 'Gaji Rapel'){
                    $kdpajak = "21-100-01";
                    $ph_bruto = ($result->gaji_pokok + $result->tj_istri + $result->tj_anak + $result->tj_upns + $result->tj_struk + $result->tj_fungs + $result->tj_daerah + $result->tj_pencil + $result->tj_lain + $result->tj_kompen + $result->pembul + $result->tj_beras);
                    $pph = $result->pph;
                    $tarif_pph = '5';
                    $tgl_lahir = '';
                    $alamat = '';
                    $no_passport = '';
                    $no_kitas = '';
                    $kd_negara = '';
                }elseif($jenis == 'Tukin'){
                    $kdpajak = "21-100-01";
                    $ph_bruto = $result->ph_bruto;
                    $pph = $result->pph_tukin;
                    $tarif_pph = '5';
                    $tgl_lahir = '';
                    $alamat = '';
                    $no_passport = '';
                    $no_kitas = '';
                    $kd_negara = '';
                }
                
                if($ph_bruto == NULL){
                  continue;
                }
                if($pph == NULL){
                  $pph = 0;
                }
                if($tarif_pph == NULL){
                  $tarif_pph = 0;
                }
    
                $cek = $this->_ci->M_tb_export_bulanan->cek_by_nip_bulan_tahun($nip, $kd_satker, $bulan, $tahun, $jenis);
                if($cek < 1){
                  $data['kd_satker']  = $kd_satker;
                  $data['kd_pajak']  = $kdpajak;
                  $data['jenis_penghasilan']  = $jenis;
                  $data['bulan']  = $bulan;
                  $data['nik']  = $nik;
                  $data['nip']  = $nip;
                  $data['tahun']  = $tahun;
                  $data['nama']  = $nama;
                  $data['npwp']  = $npwp;
                  $data['tgl_potong']  = $tgl_potong;
                  $data['penghasilan_bruto']  = $ph_bruto;
                  $data['dpp']  = $ph_bruto;
                  $data['tarif']  = $tarif_pph;
                  $data['pph']  = $pph;
                  $data['tgl_lahir']  = $tgl_lahir;
                  $data['alamat']  = $alamat;
                  $data['no_passport'] = $no_passport;
                  $data['no_kitas'] = $no_kitas;
                  $data['kd_negara'] = $kd_negara;
                  $data['no_document'] = $no_daftar;
    
                  $this->_ci->M_tb_export_bulanan->insert($data);
                }else{
                  $get_data = $this->_ci->M_tb_export_bulanan->get_by_nip_bulan_tahun($nip, $kd_satker, $bulan, $tahun, $jenis);
                //   vdebug($reg_penghasilan);
                  $data2['id']  = $get_data->id;
                  $data2['kd_satker']  = $kd_satker;
                  $data2['kd_pajak']  = $kdpajak;
                  $data2['jenis_penghasilan']  = $jenis;
                  $data2['bulan']  = $bulan;
                  $data2['nik']  = $nik;
                  $data2['nip']  = $nip;
                  $data2['tahun']  = $tahun;
                  $data2['nama']  = $nama;
                  $data2['npwp']  = $npwp;
                  $data2['tgl_potong']  = $tgl_potong;
                  $data2['penghasilan_bruto']  = $ph_bruto;
                  $data2['dpp']  = $ph_bruto;
                  $data2['tarif']  = $tarif_pph;
                  $data2['pph']  = $pph;
                  $data2['tgl_lahir']  = $tgl_lahir;
                  $data2['alamat']  = $alamat;
                  $data2['no_passport'] = $no_passport;
                  $data2['no_kitas'] = $no_kitas;
                  $data2['kd_negara'] = $kd_negara;
                  $data2['no_document'] = $no_daftar;
    
                  $this->_ci->M_tb_export_bulanan->update($data2);
                }
    
              }
    
            }
        }
      return true;
    }
Leave a Comment