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_stkrs(){ $q = "SELECT * FROM stkrs ORDER BY kdstkrs"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_stkrs(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('stkrs',$dataArray); return $ret; } function update_stkrs(){ $fieldsAndValues = $this->getFieldsAndValues(); //UPDATE $this->db->where('idstkrs', $_POST['idstkrs']); $this->db->update('stkrs', $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_stkrs(){ $where['idstkrs'] = $_POST['idstkrs']; $ret = $this->rhlib->deleteRecord('stkrs',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'kdstkrs'=> $_POST['kdstkrs'], 'nmstkrs'=> $_POST['nmstkrs'], ); return $dataArray; } } ?>