| 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_2018_sekolah_geser/application/modules/ssh/controllers/ |
Upload File : |
<?php
class Ssh extends Userpage_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('ssh_model','data_model');
$this->load->model('auth/login_model', 'auth');
$this->load->library('form_validation');
$this->report_daftar = 'Daftar SSH';
}
public function index()
{
$data['title']='SIPAPBD - Daftar Standar Satuan Harga';
$data['main_content']='ssh_view';
$data['akses'] = $this->auth->get_level_akses($this->uri->slash_segment(1));
$data['modul'] = 'ssh';
$data['report_daftar'] = $this->report_daftar;
$data['grid']['fields'] = $this->data_model->get_data_fields();
$this->load->view('layout/template',$data);
}
public function entry()
{
$data['title']='SIPAPBD - Entri Standar Satuan Harga';
$data['main_content']='ssh_form';
//$data['akses'] = $this->auth->get_level_akses($this->uri->slash_segment(1));
$this->load->view('layout/template',$data);
}
public function proses_form()
{
$id = $this->input->post('id');
$oper = $this->input->post('oper');
if($oper == 'del')
{
$this->hapus($id);
return '';
}
$this->form_validation->set_rules('SATUAN','SATUAN','required|trim');
$this->form_validation->set_rules('HARGA','HARGA','required|trim');
$respon = (object) NULL;
if($this->form_validation->run() == TRUE)
{
$exist = $this->data_model->cek_exist();
if($exist > 0)
{
$changed = $this->data_model->cek_changed();
if($changed ==1 || $this->input->post('param')==1){
if($oper == 'edit'){
$this->data_model->update_data($id);
$respon->isSuccess = TRUE;
$respon->message = 'Data sudah di ubah';
$respon->sql = $this->db->queries;
$respon->id = $this->input->post('id');
$respon->last_changed = $this->data_model->last_changed;
}
}
else{
$respon->isSuccess = FALSE;
$respon->message = 'Data sudah dirubah user lain';
$respon->error = 'changed';
$respon->id = $this->input->post('id');
$respon->last_changed = $this->data_model->last_changed;
$respon->selisih = timeAgo($changed);
$respon->sql = $this->db->queries;
}
}
else{
$respon->sql = $this->db->queries;
$respon->isSuccess = FALSE;
$respon->message = 'Data sudah dihapus user lain';
$respon->error = 'hapus';
$respon->id = $this->input->post('id');
$respon->sql = $this->db->queries;
}
}
else
{
$respon->sql = $this->db->queries;
$respon->isSuccess = TRUE;
$respon->message = 'Data gagal di ubah';
}
echo json_encode($respon);
}
public function form($id = '')
{
$binary ='';
$data['user_data']['DATA_DASAR_LOGIN'] = $this->session->userdata('DATA_DASAR_LOGIN');
$data['DATA_DASAR_LOGIN'] = $this->session->userdata('DATA_DASAR_LOGIN');
$data['title']='Entri Standar Satuan Harga';
$data['main_content']='ssh_form';
if($id)
{
$rows=$this->data_model->get_data_by_id($id);
$data['user_data'] = $this->data_model->get_data_by_id($id);
}
$this->load->view('layout/template',$data);
}
public function get_data_skpd()
{
$rows = $this->data_model->get_data_skpd();
$response->kode = $rows['KODE_SKPD_LKP'];
$response->nama = $rows['NAMA_SKPD'];
$response->id = $rows['ID_SKPD'];
echo json_encode($response);
}
public function proses()
{
$respon = (object) NULL;
$proses = $this->data_model->insert_data();
if(!$proses)
{
$respon->isSuccess = TRUE;
$respon->message = 'Data berhasil disimpan';
}
else
{
$respon->isSuccess = FALSE;
$respon->message = 'Data gagal disimpan';
}
echo json_encode($respon);
}
private function update()
{
$id = $this->input->post('id');
$update = $this->data_model->update_data($id);
return $update;
}
public function get_daftar()
{
$page = $_REQUEST['page']; // get the requested page
$limit = $_REQUEST['rows']; // get how many rows we want to have into the grid
$sidx = $_REQUEST['sidx']; // get index row - i.e. user click to sort
$sord = $_REQUEST['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') : '';
$req_param = array (
"sort_by" => $sidx,
"sort_direction" => $sord,
"limit" => null,
"search_mode" => $mode,
"q" => $q,
);
$count = $this->data_model->get_data($req_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;
$req_param['limit'] = array(
'start' => $start,
'end' => $limit
);
$result = $this->data_model->get_data($req_param);
$response->page = $page;
$response->total = $total_pages;
$response->records = $count;
for($i=0; $i<count($result); $i++){
$response->rows[$i]['id'] = $result[$i]['ID_SSH'];
$response->rows[$i]['cell'] = array($result[$i]['ID_SSH'],
$result[$i]['ID_REKENING'],
$result[$i]['KODE_REKENING'],
$result[$i]['NAMA_REKENING'],
$result[$i]['KATEGORI'],
$result[$i]['URAIAN'],
$result[$i]['KODE_STANDAR'],
$result[$i]['SATUAN'],
$result[$i]['HARGA'],
$result[$i]['LAST_CHANGED'],
$result[$i]['PARAM']
);
}
echo json_encode($response);
}
public function pilih_rekening()
{
$this->load->view('rek_pilih');
}
public function get_rek()
{
if(!isset($_POST['oper']))
{
$page = $_REQUEST['page']; // get the requested page
$limit = $_REQUEST['rows']; // get how many rows we want to have into the grid
$sidx = $_REQUEST['sidx']; // get index row - i.e. user click to sort
$sord = $_REQUEST['sord']; // get the direction if(!$sidx) $sidx =1;
$req_param = array (
"sort_by" => $sidx,
"sort_direction" => $sord,
"limit" => null,
"search" => $_REQUEST['_search'],
"search_field" => isset($_REQUEST['searchField'])?$_REQUEST['searchField']:null,
"search_operator" => isset($_REQUEST['searchOper'])?$_REQUEST['searchOper']:null,
"search_str" => isset($_REQUEST['searchString'])?$_REQUEST['searchString']:null
);
$row = $this->data_model->get_pilih($req_param)->result_array();
$count = count($row);
if( $count >0 ) {
$total_pages = ceil($count/$limit);
} else {
$total_pages = 0;
}
if ($page > $total_pages)
$page=$total_pages;
$start = $limit*$page - $limit; // do not put $limit*($page - 1)
if($start <0) $start = 0;
$req_param['limit'] = array(
'start' => $start,
'end' => $limit
);
$response = (object) NULL;
$result = $this->data_model->get_pilih($req_param)->result_array();
// sekarang format data dari dB sehingga sesuai yang diinginkan oleh jqGrid dalam hal ini pakai JSON format
$response->page = $page;
$response->total = $total_pages;
$response->records = $count;
for($i=0; $i<count($result); $i++)
{
$response->rows[$i]['id'] = $result[$i]['ID_REKENING'];
$response->rows[$i]['cell'] = array($result[$i]['ID_REKENING'],
$result[$i]['ID_PARENT_REKENING'],
$result[$i]['KODE_REKENING'],
$result[$i]['NAMA_REKENING'],
$result[$i]['LEVEL_REKENING']
);
}
echo json_encode($response);
}
}
public function get_satuan()
{
$response = (object) NULL;
$q = strtolower($_GET["term"]);
$rows = $this->data_model->get_opt_satuan($q);
for($i=0; $i<count($rows); $i++)
{
$response[$i]->label = $rows[$i]['NAMA_SATUAN'];
}
echo json_encode($response);
}
}