| 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/sipkd_2016/application/modules/setup_jurnal/controllers/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Setup_jurnal extends Userpage_Controller {
public function __construct()
{
parent::__construct();
$this->modul_name = 'setup_jurnal';
$this->modul_display = 'Setup Jurnal';
$this->view_daftar = 'setup_view';
$this->view_form = 'setup_form';
$this->report_daftar = 'Daftar Setup Jurnal';
$this->report_form = 'Form Setup Jurnal';
$this->load->model('setup_jurnal_model', 'data_model');
}
public function index()
{
$this->daftar();
}
protected function get_grid_model()
{
// di override di modul Aktivitas
}
protected function get_data_fields()
{
// di override di modul Aktivitas
}
public function daftar()
{
$this->load->model('auth/login_model', 'auth');
$data['breadcrumbs'] = 'Daftar '.$this->modul_display;
$data['title'] = 'SIP Keuangan';
$data['modul'] = $this->modul_name;
$data['report_daftar'] = $this->report_daftar;
$data['grid']['akses'] = $this->auth->get_level_akses($this->uri->slash_segment(1));
$data['grid']['skpd'] = $this->session->userdata('id_skpd');
$data['grid']['url'] = base_url($this->modul_name.'/get_daftar');
$data['grid']['url_add'] = base_url($this->modul_name.'/form');
$data['grid']['url_del'] = base_url($this->modul_name.'/hapus');
$data['grid']['data'] = $this->data_model->get_grid_model();
$data['grid']['fields'] = $this->data_model->get_data_fields();
$data['main_content'] = $this->view_daftar;
$this->load->view('layout/template', $data);
}
public function get_daftar()
{
$page = $this->input->post('page') ? $this->input->post('page') : 0; // get the requested page
$limit = $this->input->post('rows') ? $this->input->post('rows') : 0; // get how many rows we want to have into the grid
$sidx = $this->input->post('sidx') ? $this->input->post('sidx') : 0; // get index row - i.e. user click to sort
$sord = $this->input->post('sord') ? $this->input->post('sord') : ''; // get the direction if(!$sidx) $sidx =1;
/* untuk keperluan pencarian */
$mode = $this->input->post('m') ? $this->input->post('m') : '';
$q = $this->input->post('q') ? $this->input->post('q') : '';
$this->search_param = array (
"sort_by" => $sidx,
"sort_direction" => $sord,
"search_mode" => $mode,
"q" => $q,
);
$count = $this->data_model->get_data($this->search_param, TRUE);
$response = (object) NULL;
$response->sql = $this->db->queries;
if($count == 0) // tidak ada data
{
echo json_encode($response);
return '';
}
$total_pages = ceil($count/$limit);
if ($page > $total_pages) $page = $total_pages;
$start = $limit * $page - $limit;
if($start < 0) $start = 0;
$this->search_param['limit'] = array(
'start' => $start,
'end' => $limit
);
$result = $this->data_model->get_data($this->search_param);
$response->page = $page;
$response->total = $total_pages;
$response->records = $count;
$response->sql = $this->db->queries;
$fields = $this->data_model->fieldmap_daftar;
for($i=0; $i<count($result); $i++)
{
$response->rows[$i]['id'] = $result[$i][$fields[0]];
$data = array();
for ($n=1; $n < count($fields); $n++)
{
$data[] = $result[$i][$fields[$n]];
}
$response->rows[$i]['cell'] = $data;
}
echo json_encode($response);
}
public function form($id=0)
{
$data = array();
$data['title'] = 'SIP Keuangan';
$data['modul'] = $this->modul_name;
$data['modul_display'] = $this->modul_display;
$data['report_form'] = $this->report_form;
$this->load->model('auth/login_model', 'auth');
$data['akses'] = $this->auth->get_level_akses($this->uri->slash_segment(1));
$data['formulir'] = $this->data_model->formulir;
$data['elemen'] = $this->data_model->elemen;
if ($id!==0)
{
$data['data'] = $this->data_model->get_data_by_id($id);
}
$data['main_content']= $this->view_form;
$this->load->view('layout/template',$data);
}
function validasi_form()
{
$this->form_validation->set_rules('kode', 'Kode Jurnal', 'required|trim|max_length[10]');
}
// override, ditambahkan pengecekan tambahan
public function proses()
{
$response = (object) NULL;
$this->load->model('auth/login_model', 'auth');
$akses = $this->auth->get_level_akses($this->uri->slash_segment(1));
$confirm = $this->input->post('confirm') === 'true';
$id = $this->input->post('id');
if($akses == '3')
{
$this->load->library('form_validation');
$this->validasi_form();
if($this->form_validation->run() == TRUE)
{
// cek sudah pernah dipakai di aktivitas atau belum ?
if (!$confirm && $this->data_model->cek_aktivitas($id))
{
$response->isSuccess = FALSE;
$response->error = "ERR_ALREADY_USED";
}
else
{
$this->data_model->fill_data();
$success = $this->data_model->save_data();
if($success){
$response->isSuccess = TRUE;
$response->message = 'Data berhasil disimpan';
$response->id = $this->data_model->id;
$response->sql = $this->db->queries;
}
else
{
$response->isSuccess = FALSE;
$response->message = 'Data gagal disimpan';
$response->error = $this->data_model->last_error_message;
$response->sql = $this->db->queries;
}
}
}
else
{
$response->isSuccess = FALSE;
$response->sql = $this->db->queries;
$response->message = validation_errors();
}
}
else
{
$response->isSuccess = FALSE;
$response->message = 'Proses Gagal, Anda tidak memiliki hak akses';
}
echo json_encode($response);
}
public function rincian($jenis='', $id=0)
{
$result = $this->data_model->get_rinci_by_id($jenis, $id);
$response = (object) NULL;
if ($result){
for($i=0; $i<count($result); $i++)
{
$response->rows[$i]['id'] = $result[$i]['ID_RINCIAN_SETUP_JURNAL'];
$response->rows[$i]['cell']=array(
$result[$i]['ID_RINCIAN_SETUP_JURNAL'],
$result[$i]['KOLOM'],
$result[$i]['DK'],
$result[$i]['NOMINAL'],
);
}
}
echo json_encode($response);
}
public function prev($id=0)
{
$response = (object) NULL;
$response->isSuccessful = FALSE;
if ($id !== 0)
{
$result = $this->data_model->get_prev_id($id);
if ($result)
{
$response->isSuccessful = TRUE;
$response->id = $result;
}
}
echo json_encode($response);
}
public function next($id=0)
{
$response = (object) NULL;
$response->isSuccessful = FALSE;
if ($id !== 0)
{
$result = $this->data_model->get_next_id($id);
if ($result)
{
$response->isSuccessful = TRUE;
$response->id = $result;
}
}
echo json_encode($response);
}
}