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_jdiskon(){ $q = "SELECT * FROM jdiskon ORDER BY kdjnsdiskon"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_jdiskon(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('jdiskon',$dataArray); return $ret; } function update_jdiskon(){ $fieldsAndValues = $this->getFieldsAndValues(); //UPDATE $this->db->where('idjnsdiskon', $_POST['idjnsdiskon']); $this->db->update('jdiskon', $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_jdiskon(){ $where['idjnsdiskon'] = $_POST['idjnsdiskon']; $ret = $this->rhlib->deleteRecord('jdiskon',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'kdjnsdiskon'=> $_POST['kdjnsdiskon'], 'nmdiskon'=> $_POST['nmdiskon'], 'deskripsi'=> $_POST['deskripsi'], 'nominal'=> $_POST['nominal'] ); return $dataArray; } } ?>