| 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/modules/import_xml/models/ |
Upload File : |
<?php
class Import_xml_model extends Base_Model {
var $fieldmap_aktivitas;
var $fieldmap_skrd;
var $fieldmap_rincian;
var $data_aktivitas;
var $data_skrd;
var $data_rincian;
var $path;
function __construct()
{
parent::__construct();
$this->tipe = 'SKPD';
$this->tipe_jurnal = 'SKPD';
$this->path = './uploads/';
$this->fieldmap_aktivitas = array(
'id' => 'ID_AKTIVITAS',
'tipe' => 'TIPE',
'tahun' => 'TAHUN',
'no' => 'NOMOR',
'tgl' => 'TANGGAL',
'deskripsi' => 'DESKRIPSI',
'id_skpd' => 'ID_SKPD',
'user' => 'USERNAME',
'ppkd' => 'IS_PPKD',
'jurnal' => 'ID_SETUP_JURNAL',
'auto' => 'NOMOR_INT'
);
$this->fieldmap_skrd = array(
'id' => 'ID_AKTIVITAS',
'nm_wp' => 'NAMA_WP',
'alamat_wp' =>'ALAMAT_WP',
'npwpd' => 'NPWPD',
'tempo' => 'JATUH_TEMPO',
);
$this->fieldmap_rincian = array(
'id' => 'ID_AKTIVITAS',
'idrek' => 'ID_REKENING',
'nom' => 'NOMINAL'
);
}
function fill_data($data)
{
if ($data)
{
$i = 0;
foreach ($data as $keydata => $valuedata) {
/* ambil data aktivitas */
foreach($this->fieldmap_aktivitas as $key => $value){
switch ($key)
{
case 'tipe' : $$key = $this->tipe; break;
case 'tahun' : $$key = $this->tahun; break;
case 'user' : $$key = $this->username; break;
case 'ppkd' : $$key = $this->ppkd; break;
case 'auto' : $$key = isset($data[$keydata][$key]) ? 1 : 0; break;
case 'tgl' : $$key = isset($data[$keydata][$key]) && $data[$keydata][$key] ? prepare_date($data[$keydata][$key]) : NULL; break;
case 'id_skpd' : $$key = $this->input->post('id_skpd'); break;
case 'jurnal' : $$key = $this->input->post('jurnal'); break;
default : $$key = isset($data[$keydata][$key]) && $data[$keydata][$key] ? $data[$keydata][$key] : NULL;
}
if(isset($$key))
$this->data_aktivitas[$i][$value] = $$key;
}
/* ambil data skrd */
foreach($this->fieldmap_skrd as $key => $value){
switch ($key)
{
case 'tempo' : $$key = isset($data[$keydata][$key]) && $data[$keydata][$key] ? prepare_date($data[$keydata][$key]) : NULL; break;
default : $$key = isset($data[$keydata][$key]) && $data[$keydata][$key] ? $data[$keydata][$key] : NULL;
}
if(isset($$key))
$this->data_skrd[$i][$value] = $$key;
}
/* ambil data rincian */
foreach($this->fieldmap_rincian as $key => $value){
switch ($key)
{
default : $$key = isset($data[$keydata][$key]) && $data[$keydata][$key] ? $data[$keydata][$key] : NULL;
}
if(isset($$key))
$this->data_rincian[$i][$value] = $$key;
}
$i++;
}
}
}
function insert()
{
for ($i=0; $i<count($this->data_aktivitas); $i++) {
$id = $this->get_id('g_id_aktivitas');
$this->data_aktivitas[$i]['ID_AKTIVITAS'] = $id;
$this->db->insert('AKTIVITAS', $this->data_aktivitas[$i]);
$this->check_trans_status('insert aktivitas failed');
$this->id = $id;
$this->nomor = $this->data_aktivitas[$i]['NOMOR'];
$this->data_skrd[$i]['ID_AKTIVITAS'] = $this->id;
$this->db->insert('SKRD', $this->data_skrd[$i]);
$this->check_trans_status('insert skrd failed');
$this->data_rincian[$i]['ID_AKTIVITAS'] = $this->id;
$this->db->insert('RINCIAN_SKRD', $this->data_rincian[$i]);
$this->check_trans_status('insert rincian skrd failed');
}
}
function save_data()
{
$this->db->trans_begin();
try {
$this->insert();
}
catch(Exception $e){
//TODO : log error to file
}
if ($this->db->trans_status() === FALSE)
{
$this->id = NULL;
$this->nomor = NULL;
$this->last_error_id = $this->db->_error_number();
$this->last_error_message = $this->db->_error_message();
$this->db->trans_rollback();
return FALSE;
}
$this->db->trans_commit();
return TRUE;
}
function get_setup_jurnal()
{
$this->db->select('id_setup_jurnal, kode_jurnal')
->from('setup_jurnal')
->where('formulir', 'SKPD')
->where('aktif', '1');
$result = $this->db->get()->result_array();
$setup_jurnal = array();
foreach($result as $row)
{
$setup_jurnal[] = array('id' => $row['ID_SETUP_JURNAL'], 'kode' => $row['KODE_JURNAL']);
}
return $setup_jurnal;
}
function data_rekening()
{
$rek = array();
$this->db->select('r.id_rekening, r.kode_rekening')
->from('rekening r')
->where('r.tipe', '4')
->where('r.rincian <>', '');
$result = $this->db->get()->result_array();
foreach ($result as $row) {
$rek[$row['KODE_REKENING']] = $row['ID_REKENING'];
}
return $rek;
}
function data_no_skp()
{
$no = array();
$this->db->select('a.nomor, a.id_skpd')
->from('aktivitas a')
->where('a.tipe', $this->tipe)
->where('a.tahun', $this->tahun);
if ($this->session->userdata('id_skpd') !== 0)
{
$this->db->where('a.id_skpd', $this->session->userdata('id_skpd'));
}
$result = $this->db->get()->result_array();
foreach ($result as $row) {
$no[$row['NOMOR']] = $row['ID_SKPD'];
}
return $no;
}
}