load->library('session'); $this->load->library('rhlib'); } function jsonFromQuery($q) { $this->rhlib->jsonFromQuery($q); } function jsonFromQueryWLimit($q){ $this->rhlib->jsonFromQueryWLimit($q); } function retValOrNull($val){ //especially for combo & looukup with no item selected $val = ($val=='')? null : $val; return $val; } function retValOrZero($val){ $val = ($val=='')? 0 : $val; return $val; } function get_stdossemester(){ $kdprodi = $_POST['kdprodi']; $kdstsemester = $_POST['kdstsemester']; $q = "SELECT a.*, b.nmstaktivitasdos, c.kdjnskelamin, c.nidn, concat(nmdostpgelar,',',gelartertinggi) as `nmdos` FROM stdossemester a LEFT JOIN (SELECT kdkodtbkod as kode, nmkodtbkod as nmstaktivitasdos FROM tbkod WHERE kdapltbkod='15') b ON b.kode=a.kdstaktivitasdosen LEFT JOIN dosen c ON c.nidu=a.nidu WHERE c.kdprodi='".$kdprodi."' and a.kdstsemester='".$kdstsemester."'"; $this->jsonFromQueryWLimit($q); } function insert_stdossemester(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('stdossemester',$dataArray); $this->update_stat_dos(); return $ret; } function update_stdossemester(){ $dataArray = $this->getFieldsAndValues(); //UPDATE $this->db->where('idstdossemester', $_POST['idstdossemester']); $this->db->update('stdossemester', $dataArray); if($this->db->affected_rows()){ $ret["success"]=true; $ret["msg"]='Update Data Berhasil'; $this->update_stat_dos(); }else{ $ret["success"]=false; $ret["msg"]= 'Update Data Gagal'; } return $ret; } function update_stat_dos(){ $dataArray = array( 'kdstaktivitasdosen'=> $_POST['kdaktivitasdosen'], ); //UPDATE $this->db->where('nidu', $_POST['nidu']); $this->db->update('dosen', $dataArray); 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 getFieldsAndValues(){ $dataArray = array( 'nidu'=> $_POST['nidu'], 'kdprodi'=> $_POST['kdprodi'], 'kdstsemester'=> $_POST['kdsemester'], 'kdjenjangstudi'=> $_POST['kdjstudi'], 'kdstaktivitasdosen'=> $_POST['kdaktivitasdosen'], 'keterangan'=> $_POST['keterangan'], ); return $dataArray; } function delete_stdossemester(){ $where['idstdossemester'] = $_POST['idstdossemester']; $ret = $this->rhlib->deleteRecord('stdossemester',$where); return $ret; } function copy_stdossemester(){ $kdprodi = $_POST['kdprodi']; $smtbaru = $_POST['smtbaru']; $smtlama = $_POST['smtlama']; $sql = "INSERT stdossemester(kdprodi,nidu,kdstsemester,kdjenjangstudi,kdstaktivitasdosen,keterangan) SELECT kdprodi,nidu,".$smtbaru.",kdjenjangstudi,kdstaktivitasdosen,keterangan FROM stdossemester WHERE kdprodi='".$kdprodi."' and kdstsemester='".$smtlama."'"; $exec = $this->db->query($sql); if($this->db->affected_rows()){ $ret["success"]=true; $ret["msg"]='Copy Data Berhasil'; }else{ $ret["success"]=false; $ret["msg"]= 'Copy Data Gagal'; } return $ret; } } ?>