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_stkuitansi(){ $q = "SELECT * FROM stkuitansi ORDER BY kdstkuitansi"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_stkuitansi(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('stkuitansi',$dataArray); $this->rhlib->insertRecordPublic('stkuitansi',$dataArray); return $ret; } function update_stkuitansi(){ $fieldsAndValues = $this->getFieldsAndValues(); //UPDATE $where['idstkuitansi'] = $_POST['idstkuitansi']; $this->db->where('idstkuitansi', $_POST['idstkuitansi']); $this->db->update('stkuitansi', $fieldsAndValues); if($this->db->affected_rows()){ $ret["success"]=true; $ret["msg"]='Update Data Berhasil'; $this->rhlib->updateRecordPublic('stkuitansi',$fieldsAndValues,$where); }else{ $ret["success"]=false; $ret["msg"]= 'Update Data Gagal'; } return $ret; } function delete_stkuitansi(){ $where['idstkuitansi'] = $_POST['idstkuitansi']; $ret = $this->rhlib->deleteRecord('stkuitansi',$where); $this->rhlib->deleteRecordPublic('stkuitansi',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'kdstkuitansi'=> $_POST['kdstkuitansi'], 'nmstkuitansi'=> $_POST['nmstkuitansi'], 'deskripsi'=> $_POST['deskripsi'] ); return $dataArray; } } ?>