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_jruangan(){ $q = "SELECT * FROM jruangan ORDER BY kdjnsruangan"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_jruangan(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('jruangan',$dataArray); return $ret; } function update_jruangan(){ $fieldsAndValues = $this->getFieldsAndValues(); //UPDATE $this->db->where('idjnsruangan', $_POST['idjnsruangan']); $this->db->update('jruangan', $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_jruangan(){ $where['idjnsruangan'] = $_POST['idjnsruangan']; $ret = $this->rhlib->deleteRecord('jruangan',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'kdjnsruangan'=> $_POST['kdjnsruangan'], 'nmjnsruangan'=> $_POST['nmjnsruangan'], 'deskripsi'=> $_POST['deskripsi'] ); return $dataArray; } } ?>