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_stsemester(){ $q = "SELECT a.kdstsemester, a.idthnakademik, b.kdthnakademik, b.nmthnakademik, a.idjnssemester, c.kdjnssemester, c.nmjnssemester, a.idstatus, d.nmstatus, a.deskripsi FROM stsemester a LEFT JOIN thnakademik b ON a.idthnakademik=b.idthnakademik LEFT JOIN jsemester c ON a.idjnssemester=c.idjnssemester LEFT JOIN status d ON a.idstatus=d.idstatus ORDER BY a.kdstsemester DESC"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_stsemester(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('stsemester',$dataArray); $this->rhlib->insertRecordPublic('stsemester',$dataArray); return $ret; } function update_stsemester(){ $fieldsAndValues = $this->getFieldsAndValues(); //UPDATE $where['kdstsemester'] = $_POST['kdstsemester']; $this->db->where('kdstsemester', $_POST['kdstsemester']); $this->db->update('stsemester', $fieldsAndValues); if($this->db->affected_rows()){ $ret["success"]=true; $ret["msg"]='Update Data Berhasil'; $this->rhlib->updateRecordPublic('stsemester',$fieldsAndValues,$where); }else{ $ret["success"]=false; $ret["msg"]= 'Update Data Gagal'; } return $ret; } function delete_stsemester(){ $where['kdstsemester'] = $_POST['kdstsemester']; $ret = $this->rhlib->deleteRecord('stsemester',$where); $this->rhlib->deleteRecordPublic('stsemester',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'kdstsemester'=> $_POST['kdstsemester'], 'idthnakademik'=> $_POST['idthnakademik'], 'idjnssemester'=> $_POST['idjnssemester'], 'idstatus'=> $_POST['idstatus'], 'deskripsi'=> $_POST['deskripsi'] ); return $dataArray; } function cekaktifsmt(){ $q = "SELECT count(kdstsemester) as jml FROM stsemester WHERE idstatus=1"; $query = $this->db->query($q); $count= ''; $row = $query->row(); $count=$row->jml; echo $count; } } ?>