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_klsprodi(){ $q = "SELECT a.*, b.nmprodi, c.nmklsmhs, d.nmstatus FROM klsprodi a LEFT JOIN prodi b ON b.kdprodi=a.kdprodi LEFT JOIN klsmhs c ON c.idklsmhs=a.idklsmhs LEFT JOIN status d ON d.idstatus=a.idstatus"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_klsprodi(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('klsprodi',$dataArray); $this->rhlib->insertRecordPublic('klsprodi',$dataArray); return $ret; } function update_klsprodi(){ $fieldsAndValues = $this->getFieldsAndValues(); //UPDATE $where['kdprodi'] = $_POST['kdprodi']; $where['idklsmhs'] = $_POST['idklsmhs']; $this->db->where('kdprodi', $_POST['kdprodi']); $this->db->where('idklsmhs', $_POST['idklsmhs']); $this->db->update('klsprodi', $fieldsAndValues); if($this->db->affected_rows()){ $ret["success"]=true; $ret["msg"]='Update Data Berhasil'; $this->rhlib->updateRecordPublic('klsprodi',$fieldsAndValues,$where); }else{ $ret["success"]=false; $ret["msg"]= 'Update Data Gagal'; } return $ret; } function delete_klsprodi(){ $where['kdprodi'] = $_POST['kdprodi']; $where['idklsmhs'] = $_POST['idklsmhs']; $ret = $this->rhlib->deleteRecord('klsprodi',$where); $this->rhlib->deleteRecordPublic('klsprodi',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'kdprodi'=> $_POST['kdprodi'], 'idklsmhs'=> $_POST['idklsmhs'], 'idstatus'=> $_POST['idstatus'], ); return $dataArray; } } ?>