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_jpt(){ $q = "SELECT * FROM jpt ORDER BY kdjnspt"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_jpt(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('jpt',$dataArray); $this->rhlib->insertRecordPublic('jpt',$dataArray); return $ret; } function update_jpt(){ $fieldsAndValues = $this->getFieldsAndValues(); //UPDATE $where['idjnspt'] = $_POST['idjnspt']; $this->db->where('idjnspt', $_POST['idjnspt']); $this->db->update('jpt', $fieldsAndValues); if($this->db->affected_rows()){ $ret["success"]=true; $ret["msg"]='Update Data Berhasil'; $this->rhlib->updateRecordPublic('jpt',$fieldsAndValues,$where); }else{ $ret["success"]=false; $ret["msg"]= 'Update Data Gagal'; } return $ret; } function delete_jpt(){ $where['idjnspt'] = $_POST['idjnspt']; $ret = $this->rhlib->deleteRecord('jpt',$where); $this->rhlib->deleteRecordPublic('jpt',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'kdjnspt'=> $_POST['kdjnspt'], 'nmjnspt'=> $_POST['nmjnspt'], 'deskripsi'=> $_POST['deskripsi'] ); return $dataArray; } } ?>