403Webshell
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 :  /wamp/www/sipapbd_2020/application/core/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /wamp/www/sipapbd_2020/application/core/Aktivitas_Model.php
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/*********************************************************************************************
  SUPER CLASS dari semua Model Aktivitas
 *********************************************************************************************/
class Aktivitas_Model extends Base_Model{

  var $tipe;
  var $id;
  var $nomor;
  var $fieldmap_aktivitas;
  var $fieldmap_daftar_aggregate; // variabel untuk menampung kolom yang di aggregate (sum, count, dll)
  var $data_aktivitas;
  var $id_bku;
  var $no_bku;
  var $sort_default;

  function __construct()
  {
    parent::__construct();
    $this->tipe = 'AKTIVITAS'; // tipe di override di modul aktivitas
    $this->tipe_jurnal = 'AKTIVITAS'; // di override di modul aktivitas
    $this->sort_default = array();

    $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',
      'id_jurnal' => 'ID_SETUP_JURNAL',
    );

    $this->fieldmap_daftar_aggregate = array();
  }

  function get_grid_model()
  {

  }

  function fill_data()
  {
    /* 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 = $this->input->post($key) === 'true' ? 1 : 0; break;
        case 'tgl'   : $$key = $this->input->post($key) ? prepare_date($this->input->post($key)) : NULL; break;
        case 'jurnal' :
            $id = $this->input->post($key);
            if ($id == "") {
              $this->data_aktivitas['ID_SETUP_JURNAL'] = NULL;
              $this->data_aktivitas['ID_SETUP_JURNAL_2'] = NULL;
            }
            else {
              $arrid = explode(",", $id);
              if (count($arrid) > 0){
                $$key = $arrid[0];
                $this->data_aktivitas['ID_SETUP_JURNAL_2'] = NULL;
                if (count($arrid) > 1) $this->data_aktivitas['ID_SETUP_JURNAL_2'] = $arrid[1];
              }
            }
            break;
        default : $$key = $this->input->post($key) ? $this->input->post($key) : NULL;
      }
      if(isset($$key))
        $this->data_aktivitas[$value] = $$key;
    }

    /* pengambilan data lain di override di modul aktivitas */
  }

  function get_auto_number()
  {
    $id_skpd = $this->input->post('id_skpd');
    $keperluan = $this->input->post('keperluan');
    $beban = $this->input->post('beban');
    $jenis_beban = $this->input->post('jenis_beban');

    $param = array(
      'tipe' => $this->tipe,
      'id_skpd' => $id_skpd,
      'keperluan' => $keperluan,
      'beban' => $beban,
      'jenis_beban' => $jenis_beban,
    );
    return $this->autho->check_nomor_aktivitas($param);
  }

  function cek_duplikasi_auto_number($param)
  {
    $id_skpd = $this->input->post('id_skpd');
    $keperluan = $this->input->post('keperluan');
    $beban = $this->input->post('beban');
    $jenis_beban = $this->input->post('jenis_beban');

    $param = array(
      'tipe' => $this->tipe,
      'id_skpd' => $id_skpd,
      'keperluan' => $keperluan,
      'beban' => $beban,
      'jenis_beban' => $jenis_beban,
      'nomor' => $param['nomor'],
      'id' => $param['id']
    );
    return $this->autho->check_nomor_aktivitas($param, TRUE);
  }

  function insert_aktivitas()
  {
    $this->data_aktivitas['NOMOR_INT'] = 0;
    // cek apakah entri baru dan penomoran otomatis
    if ($this->input->post('id') == 0 && $this->input->post('auto') == 'true')
    {
      $nomor_otomatis = $this->get_auto_number();
      $this->data_aktivitas['NOMOR'] = $nomor_otomatis['nomor'];
      $this->data_aktivitas['NOMOR_INT'] = $nomor_otomatis['nomor_int'];
    }

    if (isset($this->data_aktivitas['ID_AKTIVITAS']))
    {
      $this->db->where('ID_AKTIVITAS', $this->data_aktivitas['ID_AKTIVITAS']);
      $this->db->update('AKTIVITAS', $this->data_aktivitas);
      $this->check_trans_status('update aktivitas failed');
      $this->id = $this->data_aktivitas['ID_AKTIVITAS'];
    }
    else
    {
      $id = $this->get_id('g_id_aktivitas');
      $this->data_aktivitas['ID_AKTIVITAS'] = $id;
      $this->db->insert('AKTIVITAS', $this->data_aktivitas);
      $this->check_trans_status('insert aktivitas failed');
      $this->id = $id;
    }
    $this->nomor = $this->data_aktivitas['NOMOR'];
  }

  function save_detail()
  {
    // fungsi ini di override di modul Aktivitas
  }

  function save_data()
  {
    $this->db->trans_begin();
    try {
      $this->insert_aktivitas();
      $this->save_detail();
    }
    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();

    /*
    Untuk entri baru dan auto number, cek ulang duplikasi nomor
    jika ada duplikasi, ambil nomor baru dan update nomor
    */
    if ($this->input->post('id') == 0 && $this->input->post('auto') == 'true')
    {
      while ( 1 === 1 )
      {
        $delay = mt_rand(1, 100) * 10000;
        usleep( $delay );

        if ( $this->cek_duplikasi_nomor($this->nomor, TRUE) ) break;

        $this->db->trans_begin();
        $nomor_otomatis = $this->get_auto_number();
        $param = array(
          'nomor' => $nomor_otomatis['nomor'],
          'nomor_int' => $nomor_otomatis['nomor_int'],
        );
        $this->db->where('id_aktivitas', $this->id);
        $this->db->update('aktivitas', $param);
        $this->nomor = $param['nomor'];
        $this->db->trans_commit();
      }
    }

    return TRUE;
  }

  // Untuk mengambil informasi BKU bagi aktivitas yang masuk BKU
  // di implementasikan pada modul aktivitas yang masuk BKU (STS, SP2D, Kontra Pos, Setoran Sisa, Setoran Pajak, Setoran PFK)
  function get_data_bku()
  {

  }

  function delete_data($id)
  {
    $this->db->trans_begin();
    try {
      $this->build_query_hapus($id);
    }
    catch(Exception $e){
      //TODO : log error to file
    }

    if ($this->db->trans_status() === FALSE)
    {
      $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;
  }

  // jika aktivitas sudah masuk bud, maka yang bisa diubah hanya Setup Jurnal
  function fill_data_bku()
  {
    foreach($this->fieldmap_aktivitas as $key => $value){
      switch ($key)
      {
        case 'id'   : $$key = $this->input->post($key) ? prepare_date($this->input->post($key)) : NULL; $this->data_aktivitas[$value] = $$key; break;
        case 'jurnal'   : $$key = $this->input->post($key) ? $this->input->post($key) : NULL; $this->data_aktivitas[$value] = $$key; break;
        case 'id_jurnal' :
            $id = $this->input->post($key);
            if ($id == "") break;
            $arrid = explode(",", $id);
            if (count($arrid) > 0){
              $this->data_aktivitas[$value] = $arrid[0];
              $this->data_aktivitas['ID_SETUP_JURNAL_2'] = NULL;
              if (count($arrid) > 1) $this->data_aktivitas['ID_SETUP_JURNAL_2'] = $arrid[1];
            }
            else {
                $this->data_aktivitas['ID_SETUP_JURNAL'] = NULL;
                $this->data_aktivitas['ID_SETUP_JURNAL_2'] = NULL;
            }
            break;
      }
    }
  }

  function save_data_bku()
  {
    try {
      $this->db->where('ID_AKTIVITAS', $this->data_aktivitas['ID_AKTIVITAS']);
      $this->db->update('AKTIVITAS', $this->data_aktivitas);
      $this->check_trans_status('update aktivitas failed');
      $this->id = $this->data_aktivitas['ID_AKTIVITAS'];
    }
    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 build_query_daftar()
  {
    // di override di modul Aktivitas
  }

  function build_query_form($id=0)
  {
    // di override di modul Aktivitas
  }

  function build_query_hapus()
  {
    // di override di modul Aktivitas
  }

  // override get_data dari base_model
  function get_data($param, $isCount=FALSE, $CompileOnly=False)
  {
    $this->build_query_daftar();

    isset($param['limit']) && $param['limit'] ? $this->db->limit($param['limit']['end'], $param['limit']['start']) : '';

    // proses parameter pencarian, jika ada
    if (isset($param['search_mode']) && $param['search_mode'] !=='' )
    {
      // proses pencarian singkat (simple search)
      if ($param['search_mode'] == 'ss')
      {
        foreach($this->fieldmap_filter as $key => $value){
          $flt[$key] = array('search_str' => $param['q'], 'search_op' => 'cn');
        }
        if (count($flt) > 0)
        {
          $swhere = get_where_str($flt, $this->fieldmap_filter);
          if ($swhere) {
            $swhere = build_or_where($swhere);
            $this->db->where($swhere);
          }
        }
      }
      // proses pencarian lanjut (advanced search)
      else if ($param['search_mode'] == 'as') {
        $fields = $this->get_data_fields();
        if (is_array($param['q']) && count($param['q']) > 0)
        {
            foreach ($param['q'] as $key=>$val) {
            $kolom = $val['c'];
            $search_str = isset($val['s']) ? $val['s'] : '';
            $search_str2 = isset($val['s2']) ? $val['s2'] : '';

            $flt[$kolom] = array(
                'search_str' => $search_str,
                'search_str2' => $search_str2,
                'search_op' => $val['o'],
                'search_datatype' => $fields[$kolom]['kategori'],
            );
          }
          if (count($flt) > 0)
          {
            $wh = get_where_str($flt, $this->fieldmap_filter);

            $this->db->where($wh);
          }
        }
      }
    }

    if ($isCount) {
      $this->db->ar_select = array();
      $this->db->ar_select[] = 'count(*) cnt';
      foreach( $this->fieldmap_daftar_aggregate as $agg_key => $agg_value)
      {
        $this->db->ar_select[] = "coalesce(".$agg_value.", 0) ".$agg_key;
      }

      $result = $this->db->get();
      return $result->row_array();
    }
    else
    {
      // proses jika ada pengurutan
      if (isset($param['sort_by']) && $param['sort_by'] != null && !$isCount && $ob = get_order_by_str($param['sort_by'], $this->fieldmap_filter))
      {
        $this->db->order_by($ob, $param['sort_direction']);
      }
      // urutkan sesuai default jika ada
      else {
        if (count($this->sort_default) > 0){
          $this->db->_protect_identifiers = FALSE;
          $urutan = implode( ',', $this->sort_default);
          $this->db->order_by( $urutan );
          $this->db->_protect_identifiers = TRUE;
        }
      }

      if ($CompileOnly)
      {
        return $this->db->get_compiled_select();
      }
      else
      {
        $result = $this->db->get();
        return $result->result_array();
      }
    }
  }

  function get_setup_jurnal()
  {
    $this->db->select('id_setup_jurnal, kode_jurnal')
        ->from('setup_jurnal')
        ->where('formulir', $this->tipe_jurnal)
        ->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 cek_duplikasi_nomor($nomor, $auto=FALSE)
  {
    $id = $this->input->post('id') ? $this->input->post('id') : NULL;
    $id_skpd = $this->input->post('id_skpd') ? $this->input->post('id_skpd') : NULL;

    if ($this->input->post('auto') == 'true')
    {
      $param = array(
        'id' => $this->id ? $this->id : $id,
        'nomor' => $nomor
      );
      return $this->cek_duplikasi_auto_number($param);
    }
    else {
      $this->db->trans_begin();
      $this->db->select('COUNT(ID_AKTIVITAS) DUP');
      $this->db->where('TIPE', $this->tipe);
      $this->db->where('TAHUN', $this->tahun);
      $this->db->where('NOMOR', $nomor);
      if ($this->id) $this->db->where('ID_AKTIVITAS <', $this->id);
      else if ($id) $this->db->where('ID_AKTIVITAS <>', $id);

      // khusus untuk Aktivitas SP2D tidak perlu di filter SKPD
      if ($this->tipe !== 'SP2D') {
        if ($id_skpd) $this->db->where('ID_SKPD', $id_skpd);
      }
      $rs = $this->db->get('AKTIVITAS')->row_array();

      $this->db->trans_commit();
      return (integer)$rs['DUP'] === 0; // return TRUE jjika tidak ada duplikasi
    }
  }

  function get_prev_id($id)
  {
    $this->db->select('coalesce(max(a.id_aktivitas), 0) id_aktivitas')
      ->from('aktivitas a')
      ->where('a.tahun', $this->tahun)
      ->where('a.tipe', $this->tipe)
      ->where('id_aktivitas < ', $id);
    if ($this->id_skpd !== 0)
    {
      $this->db->where('a.id_skpd', $this->id_skpd);
      //$this->db->where('a.is_ppkd', $this->ppkd);
    }
    $result = $this->db->get()->row_array();

    return $result['ID_AKTIVITAS'];
  }

  function get_next_id($id)
  {
    $this->db->select('coalesce(min(a.id_aktivitas), 0) id_aktivitas')
      ->from('aktivitas a')
      ->where('a.tahun', $this->tahun)
      ->where('a.tipe', $this->tipe)
      ->where('id_aktivitas > ', $id);
    if ($this->id_skpd !== 0)
    {
      $this->db->where('a.id_skpd', $this->id_skpd);
      //$this->db->where('a.is_ppkd', $this->ppkd);
    }
    $result = $this->db->get()->row_array();

    return $result['ID_AKTIVITAS'];
  }

  function check_dependency($id)
  {
    return TRUE; // fungsi ini di override di modul Aktivitas
  }

  function susun_jurnal($id)
  {
    return FALSE;
  }
}

Youez - 2016 - github.com/yon3zu
LinuXploit