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_jbiaya(){ $q = "SELECT * FROM jbiaya ORDER BY kdjnsbiaya"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_jbiaya(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('jbiaya',$dataArray); return $ret; } function update_jbiaya(){ $fieldsAndValues = $this->getFieldsAndValues(); //UPDATE $this->db->where('idjnsbiaya', $_POST['idjnsbiaya']); $this->db->update('jbiaya', $fieldsAndValues); 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_jbiaya(){ $where['idjnsbiaya'] = $_POST['idjnsbiaya']; $ret = $this->rhlib->deleteRecord('jbiaya',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'kdjnsbiaya'=> $_POST['kdjnsbiaya'], 'nmjnsbiaya'=> $_POST['nmjnsbiaya'], 'deskripsi'=> $_POST['deskripsi'], 'kodebank'=> $this->retValOrNull($_POST['kodebank']) ); return $dataArray; } } ?>