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_sttahapan(){ $q = "SELECT * FROM sttahapan ORDER BY kdsttahapan"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_sttahapan(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('sttahapan',$dataArray); return $ret; } function update_sttahapan(){ $fieldsAndValues = $this->getFieldsAndValues(); //UPDATE $this->db->where('idsttahapan', $_POST['idsttahapan']); $this->db->update('sttahapan', $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_sttahapan(){ $where['idsttahapan'] = $_POST['idsttahapan']; $ret = $this->rhlib->deleteRecord('sttahapan',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'kdsttahapan'=> $_POST['kdsttahapan'], 'nmsttahapan'=> $_POST['nmsttahapan'] ); return $dataArray; } } ?>