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_klpruangan(){ $q = "SELECT * FROM klpruangan ORDER BY kdklpruangan"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_klpruangan(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('klpruangan',$dataArray); return $ret; } function update_klpruangan(){ $fieldsAndValues = $this->getFieldsAndValues(); //UPDATE $this->db->where('idklpruangan', $_POST['idklpruangan']); $this->db->update('klpruangan', $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_klpruangan(){ $where['idklpruangan'] = $_POST['idklpruangan']; $ret = $this->rhlib->deleteRecord('klpruangan',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'kdklpruangan'=> $_POST['kdklpruangan'], 'nmklpruangan'=> $_POST['nmklpruangan'], 'deskripsi'=> $_POST['deskripsi'] ); return $dataArray; } } ?>