| 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/tim_anggaran/controllers/ |
Upload File : |
<?php
class Tim_anggaran extends Userpage_Controller {
public function __construct()
{
parent::__construct();
$this->modul_name = 'tim_anggaran';
$this->modul_display = 'Tim Anggaran';
$this->view_daftar = 'tim_anggaran_view';
$this->report_daftar = 'Daftar Tim_Anggaran';
$this->load->model('tim_anggaran_model', 'data_model');
}
public function index()
{
$this->load->model('auth/login_model', 'auth');
$data['breadcrumbs'] = 'Daftar '.$this->modul_display;
$data['modul'] = $this->modul_name;
$data['report_daftar'] = $this->report_daftar;
$data['akses'] = $this->auth->get_level_akses($this->uri->slash_segment(1));
$data['grid']['fields'] = $this->data_model->get_data_fields();
$data['main_content'] = $this->view_daftar;
$this->load->view('layout/template', $data);
}
public function form($id = '')
{
$data['title'] = get_title($this->modul_display);
$data['modul'] = $this->modul_name;
$this->load->model('auth/login_model', 'auth');
$data['akses'] = $this->auth->get_level_akses($this->uri->slash_segment(1));
$data['main_content']='tim_anggaran_form';
if($id)
{
$rows=$this->data_model->get_data_by_id($id);
$data['data'] = $this->data_model->get_data_by_id($id);
$data['locking'] = $this->data_model->check_lock($rows['ID_TIM_ANGGARAN'],$this->modul_name);
}
$this->load->view('layout/template',$data);
}
protected function validasi_form()
{
$this->form_validation->set_rules('nama_tim','Nama Tim','required|trim');
$this->form_validation->set_rules('nama_tim','Nama Tim','callback_duplikasi_nama');
$this->form_validation->set_message('required', '%s tidak boleh kosong.');
$this->form_validation->set_message('_duplikasi_nama', 'Kode sudah ada.');
}
function duplikasi_nama($str)
{
if ($this->data_model->check_duplikasi_tim($str))
{
$this->form_validation->set_message('duplikasi_nama', '%s "'.$str.'" sudah ada.');
return FALSE;
}
else
{
return TRUE;
}
}
public function get_daftar()
{
parent::get_daftar();
$result = $this->data_model->get_data($this->search_param);
$response = (object) NULL;
$response->sql = $this->db->queries;
for($i=0; $i<count($result); $i++)
{
$response->rows[$i]['id']=$result[$i]['ID_TIM_ANGGARAN'];
$response->rows[$i]['cell']=array(
$result[$i]['NAMA_TIM']
);
}
echo json_encode($response);
}
public function get_pejabat($id = 0)
{
$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;
$req_param = array (
'id_tim_anggaran' => $id,
"sort_by" => $sidx,
"sort_direction" => $sord,
);
$count = $this->data_model->get_data_pejabat($req_param, TRUE);
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;
$req_param['limit'] = array(
'start' => $start,
'end' => $limit,
);
$result = $this->data_model->get_data_pejabat($req_param);
$response = (object) NULL;
$response->page = $page;
$response->total = $total_pages;
$response->records = $count;
$response->sql = $this->db->queries;
$fields = $this->data_model->fields_pejabat;
for($i=0; $i<count($result); $i++)
{
$data = array();
for ($n=1; $n < count($fields); $n++)
{
$data[] = $result[$i][$fields[$n]];
}
$response->rows[$i]['id'] = $result[$i]['ID_PEJABAT_DAERAH'];
$response->rows[$i]['cell'] = $data;
}
echo json_encode($response);
}
function proses()
{
$response = (object) NULL;
$this->load->model('auth/login_model', 'auth');
$akses = $this->auth->get_level_akses($this->uri->slash_segment(1));
if($akses == '3')
{
$this->load->library('form_validation');
$this->validasi_form();
if($this->form_validation->run() == TRUE)
{
$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;
}
else
{
$response->isSuccess = FALSE;
$response->message = 'Data gagal disimpan';
$response->error = $this->data_model->last_error_message;
}
}
else
{
$response->isSuccess = FALSE;
$response->message = validation_errors();
}
}
else
{
$response->isSuccess = FALSE;
$response->message = 'Proses Gagal, Anda tidak memiliki hak akses';
}
$response->sql = $this->db->queries;
echo json_encode($response);
}
public function hapus()
{
$response = (object) NULL;
$this->load->model('auth/login_model', 'auth');
$akses = $this->auth->get_level_akses($this->uri->slash_segment(1));
if($akses !== 3)
{
$response->isSuccess = FALSE;
$response->message = 'Anda tidak memiliki Hak akses.';
echo json_encode($response);
return;
}
$id = $this->input->post('id');
$result = $this->data_model->check_dependency($id);
if($result)
{
// bisa dihapus
$hapus = $this->data_model->delete_data($id);
if ($hapus)
{
$response->isSuccess = TRUE;
$response->message = $this->message_berhasil_dihapus;
}
else
{
$response->isSuccess = FALSE;
$response->message = 'Proses hapus tidak berhasil.';
$response->error = $this->data_model->last_error_message;
}
}
else
{
// ada dependensi, tampilkan pesan kesalahan
$response->isSuccess = FALSE;
$response->message = $this->message_gagal_dihapus;
}
$response->sql = $this->db->queries;
echo json_encode($response);
}
function rincian_skpd($id = 0)
{
$response = (object) NULL;
$result = $this->data_model->get_rincian_skpd($id);
if ($result){
for($i=0; $i<count($result); $i++)
{
$response->rows[$i]['id'] = $result[$i]['ID_TIM_ANGGARAN_SKPD'];
$response->rows[$i]['cell'][] = $result[$i]['ID_TIM_ANGGARAN_SKPD'];
$response->rows[$i]['cell'][] = $result[$i]['ID_SKPD'];
$response->rows[$i]['cell'][] = $result[$i]['KODE_SKPD_LKP'];
$response->rows[$i]['cell'][] = $result[$i]['NAMA_SKPD'];
}
}
$response->sql = $this->db->queries;
echo json_encode($response);
}
function rincian_pejabat($id = 0)
{
$response = (object) NULL;
$result = $this->data_model->get_rincian_pejabat($id);
if ($result){
for($i=0; $i<count($result); $i++)
{
$response->rows[$i]['id'] = $result[$i]['ID_TIM_ANGGARAN_PEJABAT'];
$response->rows[$i]['cell'][] = $result[$i]['ID_TIM_ANGGARAN_PEJABAT'];
$response->rows[$i]['cell'][] = $result[$i]['JABATAN'];
$response->rows[$i]['cell'][] = $result[$i]['NAMA_PEJABAT'];
$response->rows[$i]['cell'][] = $result[$i]['NIP'];
$response->rows[$i]['cell'][] = $result[$i]['ID_PEJABAT_DAERAH'];
}
}
$response->sql = $this->db->queries;
echo json_encode($response);
}
}