load->library('session'); $this->load->library('rhlib'); } function retValOrNull($val){ //especially for combo & looukup with no item selected $val = ($val=='')? null : $val; return $val; } function get_jabatan(){ $q = "SELECT * FROM jabatan ORDER BY idjabatan"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_jabatan(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('jabatan',$dataArray); return $ret; } function update_jabatan(){ $dataArray = $this->getFieldsAndValues(); //UPDATE $this->db->where('idjabatan', $_POST['idjabatan']); $this->db->update('jabatan', $dataArray); if($this->db->affected_rows()){ $ret["success"]=true; $ret["msg"]='Update Data Berhasil'; }else{ $ret["success"]=false; $ret["msg"]= 'Update Data Gagal'; } return $ret; } function delete_jabatan(){ $where['idjabatan'] = $_POST['idjabatan']; $ret = $this->rhlib->deleteRecord('jabatan',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'kdjabatan' => $_POST['kdjabatan'], 'nmjabatan'=> $_POST['nmjabatan'], ); return $dataArray; } } ?>